From a2a8c9b492ccd08a313afb03eb5940887b86e57d Mon Sep 17 00:00:00 2001 From: tsl115 Date: Wed, 22 Nov 2023 13:21:03 +0800 Subject: [PATCH 1/6] feat: DTK changed-template and DTK changed-symbol Replacing Qt controls with DTK --- src/plugins/symbol/mainframe/symbolkeeper.cpp | 2 +- .../symbol/mainframe/symboltreeview.cpp | 39 +++++++++++-------- src/plugins/symbol/mainframe/symboltreeview.h | 9 +++-- src/plugins/symbol/symbol.cpp | 2 +- .../symbol/transceiver/symbolreceiver.h | 2 +- src/plugins/template/wizard/detailwidget.cpp | 5 ++- src/plugins/template/wizard/detailwidget.h | 5 ++- src/plugins/template/wizard/maindialog.cpp | 2 +- src/plugins/template/wizard/maindialog.h | 4 +- 9 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/plugins/symbol/mainframe/symbolkeeper.cpp b/src/plugins/symbol/mainframe/symbolkeeper.cpp index 716d12f65..3cb091676 100644 --- a/src/plugins/symbol/mainframe/symbolkeeper.cpp +++ b/src/plugins/symbol/mainframe/symbolkeeper.cpp @@ -7,7 +7,7 @@ #include "common/common.h" #include "services/builder/builderservice.h" -#include +#include namespace { static SymbolTreeView *tree{nullptr}; diff --git a/src/plugins/symbol/mainframe/symboltreeview.cpp b/src/plugins/symbol/mainframe/symboltreeview.cpp index b6cdf360e..ce1084ae4 100644 --- a/src/plugins/symbol/mainframe/symboltreeview.cpp +++ b/src/plugins/symbol/mainframe/symboltreeview.cpp @@ -10,40 +10,45 @@ #include "symboldelegate.h" +#include +#include +#include + #include #include #include +DWIDGET_USE_NAMESPACE class SymbolTreeViewPrivate { friend class SymbolTreeView; SymbolTreeView *const q; QModelIndex selIndex; QFileSystemModel *model {nullptr}; - SymbolDelegate *delegate; - QMenu *getFileLineMenu(const QString &filePath); + SymbolDelegate *delegate = {nullptr}; + DMenu *getFileLineMenu(const QString &filePath); SymbolTreeViewPrivate(SymbolTreeView *qq): q(qq){} }; -SymbolTreeView::SymbolTreeView(QWidget *parent) - : QTreeView(parent) +SymbolTreeView::SymbolTreeView(DWidget *parent) + : DTreeView(parent) , d (new SymbolTreeViewPrivate(this)) { d->model = new SymbolModel(); d->delegate = new SymbolDelegate; - QTreeView::setModel(d->model); - QTreeView::setItemDelegate(d->delegate); + DTreeView::setModel(d->model); + DTreeView::setItemDelegate(d->delegate); setContextMenuPolicy(Qt::CustomContextMenu); - setEditTriggers(QTreeView::NoEditTriggers); //节点不能编辑 - setSelectionBehavior(QTreeView::SelectRows); //一次选中整行 - setSelectionMode(QTreeView::SingleSelection); //单选,配合上面的整行就是一次选单行 + setEditTriggers(DTreeView::NoEditTriggers); //节点不能编辑 + setSelectionBehavior(DTreeView::SelectRows); //一次选中整行 + setSelectionMode(DTreeView::SingleSelection); //单选,配合上面的整行就是一次选单行 setFocusPolicy(Qt::NoFocus); //去掉鼠标移到节点上时的虚线框 header()->setVisible(false); - QObject::connect(this, &QTreeView::doubleClicked, + QObject::connect(this, &DTreeView::doubleClicked, this, &SymbolTreeView::doDoubleClieked, Qt::UniqueConnection); - QObject::connect(this, &QTreeView::customContextMenuRequested, + QObject::connect(this, &DTreeView::customContextMenuRequested, this, &SymbolTreeView::doContextMenu, Qt::UniqueConnection); } @@ -74,7 +79,7 @@ void SymbolTreeView::doContextMenu(const QPoint &point) setCurrentIndex(index); - QMenu *contextMenu{nullptr}; + DMenu *contextMenu{nullptr}; if (d->model->isDir(index)) { QString filePath = d->model->filePath(index); QDir currDir(filePath); @@ -85,7 +90,7 @@ void SymbolTreeView::doContextMenu(const QPoint &point) if (files.contains(SymbolPri::definitionsFileName) || files.contains(SymbolPri::declaredFileName)) { - contextMenu = new QMenu(this); + contextMenu = new DMenu(this); } if (files.contains(SymbolPri::definitionsFileName)) { @@ -108,23 +113,23 @@ void SymbolTreeView::doContextMenu(const QPoint &point) } if (contextMenu) { - contextMenu->exec(QWidget::mapToGlobal(point)); + contextMenu->exec(DWidget::mapToGlobal(point)); delete contextMenu; } } -QMenu *SymbolTreeViewPrivate::getFileLineMenu(const QString &filePath) +DMenu *SymbolTreeViewPrivate::getFileLineMenu(const QString &filePath) { QFile file(filePath); if (!file.open(QFile::ReadOnly)) { qCritical() << file.errorString(); } - QMenu *defMenu = nullptr; + DMenu *defMenu = nullptr; QStringList lines = QString(file.readAll()).split('\n'); for (auto line : lines) { if (!line.isEmpty()) { if (!defMenu) { - defMenu = new QMenu(); + defMenu = new DMenu(); } QAction *action = new QAction(defMenu); QObject::connect(action, &QAction::triggered, [=](){ diff --git a/src/plugins/symbol/mainframe/symboltreeview.h b/src/plugins/symbol/mainframe/symboltreeview.h index 4a186f691..e7df64981 100644 --- a/src/plugins/symbol/mainframe/symboltreeview.h +++ b/src/plugins/symbol/mainframe/symboltreeview.h @@ -7,16 +7,17 @@ #include "services/project/projectservice.h" -#include +#include -class QStandardItem; +DWIDGET_USE_NAMESPACE +class DStandardItem; class SymbolTreeViewPrivate; -class SymbolTreeView : public QTreeView +class SymbolTreeView : public DTreeView { Q_OBJECT SymbolTreeViewPrivate *const d; public: - explicit SymbolTreeView(QWidget *parent = nullptr); + explicit SymbolTreeView(DWidget *parent = nullptr); virtual ~SymbolTreeView(); void setRootPath(const QString &filePath); diff --git a/src/plugins/symbol/symbol.cpp b/src/plugins/symbol/symbol.cpp index 69ab17c7c..a2282177d 100644 --- a/src/plugins/symbol/symbol.cpp +++ b/src/plugins/symbol/symbol.cpp @@ -12,11 +12,11 @@ #include "base/abstractwidget.h" #include "services/window/windowservice.h" #include "services/symbol/symbolservice.h" +#include #include #include #include -#include using namespace dpfservice; void Symbol::initialize() diff --git a/src/plugins/symbol/transceiver/symbolreceiver.h b/src/plugins/symbol/transceiver/symbolreceiver.h index 51d169447..53bb10102 100644 --- a/src/plugins/symbol/transceiver/symbolreceiver.h +++ b/src/plugins/symbol/transceiver/symbolreceiver.h @@ -9,7 +9,7 @@ #include -class QStandardItem; +class DStandardItem; class SymbolReceiver : public dpf::EventHandler, dpf::AutoEventHandlerRegister { diff --git a/src/plugins/template/wizard/detailwidget.cpp b/src/plugins/template/wizard/detailwidget.cpp index f0b4ad063..ef68d3df2 100644 --- a/src/plugins/template/wizard/detailwidget.cpp +++ b/src/plugins/template/wizard/detailwidget.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -29,14 +30,14 @@ class DetailWidgetPrivate WizardInfo wizardInfo; }; -DetailWidget::DetailWidget(QWidget *parent) +DetailWidget::DetailWidget(DWidget *parent) : DScrollArea(parent) , d(new DetailWidgetPrivate()) { } -DetailWidget::DetailWidget(const QString &templatePath, QWidget *parent) +DetailWidget::DetailWidget(const QString &templatePath, DWidget *parent) : DScrollArea(parent) , d(new DetailWidgetPrivate()) { diff --git a/src/plugins/template/wizard/detailwidget.h b/src/plugins/template/wizard/detailwidget.h index 22d75db89..5f6153998 100644 --- a/src/plugins/template/wizard/detailwidget.h +++ b/src/plugins/template/wizard/detailwidget.h @@ -9,6 +9,7 @@ #include +DWIDGET_USE_NAMESPACE using namespace templateMgr; class DetailWidgetPrivate; @@ -16,8 +17,8 @@ class DetailWidget : public DTK_WIDGET_NAMESPACE::DScrollArea { Q_OBJECT public: - explicit DetailWidget(QWidget *parent = nullptr); - DetailWidget(const QString &templatePath, QWidget *parent = nullptr); + explicit DetailWidget(DWidget *parent = nullptr); + DetailWidget(const QString &templatePath, DWidget *parent = nullptr); ~DetailWidget() override; bool getGenParams(PojectGenParam ¶m); diff --git a/src/plugins/template/wizard/maindialog.cpp b/src/plugins/template/wizard/maindialog.cpp index 3f76cc02b..39f84c4b4 100644 --- a/src/plugins/template/wizard/maindialog.cpp +++ b/src/plugins/template/wizard/maindialog.cpp @@ -33,7 +33,7 @@ class MainDialogPrivate DWidget *blankWidget = nullptr; }; -MainDialog::MainDialog(QWidget *parent) +MainDialog::MainDialog(DWidget *parent) : DAbstractDialog(parent) , d(new MainDialogPrivate()) { diff --git a/src/plugins/template/wizard/maindialog.h b/src/plugins/template/wizard/maindialog.h index 5123b41b8..30f5e845b 100644 --- a/src/plugins/template/wizard/maindialog.h +++ b/src/plugins/template/wizard/maindialog.h @@ -7,7 +7,9 @@ #include "projectgenerate.h" #include +#include +DWIDGET_USE_NAMESPACE using namespace templateMgr; class MainDialogPrivate; @@ -15,7 +17,7 @@ class MainDialog : public DTK_WIDGET_NAMESPACE::DAbstractDialog { Q_OBJECT public: - explicit MainDialog(QWidget *parent = nullptr); + explicit MainDialog(DWidget *parent = nullptr); ~MainDialog(); signals: From 9ab220e640980793f0372d47f82c13b816d45a91 Mon Sep 17 00:00:00 2001 From: ZHANGTINGAN Date: Mon, 20 Nov 2023 17:45:58 +0800 Subject: [PATCH 2/6] feat: [Options] Appearance changes Modify the interface and replace the Dtk control according to the design drawings. --- .../codegeex/option/codegeexoptionwidget.cpp | 1 + .../cxx/cmake/option/cmakeoptionwidget.cpp | 1 + .../cxx/ninja/option/ninjaoptionwidget.cpp | 1 + .../java/gradle/option/gradleoptionwidget.cpp | 1 + .../java/java/option/javaoptionwidget.cpp | 2 +- .../java/maven/option/mavenoptionwidget.cpp | 1 + src/plugins/option/optioncore/CMakeLists.txt | 10 +- .../mainframe/environmentwidget.cpp | 21 +-- .../optioncore/mainframe/environmentwidget.h | 2 +- .../mainframe/generaloptionwidget.cpp | 53 ------ .../mainframe/generaloptionwidget.h | 28 ---- .../mainframe/optionenvironmentgenerator.cpp | 15 ++ .../mainframe/optionenvironmentgenerator.h | 19 +++ .../mainframe/optiongeneralgenerator.cpp | 16 -- .../mainframe/optiongeneralgenerator.h | 19 --- .../optionprofilesettinggenerator.cpp | 15 ++ .../mainframe/optionprofilesettinggenerator.h | 19 +++ .../optioncore/mainframe/optionsdialog.cpp | 153 +++++++++--------- .../optioncore/mainframe/optionsdialog.h | 31 ++-- .../optionshortcutsettinggenerator.cpp | 15 ++ .../optionshortcutsettinggenerator.h | 19 +++ .../mainframe/profilesettingwidget.cpp | 21 +-- .../mainframe/shortcutsettingwidget.cpp | 42 ++--- .../mainframe/shortcutsettingwidget.h | 2 +- src/plugins/option/optioncore/optioncore.cpp | 26 ++- .../python/option/pythonoptionwidget.cpp | 1 + 26 files changed, 279 insertions(+), 255 deletions(-) delete mode 100644 src/plugins/option/optioncore/mainframe/generaloptionwidget.cpp delete mode 100644 src/plugins/option/optioncore/mainframe/generaloptionwidget.h create mode 100644 src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.cpp create mode 100644 src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.h delete mode 100644 src/plugins/option/optioncore/mainframe/optiongeneralgenerator.cpp delete mode 100644 src/plugins/option/optioncore/mainframe/optiongeneralgenerator.h create mode 100644 src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.cpp create mode 100644 src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.h create mode 100644 src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.cpp create mode 100644 src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.h diff --git a/src/plugins/codegeex/option/codegeexoptionwidget.cpp b/src/plugins/codegeex/option/codegeexoptionwidget.cpp index e447bab7b..38b97f25b 100644 --- a/src/plugins/codegeex/option/codegeexoptionwidget.cpp +++ b/src/plugins/codegeex/option/codegeexoptionwidget.cpp @@ -29,6 +29,7 @@ CodeGeeXOptionWidget::CodeGeeXOptionWidget(QWidget *parent) { QHBoxLayout *layout = new QHBoxLayout(); d->tabWidget = new DTabWidget(); + d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); d->tabWidget->addTab(new DetailWidget(), tr("CodeGeeX")); diff --git a/src/plugins/cxx/cmake/option/cmakeoptionwidget.cpp b/src/plugins/cxx/cmake/option/cmakeoptionwidget.cpp index 6326ec6f8..16c707058 100644 --- a/src/plugins/cxx/cmake/option/cmakeoptionwidget.cpp +++ b/src/plugins/cxx/cmake/option/cmakeoptionwidget.cpp @@ -24,6 +24,7 @@ CMakeOptionWidget::CMakeOptionWidget(QWidget *parent) { QHBoxLayout *layout = new QHBoxLayout(); d->tabWidget = new QTabWidget(); + d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); d->tabWidget->addTab(new KitsManagerWidget(), "Kits"); diff --git a/src/plugins/cxx/ninja/option/ninjaoptionwidget.cpp b/src/plugins/cxx/ninja/option/ninjaoptionwidget.cpp index a761c02da..3c64d8fd9 100644 --- a/src/plugins/cxx/ninja/option/ninjaoptionwidget.cpp +++ b/src/plugins/cxx/ninja/option/ninjaoptionwidget.cpp @@ -24,6 +24,7 @@ NinjaOptionWidget::NinjaOptionWidget(QWidget *parent) { QHBoxLayout *layout = new QHBoxLayout(); d->tabWidget = new QTabWidget(); + d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); d->tabWidget->addTab(new NinjaWidget(), tr("Ninja")); diff --git a/src/plugins/java/gradle/option/gradleoptionwidget.cpp b/src/plugins/java/gradle/option/gradleoptionwidget.cpp index 10ac10ea6..08851aaa9 100644 --- a/src/plugins/java/gradle/option/gradleoptionwidget.cpp +++ b/src/plugins/java/gradle/option/gradleoptionwidget.cpp @@ -24,6 +24,7 @@ GradleOptionWidget::GradleOptionWidget(QWidget *parent) { QHBoxLayout *layout = new QHBoxLayout(); d->tabWidget = new QTabWidget(); + d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); d->tabWidget->addTab(new GradleWidget(), tr("Gradle")); diff --git a/src/plugins/java/java/option/javaoptionwidget.cpp b/src/plugins/java/java/option/javaoptionwidget.cpp index 80d410a9b..2d599f6da 100644 --- a/src/plugins/java/java/option/javaoptionwidget.cpp +++ b/src/plugins/java/java/option/javaoptionwidget.cpp @@ -25,7 +25,7 @@ JavaOptionWidget::JavaOptionWidget(QWidget *parent) QHBoxLayout *layout = new QHBoxLayout(); d->tabWidget = new QTabWidget(); layout->addWidget(d->tabWidget); - + d->tabWidget->tabBar()->setAutoHide(true); d->tabWidget->addTab(new JDKWidget(), tr("JDK")); QObject::connect(d->tabWidget, &QTabWidget::currentChanged, [this]() { readConfig(); diff --git a/src/plugins/java/maven/option/mavenoptionwidget.cpp b/src/plugins/java/maven/option/mavenoptionwidget.cpp index d0cde9a43..edaa19cf1 100644 --- a/src/plugins/java/maven/option/mavenoptionwidget.cpp +++ b/src/plugins/java/maven/option/mavenoptionwidget.cpp @@ -24,6 +24,7 @@ MavenOptionWidget::MavenOptionWidget(QWidget *parent) { QHBoxLayout *layout = new QHBoxLayout(); d->tabWidget = new QTabWidget(); + d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); d->tabWidget->addTab(new MavenWidget(), tr("Maven")); diff --git a/src/plugins/option/optioncore/CMakeLists.txt b/src/plugins/option/optioncore/CMakeLists.txt index b5d08e517..1e3796eb7 100644 --- a/src/plugins/option/optioncore/CMakeLists.txt +++ b/src/plugins/option/optioncore/CMakeLists.txt @@ -6,26 +6,28 @@ find_package(Qt5 COMPONENTS Xml REQUIRED) set(CXX_CPP mainframe/environmentwidget.cpp - mainframe/optiongeneralgenerator.cpp mainframe/shortcutsettingwidget.cpp mainframe/persistentsettings.cpp mainframe/optionsdialog.cpp mainframe/optiondefaultkeeper.cpp - mainframe/generaloptionwidget.cpp mainframe/profilesettingwidget.cpp + mainframe/optionenvironmentgenerator.cpp + mainframe/optionprofilesettinggenerator.cpp + mainframe/optionshortcutsettinggenerator.cpp optioncore.cpp optioncore.json ) set(CXX_H mainframe/environmentwidget.h - mainframe/optiongeneralgenerator.h mainframe/shortcutsettingwidget.h mainframe/persistentsettings.h mainframe/optionsdialog.h mainframe/optiondefaultkeeper.h - mainframe/generaloptionwidget.h mainframe/profilesettingwidget.h + mainframe/optionenvironmentgenerator.h + mainframe/optionprofilesettinggenerator.h + mainframe/optionshortcutsettinggenerator.h optioncore.h ) diff --git a/src/plugins/option/optioncore/mainframe/environmentwidget.cpp b/src/plugins/option/optioncore/mainframe/environmentwidget.cpp index 1956b8076..162239f1a 100644 --- a/src/plugins/option/optioncore/mainframe/environmentwidget.cpp +++ b/src/plugins/option/optioncore/mainframe/environmentwidget.cpp @@ -4,11 +4,13 @@ #include "environmentwidget.h" +#include +#include + #include -#include #include -#include +DWIDGET_USE_NAMESPACE const QString ENABLE_ALL_ENV = EnvironmentWidget::tr("Enable All Environment"); @@ -17,8 +19,8 @@ class EnvironmentWidgetPrivate { friend class EnvironmentWidget; QVBoxLayout *vLayout = nullptr; - QTableView *tableView = nullptr; - QCheckBox *checkBox = nullptr; + DTableView *tableView = nullptr; + DCheckBox *checkBox = nullptr; EnvironmentModel *model = nullptr; }; @@ -90,7 +92,7 @@ class EnvironmentModel : public QAbstractTableModel QProcessEnvironment envs; }; -EnvironmentWidget::EnvironmentWidget(QWidget *parent) +EnvironmentWidget::EnvironmentWidget(DWidget *parent) : PageWidget(parent) , d(new EnvironmentWidgetPrivate) { @@ -101,11 +103,12 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent) this->setLayout(d->vLayout); if (!d->tableView) { - d->tableView = new QTableView(); - + d->tableView = new DTableView(); // Initialize view d->tableView->setShowGrid(false); - QHeaderView* headerView = d->tableView->horizontalHeader(); + d->tableView->setAlternatingRowColors(true); + d->tableView->setFixedSize(QSize(685, 428)); + DHeaderView *headerView = d->tableView->horizontalHeader(); headerView->setSectionResizeMode(QHeaderView::ResizeToContents); d->tableView->verticalHeader()->hide(); } @@ -116,7 +119,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent) d->tableView->setModel(d->model); if (!d->checkBox) - d->checkBox = new QCheckBox(); + d->checkBox = new DCheckBox(); d->checkBox->setText(ENABLE_ALL_ENV); d->checkBox->setChecked(true); d->vLayout->setSpacing(0); diff --git a/src/plugins/option/optioncore/mainframe/environmentwidget.h b/src/plugins/option/optioncore/mainframe/environmentwidget.h index d678e55a0..25be8005b 100644 --- a/src/plugins/option/optioncore/mainframe/environmentwidget.h +++ b/src/plugins/option/optioncore/mainframe/environmentwidget.h @@ -5,7 +5,7 @@ #ifndef ENVIRONMENTWIDGET_H #define ENVIRONMENTWIDGET_H -#include +#include #include class EnvironmentWidgetPrivate; diff --git a/src/plugins/option/optioncore/mainframe/generaloptionwidget.cpp b/src/plugins/option/optioncore/mainframe/generaloptionwidget.cpp deleted file mode 100644 index fb6e6e455..000000000 --- a/src/plugins/option/optioncore/mainframe/generaloptionwidget.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "generaloptionwidget.h" -#include "environmentwidget.h" -#include "shortcutsettingwidget.h" -#include "profilesettingwidget.h" - -#include -#include - -class GeneralOptionWidgetPrivate { - QTabWidget* tabWidget = nullptr; - - friend class GeneralOptionWidget; -}; - -GeneralOptionWidget::GeneralOptionWidget(QWidget *parent) - : PageWidget(parent) - , d(new GeneralOptionWidgetPrivate()) -{ - QHBoxLayout *layout = new QHBoxLayout(); - d->tabWidget = new QTabWidget(); - layout->addWidget(d->tabWidget); - - d->tabWidget->addTab(new EnvironmentWidget(), tr("Environment")); - d->tabWidget->addTab(new ShortcutSettingWidget(), tr("Commands")); - d->tabWidget->addTab(new ProfileSettingWidget(), tr("Interface")); - setLayout(layout); -} - -GeneralOptionWidget::~GeneralOptionWidget() -{ - if (d) - delete d; -} - -void GeneralOptionWidget::saveConfig() -{ - PageWidget *pageWidget = qobject_cast(d->tabWidget->currentWidget()); - if (pageWidget) { - pageWidget->saveConfig(); - } -} - -void GeneralOptionWidget::readConfig() -{ - PageWidget *pageWidget = qobject_cast(d->tabWidget->currentWidget()); - if (pageWidget) { - pageWidget->readConfig(); - } -} diff --git a/src/plugins/option/optioncore/mainframe/generaloptionwidget.h b/src/plugins/option/optioncore/mainframe/generaloptionwidget.h deleted file mode 100644 index 700a6f3fc..000000000 --- a/src/plugins/option/optioncore/mainframe/generaloptionwidget.h +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef GENERALOPTIONWIDGET_H -#define GENERALOPTIONWIDGET_H - -#include "common/common.h" - -class GeneralOptionWidgetPrivate; -class GeneralOptionWidget : public PageWidget -{ - Q_OBJECT -public: - explicit GeneralOptionWidget(QWidget *parent = nullptr); - ~GeneralOptionWidget() override; - - void saveConfig() override; - void readConfig() override; - -signals: - -public slots: -private: - GeneralOptionWidgetPrivate *const d; -}; - -#endif // GENERALOPTIONWIDGET_H diff --git a/src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.cpp b/src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.cpp new file mode 100644 index 000000000..2e4bba8e1 --- /dev/null +++ b/src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.cpp @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "optionenvironmentgenerator.h" +#include "environmentwidget.h" + +OptionEnvironmentGenerator::OptionEnvironmentGenerator() +{ +} + +QWidget *OptionEnvironmentGenerator::optionWidget() +{ + return new EnvironmentWidget(); +} diff --git a/src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.h b/src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.h new file mode 100644 index 000000000..eed35a609 --- /dev/null +++ b/src/plugins/option/optioncore/mainframe/optionenvironmentgenerator.h @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef OPTIONENVIRONMENTGENERATOR_H +#define OPTIONENVIRONMENTGENERATOR_H + +#include "services/option/optiongenerator.h" + +class OptionEnvironmentGenerator : public dpfservice::OptionGenerator +{ + Q_OBJECT +public: + OptionEnvironmentGenerator(); + inline static QString kitName() {return QObject::tr("Environment");} + virtual QWidget *optionWidget() override; +}; + +#endif // OPTIONENVIRONMENTGENERATOR_H diff --git a/src/plugins/option/optioncore/mainframe/optiongeneralgenerator.cpp b/src/plugins/option/optioncore/mainframe/optiongeneralgenerator.cpp deleted file mode 100644 index 959dcd0d9..000000000 --- a/src/plugins/option/optioncore/mainframe/optiongeneralgenerator.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "optiongeneralgenerator.h" -#include "generaloptionwidget.h" - -OptionGeneralGenerator::OptionGeneralGenerator() -{ - -} - -QWidget *OptionGeneralGenerator::optionWidget() -{ - return new GeneralOptionWidget(); -} diff --git a/src/plugins/option/optioncore/mainframe/optiongeneralgenerator.h b/src/plugins/option/optioncore/mainframe/optiongeneralgenerator.h deleted file mode 100644 index 64019a5de..000000000 --- a/src/plugins/option/optioncore/mainframe/optiongeneralgenerator.h +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef OPTIONGENERALGENERATOR_H -#define OPTIONGENERALGENERATOR_H - -#include "services/option/optiongenerator.h" - -class OptionGeneralGenerator : public dpfservice::OptionGenerator -{ - Q_OBJECT -public: - OptionGeneralGenerator(); - inline static QString kitName() {return QObject::tr("General");} - virtual QWidget *optionWidget() override; -}; - -#endif // OPTIONGENERALGENERATOR_H diff --git a/src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.cpp b/src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.cpp new file mode 100644 index 000000000..8f84d0d3c --- /dev/null +++ b/src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.cpp @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "optionprofilesettinggenerator.h" +#include "profilesettingwidget.h" + +OptionProfilesettingGenerator::OptionProfilesettingGenerator() +{ +} + +QWidget *OptionProfilesettingGenerator::optionWidget() +{ + return new ProfileSettingWidget(); +} diff --git a/src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.h b/src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.h new file mode 100644 index 000000000..5e195aa71 --- /dev/null +++ b/src/plugins/option/optioncore/mainframe/optionprofilesettinggenerator.h @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef OPTIONPROFILESETTINGGENERATOR_H +#define OPTIONPROFILESETTINGGENERATOR_H + +#include "services/option/optiongenerator.h" + +class OptionProfilesettingGenerator : public dpfservice::OptionGenerator +{ + Q_OBJECT +public: + OptionProfilesettingGenerator(); + inline static QString kitName() {return QObject::tr("Interface");} + virtual QWidget *optionWidget() override; +}; + +#endif // OPTIONPROFILESETTINGGENERATOR_H diff --git a/src/plugins/option/optioncore/mainframe/optionsdialog.cpp b/src/plugins/option/optioncore/mainframe/optionsdialog.cpp index 2b551e044..d086044d1 100644 --- a/src/plugins/option/optioncore/mainframe/optionsdialog.cpp +++ b/src/plugins/option/optioncore/mainframe/optionsdialog.cpp @@ -6,73 +6,77 @@ #include "common/widget/pagewidget.h" #include "services/option/optionservice.h" +#include +#include + #include #include -#include -#include -#include -#include -#include #include #include -#include -#include +#include #include +static const int labelHeight = 30; using namespace dpfservice; OptionsDialog::OptionsDialog(QWidget *parent) - : QDialog(parent) + : DAbstractDialog(parent) { setupUi(this); } bool OptionsDialog::insertOptionPanel(const QString &itemName, PageWidget *panel) { - widgts.insert(itemName, panel); + widgets.insert(itemName, panel); leftBarModel->setStringList(leftBarModel->stringList() << itemName); - int index = stackWidget->count(); - stackWidget->insertWidget(index, panel); + + DLabel *headTitle = new DLabel(this); + headTitle->setFixedHeight(labelHeight); + headTitle->setText(itemName); + + content->addWidget(headTitle); + panel->setContentsMargins(0, 0, 0, 30); + content->addWidget(panel); return true; } void OptionsDialog::slotLeftBarClicked(const QModelIndex &index) { - qInfo() << "The selected item is :" << index.data().toString(); QString itemName = index.data().toString(); - auto widget = widgts.value(itemName); - stackWidget->setCurrentWidget(widget); - // Update head title. - headTitle->setText(itemName); - widget->readConfig(); + auto y = widgets[itemName]->y() - labelHeight; + scrollArea->verticalScrollBar()->setValue(y); } -void OptionsDialog::setupUi(QDialog *Dialog) +void OptionsDialog::setupUi(QWidget *widget) { - Dialog->resize(1000, 650); - setWindowTitle(tr("Global Options")); + DFrame *mainFrame = new DFrame(widget); + mainFrame->resize(910, 640); + //titlebar + DTitlebar *titlebar = new DTitlebar(mainFrame); + titlebar->setMenuVisible(false); + titlebar->setTitle(tr("Global Options")); + + QVBoxLayout *title = new QVBoxLayout(mainFrame); + title->setContentsMargins(0, 0, 0, 0); + title->setSpacing(0); // Center layout. - auto mainLayout = new QHBoxLayout(Dialog); + auto mainLayout = new QHBoxLayout(mainFrame); mainLayout->setSpacing(6); mainLayout->setContentsMargins(11, 11, 11, 11); // Left layout. - auto leftLayout = new QVBoxLayout(Dialog); + auto leftLayout = new QVBoxLayout(mainFrame); leftLayout->setSpacing(6); - filterEdit = new QLineEdit(Dialog); - filterEdit->setPlaceholderText(tr("Filter")); - leftLayout->addWidget(filterEdit); - QObject::connect(filterEdit, &QLineEdit::textChanged, this, &OptionsDialog::findOption); - - leftSideBar = new QListView(Dialog); + leftSideBar = new DListView(mainFrame); leftSideBar->setEditTriggers(QAbstractItemView::NoEditTriggers); + leftSideBar->setBackgroundRole(QPalette::ColorRole::Light); leftBarModel = new QStringListModel(leftSideBar); leftSideBar->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); - QObject::connect(leftSideBar, &QListView::clicked, this, [=](const QModelIndex &index){ + QObject::connect(leftSideBar, &DListView::clicked, this, [=](const QModelIndex &index){ activeOptName = index.data(Qt::DisplayRole).toString(); }); leftSideBar->setModel(leftBarModel); @@ -82,31 +86,34 @@ void OptionsDialog::setupUi(QDialog *Dialog) leftLayout->addWidget(leftSideBar); // Right layout. - auto rightLayout = new QVBoxLayout(Dialog); + auto rightLayout = new QVBoxLayout(mainFrame); rightLayout->setSpacing(6); - headTitle = new QLabel(Dialog); - headTitle->setText(tr("Head Title")); - rightLayout->addWidget(headTitle); + //scollArea + scrollArea = new QScrollArea(mainFrame); + scrollWidget = new QWidget(mainFrame); + scrollArea->setWidgetResizable(true); + scrollArea->setWidget(scrollWidget); + content = new QVBoxLayout(scrollWidget); + rightLayout->addWidget(scrollArea); - stackWidget = new QStackedWidget(Dialog); - rightLayout->addWidget(stackWidget); + connect(scrollArea->verticalScrollBar(),&QScrollBar::valueChanged,this,&OptionsDialog::slotScrollChanged); - auto buttonLayout = new QHBoxLayout(Dialog); + auto buttonLayout = new QHBoxLayout(mainFrame); buttonLayout->setSpacing(6); auto horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); buttonLayout->addItem(horizontalSpacer); - auto okBtn = new QPushButton(tr("OK"), Dialog); + auto okBtn = new DPushButton(tr("OK"), mainFrame); connect(okBtn, SIGNAL(clicked()), this, SLOT(saveAllConfig())); - auto cancelBtn = new QPushButton(tr("Cancel"), Dialog); - connect(cancelBtn, &QPushButton::clicked, [this] { + auto cancelBtn = new DPushButton(tr("Cancel"), mainFrame); + connect(cancelBtn, &DPushButton::clicked, [this] { // TODO(Mozart) this->close(); }); - auto applyBtn = new QPushButton(tr("Apply"), Dialog); + auto applyBtn = new DPushButton(tr("Apply"), mainFrame); connect(applyBtn, SIGNAL(clicked()), this, SLOT(saveSingleConfig())); buttonLayout->addWidget(okBtn); @@ -121,13 +128,17 @@ void OptionsDialog::setupUi(QDialog *Dialog) mainLayout->setStretch(0, 1); mainLayout->setStretch(1, 4); + + title->addWidget(titlebar); + title->addLayout(mainLayout); } void OptionsDialog::saveAllConfig() { - for (int index = 0; index < stackWidget->count(); index++) + for (int index = 0; index < widgets.count(); index++) { - PageWidget* widget = dynamic_cast(stackWidget->widget(index)); + auto key = widgets.keys().at(index); + PageWidget* widget = widgets.value(key); if (widget) { widget->saveConfig(); } @@ -136,12 +147,15 @@ void OptionsDialog::saveAllConfig() accept(); } + +//TODO(zta): 之前是stackedWidget情况下,对单个页面修改后,点击apply进行单个页面的配置保存 +// 现在右侧变为scrollArea,需要判断是哪个页面进行了修改。 void OptionsDialog::saveSingleConfig() { - int index = stackWidget->currentIndex(); - if (index >= 0 && index < stackWidget->count()) + for (int index = 0; index < widgets.count(); index++) { - PageWidget* widget = dynamic_cast(stackWidget->widget(index)); + auto key = widgets.keys().at(index); + PageWidget* widget = widgets.value(key); if (widget) { widget->saveConfig(); } @@ -150,38 +164,19 @@ void OptionsDialog::saveSingleConfig() void OptionsDialog::readConfig() { - for (int index = 0; index < stackWidget->count(); index++) + for (int index = 0; index < widgets.count(); index++) { - PageWidget* widget = dynamic_cast(stackWidget->widget(index)); + auto key = widgets.keys().at(index); + PageWidget* widget = widgets.value(key); if (widget) { widget->readConfig(); } } } -void OptionsDialog::findOption(const QString &filter) -{ - auto &ctx = dpfInstance.serviceContext(); - OptionService *optionService = ctx.service(OptionService::name()); - - auto list = optionService->supportGeneratorName(); - int count = list.count(); - QStringList options = leftBarModel->stringList(); - for (int i = 0; i < count; i++) { - if (list[i].contains(filter, Qt::CaseInsensitive) && !leftBarModel->stringList().contains(list[i])) { - options.insert(i, list[i]); - leftBarModel->setStringList(options); - } else if (!list[i].contains(filter, Qt::CaseInsensitive)) { - options.removeOne(list[i]); - leftBarModel->setStringList(options); - } - } -} - void OptionsDialog::showEvent(QShowEvent *e) { QDialog::showEvent(e); - // Set leftbar item seleted. auto allOptName = leftBarModel->stringList(); if (activeOptName.isEmpty() && allOptName.size() > 0){ @@ -191,13 +186,25 @@ void OptionsDialog::showEvent(QShowEvent *e) int index = allOptName.indexOf(activeOptName); if (index >= 0) { leftSideBar->selectionModel()->select(leftBarModel->index(index), QItemSelectionModel::Select); - - // Update right panel. - auto widget = widgts.value(activeOptName); - stackWidget->setCurrentWidget(widget); - - headTitle->setText(activeOptName); } readConfig(); } + +void OptionsDialog::slotScrollChanged(int value) +{ + if (value == scrollArea->verticalScrollBar()->maximum()) + return; + + leftSideBar->clearSelection(); + + for (auto row = 0; row < leftBarModel->rowCount() - 1; row++) { + auto index = leftBarModel->index(row); + auto widget = widgets.value(index.data().toString()); + if (widget && (value <= widget->y() - labelHeight)) { + leftSideBar->selectionModel()->select(index, QItemSelectionModel::Select); + activeOptName = index.data(Qt::DisplayRole).toString(); + break; + } + } +} diff --git a/src/plugins/option/optioncore/mainframe/optionsdialog.h b/src/plugins/option/optioncore/mainframe/optionsdialog.h index 47405e681..ca0fe508a 100644 --- a/src/plugins/option/optioncore/mainframe/optionsdialog.h +++ b/src/plugins/option/optioncore/mainframe/optionsdialog.h @@ -5,20 +5,25 @@ #ifndef OPTIONSDIALOG_H #define OPTIONSDIALOG_H -#include +#include +#include +#include +#include +#include +#include +#include +#include #include +DWIDGET_USE_NAMESPACE + class QHBoxLayout; class QVBoxLayout; -class QLineEdit; -class QListView; -class QLabel; class QSpacerItem; class QStringListModel; -class QStackedWidget; class PageWidget; -class OptionsDialog : public QDialog +class OptionsDialog : public DAbstractDialog { Q_OBJECT public: @@ -29,21 +34,21 @@ public slots: void slotLeftBarClicked(const QModelIndex &index); void saveSingleConfig(); void saveAllConfig(); + void slotScrollChanged(int value); private: - void setupUi(QDialog *Dialog); + void setupUi(QWidget *widget); void readConfig(); - void findOption(const QString &filter); protected: virtual void showEvent(QShowEvent *e) override; - QLineEdit *filterEdit = nullptr; - QListView *leftSideBar = nullptr; - QLabel *headTitle = nullptr; + DListView *leftSideBar = nullptr; QString activeOptName {}; - QMap widgts{}; + QMap widgets{}; QStringListModel *leftBarModel = nullptr; - QStackedWidget *stackWidget = nullptr; + QScrollArea *scrollArea = nullptr; + QWidget *scrollWidget = nullptr; + QVBoxLayout *content = nullptr; }; #endif // OPTIONSDIALOG_H diff --git a/src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.cpp b/src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.cpp new file mode 100644 index 000000000..6787aa359 --- /dev/null +++ b/src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.cpp @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "optionshortcutsettinggenerator.h" +#include "shortcutsettingwidget.h" + +OptionShortcutsettingGenerator::OptionShortcutsettingGenerator() +{ +} + +QWidget *OptionShortcutsettingGenerator::optionWidget() +{ + return new ShortcutSettingWidget(); +} diff --git a/src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.h b/src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.h new file mode 100644 index 000000000..7a5609258 --- /dev/null +++ b/src/plugins/option/optioncore/mainframe/optionshortcutsettinggenerator.h @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef OPTIONSHORTCUTSETTINGGENERATOR_H +#define OPTIONSHORTCUTSETTINGGENERATOR_H + +#include "services/option/optiongenerator.h" + +class OptionShortcutsettingGenerator : public dpfservice::OptionGenerator +{ + Q_OBJECT +public: + OptionShortcutsettingGenerator(); + inline static QString kitName() {return QObject::tr("Commands");} + virtual QWidget *optionWidget() override; +}; + +#endif // OPTIONSHORTCUTSETTINGGENERATOR_H diff --git a/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp b/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp index 0f0d5a2cd..33920e438 100644 --- a/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp +++ b/src/plugins/option/optioncore/mainframe/profilesettingwidget.cpp @@ -5,18 +5,21 @@ #include "profilesettingwidget.h" #include "common/common.h" +#include +#include +#include + #include -#include -#include -#include + +DWIDGET_USE_NAMESPACE class ProfileSettingWidgetPrivate { friend class ProfileSettingWidget; QVBoxLayout *vLayout = nullptr; QHBoxLayout *hlayout = nullptr; - QLabel *languageEdit = nullptr; - QComboBox *cbChooseLanguage = nullptr; + DLabel *languageEdit = nullptr; + DComboBox *cbChooseLanguage = nullptr; LanguagePaths languagePaths; }; @@ -71,8 +74,8 @@ void ProfileSettingWidget::saveConfig() file.write(chooseFileName.toUtf8()); file.close(); } - QMessageBox msgBox; - QPushButton *okButton = new QPushButton(tr("Ok")); + DMessageBox msgBox; + DPushButton *okButton = new DPushButton(tr("Ok")); msgBox.addButton(okButton, QMessageBox::ButtonRole::NoRole); msgBox.setWindowTitle(tr("Restart Required--deep-in unioncode")); msgBox.setText(tr("The language change will take effect after restart.")); @@ -107,11 +110,11 @@ void ProfileSettingWidget::setupUi() d->hlayout = new QHBoxLayout(); if (!d->languageEdit) { - d->languageEdit = new QLabel(tr("language:")); + d->languageEdit = new DLabel(tr("language:")); } if (!d->cbChooseLanguage) - d->cbChooseLanguage = new QComboBox(); + d->cbChooseLanguage = new DComboBox(); d->cbChooseLanguage->setFixedWidth(200); QStringList nameList = d->languagePaths.keys(); diff --git a/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.cpp b/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.cpp index 94233ee37..5e839094a 100644 --- a/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.cpp +++ b/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.cpp @@ -5,19 +5,20 @@ #include "shortcutsettingwidget.h" #include "common/common.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + #include #include -#include #define BTN_WIDTH (180) +DWIDGET_USE_NAMESPACE + class ShortcutTableModelPrivate { QMap shortcutItemMap; @@ -227,11 +228,11 @@ class ShortcutTableModel; class ShortcutSettingWidgetPrivate { ShortcutSettingWidgetPrivate(); - QTableView *tableView; + DTableView *tableView; HotkeyLineEdit *editShortCut; ShortcutTableModel *model; - QPushButton *btnRecord; - QLabel *tipLabel; + DPushButton *btnRecord; + DLabel *tipLabel; friend class ShortcutSettingWidget; }; @@ -270,21 +271,22 @@ void ShortcutSettingWidget::setupUi() d->tableView->verticalHeader()->hide(); d->tableView->setSelectionMode(QAbstractItemView::SingleSelection); d->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); + d->tableView->setFixedSize(QSize(685,428)); d->model = new ShortcutTableModel(); d->tableView->setModel(d->model); vLayout->addWidget(d->tableView); - QWidget *widgetOperate = new QWidget(); + DWidget *widgetOperate = new DWidget(); vLayout->addWidget(widgetOperate); QHBoxLayout *hLayoutOperate = new QHBoxLayout(); widgetOperate->setLayout(hLayoutOperate); - QPushButton *btnResetAll = new QPushButton(); + DPushButton *btnResetAll = new DPushButton(); btnResetAll->setText(tr("Reset All")); btnResetAll->setFixedWidth(BTN_WIDTH); - QPushButton *btnImport = new QPushButton(); + DPushButton *btnImport = new DPushButton(); btnImport->setText(tr("Import")); btnImport->setFixedWidth(BTN_WIDTH); - QPushButton *btnExport = new QPushButton(); + DPushButton *btnExport = new DPushButton(); btnExport->setText(tr("Export")); btnExport->setFixedWidth(BTN_WIDTH); hLayoutOperate->addWidget(btnResetAll); @@ -292,22 +294,22 @@ void ShortcutSettingWidget::setupUi() hLayoutOperate->addWidget(btnImport); hLayoutOperate->addWidget(btnExport); - QWidget *widgetShortcut = new QWidget(); + DWidget *widgetShortcut = new DWidget(); vLayout->addWidget(widgetShortcut); QHBoxLayout *hLayoutShortcut = new QHBoxLayout(); widgetShortcut->setLayout(hLayoutShortcut); - QLabel *labelTip = new QLabel(tr("Shortcut:")); + DLabel *labelTip = new DLabel(tr("Shortcut:")); d->editShortCut = new HotkeyLineEdit(); - d->btnRecord = new QPushButton(tr("Record")); + d->btnRecord = new DPushButton(tr("Record")); d->btnRecord->setFixedWidth(BTN_WIDTH); - QPushButton *btnReset = new QPushButton(tr("Reset")); + DPushButton *btnReset = new DPushButton(tr("Reset")); btnReset->setFixedWidth(BTN_WIDTH); hLayoutShortcut->addWidget(labelTip); hLayoutShortcut->addWidget(d->editShortCut); hLayoutShortcut->addWidget(d->btnRecord); hLayoutShortcut->addWidget(btnReset); - d->tipLabel = new QLabel(); + d->tipLabel = new DLabel(); d->tipLabel->setMargin(10); d->tipLabel->setStyleSheet("color:darkred;"); vLayout->addWidget(d->tipLabel); diff --git a/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.h b/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.h index bee04f6fc..48660b806 100644 --- a/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.h +++ b/src/plugins/option/optioncore/mainframe/shortcutsettingwidget.h @@ -5,7 +5,7 @@ #ifndef SHORTCUTSETTINGWIDGET_H #define SHORTCUTSETTINGWIDGET_H -#include +#include #include #include diff --git a/src/plugins/option/optioncore/optioncore.cpp b/src/plugins/option/optioncore/optioncore.cpp index 45c0bbe46..343414ee8 100644 --- a/src/plugins/option/optioncore/optioncore.cpp +++ b/src/plugins/option/optioncore/optioncore.cpp @@ -4,7 +4,9 @@ #include "optioncore.h" #include "mainframe/optiondefaultkeeper.h" -#include "mainframe/optiongeneralgenerator.h" +#include "mainframe/optionenvironmentgenerator.h" +#include "mainframe/optionprofilesettinggenerator.h" +#include "mainframe/optionshortcutsettinggenerator.h" #include "common/common.h" #include "base/abstractwidget.h" @@ -16,6 +18,8 @@ #include "framework/listener/listener.h" +static QStringList generalKits {}; + using namespace dpfservice; void OptionCore::initialize() { @@ -42,13 +46,19 @@ bool OptionCore::start() auto &ctx = dpfInstance.serviceContext(); WindowService *windowService = ctx.service(WindowService::name()); OptionService *optionService = ctx.service(OptionService::name()); + if (optionService) { - optionService->implGenerator(OptionGeneralGenerator::kitName()); - auto generator = optionService->createGenerator(OptionGeneralGenerator::kitName()); - if (generator) { - auto pageWidget = dynamic_cast(generator->optionWidget()); - if (pageWidget) { - optionDialog->insertOptionPanel(OptionGeneralGenerator::kitName(), pageWidget); + generalKits << OptionEnvironmentGenerator::kitName() << OptionShortcutsettingGenerator::kitName() << OptionProfilesettingGenerator::kitName(); + optionService->implGenerator(generalKits[0]); + optionService->implGenerator(generalKits[1]); + optionService->implGenerator(generalKits[2]); + + for (auto name : generalKits) { + auto generator = optionService->createGenerator(name); + if (generator) { + PageWidget *optionWidget = dynamic_cast(generator->optionWidget()); + if (optionWidget) + optionDialog->insertOptionPanel(name, optionWidget); } } } @@ -73,7 +83,7 @@ bool OptionCore::start() if (optionDialog) { auto list = optionService->supportGeneratorName(); for (auto name : list) { - if (0 == name.compare(OptionGeneralGenerator::kitName())) + if (generalKits.contains(name)) continue; auto generator = optionService->createGenerator(name); if (generator) { diff --git a/src/plugins/python/python/option/pythonoptionwidget.cpp b/src/plugins/python/python/option/pythonoptionwidget.cpp index 339a7513f..21f8a453d 100644 --- a/src/plugins/python/python/option/pythonoptionwidget.cpp +++ b/src/plugins/python/python/option/pythonoptionwidget.cpp @@ -24,6 +24,7 @@ PythonOptionWidget::PythonOptionWidget(QWidget *parent) { QHBoxLayout *layout = new QHBoxLayout(); d->tabWidget = new QTabWidget(); + d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); d->tabWidget->addTab(new InterpreterWidget(), "Interpreter"); From b77d95e11b346b528b5d34a4dec3df46e0bd8089 Mon Sep 17 00:00:00 2001 From: ZHANGTINGAN Date: Thu, 23 Nov 2023 09:33:19 +0800 Subject: [PATCH 3/6] feat: DTK-changed filebrowser plugin DTK-changed filebrowser plugin --- src/plugins/filebrowser/filebrowser.cpp | 23 +++++---- .../filebrowser/mainframe/treeview.cpp | 47 ++++++++++--------- src/plugins/filebrowser/mainframe/treeview.h | 10 ++-- 3 files changed, 44 insertions(+), 36 deletions(-) diff --git a/src/plugins/filebrowser/filebrowser.cpp b/src/plugins/filebrowser/filebrowser.cpp index b155ba290..525245d31 100644 --- a/src/plugins/filebrowser/filebrowser.cpp +++ b/src/plugins/filebrowser/filebrowser.cpp @@ -9,20 +9,23 @@ #include "base/abstractwidget.h" #include "services/window/windowservice.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + #include -#include + +DWIDGET_USE_NAMESPACE using namespace dpfservice; namespace { const int treeWidgtMinWidth = 70; const int treeWidgetMinHeight = 400; -const QString FileBrowser_TEXT = QWidget::tr("File Browser"); +const QString FileBrowser_TEXT = DWidget::tr("File Browser"); } void FileBrowser::initialize() @@ -47,7 +50,7 @@ dpf::Plugin::ShutdownFlag FileBrowser::stop() AbstractWidget *FileBrowser::createTreeWidget() { - QWidget *treeWidget = new QWidget(); + DWidget *treeWidget = new DWidget(); treeWidget->setMinimumSize({treeWidgtMinWidth, treeWidgetMinHeight}); QGridLayout* gridLayout = new QGridLayout(); @@ -57,9 +60,9 @@ AbstractWidget *FileBrowser::createTreeWidget() auto treeView = TreeViewKeeper::instance()->treeView(); treeView->setMinimumSize({treeWidgtMinWidth, treeWidgetMinHeight}); - auto folderLabel = new QLabel(); + auto folderLabel = new DLabel(); QObject::connect(treeView, &TreeView::rootPathChanged, - folderLabel, &QLabel::setText, + folderLabel, &DLabel::setText, Qt::UniqueConnection); gridLayout->addWidget(folderLabel); diff --git a/src/plugins/filebrowser/mainframe/treeview.cpp b/src/plugins/filebrowser/mainframe/treeview.cpp index 561c7ce2d..71cd707f8 100644 --- a/src/plugins/filebrowser/mainframe/treeview.cpp +++ b/src/plugins/filebrowser/mainframe/treeview.cpp @@ -6,40 +6,43 @@ #include "transceiver/sendevents.h" #include "common/common.h" +#include +#include -#include -#include #include #include #include #include +DWIDGET_USE_NAMESPACE + const QString NEW_DOCUMENT_NAME = "NewDocument.txt"; const QString NEW_FOLDER_NAME = "NewFolder"; -const QString DELETE_MESSAGE_TEXT {QTreeView::tr("The delete operation will be removed from" +const QString DELETE_MESSAGE_TEXT {DTreeView::tr("The delete operation will be removed from" "the disk and will not be recoverable " "after this operation.\nDelete anyway?")}; -const QString DELETE_WINDOW_TEXT {QTreeView::tr("Delete Warning")}; +const QString DELETE_WINDOW_TEXT {DTreeView::tr("Delete Warning")}; class TreeViewPrivate { friend class TreeView; QFileSystemModel *model {nullptr}; - QMenu* menu {nullptr}; + DMenu* menu {nullptr}; QStack moveToTrashStack; dpfservice::ProjectInfo proInfo; }; TreeView::TreeView(QWidget *parent) - : QTreeView (parent) + : DTreeView (parent) , d (new TreeViewPrivate) { d->model = new QFileSystemModel(this); - d->menu = new QMenu(this); + d->menu = new DMenu(this); setModel(d->model); - header()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); - QObject::connect(this, &QTreeView::doubleClicked, this, &TreeView::doDoubleClicked); + header()->setSectionResizeMode(DHeaderView::ResizeMode::ResizeToContents); + setAlternatingRowColors(true); + QObject::connect(this, &DTreeView::doubleClicked, this, &TreeView::doDoubleClicked); } TreeView::~TreeView() @@ -54,8 +57,8 @@ void TreeView::setProjectInfo(const dpfservice::ProjectInfo &proInfo) d->proInfo = proInfo; d->model->setRootPath(proInfo.workspaceFolder()); auto index = d->model->index(proInfo.workspaceFolder()); - QTreeView::expand(index); - QTreeView::setRootIndex(index); + DTreeView::expand(index); + DTreeView::setRootIndex(index); emit rootPathChanged(proInfo.workspaceFolder()); } @@ -99,7 +102,7 @@ void TreeView::selMoveToTrash() } else { QString errMess; for (auto errFilePath : errFilePaths) { - errMess = QTreeView::tr("Error, Can't move to trash: ") + "\n" + errMess = DTreeView::tr("Error, Can't move to trash: ") + "\n" + errFilePath + "\n"; } ContextDialog::ok(errMess); @@ -147,7 +150,7 @@ void TreeView::selRemove() if (hasError) { QString errMess; for (auto errFilePath : errFilePaths) { - errMess = QTreeView::tr("Error, Can't move to trash: ") + "\n" + errMess = DTreeView::tr("Error, Can't move to trash: ") + "\n" + errFilePath + "\n"; } ContextDialog::ok(errMess); @@ -165,10 +168,10 @@ void TreeView::selNewDocument() if (info.isDir()) { hasErr = !FileOperation::doNewDocument(filePath, NEW_DOCUMENT_NAME); if (hasErr) - errString = QTreeView::tr("Error: Can't create New Document"); + errString = DTreeView::tr("Error: Can't create New Document"); } else { hasErr = true; - errString = QTreeView::tr("Error: Create New Document, parent not's dir"); + errString = DTreeView::tr("Error: Create New Document, parent not's dir"); } } @@ -187,10 +190,10 @@ void TreeView::selNewFolder() if (info.isDir()) { hasErr = !FileOperation::doNewFolder(filePath, NEW_FOLDER_NAME); if (hasErr) - errString = QTreeView::tr("Error: Can't create new folder"); + errString = DTreeView::tr("Error: Can't create new folder"); } else { hasErr = true; - errString = QTreeView::tr("Error: Create new folder, parent not's dir"); + errString = DTreeView::tr("Error: Create new folder, parent not's dir"); } } @@ -217,7 +220,7 @@ void TreeView::doDoubleClicked(const QModelIndex &index) void TreeView::contextMenuEvent(QContextMenuEvent *event) { - QModelIndex index = QTreeView::indexAt(event->pos()); + QModelIndex index = DTreeView::indexAt(event->pos()); if (index.isValid()) { d->menu = createContextMenu(selectedIndexes()); } else { @@ -226,9 +229,9 @@ void TreeView::contextMenuEvent(QContextMenuEvent *event) d->menu->exec(viewport()->mapToGlobal(event->pos())); } -QMenu *TreeView::createContextMenu(const QModelIndexList &indexs) +DMenu *TreeView::createContextMenu(const QModelIndexList &indexs) { - QMenu *menu = new QMenu(); + DMenu *menu = new DMenu(); bool hasDir = false; bool selOne = indexs.size() == 0; for (auto index: indexs) { @@ -265,9 +268,9 @@ QMenu *TreeView::createContextMenu(const QModelIndexList &indexs) return menu; } -QMenu *TreeView::createEmptyMenu() +DMenu *TreeView::createEmptyMenu() { - QMenu *menu = new QMenu(); + DMenu *menu = new DMenu(); QAction *recoverFromTrashAction = new QAction(QAction::tr("Recover From Trash")); QObject::connect(recoverFromTrashAction, &QAction::triggered, this, &TreeView::recoverFromTrash); diff --git a/src/plugins/filebrowser/mainframe/treeview.h b/src/plugins/filebrowser/mainframe/treeview.h index 1559a6c16..de042c159 100644 --- a/src/plugins/filebrowser/mainframe/treeview.h +++ b/src/plugins/filebrowser/mainframe/treeview.h @@ -5,11 +5,13 @@ #ifndef TREEVIEW_H #define TREEVIEW_H -#include #include "services/project/projectservice.h" +#include +#include + class TreeViewPrivate; -class TreeView : public QTreeView +class TreeView : public DTK_WIDGET_NAMESPACE::DTreeView { Q_OBJECT TreeViewPrivate *const d; @@ -29,8 +31,8 @@ public slots: void rootPathChanged(const QString &folder); protected: void contextMenuEvent(QContextMenuEvent *event); - virtual QMenu *createContextMenu(const QModelIndexList &indexs); - virtual QMenu *createEmptyMenu(); + virtual DTK_WIDGET_NAMESPACE::DMenu *createContextMenu(const QModelIndexList &indexs); + virtual DTK_WIDGET_NAMESPACE::DMenu *createEmptyMenu(); }; #endif // TREEVIEW_H From c1ed655a58a07adcbb15074ee4d1d0ee46ec4264 Mon Sep 17 00:00:00 2001 From: HeXiaodong Date: Thu, 23 Nov 2023 11:32:43 +0800 Subject: [PATCH 4/6] feat: DTK Changed-Project and doc list in recent plugin DTK Changed-Project and doc list in recent plugin --- .../mainframe/naveditmainwindow.cpp | 1 + src/plugins/core/mainframe/windowkeeper.cpp | 1 + .../debugger/interface/menumanager.cpp | 2 - .../recent/mainframe/displayitemdelegate.cpp | 191 ++++++++++++++---- .../recent/mainframe/displayitemdelegate.h | 21 ++ .../recent/mainframe/displayrecentview.cpp | 59 ++++-- .../recent/mainframe/displayrecentview.h | 13 +- .../recent/mainframe/recentdisplay.cpp | 3 +- 8 files changed, 227 insertions(+), 64 deletions(-) diff --git a/src/plugins/codeeditor/mainframe/naveditmainwindow.cpp b/src/plugins/codeeditor/mainframe/naveditmainwindow.cpp index 713ddb0f3..b781347a8 100644 --- a/src/plugins/codeeditor/mainframe/naveditmainwindow.cpp +++ b/src/plugins/codeeditor/mainframe/naveditmainwindow.cpp @@ -309,6 +309,7 @@ void NavEditMainWindow::setToolBarButton(QAction *action) if (!action) return; DIconButton *iconBtn = new DIconButton(); + iconBtn->setToolTip(action->text()); iconBtn->setIcon(action->icon()); iconBtn->setMinimumSize(QSize(36, 36)); iconBtn->setIconSize(QSize(20, 20)); diff --git a/src/plugins/core/mainframe/windowkeeper.cpp b/src/plugins/core/mainframe/windowkeeper.cpp index 8be75295e..93981abc5 100644 --- a/src/plugins/core/mainframe/windowkeeper.cpp +++ b/src/plugins/core/mainframe/windowkeeper.cpp @@ -152,6 +152,7 @@ void WindowKeeper::createNavIconBtn(const QString &navName, const QString &iconN DToolButton *toolBtn = new DToolButton; toolBtn->setCheckable(true); toolBtn->setChecked(true); + toolBtn->setToolTip(navName); toolBtn->setIcon(QIcon::fromTheme(iconName)); diff --git a/src/plugins/debugger/interface/menumanager.cpp b/src/plugins/debugger/interface/menumanager.cpp index 4a5ad1d27..db58cf5c8 100644 --- a/src/plugins/debugger/interface/menumanager.cpp +++ b/src/plugins/debugger/interface/menumanager.cpp @@ -30,7 +30,6 @@ void MenuManager::initialize(WindowService *windowService) AbstractAction *actionImpl = new AbstractAction(startDebugging.get()); windowService->addAction(MWM_DEBUG, actionImpl); windowService->addToolBarActionItem("Start Debugging", startDebugging.get(), "Debug"); - windowService->addToolBarActionItem("Debugger.Start", startDebugging.get(), "Debug"); #if 0 // not used yet. detachDebugger.reset(new QAction("Detach Debugger")); @@ -68,7 +67,6 @@ void MenuManager::initialize(WindowService *windowService) actionImpl = new AbstractAction(abortDebugging.get()); windowService->addAction(MWM_DEBUG, actionImpl); windowService->addToolBarActionItem("abort_debug", abortDebugging.get(), "Debug"); - windowService->addToolBarActionItem("Debugger.Stop", abortDebugging.get(), "Debug"); restartDebugging.reset(new QAction(MWMDA_RESTART_DEBUGGING)); ActionManager::getInstance()->registerAction(restartDebugging.get(), "Debug.Restart.Debugging", diff --git a/src/plugins/recent/mainframe/displayitemdelegate.cpp b/src/plugins/recent/mainframe/displayitemdelegate.cpp index 453cfe513..a45dd8b56 100644 --- a/src/plugins/recent/mainframe/displayitemdelegate.cpp +++ b/src/plugins/recent/mainframe/displayitemdelegate.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "displayitemdelegate.h" +#include "displayrecentview.h" #include #include @@ -10,11 +11,22 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include +#include + +inline constexpr int kRectRadius = { 8 }; +inline constexpr int kIconWidth = { 30 }; +inline constexpr int kIconHeight = { 30 }; +inline constexpr int kIconLeftMargin = { 10 }; +inline constexpr int kTextLeftMargin = { 8 }; DisplayItemDelegate::DisplayItemDelegate(QAbstractItemView *parent) : DStyledItemDelegate (parent) @@ -22,51 +34,26 @@ DisplayItemDelegate::DisplayItemDelegate(QAbstractItemView *parent) } -void DisplayItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, +void DisplayItemDelegate::paint(QPainter *painter, + const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (index.isValid()) { - painter->save(); - - int textTopAlign = Qt::AlignmentFlag::AlignTop; - int textBottomAlign = Qt::AlignmentFlag::AlignBottom; - QString filePath = index.data(Qt::DisplayRole).toString(); - QString fileName = QFileInfo(filePath).fileName(); - - QStyleOptionViewItem drawStyle(option); - DStyledItemDelegate::initStyleOption(&drawStyle, index); - painter->setRenderHint(QPainter::Antialiasing); - - drawStyle.text = ""; //清空文本绘制 - QStyle *pStyle = drawStyle.widget ? drawStyle.widget->style() : DApplication::style(); - pStyle->drawControl(DStyle::CE_ItemViewItem, &drawStyle, painter, drawStyle.widget); - - QRect iconRect = pStyle->itemPixmapRect(drawStyle.rect, drawStyle.displayAlignment, - drawStyle.icon.pixmap(drawStyle.rect.height())); - QRect titleTextRect = pStyle->itemTextRect(drawStyle.fontMetrics, drawStyle.rect, textTopAlign, true, fileName) - .adjusted(iconRect.width(), 0, 0, 0); - titleTextRect.setWidth(option.rect.width()); - - QString eliedFileName = drawStyle.fontMetrics.elidedText(fileName, Qt::ElideRight, titleTextRect.width()); - pStyle->drawItemText(painter, titleTextRect, drawStyle.displayAlignment, drawStyle.palette, true, eliedFileName); - - //缩小字体 - QFont nativeFont(drawStyle.font); - nativeFont.setPointSize(drawStyle.font.pointSize() - 1); - nativeFont.setItalic(true); - painter->setFont(nativeFont); - - //计算绘制坐标 - QRect nativeTextRect = pStyle->itemTextRect(QFontMetrics(nativeFont), drawStyle.rect, textBottomAlign, true, filePath) - .adjusted(iconRect.width(), 0, 0, 0); - nativeTextRect.setWidth(option.rect.width()); - - QString eliedFilePath = drawStyle.fontMetrics.elidedText(filePath, Qt::ElideRight, nativeTextRect.width()); - painter->drawText(nativeTextRect, textBottomAlign, eliedFilePath); - painter->restore(); - } else { + if (!index.isValid()) return DStyledItemDelegate::paint(painter, option, index); - } + + painter->setRenderHints(painter->renderHints() + | QPainter::Antialiasing + | QPainter::TextAntialiasing + | QPainter::SmoothPixmapTransform); + + QStyleOptionViewItem opt = option; + initStyleOption(&opt, index); + + paintItemBackground(painter, opt, index); + QRectF iconRect = paintItemIcon(painter, opt, index); + paintItemColumn(painter, opt, index, iconRect); + + painter->setOpacity(1); } QSize DisplayItemDelegate::sizeHint(const QStyleOptionViewItem &option, @@ -77,8 +64,126 @@ QSize DisplayItemDelegate::sizeHint(const QStyleOptionViewItem &option, if (size.isValid()) { return size; } else { - return {option.rect.width(), option.fontMetrics.height() * 2}; + return {option.rect.width(), option.fontMetrics.height() * 2 + 5}; } } return DStyledItemDelegate::sizeHint(option, index); } + +void DisplayItemDelegate::paintItemBackground(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + painter->save(); + + if (option.widget) { + DPalette pl(DPaletteHelper::instance()->palette(option.widget)); + QColor baseColor = pl.color(DPalette::ColorGroup::Active, DPalette::ColorType::ItemBackground); + QColor adjustColor = baseColor; + + bool isSelected = (option.state & QStyle::State_Selected) && option.showDecorationSelected; + + if (isSelected) { + adjustColor = option.palette.color(DPalette::ColorGroup::Active, QPalette::Highlight); + } else if (option.state & QStyle::StateFlag::State_MouseOver) { + // hover color + adjustColor = DGuiApplicationHelper::adjustColor(baseColor, 0, 0, 0, 0, 0, 0, +10); + } else { + // alternately background color + painter->setOpacity(0); + if (index.row() % 2 == 0) { + adjustColor = DGuiApplicationHelper::adjustColor(baseColor, 0, 0, 0, 0, 0, 0, +5); + painter->setOpacity(1); + } + } + + // set paint path + QPainterPath path; + path.addRoundedRect(option.rect, kRectRadius, kRectRadius); + painter->fillPath(path, adjustColor); + } + + painter->restore(); +} + +QRectF DisplayItemDelegate::paintItemIcon(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + painter->save(); + + if (!parent() || !parent()->parent()) + return QRect(); + + bool isEnabled = option.state & QStyle::State_Enabled; + + // draw icon + QRectF iconRect = option.rect; + iconRect.setSize(QSize(kIconWidth, kIconHeight)); + iconRect.moveTopLeft(QPoint(kIconLeftMargin, qRound(iconRect.top() + (option.rect.bottom() - iconRect.bottom()) / 2))); + + // Copy of QStyle::alignedRect + Qt::Alignment alignment = Qt::AlignCenter; + alignment = visualAlignment(painter->layoutDirection(), alignment); + const qreal pixelRatio = painter->device()->devicePixelRatioF(); + const QPixmap &px = getIconPixmap(option.icon, iconRect.size().toSize(), pixelRatio, isEnabled ? QIcon::Normal : QIcon::Disabled, QIcon::Off); + qreal x = iconRect.x(); + qreal y = iconRect.y(); + qreal w = px.width() / px.devicePixelRatio(); + qreal h = px.height() / px.devicePixelRatio(); + if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter) + y += (iconRect.size().height() - h) / 2.0; + else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom) + y += iconRect.size().height() - h; + if ((alignment & Qt::AlignRight) == Qt::AlignRight) + x += iconRect.size().width() - w; + else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter) + x += (iconRect.size().width() - w) / 2.0; + + painter->drawPixmap(qRound(x), qRound(y), px); + painter->restore(); + + return iconRect; +} + +QPixmap DisplayItemDelegate::getIconPixmap(const QIcon &icon, const QSize &size, qreal pixelRatio = 1.0, QIcon::Mode mode, QIcon::State state) +{ + if (icon.isNull()) + return QPixmap(); + + // 确保当前参数参入获取图片大小大于0 + if (size.width() <= 0 || size.height() <= 0) + return QPixmap(); + + auto px = icon.pixmap(size, mode, state); + px.setDevicePixelRatio(qApp->devicePixelRatio()); + + return px; +} + +void DisplayItemDelegate::paintItemColumn(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index, const QRectF &iconRect) const +{ + painter->save(); + + bool isSelected = (option.state & QStyle::State_Selected) && option.showDecorationSelected; + if (isSelected) + painter->setPen(option.palette.color(DPalette::ColorGroup::Active, QPalette::HighlightedText)); + + QString filePath = index.data(Qt::DisplayRole).toString(); + QString fileName = QFileInfo(filePath).fileName(); + QFontMetrics fm(option.font); + + QString elidFilePath; + elidFilePath = fm.elidedText(filePath, Qt::ElideMiddle, + qRound(option.rect.width() - iconRect.width() - kIconLeftMargin * 2)); + + painter->drawText(option.rect.adjusted(kIconLeftMargin + kIconWidth + kTextLeftMargin, 5, 0, -5), + Qt::AlignLeft | Qt::AlignBottom, elidFilePath); + + QString elidFileName; + elidFileName = fm.elidedText(fileName, Qt::ElideMiddle, + qRound(option.rect.width() - iconRect.width() - kIconLeftMargin * 2)); + painter->drawText(option.rect.adjusted(kIconLeftMargin + kIconWidth + kTextLeftMargin, 5, 0, -5), + Qt::AlignLeft | Qt::AlignTop, elidFileName); + + painter->restore(); +} diff --git a/src/plugins/recent/mainframe/displayitemdelegate.h b/src/plugins/recent/mainframe/displayitemdelegate.h index 3e7ac9048..1bd9ae0af 100644 --- a/src/plugins/recent/mainframe/displayitemdelegate.h +++ b/src/plugins/recent/mainframe/displayitemdelegate.h @@ -12,6 +12,20 @@ DWIDGET_USE_NAMESPACE class DisplayItemDelegate : public DStyledItemDelegate { public: + static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment) + { + if (!(alignment & Qt::AlignHorizontal_Mask)) + alignment |= Qt::AlignLeft; + if (!(alignment & Qt::AlignAbsolute) && (alignment & (Qt::AlignLeft | Qt::AlignRight))) { + if (direction == Qt::RightToLeft) + alignment ^= (Qt::AlignLeft | Qt::AlignRight); + alignment |= Qt::AlignAbsolute; + } + return alignment; + } + static QPixmap getIconPixmap(const QIcon &icon, const QSize &size, qreal pixelRatio, + QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off); + explicit DisplayItemDelegate(QAbstractItemView *parent = nullptr); protected: @@ -20,6 +34,13 @@ class DisplayItemDelegate : public DStyledItemDelegate QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; + + void paintItemBackground(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + QRectF paintItemIcon(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + void paintItemColumn(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index, const QRectF &iconRect) const; }; #endif // DISPLAYITEMDELEGATE_H diff --git a/src/plugins/recent/mainframe/displayrecentview.cpp b/src/plugins/recent/mainframe/displayrecentview.cpp index df481b6b4..63be5e823 100644 --- a/src/plugins/recent/mainframe/displayrecentview.cpp +++ b/src/plugins/recent/mainframe/displayrecentview.cpp @@ -7,12 +7,14 @@ #include "displayitemdelegate.h" #include +#include + +#include #include #include #include #include -#include #include #define INIT_DATA "{\n \"Projects\":[],\n \"Documents\":[]\n}\n" @@ -57,7 +59,7 @@ QList DisplayRecentView::itemsFromFile() QList result; for (auto one : array) { QString filePath(one.toString()); - auto rowItem = new QStandardItem (icon(filePath), filePath); + auto rowItem = new DStandardItem (icon(filePath), filePath); rowItem->setToolTip(filePath); if (!cache.contains(filePath)) { cache << filePath; @@ -71,13 +73,46 @@ DisplayRecentView::DisplayRecentView(QWidget *parent) : DListView (parent) , cache({}) , model(new QStandardItemModel(this)) +{ + setDragDropMode(QAbstractItemView::NoDragDrop); + setSelectionMode(QAbstractItemView::SingleSelection); + setSelectionBehavior(QAbstractItemView::SelectRows); + setEditTriggers(QListView::NoEditTriggers); + setTextElideMode(Qt::ElideMiddle); + setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setAlternatingRowColors(false); + setSelectionRectVisible(true); + setMouseTracking(true); + + setUniformItemSizes(true); + setResizeMode(Fixed); + setOrientation(QListView::TopToBottom, false); + setFrameStyle(QFrame::NoFrame); + setSpacing(0); + setContentsMargins(0, 0, 0, 0); + + setModel(model); + setItemDelegate(new DisplayItemDelegate(this)); +} + +DisplayRecentView::~DisplayRecentView() { - DListView::setModel(model); - DListView::setEditTriggers(DListView::NoEditTriggers); - DListView::setItemDelegate(new DisplayItemDelegate(this)); - DListView::setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - DListView::setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - DListView::setSelectionMode(QAbstractItemView::NoSelection); + +} + +void DisplayRecentView::focusOutEvent(QFocusEvent *e) +{ + DListView::clearSelection(); + + DListView::focusOutEvent(e); +} + +void DisplayRecentView::mousePressEvent(QMouseEvent *e) +{ + if (e->button() != Qt::LeftButton) + return; + return DListView::mousePressEvent(e); } QString DisplayRecentView::cachePath() @@ -100,13 +135,7 @@ void DisplayRecentView::add(const QString &data) QIcon DisplayRecentView::icon(const QString &data) { QFileInfo info(data); - if (info.isFile()) { - return iconProvider.icon(QFileIconProvider::File); - } - if (info.isDir()) { - return iconProvider.icon(QFileIconProvider::Folder); - } - return QIcon(); + return iconProvider.icon(info); } void DisplayRecentView::load() diff --git a/src/plugins/recent/mainframe/displayrecentview.h b/src/plugins/recent/mainframe/displayrecentview.h index 1cdb7239e..7055cfa0d 100644 --- a/src/plugins/recent/mainframe/displayrecentview.h +++ b/src/plugins/recent/mainframe/displayrecentview.h @@ -6,23 +6,30 @@ #define DISPLAYRECENTVIEW_H #include -#include +#include + +DWIDGET_USE_NAMESPACE class QStandardItemModel; class QStandardItem; -class DisplayRecentView : public DTK_WIDGET_NAMESPACE::DListView +class DisplayRecentView : public DListView { Q_OBJECT QStringList cache; - QFileIconProvider iconProvider; + DFileIconProvider iconProvider; public: explicit DisplayRecentView(QWidget *parent = nullptr); + ~DisplayRecentView() override; + virtual QString cachePath(); virtual void add(const QString &data); virtual QIcon icon(const QString &data); virtual QString title() = 0; virtual void load(); virtual QList itemsFromFile(); + + void focusOutEvent(QFocusEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; protected: virtual void saveToFile(const QStringList &cache); protected: diff --git a/src/plugins/recent/mainframe/recentdisplay.cpp b/src/plugins/recent/mainframe/recentdisplay.cpp index 3f9be0d42..30ae5428d 100644 --- a/src/plugins/recent/mainframe/recentdisplay.cpp +++ b/src/plugins/recent/mainframe/recentdisplay.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -55,7 +56,7 @@ class DisplayProView : public DisplayRecentView QString file = projectFile(elemObj, &kitName, &language, &workspace); if (file.isEmpty() || !QFileInfo(file).exists()) continue; - auto rowItem = new QStandardItem (icon(file), file); + auto rowItem = new DStandardItem (icon(file), file); rowItem->setData(kitName, RecentDisplay::ProjectKitName); rowItem->setData(language, RecentDisplay::ProjectLanguage); rowItem->setData(workspace, RecentDisplay::ProjectWorkspace); From 010d8344b17b2be8771e4a6e45418be10daeae43 Mon Sep 17 00:00:00 2001 From: ZHANGTINGAN Date: Thu, 23 Nov 2023 13:31:00 +0800 Subject: [PATCH 5/6] feat: DTK-Changed javaPlugin include maven/gradle/java optionWidget --- .../java/gradle/option/gradleoptionwidget.cpp | 14 ++++-- .../java/gradle/option/gradlewidget.cpp | 28 ++++++----- .../java/java/option/javaoptionwidget.cpp | 12 +++-- src/plugins/java/java/option/jdkwidget.cpp | 16 ++++--- .../java/maven/option/mavenoptionwidget.cpp | 10 ++-- src/plugins/java/maven/option/mavenwidget.cpp | 47 ++++++++++--------- 6 files changed, 73 insertions(+), 54 deletions(-) diff --git a/src/plugins/java/gradle/option/gradleoptionwidget.cpp b/src/plugins/java/gradle/option/gradleoptionwidget.cpp index 08851aaa9..88443a2ec 100644 --- a/src/plugins/java/gradle/option/gradleoptionwidget.cpp +++ b/src/plugins/java/gradle/option/gradleoptionwidget.cpp @@ -9,11 +9,14 @@ #include "services/option/optiondatastruct.h" #include "services/option/optionmanager.h" +#include + #include -#include +#include +DWIDGET_USE_NAMESPACE class GradleOptionWidgetPrivate { - QTabWidget* tabWidget = nullptr; + DTabWidget* tabWidget = nullptr; friend class GradleOptionWidget; }; @@ -23,12 +26,15 @@ GradleOptionWidget::GradleOptionWidget(QWidget *parent) , d(new GradleOptionWidgetPrivate()) { QHBoxLayout *layout = new QHBoxLayout(); - d->tabWidget = new QTabWidget(); + d->tabWidget = new DTabWidget(); d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); d->tabWidget->addTab(new GradleWidget(), tr("Gradle")); - QObject::connect(d->tabWidget, &QTabWidget::currentChanged, [this]() { + //去除左/上边的边框 + d->tabWidget->setDocumentMode(true); + + QObject::connect(d->tabWidget, &DTabWidget::currentChanged, [this]() { readConfig(); }); diff --git a/src/plugins/java/gradle/option/gradlewidget.cpp b/src/plugins/java/gradle/option/gradlewidget.cpp index f9af3a124..828dd260e 100644 --- a/src/plugins/java/gradle/option/gradlewidget.cpp +++ b/src/plugins/java/gradle/option/gradlewidget.cpp @@ -7,23 +7,26 @@ #include "common/util/custompaths.h" #include "common/toolchain/toolchain.h" -#include -#include +#include +#include +#include +#include + #include #include -#include -#include #include #include #include +DWIDGET_USE_NAMESPACE + class GradleWidgetPrivate { friend class GradleWidget; - QRadioButton *useWrapper = nullptr; - QRadioButton *useLocal = nullptr; - QComboBox *localDetail = nullptr; + DRadioButton *useWrapper = nullptr; + DRadioButton *useLocal = nullptr; + DComboBox *localDetail = nullptr; QSharedPointer toolChainData; }; @@ -53,19 +56,18 @@ void GradleWidget::setupUi() { QVBoxLayout *vLayout = new QVBoxLayout(); setLayout(vLayout); - - QLabel *label = new QLabel(QLabel::tr("Gradle distribution:")); - d->useWrapper = new QRadioButton(tr("use Gradle wrapper")); + DLabel *label = new DLabel(DLabel::tr("Gradle distribution:")); + d->useWrapper = new DRadioButton(tr("use Gradle wrapper")); QHBoxLayout *localLayout = new QHBoxLayout(); - d->useLocal = new QRadioButton(tr("use Local installation, directory:")); + d->useLocal = new DRadioButton(tr("use Local installation, directory:")); d->useLocal->setFixedWidth(300); d->useLocal->setChecked(true); - d->localDetail = new QComboBox(); + d->localDetail = new DComboBox(); localLayout->addWidget(d->useLocal); localLayout->addWidget(d->localDetail); - QObject::connect(d->useLocal, &QRadioButton::setChecked, [this](){ + QObject::connect(d->useLocal, &DRadioButton::setChecked, [this](){ d->localDetail->setEnabled(d->useLocal->isChecked()); }); diff --git a/src/plugins/java/java/option/javaoptionwidget.cpp b/src/plugins/java/java/option/javaoptionwidget.cpp index 2d599f6da..bacfe0e83 100644 --- a/src/plugins/java/java/option/javaoptionwidget.cpp +++ b/src/plugins/java/java/option/javaoptionwidget.cpp @@ -9,9 +9,10 @@ #include "services/option/optiondatastruct.h" #include "services/option/optionmanager.h" -#include -#include +#include +#include +DWIDGET_USE_NAMESPACE class JavaOptionWidgetPrivate { QTabWidget* tabWidget = nullptr; @@ -23,11 +24,14 @@ JavaOptionWidget::JavaOptionWidget(QWidget *parent) , d(new JavaOptionWidgetPrivate()) { QHBoxLayout *layout = new QHBoxLayout(); - d->tabWidget = new QTabWidget(); + d->tabWidget = new DTabWidget(); layout->addWidget(d->tabWidget); d->tabWidget->tabBar()->setAutoHide(true); + //去除左/上边的边框 + d->tabWidget->setDocumentMode(true); + d->tabWidget->addTab(new JDKWidget(), tr("JDK")); - QObject::connect(d->tabWidget, &QTabWidget::currentChanged, [this]() { + QObject::connect(d->tabWidget, &DTabWidget::currentChanged, [this]() { readConfig(); }); diff --git a/src/plugins/java/java/option/jdkwidget.cpp b/src/plugins/java/java/option/jdkwidget.cpp index 4dacfde01..2d41b921e 100644 --- a/src/plugins/java/java/option/jdkwidget.cpp +++ b/src/plugins/java/java/option/jdkwidget.cpp @@ -7,6 +7,11 @@ #include "common/util/custompaths.h" #include "common/toolchain/toolchain.h" +#include +#include +#include +#include + #include #include #include @@ -15,20 +20,17 @@ #include #include -#include -#include #include #include -#include -#include #include +DWIDGET_USE_NAMESPACE class JDKWidgetPrivate { friend class JDKWidget; - QComboBox *jdkDetail = nullptr; + DComboBox *jdkDetail = nullptr; QSharedPointer toolChainData; }; @@ -60,9 +62,9 @@ void JDKWidget::setupUi() setLayout(vLayout); QHBoxLayout *hLayout = new QHBoxLayout(); - QLabel *label = new QLabel(QLabel::tr("JDK version:")); + DLabel *label = new DLabel(DLabel::tr("JDK version:")); label->setFixedWidth(120); - d->jdkDetail = new QComboBox(); + d->jdkDetail = new DComboBox(); hLayout->addWidget(label); hLayout->addWidget(d->jdkDetail); diff --git a/src/plugins/java/maven/option/mavenoptionwidget.cpp b/src/plugins/java/maven/option/mavenoptionwidget.cpp index edaa19cf1..33ce2c474 100644 --- a/src/plugins/java/maven/option/mavenoptionwidget.cpp +++ b/src/plugins/java/maven/option/mavenoptionwidget.cpp @@ -9,9 +9,11 @@ #include "services/option/optiondatastruct.h" #include "services/option/optionmanager.h" +#include + #include -#include +DWIDGET_USE_NAMESPACE class MavenOptionWidgetPrivate { QTabWidget* tabWidget = nullptr; @@ -23,13 +25,15 @@ MavenOptionWidget::MavenOptionWidget(QWidget *parent) , d(new MavenOptionWidgetPrivate()) { QHBoxLayout *layout = new QHBoxLayout(); - d->tabWidget = new QTabWidget(); + d->tabWidget = new DTabWidget(); d->tabWidget->tabBar()->setAutoHide(true); layout->addWidget(d->tabWidget); + //去除左/上边的边框 + d->tabWidget->setDocumentMode(true); d->tabWidget->addTab(new MavenWidget(), tr("Maven")); - QObject::connect(d->tabWidget, &QTabWidget::currentChanged, [this]() { + QObject::connect(d->tabWidget, &DTabWidget::currentChanged, [this]() { readConfig(); }); diff --git a/src/plugins/java/maven/option/mavenwidget.cpp b/src/plugins/java/maven/option/mavenwidget.cpp index 22b67edd6..594ccf434 100644 --- a/src/plugins/java/maven/option/mavenwidget.cpp +++ b/src/plugins/java/maven/option/mavenwidget.cpp @@ -6,24 +6,25 @@ #include "services/option/toolchaindata.h" #include "common/util/custompaths.h" -#include -#include +#include +#include +#include +#include +#include +#include + #include #include -#include -#include -#include -#include #include -#include +DWIDGET_USE_NAMESPACE class MavenWidgetPrivate { friend class MavenWidget; - QComboBox *homePathComboBox = nullptr; - QLineEdit *userSettingEdit = nullptr; - QLineEdit *localSettingEdit = nullptr; + DComboBox *homePathComboBox = nullptr; + DLineEdit *userSettingEdit = nullptr; + DLineEdit *localSettingEdit = nullptr; QSharedPointer toolChainData; }; @@ -54,27 +55,27 @@ void MavenWidget::setupUi() QVBoxLayout *vLayout = new QVBoxLayout(); setLayout(vLayout); - QLabel *homePathLabel = new QLabel(QLabel::tr("Maven path:")); + DLabel *homePathLabel = new DLabel(DLabel::tr("Maven path:")); homePathLabel->setFixedWidth(120); - d->homePathComboBox = new QComboBox(); + d->homePathComboBox = new DComboBox(); QHBoxLayout *homePathLayout = new QHBoxLayout(); homePathLayout->addWidget(homePathLabel); homePathLayout->addWidget(d->homePathComboBox); - QLabel *userSettingLabel = new QLabel(QLabel::tr("User Setting:")); + DLabel *userSettingLabel = new DLabel(DLabel::tr("User Setting:")); userSettingLabel->setFixedWidth(120); - d->userSettingEdit = new QLineEdit(); - QPushButton *userSettingBtn = new QPushButton(QPushButton::tr("Browse")); + d->userSettingEdit = new DLineEdit(); + DPushButton *userSettingBtn = new DPushButton(DPushButton::tr("Browse")); QHBoxLayout *userSettingLayout = new QHBoxLayout(); userSettingLayout->addWidget(userSettingLabel); userSettingLayout->addWidget(d->userSettingEdit); userSettingLayout->addWidget(userSettingBtn); - QLabel *localSettingLabel = new QLabel(QLabel::tr("Local Setting:")); + DLabel *localSettingLabel = new DLabel(DLabel::tr("Local Setting:")); localSettingLabel->setFixedWidth(120); - d->localSettingEdit = new QLineEdit(); - QPushButton *localSettingBtn = new QPushButton(QPushButton::tr("Browse")); + d->localSettingEdit = new DLineEdit(); + DPushButton *localSettingBtn = new DPushButton(DPushButton::tr("Browse")); QHBoxLayout *localSettingLayout = new QHBoxLayout(); localSettingLayout->addWidget(localSettingLabel); localSettingLayout->addWidget(d->localSettingEdit); @@ -86,8 +87,8 @@ void MavenWidget::setupUi() vLayout->addStretch(); - QObject::connect(userSettingBtn, &QPushButton::clicked, [this](){ - QFileDialog fileDialog; + QObject::connect(userSettingBtn, &DPushButton::clicked, [this](){ + DFileDialog fileDialog; QString filePath = fileDialog.getOpenFileName(nullptr, "Open Maven User Setting File", QString(), "*.xml"); if(!filePath.isEmpty()) { d->userSettingEdit->setText(filePath); @@ -95,9 +96,9 @@ void MavenWidget::setupUi() }); - QObject::connect(localSettingBtn, &QPushButton::clicked, [this](){ - QFileDialog fileDialog; - QString filePath = fileDialog.getExistingDirectory(nullptr, "Open Maven Local Setting Folder", QString(), QFileDialog::DontResolveSymlinks); + QObject::connect(localSettingBtn, &DPushButton::clicked, [this](){ + DFileDialog fileDialog; + QString filePath = fileDialog.getExistingDirectory(nullptr, "Open Maven Local Setting Folder", QString(), DFileDialog::DontResolveSymlinks); if(!filePath.isEmpty()) { d->localSettingEdit->setText(filePath); } From ca27ed7463007be6d1e22e2064147b5a66f77f04 Mon Sep 17 00:00:00 2001 From: ZHANGTINGAN Date: Thu, 23 Nov 2023 14:24:04 +0800 Subject: [PATCH 6/6] feat: DTK-Changed java-propertyWidget DTK-Changed java-propertyWidget --- .../properties/gradleconfigpropertywidget.cpp | 77 ++++++++--------- .../properties/gradleconfigpropertywidget.h | 3 +- .../properties/mavenconfigpropertywidget.cpp | 83 ++++++++++--------- .../properties/mavenconfigpropertywidget.h | 4 +- 4 files changed, 88 insertions(+), 79 deletions(-) diff --git a/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.cpp b/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.cpp index 95be0e01c..0125409ab 100644 --- a/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.cpp +++ b/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.cpp @@ -8,13 +8,16 @@ #include "common/toolchain/toolchain.h" #include "common/widget/pagewidget.h" -#include +#include +#include +#include +#include +#include +#include + #include -#include -#include -#include -#include -#include + +DWIDGET_USE_NAMESPACE static const QString kJrePath = QObject::tr("jre path"); static const QString kJreExecute = QObject::tr("jre execute"); @@ -26,20 +29,20 @@ static const int kHeadlineWidth = 120; class GradleDetailPropertyWidgetPrivate { friend class GradleDetailPropertyWidget; - QComboBox *jdkVersionComboBox{nullptr}; - QComboBox *gradleVersionComboBox{nullptr}; - QLineEdit *mainClass{nullptr}; + DComboBox *jdkVersionComboBox{nullptr}; + DComboBox *gradleVersionComboBox{nullptr}; + DLineEdit *mainClass{nullptr}; QSharedPointer toolChainData; - QCheckBox *detailBox{nullptr}; - QLineEdit *jreEdit{nullptr}; - QLineEdit *jreExecuteEdit{nullptr}; - QLineEdit *launchCfgPathEdit{nullptr}; - QLineEdit *lanuchCfgFileEdit{nullptr}; - QLineEdit *dapPackageFileEdit{nullptr}; + DCheckBox *detailBox{nullptr}; + DLineEdit *jreEdit{nullptr}; + DLineEdit *jreExecuteEdit{nullptr}; + DLineEdit *launchCfgPathEdit{nullptr}; + DLineEdit *lanuchCfgFileEdit{nullptr}; + DLineEdit *dapPackageFileEdit{nullptr}; }; GradleDetailPropertyWidget::GradleDetailPropertyWidget(QWidget *parent) - : QWidget(parent) + : DFrame(parent) , d(new GradleDetailPropertyWidgetPrivate()) { setupUI(); @@ -58,25 +61,25 @@ void GradleDetailPropertyWidget::setupUI() setLayout(vLayout); QHBoxLayout *hLayout = new QHBoxLayout(); - QLabel *label = new QLabel(QLabel::tr("JDK version:")); + DLabel *label = new DLabel(DLabel::tr("JDK version:")); label->setFixedWidth(kHeadlineWidth); - d->jdkVersionComboBox = new QComboBox(); + d->jdkVersionComboBox = new DComboBox(); hLayout->addWidget(label); hLayout->addWidget(d->jdkVersionComboBox); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); - label = new QLabel(QLabel::tr("Gradle Version: ")); + label = new DLabel(DLabel::tr("Gradle Version: ")); label->setFixedWidth(kHeadlineWidth); - d->gradleVersionComboBox = new QComboBox(); + d->gradleVersionComboBox = new DComboBox(); hLayout->addWidget(label); hLayout->addWidget(d->gradleVersionComboBox); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); - label = new QLabel(QLabel::tr("Main Class:")); + label = new DLabel(DLabel::tr("Main Class:")); label->setFixedWidth(kHeadlineWidth); - d->mainClass = new QLineEdit(); + d->mainClass = new DLineEdit(); d->mainClass->setPlaceholderText(tr("Input main class")); hLayout->addWidget(label); hLayout->addWidget(d->mainClass); @@ -84,9 +87,9 @@ void GradleDetailPropertyWidget::setupUI() vLayout->addStretch(10); hLayout = new QHBoxLayout(); - label = new QLabel(QLabel::tr("Detail output:")); + label = new DLabel(DLabel::tr("Detail output:")); label->setFixedWidth(kHeadlineWidth); - d->detailBox = new QCheckBox(); + d->detailBox = new DCheckBox(); hLayout->addWidget(label); hLayout->addWidget(d->detailBox); hLayout->setAlignment(Qt::AlignLeft); @@ -96,10 +99,10 @@ void GradleDetailPropertyWidget::setupUI() auto addGroupWidgets = [this](QVBoxLayout *vLayout, const QString &headLine, QWidget *widget){ QHBoxLayout *hLayout = new QHBoxLayout(); - QLabel *label = new QLabel(headLine + ":"); + DLabel *label = new DLabel(headLine + ":"); label->setFixedWidth(kHeadlineWidth); - QPushButton *btnBrowser = new QPushButton(this); + DPushButton *btnBrowser = new DPushButton(this); btnBrowser->setText(tr("Browse...")); btnBrowser->setObjectName(headLine); hLayout->addWidget(label); @@ -107,14 +110,14 @@ void GradleDetailPropertyWidget::setupUI() hLayout->addWidget(btnBrowser); vLayout->addLayout(hLayout); - connect(btnBrowser, &QPushButton::clicked, this, &GradleDetailPropertyWidget::browserFileDialog); + connect(btnBrowser, &DPushButton::clicked, this, &GradleDetailPropertyWidget::browserFileDialog); }; - d->jreEdit = new QLineEdit(this); - d->jreExecuteEdit = new QLineEdit(this); - d->launchCfgPathEdit = new QLineEdit(this); - d->lanuchCfgFileEdit = new QLineEdit(this); - d->dapPackageFileEdit = new QLineEdit(this); + d->jreEdit = new DLineEdit(this); + d->jreExecuteEdit = new DLineEdit(this); + d->launchCfgPathEdit = new DLineEdit(this); + d->lanuchCfgFileEdit = new DLineEdit(this); + d->dapPackageFileEdit = new DLineEdit(this); addGroupWidgets(vLayout, kJrePath, d->jreEdit); addGroupWidgets(vLayout, kJreExecute, d->jreExecuteEdit); @@ -130,7 +133,7 @@ void GradleDetailPropertyWidget::initData() bool ret = d->toolChainData->readToolChainData(retMsg); if (ret) { const ToolChainData::ToolChains &data = d->toolChainData->getToolChanins(); - auto initComboBox = [](QComboBox *comboBox, const ToolChainData::ToolChains &data, const QString &type) { + auto initComboBox = [](DComboBox *comboBox, const ToolChainData::ToolChains &data, const QString &type) { int index = 0; ToolChainData::Params params = data.value(type); for (auto param : params) { @@ -151,7 +154,7 @@ void GradleDetailPropertyWidget::setValues(const gradleConfig::ConfigureParam *p if (!param) return; - auto initComboBox = [](QComboBox *comboBox, const gradleConfig::ItemInfo &itemInfo) { + auto initComboBox = [](DComboBox *comboBox, const gradleConfig::ItemInfo &itemInfo) { int count = comboBox->count(); for (int i = 0; i < count; i++) { ToolChainData::ToolChainParam toolChainParam = qvariant_cast(comboBox->itemData(i, Qt::UserRole + 1)); @@ -179,7 +182,7 @@ void GradleDetailPropertyWidget::getValues(gradleConfig::ConfigureParam *param) if (!param) return; - auto getValue = [](QComboBox *comboBox, gradleConfig::ItemInfo &itemInfo){ + auto getValue = [](DComboBox *comboBox, gradleConfig::ItemInfo &itemInfo){ itemInfo.clear(); int index = comboBox->currentIndex(); if (index > -1) { @@ -205,7 +208,7 @@ void GradleDetailPropertyWidget::browserFileDialog() QObject *senderObj = qobject_cast(sender()); QString senderName = senderObj->objectName(); - auto showDirDialog = [this](QLineEdit *widget){ + auto showDirDialog = [this](DLineEdit *widget){ QString result = QFileDialog::getExistingDirectory(this, tr("Open Directory"), widget->text(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); @@ -214,7 +217,7 @@ void GradleDetailPropertyWidget::browserFileDialog() } }; - auto showFileDialog = [this](QLineEdit *widget){ + auto showFileDialog = [this](DLineEdit *widget){ QString result = QFileDialog::getOpenFileName(this, tr("Select File"), widget->text()); if (!result.isEmpty()) widget->setText(result); diff --git a/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.h b/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.h index 6029fa690..82961c348 100644 --- a/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.h +++ b/src/plugins/java/gradle/project/properties/gradleconfigpropertywidget.h @@ -7,10 +7,11 @@ #include "gradle/project/properties/gradleconfigutil.h" #include "services/project/projectinfo.h" +#include class PageWidget; class GradleDetailPropertyWidgetPrivate; -class GradleDetailPropertyWidget : public QWidget +class GradleDetailPropertyWidget : public DTK_WIDGET_NAMESPACE::DFrame { Q_OBJECT public: diff --git a/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.cpp b/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.cpp index 4b4b77928..81351d75d 100644 --- a/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.cpp +++ b/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.cpp @@ -8,13 +8,16 @@ #include "common/toolchain/toolchain.h" #include "common/widget/pagewidget.h" -#include +#include +#include +#include +#include +#include +#include + #include -#include -#include -#include -#include -#include + +DWIDGET_USE_NAMESPACE static const QString kJrePath = QObject::tr("jre path"); static const QString kJreExecute = QObject::tr("jre execute"); @@ -26,20 +29,20 @@ static const int kHeadlineWidth = 120; class MavenDetailPropertyWidgetPrivate { friend class MavenDetailPropertyWidget; - QComboBox *jdkVersionComboBox{nullptr}; - QComboBox *mvnVersionComboBox{nullptr}; - QLineEdit *mainClass{nullptr}; - QCheckBox *detailBox{nullptr}; - QLineEdit *jreEdit{nullptr}; - QLineEdit *jreExecuteEdit{nullptr}; - QLineEdit *launchCfgPathEdit{nullptr}; - QLineEdit *lanuchCfgFileEdit{nullptr}; - QLineEdit *dapPackageFileEdit{nullptr}; + DComboBox *jdkVersionComboBox{nullptr}; + DComboBox *mvnVersionComboBox{nullptr}; + DLineEdit *mainClass{nullptr}; + DCheckBox *detailBox{nullptr}; + DLineEdit *jreEdit{nullptr}; + DLineEdit *jreExecuteEdit{nullptr}; + DLineEdit *launchCfgPathEdit{nullptr}; + DLineEdit *lanuchCfgFileEdit{nullptr}; + DLineEdit *dapPackageFileEdit{nullptr}; QSharedPointer toolChainData; }; MavenDetailPropertyWidget::MavenDetailPropertyWidget(QWidget *parent) - : QWidget(parent) + : DFrame(parent) , d(new MavenDetailPropertyWidgetPrivate()) { setupUI(); @@ -58,25 +61,25 @@ void MavenDetailPropertyWidget::setupUI() setLayout(vLayout); QHBoxLayout *hLayout = new QHBoxLayout(); - QLabel *label = new QLabel(QLabel::tr("JDK version:")); + DLabel *label = new DLabel(DLabel::tr("JDK version:")); label->setFixedWidth(kHeadlineWidth); - d->jdkVersionComboBox = new QComboBox(); + d->jdkVersionComboBox = new DComboBox(); hLayout->addWidget(label); hLayout->addWidget(d->jdkVersionComboBox); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); - label = new QLabel(QLabel::tr("Maven Version: ")); + label = new DLabel(DLabel::tr("Maven Version: ")); label->setFixedWidth(kHeadlineWidth); - d->mvnVersionComboBox = new QComboBox(); + d->mvnVersionComboBox = new DComboBox(); hLayout->addWidget(label); hLayout->addWidget(d->mvnVersionComboBox); vLayout->addLayout(hLayout); hLayout = new QHBoxLayout(); - label = new QLabel(QLabel::tr("Main Class:")); + label = new DLabel(DLabel::tr("Main Class:")); label->setFixedWidth(kHeadlineWidth); - d->mainClass = new QLineEdit(); + d->mainClass = new DLineEdit(); d->mainClass->setPlaceholderText(tr("Input main class")); hLayout->addWidget(label); hLayout->addWidget(d->mainClass); @@ -84,9 +87,9 @@ void MavenDetailPropertyWidget::setupUI() vLayout->addStretch(10); hLayout = new QHBoxLayout(); - label = new QLabel(QLabel::tr("Detail output:")); + label = new DLabel(DLabel::tr("Detail output:")); label->setFixedWidth(kHeadlineWidth); - d->detailBox = new QCheckBox(); + d->detailBox = new DCheckBox(); hLayout->addWidget(label); hLayout->addWidget(d->detailBox); hLayout->setAlignment(Qt::AlignLeft); @@ -96,10 +99,10 @@ void MavenDetailPropertyWidget::setupUI() auto addGroupWidgets = [this](QVBoxLayout *vLayout, const QString &headLine, QWidget *widget){ QHBoxLayout *hLayout = new QHBoxLayout(); - QLabel *label = new QLabel(headLine + ":"); + DLabel *label = new DLabel(headLine + ":"); label->setFixedWidth(kHeadlineWidth); - QPushButton *btnBrowser = new QPushButton(this); + DPushButton *btnBrowser = new DPushButton(this); btnBrowser->setText(tr("Browse...")); btnBrowser->setObjectName(headLine); hLayout->addWidget(label); @@ -107,14 +110,14 @@ void MavenDetailPropertyWidget::setupUI() hLayout->addWidget(btnBrowser); vLayout->addLayout(hLayout); - connect(btnBrowser, &QPushButton::clicked, this, &MavenDetailPropertyWidget::browserFileDialog); + connect(btnBrowser, &DPushButton::clicked, this, &MavenDetailPropertyWidget::browserFileDialog); }; - d->jreEdit = new QLineEdit(this); - d->jreExecuteEdit = new QLineEdit(this); - d->launchCfgPathEdit = new QLineEdit(this); - d->lanuchCfgFileEdit = new QLineEdit(this); - d->dapPackageFileEdit = new QLineEdit(this); + d->jreEdit = new DLineEdit(this); + d->jreExecuteEdit = new DLineEdit(this); + d->launchCfgPathEdit = new DLineEdit(this); + d->lanuchCfgFileEdit = new DLineEdit(this); + d->dapPackageFileEdit = new DLineEdit(this); addGroupWidgets(vLayout, kJrePath, d->jreEdit); addGroupWidgets(vLayout, kJreExecute, d->jreExecuteEdit); @@ -130,7 +133,7 @@ void MavenDetailPropertyWidget::initData() bool ret = d->toolChainData->readToolChainData(retMsg); if (ret) { const ToolChainData::ToolChains &data = d->toolChainData->getToolChanins(); - auto initComboBox = [](QComboBox *comboBox, const ToolChainData::ToolChains &data, const QString &type) { + auto initComboBox = [](DComboBox *comboBox, const ToolChainData::ToolChains &data, const QString &type) { int index = 0; ToolChainData::Params params = data.value(type); for (auto param : params) { @@ -151,7 +154,7 @@ void MavenDetailPropertyWidget::setValues(const mavenConfig::ConfigureParam *par if (!param) return; - auto initComboBox = [](QComboBox *comboBox, const mavenConfig::ItemInfo &itemInfo) { + auto initComboBox = [](DComboBox *comboBox, const mavenConfig::ItemInfo &itemInfo) { int count = comboBox->count(); for (int i = 0; i < count; i++) { ToolChainData::ToolChainParam toolChainParam = qvariant_cast(comboBox->itemData(i, Qt::UserRole + 1)); @@ -179,7 +182,7 @@ void MavenDetailPropertyWidget::getValues(mavenConfig::ConfigureParam *param) if (!param) return; - auto getValue = [](QComboBox *comboBox, mavenConfig::ItemInfo &itemInfo){ + auto getValue = [](DComboBox *comboBox, mavenConfig::ItemInfo &itemInfo){ itemInfo.clear(); int index = comboBox->currentIndex(); if (index > -1) { @@ -205,17 +208,17 @@ void MavenDetailPropertyWidget::browserFileDialog() QObject *senderObj = qobject_cast(sender()); QString senderName = senderObj->objectName(); - auto showDirDialog = [this](QLineEdit *widget){ - QString result = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + auto showDirDialog = [this](DLineEdit *widget){ + QString result = DFileDialog::getExistingDirectory(this, tr("Open Directory"), widget->text(), - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + DFileDialog::ShowDirsOnly | DFileDialog::DontResolveSymlinks); if (!result.isEmpty()) { widget->setText(result); } }; - auto showFileDialog = [this](QLineEdit *widget){ - QString result = QFileDialog::getOpenFileName(this, tr("Select File"), widget->text()); + auto showFileDialog = [this](DLineEdit *widget){ + QString result = DFileDialog::getOpenFileName(this, tr("Select File"), widget->text()); if (!result.isEmpty()) widget->setText(result); }; diff --git a/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.h b/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.h index 02337b657..d70b1846d 100644 --- a/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.h +++ b/src/plugins/java/maven/project/properties/mavenconfigpropertywidget.h @@ -9,9 +9,11 @@ #include "services/project/projectinfo.h" +#include + class PageWidget; class MavenDetailPropertyWidgetPrivate; -class MavenDetailPropertyWidget : public QWidget +class MavenDetailPropertyWidget : public DTK_WIDGET_NAMESPACE::DFrame { Q_OBJECT public: