Manager: Add Help menu

Move the About dialog into its own file and object
This commit is contained in:
Alexander Babikov
2025-07-27 04:31:13 +05:00
parent 7dcf25bf3a
commit 3e1c6d3dae
7 changed files with 151 additions and 42 deletions

View File

@@ -88,6 +88,8 @@ add_library(ui STATIC
qt_openglrenderer.cpp qt_openglrenderer.cpp
qt_openglrenderer.hpp qt_openglrenderer.hpp
qt_glsl_parser.cpp qt_glsl_parser.cpp
qt_about.cpp
qt_about.hpp
qt_settings.cpp qt_settings.cpp
qt_settings.hpp qt_settings.hpp

75
src/qt/qt_about.cpp Normal file
View File

@@ -0,0 +1,75 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* About dialog module.
*
*
*
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
* Cacodemon345
* Teemu Korhonen
* dob205
*
* Copyright 2021 Joakim L. Gilje
* Copyright 2021-2022 Cacodemon345
* Copyright 2021-2022 Teemu Korhonen
* Copyright 2022 dob205
*/
#include "qt_about.hpp"
extern "C" {
#include <86box/86box.h>
#include <86box/version.h>
}
#include <QMessageBox>
#include <QIcon>
#include <QPushButton>
#include <QUrl>
#include <QDesktopServices>
About::About(QWidget *parent)
{
setTextFormat(Qt::RichText);
QString versioninfo;
#ifdef EMU_GIT_HASH
versioninfo = QString(" [%1]").arg(EMU_GIT_HASH);
#endif
#ifdef USE_DYNAREC
# ifdef USE_NEW_DYNAREC
# define DYNAREC_STR "new dynarec"
# else
# define DYNAREC_STR "old dynarec"
# endif
#else
# define DYNAREC_STR "no dynarec"
#endif
versioninfo.append(QString(" [%1, %2]").arg(QSysInfo::buildCpuArchitecture(), tr(DYNAREC_STR)));
setText(QString("<b>%3%1%2</b>").arg(EMU_VERSION_FULL, versioninfo, tr("86Box v")));
setInformativeText(tr("An emulator of old computers\n\nAuthors: Miran Grča (OBattler), RichardG867, Jasmine Iwanek, TC1995, coldbrewed, Teemu Korhonen (Manaatti), Joakim L. Gilje, Adrien Moulin (elyosh), Daniel Balsom (gloriouscow), Cacodemon345, Fred N. van Kempen (waltje), Tiseno100, reenigne, and others.\n\nWith previous core contributions from Sarah Walker, leilei, JohnElliott, greatpsycho, and others.\n\nReleased under the GNU General Public License version 2 or later. See LICENSE for more information."));
setWindowTitle(tr("About 86Box"));
const auto closeButton = addButton("OK", QMessageBox::ButtonRole::AcceptRole);
setEscapeButton(closeButton);
const auto webSiteButton = addButton(EMU_SITE, QMessageBox::ButtonRole::HelpRole);
webSiteButton->connect(webSiteButton, &QPushButton::released, []() {
QDesktopServices::openUrl(QUrl("https://" EMU_SITE));
});
#ifdef RELEASE_BUILD
setIconPixmap(QIcon(":/settings/qt/icons/86Box-green.ico").pixmap(32, 32));
#elif defined ALPHA_BUILD
setIconPixmap(QIcon(":/settings/qt/icons/86Box-red.ico").pixmap(32, 32));
#elif defined BETA_BUILD
setIconPixmap(QIcon(":/settings/qt/icons/86Box-yellow.ico").pixmap(32, 32));
#else
setIconPixmap(QIcon(":/settings/qt/icons/86Box-gray.ico").pixmap(32, 32));
#endif
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
}
About::~About()
= default;

13
src/qt/qt_about.hpp Normal file
View File

@@ -0,0 +1,13 @@
#ifndef QT_ABOUT_HPP
#define QT_ABOUT_HPP
#include <QMessageBox>
class About final : public QMessageBox {
Q_OBJECT
public:
explicit About(QWidget *parent = nullptr);
~About() override;
};
#endif // QT_ABOUT_HPP

View File

@@ -97,6 +97,7 @@ extern bool cpu_thread_running;
#include <unordered_map> #include <unordered_map>
#include "qt_settings.hpp" #include "qt_settings.hpp"
#include "qt_about.hpp"
#include "qt_machinestatus.hpp" #include "qt_machinestatus.hpp"
#include "qt_mediamenu.hpp" #include "qt_mediamenu.hpp"
#include "qt_util.hpp" #include "qt_util.hpp"
@@ -1908,42 +1909,8 @@ MainWindow::on_actionAbout_Qt_triggered()
void void
MainWindow::on_actionAbout_86Box_triggered() MainWindow::on_actionAbout_86Box_triggered()
{ {
QMessageBox msgBox; const auto msgBox = new About(this);
msgBox.setTextFormat(Qt::RichText); msgBox->exec();
QString versioninfo;
#ifdef EMU_GIT_HASH
versioninfo = QString(" [%1]").arg(EMU_GIT_HASH);
#endif
#ifdef USE_DYNAREC
# ifdef USE_NEW_DYNAREC
# define DYNAREC_STR "new dynarec"
# else
# define DYNAREC_STR "old dynarec"
# endif
#else
# define DYNAREC_STR "no dynarec"
#endif
versioninfo.append(QString(" [%1, %2]").arg(QSysInfo::buildCpuArchitecture(), tr(DYNAREC_STR)));
msgBox.setText(QString("<b>%3%1%2</b>").arg(EMU_VERSION_FULL, versioninfo, tr("86Box v")));
msgBox.setInformativeText(tr("An emulator of old computers\n\nAuthors: Miran Grča (OBattler), RichardG867, Jasmine Iwanek, TC1995, coldbrewed, Teemu Korhonen (Manaatti), Joakim L. Gilje, Adrien Moulin (elyosh), Daniel Balsom (gloriouscow), Cacodemon345, Fred N. van Kempen (waltje), Tiseno100, reenigne, and others.\n\nWith previous core contributions from Sarah Walker, leilei, JohnElliott, greatpsycho, and others.\n\nReleased under the GNU General Public License version 2 or later. See LICENSE for more information."));
msgBox.setWindowTitle(tr("About 86Box"));
const auto closeButton = msgBox.addButton("OK", QMessageBox::ButtonRole::AcceptRole);
msgBox.setEscapeButton(closeButton);
const auto webSiteButton = msgBox.addButton(EMU_SITE, QMessageBox::ButtonRole::HelpRole);
webSiteButton->connect(webSiteButton, &QPushButton::released, []() {
QDesktopServices::openUrl(QUrl("https://" EMU_SITE));
});
#ifdef RELEASE_BUILD
msgBox.setIconPixmap(QIcon(":/settings/qt/icons/86Box-green.ico").pixmap(32, 32));
#elif defined ALPHA_BUILD
msgBox.setIconPixmap(QIcon(":/settings/qt/icons/86Box-red.ico").pixmap(32, 32));
#elif defined BETA_BUILD
msgBox.setIconPixmap(QIcon(":/settings/qt/icons/86Box-yellow.ico").pixmap(32, 32));
#else
msgBox.setIconPixmap(QIcon(":/settings/qt/icons/86Box-gray.ico").pixmap(32, 32));
#endif
msgBox.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
msgBox.exec();
} }
void void

View File

@@ -22,10 +22,12 @@
#if EMU_BUILD_NUM != 0 #if EMU_BUILD_NUM != 0
# include "qt_updatecheckdialog.hpp" # include "qt_updatecheckdialog.hpp"
#endif #endif
#include "qt_about.hpp"
#include <QLineEdit> #include <QLineEdit>
#include <QStringListModel> #include <QStringListModel>
#include <QCompleter> #include <QCompleter>
#include <QDesktopServices>
VMManagerMainWindow:: VMManagerMainWindow::
VMManagerMainWindow(QWidget *parent) VMManagerMainWindow(QWidget *parent)
@@ -186,8 +188,27 @@ VMManagerMainWindow::checkForUpdatesTriggered()
} }
#endif #endif
void VMManagerMainWindow::on_actionExit_triggered() void
VMManagerMainWindow::on_actionExit_triggered()
{ {
this->close(); this->close();
} }
void
VMManagerMainWindow::on_actionAbout_Qt_triggered()
{
QApplication::aboutQt();
}
void
VMManagerMainWindow::on_actionAbout_86Box_triggered()
{
const auto msgBox = new About(this);
msgBox->exec();
}
void
VMManagerMainWindow::on_actionDocumentation_triggered()
{
QDesktopServices::openUrl(QUrl(EMU_DOCS_URL));
}

View File

@@ -55,6 +55,9 @@ private slots:
#endif #endif
void on_actionExit_triggered(); void on_actionExit_triggered();
void on_actionDocumentation_triggered();
void on_actionAbout_86Box_triggered();
void on_actionAbout_Qt_triggered();
protected: protected:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;

View File

@@ -38,8 +38,17 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
</widget> </widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionDocumentation"/>
<addaction name="actionAbout_86Box"/>
<addaction name="actionAbout_Qt"/>
</widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuTools"/> <addaction name="menuTools"/>
<addaction name="menuHelp"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
@@ -71,11 +80,6 @@
<addaction name="actionSettings"/> <addaction name="actionSettings"/>
<addaction name="actionNew_Machine"/> <addaction name="actionNew_Machine"/>
</widget> </widget>
<action name="actionDo_something">
<property name="text">
<string>Do something</string>
</property>
</action>
<action name="actionStartPause"> <action name="actionStartPause">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@@ -217,6 +221,30 @@
<enum>QAction::QuitRole</enum> <enum>QAction::QuitRole</enum>
</property> </property>
</action> </action>
<action name="actionDocumentation">
<property name="text">
<string>&amp;Documentation...</string>
</property>
</action>
<action name="actionAbout_86Box">
<property name="text">
<string>&amp;About 86Box...</string>
</property>
<property name="menuRole">
<enum>QAction::AboutRole</enum>
</property>
</action>
<action name="actionAbout_Qt">
<property name="text">
<string>About Qt</string>
</property>
<property name="visible">
<bool>false</bool>
</property>
<property name="menuRole">
<enum>QAction::AboutQtRole</enum>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../qt_resources.qrc"/> <include location="../qt_resources.qrc"/>