Added "About" & "About Qt" dialogs.
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "../../ApplicationConfig.h"
|
||||
#include "data/settingshandler.h"
|
||||
#include "genericcore.h"
|
||||
|
||||
@ -29,6 +30,9 @@ MainWindow::MainWindow(QWidget* parent)
|
||||
setWindowIcon(QIcon(iconString));
|
||||
#endif
|
||||
|
||||
createActions();
|
||||
createHelpMenu();
|
||||
|
||||
/// TODO restore window geometry and state (& save it in closeEvent)
|
||||
const QVariantMap settings = SettingsHandler::getSettings("GUI");
|
||||
restoreGeometry(settings.value("geometry").toByteArray());
|
||||
@ -45,30 +49,6 @@ MainWindow::~MainWindow() {
|
||||
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) {
|
||||
if (isWindowModified()) {
|
||||
QMessageBox msgBox;
|
||||
@ -106,3 +86,54 @@ void MainWindow::closeEvent(QCloseEvent* event) {
|
||||
"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, ...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user