mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 09:45:44 +08:00
Some dock widget formatting and ESC key can dock ("unfloat") widget
This commit is contained in:
@@ -48,24 +48,24 @@ namespace BlackGui
|
|||||||
m_allowStatusBar(allowStatusBar)
|
m_allowStatusBar(allowStatusBar)
|
||||||
{
|
{
|
||||||
// init settings
|
// init settings
|
||||||
this->ps_onStyleSheetsChanged();
|
this->onStyleSheetsChanged();
|
||||||
this->initTitleBarWidgets();
|
this->initTitleBarWidgets();
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
this->m_input = new CMarginsInput(this);
|
m_input = new CMarginsInput(this);
|
||||||
this->m_input->setMaximumWidth(150);
|
m_input->setMaximumWidth(150);
|
||||||
this->m_marginMenuAction = new QWidgetAction(this);
|
m_marginMenuAction = new QWidgetAction(this);
|
||||||
this->m_marginMenuAction->setDefaultWidget(this->m_input);
|
m_marginMenuAction->setDefaultWidget(m_input);
|
||||||
this->m_fontMenu = new CFontMenu(this, true, Qt::WidgetWithChildrenShortcut);
|
m_fontMenu = new CFontMenu(this, true, Qt::WidgetWithChildrenShortcut);
|
||||||
|
|
||||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::ps_showContextMenu);
|
connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::showContextMenu);
|
||||||
connect(this->m_input, &CMarginsInput::changedMargins, this, &CDockWidget::ps_menuChangeMargins);
|
connect(m_input, &CMarginsInput::changedMargins, this, &CDockWidget::menuChangeMargins);
|
||||||
|
|
||||||
// connect
|
// connect
|
||||||
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::ps_onTopLevelChanged);
|
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged);
|
||||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::ps_onStyleSheetsChanged);
|
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged);
|
||||||
connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::ps_onVisibilityChanged);
|
connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::onVisibilityChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::setMargins()
|
void CDockWidget::setMargins()
|
||||||
@@ -85,16 +85,16 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDockWidget::setOriginalTitleBar()
|
void CDockWidget::setOriginalTitleBar()
|
||||||
{
|
{
|
||||||
if (!this->m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
|
if (!m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
|
||||||
if (this->titleBarWidget() == this->m_titleBarWidgetOriginal) return; // on purpose, as I do not know what happens when I call setTitleBar
|
if (this->titleBarWidget() == m_titleBarWidgetOriginal) return; // on purpose, as I do not know what happens when I call setTitleBar
|
||||||
this->setTitleBarWidget(this->m_titleBarWidgetOriginal);
|
this->setTitleBarWidget(m_titleBarWidgetOriginal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::setEmptyTitleBar()
|
void CDockWidget::setEmptyTitleBar()
|
||||||
{
|
{
|
||||||
if (!this->m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
|
if (!m_titleBarWidgetOriginal) { this->initTitleBarWidgets(); }
|
||||||
if (this->titleBarWidget() == this->m_titleBarWidgetEmpty) { return; } // on purpose, as I do not know what happens when I call setTitleBar
|
if (this->titleBarWidget() == m_titleBarWidgetEmpty) { return; } // on purpose, as I do not know what happens when I call setTitleBar
|
||||||
this->setTitleBarWidget(this->m_titleBarWidgetEmpty);
|
this->setTitleBarWidget(m_titleBarWidgetEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::setNullTitleBarWidget()
|
void CDockWidget::setNullTitleBarWidget()
|
||||||
@@ -155,33 +155,33 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CDockWidget::isWidgetVisible() const
|
bool CDockWidget::isWidgetVisible() const
|
||||||
{
|
{
|
||||||
return this->m_dockWidgetVisible && this->isVisible();
|
return m_dockWidgetVisible && this->isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::setWindowTitle(const QString &title)
|
void CDockWidget::setWindowTitle(const QString &title)
|
||||||
{
|
{
|
||||||
this->m_windowTitleBackup = title;
|
m_windowTitleBackup = title;
|
||||||
QDockWidget::setWindowTitle(title);
|
QDockWidget::setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::displayStatusMessage(const BlackMisc::CStatusMessage &statusMessage)
|
void CDockWidget::displayStatusMessage(const BlackMisc::CStatusMessage &statusMessage)
|
||||||
{
|
{
|
||||||
if (!this->m_allowStatusBar || !this->isFloating()) { return; }
|
if (!m_allowStatusBar || !this->isFloating()) { return; }
|
||||||
this->m_statusBar.displayStatusMessage(statusMessage);
|
m_statusBar.displayStatusMessage(statusMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::displayStatusMessages(const BlackMisc::CStatusMessageList &statusMessages)
|
void CDockWidget::displayStatusMessages(const BlackMisc::CStatusMessageList &statusMessages)
|
||||||
{
|
{
|
||||||
if (!this->m_allowStatusBar || !this->isFloating()) { return; }
|
if (!m_allowStatusBar || !this->isFloating()) { return; }
|
||||||
this->m_statusBar.displayStatusMessages(statusMessages);
|
m_statusBar.displayStatusMessages(statusMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::showTitleWhenDocked(bool show)
|
void CDockWidget::showTitleWhenDocked(bool show)
|
||||||
{
|
{
|
||||||
this->m_windowTitleWhenDocked = show;
|
m_windowTitleWhenDocked = show;
|
||||||
if (show)
|
if (show)
|
||||||
{
|
{
|
||||||
QDockWidget::setWindowTitle(this->m_windowTitleBackup);
|
QDockWidget::setWindowTitle(m_windowTitleBackup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -191,12 +191,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDockWidget::resetWasAlreadyFloating()
|
void CDockWidget::resetWasAlreadyFloating()
|
||||||
{
|
{
|
||||||
this->m_wasAlreadyFloating = false;
|
m_wasAlreadyFloating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::setPreferredSizeWhenFloating(const QSize &size)
|
void CDockWidget::setPreferredSizeWhenFloating(const QSize &size)
|
||||||
{
|
{
|
||||||
this->m_preferredSizeWhenFloating = size;
|
m_preferredSizeWhenFloating = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::setFrameless(bool frameless)
|
void CDockWidget::setFrameless(bool frameless)
|
||||||
@@ -204,12 +204,12 @@ namespace BlackGui
|
|||||||
CEnableForFramelessWindow::setFrameless(frameless);
|
CEnableForFramelessWindow::setFrameless(frameless);
|
||||||
|
|
||||||
// grip
|
// grip
|
||||||
bool hasStatusBar = this->m_statusBar.getStatusBar();
|
bool hasStatusBar = m_statusBar.getStatusBar();
|
||||||
if (frameless)
|
if (frameless)
|
||||||
{
|
{
|
||||||
if (hasStatusBar)
|
if (hasStatusBar)
|
||||||
{
|
{
|
||||||
this->addFramelessSizeGripToStatusBar(this->m_statusBar.getStatusBar());
|
this->addFramelessSizeGripToStatusBar(m_statusBar.getStatusBar());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -319,6 +319,18 @@ namespace BlackGui
|
|||||||
if (!handleMouseMoveEvent(event)) { QDockWidget::mouseMoveEvent(event); } ;
|
if (!handleMouseMoveEvent(event)) { QDockWidget::mouseMoveEvent(event); } ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDockWidget::keyPressEvent(QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->key() == Qt::Key_Escape)
|
||||||
|
{
|
||||||
|
if (this->isFloating())
|
||||||
|
{
|
||||||
|
this->toggleFloating();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QDockWidget::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void CDockWidget::mousePressEvent(QMouseEvent *event)
|
void CDockWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!handleMousePressEvent(event)) { QDockWidget::mousePressEvent(event); }
|
if (!handleMousePressEvent(event)) { QDockWidget::mousePressEvent(event); }
|
||||||
@@ -357,9 +369,9 @@ namespace BlackGui
|
|||||||
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset to defaults", this, &CDockWidget::resetSettings);
|
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset to defaults", this, &CDockWidget::resetSettings);
|
||||||
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset position", this, &CDockWidget::resetPosition);
|
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset position", this, &CDockWidget::resetPosition);
|
||||||
|
|
||||||
this->m_input->setMargins(this->contentsMargins());
|
m_input->setMargins(this->contentsMargins());
|
||||||
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Margins", this, &CDockWidget::ps_dummy);
|
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Margins", this, &CDockWidget::dummy);
|
||||||
contextMenu->addAction(this->m_marginMenuAction);
|
contextMenu->addAction(m_marginMenuAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::initialFloating()
|
void CDockWidget::initialFloating()
|
||||||
@@ -368,18 +380,18 @@ namespace BlackGui
|
|||||||
this->initStatusBarAndProperties();
|
this->initStatusBarAndProperties();
|
||||||
|
|
||||||
// for the first time resize
|
// for the first time resize
|
||||||
if (!this->m_preferredSizeWhenFloating.isNull())
|
if (!m_preferredSizeWhenFloating.isNull())
|
||||||
{
|
{
|
||||||
this->m_initialDockedMinimumSize = this->minimumSize();
|
m_initialDockedMinimumSize = this->minimumSize();
|
||||||
this->resize(this->m_preferredSizeWhenFloating);
|
this->resize(m_preferredSizeWhenFloating);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and move
|
// and move
|
||||||
QPoint mainWindowPos = BlackGui::CGuiUtility::mainWindowPosition();
|
QPoint mainWindowPos = BlackGui::CGuiUtility::mainWindowPosition();
|
||||||
if (!mainWindowPos.isNull())
|
if (!mainWindowPos.isNull())
|
||||||
{
|
{
|
||||||
int x = mainWindowPos.x() + this->m_offsetWhenFloating.x();
|
int x = mainWindowPos.x() + m_offsetWhenFloating.x();
|
||||||
int y = mainWindowPos.y() + this->m_offsetWhenFloating.y();
|
int y = mainWindowPos.y() + m_offsetWhenFloating.y();
|
||||||
this->move(x, y);
|
this->move(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -391,7 +403,7 @@ namespace BlackGui
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::ps_onTopLevelChanged(bool topLevel)
|
void CDockWidget::onTopLevelChanged(bool topLevel)
|
||||||
{
|
{
|
||||||
# ifdef Q_OS_LINUX
|
# ifdef Q_OS_LINUX
|
||||||
// Give XCB platforms enough time to handle window events before adjusting it.
|
// Give XCB platforms enough time to handle window events before adjusting it.
|
||||||
@@ -401,12 +413,12 @@ namespace BlackGui
|
|||||||
this->setMargins();
|
this->setMargins();
|
||||||
if (topLevel)
|
if (topLevel)
|
||||||
{
|
{
|
||||||
if (this->m_windowTitleBackup != QDockWidget::windowTitle())
|
if (m_windowTitleBackup != QDockWidget::windowTitle())
|
||||||
{
|
{
|
||||||
QDockWidget::setWindowTitle(this->m_windowTitleBackup);
|
QDockWidget::setWindowTitle(m_windowTitleBackup);
|
||||||
}
|
}
|
||||||
this->setNullTitleBarWidget();
|
this->setNullTitleBarWidget();
|
||||||
if (!this->m_wasAlreadyFloating)
|
if (!m_wasAlreadyFloating)
|
||||||
{
|
{
|
||||||
this->initialFloating();
|
this->initialFloating();
|
||||||
}
|
}
|
||||||
@@ -414,22 +426,22 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (m_wasFrameless) { setFrameless(true); }
|
if (m_wasFrameless) { setFrameless(true); }
|
||||||
}
|
}
|
||||||
this->m_statusBar.show();
|
m_statusBar.show();
|
||||||
this->m_wasAlreadyFloating = true;
|
m_wasAlreadyFloating = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// frameless
|
// frameless
|
||||||
this->setFrameless(false);
|
this->setFrameless(false);
|
||||||
|
|
||||||
if (!this->m_windowTitleWhenDocked) { QDockWidget::setWindowTitle(""); }
|
if (!m_windowTitleWhenDocked) { QDockWidget::setWindowTitle(""); }
|
||||||
this->m_statusBar.hide();
|
m_statusBar.hide();
|
||||||
this->setEmptyTitleBar();
|
this->setEmptyTitleBar();
|
||||||
|
|
||||||
// sometimes floating sets a new minimum size, here we reset it
|
// sometimes floating sets a new minimum size, here we reset it
|
||||||
if (this->minimumHeight() > this->m_initialDockedMinimumSize.height())
|
if (this->minimumHeight() > m_initialDockedMinimumSize.height())
|
||||||
{
|
{
|
||||||
this->setMinimumSize(this->m_initialDockedMinimumSize);
|
this->setMinimumSize(m_initialDockedMinimumSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,14 +451,14 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDockWidget::initTitleBarWidgets()
|
void CDockWidget::initTitleBarWidgets()
|
||||||
{
|
{
|
||||||
this->m_titleBarWidgetOriginal = this->titleBarWidget();
|
m_titleBarWidgetOriginal = this->titleBarWidget();
|
||||||
this->m_titleBarWidgetEmpty = new QWidget(this);
|
m_titleBarWidgetEmpty = new QWidget(this);
|
||||||
this->setTitleBarWidget(this->m_titleBarWidgetEmpty);
|
this->setTitleBarWidget(m_titleBarWidgetEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::initStatusBarAndProperties()
|
void CDockWidget::initStatusBarAndProperties()
|
||||||
{
|
{
|
||||||
if (this->m_statusBar.getStatusBar()) { return; }
|
if (m_statusBar.getStatusBar()) { return; }
|
||||||
|
|
||||||
// Typical reasons for asserts here
|
// Typical reasons for asserts here
|
||||||
// 1) Check the structure, we expect the following hierarchy:
|
// 1) Check the structure, we expect the following hierarchy:
|
||||||
@@ -462,23 +474,23 @@ namespace BlackGui
|
|||||||
Q_ASSERT_X(outerWidget->layout(), "CDockWidget::initStatusBar", "No outer widget layout");
|
Q_ASSERT_X(outerWidget->layout(), "CDockWidget::initStatusBar", "No outer widget layout");
|
||||||
if (!outerWidget->layout()) { return; }
|
if (!outerWidget->layout()) { return; }
|
||||||
Q_ASSERT_X(outerWidget->layout()->itemAt(0) && outerWidget->layout()->itemAt(0)->widget(), "CDockWidget::initStatusBar", "No outer widget layout item");
|
Q_ASSERT_X(outerWidget->layout()->itemAt(0) && outerWidget->layout()->itemAt(0)->widget(), "CDockWidget::initStatusBar", "No outer widget layout item");
|
||||||
if (!outerWidget->layout()->itemAt(0) || !outerWidget->layout()->itemAt(0)->widget()) { this->m_allowStatusBar = false; return; }
|
if (!outerWidget->layout()->itemAt(0) || !outerWidget->layout()->itemAt(0)->widget()) { m_allowStatusBar = false; return; }
|
||||||
|
|
||||||
// Inner widget is supposed to be a QFrame / promoted QFrame
|
// Inner widget is supposed to be a QFrame / promoted QFrame
|
||||||
QFrame *innerWidget = qobject_cast<QFrame *>(outerWidget->layout()->itemAt(0)->widget()); // the inner widget containing the layout
|
QFrame *innerWidget = qobject_cast<QFrame *>(outerWidget->layout()->itemAt(0)->widget()); // the inner widget containing the layout
|
||||||
Q_ASSERT_X(innerWidget, "CDockWidget::initStatusBar", "No inner widget");
|
Q_ASSERT_X(innerWidget, "CDockWidget::initStatusBar", "No inner widget");
|
||||||
if (!innerWidget) { this->m_allowStatusBar = false; return; }
|
if (!innerWidget) { m_allowStatusBar = false; return; }
|
||||||
innerWidget->setProperty("dockwidget", propertyInnerWidget());
|
innerWidget->setProperty("dockwidget", propertyInnerWidget());
|
||||||
|
|
||||||
// status bar
|
// status bar
|
||||||
if (!this->m_allowStatusBar) { return; }
|
if (!m_allowStatusBar) { return; }
|
||||||
this->m_statusBar.initStatusBar();
|
m_statusBar.initStatusBar();
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(innerWidget->layout());
|
QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(innerWidget->layout());
|
||||||
Q_ASSERT_X(vLayout, "CDockWidget::initStatusBar", "No outer widget layout");
|
Q_ASSERT_X(vLayout, "CDockWidget::initStatusBar", "No outer widget layout");
|
||||||
if (!vLayout) { this->m_allowStatusBar = false; return; }
|
if (!vLayout) { m_allowStatusBar = false; return; }
|
||||||
vLayout->addWidget(this->m_statusBar.getStatusBar(), 0, Qt::AlignBottom); // 0->vertical stretch minimum
|
vLayout->addWidget(m_statusBar.getStatusBar(), 0, Qt::AlignBottom); // 0->vertical stretch minimum
|
||||||
|
|
||||||
// adjust stretching of the original widget. It was the only widget so far
|
// adjust stretching of the original widget. It was the only widget so far
|
||||||
// and should occupy maximum space
|
// and should occupy maximum space
|
||||||
@@ -490,7 +502,7 @@ namespace BlackGui
|
|||||||
compWidget->setSizePolicy(sizePolicy);
|
compWidget->setSizePolicy(sizePolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::ps_showContextMenu(const QPoint &pos)
|
void CDockWidget::showContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QPoint globalPos = this->mapToGlobal(pos);
|
QPoint globalPos = this->mapToGlobal(pos);
|
||||||
QScopedPointer<QMenu> contextMenu(new QMenu(this));
|
QScopedPointer<QMenu> contextMenu(new QMenu(this));
|
||||||
@@ -499,12 +511,12 @@ namespace BlackGui
|
|||||||
Q_UNUSED(selectedItem);
|
Q_UNUSED(selectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::ps_onVisibilityChanged(bool visible)
|
void CDockWidget::onVisibilityChanged(bool visible)
|
||||||
{
|
{
|
||||||
this->m_dockWidgetVisible = visible;
|
m_dockWidgetVisible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::ps_menuChangeMargins(const QMargins &margins)
|
void CDockWidget::menuChangeMargins(const QMargins &margins)
|
||||||
{
|
{
|
||||||
const bool frameless = this->isFrameless();
|
const bool frameless = this->isFrameless();
|
||||||
const bool floating = this->isFloating();
|
const bool floating = this->isFloating();
|
||||||
@@ -527,17 +539,17 @@ namespace BlackGui
|
|||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::ps_settingsChanged()
|
void CDockWidget::settingsChanged()
|
||||||
{
|
{
|
||||||
// void, normally not used
|
// void, normally not used
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::ps_dummy()
|
void CDockWidget::dummy()
|
||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::ps_onStyleSheetsChanged()
|
void CDockWidget::onStyleSheetsChanged()
|
||||||
{
|
{
|
||||||
// style sheet changes go here
|
// style sheet changes go here
|
||||||
}
|
}
|
||||||
@@ -552,14 +564,14 @@ namespace BlackGui
|
|||||||
CDockWidgetSettings CDockWidget::getSettings() const
|
CDockWidgetSettings CDockWidget::getSettings() const
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!this->objectName().isEmpty(), Q_FUNC_INFO, "Need object name for settings %OwnerName%");
|
Q_ASSERT_X(!this->objectName().isEmpty(), Q_FUNC_INFO, "Need object name for settings %OwnerName%");
|
||||||
const CDockWidgetSettings s = this->m_settings.get();
|
const CDockWidgetSettings s = m_settings.get();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::saveSettings(const CDockWidgetSettings &settings)
|
void CDockWidget::saveSettings(const CDockWidgetSettings &settings)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(!this->objectName().isEmpty(), Q_FUNC_INFO, "Need object name for settings %OwnerName%");
|
Q_ASSERT_X(!this->objectName().isEmpty(), Q_FUNC_INFO, "Need object name for settings %OwnerName%");
|
||||||
const CStatusMessage m = this->m_settings.setAndSave(settings);
|
const CStatusMessage m = m_settings.setAndSave(settings);
|
||||||
if (m.isFailure())
|
if (m.isFailure())
|
||||||
{
|
{
|
||||||
CLogMessage::preformatted(m);
|
CLogMessage::preformatted(m);
|
||||||
|
|||||||
@@ -63,23 +63,23 @@ namespace BlackGui
|
|||||||
void setNullTitleBarWidget();
|
void setNullTitleBarWidget();
|
||||||
|
|
||||||
//! Window title backup
|
//! Window title backup
|
||||||
const QString &windowTitleBackup() const { return this->m_windowTitleBackup; }
|
const QString &windowTitleBackup() const { return m_windowTitleBackup; }
|
||||||
|
|
||||||
//! If current window title is empty, use backup
|
//! If current window title is empty, use backup
|
||||||
QString windowTitleOrBackup() const;
|
QString windowTitleOrBackup() const;
|
||||||
|
|
||||||
//! Window title when window is docked
|
//! Window title when window is docked
|
||||||
bool showTitleWhenDocked() const { return this->m_windowTitleWhenDocked; }
|
bool showTitleWhenDocked() const { return m_windowTitleWhenDocked; }
|
||||||
|
|
||||||
//! Selected when tabbed
|
//! Selected when tabbed
|
||||||
bool isSelected() const { return this->m_selected; }
|
bool isSelected() const { return m_selected; }
|
||||||
|
|
||||||
//! Is widget visible? Not to be confused with \sa QWidget::isVisbible
|
//! Is widget visible? Not to be confused with \sa QWidget::isVisbible
|
||||||
//! \remarks Logical vsibility as in \sa QDockWidget::visibilityChanged
|
//! \remarks Logical vsibility as in \sa QDockWidget::visibilityChanged
|
||||||
bool isWidgetVisible() const;
|
bool isWidgetVisible() const;
|
||||||
|
|
||||||
//! Allow a status bar to be displayed
|
//! Allow a status bar to be displayed
|
||||||
void allowStatusBar(bool allow) { this->m_allowStatusBar = allow; }
|
void allowStatusBar(bool allow) { m_allowStatusBar = allow; }
|
||||||
|
|
||||||
//! Show the window title when docked
|
//! Show the window title when docked
|
||||||
void showTitleWhenDocked(bool show);
|
void showTitleWhenDocked(bool show);
|
||||||
@@ -88,13 +88,13 @@ namespace BlackGui
|
|||||||
void resetWasAlreadyFloating();
|
void resetWasAlreadyFloating();
|
||||||
|
|
||||||
//! Was widget already floating?
|
//! Was widget already floating?
|
||||||
bool wasAlreadyFloating() const { return this->m_wasAlreadyFloating; }
|
bool wasAlreadyFloating() const { return m_wasAlreadyFloating; }
|
||||||
|
|
||||||
//! Size when floating first time
|
//! Size when floating first time
|
||||||
void setPreferredSizeWhenFloating(const QSize &size);
|
void setPreferredSizeWhenFloating(const QSize &size);
|
||||||
|
|
||||||
//! Position offset when floating first time
|
//! Position offset when floating first time
|
||||||
void setOffsetWhenFloating(const QPoint &point) { this->m_offsetWhenFloating = point; }
|
void setOffsetWhenFloating(const QPoint &point) { m_offsetWhenFloating = point; }
|
||||||
|
|
||||||
//! \copydoc CEnableForFramelessWindow::setFrameless
|
//! \copydoc CEnableForFramelessWindow::setFrameless
|
||||||
virtual void setFrameless(bool frameless) override;
|
virtual void setFrameless(bool frameless) override;
|
||||||
@@ -183,10 +183,13 @@ namespace BlackGui
|
|||||||
//! \copydoc QWidget::paintEvent
|
//! \copydoc QWidget::paintEvent
|
||||||
virtual void paintEvent(QPaintEvent *event) override;
|
virtual void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
//! \copydoc QMainWindow::mouseMoveEvent
|
//! \copydoc QWidget::mouseMoveEvent
|
||||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
//! \copydoc QMainWindow::mousePressEvent
|
//! \copydoc QWidget::mouseMoveEvent
|
||||||
|
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
|
||||||
|
//! \copydoc QWidget::mousePressEvent
|
||||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
//! Contribute to menu
|
//! Contribute to menu
|
||||||
@@ -197,28 +200,8 @@ namespace BlackGui
|
|||||||
//! The GUI is already initialized, so all widget data are available.
|
//! The GUI is already initialized, so all widget data are available.
|
||||||
virtual void initialFloating();
|
virtual void initialFloating();
|
||||||
|
|
||||||
protected slots:
|
|
||||||
//! Style sheet has changed
|
//! Style sheet has changed
|
||||||
virtual void ps_onStyleSheetsChanged();
|
virtual void onStyleSheetsChanged();
|
||||||
|
|
||||||
private slots:
|
|
||||||
//! Top level has been chaged
|
|
||||||
void ps_onTopLevelChanged(bool topLevel);
|
|
||||||
|
|
||||||
//! Context menu
|
|
||||||
void ps_showContextMenu(const QPoint &pos);
|
|
||||||
|
|
||||||
//! Visibility has changed
|
|
||||||
void ps_onVisibilityChanged(bool visible);
|
|
||||||
|
|
||||||
//! Change margins
|
|
||||||
void ps_menuChangeMargins(const QMargins &margins);
|
|
||||||
|
|
||||||
//! Changed settings
|
|
||||||
void ps_settingsChanged();
|
|
||||||
|
|
||||||
//! Dummy slot for QAction
|
|
||||||
void ps_dummy();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_titleBarWidgetEmpty = nullptr; //!< replacing default title bar
|
QWidget *m_titleBarWidgetEmpty = nullptr; //!< replacing default title bar
|
||||||
@@ -237,7 +220,25 @@ namespace BlackGui
|
|||||||
bool m_selected = false; //!< selected when tabbed
|
bool m_selected = false; //!< selected when tabbed
|
||||||
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
bool m_dockWidgetVisible = false; //!< logical visible, not to be confused with QDockWidget::isVisible()
|
||||||
bool m_wasFrameless = false; //!< frameless when last floating
|
bool m_wasFrameless = false; //!< frameless when last floating
|
||||||
BlackMisc::CSetting<BlackGui::Settings::TDockWidget> m_settings { this, &CDockWidget::ps_settingsChanged };
|
BlackMisc::CSetting<BlackGui::Settings::TDockWidget> m_settings { this, &CDockWidget::settingsChanged };
|
||||||
|
|
||||||
|
//! Top level has been chaged
|
||||||
|
void onTopLevelChanged(bool topLevel);
|
||||||
|
|
||||||
|
//! Context menu
|
||||||
|
void showContextMenu(const QPoint &pos);
|
||||||
|
|
||||||
|
//! Visibility has changed
|
||||||
|
void onVisibilityChanged(bool visible);
|
||||||
|
|
||||||
|
//! Change margins
|
||||||
|
void menuChangeMargins(const QMargins &margins);
|
||||||
|
|
||||||
|
//! Changed settings
|
||||||
|
void settingsChanged();
|
||||||
|
|
||||||
|
//! Dummy slot for QAction
|
||||||
|
void dummy();
|
||||||
|
|
||||||
//! Empty widget with no size
|
//! Empty widget with no size
|
||||||
void initTitleBarWidgets();
|
void initTitleBarWidgets();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
this->setWindowTitle("Info status bar");
|
this->setWindowTitle("Info status bar");
|
||||||
this->setWindowIcon(CIcons::swift24());
|
this->setWindowIcon(CIcons::swift24());
|
||||||
this->ps_onStyleSheetsChanged(); // margins from infobar
|
this->onStyleSheetsChanged(); // margins from infobar
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidgetInfoBar::addToContextMenu(QMenu *contextMenu) const
|
void CDockWidgetInfoBar::addToContextMenu(QMenu *contextMenu) const
|
||||||
@@ -33,7 +33,7 @@ namespace BlackGui
|
|||||||
CDockWidget::addToContextMenu(contextMenu);
|
CDockWidget::addToContextMenu(contextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidgetInfoBar::ps_onStyleSheetsChanged()
|
void CDockWidgetInfoBar::onStyleSheetsChanged()
|
||||||
{
|
{
|
||||||
const QString st = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameInfoBar());
|
const QString st = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameInfoBar());
|
||||||
this->setStyleSheet(st);
|
this->setStyleSheet(st);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class QWidget;
|
|||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Class for dock widgets in the info area, containing some specialized functionality
|
//! Class for dock widgets in the info area, containing some specialized functionality
|
||||||
//! \sa CDockWidgetInfoArea
|
//! \sa CDockWidgetInfoArea
|
||||||
//! \sa CInfoArea
|
//! \sa CInfoArea
|
||||||
@@ -38,12 +37,10 @@ namespace BlackGui
|
|||||||
//! Contribute to menu
|
//! Contribute to menu
|
||||||
virtual void addToContextMenu(QMenu *contextMenu) const override;
|
virtual void addToContextMenu(QMenu *contextMenu) const override;
|
||||||
|
|
||||||
protected slots:
|
protected:
|
||||||
//! \copydoc CDockWidget::ps_onStyleSheetsChanged
|
//! \copydoc CDockWidget::onStyleSheetsChanged
|
||||||
virtual void ps_onStyleSheetsChanged() override;
|
virtual void onStyleSheetsChanged() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user