fixed shortcut bug (ordering is important)

This commit is contained in:
mrbesen 2021-12-15 01:11:46 +01:00
parent 3aee5192b6
commit 425b0df19f
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
3 changed files with 58 additions and 5 deletions

@ -1 +1 @@
Subproject commit 336b6f5780109501dd8c3d98ca336265af021808
Subproject commit 66d741954d224eb3835cb84b682a50760aa4d1ee

View File

@ -24,6 +24,12 @@ public slots:
void reloadConfig();
void stop();
void moveUp();
void moveDown();
void moveLeft();
void moveRight();
void playCurrent();
signals:
void newStatusMessage(const QString&);
@ -35,6 +41,14 @@ private:
Ui::Soundboard *ui;
std::vector<SoundButton*> soundbuttons;
QxtGlobalShortcut* stopGlobal = nullptr;
QxtGlobalShortcut* up = nullptr;
QxtGlobalShortcut* down = nullptr;
QxtGlobalShortcut* left = nullptr;
QxtGlobalShortcut* right = nullptr;
QxtGlobalShortcut* play = nullptr;
Config config;
};
#endif // MAINWINDOW_H

View File

@ -9,21 +9,40 @@
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::Soundboard) {
ui->setupUi(this);
reloadConfig();
up = new QxtGlobalShortcut(QKeySequence("Shift+Up"));
down = new QxtGlobalShortcut(QKeySequence("Shift+Down"));
left = new QxtGlobalShortcut(QKeySequence("Shift+Left"));
right = new QxtGlobalShortcut(QKeySequence("Shift+Right"));
play = new QxtGlobalShortcut(QKeySequence("Shift+Num+Enter"));
// QKeySequence seq(QString::fromStdString("Shift+Num+0"));
// stopGlobal = new QxtGlobalShortcut(seq);
QKeySequence seq(QString::fromStdString("Shift+Num+0"));
stopGlobal = new QxtGlobalShortcut(seq);
reloadConfig();
QObject::connect(ui->reloadButton, SIGNAL(clicked()), this, SLOT(reloadConfig()));
QObject::connect(ui->stopButton, SIGNAL( clicked() ), this, SLOT( stop() ));
// QObject::connect(stopGlobal, SIGNAL( activated() ), this, SLOT( stop() ));
QObject::connect(stopGlobal, SIGNAL( activated() ), this, SLOT( stop() ));
QObject::connect(this, SIGNAL(newStatusMessage(const QString&)), ui->statusbar, SLOT(showMessage(const QString&)));
QObject::connect(up, SIGNAL( activated() ), this, SLOT( moveUp() ));
QObject::connect(down, SIGNAL( activated() ), this, SLOT( moveDown() ));
QObject::connect(left, SIGNAL( activated() ), this, SLOT( moveLeft() ));
QObject::connect(right, SIGNAL( activated() ), this, SLOT( moveRight() ));
QObject::connect(play, SIGNAL( activated() ), this, SLOT( playCurrent() ));
}
MainWindow::~MainWindow() {
delete ui;
delete stopGlobal;
delete up;
delete down;
delete left;
delete right;
delete play;
Sound::deinit();
}
@ -51,6 +70,26 @@ void MainWindow::stop() {
Sound::instance().stopAll();
}
void MainWindow::moveUp() {
Log::debug << "up";
}
void MainWindow::moveDown() {
Log::debug << "down";
}
void MainWindow::moveLeft() {
Log::debug << "left";
}
void MainWindow::moveRight() {
Log::debug << "right";
}
void MainWindow::playCurrent() {
Log::debug << "play";
}
void MainWindow::loadSoundFromConfig() {
Sound& sound = Sound::instance(); // init sound
sound.reset();