Subversion Repositories Code-Repo

Rev

Rev 347 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 347 Rev 348
Line 4... Line 4...
4
{
4
{
5
    sigMapper = new QSignalMapper();
5
    sigMapper = new QSignalMapper();
6
 
6
 
7
    btnExport = new QPushButton("&Export");
7
    btnExport = new QPushButton("&Export");
8
    btnImport = new QPushButton("&Import");
8
    btnImport = new QPushButton("&Import");
9
    btnIncreaseMacro = new QPushButton("&Add");
9
    btnAddMacro = new QPushButton("&Add");
10
    btnDecreaseMacro = new QPushButton("&Remove");
10
    btnRemoveMacro = new QPushButton("&Remove");
11
 
11
 
12
    mainLayout = new QGridLayout();
12
    mainLayout = new QGridLayout();
13
 
13
 
14
    macroCount = 0;
14
    macroCount = 0;
15
    connected = false;
15
    connected = false;
16
    lastKnownFilePath = ".";
16
    lastKnownFilePath = ".";
17
 
17
 
18
    ioLayout = new QHBoxLayout();
18
    ioLayout = new QHBoxLayout();
19
    ioLayout->addStretch();
-
 
20
    ioLayout->addWidget(btnIncreaseMacro);
19
    ioLayout->addWidget(btnAddMacro);
21
    ioLayout->addWidget(btnDecreaseMacro);
20
    ioLayout->addWidget(btnRemoveMacro);
22
    ioLayout->addWidget(btnExport);
21
    ioLayout->addWidget(btnExport);
23
    ioLayout->addWidget(btnImport);
22
    ioLayout->addWidget(btnImport);
-
 
23
    ioLayout->addStretch();
24
    mainLayout->addLayout(ioLayout, 0, 0, 1, 2);
24
    mainLayout->addLayout(ioLayout, 0, 0, 1, 2);
25
 
25
 
26
    for (int i = 0; i < MACRO_DEFAULT_COUNT; i++) {
26
    for (int i = 0; i < MACRO_DEFAULT_COUNT; i++) {
27
        Macro_AddEntry();
27
        Macro_AddEntry();
28
    }
28
    }
29
 
29
 
30
    setLayout(mainLayout);
30
    setLayout(mainLayout);
31
    this->resize(this->minimumSizeHint());
-
 
32
 
31
 
33
    connect(btnIncreaseMacro, SIGNAL(clicked()), this, SLOT(Macro_AddEntry()));
32
    connect(btnAddMacro, SIGNAL(clicked()), this, SLOT(Macro_AddEntry()));
34
    connect(btnDecreaseMacro, SIGNAL(clicked()), this, SLOT(Macro_RemoveEntry()));
33
    connect(btnRemoveMacro, SIGNAL(clicked()), this, SLOT(Macro_RemoveEntry()));
35
    connect(btnExport, SIGNAL(clicked()), this, SLOT(Macro_WriteToFile()));
34
    connect(btnExport, SIGNAL(clicked()), this, SLOT(Macro_WriteToFile()));
36
    connect(btnImport, SIGNAL(clicked()), this, SLOT(Macro_ReadFromFile()));
35
    connect(btnImport, SIGNAL(clicked()), this, SLOT(Macro_ReadFromFile()));
37
    connect(sigMapper, SIGNAL(mapped(QWidget*)), this, SLOT(Macro_InitTransmit(QWidget*)));
36
    connect(sigMapper, SIGNAL(mapped(QWidget*)), this, SLOT(Macro_InitTransmit(QWidget*)));
38
 
-
 
39
    setWindowTitle("Macro Settings");
-
 
40
    setWindowIcon(QIcon(":/External/Resources/Icon_16.bmp"));
-
 
41
}
37
}
42
 
38
 
43
MacroController::~MacroController()
39
MacroController::~MacroController()
44
{
40
{
45
 
41
 
46
}
42
}
47
 
43
 
-
 
44
QSize MacroController::sizeHint() const
-
 
45
{
-
 
46
    return this->minimumSizeHint();
-
 
47
}
-
 
48
 
48
void MacroController::Macro_EnableTransmit()
49
void MacroController::Macro_EnableTransmit()
49
{
50
{
50
    connected = true;
51
    connected = true;
51
    for (int i = 0; i < macroBtnList.size(); i++) {
52
    for (int i = 0; i < macroBtnList.size(); i++) {
52
        macroBtnList[i]->setEnabled(true);
53
        macroBtnList[i]->setEnabled(true);
Line 104... Line 105...
104
    sigMapper->setMapping(pushButton, textEdit);
105
    sigMapper->setMapping(pushButton, textEdit);
105
    connect(pushButton, SIGNAL(clicked()), sigMapper, SLOT(map()));
106
    connect(pushButton, SIGNAL(clicked()), sigMapper, SLOT(map()));
106
 
107
 
107
    QLayoutItem *item = mainLayout->itemAtPosition(1, 1);
108
    QLayoutItem *item = mainLayout->itemAtPosition(1, 1);
108
    int height = item->widget()->height() + mainLayout->verticalSpacing();
109
    int height = item->widget()->height() + mainLayout->verticalSpacing();
109
    if (!this->isMaximized())
-
 
110
        this->resize(this->width(), this->height() + height);
-
 
111
 
110
 
-
 
111
    QDockWidget *parent = qobject_cast<QDockWidget*>(this->parent());
-
 
112
    if (parent->isFloating())
-
 
113
        parent->resize(parent->width(), parent->height() + height);
-
 
114
 
112
    btnDecreaseMacro->setEnabled(true);
115
    btnRemoveMacro->setEnabled(true);
113
}
116
}
114
 
117
 
115
void MacroController::Macro_RemoveEntry()
118
void MacroController::Macro_RemoveEntry()
116
{
119
{
117
 
120
 
Line 135... Line 138...
135
    macroValueList.pop_back();
138
    macroValueList.pop_back();
136
    macroBtnList.pop_back();
139
    macroBtnList.pop_back();
137
 
140
 
138
    macroCount--;
141
    macroCount--;
139
 
142
 
-
 
143
    QDockWidget *parent = qobject_cast<QDockWidget*>(this->parent());
140
    if (!this->isMaximized())
144
    if (parent->isFloating())
141
        this->resize(this->width(), this->height() - height);
145
        parent->resize(parent->width(), parent->height() - height);
142
 
146
 
143
    if (macroCount == 1)
147
    if (macroCount == 1)
144
        btnDecreaseMacro->setEnabled(false);
148
        btnRemoveMacro->setEnabled(false);
145
}
149
}
146
 
150
 
147
void MacroController::Macro_WriteToFile()
151
void MacroController::Macro_WriteToFile()
148
{
152
{
149
    QString file = QFileDialog::getSaveFileName(this, "Settings XML File", lastKnownFilePath, "XML File (*.xml)");
153
    QString file = QFileDialog::getSaveFileName(this, "Settings XML File", lastKnownFilePath, "XML File (*.xml)");