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: 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 moveRight();
void playCurrent(); void playCurrent();
private slots:
void alwaysOnTopSettingChange(int status);
signals: signals:
void newStatusMessage(const QString&); 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->reloadButton, SIGNAL(clicked()), this, SLOT(reloadConfig()));
QObject::connect(ui->stopButton, SIGNAL( clicked() ), this, SLOT( stop() )); 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(stopGlobal, SIGNAL( activated() ), this, SLOT( stop() ));
QObject::connect(this, SIGNAL(newStatusMessage(const QString&)), ui->statusbar, SLOT(showMessage(const QString&))); 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(left, SIGNAL( activated() ), this, SLOT( moveLeft() ));
QObject::connect(right, SIGNAL( activated() ), this, SLOT( moveRight() )); QObject::connect(right, SIGNAL( activated() ), this, SLOT( moveRight() ));
QObject::connect(play, SIGNAL( activated() ), this, SLOT( playCurrent() )); QObject::connect(play, SIGNAL( activated() ), this, SLOT( playCurrent() ));
} }
MainWindow::~MainWindow() { 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() { void MainWindow::loadSoundFromConfig() {
Sound& sound = Sound::instance(); // init sound Sound& sound = Sound::instance(); // init sound
sound.reset(); sound.reset();

View File

@ -66,11 +66,11 @@ void SoundButton::setVolume(float v) {
void SoundButton::setHighlighted(bool highlighted) { void SoundButton::setHighlighted(bool highlighted) {
if(highlighted) { if(highlighted) {
setStyleSheet("QPushButton { background: red; }"); setStyleSheet("SoundButton { color: red; }");
setText(">" + getInfo()); //setText("-> " + getInfo());
} else { } else {
setStyleSheet("QPushButton {}"); setStyleSheet("SoundButton {}");
setText(getInfo()); //setText(getInfo());
} }
} }

View File

@ -61,6 +61,19 @@
<string>Stop</string> <string>Stop</string>
</property> </property>
</widget> </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>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
<property name="geometry"> <property name="geometry">