Skip to content

Commit b0f1965

Browse files
committed
other(UI): add menubar
1 parent f51ee6f commit b0f1965

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/QBrowserApp.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ QBrowserApp::QBrowserApp(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(p
2727
vSplitter->setStretchFactor(0, 1);
2828
vSplitter->setStretchFactor(1, 0);
2929

30+
QMenu* mainMenu = menuBar()->addMenu(QObject::tr("&General"));
31+
mainMenu->addAction(QObject::tr("Add &Connection..."), [&]() { QMetaObject::invokeMethod(findChild<QConnectionCtrl*>("connectionCtrl"), "showConnectionDialog", Qt::QueuedConnection); });
32+
mainMenu->addSeparator();
33+
mainMenu->addAction(QObject::tr("&Quit"), []() { qApp->quit(); });
34+
35+
QMenu* helpMenu = menuBar()->addMenu(QObject::tr("&Help"));
36+
helpMenu->addAction(QObject::tr("About"), [&]() { about(); });
37+
helpMenu->addAction(QObject::tr("About Qt"), []() { qApp->aboutQt(); });
38+
3039
QVBoxLayout* mainLayout = new QVBoxLayout;
3140
mainLayout->addWidget(vSplitter);
3241
m_mainWidget->setLayout(mainLayout);
@@ -37,4 +46,17 @@ QBrowserApp::QBrowserApp(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(p
3746
QObject::connect(m_tree, &QConnectionCtrl::dbSelected, querypanel, &QSqlQueryPanel::dbChange);
3847
QObject::connect(m_tree, &QConnectionCtrl::statusMessage, [&](const QString& text) { statusBar()->showMessage(text); });
3948
QObject::connect(querypanel, &QSqlQueryPanel::statusMessage, [&](const QString& text) { statusBar()->showMessage(text); });
49+
}
50+
51+
void QBrowserApp::about() {
52+
QMessageBox msgBox;
53+
msgBox.setWindowTitle("About");
54+
msgBox.setTextFormat(Qt::MarkdownText);
55+
msgBox.setText(tr("### qSQLbrowser\r\n"
56+
"Browser for visualizing the results of SQL statements on a live database.\r\n"
57+
"#### Author\r\n"
58+
"Korshunov Vladislav \\<vladredsoup@gmail.com\\>\n\n"
59+
"[License](https://github.com/n0f4ph4mst3r/qSQLbrowser/blob/master/LICENSE.txt) | [GitHub](https://github.com/n0f4ph4mst3r/qSQLbrowser)"));
60+
msgBox.setIconPixmap(QPixmap(":/icons/app_icon.png"));
61+
msgBox.exec();
4062
}

src/QBrowserApp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <QStatusBar>
88
#include <QSplitter>
99
#include <QFrame>
10+
#include <QMenuBar>
1011

1112
#include "QConnectionCtrl.h"
1213
#include "QDbTableView.h"
@@ -22,6 +23,8 @@ class QBrowserApp : public QMainWindow
2223
QDbTableView* m_table;
2324
public:
2425
explicit QBrowserApp(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
26+
public slots:
27+
void about();
2528
};
2629

2730
#endif

0 commit comments

Comments
 (0)