Skip to content

Commit 8ca3cec

Browse files
author
m.zabic
committed
save feature added, gui-scrolling experience improved
1 parent c42e2e1 commit 8ca3cec

19 files changed

+109
-99
lines changed

src/FDMLControl.pro

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ HEADERS += ./fdmlcontrol.h \
5252
plotwidget.h \
5353
querymanager.h \
5454
querywidget.h \
55-
querywidgetmanager.h
55+
querywidgetmanager.h \
56+
eventguard.h
5657

5758
SOURCES += ./fdmlcontrol.cpp \
5859
./QCustomPlot/qcustomplot.cpp \
@@ -67,10 +68,11 @@ SOURCES += ./fdmlcontrol.cpp \
6768
plotwidget.cpp \
6869
querymanager.cpp \
6970
querywidget.cpp \
70-
querywidgetmanager.cpp
71+
querywidgetmanager.cpp \
72+
eventguard.cpp
7173

72-
FORMS += ./ComSettingsWidget.ui \
73-
./ConsoleWidget.ui \
74+
FORMS += ./comsettingswidget.ui \
75+
./consolewidget.ui \
7476
./fdmlcontrol.ui
7577

7678
RESOURCES += fdmlcontrol.qrc

src/authenticationwidget.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ AuthenticationWidget::~AuthenticationWidget()
4141
{
4242
}
4343

44-
bool AuthenticationWidget::isKeyAvailable(){
44+
bool AuthenticationWidget::isKeyAvailable()
45+
{
4546
return this->keyAvailable;
4647
}
4748

48-
void AuthenticationWidget::loadKeyFromFile(QString filePath){
49+
void AuthenticationWidget::loadKeyFromFile(QString filePath) {
4950
QFile inputFile(filePath);
5051
if (inputFile.open(QIODevice::ReadOnly)){
5152
QTextStream in(&inputFile);
@@ -97,7 +98,7 @@ void AuthenticationWidget::handleResponse(QString initialQuery, QString response
9798
}
9899
}
99100
}
100-
else if (status == "401"){
101+
else if (status == "401") {
101102
emit error(tr("Invalid command! Initial query: ") + initialQuery + tr(" Response: ") + recoveredResponse);
102103
}
103104
else {

src/authenticationwidget.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ class AuthenticationWidget : public QueryWidget
4343

4444
bool isKeyAvailable();
4545

46+
4647
private:
4748
QString key;
4849
bool keyAvailable;
4950

51+
5052
public slots:
5153
void loadKeyFromFile(QString filePath);
5254
void authenticate();
5355
void handleResponse(QString initialQuery, QString response) override;
5456

57+
5558
signals:
5659

5760
};
58-

src/buttonquerywidget.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@ ButtonQueryWidget::ButtonQueryWidget(QWidget *parent) : QueryWidget(parent) {
4040
}
4141

4242
ButtonQueryWidget::ButtonQueryWidget(QString name, QString command, bool expert, QString infoText, QWidget* parent) : ButtonQueryWidget(parent) {
43-
this->name = name;
44-
this->command = command;
45-
this->expert = expert;
46-
this->setToolTip("<font>" + infoText + "</font>");
47-
this->button->setText(name);
43+
this->name = name;
44+
this->command = command;
45+
this->expert = expert;
46+
this->setToolTip("<font>" + infoText + "</font>");
47+
this->button->setText(name);
4848
}
4949

50-
ButtonQueryWidget::~ButtonQueryWidget()
51-
{
50+
ButtonQueryWidget::~ButtonQueryWidget() {
5251
}
5352

54-
void ButtonQueryWidget::handleResponse(QString initialQuery, QString response){
53+
void ButtonQueryWidget::handleResponse(QString initialQuery, QString response) {
5554
}
5655

5756
void ButtonQueryWidget::sendQuery() {

src/buttonquerywidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ class ButtonQueryWidget : public QueryWidget
4242
ButtonQueryWidget(QString name, QString command, bool expert, QString infoText, QWidget *parent = nullptr);
4343
~ButtonQueryWidget();
4444

45+
4546
private:
4647
QPushButton* button;
4748
QHBoxLayout* layout;
4849
QString command;
4950

51+
5052
public slots:
5153
void handleResponse(QString initialQuery, QString response) override;
5254
void sendQuery();

src/comboboxquerywidget.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
ComboBoxQueryWidget::ComboBoxQueryWidget(QWidget *parent) : QueryWidget(parent) {
3232
this->comboBox = new QComboBox(this);
33+
this->comboBox->setFocusPolicy(Qt::StrongFocus);
34+
this->comboBox->installEventFilter(new EventGuard(this->comboBox)); //StrongFocus and event filter prevent the accidental change of comboBox value inside QScrollArea
3335
this->label = new QLabel(this);
3436
this->layout = new QHBoxLayout(this);
3537
this->layout->setMargin(0);
@@ -59,7 +61,11 @@ ComboBoxQueryWidget::~ComboBoxQueryWidget()
5961
{
6062
}
6163

62-
void ComboBoxQueryWidget::handleResponse(QString initialQuery, QString response){
64+
QString ComboBoxQueryWidget::content() {
65+
return this->name + ":" + "\t" + this->comboBox->currentText();
66+
}
67+
68+
void ComboBoxQueryWidget::handleResponse(QString initialQuery, QString response) {
6369
//check if response is not empty
6470
if (!(response.size() > 2)) {
6571
emit error(tr("Could not change value, response too short. Initial query: ") + initialQuery + tr(" Response: ") + response);

src/comboboxquerywidget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <QString>
3434
#include <QHBoxLayout>
3535
#include "querywidget.h"
36+
#include "eventguard.h"
3637

3738
class ComboBoxQueryWidget : public QueryWidget
3839
{
@@ -42,6 +43,8 @@ class ComboBoxQueryWidget : public QueryWidget
4243
ComboBoxQueryWidget(QWidget *parent = nullptr);
4344
ComboBoxQueryWidget(QString name, QStringList options, bool expert, QString infoText, QWidget *parent = nullptr);
4445
~ComboBoxQueryWidget();
46+
QString content() override;
47+
4548

4649
private:
4750
QComboBox* comboBox;
@@ -50,11 +53,13 @@ class ComboBoxQueryWidget : public QueryWidget
5053
QStringList options;
5154
bool enableDisableComboBox;
5255

56+
5357
public slots:
5458
void handleResponse(QString initialQuery, QString response) override;
5559
void changeValue(int value);
5660
void queryCurrentValue();
5761

62+
5863
signals:
5964

6065
};

src/comsettingswidget.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ private slots:
104104
void connectCom();
105105
void disconnectCom();
106106
};
107-

src/consolewidget.cpp

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/consolewidget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
** at **
2525
** iqo.uni-hannover.de **
2626
** **
27-
** Date: 12 June 2019 **
28-
** Version: 1.0.0 **
2927
****************************************************************************/
3028

3129
#pragma once
@@ -42,9 +40,11 @@ class ConsoleWidget : public QueryWidget
4240
ConsoleWidget(QWidget *parent = Q_NULLPTR);
4341
~ConsoleWidget();
4442

43+
4544
private:
4645
Ui::ConsoleWidget ui;
4746

47+
4848
public slots:
4949
void handleResponse(QString initialQuery, QString response) override;
5050
void slot_commandSent();

0 commit comments

Comments
 (0)