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;