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)
|
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QMenu * menu = new QMenu;
|
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"));
|
QAction * protectedMode = new QAction(tr("Protected mode"));
|
||||||
connect(protectedMode, &QAction::triggered, this, [ = ](){
|
connect(protectedMode, &QAction::triggered, this, [ = ](){
|
||||||
toggleProtectedMode();
|
toggleProtectedMode();
|
||||||
});
|
});
|
||||||
protectedMode->setCheckable(true);
|
protectedMode->setCheckable(true);
|
||||||
protectedMode->setChecked(m_protectedMode);
|
protectedMode->setChecked(m_protectedMode);
|
||||||
|
menu->addAction(stayOnTopMode);
|
||||||
menu->addAction(protectedMode);
|
menu->addAction(protectedMode);
|
||||||
menu->exec(mapToGlobal(event->pos()));
|
menu->exec(mapToGlobal(event->pos()));
|
||||||
menu->deleteLater();
|
menu->deleteLater();
|
||||||
|
@ -385,3 +392,13 @@ void MainWindow::toggleProtectedMode()
|
||||||
m_protectedMode = !m_protectedMode;
|
m_protectedMode = !m_protectedMode;
|
||||||
m_closeButton->setVisible(!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 closeWindow();
|
||||||
void updateWidgetsPosition();
|
void updateWidgetsPosition();
|
||||||
void toggleProtectedMode();
|
void toggleProtectedMode();
|
||||||
|
void toggleStayOnTop();
|
||||||
|
bool stayOnTop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint m_oldMousePos;
|
QPoint m_oldMousePos;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user