Skip to content

Commit

Permalink
fix: add runtime dependency onboard for dde-session-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
ComixHe committed Feb 1, 2024
1 parent bfe1e95 commit 626c279
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 23 deletions.
6 changes: 3 additions & 3 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 13 additions & 13 deletions modules/virtualkeyboard/keyboardiconwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
8 changes: 4 additions & 4 deletions modules/virtualkeyboard/keyboardiconwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 18 additions & 1 deletion src/widgets/controlwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,38 @@ static constexpr int TipsBottomDistance = 10;
using namespace dss;
DCORE_USE_NAMESPACE

void FloatingButton::showCustomWidget() const {
qInfo() << __PRETTY_FUNCTION__;
QEvent eve{static_cast<QEvent::Type>(QEvent::User + 10)};
if (pluginItem() != nullptr) {
QCoreApplication::sendEvent(pluginItem(), &eve);
}
}

bool FloatingButton::eventFilter(QObject *watch, QEvent *event)
{
if (watch == this) {
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *e = static_cast<QMouseEvent *>(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<QKeyEvent *>(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)
Expand Down Expand Up @@ -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()));
}
Expand Down
9 changes: 7 additions & 2 deletions src/widgets/controlwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
{
Expand Down

0 comments on commit 626c279

Please sign in to comment.