[qrvthtool] Set KAboutData.

TODO:
- Use KCrash, but it shows bugs.kde.org as the bug reporting address...
- KIO writes to qrvthtoolrc in ~/.config/, and it doesn't seem like
  there's any way to easily fix this, since KIO uses the default
  path (QStandardPaths::GenericConfigLocation) for KSharedConfig.
This commit is contained in:
David Korth 2025-06-07 11:21:33 -04:00
parent a823d358d6
commit 603243205e
4 changed files with 59 additions and 12 deletions

View File

@ -45,6 +45,14 @@ ENDIF(INSTALL_DEBUG AND NOT SPLIT_DEBUG)
SET(QT_VERSION AUTO CACHE STRING "Qt version to use (default is 'AUTO' to auto-detect Qt6 or Qt5)")
SET_PROPERTY(CACHE QT_VERSION PROPERTY STRINGS AUTO 6 5)
# Enable KDE integration (defaults to ON on Linux)
IF(WIN32 OR APPLE)
SET(ENABLE_KDE_DEFAULT OFF)
ELSE(WIN32 OR APPLE)
SET(ENABLE_KDE_DEFAULT ON)
ENDIF(WIN32 OR APPLE)
OPTION(ENABLE_KDE "Enable KDE integration." ${ENABLE_KDE_DEFAULT})
# Translations
OPTION(ENABLE_NLS "Enable NLS using Qt's built-in localization system." ON)

View File

@ -105,8 +105,10 @@ ELSE()
SET(QRVTHTOOL_TRANSLATIONS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_TRANSLATIONS}")
ENDIF()
# KF5/KF6: Check for KWidgetsAddons headers for notification sounds.
IF(UNIX AND NOT APPLE)
# KDE integration for:
# - KCoreAddons: KAboutData
# - KWidgetsAddons: Notification sounds
IF(ENABLE_KDE)
# Reference: http://www.proli.net/2014/06/21/porting-your-project-to-qt5kf5/
# Find KF5/KF6 Extra CMake Modules.
FIND_PACKAGE(ECM ${ECM_MINIMUM_VERSION} NO_MODULE)
@ -129,16 +131,20 @@ IF(UNIX AND NOT APPLE)
# NOTE: Not needed because KDECompilerSettings isn't used.
#STRING(REPLACE "-std=iso9899:1990" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# Find KF5/KF6. (TODO: Version?)
FIND_PACKAGE(${KF_NS} ${KF_MIN} COMPONENTS WidgetsAddons)
# Find KDE Frameworks.
FIND_PACKAGE(${KF_NS} ${KF_MIN} COMPONENTS CoreAddons WidgetsAddons)
IF(${KF_NS}CoreAddons_FOUND)
SET(HAVE_KF_CoreAddons 1)
ENDIF(${KF_NS}CoreAddons_FOUND)
IF(${KF_NS}WidgetsAddons_FOUND)
SET(HAVE_KF_WidgetsAddons 1)
# KDE code uses pthread_once().
FIND_PACKAGE(Threads REQUIRED)
ENDIF(${KF_NS}WidgetsAddons_FOUND)
ENDIF()
ENDIF(UNIX AND NOT APPLE)
ENDIF(ENABLE_KDE)
# Write the config.h file.
@ -321,6 +327,10 @@ IF(CMAKE_THREAD_LIBS_INIT)
TARGET_LINK_LIBRARIES(qrvthtool PRIVATE ${CMAKE_THREAD_LIBS_INIT})
ENDIF(CMAKE_THREAD_LIBS_INIT)
IF(HAVE_KF_CoreAddons)
TARGET_LINK_LIBRARIES(qrvthtool PRIVATE ${KF_NS}::CoreAddons)
ENDIF(HAVE_KF_CoreAddons)
IF(HAVE_KF_WidgetsAddons)
# NOTE: The library isn't actually needed, but we need to
# link to the target in order to get the headers.

View File

@ -2,7 +2,7 @@
* RVT-H Tool (qrvthtool) *
* config.qrvthtool.h.in: QRvthTool configuration. (source file) *
* *
* Copyright (c) 2013-2024 by David Korth. *
* Copyright (c) 2013-2025 by David Korth. *
* SPDX-License-Identifier: GPL-2.0-or-later *
***************************************************************************/
@ -15,6 +15,9 @@
/* Program version. */
#define VERSION_STRING "@VERSION_STRING@"
/* Define to 1 if you have CoreAddons from KDE Frameworks. */
#cmakedefine HAVE_KF_CoreAddons 1
/* Define to 1 if you have WidgetsAddons from KDE Frameworks. */
#cmakedefine HAVE_KF_WidgetsAddons 1

View File

@ -2,7 +2,7 @@
* RVT-H Tool (librvth) *
* qrvthtool.cpp: Main program. *
* *
* Copyright (c) 2018-2023 by David Korth. *
* Copyright (c) 2018-2025 by David Korth. *
* SPDX-License-Identifier: GPL-2.0-or-later *
***************************************************************************/
@ -10,22 +10,27 @@
#include "windows/QRvtHToolWindow.hpp"
// Qt includes.
// Qt includes
#include <QApplication>
#include <QtCore/QDir>
// KDE
#ifdef HAVE_KF_CoreAddons
# include <KAboutData>
#endif /* HAVE_KF_CoreAddons */
// TranslationManager
#include "TranslationManager.hpp"
#ifdef _WIN32
# include <windows.h>
# include <tchar.h>
# include <windows.h>
# include <tchar.h>
extern UINT WM_TaskbarButtonCreated;
UINT WM_TaskbarButtonCreated;
// MSGFLT_ADD (requires _WIN32_WINNT >= 0x0600)
#ifndef MSGFLT_ADD
# define MSGFLT_ADD 1
# define MSGFLT_ADD 1
#endif
/**
@ -90,6 +95,27 @@ int main(int argc, char *argv[])
app->setDesktopFileName(QStringLiteral("com.gerbilsoft.qrvthtool"));
#endif /* QT_VERSION >= QT_VERSION_CHECK(5,7,0) */
#ifdef HAVE_KF_CoreAddons
// Set up KAboutData.
QString applicationDisplayName = QStringLiteral("RVT-H Tool");
KAboutData aboutData(
app->applicationName(), // componentName
applicationDisplayName, // displayName
app->applicationVersion(), // version
applicationDisplayName, // shortDescription (TODO: Better value?)
KAboutLicense::GPL_V2, // licenseType
QStringLiteral("Copyright (c) 2018-2025 by David Korth."), // copyrightStatement
QString(), // otherText
QLatin1String("https://github.com/GerbilSoft/rvthtool"), // homePageAddress
QLatin1String("https://github.com/GerbilSoft/rvthtool/issues") // bugAddress
);
KAboutData::setApplicationData(aboutData);
#endif /* HAVE_KF_CoreAddons */
// Initialize KCrash.
// FIXME: It shows bugs.kde.org as the bug reporting address, which isn't wanted...
//KCrash::initialize();
// Initialize the TranslationManager.
TranslationManager *const tsm = TranslationManager::instance();
tsm->setTranslation(QLocale::system().name());