summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-08-25 07:58:43 +0200
committerArno <arno@disconnect.de>2018-08-25 07:58:43 +0200
commit36d643da276a90ed8c8fc920d3e6a150d0bfc809 (patch)
treedce1c4543e2ad2c671dd95be9514bc0cbbb82c56
parent295114f77a4ed6ed8957485c0ceaf5c6d38b3485 (diff)
downloadBeetPlayer-36d643da276a90ed8c8fc920d3e6a150d0bfc809.tar.gz
BeetPlayer-36d643da276a90ed8c8fc920d3e6a150d0bfc809.tar.bz2
BeetPlayer-36d643da276a90ed8c8fc920d3e6a150d0bfc809.zip
Create keyboard Shortcuts for Views
In order of the bottom Icons: Alt+1 = Artist, Alt+6 = Folder
-rw-r--r--beetplayer.cpp17
-rw-r--r--beetplayer.h1
-rw-r--r--playerwidget.cpp18
-rw-r--r--playerwidget.h3
4 files changed, 30 insertions, 9 deletions
diff --git a/beetplayer.cpp b/beetplayer.cpp
index f37f5ed..a97ff7d 100644
--- a/beetplayer.cpp
+++ b/beetplayer.cpp
@@ -9,6 +9,7 @@
#include <QLabel>
#include <QSplashScreen>
#include <QApplication>
+#include <QKeyEvent>
#include "beetplayer.h"
#include "configurationdialog.h"
@@ -164,3 +165,19 @@ void BeetPlayer::closeEvent(QCloseEvent *event){
Q_UNUSED(event);
qApp->quit();
}
+
+#include <QDebug>
+
+void BeetPlayer::keyPressEvent(QKeyEvent *e){
+ if(e->modifiers() & Qt::AltModifier){
+ const QActionGroup *ag = mPlayerWidget->bottomAG();
+ int keyNum = e->key();
+ if(keyNum < Qt::Key_7 && keyNum > Qt::Key_0){
+ qDebug() << keyNum << (keyNum - Qt::Key_1);
+ int action = keyNum - Qt::Key_1;
+ ag->actions().at(action)->trigger();
+ return;
+ }
+ }
+ return QMainWindow::keyPressEvent(e);
+}
diff --git a/beetplayer.h b/beetplayer.h
index 38264f1..6b75e29 100644
--- a/beetplayer.h
+++ b/beetplayer.h
@@ -22,6 +22,7 @@ class BeetPlayer : public QMainWindow {
protected:
virtual void closeEvent(QCloseEvent *event);
+ virtual void keyPressEvent(QKeyEvent *e);
private:
void openDatabase();
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 4564b35..02b5354 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -81,8 +81,8 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
//THE views
QToolBar *bottomTB = new QToolBar;
- QActionGroup *bottomTBG = new QActionGroup(this);
- bottomTBG->setExclusive(true);
+ mBottomTBG = new QActionGroup(this);
+ mBottomTBG->setExclusive(true);
mCollectionStack = new QStackedWidget;
//artists view
CollectionArtistsView *artistsView = new CollectionArtistsView;
@@ -95,7 +95,7 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
QAction *viewByArtistsA = new QAction(QIcon(":/artist.png"), tr("View by artist"), this);
viewByArtistsA->setCheckable(true);
connect(viewByArtistsA, &QAction::triggered, [this, cIdx] { setCollectionIndex(cIdx, false); });
- bottomTBG->addAction(viewByArtistsA);
+ mBottomTBG->addAction(viewByArtistsA);
//albums view
CollectionAlbumsView *albumsView = new CollectionAlbumsView;
albumsView->setHeaders(QStringList() << tr("Album"));
@@ -107,7 +107,7 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
mViewByAlbumsA = new QAction(QIcon(":/album.png"), tr("View by album"), this);
mViewByAlbumsA->setCheckable(true);
connect(mViewByAlbumsA, &QAction::triggered, [this, cIdx] { setCollectionIndex(cIdx, false); });
- bottomTBG->addAction(mViewByAlbumsA);
+ mBottomTBG->addAction(mViewByAlbumsA);
//dates view
CollectionDatesView *datesView = new CollectionDatesView;;
datesView->setHeaders(QStringList() << tr("Date added"));
@@ -119,7 +119,7 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
QAction *viewByDatesA = new QAction(QIcon(":/sissyd.png"), tr("View by date"), this);
viewByDatesA->setCheckable(true);
connect(viewByDatesA, &QAction::triggered, [this, cIdx] { setCollectionIndex(cIdx, false); });
- bottomTBG->addAction(viewByDatesA);
+ mBottomTBG->addAction(viewByDatesA);
//favorites view
CollectionFavoritesView *favoritesView = new CollectionFavoritesView;
favoritesView->setHeaders(QStringList() << tr("Song"));
@@ -131,7 +131,7 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
QAction *viewByFavoritesA = new QAction(QIcon(":/male_chastity_belt.png"), tr("View by favorites"), this);
viewByFavoritesA->setCheckable(true);
connect(viewByFavoritesA, &QAction::triggered, [this, cIdx] { setCollectionIndex(cIdx, false); });
- bottomTBG->addAction(viewByFavoritesA);
+ mBottomTBG->addAction(viewByFavoritesA);
//webradio view
CollectionWebradioView *webradioView = new CollectionWebradioView;
webradioView->setHeaders(QStringList() << tr("Webradio"));
@@ -143,7 +143,7 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
QAction *viewByWebradioA = new QAction(QIcon(":/dog_hood.png"), tr("Webradio"), this);
viewByWebradioA->setCheckable(true);
connect(viewByWebradioA, &QAction::triggered, [this, cIdx] { setCollectionIndex(cIdx, true); });
- bottomTBG->addAction(viewByWebradioA);
+ mBottomTBG->addAction(viewByWebradioA);
//folders view
CollectionFoldersView *foldersView = new CollectionFoldersView;
foldersView->setHeaders(QStringList() << tr("Folder contents"));
@@ -155,8 +155,8 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
QAction *viewByFoldersA = new QAction(QIcon(":/folder.png"), tr("View by folder"), this);
viewByFoldersA->setCheckable(true);
connect(viewByFoldersA, &QAction::triggered, [this, cIdx] { setCollectionIndex(cIdx, false); });
- bottomTBG->addAction(viewByFoldersA);
- for(QAction *a : bottomTBG->actions()){
+ mBottomTBG->addAction(viewByFoldersA);
+ for(QAction *a : mBottomTBG->actions()){
bottomTB->addAction(a);
}
for(int i = 0; i < mCollectionStack->count(); ++i){
diff --git a/playerwidget.h b/playerwidget.h
index da13747..f24700f 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -19,6 +19,7 @@ class QTextBrowser;
class QMediaPlayer;
class QToolBar;
class QAction;
+class QActionGroup;
class QTimer;
class QStackedLayout;
class BeetPlayerProxy;
@@ -35,6 +36,7 @@ class PlayerWidget : public QWidget {
explicit PlayerWidget(QSplashScreen *splash, QWidget *parent = nullptr);
~PlayerWidget();
const QMediaPlayer* player() const { return mPlayer; }
+ const QActionGroup* bottomAG() const { return mBottomTBG; }
public slots:
void rightCurrentChanged(const QModelIndex &cur, const QModelIndex &prev);
@@ -125,6 +127,7 @@ class PlayerWidget : public QWidget {
QMap<QString, QVariant> mOtherMeta;
QStackedWidget *mCollectionStack;
QTabWidget *mPlaylistTab;
+ QActionGroup *mBottomTBG;
};
#endif // PLAYERWIDGET_H