[education/rkward] rkward/windows: Modernize one more slot connection
Thomas Friedrichsmeier
null at kde.org
Sun May 12 16:32:29 BST 2024
Git commit 0889f2bc9a79e73df0b111c0c1c8113b19b27e8d by Thomas Friedrichsmeier.
Committed on 12/05/2024 at 11:56.
Pushed by tfry into branch 'master'.
Modernize one more slot connection
M +6 -8 rkward/windows/rktoplevelwindowgui.cpp
M +1 -1 rkward/windows/rktoplevelwindowgui.h
https://invent.kde.org/education/rkward/-/commit/0889f2bc9a79e73df0b111c0c1c8113b19b27e8d
diff --git a/rkward/windows/rktoplevelwindowgui.cpp b/rkward/windows/rktoplevelwindowgui.cpp
index 83eafcb0a..097845c32 100644
--- a/rkward/windows/rktoplevelwindowgui.cpp
+++ b/rkward/windows/rktoplevelwindowgui.cpp
@@ -126,11 +126,11 @@ void RKTopLevelWindowGUI::initToolWindowActions () {
const auto windows = RKToolWindowList::registeredToolWindows ();
for (const RKToolWindowList::ToolWindowRepresentation& rep : windows) {
QString id = QLatin1String ("window_show_") + rep.id;
- action = actionCollection ()->addAction (id, this, SLOT (toggleToolView()));
+ QString wid = rep.id;
+ action = actionCollection()->addAction(id, this, [this, wid](){ toggleToolView(wid); });
action->setText (i18n ("Show/Hide %1", rep.window->shortCaption ()));
action->setIcon (rep.window->windowIcon ());
actionCollection ()->setDefaultShortcut (action, rep.default_shortcut);
- action->setProperty ("rk_toolwindow_id", rep.id);
QDomElement e = doc.createElement (action_tag);
e.setAttribute (name_attr, id);
menu.insertBefore (e, ref);
@@ -204,14 +204,12 @@ void RKTopLevelWindowGUI::toggleToolView (RKMDIWindow *tool_window) {
}
}
-void RKTopLevelWindowGUI::toggleToolView () {
+void RKTopLevelWindowGUI::toggleToolView(const QString &id) {
RK_TRACE (APP);
- QAction *act = dynamic_cast<QAction*> (sender ());
- RK_ASSERT (act);
- RKMDIWindow *win = RKToolWindowList::findToolWindowById (act->property ("rk_toolwindow_id").toString ());
- RK_ASSERT (win);
- toggleToolView (win);
+ RKMDIWindow *win = RKToolWindowList::findToolWindowById(id);
+ RK_ASSERT(win);
+ toggleToolView(win);
}
void RKTopLevelWindowGUI::showHelpSearch () {
diff --git a/rkward/windows/rktoplevelwindowgui.h b/rkward/windows/rktoplevelwindowgui.h
index 82f586f40..022f9859f 100644
--- a/rkward/windows/rktoplevelwindowgui.h
+++ b/rkward/windows/rktoplevelwindowgui.h
@@ -55,7 +55,7 @@ public Q_SLOTS:
/** configure key bindings. Reimplemented to show notice before the actual dialog. */
void configureToolbars ();
private Q_SLOTS:
- void toggleToolView ();
+ void toggleToolView(const QString &id);
void previousWindow ();
void nextWindow ();
private:
More information about the rkward-tracker
mailing list