summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2016-04-06 12:52:37 +0200
committerAndre Heinecke <[email protected]>2016-04-06 12:52:37 +0200
commitb89cc61d380b6e2ea8a1b03d7646b133cd5b063e (patch)
tree9c7068e5ce03d6212b460705f23a7a47d63f4af4
parentc33e24a26e7eda8129c48dc07d10faab3c4815c1 (diff)
Fix KXmlGui shortcut warnings
Tabwidget actions are now created with the collection in addActions. Functions that would cause a runtime warning have been removed from action_data. Focus to Quick search shortcut is now set through the collection.
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/utils/action_data.cpp20
-rw-r--r--src/utils/action_data.h9
-rw-r--r--src/view/tabwidget.cpp119
4 files changed, 61 insertions, 89 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 0e59475..c1f6d9c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -347,8 +347,8 @@ void MainWindow::Private::setupActions()
KStandardAction::preferences(qApp, SLOT(openOrRaiseConfigDialog()), coll);
focusToClickSearchAction = new QAction(i18n("Set Focus to Quick Search"), q);
- focusToClickSearchAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Q));
coll->addAction(QStringLiteral("focus_to_quickseach"), focusToClickSearchAction);
+ coll->setDefaultShortcut(focusToClickSearchAction, QKeySequence(Qt::ALT + Qt::Key_Q));
connect(focusToClickSearchAction, SIGNAL(triggered(bool)), q, SLOT(slotFocusQuickSearch()));
clipboadMenu = new ClipboardMenu(q);
clipboadMenu->setMainWindow(q);
diff --git a/src/utils/action_data.cpp b/src/utils/action_data.cpp
index 2791fdd..e62cdfc 100644
--- a/src/utils/action_data.cpp
+++ b/src/utils/action_data.cpp
@@ -63,16 +63,7 @@ QAction *Kleo::createAction(const action_data &ad, QObject *parent)
return a;
}
-QAction *Kleo::make_action_from_data(const action_data &ad, QObject *parent)
-{
- QAction *const a = createAction(ad, parent);
- if (!ad.shortcut.isEmpty()) {
- a->setShortcut(QKeySequence(ad.shortcut));
- }
- return a;
-}
-
-QAction *Kleo::make_action_from_data_with_collection(const action_data &ad, KActionCollection *coll)
+QAction *Kleo::make_action_from_data(const action_data &ad, KActionCollection *coll)
{
QAction *const a = createAction(ad, coll);
@@ -82,16 +73,9 @@ QAction *Kleo::make_action_from_data_with_collection(const action_data &ad, KAct
return a;
}
-void Kleo::make_actions_from_data(const action_data *ads, unsigned int size, QObject *parent)
-{
- for (unsigned int i = 0; i < size; ++i) {
- make_action_from_data(ads[i], parent);
- }
-}
-
void Kleo::make_actions_from_data(const action_data *ads, unsigned int size, KActionCollection *coll)
{
for (unsigned int i = 0; i < size; ++i) {
- coll->addAction(QLatin1String(ads[i].name), make_action_from_data_with_collection(ads[i], coll));
+ coll->addAction(QLatin1String(ads[i].name), make_action_from_data(ads[i], coll));
}
}
diff --git a/src/utils/action_data.h b/src/utils/action_data.h
index ae13abe..c4dba45 100644
--- a/src/utils/action_data.h
+++ b/src/utils/action_data.h
@@ -55,21 +55,14 @@ struct action_data {
};
void make_actions_from_data(const action_data *data, unsigned int numData, KActionCollection *collection);
-void make_actions_from_data(const action_data *data, unsigned int numData, QObject *parent);
template <unsigned int N>
inline void make_actions_from_data(const action_data(&data)[N], KActionCollection *collection)
{
make_actions_from_data(data, N, collection);
}
-template <unsigned int N>
-inline void make_actions_from_data(const action_data(&data)[N], QObject *parent)
-{
- make_actions_from_data(data, N, parent);
-}
-QAction *make_action_from_data(const action_data &data, QObject *parent);
-QAction *make_action_from_data_with_collection(const action_data &ad, KActionCollection *coll);
+QAction *make_action_from_data(const action_data &ad, KActionCollection *coll);
QAction *createAction(const action_data &ad, QObject *parent);
}
diff --git a/src/view/tabwidget.cpp b/src/view/tabwidget.cpp
index 8a6e72e..499ebf0 100644
--- a/src/view/tabwidget.cpp
+++ b/src/view/tabwidget.cpp
@@ -444,64 +444,6 @@ TabWidget::Private::Private(TabWidget *qq)
slotContextMenu(p);
});
- const action_data actionDataNew = {
- "window_new_tab", i18n("New Tab"), i18n("Open a new tab"),
- "tab-new-background", q, SLOT(slotNewTab()), QStringLiteral("CTRL+SHIFT+N"), false, true
- };
-
- newAction = make_action_from_data(actionDataNew, q);
-
- struct action_data actionData[NumPageActions] = {
- {
- "window_rename_tab", i18n("Rename Tab..."), i18n("Rename this tab"),
- "edit-rename", q, SLOT(slotRenameCurrentTab()), QStringLiteral("CTRL+SHIFT+R"), false, false
- },
- {
- "window_duplicate_tab", i18n("Duplicate Tab"), i18n("Duplicate this tab"),
- "tab-duplicate", q, SLOT(slotDuplicateCurrentTab()), QStringLiteral("CTRL+SHIFT+D"), false, true
- },
- {
- "window_close_tab", i18n("Close Tab"), i18n("Close this tab"),
- "tab-close", q, SLOT(slotCloseCurrentTab()), QStringLiteral("CTRL+SHIFT+W"), false, false
- }, // ### CTRL-W when available
- {
- "window_move_tab_left", i18n("Move Tab Left"), QString(),
- 0, q, SLOT(slotMoveCurrentTabLeft()), QStringLiteral("CTRL+SHIFT+LEFT"), false, false
- },
- {
- "window_move_tab_right", i18n("Move Tab Right"), QString(),
- 0, q, SLOT(slotMoveCurrentTabRight()), QStringLiteral("CTRL+SHIFT+RIGHT"), false, false
- },
- {
- "window_view_hierarchical", i18n("Hierarchical Certificate List"), QString(),
- 0, q, SLOT(slotToggleHierarchicalView(bool)), QString(), true, false
- },
- {
- "window_expand_all", i18n("Expand All"), QString(),
- 0, q, SLOT(slotExpandAll()), QStringLiteral("CTRL+."), false, false
- },
- {
- "window_collapse_all", i18n("Collapse All"), QString(),
- 0, q, SLOT(slotCollapseAll()), QStringLiteral("CTRL+,"), false, false
- },
- };
-
- for (unsigned int i = 0; i < NumPageActions; ++i) {
- currentPageActions[i] = make_action_from_data(actionData[i], q);
- }
-
- for (unsigned int i = 0; i < NumPageActions; ++i) {
- action_data ad = actionData[i];
- assert(QString::fromLatin1(ad.name).startsWith(QStringLiteral("window_")));
- ad.name = ad.name + strlen("window_");
- ad.tooltip.clear();
- ad.receiver = 0;
- ad.shortcut.clear();
- otherPageActions[i] = make_action_from_data(ad, q);
- }
-
- setCornerAction(newAction, Qt::TopLeftCorner);
- setCornerAction(currentPageActions[Close], Qt::TopRightCorner);
}
void TabWidget::Private::slotContextMenu(const QPoint &p)
@@ -811,11 +753,64 @@ void TabWidget::createActions(KActionCollection *coll)
if (!coll) {
return;
}
- coll->addAction(d->newAction->objectName(), d->newAction);
- for (unsigned int i = 0; i < Private::NumPageActions; ++i) {
- QAction *a = d->currentPageActions[i];
- coll->addAction(a->objectName(), a);
+ const action_data actionDataNew = {
+ "window_new_tab", i18n("New Tab"), i18n("Open a new tab"),
+ "tab-new-background", this, SLOT(slotNewTab()), QStringLiteral("CTRL+SHIFT+N"), false, true
+ };
+
+ d->newAction = make_action_from_data(actionDataNew, coll);
+
+ struct action_data actionData[] = {
+ {
+ "window_rename_tab", i18n("Rename Tab..."), i18n("Rename this tab"),
+ "edit-rename", this, SLOT(slotRenameCurrentTab()), QStringLiteral("CTRL+SHIFT+R"), false, false
+ },
+ {
+ "window_duplicate_tab", i18n("Duplicate Tab"), i18n("Duplicate this tab"),
+ "tab-duplicate", this, SLOT(slotDuplicateCurrentTab()), QStringLiteral("CTRL+SHIFT+D"), false, true
+ },
+ {
+ "window_close_tab", i18n("Close Tab"), i18n("Close this tab"),
+ "tab-close", this, SLOT(slotCloseCurrentTab()), QStringLiteral("CTRL+SHIFT+W"), false, false
+ }, // ### CTRL-W when available
+ {
+ "window_move_tab_left", i18n("Move Tab Left"), i18n("Move this tab left"),
+ 0, this, SLOT(slotMoveCurrentTabLeft()), QStringLiteral("CTRL+SHIFT+LEFT"), false, false
+ },
+ {
+ "window_move_tab_right", i18n("Move Tab Right"), i18n("Move this tab right"),
+ 0, this, SLOT(slotMoveCurrentTabRight()), QStringLiteral("CTRL+SHIFT+RIGHT"), false, false
+ },
+ {
+ "window_view_hierarchical", i18n("Hierarchical Certificate List"), QString(),
+ 0, this, SLOT(slotToggleHierarchicalView(bool)), QString(), true, false
+ },
+ {
+ "window_expand_all", i18n("Expand All"), QString(),
+ 0, this, SLOT(slotExpandAll()), QStringLiteral("CTRL+."), false, false
+ },
+ {
+ "window_collapse_all", i18n("Collapse All"), QString(),
+ 0, this, SLOT(slotCollapseAll()), QStringLiteral("CTRL+,"), false, false
+ },
+ };
+
+ for (int i = 0; i < d->NumPageActions; ++i) {
+ d->currentPageActions[i] = make_action_from_data(actionData[i], coll);
}
+
+ for (int i = 0; i < d->NumPageActions; ++i) {
+ action_data ad = actionData[i];
+ assert(QString::fromLatin1(ad.name).startsWith(QStringLiteral("window_")));
+ ad.name = ad.name + strlen("window_");
+ ad.tooltip.clear();
+ ad.receiver = 0;
+ ad.shortcut.clear();
+ d->otherPageActions[i] = make_action_from_data(ad, coll);
+ }
+
+ d->setCornerAction(d->newAction, Qt::TopLeftCorner);
+ d->setCornerAction(d->currentPageActions[d->Close], Qt::TopRightCorner);
}
QAbstractItemView *TabWidget::addView(const QString &title, const QString &id, const QString &text)