From d614316af658182d1521d3362a00cc0d131f8707 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Fri, 17 Dec 2021 01:26:28 +0100 Subject: [PATCH] Allways on top working, but cursed --- include/mainwindow.h | 3 +++ src/mainwindow.cpp | 14 ++++++++++++++ src/soundbutton.cpp | 8 ++++---- ui/mainwindow.ui | 13 +++++++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/include/mainwindow.h b/include/mainwindow.h index a50ca42..e483b98 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -32,6 +32,9 @@ public slots: void moveRight(); void playCurrent(); +private slots: + void alwaysOnTopSettingChange(int status); + signals: void newStatusMessage(const QString&); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e19527e..76eaa27 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -22,6 +22,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::Soundb QObject::connect(ui->reloadButton, SIGNAL(clicked()), this, SLOT(reloadConfig())); QObject::connect(ui->stopButton, SIGNAL( clicked() ), this, SLOT( stop() )); + QObject::connect(ui->allwaysOnTop, SIGNAL( stateChanged(int) ), this, SLOT( alwaysOnTopSettingChange(int) )); QObject::connect(stopGlobal, SIGNAL( activated() ), this, SLOT( stop() )); QObject::connect(this, SIGNAL(newStatusMessage(const QString&)), ui->statusbar, SLOT(showMessage(const QString&))); @@ -30,6 +31,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::Soundb 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() { @@ -115,6 +117,18 @@ void MainWindow::playCurrent() { } } +void MainWindow::alwaysOnTopSettingChange(int status) { + Qt::WindowFlags eFlags = windowFlags(); + Log::debug << "status: " << status; + if(status) { + setWindowFlags(eFlags | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint); + } else { + setWindowFlags(eFlags & ~(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)); + } + + show(); +} + void MainWindow::loadSoundFromConfig() { Sound& sound = Sound::instance(); // init sound sound.reset(); diff --git a/src/soundbutton.cpp b/src/soundbutton.cpp index aad83a0..65844d3 100644 --- a/src/soundbutton.cpp +++ b/src/soundbutton.cpp @@ -66,11 +66,11 @@ void SoundButton::setVolume(float v) { void SoundButton::setHighlighted(bool highlighted) { if(highlighted) { - setStyleSheet("QPushButton { background: red; }"); - setText(">" + getInfo()); + setStyleSheet("SoundButton { color: red; }"); + //setText("-> " + getInfo()); } else { - setStyleSheet("QPushButton {}"); - setText(getInfo()); + setStyleSheet("SoundButton {}"); + //setText(getInfo()); } } diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index d941444..ea81ff1 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -61,6 +61,19 @@ Stop + + + + 660 + 10 + 141 + 25 + + + + AllwaysOnTop + +