Add Quit, About actions to the menubar
This commit is contained in:
parent
16ab086e27
commit
2144ada2a8
4 changed files with 110 additions and 2 deletions
|
@ -36,6 +36,8 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n)
|
||||||
|
|
||||||
add_executable(Redai)
|
add_executable(Redai)
|
||||||
target_sources(Redai PRIVATE
|
target_sources(Redai PRIVATE
|
||||||
|
src/aboutwindow.cpp
|
||||||
|
src/artconfigwindow.h
|
||||||
src/artconfigwindow.cpp
|
src/artconfigwindow.cpp
|
||||||
src/artconfigwindow.h
|
src/artconfigwindow.h
|
||||||
src/artdetailwindow.cpp
|
src/artdetailwindow.cpp
|
||||||
|
|
64
src/aboutwindow.cpp
Normal file
64
src/aboutwindow.cpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#include "aboutwindow.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
AboutWindow::AboutWindow(QWidget *widget)
|
||||||
|
: QDialog(widget)
|
||||||
|
{
|
||||||
|
setWindowTitle("About");
|
||||||
|
setWindowModality(Qt::WindowModality::ApplicationModal);
|
||||||
|
|
||||||
|
auto mainLayout = new QVBoxLayout();
|
||||||
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
auto mainLabel = new QLabel();
|
||||||
|
mainLabel->setText(QString("<h2>%1</h2>").arg(QCoreApplication::applicationName()));
|
||||||
|
mainLayout->addWidget(mainLabel);
|
||||||
|
|
||||||
|
auto aboutWidget = new QWidget();
|
||||||
|
auto aboutLayout = new QVBoxLayout();
|
||||||
|
aboutWidget->setLayout(aboutLayout);
|
||||||
|
|
||||||
|
auto aboutLabel = new QLabel();
|
||||||
|
aboutLabel->setText("Tool manage website galleries.");
|
||||||
|
aboutLayout->addWidget(aboutLabel);
|
||||||
|
|
||||||
|
auto websiteLabel = new QLabel();
|
||||||
|
websiteLabel->setText("<a href='https://git.sr.ht/~redstrate/redai'>https://git.sr.ht/~redstrate/redai</a>");
|
||||||
|
websiteLabel->setOpenExternalLinks(true);
|
||||||
|
aboutLayout->addWidget(websiteLabel);
|
||||||
|
|
||||||
|
auto licenseLabel = new QLabel();
|
||||||
|
licenseLabel->setText("License: GNU General Public License Version 3");
|
||||||
|
aboutLayout->addWidget(licenseLabel);
|
||||||
|
|
||||||
|
aboutLayout->addStretch();
|
||||||
|
|
||||||
|
auto authorsWidget = new QWidget();
|
||||||
|
auto authorsLayout = new QVBoxLayout();
|
||||||
|
authorsWidget->setLayout(authorsLayout);
|
||||||
|
|
||||||
|
auto authorNameLabel = new QLabel();
|
||||||
|
authorNameLabel->setText("Joshua Goins");
|
||||||
|
|
||||||
|
QFont boldFont = authorNameLabel->font();
|
||||||
|
boldFont.setBold(true);
|
||||||
|
authorNameLabel->setFont(boldFont);
|
||||||
|
|
||||||
|
authorsLayout->addWidget(authorNameLabel);
|
||||||
|
|
||||||
|
auto authorRoleLabel = new QLabel();
|
||||||
|
authorRoleLabel->setText("Maintainer");
|
||||||
|
authorsLayout->addWidget(authorRoleLabel);
|
||||||
|
|
||||||
|
authorsLayout->addStretch();
|
||||||
|
|
||||||
|
auto tabWidget = new QTabWidget();
|
||||||
|
tabWidget->addTab(aboutWidget, "About");
|
||||||
|
tabWidget->addTab(authorsWidget, "Authors");
|
||||||
|
mainLayout->addWidget(tabWidget);
|
||||||
|
}
|
9
src/aboutwindow.h
Normal file
9
src/aboutwindow.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class AboutWindow : public QDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AboutWindow(QWidget *widget = nullptr);
|
||||||
|
};
|
|
@ -5,10 +5,13 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDesktopServices>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
|
#include "aboutwindow.h"
|
||||||
#include "artconfigwindow.h"
|
#include "artconfigwindow.h"
|
||||||
#include "artdetailwindow.h"
|
#include "artdetailwindow.h"
|
||||||
#include "artmodel.h"
|
#include "artmodel.h"
|
||||||
|
@ -22,15 +25,45 @@ MainWindow::MainWindow(const QDir &definitionDirectory, const QDir &assetDirecto
|
||||||
auto menuBar = new QMenuBar();
|
auto menuBar = new QMenuBar();
|
||||||
setMenuBar(menuBar);
|
setMenuBar(menuBar);
|
||||||
|
|
||||||
|
auto fileMenu = menuBar->addMenu(i18nc("@title:menu", "File"));
|
||||||
|
|
||||||
|
auto quitAction = fileMenu->addAction(i18nc("@action:inmenu", "Quit"));
|
||||||
|
quitAction->setIcon(QIcon::fromTheme(QStringLiteral("gtk-quit")));
|
||||||
|
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
|
||||||
|
|
||||||
auto manageMenu = menuBar->addMenu(i18nc("@title:menu Manage site", "Manage"));
|
auto manageMenu = menuBar->addMenu(i18nc("@title:menu Manage site", "Manage"));
|
||||||
|
|
||||||
auto editConfigAction = manageMenu->addAction(i18nc("@action:inmenu", "Edit Config..."));
|
auto editConfigAction = manageMenu->addAction(i18nc("@action:inmenu", "Edit Config..."));
|
||||||
|
editConfigAction->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
|
||||||
connect(editConfigAction, &QAction::triggered, this, [this, dataDirectory, definitionDirectory, assetDirectory] {
|
connect(editConfigAction, &QAction::triggered, this, [this, dataDirectory, definitionDirectory, assetDirectory] {
|
||||||
auto window =
|
auto window = new ArtConfigWindow(dataDirectory.absoluteFilePath(QStringLiteral("art-config.json")),
|
||||||
new ArtConfigWindow(dataDirectory.absoluteFilePath("art-config.json"), definitionDirectory.absolutePath(), assetDirectory.absolutePath(), this);
|
definitionDirectory.absolutePath(),
|
||||||
|
assetDirectory.absolutePath(),
|
||||||
|
this);
|
||||||
window->show();
|
window->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto helpMenu = menuBar->addMenu(i18nc("@title:menu", "Help"));
|
||||||
|
|
||||||
|
auto donateAction = helpMenu->addAction(i18nc("@action:inmenu", "Donate"));
|
||||||
|
connect(donateAction, &QAction::triggered, this, [] {
|
||||||
|
QDesktopServices::openUrl(QUrl(QStringLiteral("https://redstrate.com/fund")));
|
||||||
|
});
|
||||||
|
donateAction->setIcon(QIcon::fromTheme(QStringLiteral("help-donate")));
|
||||||
|
|
||||||
|
helpMenu->addSeparator();
|
||||||
|
|
||||||
|
auto aboutNovusAction = helpMenu->addAction(i18nc("@action:inmenu", "About Redai"));
|
||||||
|
aboutNovusAction->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
|
||||||
|
connect(aboutNovusAction, &QAction::triggered, this, [this] {
|
||||||
|
auto window = new AboutWindow(this);
|
||||||
|
window->show();
|
||||||
|
});
|
||||||
|
|
||||||
|
auto aboutQtAction = helpMenu->addAction(i18nc("@action:inmenu", "About Qt"));
|
||||||
|
aboutQtAction->setIcon(QIcon(QStringLiteral(":/qt-project.org/qmessagebox/images/qtlogo-64.png")));
|
||||||
|
connect(aboutQtAction, &QAction::triggered, QApplication::instance(), &QApplication::aboutQt);
|
||||||
|
|
||||||
auto model = new ArtModel(definitionDirectory, assetDirectory);
|
auto model = new ArtModel(definitionDirectory, assetDirectory);
|
||||||
|
|
||||||
auto pieceListView = new QTableView();
|
auto pieceListView = new QTableView();
|
||||||
|
|
Loading…
Add table
Reference in a new issue