able to toggle stay on top
This commit is contained in:
parent
443ec1d8a7
commit
5d35de4e84
|
@ -250,12 +250,19 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|||
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu * menu = new QMenu;
|
||||
QAction * stayOnTopMode = new QAction(tr("Stay on top"));
|
||||
connect(stayOnTopMode, &QAction::triggered, this, [ = ](){
|
||||
toggleStayOnTop();
|
||||
});
|
||||
stayOnTopMode->setCheckable(true);
|
||||
stayOnTopMode->setChecked(stayOnTop());
|
||||
QAction * protectedMode = new QAction(tr("Protected mode"));
|
||||
connect(protectedMode, &QAction::triggered, this, [ = ](){
|
||||
toggleProtectedMode();
|
||||
});
|
||||
protectedMode->setCheckable(true);
|
||||
protectedMode->setChecked(m_protectedMode);
|
||||
menu->addAction(stayOnTopMode);
|
||||
menu->addAction(protectedMode);
|
||||
menu->exec(mapToGlobal(event->pos()));
|
||||
menu->deleteLater();
|
||||
|
@ -385,3 +392,13 @@ void MainWindow::toggleProtectedMode()
|
|||
m_protectedMode = !m_protectedMode;
|
||||
m_closeButton->setVisible(!m_protectedMode);
|
||||
}
|
||||
|
||||
void MainWindow::toggleStayOnTop()
|
||||
{
|
||||
setWindowFlag(Qt::WindowStaysOnTopHint, !stayOnTop());
|
||||
}
|
||||
|
||||
bool MainWindow::stayOnTop()
|
||||
{
|
||||
return windowFlags().testFlag(Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ protected slots:
|
|||
void closeWindow();
|
||||
void updateWidgetsPosition();
|
||||
void toggleProtectedMode();
|
||||
void toggleStayOnTop();
|
||||
bool stayOnTop();
|
||||
|
||||
private:
|
||||
QPoint m_oldMousePos;
|
||||
|
|
Loading…
Reference in New Issue
Block a user