Skip to content

Commit d59fb84

Browse files
committed
Improve script module importing
1 parent cdc73f9 commit d59fb84

File tree

15 files changed

+245
-60
lines changed

15 files changed

+245
-60
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.13) # 2.2 - case insensitive syntax
22
# 3.13 included policy CMP0077
33

4-
project(ModbusTools VERSION 0.4.5 LANGUAGES CXX)
4+
project(ModbusTools VERSION 0.4.6 LANGUAGES CXX)
55

66
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
77
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

src/client/win_resource.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
IDI_ICON1 ICON DISCARDABLE "gui\\icons\\client.ico"
44

55
VS_VERSION_INFO VERSIONINFO
6-
FILEVERSION 0,4,5,0
7-
PRODUCTVERSION 0,4,5,0
6+
FILEVERSION 0,4,6,0
7+
PRODUCTVERSION 0,4,6,0
88
FILEFLAGSMASK 0x3fL
99
#ifdef _DEBUG
1010
FILEFLAGS VS_FF_DEBUG
@@ -21,11 +21,11 @@ VS_VERSION_INFO VERSIONINFO
2121
BEGIN
2222
VALUE "CompanyName", "\0"
2323
VALUE "FileDescription", "\0"
24-
VALUE "FileVersion", "0.4.5.0\0"
24+
VALUE "FileVersion", "0.4.6.0\0"
2525
VALUE "LegalCopyright", "\0"
2626
VALUE "OriginalFilename", "client.exe\0"
2727
VALUE "ProductName", "client\0"
28-
VALUE "ProductVersion", "0.4.5.0\0"
28+
VALUE "ProductVersion", "0.4.6.0\0"
2929
END
3030
END
3131
BLOCK "VarFileInfo"

src/core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ set(HEADERS
4040
${CMAKE_CURRENT_LIST_DIR}/project/core_dom.h
4141
${CMAKE_CURRENT_LIST_DIR}/project/core_builder.h
4242
gui/widgets/core_addresswidget.h
43+
gui/dialogs/core_dialogreplace.h
4344
gui/dialogs/core_dialogbase.h
4445
gui/dialogs/settings/core_widgetsettingsview.h
4546
gui/dialogs/settings/core_widgetsettingsdataview.h
@@ -89,6 +90,7 @@ set(SOURCES
8990
${CMAKE_CURRENT_LIST_DIR}/project/core_dom.cpp
9091
${CMAKE_CURRENT_LIST_DIR}/project/core_builder.cpp
9192
gui/widgets/core_addresswidget.cpp
93+
gui/dialogs/core_dialogreplace.cpp
9294
gui/dialogs/core_dialogbase.cpp
9395
gui/dialogs/settings/core_widgetsettingsview.cpp
9496
gui/dialogs/settings/core_widgetsettingsdataview.cpp
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#include "core_dialogreplace.h"
2+
3+
#include <QVBoxLayout>
4+
#include <QGridLayout>
5+
#include <QLabel>
6+
#include <QPushButton>
7+
8+
mbCoreDialogReplace::mbCoreDialogReplace(QWidget *parent)
9+
{
10+
setWindowTitle("Replace Dialog");
11+
12+
auto *mainLayout = new QVBoxLayout(this);
13+
m_label = new QLabel("What would you like to do?", this);
14+
mainLayout->addWidget(m_label);
15+
16+
QGridLayout *grid = new QGridLayout;
17+
mainLayout->addLayout(grid);
18+
19+
m_buttonReplace = new QPushButton(tr("Replace"), this);
20+
connect(m_buttonReplace, &QPushButton::clicked, this, &mbCoreDialogReplace::slotReplaceClicked);
21+
grid->addWidget(m_buttonReplace, 0, 0);
22+
23+
m_buttonRename = new QPushButton(tr("Rename"), this);
24+
connect(m_buttonRename, &QPushButton::clicked, this, &mbCoreDialogReplace::slotRenameClicked);
25+
grid->addWidget(m_buttonRename, 0, 1);
26+
27+
m_buttonSkip = new QPushButton(tr("Skip"), this);
28+
connect(m_buttonSkip, &QPushButton::clicked, this, &mbCoreDialogReplace::slotSkipClicked);
29+
grid->addWidget(m_buttonSkip, 0, 2);
30+
31+
m_buttonReplaceAll = new QPushButton(tr("Replace All"), this);
32+
connect(m_buttonReplaceAll, &QPushButton::clicked, this, &mbCoreDialogReplace::slotReplaceAllClicked);
33+
grid->addWidget(m_buttonReplaceAll, 1, 0);
34+
35+
m_buttonRenameAll = new QPushButton(tr("Rename All"), this);
36+
connect(m_buttonRenameAll, &QPushButton::clicked, this, &mbCoreDialogReplace::slotRenameAllClicked);
37+
grid->addWidget(m_buttonRenameAll, 1, 1);
38+
39+
m_buttonSkipAll = new QPushButton(tr("Skip All"), this);
40+
connect(m_buttonSkipAll, &QPushButton::clicked, this, &mbCoreDialogReplace::slotSkipAllClicked);
41+
grid->addWidget(m_buttonSkipAll, 1, 2);
42+
43+
m_buttonCancel = new QPushButton(tr("Cancel"), this);
44+
connect(m_buttonCancel, &QPushButton::clicked, this, &mbCoreDialogReplace::slotCancelClicked);
45+
grid->addWidget(m_buttonCancel, 2, 2);
46+
}
47+
48+
QString mbCoreDialogReplace::text() const
49+
{
50+
return m_label->text();
51+
}
52+
53+
void mbCoreDialogReplace::setText(const QString &text)
54+
{
55+
m_label->setText(text);
56+
}
57+
58+
void mbCoreDialogReplace::setUseAllButtons(bool use)
59+
{
60+
m_buttonReplaceAll->setVisible(use);
61+
m_buttonRenameAll->setVisible(use);
62+
m_buttonSkipAll->setVisible(use);
63+
}
64+
65+
void mbCoreDialogReplace::slotReplaceClicked()
66+
{
67+
QDialog::done(Replace);
68+
}
69+
70+
void mbCoreDialogReplace::slotRenameClicked()
71+
{
72+
QDialog::done(Rename);
73+
}
74+
75+
void mbCoreDialogReplace::slotSkipClicked()
76+
{
77+
QDialog::done(Skip);
78+
}
79+
80+
void mbCoreDialogReplace::slotReplaceAllClicked()
81+
{
82+
QDialog::done(ReplaceAll);
83+
}
84+
85+
void mbCoreDialogReplace::slotRenameAllClicked()
86+
{
87+
QDialog::done(RenameAll);
88+
}
89+
90+
void mbCoreDialogReplace::slotSkipAllClicked()
91+
{
92+
QDialog::done(SkipAll);
93+
}
94+
95+
void mbCoreDialogReplace::slotCancelClicked()
96+
{
97+
QDialog::reject();
98+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#ifndef CORE_DIALOGREPLACE_H
2+
#define CORE_DIALOGREPLACE_H
3+
4+
#include <QDialog>
5+
6+
class QLabel;
7+
class QPushButton;
8+
9+
class mbCoreDialogReplace : public QDialog
10+
{
11+
Q_OBJECT
12+
13+
public:
14+
enum Button
15+
{
16+
None = 0x00,
17+
Replace = 0x01,
18+
Rename = 0x02,
19+
Skip = 0x04,
20+
ReplaceAll = 0x08,
21+
RenameAll = 0x10,
22+
SkipAll = 0x20,
23+
Cancel = 0x40
24+
};
25+
26+
public:
27+
mbCoreDialogReplace(QWidget *parent = nullptr);
28+
29+
public:
30+
QString text() const;
31+
void setText(const QString &text);
32+
void setUseAllButtons(bool use);
33+
34+
private Q_SLOTS:
35+
void slotReplaceClicked();
36+
void slotRenameClicked();
37+
void slotSkipClicked();
38+
void slotReplaceAllClicked();
39+
void slotRenameAllClicked();
40+
void slotSkipAllClicked();
41+
void slotCancelClicked();
42+
43+
private:
44+
QLabel* m_label;
45+
QPushButton* m_buttonReplace;
46+
QPushButton* m_buttonRename;
47+
QPushButton* m_buttonSkip;
48+
QPushButton* m_buttonReplaceAll;
49+
QPushButton* m_buttonRenameAll;
50+
QPushButton* m_buttonSkipAll;
51+
QPushButton* m_buttonCancel;
52+
53+
};
54+
55+
#endif // CORE_DIALOGREPLACE_H

src/core/gui/dialogs/core_dialogs.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const mbCoreDialogs::Strings &mbCoreDialogs::Strings::instance()
5050

5151
mbCoreDialogs::mbCoreDialogs(QWidget *parent)
5252
{
53+
m_replace = new mbCoreDialogReplace(parent);
5354
m_settings = nullptr;
5455
m_projectInfo = new mbCoreDialogProjectInfo(parent);
5556
m_project = new mbCoreDialogProject(parent);
@@ -64,6 +65,14 @@ mbCoreDialogs::~mbCoreDialogs()
6465
{
6566
}
6667

68+
int mbCoreDialogs::replace(const QString &title, const QString &label, bool useAllButtons)
69+
{
70+
m_replace->setWindowTitle(title);
71+
m_replace->setText(label);
72+
m_replace->setUseAllButtons(useAllButtons);
73+
return m_replace->exec();
74+
}
75+
6776
QString mbCoreDialogs::getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode echo, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
6877
{
6978
return QInputDialog::getText(parent, title, label, echo, text, ok, flags, inputMethodHints);

src/core/gui/dialogs/core_dialogs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <QColorDialog>
2929
#include <QFontDialog>
3030

31+
#include "core_dialogreplace.h"
32+
3133
#include <project/core_project.h>
3234

3335
class mbCore;
@@ -72,6 +74,7 @@ class MB_EXPORT mbCoreDialogs
7274
virtual ~mbCoreDialogs();
7375

7476
public:
77+
int replace(const QString &title, const QString &label, bool useAllButtons = false);
7578
QString getText(QWidget *parent, const QString &title, const QString &label,
7679
QLineEdit::EchoMode echo = QLineEdit::Normal,
7780
const QString &text = QString(), bool *ok = nullptr,
@@ -109,6 +112,7 @@ class MB_EXPORT mbCoreDialogs
109112
QString m_lastFilter;
110113

111114
protected:
115+
mbCoreDialogReplace *m_replace ;
112116
mbCoreDialogSettings *m_settings ;
113117
mbCoreDialogProjectInfo *m_projectInfo ;
114118
mbCoreDialogProject *m_project ;

src/core/gui/dialogs/dialogs.pri

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ HEADERS += \
99
$$PWD/core_dialogdevice.h \
1010
$$PWD/core_dialogdataview.h \
1111
$$PWD/core_dialogdataviewitem.h \
12+
$$PWD/core_dialogreplace.h \
1213
$$PWD/core_dialogvaluelist.h \
1314
$$PWD/core_dialogs.h \
1415
@@ -20,6 +21,7 @@ SOURCES += \
2021
$$PWD/core_dialogdevice.cpp \
2122
$$PWD/core_dialogdataview.cpp \
2223
$$PWD/core_dialogdataviewitem.cpp \
24+
$$PWD/core_dialogreplace.cpp \
2325
$$PWD/core_dialogvaluelist.cpp \
2426
$$PWD/core_dialogs.cpp
2527

src/core/sdk/mbcore_config.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
#ifndef MBCORE_CONFIG_H
2-
#define MBCORE_CONFIG_H
3-
4-
/*
5-
Major part of mbtools version
6-
*/
7-
#define MBTOOLS_VERSION_MAJOR 0
8-
9-
/*
10-
Minor part of mbtools version
11-
*/
12-
#define MBTOOLS_VERSION_MINOR 4
13-
14-
/*
15-
Patch part of mbtools version
16-
*/
17-
#define MBTOOLS_VERSION_PATCH 5
18-
19-
#endif // MBCORE_CONFIG_H
1+
#ifndef MBCORE_CONFIG_H
2+
#define MBCORE_CONFIG_H
3+
4+
/*
5+
Major part of mbtools version
6+
*/
7+
#define MBTOOLS_VERSION_MAJOR 0
8+
9+
/*
10+
Minor part of mbtools version
11+
*/
12+
#define MBTOOLS_VERSION_MINOR 4
13+
14+
/*
15+
Patch part of mbtools version
16+
*/
17+
#define MBTOOLS_VERSION_PATCH 6
18+
19+
#endif // MBCORE_CONFIG_H

0 commit comments

Comments
 (0)