mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
refs #503, callback when window mode / flags changes
This commit is contained in:
@@ -20,28 +20,33 @@ using namespace BlackMisc;
|
|||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
|
|
||||||
CEnableForFramelessWindow::CEnableForFramelessWindow(CEnableForFramelessWindow::WindowMode mode, bool isMainApplicationWindow, const char *framelessPropertyName, QWidget *correspondingWidget) :
|
CEnableForFramelessWindow::CEnableForFramelessWindow(CEnableForFramelessWindow::WindowMode mode, bool isMainApplicationWindow, const char *framelessPropertyName, QWidget *correspondingWidget) :
|
||||||
m_windowMode(mode), m_mainApplicationWindow(isMainApplicationWindow), m_widget(correspondingWidget), m_framelessPropertyName(framelessPropertyName)
|
m_windowMode(mode), m_mainApplicationWindow(isMainApplicationWindow), m_widget(correspondingWidget), m_framelessPropertyName(framelessPropertyName)
|
||||||
{
|
{
|
||||||
Q_ASSERT(correspondingWidget);
|
Q_ASSERT(correspondingWidget);
|
||||||
Q_ASSERT(!m_framelessPropertyName.isEmpty());
|
Q_ASSERT(!m_framelessPropertyName.isEmpty());
|
||||||
|
this->m_originalWindowMode = mode;
|
||||||
this->setWindowAttributes(mode);
|
this->setWindowAttributes(mode);
|
||||||
|
this->windowFlagsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnableForFramelessWindow::setMode(CEnableForFramelessWindow::WindowMode mode)
|
void CEnableForFramelessWindow::setMode(CEnableForFramelessWindow::WindowMode mode)
|
||||||
{
|
{
|
||||||
if (mode == this->m_windowMode) { return; }
|
if (mode == this->m_windowMode) { return; }
|
||||||
|
this->m_windowMode = mode;
|
||||||
|
|
||||||
// set the main window or dock widget flags and attributes
|
// set the main window or dock widget flags and attributes
|
||||||
this->m_widget->setWindowFlags(modeToWindowFlags(mode));
|
this->m_widget->setWindowFlags(modeToWindowFlags(mode));
|
||||||
|
this->windowFlagsChanged();
|
||||||
this->setWindowAttributes(mode);
|
this->setWindowAttributes(mode);
|
||||||
this->m_widget->show();
|
this->m_widget->show();
|
||||||
this->m_windowMode = mode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnableForFramelessWindow::setFrameless(bool frameless)
|
void CEnableForFramelessWindow::setFrameless(bool frameless)
|
||||||
{
|
{
|
||||||
setMode(frameless ? WindowFrameless : WindowTool);
|
WindowMode nonFrameLessMode = this->m_originalWindowMode;
|
||||||
|
if (nonFrameLessMode == WindowFrameless) { nonFrameLessMode = WindowNormal; }
|
||||||
|
setMode(frameless ? WindowFrameless : nonFrameLessMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnableForFramelessWindow::alwaysOnTop(bool onTop)
|
void CEnableForFramelessWindow::alwaysOnTop(bool onTop)
|
||||||
@@ -56,6 +61,7 @@ namespace BlackGui
|
|||||||
flags &= ~Qt::WindowStaysOnTopHint;
|
flags &= ~Qt::WindowStaysOnTopHint;
|
||||||
}
|
}
|
||||||
this->m_widget->setWindowFlags(flags);
|
this->m_widget->setWindowFlags(flags);
|
||||||
|
this->windowFlagsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
CEnableForFramelessWindow::WindowMode CEnableForFramelessWindow::stringToWindowMode(const QString &s)
|
CEnableForFramelessWindow::WindowMode CEnableForFramelessWindow::stringToWindowMode(const QString &s)
|
||||||
@@ -80,6 +86,11 @@ namespace BlackGui
|
|||||||
return "normal";
|
return "normal";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEnableForFramelessWindow::windowFlagsChanged()
|
||||||
|
{
|
||||||
|
// void
|
||||||
|
}
|
||||||
|
|
||||||
void CEnableForFramelessWindow::setWindowAttributes(CEnableForFramelessWindow::WindowMode mode)
|
void CEnableForFramelessWindow::setWindowAttributes(CEnableForFramelessWindow::WindowMode mode)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(this->m_widget, "CEnableForFramelessWindow::setWindowAttributes", "Missing widget representing window");
|
Q_ASSERT_X(this->m_widget, "CEnableForFramelessWindow::setWindowAttributes", "Missing widget representing window");
|
||||||
@@ -92,7 +103,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
// Qt::WA_PaintOnScreen leads to a warning
|
// Qt::WA_PaintOnScreen leads to a warning
|
||||||
// setMask(QRegion(10, 10, 10, 10) would work, but requires "complex" calcs for rounded corners
|
// setMask(QRegion(10, 10, 10, 10) would work, but requires "complex" calcs for rounded corners
|
||||||
//! \todo Transparent dock widget,try out void QWidget::setMask
|
//! \todo Transparent widget, try out void QWidget::setMask
|
||||||
this->setDynamicProperties(frameless);
|
this->setDynamicProperties(frameless);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,11 +236,15 @@ namespace BlackGui
|
|||||||
void CEnableForFramelessWindow::toolToNormalWindow()
|
void CEnableForFramelessWindow::toolToNormalWindow()
|
||||||
{
|
{
|
||||||
this->m_widget->setWindowFlags((this->m_widget->windowFlags() & (~Qt::Tool)) | Qt::Window);
|
this->m_widget->setWindowFlags((this->m_widget->windowFlags() & (~Qt::Tool)) | Qt::Window);
|
||||||
|
this->windowFlagsChanged();
|
||||||
|
this->m_originalWindowMode = WindowNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnableForFramelessWindow::normalToToolWindow()
|
void CEnableForFramelessWindow::normalToToolWindow()
|
||||||
{
|
{
|
||||||
this->m_widget->setWindowFlags(this->m_widget->windowFlags() | Qt::Tool);
|
this->m_widget->setWindowFlags(this->m_widget->windowFlags() | Qt::Tool);
|
||||||
|
this->windowFlagsChanged();
|
||||||
|
this->m_originalWindowMode = WindowTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CEnableForFramelessWindow::isToolWindow() const
|
bool CEnableForFramelessWindow::isToolWindow() const
|
||||||
@@ -252,5 +267,4 @@ namespace BlackGui
|
|||||||
return (Qt::Window | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
|
return (Qt::Window | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ namespace BlackGui
|
|||||||
};
|
};
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
|
//! \param mode window mode as defined in WindowMode
|
||||||
|
//! \param isMainApplicationWindow is this the main (there should be only one) application window
|
||||||
|
//! \param framelessPropertyname qss property indication frameless
|
||||||
|
//! \param correspondingWidget the widget representing the window
|
||||||
|
//!
|
||||||
CEnableForFramelessWindow(WindowMode mode, bool isMainApplicationWindow, const char *framelessPropertyname, QWidget *correspondingWidget);
|
CEnableForFramelessWindow(WindowMode mode, bool isMainApplicationWindow, const char *framelessPropertyname, QWidget *correspondingWidget);
|
||||||
|
|
||||||
//! Window mode
|
//! Window mode
|
||||||
@@ -66,13 +71,17 @@ namespace BlackGui
|
|||||||
static QString windowModeToString(WindowMode m);
|
static QString windowModeToString(WindowMode m);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPoint m_framelessDragPosition; //!< position, if moving is handled with frameless window */
|
QPoint m_framelessDragPosition; //!< position, if moving is handled with frameless window */
|
||||||
QPushButton *m_framelessCloseButton = nullptr; //!< close button
|
QPushButton *m_framelessCloseButton = nullptr; //!< close button
|
||||||
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
|
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
|
||||||
bool m_mainApplicationWindow = false; //!< is the main application window (only 1)
|
WindowMode m_originalWindowMode = WindowNormal; //!< mode when initialized
|
||||||
QWidget *m_widget = nullptr; //!< corresponding main window or dock widget
|
bool m_mainApplicationWindow = false; //!< is the main application window (only 1)
|
||||||
QSizeGrip *m_framelessSizeGrip = nullptr; //!< size grip object
|
QWidget *m_widget = nullptr; //!< corresponding main window or dock widget
|
||||||
QByteArray m_framelessPropertyName; //!< property name for frameless widgets
|
QSizeGrip *m_framelessSizeGrip = nullptr; //!< size grip object
|
||||||
|
QByteArray m_framelessPropertyName; //!< property name for frameless widgets
|
||||||
|
|
||||||
|
//! Can be used as notification if window mode changes
|
||||||
|
virtual void windowFlagsChanged();
|
||||||
|
|
||||||
//! Resize grip handle
|
//! Resize grip handle
|
||||||
void addFramelessSizeGripToStatusBar(QStatusBar *statusBar);
|
void addFramelessSizeGripToStatusBar(QStatusBar *statusBar);
|
||||||
|
|||||||
Reference in New Issue
Block a user