From 568ab246322d7aa00a497ea7a613f0a16a0bb06f Mon Sep 17 00:00:00 2001 From: zhoudisi Date: Sun, 31 Mar 2024 20:45:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=80=82=E9=85=8Dsdk=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoudisi --- kybackup/main.cpp | 5 ++++- kybackup/maindialog.cpp | 21 ++++++++++++++++++--- kybackup/maindialog.h | 5 +++++ kybackup/messageboxutils.cpp | 7 +++++-- kybackup/module/databackup.cpp | 7 +++++++ kybackup/module/datarestore.cpp | 4 ++++ kybackup/module/ghostimage.cpp | 4 ++++ kybackup/module/systembackup.cpp | 4 ++++ kybackup/module/systemrestore.cpp | 4 ++++ 9 files changed, 55 insertions(+), 6 deletions(-) diff --git a/kybackup/main.cpp b/kybackup/main.cpp index 9f0ea0b..160d4f1 100755 --- a/kybackup/main.cpp +++ b/kybackup/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) } MainDialog w; // 居中窗口 - centerToScreen(&w); +// centerToScreen(&w); a.setWindowIcon(QIcon::fromTheme(THEME_YHKYLIN_BACKUP_TOOLS, QIcon(":/images/yhkylin-backup-tools.png"))); a.setActivationWindow(&w, true); a.setApplicationName(QObject::tr("Backup & Restore")); @@ -68,6 +68,9 @@ int main(int argc, char *argv[]) QObject::connect(&a,SIGNAL(messageReceived(const QString&)),&w,SLOT(sltMessageReceived(const QString&))); w.show(); + kdk::WindowManager::setGeometry(w.windowHandle(), + QRect(qApp->desktop()->geometry().center() - w.geometry().center(), + QSize(w.size()))); return a.exec(); } diff --git a/kybackup/maindialog.cpp b/kybackup/maindialog.cpp index 6ffd87d..17a441f 100755 --- a/kybackup/maindialog.cpp +++ b/kybackup/maindialog.cpp @@ -34,6 +34,12 @@ MainDialog::MainDialog(QWidget *parent) // 或使用设置毛玻璃属性的方式实现毛玻璃背景(两者都行,可使用其一) this->setProperty("useSystemStyleBlur", true); this->setAutoFillBackground(true); + connect(kdk::WindowManager::self(), &kdk::WindowManager::windowAdded, this, [=](const kdk::WindowId& window_id){ + if (getpid() == kdk::WindowManager::getPid(window_id) && m_window_id == 0) + { + m_window_id = window_id.toULongLong(); + } + }); // 去除窗管标题栏,传入参数为QWidget * kdk::UkuiStyleHelper::self()->removeHeader(this); @@ -202,6 +208,13 @@ void MainDialog::initConnect() // 关于 connect(m_backupAbout, &QAction::triggered, this, [=] { AboutDialog *about = new AboutDialog(this); + kdk::UkuiStyleHelper::self()->removeHeader(about); + if(!GlobelBackupInfo::instance().isWayland()){ + about->setModal(true); + about->show(); + about->move(width()/2-about->width()/2+x(),height()/2-about->height()/2+y()); + kdk::WindowManager::setGeometry(about->windowHandle(),about->geometry()); + } about->exec(); about->deleteLater(); }); @@ -213,14 +226,16 @@ void MainDialog::initConnect() }); //最小化按钮 - connect(m_minBtn, &QPushButton::clicked, this, &MainDialog::showMinimized); + connect(m_minBtn, &QPushButton::clicked, this, [=](){ + kdk::WindowManager::minimizeWindow(m_window_id); + }); //最大化按钮 connect(m_maxBtn, &QPushButton::clicked, this, [=] { if (isMaximized()) { showNormal(); } else { - showMaximized(); + kdk::WindowManager::maximizeWindow(m_window_id); } }); connect(m_titleWidget, &DoubleClickWidget::doubleClicked, m_maxBtn, &QPushButton::click); @@ -429,7 +444,7 @@ void MainDialog::resizeEvent(QResizeEvent *event) { void MainDialog::closeBtn() { if (this->close()) { - qApp->quit(); + kdk::WindowManager::closeWindow(m_window_id); } } diff --git a/kybackup/maindialog.h b/kybackup/maindialog.h index e783abc..9711509 100755 --- a/kybackup/maindialog.h +++ b/kybackup/maindialog.h @@ -11,6 +11,9 @@ #include #include "leftsiderbarwidget.h" #include "component/doubleclickwidget.h" +#include "windowmanager/windowmanager.h" + +using namespace kdk; QT_BEGIN_NAMESPACE namespace Ui { class MainDialog; } @@ -71,6 +74,8 @@ private: // 监控是否平板的dbus接口 QDBusInterface * m_statusSessionDbus = nullptr; + quint64 m_window_id; + Ui::MainDialog *ui; }; #endif // MAINDIALOG_H diff --git a/kybackup/messageboxutils.cpp b/kybackup/messageboxutils.cpp index b607e0b..94a894c 100755 --- a/kybackup/messageboxutils.cpp +++ b/kybackup/messageboxutils.cpp @@ -6,12 +6,14 @@ #include "globalsignals.h" #include "globalbackupinfo.h" #include - - +#include +#include +#include MyMessageBox::MyMessageBox(QWidget *parent) : QMessageBox(parent) { setThemeIcon(THEME_YHKYLIN_BACKUP_TOOLS); + kdk::UkuiStyleHelper::self()->removeHeader(this); } MyMessageBox::~MyMessageBox() @@ -51,6 +53,7 @@ void MessageBoxUtils::QMESSAGE_BOX_INFORMATION(QWidget* q_parent, const QString& box->setText(message); QPushButton * okbtn = box->addButton(label, QMessageBox::AcceptRole); box->setDefaultButton(okbtn); + box->show(); box->exec(); } diff --git a/kybackup/module/databackup.cpp b/kybackup/module/databackup.cpp index f13d001..9a8cb44 100755 --- a/kybackup/module/databackup.cpp +++ b/kybackup/module/databackup.cpp @@ -30,6 +30,7 @@ #include "../gsettingswrapper.h" #include "kwidget.h" #include "kborderbutton.h" +#include using namespace kdk; @@ -206,6 +207,9 @@ void DataBackup::initHomePage() this->m_prefixDestPath = backupPoint.m_path; this->m_isLocal = backupPoint.m_iPosition == BackupPosition::UDISK || backupPoint.m_iPosition == BackupPosition::OTHER ? false : true; }); + QPointF position = parentWidget()->mapToGlobal(QPoint(0,0)); + selectDialog->move(position.x()-100+parentWidget()->width()/2-selectDialog->width()/2,position.y()-20+parentWidget()->height()/2-selectDialog->height()/2); + kdk::WindowManager::setGeometry(selectDialog->windowHandle(),selectDialog->geometry()); if (QDialog::Accepted == selectDialog->exec()) { this->m_isIncrement = true; @@ -239,6 +243,9 @@ void DataBackup::initHomePage() connect(backupPointManage, &MyPushButton::clicked, this, [=]() { ManageBackupPointList backupManager(homePage, ManageBackupPointList::DATA); + QPointF position = parentWidget()->mapToGlobal(QPoint(0,0)); + backupManager.move(position.x()-100+parentWidget()->width()/2-backupManager.width()/2,position.y()-20+parentWidget()->height()/2-backupManager.height()/2); + kdk::WindowManager::setGeometry(backupManager.windowHandle(),backupManager.geometry()); backupManager.exec(); }); connect(GlobelBackupInfo::instance().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) { diff --git a/kybackup/module/datarestore.cpp b/kybackup/module/datarestore.cpp index 9a45626..0b76efe 100755 --- a/kybackup/module/datarestore.cpp +++ b/kybackup/module/datarestore.cpp @@ -23,6 +23,7 @@ #include "messageboxutils.h" #include "selectrestorepoint.h" #include "kborderbutton.h" +#include using namespace kdk; // bigTitle控件前面的宽度:24+spacing @@ -191,6 +192,9 @@ void DataRestore::on_button_beginRestore_clicked(bool checked) this->m_devPath = backupPoint.m_path; this->m_iPosition = backupPoint.m_iPosition; }); + QPointF position = parentWidget()->mapToGlobal(QPoint(0,0)); + selectRestoreDialog->move(position.x()-100+parentWidget()->width()/2-selectRestoreDialog->width()/2,position.y()-20+parentWidget()->height()/2-selectRestoreDialog->height()/2); + kdk::WindowManager::setGeometry(selectRestoreDialog->windowHandle(),selectRestoreDialog->geometry()); if (QDialog::Rejected == selectRestoreDialog->exec()) { selectRestoreDialog->deleteLater(); diff --git a/kybackup/module/ghostimage.cpp b/kybackup/module/ghostimage.cpp index 77c995f..8133b45 100755 --- a/kybackup/module/ghostimage.cpp +++ b/kybackup/module/ghostimage.cpp @@ -24,6 +24,7 @@ #include "selectrestorepoint.h" #include "messageboxutils.h" #include "kborderbutton.h" +#include using namespace kdk; // bigTitle控件前面的宽度:24+spacing @@ -176,6 +177,9 @@ void GhostImage::initHomePage() this->m_backupName = backupPoint.m_backupName; this->m_iPosition = backupPoint.m_iPosition; }); + QPointF position = parentWidget()->mapToGlobal(QPoint(0,0)); + selectDialog->move(position.x()-100+parentWidget()->width()/2-selectDialog->width()/2,position.y()-20+parentWidget()->height()/2-selectDialog->height()/2); + kdk::WindowManager::setGeometry(selectDialog->windowHandle(),selectDialog->geometry()); if (QDialog::Accepted == selectDialog->exec()) { this->m_isLocal = true; diff --git a/kybackup/module/systembackup.cpp b/kybackup/module/systembackup.cpp index 6d7dbc7..5505d7c 100755 --- a/kybackup/module/systembackup.cpp +++ b/kybackup/module/systembackup.cpp @@ -26,6 +26,7 @@ #include "managebackuppointlist.h" #include "messageboxutils.h" #include "kborderbutton.h" +#include using namespace kdk; // bigTitle控件前面的宽度:24+spacing @@ -181,6 +182,9 @@ void SystemBackup::initHomePage() connect(backupPointManage, &MyPushButton::clicked, this, [=]() { ManageBackupPointList backupManager(homePage, ManageBackupPointList::SYSTEM); + QPointF position = parentWidget()->mapToGlobal(QPoint(0,0)); + backupManager.move(position.x()-100+parentWidget()->width()/2-backupManager.width()/2,position.y()-20+parentWidget()->height()/2-backupManager.height()/2); + kdk::WindowManager::setGeometry(backupManager.windowHandle(),backupManager.geometry()); backupManager.exec(); }); connect(GlobelBackupInfo::instance().getGlobalSignals(), &GlobalSignals::styleNameChanged, this, [=](bool isDark) { diff --git a/kybackup/module/systemrestore.cpp b/kybackup/module/systemrestore.cpp index 2051804..6a12055 100755 --- a/kybackup/module/systemrestore.cpp +++ b/kybackup/module/systemrestore.cpp @@ -23,6 +23,7 @@ #include "messageboxutils.h" #include "selectrestorepoint.h" #include "kborderbutton.h" +#include using namespace kdk; // bigTitle控件前面的宽度:24+spacing @@ -244,6 +245,9 @@ void SystemRestore::on_button_beginRestore_clicked(bool checked) this->m_isOtherMachine = backupPoint.m_iPosition == BackupPosition::OTHER ? true : false; this->m_iPosition = backupPoint.m_iPosition == BackupPosition::OTHER ? BackupPosition::UDISK : backupPoint.m_iPosition; }); + QPointF position = parentWidget()->mapToGlobal(QPoint(0,0)); + selectRestoreDialog->move(position.x()-100+parentWidget()->width()/2-selectRestoreDialog->width()/2,position.y()-20+parentWidget()->height()/2-selectRestoreDialog->height()/2); + kdk::WindowManager::setGeometry(selectRestoreDialog->windowHandle(),selectRestoreDialog->geometry()); if (QDialog::Rejected == selectRestoreDialog->exec()) { selectRestoreDialog->deleteLater();