Simplify main, use version from meta-data defined in CMake
* Simplify code * Set meta-data for Qt application via helpers from c++utilities and qtutilities * Set sensible default settings for Qt via helper from qtutilities for more modern behavior regarding High DPI scaling and theming, e.g. for better dark mode support under Windows 11
This commit is contained in:
parent
8dfca58470
commit
370304e576
|
@ -6,9 +6,10 @@ cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
|||
project(pianobooster)
|
||||
set(META_PROJECT_NAME ${PROJECT_NAME})
|
||||
set(META_PROJECT_TYPE application)
|
||||
set(META_APP_NAME "PianoBooster")
|
||||
set(META_APP_NAME "Piano Booster")
|
||||
set(META_APP_CATEGORIES "Music;Education;")
|
||||
set(META_APP_AUTHOR "Martchus")
|
||||
set(META_APP_DOMAIN "https://github.com/${META_APP_AUTHOR}")
|
||||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||
set(META_APP_DESCRIPTION "Learn the piano just by playing a game")
|
||||
set(META_VERSION_MAJOR 1)
|
||||
|
@ -309,3 +310,5 @@ endif()
|
|||
if(DEBUG_LOG_TIMING)
|
||||
ADD_DEFINITIONS(-DPB_LOG_TIMING)
|
||||
endif()
|
||||
|
||||
include(ConfigHeader)
|
||||
|
|
|
@ -19,36 +19,39 @@
|
|||
|
||||
****************************************************************************/
|
||||
|
||||
#include <qtutilities/settingsdialog/qtsettings.h>
|
||||
#include <qtutilities/resources/resources.h>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "QtWindow.h"
|
||||
#include "version.h"
|
||||
#include "resources/config.h"
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("PianoBooster"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("https://github.com/pianobooster/PianoBooster"));
|
||||
QCoreApplication::setApplicationName(QStringLiteral("Piano Booster"));
|
||||
QCoreApplication::setApplicationVersion(QStringLiteral(PB_VERSION));
|
||||
QGuiApplication::setDesktopFileName(QStringLiteral("pianobooster"));
|
||||
int main(int argc, char *argv[]) {
|
||||
// instantiate app and apply sensible default settings
|
||||
SET_QT_APPLICATION_INFO;
|
||||
QGuiApplication::setDesktopFileName(QStringLiteral(PROJECT_NAME));
|
||||
auto app = QApplication(argc, argv);
|
||||
auto qtSettings = QtUtilities::QtSettings();
|
||||
qtSettings.disableNotices();
|
||||
qtSettings.apply();
|
||||
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
QStringList argList = QCoreApplication::arguments();
|
||||
for (const QString &arg : argList){
|
||||
if (arg == QLatin1String("--version")) {
|
||||
fprintf(stdout, "pianobooster " PB_VERSION "\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
// print version
|
||||
const auto argList = QCoreApplication::arguments();
|
||||
for (const auto &arg : argList){
|
||||
if (arg == QLatin1String("--version")) {
|
||||
fprintf(stdout, "pianobooster " APP_VERSION "\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
QApplication app(argc, argv);
|
||||
QtWindow window;
|
||||
// show main window and execute app
|
||||
auto window = QtWindow();
|
||||
window.show();
|
||||
|
||||
int value = app.exec();
|
||||
const auto ret = app.exec();
|
||||
closeLogs();
|
||||
return value;
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "GlView.h"
|
||||
#include "QtWindow.h"
|
||||
#include "version.h"
|
||||
#include "resources/config.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSurfaceFormat>
|
||||
|
@ -290,7 +290,7 @@ void QtWindow::decodeCommandLine()
|
|||
}
|
||||
else if (arg.startsWith("-v") || arg.startsWith("--version"))
|
||||
{
|
||||
fprintf(stdout, "pianobooster Version " PB_VERSION"\n");
|
||||
fprintf(stdout, "pianobooster Version " APP_VERSION "\n");
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
|
@ -597,7 +597,7 @@ void QtWindow::about()
|
|||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle (tr("About Piano Booster"));
|
||||
msgBox.setText(
|
||||
tr("<b>PianoBooster - Version %1</b> <br><br>").arg(PB_VERSION) %
|
||||
tr("<b>PianoBooster - Version %1</b> <br><br>").arg(APP_VERSION) %
|
||||
tr("<b>Boost</b> your <b>Piano</b> playing skills!<br><br>") %
|
||||
QStringLiteral("<a href=\"https://www.pianobooster.org/\" ><b>https://www.pianobooster.org/</b></a><br><br>") %
|
||||
tr("Copyright(c) L. J. Barman, 2008-2020; All rights reserved.<br>") %
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "GuiSidePanel.h"
|
||||
#include "QtWindow.h"
|
||||
#include "version.h"
|
||||
#include "resources/config.h"
|
||||
|
||||
#if WITH_INTERNAL_FLUIDSYNTH
|
||||
#include "MidiDeviceFluidSynth.h"
|
||||
|
@ -384,7 +385,7 @@ void CSettings::loadSettings()
|
|||
{
|
||||
unzipBoosterMusicBooks();
|
||||
// Set default values
|
||||
setValue("PianoBooster/Version", PB_VERSION);
|
||||
setValue("PianoBooster/Version", APP_VERSION);
|
||||
setDefaultValue("ShortCuts/LeftHand", "F2");
|
||||
setDefaultValue("ShortCuts/BothHands","F3");
|
||||
setDefaultValue("ShortCuts/RightHand","F4");
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
#define PB_VERSION "1.0.1-SNAPSHOT"
|
||||
#define MUSIC_RELEASE 4
|
||||
|
|
Loading…
Reference in New Issue