-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
FrmParameterClient.cpp
103 lines (94 loc) · 3.83 KB
/
FrmParameterClient.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "FrmParameterClient.h"
#include "ui_FrmParameterClient.h"
CFrmParameterClient::CFrmParameterClient(QWidget *parent) :
CParameterUI(parent),
ui(new Ui::CFrmParameterClient)
{
ui->setupUi(this);
}
CFrmParameterClient::~CFrmParameterClient()
{
delete ui;
}
int CFrmParameterClient::Accept()
{
if(m_pPara)
return -1;
m_pPara->SetHookKeyboard(ui->cbHookKeyboard->isChecked());
m_pPara->SetEnableSystemUserToUser(ui->cbEnableUserName->isChecked());
m_pPara->SetAdaptWindows((CFrmViewer::ADAPT_WINDOWS)ui->cbViewZoom->currentData().toInt());
m_pPara->SetEncryptKey(ui->leEncryptKey->text());
m_pPara->SetSavePassword(ui->cbSavePassword->isChecked());
m_pPara->SetViewPassowrd(ui->cbEnableViewPassword->isChecked());
if(ui->rbPromptAlways->isChecked())
m_pPara->SetPromptType(CParameterClient::PromptType::Always);
if(ui->rbPromptFirst->isChecked())
m_pPara->SetPromptType(CParameterClient::PromptType::First);
if(ui->rbPromptNo->isChecked())
m_pPara->SetPromptType(CParameterClient::PromptType::No);
m_pPara->SetShowProtocolPrefix(ui->cbShowPrefix->isChecked());
m_pPara->SetShowIpPortInName(ui->cbShowIPPort->isChecked());
return 0;
}
void CFrmParameterClient::on_cbEnableViewPassword_clicked(bool checked)
{
ui->pbEncryptKey->setEnabled(checked);
}
void CFrmParameterClient::on_pbEncryptKey_clicked()
{
switch(ui->leEncryptKey->echoMode())
{
case QLineEdit::Password:
ui->leEncryptKey->setEchoMode(QLineEdit::Normal);
ui->pbEncryptKey->setIcon(QIcon::fromTheme("eye-off"));
break;
case QLineEdit::Normal:
ui->leEncryptKey->setEchoMode(QLineEdit::Password);
ui->pbEncryptKey->setIcon(QIcon::fromTheme("eye-on"));
break;
default:
break;
}
}
int CFrmParameterClient::SetParameter(CParameter *pParameter)
{
m_pPara = qobject_cast<CParameterClient*>(pParameter);
if(m_pPara)
return -1;
ui->cbHookKeyboard->setChecked(m_pPara->GetHookKeyboard());
ui->cbEnableUserName->setChecked(m_pPara->GetEnableSystemUserToUser());
ui->cbViewZoom->addItem(QIcon::fromTheme("zoom-original"),
tr("Original"),
(int)CFrmViewer::ADAPT_WINDOWS::Original);
/*ui->cbViewZoom->addItem(tr("Original Center"),
(int)CFrmViewer::ADAPT_WINDOWS::OriginalCenter);*/
ui->cbViewZoom->addItem(QIcon::fromTheme("zoom"), tr("Zoom"),
(int)CFrmViewer::ADAPT_WINDOWS::Zoom);
ui->cbViewZoom->addItem(QIcon::fromTheme("zoom-fit-best"),
tr("Zoom to window"),
(int)CFrmViewer::ADAPT_WINDOWS::ZoomToWindow);
ui->cbViewZoom->addItem(QIcon::fromTheme("zoom-aspect-ratio"),
tr("Keep desktop aspectration adapt to windows"),
(int)CFrmViewer::ADAPT_WINDOWS::KeepAspectRationToWindow);
int nIndex = ui->cbViewZoom->findData((int)m_pPara->GetAdaptWindows());
if(-1 != nIndex)
ui->cbViewZoom->setCurrentIndex(nIndex);
ui->leEncryptKey->setText(m_pPara->GetEncryptKey());
ui->cbSavePassword->setChecked(m_pPara->GetSavePassword());
ui->cbEnableViewPassword->setChecked(m_pPara->GetViewPassowrd());
ui->pbEncryptKey->setEnabled(ui->cbEnableViewPassword->isChecked());
switch (m_pPara->GetPromptType()) {
case CParameterClient::PromptType::Always:
ui->rbPromptAlways->setChecked(true);
break;
case CParameterClient::PromptType::First:
ui->rbPromptFirst->setChecked(true);
break;
case CParameterClient::PromptType::No:
ui->rbPromptNo->setChecked(true);
break;
}
ui->cbShowPrefix->setChecked(m_pPara->GetShowProtocolPrefix());
ui->cbShowIPPort->setChecked(m_pPara->GetShowIpPortInName());
return 0;
}