Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterDlgSettings.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include "ParameterDlgSettings.h"
4#include "ui_ParameterDlgSettings.h"
5#include "mainwindow.h"
6#include "RabbitCommonDir.h"
7
8#ifdef HAVE_ICE
9#include "Ice.h"
10#endif
11
12#include <QFileDialog>
13#include <QLoggingCategory>
14
15static Q_LOGGING_CATEGORY(log, "App.MainWindow.Parameter")
16
18 QList<QWidget *> wViewer,
19 QWidget *parent) :
20 QDialog(parent),
22 m_pParameters(pPara)
23{
24 ui->setupUi(this);
25
26 // [connect accepted to slotAccept of widget]
27 foreach(auto p, wViewer)
28 {
29 ui->tabWidget->addTab(p, p->windowIcon(), p->windowTitle());
30 bool check = false;
31 check = connect(this, SIGNAL(accepted()), p, SLOT(slotAccept()));
32 if(!check)
33 {
34 qCritical(log) << "Class" << p->metaObject()->className()
35 << "must has slot slotAccept(), please add it";
36 }
37 Q_ASSERT(check);
38 }
39 // [connect accepted to slotAccept of widget]
40
41#ifdef HAVE_ICE
42 QWidget* pWidget = CICE::Instance()->GetParameterWidget(this);
43 if(pWidget)
44 {
45 ui->tabWidget->addTab(pWidget, pWidget->windowTitle());
46 bool check = false;
47 check = connect(this, SIGNAL(accepted()),
48 pWidget, SLOT(slotAccept()));
49 if(!check)
50 {
51 qCritical(log) << "Class" << pWidget->metaObject()->className()
52 << "must has slot slotAccept(), please add it";
53 }
54 Q_ASSERT(check);
55 }
56#endif
57
58 ui->cbReciverShortCut->setChecked(m_pParameters->GetReceiveShortCut());
59 ui->cbSaveMainWindowStatus->setChecked(m_pParameters->GetSaveMainWindowStatus());
60 ui->cbResumLasterClose->setChecked(m_pParameters->GetOpenLasterClose());
61
62 switch (m_pParameters->GetTabPosition()) {
63 case QTabWidget::North:
64 ui->rbNorth->setChecked(true);
65 break;
66 case QTabWidget::South:
67 ui->rbSouth->setChecked(true);
68 break;
69 case QTabWidget::West:
70 ui->rbWest->setChecked(true);
71 break;
72 case QTabWidget::East:
73 ui->rbEast->setChecked(true);
74 break;
75 }
76 ui->cbTabToolTip->setChecked(m_pParameters->GetEnableTabToolTip());
77 ui->cbTabIcon->setChecked(m_pParameters->GetEnableTabIcon());
78
79 ui->sbRecentMenuMaxCount->setValue(m_pParameters->GetRecentMenuMaxCount());
80
81 switch (m_pParameters->GetSystemTrayIconMenuType()) {
82 case CParameterApp::SystemTrayIconMenuType::No:
83 ui->rbSystemTrayIconNo->setChecked(true);
84 break;
85 case CParameterApp::SystemTrayIconMenuType::MenuBar:
86 ui->rbMenuBar->setChecked(true);
87 break;
88 case CParameterApp::SystemTrayIconMenuType::RecentOpen:
89 ui->rbSystemTrayIconRecentOpen->setChecked(true);
90 break;
91 case CParameterApp::SystemTrayIconMenuType::Remote:
92 ui->rbSystemTrayIconRemote->setChecked(true);
93 break;
94 default:
95 break;
96 }
97 ui->cbShowSystemTrayIcon->setChecked(m_pParameters->GetEnableSystemTrayIcon());
98
99 ui->cbFavoriteDoubleEdit->setChecked(m_pParameters->GetFavoriteEdit());
100 ui->cbMessageBoxDisplayInfo->setChecked(m_pParameters->GetMessageBoxDisplayInformation());
101}
102
103CParameterDlgSettings::~CParameterDlgSettings()
104{
105 delete ui;
106}
107
108void CParameterDlgSettings::on_pbOk_clicked()
109{
110 if(!m_pParameters) return;
111
112 m_pParameters->SetReceiveShortCut(ui->cbReciverShortCut->isChecked());
113 m_pParameters->SetSaveMainWindowStatus(ui->cbSaveMainWindowStatus->isChecked());
114 m_pParameters->SetOpenLasterClose(ui->cbResumLasterClose->isChecked());
115
116 if(ui->rbNorth->isChecked()) m_pParameters->SetTabPosition(QTabWidget::North);
117 if(ui->rbSouth->isChecked()) m_pParameters->SetTabPosition(QTabWidget::South);
118 if(ui->rbEast->isChecked()) m_pParameters->SetTabPosition(QTabWidget::East);
119 if(ui->rbWest->isChecked()) m_pParameters->SetTabPosition(QTabWidget::West);
120 m_pParameters->SetEnableTabToolTip(ui->cbTabToolTip->isChecked());
121 m_pParameters->SetEnableTabIcon(ui->cbTabIcon->isChecked());
122
123 m_pParameters->SetRecentMenuMaxCount(ui->sbRecentMenuMaxCount->value());
124
125 //NOTE: The order cannot be changed
126 m_pParameters->SetEnableSystemTrayIcon(ui->cbShowSystemTrayIcon->isChecked());
127 if(ui->rbSystemTrayIconNo->isChecked())
128 m_pParameters->SetSystemTrayIconMenuType(CParameterApp::SystemTrayIconMenuType::No);
129 if(ui->rbMenuBar->isChecked())
130 m_pParameters->SetSystemTrayIconMenuType(CParameterApp::SystemTrayIconMenuType::MenuBar);
131 if(ui->rbSystemTrayIconRecentOpen->isChecked())
132 m_pParameters->SetSystemTrayIconMenuType(CParameterApp::SystemTrayIconMenuType::RecentOpen);
133 if(ui->rbSystemTrayIconRemote->isChecked())
134 m_pParameters->SetSystemTrayIconMenuType(CParameterApp::SystemTrayIconMenuType::Remote);
135
136 m_pParameters->SetFavoriteEdit(ui->cbFavoriteDoubleEdit->isChecked());
137 m_pParameters->SetMessageBoxDisplayInformation(ui->cbMessageBoxDisplayInfo->isChecked());
138
139 accept();
140}
141
142void CParameterDlgSettings::on_pbNo_clicked()
143{
144 reject();
145}
146
147void CParameterDlgSettings::on_cbShowSystemTrayIcon_toggled(bool checked)
148{
149 ui->gbSystemTrayIconContextMenu->setEnabled(checked);
150}
static CICE * Instance()
Single instance.
Definition Ice.cpp:55