Compare commits
3 Commits
43df76c88f
...
8105fac8d3
| Author | SHA1 | Date | |
|---|---|---|---|
| 8105fac8d3 | |||
| 7dd9d3d95b | |||
| c8825bfe14 |
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(TARGET_APP "GenericQtClient-Widgets")
|
set(TARGET_APP "GenericQtClient-Widgets")
|
||||||
project(${TARGET_APP} VERSION 0.0.2 LANGUAGES CXX)
|
project(${TARGET_APP} VERSION 0.1.0 LANGUAGES CXX)
|
||||||
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
@ -35,7 +35,8 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
|||||||
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
|
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
|
||||||
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
|
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
|
||||||
|
|
||||||
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
# qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
||||||
|
|
||||||
else()
|
else()
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
add_library(${TARGET_APP} SHARED
|
add_library(${TARGET_APP} SHARED
|
||||||
@ -52,6 +53,8 @@ endif()
|
|||||||
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
target_link_libraries(${TARGET_APP} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
target_link_libraries(${TARGET_APP} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
|
||||||
|
|
||||||
target_include_directories(${TARGET_APP} PRIVATE ${CORE_LIB_DIR}/)
|
target_include_directories(${TARGET_APP} PRIVATE ${CORE_LIB_DIR}/)
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "../../ApplicationConfig.h"
|
||||||
#include "data/settingshandler.h"
|
#include "data/settingshandler.h"
|
||||||
#include "genericcore.h"
|
#include "genericcore.h"
|
||||||
|
|
||||||
@ -29,6 +30,9 @@ MainWindow::MainWindow(QWidget* parent)
|
|||||||
setWindowIcon(QIcon(iconString));
|
setWindowIcon(QIcon(iconString));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
createActions();
|
||||||
|
createHelpMenu();
|
||||||
|
|
||||||
/// TODO restore window geometry and state (& save it in closeEvent)
|
/// TODO restore window geometry and state (& save it in closeEvent)
|
||||||
const QVariantMap settings = SettingsHandler::getSettings("GUI");
|
const QVariantMap settings = SettingsHandler::getSettings("GUI");
|
||||||
restoreGeometry(settings.value("geometry").toByteArray());
|
restoreGeometry(settings.value("geometry").toByteArray());
|
||||||
@ -45,30 +49,6 @@ MainWindow::~MainWindow() {
|
|||||||
delete m_core;
|
delete m_core;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_pushButton_clicked() {
|
|
||||||
const QString prefix("Backend provided by: ");
|
|
||||||
ui->label->setText(prefix + m_core->toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showStatusMessage(const QString text) {
|
|
||||||
qInfo() << text;
|
|
||||||
ui->statusbar->showMessage(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_actionCheck_for_update_triggered() {
|
|
||||||
showStatusMessage("Checking for update...");
|
|
||||||
const bool updateAvailable = m_core->isApplicationUpdateAvailable();
|
|
||||||
if (updateAvailable) {
|
|
||||||
const QString text = isWindowModified() ? updateTextDirty : updateTextClean;
|
|
||||||
const QMessageBox::StandardButton clickedButton = QMessageBox::question(
|
|
||||||
this, tr("Update available."), text, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
|
||||||
if (clickedButton == QMessageBox::Yes) {
|
|
||||||
m_core->triggerApplicationUpdate();
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event) {
|
void MainWindow::closeEvent(QCloseEvent* event) {
|
||||||
if (isWindowModified()) {
|
if (isWindowModified()) {
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
@ -106,3 +86,54 @@ void MainWindow::closeEvent(QCloseEvent* event) {
|
|||||||
"GUI");
|
"GUI");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onAboutClicked() {
|
||||||
|
const QString applicationName = APPLICATION_NAME;
|
||||||
|
const QString titlePrefix = tr("About ");
|
||||||
|
const QString aboutText =
|
||||||
|
tr(QString("<b>%1 v%2</b> is a template for Qt applications."
|
||||||
|
"<br><br><a href=\"https://working-copy.org/\">Working-Copy_Collective website</a>"
|
||||||
|
"<br><br><a href=\"mailto:support@working-copy.org\">Mail to support</a>"
|
||||||
|
"<br><br>It uses the <a href=\"https://qt.io\">Qt Framework</a>.")
|
||||||
|
.arg(applicationName)
|
||||||
|
.arg(APPLICATION_VERSION)
|
||||||
|
.toLatin1());
|
||||||
|
QMessageBox::about(this, titlePrefix + applicationName, aboutText);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::showStatusMessage(const QString text) {
|
||||||
|
qInfo() << text;
|
||||||
|
ui->statusbar->showMessage(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionCheck_for_update_triggered() {
|
||||||
|
showStatusMessage("Checking for update...");
|
||||||
|
const bool updateAvailable = m_core->isApplicationUpdateAvailable();
|
||||||
|
if (updateAvailable) {
|
||||||
|
const QString text = isWindowModified() ? updateTextDirty : updateTextClean;
|
||||||
|
const QMessageBox::StandardButton clickedButton = QMessageBox::question(
|
||||||
|
this, tr("Update available."), text, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||||
|
if (clickedButton == QMessageBox::Yes) {
|
||||||
|
m_core->triggerApplicationUpdate();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_pushButton_clicked() {
|
||||||
|
const QString prefix("Backend provided by: ");
|
||||||
|
ui->label->setText(prefix + m_core->toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::createHelpMenu() {
|
||||||
|
QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||||
|
QAction* aboutAct = helpMenu->addAction(tr("&About"), this, &MainWindow::onAboutClicked);
|
||||||
|
aboutAct->setStatusTip(tr("Show the application's About box"));
|
||||||
|
|
||||||
|
QAction* aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, &QApplication::aboutQt);
|
||||||
|
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::createActions() {
|
||||||
|
// TODO add generic menu actions (file/new, edit/cut, ...)
|
||||||
|
}
|
||||||
|
|||||||
@ -27,14 +27,19 @@ class MainWindow : public QMainWindow {
|
|||||||
void closeEvent(QCloseEvent* event) override;
|
void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void onAboutClicked();
|
||||||
void showStatusMessage(const QString text);
|
void showStatusMessage(const QString text);
|
||||||
|
void on_actionCheck_for_update_triggered();
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
void on_actionCheck_for_update_triggered();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
|
|
||||||
GenericCore* m_core;
|
GenericCore* m_core;
|
||||||
|
|
||||||
|
/// Setup functions
|
||||||
|
void createActions();
|
||||||
|
void createHelpMenu();
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user