add protected mode
This commit is contained in:
parent
1b646a5183
commit
9f4db60f82
|
@ -1,7 +1,7 @@
|
|||
environment:
|
||||
matrix:
|
||||
- build_name: mingw53_32_qt5_11_3
|
||||
QTPATH: C:\Qt\5.11.3\mingw53_32
|
||||
- build_name: mingw73_32_qt5_12_4
|
||||
QTPATH: C:\Qt\5.12.4\mingw73_32
|
||||
MINGW32: C:\Qt\Tools\mingw530_32
|
||||
# - build_name: msvc2017_64
|
||||
# QTPATH: C:\Qt\5.11.2\msvc2017_64
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <QStyle>
|
||||
#include <QScreen>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QMenu>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -246,6 +247,22 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|||
return QMainWindow::resizeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu * menu = new QMenu;
|
||||
QAction * protectedMode = new QAction(tr("Protected mode"));
|
||||
connect(protectedMode, &QAction::triggered, this, [ = ](){
|
||||
toggleProtectedMode();
|
||||
});
|
||||
protectedMode->setCheckable(true);
|
||||
protectedMode->setChecked(m_protectedMode);
|
||||
menu->addAction(protectedMode);
|
||||
menu->exec(mapToGlobal(event->pos()));
|
||||
menu->deleteLater();
|
||||
|
||||
return QMainWindow::contextMenuEvent(event);
|
||||
}
|
||||
|
||||
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -362,3 +379,9 @@ void MainWindow::updateWidgetsPosition()
|
|||
height() - m_bottomButtonGroup->height());
|
||||
m_gv->move(width() - m_gv->width(), height() - m_gv->height());
|
||||
}
|
||||
|
||||
void MainWindow::toggleProtectedMode()
|
||||
{
|
||||
m_protectedMode = !m_protectedMode;
|
||||
m_closeButton->setVisible(!m_protectedMode);
|
||||
}
|
||||
|
|
|
@ -35,12 +35,14 @@ protected slots:
|
|||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||
|
||||
bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;
|
||||
|
||||
void centerWindow();
|
||||
void closeWindow();
|
||||
void updateWidgetsPosition();
|
||||
void toggleProtectedMode();
|
||||
|
||||
private:
|
||||
QPoint m_oldMousePos;
|
||||
|
|
Loading…
Reference in New Issue
Block a user