[education/rkward] rkward: Fix deprecation warning
Thomas Friedrichsmeier
null at kde.org
Mon Jun 10 21:10:51 BST 2024
Git commit 44d5457a7fda313a767b0a949aff5ff54d0cf273 by Thomas Friedrichsmeier.
Committed on 10/06/2024 at 20:10.
Pushed by tfry into branch 'master'.
Fix deprecation warning
M +1 -1 rkward/dialogs/rksetupwizard.cpp
M +1 -7 rkward/misc/rkstyle.cpp
M +1 -1 rkward/misc/rkstyle.h
M +9 -1 rkward/rkward.cpp
M +1 -0 rkward/rkward.h
https://invent.kde.org/education/rkward/-/commit/44d5457a7fda313a767b0a949aff5ff54d0cf273
diff --git a/rkward/dialogs/rksetupwizard.cpp b/rkward/dialogs/rksetupwizard.cpp
index 17c443ce9..5effd7597 100644
--- a/rkward/dialogs/rksetupwizard.cpp
+++ b/rkward/dialogs/rksetupwizard.cpp
@@ -553,7 +553,7 @@ void RKSetupWizard::fullInteractiveCheck(InvokationReason reason, const QList<RK
// save backend selection (if one was made)
if (!RInterface::instance()->backendIsDead() && (RKSessionVars::RBinary() != old_r_binary)) {
if (RKSessionVars::isPathInAppImage(RKSessionVars::RBinary())) {
- // the appimage path isn't stable, but leaving this empty causes it to be used by default (via rkward.ini)
+ // the appimage path isn't stable, but an empty setting causes it to be used by default (via rkward.ini)
RKSettingsModuleR::options_r_binary = QString();;
} else {
RKSettingsModuleR::options_r_binary = RKSessionVars::RBinary();
diff --git a/rkward/misc/rkstyle.cpp b/rkward/misc/rkstyle.cpp
index c03195164..196fe0205 100644
--- a/rkward/misc/rkstyle.cpp
+++ b/rkward/misc/rkstyle.cpp
@@ -26,14 +26,8 @@ int RKStyle::spacingHint() {
KColorScheme* RKStyle::viewScheme() {
if (!_view_scheme) {
RK_TRACE(MISC);
+ // Note: Will be updated on changes with RKWardMainWindow::event
_view_scheme = new KColorScheme(QPalette::Normal);
- QObject::connect(qApp, &QGuiApplication::paletteChanged, cleanResources); // will be re-initialized when needed, again; NOTE: Not emitted before Qt 5.13.0, so quirky, before
}
return _view_scheme;
}
-
-void RKStyle::cleanResources() {
- RK_TRACE(MISC);
- delete _view_scheme;
- _view_scheme = nullptr;
-}
diff --git a/rkward/misc/rkstyle.h b/rkward/misc/rkstyle.h
index f2ac381e0..581afaace 100644
--- a/rkward/misc/rkstyle.h
+++ b/rkward/misc/rkstyle.h
@@ -22,8 +22,8 @@ public:
static int spacingHint ();
/// @returns a cached instance of the color scheme for normal views. Particularly useful for setting specials colors in item models
static KColorScheme* viewScheme();
- static void cleanResources();
private:
+friend class RKWardMainWindow;
static KColorScheme* _view_scheme;
};
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index f18f549af..d6f911a20 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -194,7 +194,7 @@ RKWardMainWindow::~RKWardMainWindow() {
delete RControlWindow::getControl ();
factory ()->removeClient (RKComponentMap::getMap ());
delete RKComponentMap::getMap ();
- RKStyle::cleanResources();
+ delete RKStyle::_view_scheme;
}
KatePluginIntegrationApp* RKWardMainWindow::katePluginIntegration () {
@@ -221,6 +221,14 @@ void RKWardMainWindow::closeEvent (QCloseEvent *e) {
}
}
+bool RKWardMainWindow::event(QEvent *e) {
+ if (e->type() == QEvent::ApplicationPaletteChange) {
+ delete RKStyle::_view_scheme;
+ RKStyle::_view_scheme = nullptr;
+ }
+ return KParts::MainWindow::event(e);
+}
+
void RKWardMainWindow::doPostInit () {
RK_TRACE (APP);
diff --git a/rkward/rkward.h b/rkward/rkward.h
index 3bb2d137c..de7e2a4f2 100644
--- a/rkward/rkward.h
+++ b/rkward/rkward.h
@@ -65,6 +65,7 @@ protected:
void initToolViewsAndR ();
/** reimplemented from KMainWindow to call our doQueryClose (), and then (if quitting was not cancelled), invoke an RKQuitAgent to wait for the R-backend to finish up before actually quitting. */
virtual void closeEvent (QCloseEvent *e) override;
+ bool event(QEvent *e) override;
Q_SIGNALS:
void aboutToQuitRKWard ();
void tabForToolViewAdded(QWidget*, QWidget*); // Needed from katepluginintegration
More information about the rkward-tracker
mailing list