Skip to content

Commit e953f7d

Browse files
committed
Implemented about dialog with version
1 parent 8cf88d4 commit e953f7d

File tree

8 files changed

+205
-3
lines changed

8 files changed

+205
-3
lines changed

qt/about_dialog.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* Copyright (C) 2017 Bogdan Bogush <[email protected]>
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License version 3.
4+
*/
5+
6+
#include "about_dialog.h"
7+
#include "ui_about_dialog.h"
8+
#include "version.h"
9+
10+
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent),
11+
ui(new Ui::AboutDialog)
12+
{
13+
ui->setupUi(this);
14+
ui->versionLabel->setText(SW_VERSION);
15+
}
16+
17+
AboutDialog::~AboutDialog()
18+
{
19+
delete ui;
20+
}

qt/about_dialog.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright (C) 2017 Bogdan Bogush <[email protected]>
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License version 3.
4+
*/
5+
6+
#ifndef ABOUT_DIALOG_H
7+
#define ABOUT_DIALOG_H
8+
9+
#include <QDialog>
10+
11+
namespace Ui {
12+
class AboutDialog;
13+
}
14+
15+
class AboutDialog : public QDialog
16+
{
17+
Q_OBJECT
18+
19+
public:
20+
explicit AboutDialog(QWidget *parent = nullptr);
21+
~AboutDialog();
22+
23+
private:
24+
Ui::AboutDialog *ui;
25+
};
26+
27+
#endif // ABOUT_DIALOG_H

qt/about_dialog.ui

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>AboutDialog</class>
4+
<widget class="QDialog" name="AboutDialog">
5+
<property name="windowModality">
6+
<enum>Qt::WindowModal</enum>
7+
</property>
8+
<property name="geometry">
9+
<rect>
10+
<x>0</x>
11+
<y>0</y>
12+
<width>400</width>
13+
<height>180</height>
14+
</rect>
15+
</property>
16+
<property name="sizePolicy">
17+
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
18+
<horstretch>0</horstretch>
19+
<verstretch>0</verstretch>
20+
</sizepolicy>
21+
</property>
22+
<property name="windowTitle">
23+
<string>About NANDO</string>
24+
</property>
25+
<widget class="QDialogButtonBox" name="buttonBox">
26+
<property name="geometry">
27+
<rect>
28+
<x>160</x>
29+
<y>140</y>
30+
<width>81</width>
31+
<height>32</height>
32+
</rect>
33+
</property>
34+
<property name="orientation">
35+
<enum>Qt::Horizontal</enum>
36+
</property>
37+
<property name="standardButtons">
38+
<set>QDialogButtonBox::Ok</set>
39+
</property>
40+
</widget>
41+
<widget class="QWidget" name="">
42+
<property name="geometry">
43+
<rect>
44+
<x>20</x>
45+
<y>30</y>
46+
<width>131</width>
47+
<height>42</height>
48+
</rect>
49+
</property>
50+
<layout class="QGridLayout" name="gridLayout">
51+
<item row="0" column="0">
52+
<widget class="QLabel" name="label">
53+
<property name="text">
54+
<string>Version:</string>
55+
</property>
56+
</widget>
57+
</item>
58+
<item row="0" column="1">
59+
<widget class="QLabel" name="versionLabel">
60+
<property name="text">
61+
<string>0.0.0</string>
62+
</property>
63+
</widget>
64+
</item>
65+
<item row="1" column="0">
66+
<widget class="QLabel" name="label_2">
67+
<property name="text">
68+
<string>License:</string>
69+
</property>
70+
</widget>
71+
</item>
72+
<item row="1" column="1">
73+
<widget class="QLabel" name="label_3">
74+
<property name="text">
75+
<string>GPLv3</string>
76+
</property>
77+
</widget>
78+
</item>
79+
</layout>
80+
</widget>
81+
</widget>
82+
<resources/>
83+
<connections>
84+
<connection>
85+
<sender>buttonBox</sender>
86+
<signal>accepted()</signal>
87+
<receiver>AboutDialog</receiver>
88+
<slot>accept()</slot>
89+
<hints>
90+
<hint type="sourcelabel">
91+
<x>248</x>
92+
<y>254</y>
93+
</hint>
94+
<hint type="destinationlabel">
95+
<x>157</x>
96+
<y>274</y>
97+
</hint>
98+
</hints>
99+
</connection>
100+
<connection>
101+
<sender>buttonBox</sender>
102+
<signal>rejected()</signal>
103+
<receiver>AboutDialog</receiver>
104+
<slot>reject()</slot>
105+
<hints>
106+
<hint type="sourcelabel">
107+
<x>316</x>
108+
<y>260</y>
109+
</hint>
110+
<hint type="destinationlabel">
111+
<x>286</x>
112+
<y>274</y>
113+
</hint>
114+
</hints>
115+
</connection>
116+
</connections>
117+
</ui>

qt/main_window.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "chip_db_dialog.h"
1010
#include "chip_db.h"
1111
#include "logger.h"
12+
#include "about_dialog.h"
1213
#include <QDebug>
1314
#include <QFileDialog>
1415
#include <QFile>
@@ -81,6 +82,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
8182
SLOT(slotSettingsProgrammer()));
8283
connect(ui->actionChipDb, SIGNAL(triggered()), this,
8384
SLOT(slotSettingsChipDb()));
85+
connect(ui->actionAbout, SIGNAL(triggered()), this,
86+
SLOT(slotAboutDialog()));
8487
}
8588

8689
MainWindow::~MainWindow()
@@ -449,3 +452,10 @@ void MainWindow::updateChipList()
449452
}
450453
ui->chipSelectComboBox->setCurrentIndex(CHIP_INDEX_DEFAULT);
451454
}
455+
456+
void MainWindow::slotAboutDialog()
457+
{
458+
AboutDialog aboutDialog(this);
459+
460+
aboutDialog.exec();
461+
}

qt/main_window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public slots:
5757
void slotSelectChip(int selectedChipNum);
5858
void slotSettingsProgrammer();
5959
void slotSettingsChipDb();
60+
void slotAboutDialog();
6061
};
6162

6263
#endif // MAIN_WINDOW_H

qt/main_window.ui

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,17 @@
265265
<addaction name="actionProgrammer"/>
266266
<addaction name="actionChipDb"/>
267267
</widget>
268+
<widget class="QMenu" name="menuHelp">
269+
<property name="title">
270+
<string>Help</string>
271+
</property>
272+
<addaction name="actionAbout"/>
273+
</widget>
268274
<addaction name="menuFile"/>
269275
<addaction name="menuProgrammer"/>
270276
<addaction name="menuDevice"/>
271277
<addaction name="menuSettings"/>
278+
<addaction name="menuHelp"/>
272279
</widget>
273280
<widget class="QToolBar" name="mainToolBar">
274281
<attribute name="toolBarArea">
@@ -355,6 +362,11 @@
355362
<string>Chip database</string>
356363
</property>
357364
</action>
365+
<action name="actionAbout">
366+
<property name="text">
367+
<string>About NANDO</string>
368+
</property>
369+
</action>
358370
</widget>
359371
<layoutdefault spacing="6" margin="11"/>
360372
<resources/>

qt/qt.pro

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ SOURCES += main.cpp\
3535
stm32.cpp \
3636
chip_db_dialog.cpp \
3737
chip_db_table_model.cpp \
38-
err.cpp
38+
err.cpp \
39+
about_dialog.cpp
3940

4041
HEADERS += main_window.h \
4142
programmer.h \
@@ -49,11 +50,14 @@ HEADERS += main_window.h \
4950
stm32.h \
5051
chip_db_dialog.h \
5152
chip_db_table_model.h \
52-
err.h
53+
err.h \
54+
about_dialog.h \
55+
version.h
5356

5457
FORMS += main_window.ui \
5558
settings_programmer_dialog.ui \
56-
chip_db_dialog.ui
59+
chip_db_dialog.ui \
60+
about_dialog.ui
5761

5862
QMAKE_CXXFLAGS += -std=c++11 -Wextra -Werror
5963
mingw:QMAKE_CXXFLAGS += -mno-ms-bitfields

qt/version.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* Copyright (C) 2017 Bogdan Bogush <[email protected]>
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License version 3.
4+
*/
5+
6+
#ifndef VERSION_H
7+
#define VERSION_H
8+
9+
#define SW_VERSION "2.2.0"
10+
11+
#endif // VERSION_H

0 commit comments

Comments
 (0)