diff --git a/CMakeLists.txt b/CMakeLists.txt index 53906452e..047526202 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,9 @@ endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wl,--as-need -fPIE") +find_package(Dtk COMPONENTS Widget REQUIRED) +include_directories(${PROJECT_NAME} PRIVATE ${DtkWidget_INCLUDE_DIRS}) + # Use Qt modules no WebEngineWidgets WebChannel set(QtFindModules Core Gui Widgets Concurrent Network DBus) foreach(QtModule ${QtFindModules}) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 195f7fbb5..5aa72d383 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -8,6 +8,7 @@ target_link_libraries( common ${QtUseModules} ${PkgUseModule} + ${DtkWidget_LIBRARIES} ) install(TARGETS ${PROJECT_NAME} DESTINATION ${RUNTIME_INSTALL_RPEFIX}) diff --git a/src/app/main.cpp b/src/app/main.cpp index 750803eb8..9925a7713 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -6,9 +6,14 @@ #include #include + +#include + #include #include +DWIDGET_USE_NAMESPACE + static const char *const IID = "org.deepin.plugin.unioncode"; static const char *const CORE_PLUGIN = "plugin-core"; static const char *const CORE_NAME = "libplugin-core.so"; @@ -94,9 +99,12 @@ void voidMessageOutput(QtMsgType type, const QMessageLogContext &context, const int main(int argc, char *argv[]) { - QApplication a(argc, argv); - QApplication::setStyle(QStyleFactory::create("Fusion")); + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + DApplication a(argc, argv); + a.setOrganizationName("deepin"); + a.setQuitOnLastWindowClosed(false); CommandParser::instance().process(); // TODO(Any): put to command processor @@ -118,8 +126,5 @@ int main(int argc, char *argv[]) abort(); } - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - return a.exec(); } diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index c6bc7eb15..066b0bb3b 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -134,6 +134,7 @@ target_link_libraries( ${PROJECT_NAME} unioncode-jsonrpcclient Qt5::Network + ${DtkWidget_LIBRARIES} ) install(TARGETS ${PROJECT_NAME} DESTINATION ${LIBRARY_INSTALL_PREFIX}) diff --git a/src/common/widget/elidedlabel.cpp b/src/common/widget/elidedlabel.cpp index b14354a1a..6ce9b8f22 100644 --- a/src/common/widget/elidedlabel.cpp +++ b/src/common/widget/elidedlabel.cpp @@ -13,7 +13,7 @@ class ElidedLabelPrivate }; ElidedLabel::ElidedLabel(QWidget *parent) - : QLabel (parent) + : DLabel (parent) , d (new ElidedLabelPrivate) { @@ -38,8 +38,8 @@ void ElidedLabel::setText(const QString &text) } else { resultText = d->sourceText; } - QLabel::setText(resultText); - QLabel::setToolTip(text); + DLabel::setText(resultText); + DLabel::setToolTip(text); } QString ElidedLabel::text() diff --git a/src/common/widget/elidedlabel.h b/src/common/widget/elidedlabel.h index 164b543bc..a59d05a6e 100644 --- a/src/common/widget/elidedlabel.h +++ b/src/common/widget/elidedlabel.h @@ -5,10 +5,10 @@ #ifndef ELIDEDLABEL_H #define ELIDEDLABEL_H -#include +#include class ElidedLabelPrivate; -class ElidedLabel : public QLabel +class ElidedLabel : public DTK_WIDGET_NAMESPACE::DLabel { Q_OBJECT ElidedLabelPrivate *const d; diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 72e302690..49dbce95b 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -87,6 +87,7 @@ target_link_libraries( stdc++fs ${QtUseModules} ${PkgUseModules} + ${DtkWidget_LIBRARIES} ) target_include_directories(${PROJECT_NAME} diff --git a/src/plugins/core/CMakeLists.txt b/src/plugins/core/CMakeLists.txt index 8b842d0cf..dd414641b 100644 --- a/src/plugins/core/CMakeLists.txt +++ b/src/plugins/core/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 3.0.2) project(plugin-core) set(CXX_CPP - mainframe/windowtheme.cpp mainframe/windowkeeper.cpp mainframe/windowstatusbar.cpp mainframe/progressbar.cpp @@ -15,7 +14,6 @@ set(CXX_CPP ) set(CXX_H - mainframe/windowtheme.h mainframe/windowkeeper.h mainframe/windowstatusbar.h mainframe/progressbar.h @@ -42,6 +40,7 @@ target_link_libraries(${PROJECT_NAME} services ${QtUseModules} ${PkgUserModules} + ${DtkWidget_LIBRARIES} ) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) diff --git a/src/plugins/core/core.cpp b/src/plugins/core/core.cpp index 1de7ab121..764736fba 100644 --- a/src/plugins/core/core.cpp +++ b/src/plugins/core/core.cpp @@ -4,18 +4,11 @@ #include "core.h" #include "mainframe/windowkeeper.h" -#include "mainframe/windowtheme.h" #include "services/window/windowservice.h" #include #include "common/common.h" -#include -#include -#include -#include -#include - using namespace dpfservice; void Core::initialize() @@ -48,7 +41,6 @@ bool Core::start() } WindowKeeper::instace(); - WindowTheme::setTheme(":/dark.css"); QObject::connect(&dpf::Listener::instance(), &dpf::Listener::pluginsStarted, [=] { ActionManager::getInstance()->readUserSetting(); diff --git a/src/plugins/core/mainframe/aboutdialog.cpp b/src/plugins/core/mainframe/aboutdialog.cpp index 1cc7eea2a..2726a70d6 100644 --- a/src/plugins/core/mainframe/aboutdialog.cpp +++ b/src/plugins/core/mainframe/aboutdialog.cpp @@ -5,17 +5,23 @@ #include "aboutdialog.h" #include "common/common.h" +#include +#include +#include +#include +#include + #include -#include -#include #include #include #include +DWIDGET_USE_NAMESPACE + const QString ICON_LOGO_128PX = ":/core/images/unioncode@128.png"; -AboutDialog::AboutDialog(QDialog *parent) - : QDialog(parent) +AboutDialog::AboutDialog(QWidget *parent) + : DAbstractDialog(parent) { setupUi(); } @@ -27,9 +33,13 @@ AboutDialog::~AboutDialog() void AboutDialog::setupUi() { - setWindowTitle(tr("About Deepin Union Code")); + DTitlebar *titleBar = new DTitlebar(); + titleBar = new DTitlebar(); + titleBar->setMenuVisible(false); + titleBar->setTitle(QString(tr("About Deepin Union Code"))); - QLabel *logoLabel = new QLabel; + DLabel *logoLabel = new DLabel(this); + logoLabel->setText("aaa"); logoLabel->setPixmap(QPixmap(ICON_LOGO_128PX)); QString buildDateInfo = tr("
Built on %1 %2 in %3
") @@ -49,23 +59,27 @@ void AboutDialog::setupUi() buildDateInfo, QString::number(QDateTime::currentDateTime().date().year())); - QLabel *copyRightLabel = new QLabel(description); + DLabel *copyRightLabel = new DLabel(description); copyRightLabel->setWordWrap(true); copyRightLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - connect(copyRightLabel, &QLabel::linkActivated, this, &AboutDialog::handleLinkActivated); + connect(copyRightLabel, &DLabel::linkActivated, this, &AboutDialog::handleLinkActivated); QHBoxLayout *layoutButtons = new QHBoxLayout(); - QPushButton *closeButton = new QPushButton(QPushButton::tr("Close")); - connect(closeButton , &QPushButton::clicked, this, &QDialog::reject); + DPushButton *closeButton = new DPushButton(DPushButton::tr("Close")); + connect(closeButton , &DPushButton::clicked, this, &DAbstractDialog::reject); layoutButtons->addStretch(); layoutButtons->addWidget(closeButton); auto vLayout = new QVBoxLayout(this); + vLayout->setContentsMargins(0, 0, 0, 0); + vLayout->setSpacing(0); + auto detailLayout = new QGridLayout(this); detailLayout->setSizeConstraint(QLayout::SetFixedSize); detailLayout->addWidget(logoLabel , 1, 0, 1, 1); detailLayout->addWidget(copyRightLabel, 0, 4, 4, 5); detailLayout->addLayout(layoutButtons, 4, 4, 1, 5); + vLayout->addWidget(titleBar); vLayout->addLayout(detailLayout); } @@ -74,7 +88,7 @@ void AboutDialog::handleLinkActivated(const QString& link) if (link == "opensourcesoftware" && !bExpand) { QFile file("/usr/share/doc/deepin-unioncode/copyright"); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextEdit* textEdit = new QTextEdit(this); + DTextEdit* textEdit = new DTextEdit(this); layout()->addWidget(textEdit); QTextStream stream(&file); @@ -83,7 +97,7 @@ void AboutDialog::handleLinkActivated(const QString& link) setFixedHeight(height() * 2); bExpand = true; } else { - QMessageBox::critical(this, tr("Error"), tr("Failed to open the file.")); + DMessageBox::critical(this, tr("Error"), tr("Failed to open the file.")); } } else { QDesktopServices::openUrl(QUrl(link)); diff --git a/src/plugins/core/mainframe/aboutdialog.h b/src/plugins/core/mainframe/aboutdialog.h index 2ddc255b0..42a236499 100644 --- a/src/plugins/core/mainframe/aboutdialog.h +++ b/src/plugins/core/mainframe/aboutdialog.h @@ -5,13 +5,13 @@ #ifndef ABOUTDIALOG_H #define ABOUTDIALOG_H -#include +#include -class AboutDialog : public QDialog +class AboutDialog : public DTK_WIDGET_NAMESPACE::DAbstractDialog { Q_OBJECT public: - explicit AboutDialog(QDialog *parent = nullptr); + explicit AboutDialog(QWidget *parent = nullptr); virtual ~AboutDialog(); signals: diff --git a/src/plugins/core/mainframe/plugindialog.cpp b/src/plugins/core/mainframe/plugindialog.cpp index 38635c029..3e24a2fa2 100644 --- a/src/plugins/core/mainframe/plugindialog.cpp +++ b/src/plugins/core/mainframe/plugindialog.cpp @@ -9,32 +9,36 @@ #include "framework/lifecycle/pluginmetaobject.h" #include "framework/lifecycle/pluginview.h" +#include + #include #include -#include -#include -#include -#include #include static bool isRestartRequired = false; PluginDialog::PluginDialog(QWidget *parent) - : QDialog(parent), + : DAbstractDialog(parent), view(new dpf::PluginView(this)) { resize(1000, 600); - setWindowTitle(tr("Installed Plugins")); + + DTitlebar *titleBar = new DTitlebar(); + titleBar = new DTitlebar(); + titleBar->setMenuVisible(false); + titleBar->setTitle(QString(tr("Installed Plugins"))); auto vLayout = new QVBoxLayout(this); + vLayout->setContentsMargins(0, 0, 0, 0); + vLayout->setSpacing(0); auto detailLayout = new QHBoxLayout; detailLayout->addWidget(view); - closeButton = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this); - closeButton->button(QDialogButtonBox::Close)->setText(tr("Close")); + closeButton = new DDialogButtonBox(DDialogButtonBox::Close, Qt::Horizontal, this); + closeButton->button(DDialogButtonBox::Close)->setText(tr("Close")); closeButton->setEnabled(true); - restratRequired = new QLabel(tr(" Restart required."), this); + restratRequired = new DLabel(tr(" Restart required."), this); if (!isRestartRequired) restratRequired->setVisible(false); @@ -48,13 +52,14 @@ PluginDialog::PluginDialog(QWidget *parent) detailLayout->addWidget(detailView); slotCurrentPluginActived(); + vLayout->addWidget(titleBar); vLayout->addLayout(detailLayout); vLayout->addLayout(buttonLayout); QObject::connect(view, &dpf::PluginView::currentPluginActived, this, &PluginDialog::slotCurrentPluginActived); QObject::connect(view, &dpf::PluginView::pluginSettingChanged, this, &PluginDialog::updateRestartRequired); - QObject::connect(closeButton->button(QDialogButtonBox::Close), &QPushButton::clicked, + QObject::connect(closeButton->button(DDialogButtonBox::Close), &DPushButton::clicked, [this] { closeDialog() ;}); } @@ -77,89 +82,89 @@ void PluginDialog::closeDialog() } DetailsView::DetailsView(QWidget *parent) - : QWidget(parent) + : DWidget(parent) { gridLayout = new QGridLayout(this); gridLayout->setContentsMargins(2, 2, 2, 2); - nameLabel = new QLabel(tr("Name:"), this); + nameLabel = new DLabel(tr("Name:"), this); nameLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - name = new QLabel(this); + name = new DLabel(this); name->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); gridLayout->addWidget(nameLabel, 0, 0, 1, 1); gridLayout->addWidget(name, 0, 1, 1, 1); - versionLabel = new QLabel(tr("Version:"), this); + versionLabel = new DLabel(tr("Version:"), this); versionLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - version = new QLabel(this); + version = new DLabel(this); version->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); gridLayout->addWidget(versionLabel, 1, 0, 1, 1); gridLayout->addWidget(version, 1, 1, 1, 1); - compatVersionLabel = new QLabel(tr("Compatibility version:"), this); + compatVersionLabel = new DLabel(tr("Compatibility version:"), this); compatVersionLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - compatVersion = new QLabel(this); + compatVersion = new DLabel(this); compatVersion->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); gridLayout->addWidget(compatVersionLabel, 2, 0, 1, 1); gridLayout->addWidget(compatVersion, 2, 1, 1, 1); - vendorLabel = new QLabel(tr("Vendor:"), this); + vendorLabel = new DLabel(tr("Vendor:"), this); vendorLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - vendor = new QLabel(this); + vendor = new DLabel(this); vendor->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); gridLayout->addWidget(vendorLabel, 3, 0, 1, 1); gridLayout->addWidget(vendor, 3, 1, 1, 1); - copyrightLabel = new QLabel(tr("Copyright:"), this); + copyrightLabel = new DLabel(tr("Copyright:"), this); copyrightLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - copyright = new QLabel(this); + copyright = new DLabel(this); copyright->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); gridLayout->addWidget(copyrightLabel, 4, 0, 1, 1); gridLayout->addWidget(copyright, 4, 1, 1, 1); - categoryLabel = new QLabel(tr("Category:"), this); + categoryLabel = new DLabel(tr("Category:"), this); categoryLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - category = new QLabel(this); + category = new DLabel(this); category->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); gridLayout->addWidget(categoryLabel, 5, 0, 1, 1); gridLayout->addWidget(category, 5, 1, 1, 1); - urlLabel = new QLabel(tr("URL:"), this); + urlLabel = new DLabel(tr("URL:"), this); urlLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); - urlLink = new QLabel(this); + urlLink = new DLabel(this); urlLink->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); gridLayout->addWidget(urlLabel, 6, 0, 1, 1); gridLayout->addWidget(urlLink, 6, 1, 1, 1); vboxLayout_1 = new QVBoxLayout(); - licenseLabel = new QLabel(tr("License:"), this); + licenseLabel = new DLabel(tr("License:"), this); licenseLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); vboxLayout_1->addWidget(licenseLabel); spacerItem_1 = new QSpacerItem(17, 13, QSizePolicy::Minimum, QSizePolicy::Expanding); vboxLayout_1->addItem(spacerItem_1); - license = new QTextEdit(this); + license = new DTextEdit(this); license->setReadOnly(true); gridLayout->addLayout(vboxLayout_1, 7, 0, 1, 1); gridLayout->addWidget(license, 7, 1, 1, 1); vboxLayout_2 = new QVBoxLayout(); - descriptionLabel = new QLabel(tr("Description:"), this); + descriptionLabel = new DLabel(tr("Description:"), this); descriptionLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); vboxLayout_2->addWidget(descriptionLabel); spacerItem_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); vboxLayout_2->addItem(spacerItem_2); - description = new QTextEdit(this); + description = new DTextEdit(this); description->setReadOnly(true); gridLayout->addLayout(vboxLayout_2, 8, 0, 1, 1); gridLayout->addWidget(description, 8, 1, 1, 1); vboxLayout_3 = new QVBoxLayout(); - dependenciesLabel = new QLabel(tr("Dependencies:"), this); + dependenciesLabel = new DLabel(tr("Dependencies:"), this); dependenciesLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse); vboxLayout_3->addWidget(dependenciesLabel); spacerItem_3 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); vboxLayout_3->addItem(spacerItem_3); - dependencies = new QListWidget(this); + dependencies = new DListWidget(this); gridLayout->addLayout(vboxLayout_3, 9, 0, 1, 1); gridLayout->addWidget(dependencies, 9, 1, 1, 1); } @@ -188,7 +193,7 @@ void DetailsView::update(dpf::PluginMetaObjectPointer plugin) } dependencies->addItems(dependsList); - connect(urlLink, &QLabel::linkActivated, [=](){ + connect(urlLink, &DLabel::linkActivated, [=](){ QDesktopServices::openUrl(QUrl(plugin->urlLink())); }); } diff --git a/src/plugins/core/mainframe/plugindialog.h b/src/plugins/core/mainframe/plugindialog.h index 51c1f238a..123fc0506 100644 --- a/src/plugins/core/mainframe/plugindialog.h +++ b/src/plugins/core/mainframe/plugindialog.h @@ -7,13 +7,18 @@ #include "framework/lifecycle/pluginmetaobject.h" -#include -#include +#include +#include +#include +#include +#include +#include + #include -#include -#include #include +DWIDGET_USE_NAMESPACE + class DetailsView; class QDialogButtonBox; class QLabel; @@ -22,7 +27,7 @@ namespace dpf { class PluginView; } -class PluginDialog : public QDialog +class PluginDialog : public DTK_WIDGET_NAMESPACE::DAbstractDialog { Q_OBJECT @@ -40,12 +45,12 @@ private slots: dpf::PluginView *view = nullptr; DetailsView *detailView = nullptr; - QDialogButtonBox *closeButton = nullptr; - QPushButton *detailsButton = nullptr; - QLabel *restratRequired = nullptr; + DDialogButtonBox *closeButton = nullptr; + DPushButton *detailsButton = nullptr; + DLabel *restratRequired = nullptr; }; -class DetailsView : public QWidget +class DetailsView : public DTK_WIDGET_NAMESPACE::DWidget { Q_OBJECT public: @@ -61,27 +66,27 @@ class DetailsView : public QWidget QSpacerItem *spacerItem_1 = nullptr; QSpacerItem *spacerItem_2 = nullptr; QSpacerItem *spacerItem_3 = nullptr; - QLabel *name = nullptr; - QLabel *version = nullptr; - QLabel *compatVersion = nullptr; - QLabel *vendor = nullptr; - QLabel *copyright = nullptr; - QLabel *category = nullptr; - QLabel *urlLink = nullptr; - QTextEdit *description = nullptr; - QTextEdit *license = nullptr; - QListWidget *dependencies = nullptr; - - QLabel *nameLabel = nullptr; - QLabel *versionLabel = nullptr; - QLabel *compatVersionLabel = nullptr; - QLabel *vendorLabel = nullptr; - QLabel *copyrightLabel = nullptr; - QLabel *categoryLabel = nullptr; - QLabel *urlLabel = nullptr; - QLabel *licenseLabel = nullptr; - QLabel *descriptionLabel = nullptr; - QLabel *dependenciesLabel = nullptr; + DLabel *name = nullptr; + DLabel *version = nullptr; + DLabel *compatVersion = nullptr; + DLabel *vendor = nullptr; + DLabel *copyright = nullptr; + DLabel *category = nullptr; + DLabel *urlLink = nullptr; + DTextEdit *description = nullptr; + DTextEdit *license = nullptr; + DListWidget *dependencies = nullptr; + + DLabel *nameLabel = nullptr; + DLabel *versionLabel = nullptr; + DLabel *compatVersionLabel = nullptr; + DLabel *vendorLabel = nullptr; + DLabel *copyrightLabel = nullptr; + DLabel *categoryLabel = nullptr; + DLabel *urlLabel = nullptr; + DLabel *licenseLabel = nullptr; + DLabel *descriptionLabel = nullptr; + DLabel *dependenciesLabel = nullptr; }; #endif // PLUGINDIALOG_H diff --git a/src/plugins/core/mainframe/progressbar.cpp b/src/plugins/core/mainframe/progressbar.cpp index 1f1092d99..0cd3629d6 100644 --- a/src/plugins/core/mainframe/progressbar.cpp +++ b/src/plugins/core/mainframe/progressbar.cpp @@ -7,6 +7,8 @@ #include #include +DWIDGET_USE_NAMESPACE + class ProgressBarPrivate { friend class ProgressBar; @@ -16,7 +18,7 @@ class ProgressBarPrivate }; ProgressBar::ProgressBar(QWidget *parent) - : QWidget(parent) + : DWidget(parent) , d(new ProgressBarPrivate) { setObjectName("ProgressBar"); diff --git a/src/plugins/core/mainframe/progressbar.h b/src/plugins/core/mainframe/progressbar.h index 5c38bd6c4..1a26c876b 100644 --- a/src/plugins/core/mainframe/progressbar.h +++ b/src/plugins/core/mainframe/progressbar.h @@ -5,10 +5,10 @@ #ifndef PROGRESSBAR_H #define PROGRESSBAR_H -#include +#include class ProgressBarPrivate; -class ProgressBar : public QWidget +class ProgressBar : public DTK_WIDGET_NAMESPACE::DWidget { Q_OBJECT ProgressBarPrivate *const d; diff --git a/src/plugins/core/mainframe/windowkeeper.cpp b/src/plugins/core/mainframe/windowkeeper.cpp index 12eb10b1c..896825089 100644 --- a/src/plugins/core/mainframe/windowkeeper.cpp +++ b/src/plugins/core/mainframe/windowkeeper.cpp @@ -11,16 +11,18 @@ #include "services/project/projectservice.h" #include "common/common.h" +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include #include -#include #include #include #include @@ -32,10 +34,11 @@ using namespace dpfservice; class WindowKeeperPrivate { WindowKeeperPrivate(); - QHash centrals{}; - QMainWindow *window{nullptr}; + QHash centrals{}; + DMainWindow *window{nullptr}; QActionGroup *navActionGroup{nullptr}; - QToolBar *toolbar{nullptr}; + DToolBar *toolbar{nullptr}; + DMenu *mainMenu{nullptr}; friend class WindowKeeper; }; @@ -45,76 +48,100 @@ WindowKeeperPrivate::WindowKeeperPrivate() } -void WindowKeeper::createFileActions(QMenuBar *menuBar) +void WindowKeeper::createFileActions(DMenu *menu) { qInfo() << __FUNCTION__; - QMenu* fileMenu = new QMenu(); - QAction* actionQuit = new QAction(MWMFA_QUIT); - ActionManager::getInstance()->registerAction(actionQuit, "File.Quit", - MWMFA_QUIT, QKeySequence(Qt::Modifier::CTRL | Qt::Key::Key_Q), - ":/core/images/quit.png"); - QAction::connect(actionQuit, &QAction::triggered, [](){ - qApp->closeAllWindows(); - }); - QAction* actionOpenFile = new QAction(MWMFA_OPEN_FILE); ActionManager::getInstance()->registerAction(actionOpenFile, "File.Open.File", - MWMFA_OPEN_FILE, QKeySequence(Qt::Modifier::CTRL | Qt::Key::Key_O), - ":/core/images/open_file.png"); + MWMFA_OPEN_FILE, QKeySequence(Qt::Modifier::CTRL | Qt::Key::Key_O)); QAction::connect(actionOpenFile, &QAction::triggered, [=](){ QString dir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); - QString filePath = QFileDialog::getOpenFileName(nullptr, DIALOG_OPEN_DOCUMENT_TITLE, dir); + QString filePath = DFileDialog::getOpenFileName(nullptr, DIALOG_OPEN_DOCUMENT_TITLE, dir); if (filePath.isEmpty() && !QFileInfo(filePath).exists()) return; recent.saveOpenedFile(filePath); editor.openFile(filePath); }); - QMenu* menuOpenProject = new QMenu(MWMFA_OPEN_PROJECT); - menuOpenProject->setIcon(QIcon(":/core/images/open_project.png")); + menu->addAction(actionOpenFile); + + DMenu* menuOpenProject = new DMenu(MWMFA_OPEN_PROJECT); + menu->addMenu(menuOpenProject); +} + +void WindowKeeper::createAnalyzeActions(DMenu *menu) +{ + qInfo() << __FUNCTION__; + DMenu* analyzeMenu = new DMenu(); + QAction* buildAction = menu->addMenu(analyzeMenu); + buildAction->setText(MWM_ANALYZE); +} - fileMenu->addAction(actionOpenFile); - fileMenu->addMenu(menuOpenProject); - fileMenu->addAction(actionQuit); - QAction* fileAction = menuBar->addMenu(fileMenu); - fileAction->setText(MWM_FILE); +void WindowKeeper::createBuildActions(DMenu *menu) +{ + qInfo() << __FUNCTION__; + DMenu* buildMenu = new DMenu(); + QAction* buildAction = menu->addMenu(buildMenu); + buildAction->setText(MWM_BUILD); +} + +void WindowKeeper::createDebugActions(DMenu *menu) +{ + qInfo() << __FUNCTION__; + QAction* debugAction = menu->addMenu(new DMenu()); + debugAction->setText(MWM_DEBUG); +} + +void WindowKeeper::createToolsActions(DMenu *menu) +{ + qInfo() << __FUNCTION__; + auto toolsMenu = new DMenu(MWM_TOOLS); + menu->addMenu(toolsMenu); +} + +void WindowKeeper::createHelpActions(DMenu *menu) +{ + qInfo() << __FUNCTION__; + auto helpMenu = new DMenu(MWM_HELP); + menu->addMenu(helpMenu); +======= } -void WindowKeeper::createAnalyzeActions(QMenuBar *menuBar) +void WindowKeeper::createAnalyzeActions(DMenuBar *menuBar) { qInfo() << __FUNCTION__; - QMenu* analyzeMenu = new QMenu(); + DMenu* analyzeMenu = new DMenu(); QAction* buildAction = menuBar->addMenu(analyzeMenu); buildAction->setText(MWM_ANALYZE); } -void WindowKeeper::createBuildActions(QMenuBar *menuBar) +void WindowKeeper::createBuildActions(DMenuBar *menuBar) { qInfo() << __FUNCTION__; - QMenu* buildMenu = new QMenu(); + DMenu* buildMenu = new DMenu(); QAction* buildAction = menuBar->addMenu(buildMenu); buildAction->setText(MWM_BUILD); } -void WindowKeeper::createDebugActions(QMenuBar *menuBar) +void WindowKeeper::createDebugActions(DMenuBar *menuBar) { qInfo() << __FUNCTION__; - QAction* debugAction = menuBar->addMenu(new QMenu()); + QAction* debugAction = menuBar->addMenu(new DMenu()); debugAction->setText(MWM_DEBUG); } -void WindowKeeper::createToolsActions(QMenuBar *menuBar) +void WindowKeeper::createToolsActions(DMenuBar *menuBar) { qInfo() << __FUNCTION__; - auto toolsMenu = new QMenu(MWM_TOOLS); + auto toolsMenu = new DMenu(MWM_TOOLS); menuBar->addMenu(toolsMenu); } -void WindowKeeper::createHelpActions(QMenuBar *menuBar) +void WindowKeeper::createHelpActions(DMenuBar *menuBar) { qInfo() << __FUNCTION__; - auto helpMenu = new QMenu(MWM_HELP); + auto helpMenu = new DMenu(MWM_HELP); menuBar->addMenu(helpMenu); QAction *actionReportBug = new QAction(MWM_REPORT_BUG); @@ -149,14 +176,14 @@ void WindowKeeper::createHelpActions(QMenuBar *menuBar) QAction::connect(actionAboutPlugin, &QAction::triggered, this, &WindowKeeper::showAboutPlugins); } -void WindowKeeper::createStatusBar(QMainWindow *window) +void WindowKeeper::createStatusBar(DMainWindow *window) { qInfo() << __FUNCTION__; - QStatusBar* statusBar = new WindowStatusBar(); + DStatusBar* statusBar = new WindowStatusBar(); window->setStatusBar(statusBar); } -void WindowKeeper::createNavRecent(QToolBar *toolbar) +void WindowKeeper::createNavRecent(DToolBar *toolbar) { qInfo() << __FUNCTION__; if (!toolbar) @@ -173,7 +200,7 @@ void WindowKeeper::createNavRecent(QToolBar *toolbar) toolbar->widgetForAction(navRecent)->setObjectName("Recent"); } -void WindowKeeper::createNavEdit(QToolBar *toolbar) +void WindowKeeper::createNavEdit(DToolBar *toolbar) { qInfo() << __FUNCTION__; if (!toolbar) @@ -190,14 +217,38 @@ void WindowKeeper::createNavEdit(QToolBar *toolbar) toolbar->widgetForAction(navEdit)->setObjectName("Edit"); } -void WindowKeeper::layoutWindow(QMainWindow *window) +void WindowKeeper::createMainMenu(DMenu *menu) +{ + qInfo() << __FUNCTION__; + + if (!menu) + return; + + createFileActions(menu); + menu->addSeparator(); + + createBuildActions(menu); + createDebugActions(menu); + menu->addSeparator(); + + createAnalyzeActions(menu); + createToolsActions(menu); + menu->addSeparator(); + + createHelpActions(menu); + + DMenu* menuOpenProject = new DMenu(MWMFA_OPEN_PROJECT); + menu->addMenu(menuOpenProject); +} + +void WindowKeeper::layoutWindow(DMainWindow *window) { qInfo() << __FUNCTION__; if (!d->navActionGroup) d->navActionGroup = new QActionGroup(window); - d->toolbar = new QToolBar(QToolBar::tr("Navigation")); - d->toolbar->setMovable(false); + d->toolbar = new DToolBar(DToolBar::tr("Navigation")); + d->toolbar->setMovable(true); d->toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); QWidget *titleWiget = new QWidget(); @@ -207,20 +258,21 @@ void WindowKeeper::layoutWindow(QMainWindow *window) createNavRecent(d->toolbar); createNavEdit(d->toolbar); - QMenuBar* menuBar = new QMenuBar(); - createFileActions(menuBar); - createBuildActions(menuBar); - createDebugActions(menuBar); - createAnalyzeActions(menuBar); - createToolsActions(menuBar); - createHelpActions(menuBar); + createMainMenu(d->mainMenu); createStatusBar(window); + window->setWindowTitle("Deepin Union Code"); + window->setWindowIcon(QIcon(":/core/images/unioncode@128.png")); window->addToolBar(Qt::LeftToolBarArea, d->toolbar); window->setMinimumSize(QSize(MW_MIN_WIDTH,MW_MIN_HEIGHT)); window->setAttribute(Qt::WA_DeleteOnClose); - window->setMenuBar(menuBar); + + window->titlebar()->setIcon(QIcon(":/core/images/unioncode@128.png")); + window->titlebar()->setTitle(QString(tr("Deepin Union Code"))); + window->titlebar()->setContentsMargins(0, 0, 0, 0); + + window->titlebar()->setMenu(d->mainMenu); } WindowKeeper *WindowKeeper::instace() @@ -242,10 +294,13 @@ WindowKeeper::WindowKeeper(QObject *parent) } if (!d->window) { - d->window = new QMainWindow(); - d->window->setWindowTitle("Deepin Union Code"); - d->window->setWindowIcon(QIcon(":/core/images/unioncode@128.png")); - QObject::connect(d->window, &QMainWindow::destroyed, [&](){ + d->window = new DMainWindow(); + + if (!d->mainMenu) { + d->mainMenu = new DMenu(d->window->titlebar()); + } + + QObject::connect(d->window, &DMainWindow::destroyed, [&](){ d->window->takeCentralWidget(); }); layoutWindow(d->window); @@ -334,20 +389,20 @@ void WindowKeeper::addMenu(AbstractMenu *menu) { qInfo() << __FUNCTION__; - QMenu *inputMenu = static_cast(menu->qMenu()); + DMenu *inputMenu = static_cast(menu->qMenu()); if (!d->window || !inputMenu) return; //始终将Helper置末 - for (QAction *action : d->window->menuBar()->actions()) { - if (action->text() == MWM_HELP) { - d->window->menuBar()->insertMenu(action, inputMenu); + for (QAction *action : d->mainMenu->actions()) { + if (action->text() == MWM_TOOLS) { + d->mainMenu->insertMenu(action, inputMenu); return; //提前返回 } } //直接添加到最后 - d->window->menuBar()->addMenu(inputMenu); + d->mainMenu->addMenu(inputMenu); } void WindowKeeper::insertAction(const QString &menuName, @@ -381,7 +436,16 @@ void WindowKeeper::addAction(const QString &menuName, AbstractAction *action) if (!action || !inputAction) return; - for (QAction *qAction : d->window->menuBar()->actions()) { + if (inputAction->text() == MWMFA_NEW_FILE_OR_PROJECT) { + for (QAction *qAction : d->mainMenu->actions()) { + if (qAction->text() == MWM_BUILD) { + d->mainMenu->insertAction(qAction, inputAction); + return; + } + } + } + + for (QAction *qAction : d->mainMenu->actions()) { if (qAction->text() == menuName) { if (qAction->text() == MWM_FILE) { auto endAction = *(qAction->menu()->actions().rbegin()); @@ -414,22 +478,19 @@ void WindowKeeper::addOpenProjectAction(const QString &name, AbstractAction *act return; QAction *inputAction = static_cast(action->qAction()); - for (QAction *qAction : d->window->menuBar()->actions()) { - if (qAction->text() == MWM_FILE) { - for(QAction *childAction : qAction->menu()->actions()) { - if (childAction->text() == MWMFA_OPEN_PROJECT) { - for (auto langAction : childAction->menu()->menuAction()->menu()->actions()) { - if (name == langAction->text()) { - langAction->menu()->addAction(inputAction); - return; - } - } - auto langMenu = new QMenu(name); - childAction->menu()->addMenu(langMenu); - langMenu->addAction(inputAction); + + foreach (QAction *action, d->mainMenu->actions()) { + if (action->text() == MWMFA_OPEN_PROJECT) { + for (auto langAction : action->menu()->menuAction()->menu()->actions()) { + if (name == langAction->text()) { + langAction->menu()->addAction(inputAction); return; } } + auto langMenu = new DMenu(name); + action->menu()->addMenu(langMenu); + langMenu->addAction(inputAction); + return; } } } @@ -437,6 +498,9 @@ void WindowKeeper::addOpenProjectAction(const QString &name, AbstractAction *act void WindowKeeper::initUserWidget() { qApp->processEvents(); + if (!d->toolbar) + return; + if (d->toolbar->actions().size() > 0) { d->toolbar->actions().at(0)->trigger(); } diff --git a/src/plugins/core/mainframe/windowkeeper.h b/src/plugins/core/mainframe/windowkeeper.h index e5378e74b..74cbdf417 100644 --- a/src/plugins/core/mainframe/windowkeeper.h +++ b/src/plugins/core/mainframe/windowkeeper.h @@ -15,8 +15,16 @@ #include +#include +#include +#include +#include + #include +DWIDGET_USE_NAMESPACE +DCORE_USE_NAMESPACE + class QAction; class QMainWindow; class QStatusBar; @@ -52,17 +60,28 @@ public slots: private : void showAboutDlg(); void showAboutPlugins(); - void layoutWindow(QMainWindow *window); - void createNavEdit(QToolBar *toolbar); - void createNavRecent(QToolBar *toolbar); - void createStatusBar(QMainWindow *window); - void createHelpActions(QMenuBar *menuBar); - void createToolsActions(QMenuBar *menuBar); - void createDebugActions(QMenuBar *menuBar); - void createBuildActions(QMenuBar *menuBar); - void createFileActions(QMenuBar *menuBar); - void createAnalyzeActions(QMenuBar *menuBar); + void layoutWindow(DMainWindow *window); + void createNavEdit(DToolBar *toolbar); + void createNavRecent(DToolBar *toolbar); + void createStatusBar(DMainWindow *window); + + void createHelpActions(DMenu *menu); + void createToolsActions(DMenu *menu); + void createDebugActions(DMenu *menu); + void createBuildActions(DMenu *menu); + void createFileActions(DMenu *menu); + void createAnalyzeActions(DMenu *menu); + + void createHelpActions(DMenuBar *menuBar); + void createToolsActions(DMenuBar *menuBar); + void createDebugActions(DMenuBar *menuBar); + void createBuildActions(DMenuBar *menuBar); + void createFileActions(DMenu *menu); + void createAnalyzeActions(DMenuBar *menuBar); + void setNavActionChecked(const QString &actionName, bool checked); + + void createMainMenu(DMenu *mainMenu); }; #endif // WINDOWKEEPER_H diff --git a/src/plugins/core/mainframe/windowstatusbar.cpp b/src/plugins/core/mainframe/windowstatusbar.cpp index 52078b546..9023e6fe6 100644 --- a/src/plugins/core/mainframe/windowstatusbar.cpp +++ b/src/plugins/core/mainframe/windowstatusbar.cpp @@ -6,6 +6,8 @@ #include "progressbar.h" #include "common/common.h" +DWIDGET_USE_NAMESPACE + class WindowStatusBarPrivate { friend class WindowStatusBar; @@ -14,7 +16,7 @@ class WindowStatusBarPrivate }; WindowStatusBar::WindowStatusBar(QWidget *parent) - : QStatusBar(parent) + : DStatusBar(parent) , d(new WindowStatusBarPrivate()) { d->progressBar = new ProgressBar; diff --git a/src/plugins/core/mainframe/windowstatusbar.h b/src/plugins/core/mainframe/windowstatusbar.h index d2f638dd9..d005df350 100644 --- a/src/plugins/core/mainframe/windowstatusbar.h +++ b/src/plugins/core/mainframe/windowstatusbar.h @@ -5,10 +5,10 @@ #ifndef WINDOWSTATUSBAR_H #define WINDOWSTATUSBAR_H -#include +#include class WindowStatusBarPrivate; -class WindowStatusBar : public QStatusBar +class WindowStatusBar : public DTK_WIDGET_NAMESPACE::DStatusBar { Q_OBJECT WindowStatusBarPrivate *const d; diff --git a/src/plugins/core/mainframe/windowtheme.cpp b/src/plugins/core/mainframe/windowtheme.cpp deleted file mode 100644 index 7b8a6fd48..000000000 --- a/src/plugins/core/mainframe/windowtheme.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#include "windowtheme.h" - -#include -#include -#include - -void WindowTheme::setTheme(const QString &file) -{ - QFile qssFile(file); - if (!qssFile.open(QFile::ReadOnly)) { - qCritical()<< "Failed can't open qss file" << file; - return; - } - qApp->setStyleSheet(qssFile.readAll()); -} diff --git a/src/plugins/core/mainframe/windowtheme.h b/src/plugins/core/mainframe/windowtheme.h deleted file mode 100644 index 1fd33b243..000000000 --- a/src/plugins/core/mainframe/windowtheme.h +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. -// -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef WINDOWTHEME_H -#define WINDOWTHEME_H - -#include - -class WindowTheme -{ -public: - WindowTheme() = delete; - static void setTheme(const QString &file); -}; - -#endif // WINDOWTHEME_H diff --git a/src/plugins/template/CMakeLists.txt b/src/plugins/template/CMakeLists.txt index c263eb05a..d82b69e60 100644 --- a/src/plugins/template/CMakeLists.txt +++ b/src/plugins/template/CMakeLists.txt @@ -35,6 +35,7 @@ target_link_libraries(${PROJECT_NAME} common ${QtUseModules} ${PkgUserModules} + ${DtkWidget_LIBRARIES} ) install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH}) diff --git a/src/plugins/template/templatemanager.cpp b/src/plugins/template/templatemanager.cpp index 54ab03ac2..23e1910fa 100644 --- a/src/plugins/template/templatemanager.cpp +++ b/src/plugins/template/templatemanager.cpp @@ -53,13 +53,13 @@ void TemplateManager::addMenu() auto actionInit = [&](QAction *action, QString actionID, QKeySequence key, QString iconFileName){ ActionManager::getInstance()->registerAction(action, actionID, action->text(), key, iconFileName); AbstractAction *actionImpl = new AbstractAction(action); - windowService->addAction(dpfservice::MWM_FILE, actionImpl); + windowService->addAction(dpfservice::MWMFA_NEW_FILE_OR_PROJECT, actionImpl); }; d->newAction.reset(new QAction(MWMFA_NEW_FILE_OR_PROJECT)); actionInit(d->newAction.get(), "Fiel.New.FileOrProject", - QKeySequence(Qt::Modifier::CTRL | Qt::Modifier::SHIFT | Qt::Key::Key_O), ":/template/images/new_project.png"); + QKeySequence(Qt::Modifier::CTRL | Qt::Modifier::SHIFT | Qt::Key::Key_O), QString()); QObject::connect(d->newAction.get(), &QAction::triggered, this, &TemplateManager::newWizard, Qt::DirectConnection); } diff --git a/src/plugins/template/wizard/detailwidget.cpp b/src/plugins/template/wizard/detailwidget.cpp index 0fc83a64a..f0b4ad063 100644 --- a/src/plugins/template/wizard/detailwidget.cpp +++ b/src/plugins/template/wizard/detailwidget.cpp @@ -7,58 +7,61 @@ #include "common/util/custompaths.h" -#include +#include +#include +#include +#include +#include +#include + #include #include -#include -#include -#include -#include -#include + +DWIDGET_USE_NAMESPACE class DetailWidgetPrivate { friend class DetailWidget; QString templatePath; - QMap lineEditMap; - QMap comboBoxMap; + QMap lineEditMap; + QMap comboBoxMap; WizardInfo wizardInfo; }; DetailWidget::DetailWidget(QWidget *parent) - : QScrollArea(parent) + : DScrollArea(parent) , d(new DetailWidgetPrivate()) { } DetailWidget::DetailWidget(const QString &templatePath, QWidget *parent) - : QScrollArea(parent) + : DScrollArea(parent) , d(new DetailWidgetPrivate()) { d->templatePath = templatePath; if (!TemplateParser::readWizardConfig(d->templatePath, d->wizardInfo)) return; - QWidget *widget = new QWidget(); + DWidget *widget = new DWidget(); QVBoxLayout *vLayout = new QVBoxLayout(); widget->setLayout(vLayout); - QLabel *titleLabel = new QLabel(d->wizardInfo.trDisplayName); + DLabel *titleLabel = new DLabel(d->wizardInfo.trDisplayName); vLayout->addWidget(titleLabel); vLayout->addSpacing(10); auto iter = d->wizardInfo.configures.begin(); for (; iter != d->wizardInfo.configures.end(); ++iter) { QHBoxLayout *hLayout = new QHBoxLayout(); - QLabel *label = new QLabel(iter->displayName + ":"); + DLabel *label = new DLabel(iter->displayName + ":"); label->setFixedSize(120, 30); hLayout->addWidget(label, 0, Qt::AlignLeft); hLayout->setStretchFactor(label, 1); if ("lineEdit" == iter->type) { - QLineEdit *lineEdit = new QLineEdit(); + DLineEdit *lineEdit = new DLineEdit(); if (!iter->defaultValues.isEmpty()) { lineEdit->setText(iter->defaultValues.at(0)); } @@ -68,15 +71,15 @@ DetailWidget::DetailWidget(const QString &templatePath, QWidget *parent) d->lineEditMap.insert(iter->key, lineEdit); if (iter->browse) { lineEdit->setFixedSize(300, 30); - lineEdit->setReadOnly(true); + lineEdit->lineEdit()->setReadOnly(true); - QPushButton *browse = new QPushButton(tr("Browse...")); + DPushButton *browse = new DPushButton(tr("Browse...")); browse->setFixedSize(100, 30); hLayout->addWidget(browse, 0, Qt::AlignRight); hLayout->setStretchFactor(browse, 1); - connect(browse, &QPushButton::clicked, [=]() { - QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), QDir::homePath()); + connect(browse, &DPushButton::clicked, [=]() { + QString path = DFileDialog::getExistingDirectory(this, tr("Choose path"), QDir::homePath()); if (!path.isEmpty()) { lineEdit->setText(path); } @@ -85,7 +88,7 @@ DetailWidget::DetailWidget(const QString &templatePath, QWidget *parent) lineEdit->setFixedSize(400, 30); } } else if ("comboBox" == iter->type) { - QComboBox *comboBox = new QComboBox(); + DComboBox *comboBox = new DComboBox(); comboBox->setFixedSize(400, 30); hLayout->addWidget(comboBox, 0, Qt::AlignLeft); hLayout->setStretchFactor(comboBox, 3); @@ -115,7 +118,7 @@ bool DetailWidget::getGenParams(PojectGenParam ¶m) auto lineEdit = d->lineEditMap.value(key); if (lineEdit->text().trimmed().isEmpty()) { - QMessageBox::critical(this, "tip", "The value of " + key + " is empty"); + DMessageBox::critical(this, "tip", "The value of " + key + " is empty"); return false; } diff --git a/src/plugins/template/wizard/detailwidget.h b/src/plugins/template/wizard/detailwidget.h index 8166d03f6..22d75db89 100644 --- a/src/plugins/template/wizard/detailwidget.h +++ b/src/plugins/template/wizard/detailwidget.h @@ -7,12 +7,12 @@ #include "projectgenerate.h" -#include +#include using namespace templateMgr; class DetailWidgetPrivate; -class DetailWidget : public QScrollArea +class DetailWidget : public DTK_WIDGET_NAMESPACE::DScrollArea { Q_OBJECT public: diff --git a/src/plugins/template/wizard/maindialog.cpp b/src/plugins/template/wizard/maindialog.cpp index 341fc63bb..dfc2007bf 100644 --- a/src/plugins/template/wizard/maindialog.cpp +++ b/src/plugins/template/wizard/maindialog.cpp @@ -8,17 +8,23 @@ #include "services/language/languageservice.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include + +#include #include #include -#include #include +#include #include #include +DWIDGET_USE_NAMESPACE using namespace dpfservice; class MainDialogPrivate @@ -26,14 +32,13 @@ class MainDialogPrivate friend class MainDialog; QMap detailWidgetMap; QStackedWidget *detailStackedWidget = nullptr; - QWidget *blankWidget = nullptr; + DWidget *blankWidget = nullptr; }; -MainDialog::MainDialog(QDialog *parent) - : QDialog(parent) +MainDialog::MainDialog(QWidget *parent) + : DAbstractDialog(parent) , d(new MainDialogPrivate()) { - setWindowTitle(tr("New File or Project")); setMinimumSize(850, 550); TemplateVector templateVec; @@ -50,13 +55,18 @@ MainDialog::~MainDialog() void MainDialog::setupUI(TemplateVector &templateVec) { - QLabel * title = new QLabel(tr("Choose a template:")); + DTitlebar *titleBar = new DTitlebar(); + titleBar = new DTitlebar(); + titleBar->setMenuVisible(false); + titleBar->setTitle(QString(tr("New File or Project"))); + + DLabel *title = new DLabel(tr("Choose a template:")); d->detailStackedWidget = new QStackedWidget(); d->blankWidget = new DetailWidget(this); d->detailStackedWidget->addWidget(d->blankWidget); - QTreeView * treeView = new QTreeView(); + DTreeView * treeView = new DTreeView(); treeView->setEditTriggers(QAbstractItemView::NoEditTriggers); treeView->setSelectionMode(QAbstractItemView::SingleSelection); treeView->setSelectionBehavior(QAbstractItemView::SelectItems); @@ -92,7 +102,7 @@ void MainDialog::setupUI(TemplateVector &templateVec) treeView->setModel(standardModel); } - connect(treeView, &QTreeView::clicked, [=](){ + connect(treeView, &DTreeView::clicked, [=](){ QModelIndex index = treeView->selectionModel()->currentIndex(); if (!index.isValid()){ d->detailStackedWidget->setCurrentWidget(d->blankWidget); @@ -134,7 +144,7 @@ void MainDialog::setupUI(TemplateVector &templateVec) QVBoxLayout *vItemLayout = new QVBoxLayout(); vItemLayout->addWidget(treeView); - QWidget *contentWidget = new QWidget(); + DWidget *contentWidget = new DWidget(); QHBoxLayout *hLayout = new QHBoxLayout(); contentWidget->setLayout(hLayout); hLayout->addLayout(vItemLayout); @@ -142,17 +152,17 @@ void MainDialog::setupUI(TemplateVector &templateVec) hLayout->setStretchFactor(vItemLayout, 1); hLayout->setStretchFactor(d->detailStackedWidget, 2); - QWidget *bottomWidget = new QWidget(); + DWidget *bottomWidget = new DWidget(); QHBoxLayout * bottomLayout = new QHBoxLayout(); bottomWidget->setLayout(bottomLayout); - QPushButton *create = new QPushButton(tr("Create")); - QPushButton *cancel = new QPushButton(tr("Cancel")); + DPushButton *create = new DPushButton(tr("Create")); + DPushButton *cancel = new DPushButton(tr("Cancel")); bottomLayout->addStretch(15); bottomLayout->addWidget(create, Qt::AlignRight); bottomLayout->addWidget(cancel, Qt::AlignRight); - connect(create, &QPushButton::clicked, [&](){ + connect(create, &DPushButton::clicked, [&](){ DetailWidget *detailWidget = dynamic_cast(d->detailStackedWidget->currentWidget()); if (detailWidget) { PojectGenParam param; @@ -162,11 +172,15 @@ void MainDialog::setupUI(TemplateVector &templateVec) } }); - connect(cancel, &QPushButton::clicked, [&](){ + connect(cancel, &DPushButton::clicked, [&](){ close(); }); QVBoxLayout *vLayout = new QVBoxLayout(); + vLayout->setContentsMargins(0, 0, 0, 0); + vLayout->setSpacing(0); + + vLayout->addWidget(titleBar); vLayout->addWidget(title); vLayout->addWidget(contentWidget); vLayout->addWidget(bottomWidget); @@ -179,7 +193,7 @@ void MainDialog::generate(const PojectGenParam ¶m) ProjectGenerate projectGen; PojectGenResult result; if (!projectGen.create(result, param)) { - QMessageBox::critical(this, tr("Tip"), result.message); + DMessageBox::critical(this, tr("Tip"), result.message); return; } @@ -192,7 +206,7 @@ void MainDialog::generate(const PojectGenParam ¶m) close(); project.openProject(result.kit, result.language, result.projectPath); } else { - QMessageBox::critical(this, tr("Tip"), tr("Can not find kit.")); + DMessageBox::critical(this, tr("Tip"), tr("Can not find kit.")); } } } else if (param.type == File) { diff --git a/src/plugins/template/wizard/maindialog.h b/src/plugins/template/wizard/maindialog.h index 552cdb3af..5123b41b8 100644 --- a/src/plugins/template/wizard/maindialog.h +++ b/src/plugins/template/wizard/maindialog.h @@ -6,16 +6,16 @@ #define MAINDIALOG_H #include "projectgenerate.h" -#include +#include using namespace templateMgr; class MainDialogPrivate; -class MainDialog : public QDialog +class MainDialog : public DTK_WIDGET_NAMESPACE::DAbstractDialog { Q_OBJECT public: - explicit MainDialog(QDialog *parent = nullptr); + explicit MainDialog(QWidget *parent = nullptr); ~MainDialog(); signals: