[education/rkward/kf5] rkward: Install icons via qrc rather than regular files (fixes loading of app icon)
Thomas Friedrichsmeier
null at kde.org
Wed Apr 10 16:12:08 BST 2024
Git commit f355cb876c9c02cd1c942be57cae98758f9cffda by Thomas Friedrichsmeier.
Committed on 04/04/2024 at 12:44.
Pushed by tfry into branch 'kf5'.
Install icons via qrc rather than regular files (fixes loading of app icon)
M +1 -1 rkward/CMakeLists.txt
M +1 -18 rkward/icons/CMakeLists.txt
M +0 -2 rkward/icons/app-icon/CMakeLists.txt
A +26 -0 rkward/icons/icons.qrc
M +4 -8 rkward/misc/rkstandardicons.cpp
M +1 -0 rkward/rkward.cpp
M +3 -4 rkward/windows/rktoplevelwindowgui.cpp
https://invent.kde.org/education/rkward/-/commit/f355cb876c9c02cd1c942be57cae98758f9cffda
diff --git a/rkward/CMakeLists.txt b/rkward/CMakeLists.txt
index 6b216da7a..3a7ba3a6e 100644
--- a/rkward/CMakeLists.txt
+++ b/rkward/CMakeLists.txt
@@ -40,7 +40,7 @@ SET(RKWard_Sources
robjectviewer.cpp
rkconsole.cpp
)
-QT_ADD_RESOURCES(RKWard_Sources resources.qrc)
+QT_ADD_RESOURCES(RKWard_Sources resources.qrc icons/icons.qrc)
# somehow the detected R paths from FindR.cmake do not get passed down automatically
GET_DIRECTORY_PROPERTY(R_EXECUTABLE DIRECTORY rbackend DEFINITION R_EXECUTABLE)
diff --git a/rkward/icons/CMakeLists.txt b/rkward/icons/CMakeLists.txt
index 34360f894..1e873da4c 100644
--- a/rkward/icons/CMakeLists.txt
+++ b/rkward/icons/CMakeLists.txt
@@ -4,21 +4,4 @@
# SPDX-License-Identifier: GPL-2.0-or-later
ADD_SUBDIRECTORY(app-icon)
-INSTALL(FILES
- rkward_logo.png
- function.png
- list.png
- matrix.png
- menu.svg
- data-numeric.png
- data-factor.png
- data-logical.png
- window_back.png
- window_forward.png
- run_line.png
- run_selection.png
- run_all.png
- s4_slots.png
- paste_inside_selection.png
- paste_inside_table.png
- DESTINATION ${KDE_INSTALL_DATADIR}/rkward/icons)
+# Note: Icons are installed via QRC from CMakeLists.txt in parent folder
diff --git a/rkward/icons/app-icon/CMakeLists.txt b/rkward/icons/app-icon/CMakeLists.txt
index 5eb42f8af..aabb03291 100644
--- a/rkward/icons/app-icon/CMakeLists.txt
+++ b/rkward/icons/app-icon/CMakeLists.txt
@@ -3,5 +3,3 @@
# SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
# SPDX-License-Identifier: GPL-2.0-or-later
ECM_INSTALL_ICONS(ICONS 16-apps-rkward.png 22-apps-rkward.png 32-apps-rkward.png 48-apps-rkward.png 64-apps-rkward.png 128-apps-rkward.png sc-apps-rkward.svgz DESTINATION ${KDE_INSTALL_ICONDIR})
-
-INSTALL(FILES 64-apps-rkward.png DESTINATION ${KDE_INSTALL_DATADIR}/rkward/icons) # see rkstandardicons.cpp
diff --git a/rkward/icons/icons.qrc b/rkward/icons/icons.qrc
new file mode 100644
index 000000000..c92b3045b
--- /dev/null
+++ b/rkward/icons/icons.qrc
@@ -0,0 +1,26 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<!--- This file is part of the RKWard project (https://rkward.kde.org).
+SPDX-FileCopyrightText: by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
+SPDX-License-Identifier: GPL-2.0-or-later
+-->
+<qresource prefix="/rkward/icons">
+ <file>rkward_logo.png</file>
+ <file>function.png</file>
+ <file>list.png</file>
+ <file>matrix.png</file>
+ <file>menu.svg</file>
+ <file>data-numeric.png</file>
+ <file>data-factor.png</file>
+ <file>data-logical.png</file>
+ <file>window_back.png</file>
+ <file>window_forward.png</file>
+ <file>run_line.png</file>
+ <file>run_selection.png</file>
+ <file>run_all.png</file>
+ <file>s4_slots.png</file>
+ <file>paste_inside_selection.png</file>
+ <file>paste_inside_table.png</file>
+ <file alias="rkward.svgz">app-icon/sc-apps-rkward.svgz</file>
+</qresource>
+</RCC>
diff --git a/rkward/misc/rkstandardicons.cpp b/rkward/misc/rkstandardicons.cpp
index 83aac57ce..58f6099a4 100644
--- a/rkward/misc/rkstandardicons.cpp
+++ b/rkward/misc/rkstandardicons.cpp
@@ -1,6 +1,6 @@
/*
rkstandardicons - This file is part of RKWard (https://rkward.kde.org). Created: Wed Oct 24 2007
-SPDX-FileCopyrightText: 2007-2018 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2007-2024 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -34,7 +34,7 @@ void RKStandardIcons::doInitIcons () {
RK_TRACE (APP);
// base path for icons provided by rkward itself
- QString rkward_icon_base = RKCommonFunctions::getRKWardDataDir () + "icons/";
+ QString rkward_icon_base = ":/rkward/icons/";
// actions
icons[ActionRunAll] = QIcon (rkward_icon_base + "run_all.png");
@@ -122,12 +122,8 @@ void RKStandardIcons::doInitIcons () {
icons[DocumentPDF] = QIcon::fromTheme("application-pdf");
- // this used to be accessible as QApplication::windowIcon(), but apparently no longer in Qt5
- if (QFileInfo::exists(rkward_icon_base + "64-apps-rkward.png")) {
- icons[RKWardIcon] = QIcon(rkward_icon_base + "64-apps-rkward.png");
- } else {
- icons[RKWardIcon] = QIcon::fromTheme("rkward"); // Does not work on Windows, thus only used as fallback
- }
+ // this used to be accessible as QApplication::windowIcon(), but apparently no longer since Qt5 (despite documentation)
+ icons[RKWardIcon] = QIcon(rkward_icon_base + "rkward.svgz");
RK_DO ({
for (int i = ActionRunAll; i < Last; ++i) {
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 8fae0170d..f0494a1a9 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -113,6 +113,7 @@ RKWardMainWindow::RKWardMainWindow() : KParts::MainWindow() {
RK_ASSERT(rkward_mainwin == nullptr);
Q_INIT_RESOURCE(resources);
+ Q_INIT_RESOURCE(icons);
testmode_suppress_dialogs = false;
gui_rebuild_locked = true;
no_ask_save = true;
diff --git a/rkward/windows/rktoplevelwindowgui.cpp b/rkward/windows/rktoplevelwindowgui.cpp
index ab3b2d999..b4007984d 100644
--- a/rkward/windows/rktoplevelwindowgui.cpp
+++ b/rkward/windows/rktoplevelwindowgui.cpp
@@ -1,6 +1,6 @@
/*
rktoplevelwindowgui - This file is part of RKWard (https://rkward.kde.org). Created: Tue Apr 24 2007
-SPDX-FileCopyrightText: 2007-2020 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
+SPDX-FileCopyrightText: 2007-2024 by Thomas Friedrichsmeier <thomas.friedrichsmeier at kdemail.net>
SPDX-FileContributor: The RKWard Team <rkward-devel at kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
@@ -37,7 +37,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
#include "../windows/rkmdiwindow.h"
#include "../misc/rkstandardicons.h"
#include "../misc/rkprogresscontrol.h"
-#include "../misc/rkcommonfunctions.h"
#include "../misc/rkoutputdirectory.h"
#include "../plugin/rkcomponentmap.h"
#include "../dialogs/rkerrordialog.h"
@@ -74,11 +73,11 @@ RKTopLevelWindowGUI::RKTopLevelWindowGUI(KXmlGuiWindow *for_window) : QObject(fo
// NOTE: enabling / disabling the prev/next actions is not a good idea. It will cause the script windows to "accept" their shortcuts, when disabled
prev_action = actionCollection ()->addAction ("prev_window", this, SLOT (previousWindow()));
prev_action->setText (i18n ("Previous Window"));
- prev_action->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/window_back.png"));
+ prev_action->setIcon(QIcon(":/rkward/icons/window_back.png"));
actionCollection ()->setDefaultShortcut (prev_action, Qt::ControlModifier | Qt::Key_Tab);
next_action = actionCollection ()->addAction ("next_window", this, SLOT (nextWindow()));
next_action->setText (i18n ("Next Window"));
- next_action->setIcon (QIcon (RKCommonFunctions::getRKWardDataDir () + "icons/window_forward.png"));
+ next_action->setIcon(QIcon(":rkward/icons/window_forward.png"));
actionCollection ()->setDefaultShortcut (next_action, Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Tab);
QAction* action = actionCollection ()->addAction ("window_activate_docview", this, SLOT(activateDocumentView()));
More information about the rkward-tracker
mailing list