diff --git a/debian/changelog b/debian/changelog index 876717c70..c4595a5e2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +dde-session-shell (6.0.17) unstable; urgency=medium + + * fix: trayWidget shouldn't acquire focus + * fix: add runtime dependency `onboard` for dde-session-shell + + -- YuMing He Tue, 30 Jan 2024 10:17:50 +0800 + dde-session-shell (6.0.16) unstable; urgency=medium * fix: switch tty can not lock screen diff --git a/debian/control b/debian/control index a0ef37437..0111543e1 100644 --- a/debian/control +++ b/debian/control @@ -42,10 +42,10 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${dist:Depends}, deepin-authenticate(>=1.2.27), libssl3, libxcb-util0|libxcb-util1, - xsettingsd + xsettingsd, + onboard Provides: lightdm-greeter -Recommends: onboard, - dss-network-plugin, +Recommends: dss-network-plugin, dde-network-dialog Conflicts: dde-workspace, deepin-notifications, diff --git a/modules/virtualkeyboard/keyboardiconwidget.cpp b/modules/virtualkeyboard/keyboardiconwidget.cpp index 1427338ad..f48d8fa92 100644 --- a/modules/virtualkeyboard/keyboardiconwidget.cpp +++ b/modules/virtualkeyboard/keyboardiconwidget.cpp @@ -23,6 +23,19 @@ void KeyboardIconWidget::setIconPath(const QString &iconPath) update(); } +bool KeyboardIconWidget::event(QEvent *event) { + if (event->type() == QEvent::User + 10) { + QWidget *topLevelWidget = this->topLevelWidget(); + if (topLevelWidget) { + // 获取顶层窗口,虚拟键盘窗口中需要知道顶层窗口以便移动位置 + Q_EMIT clicked(topLevelWidget); + } + } + + return QWidget::event(event); +} + + void KeyboardIconWidget::paintEvent(QPaintEvent *event) { QPainter painter(this); @@ -53,16 +66,3 @@ void KeyboardIconWidget::hideEvent(QHideEvent *event) QWidget::hideEvent(event); } - -void KeyboardIconWidget::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - QWidget *topLevelWidget = this->topLevelWidget(); - if (topLevelWidget) { - // 获取顶层窗口,虚拟键盘窗口中需要知道顶层窗口以便移动位置 - Q_EMIT clicked(topLevelWidget); - } - } - - QWidget::mousePressEvent(event); -} diff --git a/modules/virtualkeyboard/keyboardiconwidget.h b/modules/virtualkeyboard/keyboardiconwidget.h index 95dd299c1..48042668e 100644 --- a/modules/virtualkeyboard/keyboardiconwidget.h +++ b/modules/virtualkeyboard/keyboardiconwidget.h @@ -21,12 +21,12 @@ class KeyboardIconWidget : public QWidget void clicked(QWidget *parent); protected: - virtual void paintEvent(QPaintEvent *event); - virtual void hideEvent(QHideEvent *event); - virtual void mousePressEvent(QMouseEvent *event); + bool event(QEvent *event) override; + virtual void paintEvent(QPaintEvent *event); + virtual void hideEvent(QHideEvent *event); private: - QString m_iconPath; + QString m_iconPath; }; #endif // KEYBOARDICONWIDGET_H diff --git a/src/widgets/controlwidget.cpp b/src/widgets/controlwidget.cpp index a3891bcc3..1cb13b103 100644 --- a/src/widgets/controlwidget.cpp +++ b/src/widgets/controlwidget.cpp @@ -35,6 +35,14 @@ static constexpr int TipsBottomDistance = 10; using namespace dss; DCORE_USE_NAMESPACE +void FloatingButton::showCustomWidget() const { + qInfo() << __PRETTY_FUNCTION__; + QEvent eve{static_cast(QEvent::User + 10)}; + if (pluginItem() != nullptr) { + QCoreApplication::sendEvent(pluginItem(), &eve); + } +} + bool FloatingButton::eventFilter(QObject *watch, QEvent *event) { if (watch == this) { @@ -42,15 +50,23 @@ bool FloatingButton::eventFilter(QObject *watch, QEvent *event) QMouseEvent *e = static_cast(event); if (e->button() == Qt::RightButton) { Q_EMIT requestShowMenu(); + } else if (e->button() == Qt::LeftButton) { + showCustomWidget(); } } else if (event->type() == QEvent::Enter) { Q_EMIT requestShowTips(); } else if (event->type() == QEvent::Leave || event->type() == QEvent::MouseButtonPress) { Q_EMIT requestHideTips(); + } else if (event->type() == QEvent::KeyRelease) { + auto *keyEve = dynamic_cast(event); + if (keyEve->key() == Qt::Key_Return || + keyEve->key() == Qt::Key_Enter) { + showCustomWidget(); + } } } - return false; + return DFloatingButton::eventFilter(watch, event); } ControlWidget::ControlWidget(const SessionBaseModel *model, QWidget *parent) @@ -228,6 +244,7 @@ void ControlWidget::addModule(module::BaseModuleInterface *module) layout->setSpacing(0); layout->setMargin(0); layout->addWidget(trayWidget); + button->setPluginItem(trayWidget); } else { button->setIcon(QIcon(trayModule->icon())); } diff --git a/src/widgets/controlwidget.h b/src/widgets/controlwidget.h index 3f49661fb..c9d65b9b9 100644 --- a/src/widgets/controlwidget.h +++ b/src/widgets/controlwidget.h @@ -76,7 +76,10 @@ class FloatingButton : public DFloatingButton return m_tipText; } -Q_SIGNALS: + void setPluginItem(QWidget *item) { m_item = item; } + QWidget *pluginItem() const { return m_item; } + + Q_SIGNALS: void requestShowMenu(); void requestShowTips(); void requestHideTips(); @@ -85,7 +88,9 @@ class FloatingButton : public DFloatingButton bool eventFilter(QObject *watch, QEvent *event) override; private: - QString m_tipText; + void showCustomWidget() const; + QString m_tipText; + QWidget *m_item{nullptr}; }; class ControlWidget : public QWidget {