mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Ref T369, link font size signals with dock widget
This commit is contained in:
@@ -63,9 +63,11 @@ namespace BlackGui
|
|||||||
connect(m_input, &CMarginsInput::changedMargins, this, &CDockWidget::menuChangeMargins);
|
connect(m_input, &CMarginsInput::changedMargins, this, &CDockWidget::menuChangeMargins);
|
||||||
|
|
||||||
// connect
|
// connect
|
||||||
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged);
|
|
||||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged, Qt::QueuedConnection);
|
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged, Qt::QueuedConnection);
|
||||||
|
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged);
|
||||||
connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::onVisibilityChanged);
|
connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::onVisibilityChanged);
|
||||||
|
connect(m_fontMenu, &CFontMenu::fontSizeMinus, this, &CDockWidget::fontSizeMinus);
|
||||||
|
connect(m_fontMenu, &CFontMenu::fontSizePlus, this, &CDockWidget::fontSizePlus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDockWidget::setMargins()
|
void CDockWidget::setMargins()
|
||||||
@@ -334,20 +336,20 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (this->isFloating())
|
if (this->isFloating())
|
||||||
{
|
{
|
||||||
contextMenu->addAction(BlackMisc::CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating);
|
contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating);
|
||||||
if (this->isFrameless())
|
if (this->isFrameless())
|
||||||
{
|
{
|
||||||
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Normal window", this, &CDockWidget::toggleFrameless);
|
contextMenu->addAction(CIcons::tableSheet16(), "Normal window", this, &CDockWidget::toggleFrameless);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Frameless", this, &CDockWidget::toggleFrameless);
|
contextMenu->addAction(CIcons::tableSheet16(), "Frameless", this, &CDockWidget::toggleFrameless);
|
||||||
}
|
}
|
||||||
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Redraw", this, SLOT(update()));
|
contextMenu->addAction(CIcons::refresh16(), "Redraw", this, SLOT(update()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
contextMenu->addAction(BlackMisc::CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating);
|
contextMenu->addAction(CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font actions
|
// Font actions
|
||||||
@@ -358,13 +360,13 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// State actions (windows state)
|
// State actions (windows state)
|
||||||
contextMenu->addAction(BlackMisc::CIcons::load16(), "Restore", this, &CDockWidget::restoreFromSettings);
|
contextMenu->addAction(CIcons::load16(), "Restore", this, &CDockWidget::restoreFromSettings);
|
||||||
contextMenu->addAction(BlackMisc::CIcons::save16(), "Save state", this, &CDockWidget::saveCurrentStateToSettings);
|
contextMenu->addAction(CIcons::save16(), "Save state", this, &CDockWidget::saveCurrentStateToSettings);
|
||||||
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset to defaults", this, &CDockWidget::resetSettings);
|
contextMenu->addAction(CIcons::refresh16(), "Reset to defaults", this, &CDockWidget::resetSettings);
|
||||||
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset position", this, &CDockWidget::resetPosition);
|
contextMenu->addAction(CIcons::refresh16(), "Reset position", this, &CDockWidget::resetPosition);
|
||||||
|
|
||||||
m_input->setMargins(this->contentsMargins());
|
m_input->setMargins(this->contentsMargins());
|
||||||
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Margins", this, &CDockWidget::dummy);
|
contextMenu->addAction(CIcons::tableSheet16(), "Margins", this, &CDockWidget::dummy);
|
||||||
contextMenu->addAction(m_marginMenuAction);
|
contextMenu->addAction(m_marginMenuAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,11 @@ namespace BlackGui
|
|||||||
//! Top level has changed for given widget
|
//! Top level has changed for given widget
|
||||||
void widgetTopLevelChanged(CDockWidget *, bool topLevel);
|
void widgetTopLevelChanged(CDockWidget *, bool topLevel);
|
||||||
|
|
||||||
|
//! Font size signals @{
|
||||||
|
void fontSizePlus();
|
||||||
|
void fontSizeMinus();
|
||||||
|
//! @}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit CDockWidget(QWidget *parent = nullptr);
|
explicit CDockWidget(QWidget *parent = nullptr);
|
||||||
|
|||||||
@@ -29,25 +29,25 @@ namespace BlackGui
|
|||||||
CFontMenu::CFontMenu(QWidget *widget, Qt::ShortcutContext shortcutContext) :
|
CFontMenu::CFontMenu(QWidget *widget, Qt::ShortcutContext shortcutContext) :
|
||||||
IMenuDelegate(widget), m_widget(widget)
|
IMenuDelegate(widget), m_widget(widget)
|
||||||
{
|
{
|
||||||
this->m_fontDialogAction.reset(new QAction(CIcons::font16(), "Font", this));
|
m_fontDialogAction.reset(new QAction(CIcons::font16(), "Font", this));
|
||||||
QObject::connect(this->m_fontDialogAction.data(), &QAction::triggered, this, &CFontMenu::changeFontDialog);
|
QObject::connect(m_fontDialogAction.data(), &QAction::triggered, this, &CFontMenu::changeFontDialog);
|
||||||
|
|
||||||
m_fontSizePlusShortcut = new QShortcut(CShortcut::keyFontPlus(), this->m_widget);
|
m_fontSizePlusShortcut = new QShortcut(CShortcut::keyFontPlus(), m_widget);
|
||||||
m_fontSizePlusShortcut->setContext(shortcutContext);
|
m_fontSizePlusShortcut->setContext(shortcutContext);
|
||||||
QObject::connect(this->m_fontSizePlusShortcut, &QShortcut::activated, this, &CFontMenu::fontSizePlus);
|
QObject::connect(m_fontSizePlusShortcut, &QShortcut::activated, this, &CFontMenu::onFontSizePlus);
|
||||||
|
|
||||||
m_fontSizeMinusShortcut = new QShortcut(CShortcut::keyFontMinus(), this->m_widget);
|
m_fontSizeMinusShortcut = new QShortcut(CShortcut::keyFontMinus(), m_widget);
|
||||||
m_fontSizeMinusShortcut->setContext(shortcutContext);
|
m_fontSizeMinusShortcut->setContext(shortcutContext);
|
||||||
QObject::connect(this->m_fontSizeMinusShortcut, &QShortcut::activated, this, &CFontMenu::fontSizeMinus);
|
QObject::connect(m_fontSizeMinusShortcut, &QShortcut::activated, this, &CFontMenu::onFontSizeMinus);
|
||||||
|
|
||||||
m_fontResetShortcut = new QShortcut(CShortcut::keyFontReset(), this->m_widget);
|
m_fontResetShortcut = new QShortcut(CShortcut::keyFontReset(), m_widget);
|
||||||
m_fontResetShortcut->setContext(shortcutContext);
|
m_fontResetShortcut->setContext(shortcutContext);
|
||||||
QObject::connect(this->m_fontResetShortcut, &QShortcut::activated, this, &CFontMenu::fontReset);
|
QObject::connect(m_fontResetShortcut, &QShortcut::activated, this, &CFontMenu::onFontReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFontMenu::customMenu(CMenuActions &menuActions)
|
void CFontMenu::customMenu(CMenuActions &menuActions)
|
||||||
{
|
{
|
||||||
menuActions.addAction(this->m_fontDialogAction.data(), CMenuAction::pathFont());
|
menuActions.addAction(m_fontDialogAction.data(), CMenuAction::pathFont());
|
||||||
this->nestedCustomMenu(menuActions);
|
this->nestedCustomMenu(menuActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ namespace BlackGui
|
|||||||
m_widget->setStyleSheet(qss);
|
m_widget->setStyleSheet(qss);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFontMenu::fontSizePlus()
|
void CFontMenu::onFontSizePlus()
|
||||||
{
|
{
|
||||||
if (!m_widget) { return; }
|
if (!m_widget) { return; }
|
||||||
const int pt = m_widget->font().pointSize() + 1;
|
const int pt = m_widget->font().pointSize() + 1;
|
||||||
@@ -84,18 +84,23 @@ namespace BlackGui
|
|||||||
|
|
||||||
m_widget->setStyleSheet(""); // avoid Qt crash
|
m_widget->setStyleSheet(""); // avoid Qt crash
|
||||||
m_widget->setStyleSheet(CStyleSheetUtility::asStylesheet(m_widget, pt));
|
m_widget->setStyleSheet(CStyleSheetUtility::asStylesheet(m_widget, pt));
|
||||||
|
|
||||||
|
emit this->fontSizePlus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFontMenu::fontSizeMinus()
|
void CFontMenu::onFontSizeMinus()
|
||||||
{
|
{
|
||||||
if (!m_widget) { return; }
|
if (!m_widget) { return; }
|
||||||
const int pt = m_widget->font().pointSize() - 1;
|
const int pt = m_widget->font().pointSize() - 1;
|
||||||
if (pt < 5) { return; }
|
if (pt < 5) { return; }
|
||||||
|
|
||||||
m_widget->setStyleSheet(""); // avoid Qt crash
|
m_widget->setStyleSheet(""); // avoid Qt crash
|
||||||
m_widget->setStyleSheet(CStyleSheetUtility::asStylesheet(m_widget, pt));
|
m_widget->setStyleSheet(CStyleSheetUtility::asStylesheet(m_widget, pt));
|
||||||
|
|
||||||
|
emit this->fontSizeMinus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFontMenu::fontReset()
|
void CFontMenu::onFontReset()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(m_widget, Q_FUNC_INFO, "No widget");
|
Q_ASSERT_X(m_widget, Q_FUNC_INFO, "No widget");
|
||||||
m_widget->setStyleSheet("");
|
m_widget->setStyleSheet("");
|
||||||
|
|||||||
@@ -47,11 +47,17 @@ namespace BlackGui
|
|||||||
//! The shortcus owned by QWidget
|
//! The shortcus owned by QWidget
|
||||||
QList<QShortcut *> getShortcuts() const;
|
QList<QShortcut *> getShortcuts() const;
|
||||||
|
|
||||||
private:
|
signals:
|
||||||
void changeFontDialog();
|
//! Font size signals @{
|
||||||
void fontSizePlus();
|
void fontSizePlus();
|
||||||
void fontSizeMinus();
|
void fontSizeMinus();
|
||||||
void fontReset();
|
//! @}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void changeFontDialog();
|
||||||
|
void onFontSizePlus();
|
||||||
|
void onFontSizeMinus();
|
||||||
|
void onFontReset();
|
||||||
|
|
||||||
QWidget *m_widget = nullptr;
|
QWidget *m_widget = nullptr;
|
||||||
QShortcut *m_fontSizePlusShortcut = nullptr; //! owned by widget
|
QShortcut *m_fontSizePlusShortcut = nullptr; //! owned by widget
|
||||||
|
|||||||
Reference in New Issue
Block a user