@@ -24,6 +24,8 @@ MainWindow::MainWindow(QApplication* app, QWidget *parent)
2424#ifdef LINUX
2525 setAttribute (Qt::WA_TransparentForMouseEvents);
2626 setWindowFlags (Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::Tool | Qt::WindowTransparentForInput);
27+ #else
28+ connect (this ->stayOnTopTimer , &QTimer::timeout, this , &MainWindow::handleRefreshStayOnTopFlag);
2729#endif
2830
2931 connect (this , &MainWindow::needReloadSetting, this , &MainWindow::reloadSetting);
@@ -94,6 +96,17 @@ void MainWindow::reloadSetting()
9496 setWindowFlag (Qt::WindowTransparentForInput, setting.getBool (KEY_FRAME_LESS));
9597 setAttribute (Qt::WA_TransparentForMouseEvents, setting.getBool (KEY_FRAME_LESS));
9698
99+ # ifndef LINUX
100+ this ->stayOnTop = setting.getBool (KEY_FLAGS_STAY_ON_TOP);
101+ if (this ->stayOnTop )
102+ {
103+ this ->stayOnTopTimer ->start (1000 );
104+ } else
105+ {
106+ this ->stayOnTopTimer ->stop ();
107+ }
108+ # endif
109+
97110 // 自动tick
98111 int autoTick = QString::fromStdString (setting.get (KEY_LYRIC_AUTO_TICK, " 0" )).toInt ();
99112 quint16 port = setting.has (KEY_RECEIVE_PORT) ? QString::fromStdString (setting.get (KEY_RECEIVE_PORT)).toInt () : PORT;
@@ -187,7 +200,7 @@ void MainWindow::handleCommand(QString command)
187200 }
188201 else if (commands[0 ] == " LYRIC_CONFIG_STAY_ON_TOP" && commands.size () == 2 )
189202 {
190- setWindowFlag (Qt::WindowStaysOnBottomHint , commands[1 ] == " 1" );
203+ setWindowFlag (Qt::WindowStaysOnTopHint , commands[1 ] == " 1" );
191204 setVisible (true );
192205 return ;
193206 }
@@ -197,6 +210,16 @@ void MainWindow::handleCommand(QString command)
197210 }
198211}
199212
213+ void MainWindow::handleRefreshStayOnTopFlag ()
214+ {
215+ # ifndef LINUX
216+ setWindowFlag (Qt::WindowStaysOnTopHint, !this ->stayOnTop );
217+ setWindowFlag (Qt::WindowStaysOnTopHint, this ->stayOnTop );
218+ setWindowFlag (Qt::Tool, true );
219+ setVisible (true );
220+ # endif
221+ }
222+
200223void MainWindow::receiveLyric ()
201224{
202225 QByteArray buffer;
0 commit comments