aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pyne <[email protected]>2017-08-26 20:09:57 -0400
committerMichael Pyne <[email protected]>2017-08-26 20:09:57 -0400
commit2889fd1fa4b78702ae3f819672c6359bf7717352 (patch)
tree199e0ed61cc51bc778e5bbb1e5f9897ed7c74a9c
parent8787d75195115abe8372643d66e024746a04eebe (diff)
More QAction streamlining.
- Use KActionCollection::setDefaultShortcut to reduce warnings - Use QKeySequence instead of deprecated KShortcut
-rw-r--r--playlistcollection.cpp41
-rw-r--r--playlistcollection.h3
-rw-r--r--playlistsplitter.cpp3
-rw-r--r--tageditor.cpp6
4 files changed, 30 insertions, 23 deletions
diff --git a/playlistcollection.cpp b/playlistcollection.cpp
index 6ba6b57..769cf3d 100644
--- a/playlistcollection.cpp
+++ b/playlistcollection.cpp
@@ -915,11 +915,11 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
actions()->addAction("file_new", menu);
menu->addAction(createAction(i18n("&Empty Playlist..."), SLOT(slotCreatePlaylist()),
- "newPlaylist", "window-new", KShortcut(Qt::CTRL + Qt::Key_N)));
+ "newPlaylist", "window-new", QKeySequence(Qt::CTRL + Qt::Key_N)));
menu->addAction(createAction(i18n("&Search Playlist..."), SLOT(slotCreateSearchPlaylist()),
- "newSearchPlaylist", "edit-find", KShortcut(Qt::CTRL + Qt::Key_F)));
+ "newSearchPlaylist", "edit-find", QKeySequence(Qt::CTRL + Qt::Key_F)));
menu->addAction(createAction(i18n("Playlist From &Folder..."), SLOT(slotCreateFolderPlaylist()),
- "newDirectoryPlaylist", "document-open", KShortcut(Qt::CTRL + Qt::Key_D)));
+ "newDirectoryPlaylist", "document-open", QKeySequence(Qt::CTRL + Qt::Key_D)));
// Guess tag info menu
@@ -930,12 +930,12 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
/* menu->setIcon(SmallIcon("wizard")); */
menu->addAction(createAction(i18n("From &File Name"), SLOT(slotGuessTagFromFile()),
- "guessTagFile", "document-import", KShortcut(Qt::CTRL + Qt::Key_G)));
+ "guessTagFile", "document-import", QKeySequence(Qt::CTRL + Qt::Key_G)));
menu->addAction(createAction(i18n("From &Internet"), SLOT(slotGuessTagFromInternet()),
- "guessTagInternet", "network-server", KShortcut(Qt::CTRL + Qt::Key_I)));
+ "guessTagInternet", "network-server", QKeySequence(Qt::CTRL + Qt::Key_I)));
#else
createAction(i18n("Guess Tag Information From &File Name"), SLOT(slotGuessTagFromFile()),
- "guessTag", "document-import", KShortcut(Qt::CTRL + Qt::Key_G));
+ "guessTag", "document-import", QKeySequence(Qt::CTRL + Qt::Key_G));
#endif
@@ -956,7 +956,7 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
createAction(i18n("&Delete"), SLOT(slotRemoveItems()), "removeItem", "edit-delete");
createAction(i18n("Refresh"), SLOT(slotRefreshItems()), "refresh", "view-refresh");
- createAction(i18n("&Rename File"), SLOT(slotRenameItems()), "renameFile", "document-save-as", KShortcut(Qt::CTRL + Qt::Key_R));
+ createAction(i18n("&Rename File"), SLOT(slotRenameItems()), "renameFile", "document-save-as", QKeySequence(Qt::CTRL + Qt::Key_R));
menu = new KActionMenu(i18n("Cover Manager"), actions());
actions()->addAction("coverManager", menu);
@@ -964,9 +964,9 @@ PlaylistCollection::ActionHandler::ActionHandler(PlaylistCollection *collection)
menu->addAction(createAction(i18n("&View Cover"),
SLOT(slotViewCovers()), "viewCover", "document-preview"));
menu->addAction(createAction(i18n("Get Cover From &File..."),
- SLOT(slotAddLocalCover()), "addCover", "document-import", KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_F)));
+ SLOT(slotAddLocalCover()), "addCover", "document-import", QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_F)));
menu->addAction(createAction(i18n("Get Cover From &Internet..."),
- SLOT(slotAddInternetCover()), "webImageCover", "network-server", KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_G)));
+ SLOT(slotAddInternetCover()), "webImageCover", "network-server", QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G)));
menu->addAction(createAction(i18n("&Delete Cover"),
SLOT(slotRemoveCovers()), "removeCover", "edit-delete"));
menu->addAction(createAction(i18n("Show Cover &Manager"),
@@ -984,17 +984,20 @@ QAction *PlaylistCollection::ActionHandler::createAction(const QString &text,
const char *slot,
const char *name,
const QString &icon,
- const KShortcut &shortcut)
+ const QKeySequence &shortcut)
{
- QAction *action;
- if(icon.isNull())
- action = new QAction(text, actions());
- else
- action = new QAction(QIcon::fromTheme(icon), text, actions());
- actions()->addAction(name, action);
- connect( action, SIGNAL(triggered(bool)), slot);
- if (!shortcut.toList().isEmpty()) {
- action->setShortcut(shortcut.toList().constFirst());
+ auto actionCollection = actions();
+ QAction *action = new QAction(text, actions());
+
+ if(!icon.isEmpty()) {
+ action->setIcon(QIcon::fromTheme(icon));
+ }
+ connect(action, SIGNAL(triggered(bool)), slot);
+
+ actionCollection->addAction(name, action);
+
+ if (!shortcut.isEmpty()) {
+ actionCollection->setDefaultShortcut(action, shortcut);
}
return action;
}
diff --git a/playlistcollection.h b/playlistcollection.h
index 0376262..0808ca2 100644
--- a/playlistcollection.h
+++ b/playlistcollection.h
@@ -25,6 +25,7 @@
#include <kdirlister.h>
#include <QPointer>
+#include <QKeySequence>
class QPixmap;
class QStackedWidget;
@@ -245,7 +246,7 @@ private:
const char *slot,
const char *name,
const QString &icon = QString(),
- const KShortcut &shortcut = KShortcut());
+ const QKeySequence &shortcut = QKeySequence());
private slots:
void slotPlayFirst() { m_collection->playFirst(); }
void slotPlayNextAlbum() { m_collection->playNextAlbum(); }
diff --git a/playlistsplitter.cpp b/playlistsplitter.cpp
index db28236..44b5178 100644
--- a/playlistsplitter.cpp
+++ b/playlistsplitter.cpp
@@ -32,6 +32,7 @@
#include <QTime>
#include <QStackedWidget>
#include <QSizePolicy>
+#include <QKeySequence>
#include "searchwidget.h"
#include "playlistsearch.h"
@@ -164,7 +165,7 @@ void PlaylistSplitter::setupActions()
QAction *act = new QAction(QIcon::fromTheme(QStringLiteral("edit-clear")), i18n("Edit Track Search"), this);
coll->addAction("editTrackSearch", act);
- act->setShortcut(Qt::Key_F6);
+ coll->setDefaultShortcut(act, Qt::Key_F6);
connect(act, SIGNAL(triggered(bool)), SLOT(setFocus()));
}
diff --git a/tageditor.cpp b/tageditor.cpp
index 3b45e1e..2fcc9f5 100644
--- a/tageditor.cpp
+++ b/tageditor.cpp
@@ -488,11 +488,13 @@ void TagEditor::setupActions()
i18n("Show &Tag Editor"), this);
ActionCollection::actions()->addAction("showEditor", show);
connect(show, SIGNAL(toggled(bool)), this, SLOT(setVisible(bool)));
+ connect(show, &QAction::toggled, this, &TagEditor::setVisible);
QAction *act = new QAction(QIcon::fromTheme(QLatin1String( "document-save")), i18n("&Save"), this);
ActionCollection::actions()->addAction("saveItem", act);
- act->setShortcut(Qt::CTRL + Qt::Key_T);
- connect(act, SIGNAL(triggered(bool)), SLOT(slotSave()));
+ ActionCollection::actions()->setDefaultShortcut(act,
+ QKeySequence(Qt::CTRL + Qt::Key_T));
+ connect(act, &QAction::triggered, this, &TagEditor::slotSave);
}
void TagEditor::setupLayout()