|
8 | 8 |
|
9 | 9 | #include "ParameterDlgSettings.h" |
10 | 10 | #include "ui_ParameterDlgSettings.h" |
11 | | -#include "mainwindow.h" |
12 | | -#include "RabbitCommonDir.h" |
13 | 11 |
|
14 | 12 | #ifdef HAVE_ICE |
15 | 13 | #include "Ice.h" |
|
18 | 16 | static Q_LOGGING_CATEGORY(log, "App.MainWindow.Parameter") |
19 | 17 |
|
20 | 18 | CParameterDlgSettings::CParameterDlgSettings(CParameterApp *pPara, |
21 | | - QList<QWidget *> wViewer, |
22 | 19 | QWidget *parent) : |
23 | 20 | QDialog(parent), |
24 | 21 | ui(new Ui::CParameterDlgSettings), |
25 | 22 | m_pParameters(pPara) |
26 | 23 | { |
27 | 24 | ui->setupUi(this); |
28 | 25 |
|
29 | | - int nWidth = 0; |
30 | | - int nHeigth = 0; |
31 | | - foreach(auto p, wViewer) { |
32 | | - if(!p) continue; |
33 | | - nWidth = qMax(nWidth, p->frameSize().width()); |
34 | | - nHeigth = qMax(nHeigth, p->frameSize().height()); |
35 | | - } |
36 | | - bool bScroll = false; |
37 | | - QScreen* pScreen = QApplication::primaryScreen(); |
38 | | - QSize size = this->size(); |
39 | | - if(nWidth > size.width() || nHeigth > size.height()) |
40 | | - bScroll = true; |
41 | | - // [connect accepted to slotAccept of widget] |
42 | | - foreach(auto p, wViewer) |
43 | | - { |
44 | | - QString szMsg; |
45 | | - QWidget* pView = p; |
46 | | - if(bScroll) |
47 | | - { |
48 | | - QScrollArea* pScroll = new QScrollArea(ui->tabWidget); |
49 | | - if(!pScroll) continue; |
50 | | - pScroll->setWidget(p); |
51 | | - pView = pScroll; |
52 | | - } |
53 | | - ui->tabWidget->addTab(pView, p->windowIcon(), p->windowTitle()); |
54 | | - bool check = false; |
55 | | - check = connect(this, SIGNAL(accepted()), p, SLOT(slotAccept())); |
56 | | - if(!check) |
57 | | - { |
58 | | - szMsg = "Class" + QString(p->metaObject()->className()) |
59 | | - + "must has slot slotAccept(), please add it. " |
60 | | - + "Or the class derived from CParameterUI"; |
61 | | - qCritical(log) << szMsg; |
62 | | - } |
63 | | - Q_ASSERT_X(check, "CParameterDlgSettings", szMsg.toStdString().c_str()); |
64 | | - } |
65 | | - // [connect accepted to slotAccept of widget] |
66 | | - |
67 | 26 | #ifdef HAVE_ICE |
68 | 27 | QWidget* pWidget = CICE::Instance()->GetParameterWidget(this); |
69 | 28 | if(pWidget) |
@@ -135,6 +94,47 @@ CParameterDlgSettings::~CParameterDlgSettings() |
135 | 94 | delete ui; |
136 | 95 | } |
137 | 96 |
|
| 97 | +void CParameterDlgSettings::SetViewers(const QList<QWidget *> &wViewer) |
| 98 | +{ |
| 99 | + int nWidth = 0; |
| 100 | + int nHeigth = 0; |
| 101 | + foreach(auto p, wViewer) { |
| 102 | + if(!p) continue; |
| 103 | + nWidth = qMax(nWidth, p->frameSize().width()); |
| 104 | + nHeigth = qMax(nHeigth, p->frameSize().height()); |
| 105 | + } |
| 106 | + bool bScroll = false; |
| 107 | + QScreen* pScreen = QApplication::primaryScreen(); |
| 108 | + QSize size = this->size(); |
| 109 | + if(nWidth > size.width() || nHeigth > size.height()) |
| 110 | + bScroll = true; |
| 111 | + // [connect accepted to slotAccept of widget] |
| 112 | + foreach(auto p, wViewer) |
| 113 | + { |
| 114 | + QString szMsg; |
| 115 | + QWidget* pView = p; |
| 116 | + if(bScroll) |
| 117 | + { |
| 118 | + QScrollArea* pScroll = new QScrollArea(ui->tabWidget); |
| 119 | + if(!pScroll) continue; |
| 120 | + pScroll->setWidget(p); |
| 121 | + pView = pScroll; |
| 122 | + } |
| 123 | + ui->tabWidget->addTab(pView, p->windowIcon(), p->windowTitle()); |
| 124 | + bool check = false; |
| 125 | + check = connect(this, SIGNAL(accepted()), p, SLOT(slotAccept())); |
| 126 | + if(!check) |
| 127 | + { |
| 128 | + szMsg = "Class" + QString(p->metaObject()->className()) |
| 129 | + + "must has slot slotAccept(), please add it. " |
| 130 | + + "Or the class derived from CParameterUI"; |
| 131 | + qCritical(log) << szMsg; |
| 132 | + } |
| 133 | + Q_ASSERT_X(check, "CParameterDlgSettings", szMsg.toStdString().c_str()); |
| 134 | + } |
| 135 | + // [connect accepted to slotAccept of widget] |
| 136 | +} |
| 137 | + |
138 | 138 | void CParameterDlgSettings::on_pbOk_clicked() |
139 | 139 | { |
140 | 140 | if(!m_pParameters) return; |
|
0 commit comments