mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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
|
||||
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged);
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged, Qt::QueuedConnection);
|
||||
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged);
|
||||
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()
|
||||
@@ -334,20 +336,20 @@ namespace BlackGui
|
||||
{
|
||||
if (this->isFloating())
|
||||
{
|
||||
contextMenu->addAction(BlackMisc::CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating);
|
||||
contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating);
|
||||
if (this->isFrameless())
|
||||
{
|
||||
contextMenu->addAction(BlackMisc::CIcons::tableSheet16(), "Normal window", this, &CDockWidget::toggleFrameless);
|
||||
contextMenu->addAction(CIcons::tableSheet16(), "Normal window", this, &CDockWidget::toggleFrameless);
|
||||
}
|
||||
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
|
||||
{
|
||||
contextMenu->addAction(BlackMisc::CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating);
|
||||
contextMenu->addAction(CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating);
|
||||
}
|
||||
|
||||
// Font actions
|
||||
@@ -358,13 +360,13 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
// State actions (windows state)
|
||||
contextMenu->addAction(BlackMisc::CIcons::load16(), "Restore", this, &CDockWidget::restoreFromSettings);
|
||||
contextMenu->addAction(BlackMisc::CIcons::save16(), "Save state", this, &CDockWidget::saveCurrentStateToSettings);
|
||||
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset to defaults", this, &CDockWidget::resetSettings);
|
||||
contextMenu->addAction(BlackMisc::CIcons::refresh16(), "Reset position", this, &CDockWidget::resetPosition);
|
||||
contextMenu->addAction(CIcons::load16(), "Restore", this, &CDockWidget::restoreFromSettings);
|
||||
contextMenu->addAction(CIcons::save16(), "Save state", this, &CDockWidget::saveCurrentStateToSettings);
|
||||
contextMenu->addAction(CIcons::refresh16(), "Reset to defaults", this, &CDockWidget::resetSettings);
|
||||
contextMenu->addAction(CIcons::refresh16(), "Reset position", this, &CDockWidget::resetPosition);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,11 @@ namespace BlackGui
|
||||
//! Top level has changed for given widget
|
||||
void widgetTopLevelChanged(CDockWidget *, bool topLevel);
|
||||
|
||||
//! Font size signals @{
|
||||
void fontSizePlus();
|
||||
void fontSizeMinus();
|
||||
//! @}
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
explicit CDockWidget(QWidget *parent = nullptr);
|
||||
|
||||
@@ -29,25 +29,25 @@ namespace BlackGui
|
||||
CFontMenu::CFontMenu(QWidget *widget, Qt::ShortcutContext shortcutContext) :
|
||||
IMenuDelegate(widget), m_widget(widget)
|
||||
{
|
||||
this->m_fontDialogAction.reset(new QAction(CIcons::font16(), "Font", this));
|
||||
QObject::connect(this->m_fontDialogAction.data(), &QAction::triggered, this, &CFontMenu::changeFontDialog);
|
||||
m_fontDialogAction.reset(new QAction(CIcons::font16(), "Font", this));
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
QObject::connect(this->m_fontResetShortcut, &QShortcut::activated, this, &CFontMenu::fontReset);
|
||||
QObject::connect(m_fontResetShortcut, &QShortcut::activated, this, &CFontMenu::onFontReset);
|
||||
}
|
||||
|
||||
void CFontMenu::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
menuActions.addAction(this->m_fontDialogAction.data(), CMenuAction::pathFont());
|
||||
menuActions.addAction(m_fontDialogAction.data(), CMenuAction::pathFont());
|
||||
this->nestedCustomMenu(menuActions);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace BlackGui
|
||||
m_widget->setStyleSheet(qss);
|
||||
}
|
||||
|
||||
void CFontMenu::fontSizePlus()
|
||||
void CFontMenu::onFontSizePlus()
|
||||
{
|
||||
if (!m_widget) { return; }
|
||||
const int pt = m_widget->font().pointSize() + 1;
|
||||
@@ -84,18 +84,23 @@ namespace BlackGui
|
||||
|
||||
m_widget->setStyleSheet(""); // avoid Qt crash
|
||||
m_widget->setStyleSheet(CStyleSheetUtility::asStylesheet(m_widget, pt));
|
||||
|
||||
emit this->fontSizePlus();
|
||||
}
|
||||
|
||||
void CFontMenu::fontSizeMinus()
|
||||
void CFontMenu::onFontSizeMinus()
|
||||
{
|
||||
if (!m_widget) { return; }
|
||||
const int pt = m_widget->font().pointSize() - 1;
|
||||
if (pt < 5) { return; }
|
||||
|
||||
m_widget->setStyleSheet(""); // avoid Qt crash
|
||||
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");
|
||||
m_widget->setStyleSheet("");
|
||||
|
||||
@@ -47,11 +47,17 @@ namespace BlackGui
|
||||
//! The shortcus owned by QWidget
|
||||
QList<QShortcut *> getShortcuts() const;
|
||||
|
||||
private:
|
||||
void changeFontDialog();
|
||||
signals:
|
||||
//! Font size signals @{
|
||||
void fontSizePlus();
|
||||
void fontSizeMinus();
|
||||
void fontReset();
|
||||
//! @}
|
||||
|
||||
private:
|
||||
void changeFontDialog();
|
||||
void onFontSizePlus();
|
||||
void onFontSizeMinus();
|
||||
void onFontReset();
|
||||
|
||||
QWidget *m_widget = nullptr;
|
||||
QShortcut *m_fontSizePlusShortcut = nullptr; //! owned by widget
|
||||
|
||||
Reference in New Issue
Block a user