Allways on top working, but cursed

This commit is contained in:
mrbesen 2021-12-17 01:26:28 +01:00
parent a2ce79da7a
commit d614316af6
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
4 changed files with 34 additions and 4 deletions

View File

@ -32,6 +32,9 @@ public slots:
void moveRight();
void playCurrent();
private slots:
void alwaysOnTopSettingChange(int status);
signals:
void newStatusMessage(const QString&);

View File

@ -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();

View File

@ -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());
}
}

View File

@ -61,6 +61,19 @@
<string>Stop</string>
</property>
</widget>
<widget class="QCheckBox" name="allwaysOnTop">
<property name="geometry">
<rect>
<x>660</x>
<y>10</y>
<width>141</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>AllwaysOnTop</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">