From a8d0aba1567b1e69993739caec2ca6db472dea74 Mon Sep 17 00:00:00 2001 From: yangyanwei Date: Wed, 26 Apr 2023 16:09:31 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=20=E3=80=90rc8=E8=B5=B0=E6=9F=A5=E3=80=91?= =?UTF-8?q?=E3=80=90=E6=96=87=E4=BB=B6=E7=AE=A1=E7=90=86=E5=99=A8=E3=80=91?= =?UTF-8?q?=E6=89=93=E5=BC=80=E6=96=B9=E5=BC=8F=E9=93=BE=E6=8E=A5=E6=96=87?= =?UTF-8?q?=E5=AD=97=E6=A0=B7=E5=BC=8F=E5=BE=85=E4=BC=98=E5=8C=96=20,?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E8=A6=81=E6=B1=82=E7=94=A8KBorderlessButton?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E7=94=A8KY=5FSDK=5FQT=5FWIDGETS=E6=8E=A7?= =?UTF-8?q?=E5=88=B6[LINK]147952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open-with-properties-page.cpp | 74 +++++++++++-------- .../property-page/open-with-properties-page.h | 4 + 2 files changed, 49 insertions(+), 29 deletions(-) diff --git a/libpeony-qt/controls/property-page/open-with-properties-page.cpp b/libpeony-qt/controls/property-page/open-with-properties-page.cpp index 3af56571..229de7ff 100644 --- a/libpeony-qt/controls/property-page/open-with-properties-page.cpp +++ b/libpeony-qt/controls/property-page/open-with-properties-page.cpp @@ -31,6 +31,11 @@ #include #include +#ifdef KY_SDK_QT_WIDGETS +#include "kborderlessbutton.h" +using namespace kdk; +#endif + using namespace Peony; OpenWithGlobalData *OpenWithPropertiesPage::openWithGlobalData = nullptr; @@ -165,7 +170,12 @@ void OpenWithPropertiesPage::initFloorThree() floor3->setLayout(layout3); floor3->setMaximumHeight(122); layout3->setContentsMargins(22, 0, 0, 0); - +#ifdef KY_SDK_QT_WIDGETS + KBorderlessButton *allOpenLabel = new KBorderlessButton(tr("Choose other application"), floor3); + KBorderlessButton *otherOpenLabel = new KBorderlessButton(tr("Go to application center"), floor3); + connect(allOpenLabel, &KBorderlessButton::clicked, this, &OpenWithPropertiesPage::chooseOtherApp); + connect(otherOpenLabel, &KBorderlessButton::clicked, this, &OpenWithPropertiesPage::openAppCenter); +#else QString str1; str1 = "" + tr("Choose other application") @@ -173,41 +183,16 @@ void OpenWithPropertiesPage::initFloorThree() QLabel *allOpenLabel = new QLabel(str1, floor3); allOpenLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); - connect(allOpenLabel, &QLabel::linkActivated, this, [=]() { - AllFileLaunchDialog dialog(m_fileInfo.get()->uri()); - if (QDialog::Accepted == dialog.exec()) { - m_defaultOpenWithWidget->setLaunchAction(FileLaunchManager::getDefaultAction(m_fileInfo->uri())); - } - }); - - layout3->addWidget(allOpenLabel); - QString str2; str2 = "" + tr("Go to application center") + ""; + QLabel *otherOpenLabel = new QLabel(str2, floor3); otherOpenLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); - - connect(otherOpenLabel, &QLabel::linkActivated, this, [=]() { - QtConcurrent::run([=]() { - QProcess p; - if (COMMERCIAL_VERSION || (GlobalSettings::getInstance()->getProjectName() == V10_SP1_EDU)) - p.setProgram("kylin-software-center"); - else - p.setProgram("ubuntu-kylin-software-center"); - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - p.startDetached(); -#else - if (COMMERCIAL_VERSION) - p.startDetached("kylin-software-center"); - else - p.startDetached("ubuntu-kylin-software-center"); - + connect(allOpenLabel, &QLabel::linkActivated, this, &OpenWithPropertiesPage::chooseOtherApp); + connect(otherOpenLabel, &QLabel::linkActivated, this, &OpenWithPropertiesPage::openAppCenter); #endif - }); - }); bool isVisible = false; if(QFileInfo::exists("/usr/bin/kylin-software-center") @@ -216,12 +201,43 @@ void OpenWithPropertiesPage::initFloorThree() } otherOpenLabel->setVisible(isVisible); + + layout3->addWidget(allOpenLabel); layout3->addWidget(otherOpenLabel); layout3->addStretch(1); this->m_layout->addWidget(floor3); } +void OpenWithPropertiesPage::chooseOtherApp() +{ + AllFileLaunchDialog dialog(m_fileInfo.get()->uri()); + if (QDialog::Accepted == dialog.exec()) { + m_defaultOpenWithWidget->setLaunchAction(FileLaunchManager::getDefaultAction(m_fileInfo->uri())); + } +} + +void OpenWithPropertiesPage::openAppCenter() +{ + QtConcurrent::run([=]() { + QProcess p; + if (COMMERCIAL_VERSION) + p.setProgram("kylin-software-center"); + else + p.setProgram("ubuntu-kylin-software-center"); + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) + p.startDetached(); +#else + if (COMMERCIAL_VERSION) + p.startDetached("kylin-software-center"); + else + p.startDetached("ubuntu-kylin-software-center"); + +#endif + }); +} + NewFileLaunchDialog::NewFileLaunchDialog(const QString &uri, QWidget *parent) : QDialog(parent) { m_launchHashList = new LaunchHashList(uri, this); diff --git a/libpeony-qt/controls/property-page/open-with-properties-page.h b/libpeony-qt/controls/property-page/open-with-properties-page.h index ec6abe49..d2462b8a 100644 --- a/libpeony-qt/controls/property-page/open-with-properties-page.h +++ b/libpeony-qt/controls/property-page/open-with-properties-page.h @@ -169,6 +169,10 @@ public: void init(); void saveAllChange() override; +public Q_SLOTS: + void chooseOtherApp(); + void openAppCenter(); + private: QVBoxLayout *m_layout = nullptr;