Skip to content

Commit

Permalink
sync: from linuxdeepin/dtkwidget
Browse files Browse the repository at this point in the history
Synchronize source files from linuxdeepin/dtkwidget.

Source-pull-request: linuxdeepin/dtkwidget#566
  • Loading branch information
deepin-ci-robot authored and kegechen committed May 13, 2024
1 parent fc7817d commit e8d8171
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 16 additions & 0 deletions src/widgets/dapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,22 @@ bool DApplication::notify(QObject *obj, QEvent *event)
}
}

// Qt 6.4 引入了 QPlatformTheme::ThemeHint::ButtonPressKeys
// 可以通过主题插件 themeHint 返回一个按键列表,按钮应该响应列表中的按键
// see https://github.com/linuxdeepin/qt5integration/pull/20
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
if (event->type() == QEvent::KeyPress && obj == focusWidget()) {
if (auto keyEvent = dynamic_cast<QKeyEvent *>(event)) {
if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
if (auto btn = qobject_cast<QAbstractButton *>(obj)) {
Q_EMIT btn->clicked();
return true;
}
}
}
}
#endif

if (event->type() == QEvent::ApplicationFontChange) {
// ApplicationFontChange 调用 font() 是 ok 的,如果在 fontChanged 中调用在某些版本中会出现 deadlock
DFontSizeManager::instance()->setFontGenericPixelSize(static_cast<quint16>(DFontSizeManager::fontPixelSize(font())));
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/dprintpreviewdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ void DPrintPreviewDialogPrivate::initconnections()
this->marginsUpdate(false);
}
if (pview->pageRangeMode() == DPrintPreviewWidget::SelectPage && pageRangeCombo->isEnabled())
pageRangeCombo->setCurrentIndex(PAGERANGE_ALL);
_q_customPagesFinished();

});

Expand Down Expand Up @@ -1769,7 +1769,7 @@ void DPrintPreviewDialogPrivate::_q_printerChanged(int index)

marginsUpdate(true);
if (pview->pageRangeMode() == DPrintPreviewWidget::SelectPage && pageRangeCombo->isEnabled())
pageRangeCombo->setCurrentIndex(PAGERANGE_ALL);
_q_customPagesFinished();
paperSizeCombo->blockSignals(false);
if (isInited)
updateAllControlSettings();
Expand Down Expand Up @@ -1859,7 +1859,7 @@ void DPrintPreviewDialogPrivate::_q_pageMarginChanged(int index)
}

if (pview->pageRangeMode() == DPrintPreviewWidget::SelectPage && pageRangeCombo->isEnabled())
pageRangeCombo->setCurrentIndex(PAGERANGE_ALL);
_q_customPagesFinished();

if (marginOldValue.length() > 4)
marginOldValue.clear();
Expand Down Expand Up @@ -1912,7 +1912,7 @@ void DPrintPreviewDialogPrivate::_q_orientationChanged(int index)
pview->setOrientation(DPrinter::Landscape);
}
if (pview->pageRangeMode() == DPrintPreviewWidget::SelectPage && pageRangeCombo->isEnabled())
pageRangeCombo->setCurrentIndex(PAGERANGE_ALL);
_q_customPagesFinished();
}

/*!
Expand Down Expand Up @@ -2008,7 +2008,7 @@ void DPrintPreviewDialogPrivate::adjustMargins()
this->printer->setPageMargins(QMarginsF(leftMarginF, topMarginF, rightMarginF, bottomMarginF), QPageLayout::Millimeter);
this->pview->updatePreview();
if (pview->pageRangeMode() == DPrintPreviewWidget::SelectPage && pageRangeCombo->isEnabled())
pageRangeCombo->setCurrentIndex(PAGERANGE_ALL);
_q_customPagesFinished();
}

/*!
Expand Down

0 comments on commit e8d8171

Please sign in to comment.