Rabbit Remote Control 0.0.33
Loading...
Searching...
No Matches
FrmParameterClient.cpp
1#include "FrmParameterClient.h"
2#include "ui_FrmParameterClient.h"
3#include <RabbitCommonTools.h>
4
5CFrmParameterClient::CFrmParameterClient(QWidget *parent) :
6 CParameterUI(parent),
7 ui(new Ui::CFrmParameterClient),
8 m_pPara(nullptr)
9{
10 ui->setupUi(this);
11 if(RabbitCommon::CTools::HasAdministratorPrivilege()) {
12 ui->cbHookKeyboard->setText(
13 tr("Hook: capture system key"));
14 ui->cbShowHookAdminPrivilege->setText("");
15 ui->cbShowHookAdminPrivilege->hide();
16 } else {
17 ui->cbHookKeyboard->setText(
18 tr("Hook: capture system key(System shortcuts is need administrator privilege)"));
19 ui->cbShowHookAdminPrivilege->setText(
20 tr("Hook: show restart program with administrator privilege"));
21 ui->cbShowHookAdminPrivilege->show();
22 }
23}
24
25CFrmParameterClient::~CFrmParameterClient()
26{
27 delete ui;
28}
29
31{
32 if(!m_pPara)
33 return -1;
34 m_pPara->SetHookKeyboard(ui->cbHookKeyboard->isChecked());
35 m_pPara->SetHookShowAdministratorPrivilege(ui->cbShowHookAdminPrivilege->isChecked());
36 m_pPara->SetEnableSystemUserToUser(ui->cbEnableUserName->isChecked());
37 m_pPara->SetAdaptWindows((CFrmViewer::ADAPT_WINDOWS)ui->cbViewZoom->currentData().toInt());
38
39 m_pPara->SetEncryptKey(ui->leEncryptKey->text());
40 m_pPara->SetSavePassword(ui->cbSavePassword->isChecked());
41 m_pPara->SetViewPassowrd(ui->cbEnableViewPassword->isChecked());
42 if(ui->rbPromptAlways->isChecked())
43 m_pPara->SetPromptType(CParameterClient::PromptType::Always);
44 if(ui->rbPromptFirst->isChecked())
45 m_pPara->SetPromptType(CParameterClient::PromptType::First);
46 if(ui->rbPromptNo->isChecked())
47 m_pPara->SetPromptType(CParameterClient::PromptType::No);
48 m_pPara->SetShowProtocolPrefix(ui->cbShowPrefix->isChecked());
49 m_pPara->SetShowIpPortInName(ui->cbShowIPPort->isChecked());
50 return 0;
51}
52
53void CFrmParameterClient::on_cbEnableViewPassword_clicked(bool checked)
54{
55 ui->pbEncryptKey->setEnabled(checked);
56}
57
58void CFrmParameterClient::on_pbEncryptKey_clicked()
59{
60 switch(ui->leEncryptKey->echoMode())
61 {
62 case QLineEdit::Password:
63 ui->leEncryptKey->setEchoMode(QLineEdit::Normal);
64 ui->pbEncryptKey->setIcon(QIcon::fromTheme("eye-off"));
65 break;
66 case QLineEdit::Normal:
67 ui->leEncryptKey->setEchoMode(QLineEdit::Password);
68 ui->pbEncryptKey->setIcon(QIcon::fromTheme("eye-on"));
69 break;
70 default:
71 break;
72 }
73}
74
76{
77 m_pPara = qobject_cast<CParameterClient*>(pParameter);
78 if(!m_pPara)
79 return -1;
80 ui->cbHookKeyboard->setChecked(m_pPara->GetHookKeyboard());
81 ui->cbShowHookAdminPrivilege->setChecked(m_pPara->GetHookShowAdministratorPrivilege());
82 ui->cbEnableUserName->setChecked(m_pPara->GetEnableSystemUserToUser());
83
84 ui->cbViewZoom->addItem(QIcon::fromTheme("zoom-original"),
85 tr("Original"),
87 /*ui->cbViewZoom->addItem(tr("Original Center"),
88 (int)CFrmViewer::ADAPT_WINDOWS::OriginalCenter);*/
89 ui->cbViewZoom->addItem(QIcon::fromTheme("zoom"), tr("Zoom"),
91 ui->cbViewZoom->addItem(QIcon::fromTheme("zoom-fit-best"),
92 tr("Zoom to window"),
94 ui->cbViewZoom->addItem(QIcon::fromTheme("zoom-aspect-ratio"),
95 tr("Keep desktop aspectration adapt to windows"),
97 int nIndex = ui->cbViewZoom->findData((int)m_pPara->GetAdaptWindows());
98 if(-1 != nIndex)
99 ui->cbViewZoom->setCurrentIndex(nIndex);
100
101 ui->leEncryptKey->setText(m_pPara->GetEncryptKey());
102 ui->cbSavePassword->setChecked(m_pPara->GetSavePassword());
103 ui->cbEnableViewPassword->setChecked(m_pPara->GetViewPassowrd());
104 ui->pbEncryptKey->setEnabled(ui->cbEnableViewPassword->isChecked());
105 switch (m_pPara->GetPromptType()) {
106 case CParameterClient::PromptType::Always:
107 ui->rbPromptAlways->setChecked(true);
108 break;
109 case CParameterClient::PromptType::First:
110 ui->rbPromptFirst->setChecked(true);
111 break;
112 case CParameterClient::PromptType::No:
113 ui->rbPromptNo->setChecked(true);
114 break;
115 }
116 ui->cbShowPrefix->setChecked(m_pPara->GetShowProtocolPrefix());
117 ui->cbShowIPPort->setChecked(m_pPara->GetShowIpPortInName());
118 return 0;
119}
virtual int Accept() override
Accept parameters.
virtual int SetParameter(CParameter *pParameter) override
Set the parameters and initialize the user interface.
ADAPT_WINDOWS
The ADAPT_WINDOWS enum.
Definition FrmViewer.h:61
@ Original
Original desktop size, the left-top of the desktop is aligned with the left-top of the window.
@ Zoom
zoom windows = desktop size * factor
@ KeepAspectRationToWindow
Keep desktop aspectration adapt to windows.
@ ZoomToWindow
Desktop adapt to windows.
The parameter UI interface.
Definition ParameterUI.h:15
Parameter interface.
Definition Parameter.h:169