Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions application/widgets/customcontrol/ddbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
// SPDX-License-Identifier: GPL-3.0-only

#include "ddbase.h"
#include "common.h"

Check warning on line 6 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "common.h" not found.

#include <QGuiApplication>

Check warning on line 8 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QKeyEvent>

Check warning on line 9 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QKeyEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScreen>

Check warning on line 10 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QScreen> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QShowEvent>

Check warning on line 11 in application/widgets/customcontrol/ddbase.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QShowEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DDBase::DDBase(QWidget *parent)
: DDialog(parent)
Expand Down Expand Up @@ -33,3 +36,18 @@
DDialog::keyPressEvent(event);
}
}

void DDBase::showEvent(QShowEvent *event)
{
DDialog::showEvent(event);

QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
if (!screen && parentWidget())
screen = QGuiApplication::screenAt(parentWidget()->window()->geometry().center());
if (!screen)
screen = QGuiApplication::primaryScreen();
if (screen) {
QRect screenGeo = screen->geometry();
move(screenGeo.center() - rect().center());
}
}
5 changes: 5 additions & 0 deletions application/widgets/customcontrol/ddbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class DDBase : public DDialog
* @param event事件
*/
void keyPressEvent(QKeyEvent *event) override;
/**
* @brief 显示事件,Wayland下手动居中到当前屏幕
* @param event事件
*/
void showEvent(QShowEvent *event) override;
};

#endif // DDBASE_H
18 changes: 18 additions & 0 deletions application/widgets/messagebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

#include <DLabel>
#include <DFontSizeManager>
#include <DGuiApplicationHelper>

Check warning on line 12 in application/widgets/messagebox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QAbstractButton>

Check warning on line 14 in application/widgets/messagebox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QAbstractButton> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QGuiApplication>

Check warning on line 15 in application/widgets/messagebox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QKeyEvent>

Check warning on line 16 in application/widgets/messagebox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QKeyEvent> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScreen>

Check warning on line 17 in application/widgets/messagebox.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QScreen> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QShowEvent>

MessageBox::MessageBox(QWidget *parent) : DDialog(parent)
{
Expand Down Expand Up @@ -192,4 +195,19 @@
// qDebug() << "MessageBox::keyPressEvent completed.";
}

void MessageBox::showEvent(QShowEvent *event)
{
DDialog::showEvent(event);

QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
if (!screen && parentWidget())
screen = QGuiApplication::screenAt(parentWidget()->window()->geometry().center());
if (!screen)
screen = QGuiApplication::primaryScreen();
if (screen) {
QRect screenGeo = screen->geometry();
move(screenGeo.center() - rect().center());
}
}


5 changes: 5 additions & 0 deletions application/widgets/messagebox.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public slots:
* @param event事件
*/
void keyPressEvent(QKeyEvent *event) override;
/**
* @brief 显示事件,Wayland下手动居中到当前屏幕
* @param event事件
*/
void showEvent(QShowEvent *event) override;

private:
DProgressBar *m_progressBar; // 进度条
Expand Down
Loading