diff --git a/assets/translations/en_US.ts b/assets/translations/en_US.ts index d58ae0591..f19a0f37f 100644 --- a/assets/translations/en_US.ts +++ b/assets/translations/en_US.ts @@ -4,20 +4,30 @@ AboutDialog - + About Deepin Union Code - + <br/>Built on %1 %2 in %3<br/> - + <h3>Deepin Union Code %1</h3>%2<br/>Copyright 2019-%3 UnionTech Software Technology Co., Ltd. All rights reserved.<br/><br/>This program is released under <a href="https://www.gnu.org/licenses/gpl-3.0.html">GPL-3.0-or-later</a>; we hope that the scheme will be useful, but we do not guarantee that it will be of economic value or fit for a particular purpose. For more information, see the GNU General Public License. <br/> Thanks to all the <a href="opensourcesoftware">open source software</a> used.<br/> + + + Error + + + + + Failed to open the file. + + AppOutputPane @@ -762,6 +772,22 @@ The dap port is not ready, please retry. + + DPushButton + + + Close + + + + + DToolBar + + + Navigation + + + DebuggerPlugin @@ -783,12 +809,12 @@ The dap port is not ready, please retry. DetailWidget - + Browse... - + Choose path @@ -804,52 +830,52 @@ The dap port is not ready, please retry. DetailsView - + Name: - + Version: - + Compatibility version: - + Vendor: - + Copyright: - + Category: - + URL: - + Description: - + License: - + Dependencies: @@ -857,7 +883,7 @@ The dap port is not ready, please retry. DisplayDocView - + Documents @@ -865,7 +891,7 @@ The dap port is not ready, please retry. DisplayProView - + Projects @@ -1178,38 +1204,38 @@ repos path: %0 MainDialog - + New File or Project - + Choose a template: - + Templates - + Create - + Cancel - - + + Tip - + Can not find kit. @@ -1370,17 +1396,17 @@ repos path: %0 PluginDialog - + Installed Plugins - + Close - + Restart required. @@ -2451,11 +2477,6 @@ storage: %2 Revert All - - - Close - - Find Previous @@ -2550,11 +2571,6 @@ storage: %2 QToolBar - - - Navigation - - Start @@ -2641,12 +2657,32 @@ Delete anyway? RecentDisplay - + + Open File + + + + + Open Project + + + + + New File or Project + + + + + Recent Open + + + + Documents - + Projects @@ -3354,6 +3390,14 @@ Delete anyway? + + WindowKeeper + + + Deepin Union Code + + + XmlStreamReader diff --git a/assets/translations/zh_CN.ts b/assets/translations/zh_CN.ts index e19e0d4ab..36cfea642 100644 --- a/assets/translations/zh_CN.ts +++ b/assets/translations/zh_CN.ts @@ -4,20 +4,30 @@ AboutDialog - + About Deepin Union Code 关于Deepin Union Code - + <br/>Built on %1 %2 in %3<br/> 创建于%1 %2, %3平台 - + <h3>Deepin Union Code %1</h3>%2<br/>Copyright 2019-%3 UnionTech Software Technology Co., Ltd. All rights reserved.<br/><br/>This program is released under <a href="https://www.gnu.org/licenses/gpl-3.0.html">GPL-3.0-or-later</a>; we hope that the scheme will be useful, but we do not guarantee that it will be of economic value or fit for a particular purpose. For more information, see the GNU General Public License. <br/> Thanks to all the <a href="opensourcesoftware">open source software</a> used.<br/> <h3>Deepin Union Code%1</h3>%2<br/>版权 2019-%3 统信软件技术有限公司所有<br/><br/>本程序基于<a href="https://www.gnu.org/licenses/gpl-3.0.html">GPL-3.0-or-later</a>发布;我们希望发布的这款程序有用,但不提供保证,甚至不保证它有经济价值和适合特定用途。详情参见GNU通用公共许可协议。<br/> 致谢所有用到的<a href="opensourcesoftware">开源软件</a>。 + + + Error + 错误 + + + + Failed to open the file. + + AppOutputPane @@ -786,6 +796,22 @@ dap端口未就绪,请重试。 coredump文件错误: + + DPushButton + + + Close + 关闭 + + + + DToolBar + + + Navigation + 导航栏 + + DebuggerPlugin @@ -807,12 +833,12 @@ dap端口未就绪,请重试。 DetailWidget - + Browse... 浏览... - + Choose path 选择路径 @@ -828,52 +854,52 @@ dap端口未就绪,请重试。 DetailsView - + Name: 名称: - + Version: 版本: - + Compatibility version: 兼容版本: - + Vendor: 供应商: - + Copyright: 版权: - + Category: 插件类别: - + URL: URL: - + Description: 说明: - + License: 许可: - + Dependencies: 依赖关系: @@ -881,7 +907,7 @@ dap端口未就绪,请重试。 DisplayDocView - + Documents 文件 @@ -889,7 +915,7 @@ dap端口未就绪,请重试。 DisplayProView - + Projects 工程 @@ -1016,7 +1042,7 @@ dap端口未就绪,请重试。 The path of "%1" is not exist! please check and reopen the project. - "%1" 路径不存在! + "%1" 路径不存在!请检查并重新打开项目。 @@ -1203,38 +1229,38 @@ repos path: %0 MainDialog - + New File or Project 新建文件或工程 - + Choose a template: 选择一个模板: - + Templates 模板 - + Create 创建 - + Cancel 取消 - - + + Tip 提示 - + Can not find kit. 找不到配套工具。 @@ -1395,17 +1421,17 @@ repos path: %0 PluginDialog - + Installed Plugins 已安装的插件 - + Close 关闭 - + Restart required. 需要重启。 @@ -2486,11 +2512,6 @@ storage: %2 Revert All 全部还原 - - - Close - 关闭 - Find Previous @@ -2585,11 +2606,6 @@ storage: %2 QToolBar - - - Navigation - 导航栏 - Start @@ -2677,12 +2693,32 @@ Delete anyway? RecentDisplay - + + Open File + 打开文件 + + + + Open Project + 打开工程 + + + + New File or Project + 新建文件或工程 + + + + Recent Open + 最近打开 + + + Documents 文件 - + Projects 工程 @@ -3396,6 +3432,14 @@ Delete anyway? 应用程序输出(&A) + + WindowKeeper + + + Deepin Union Code + + + XmlStreamReader diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 315504680..e491afaaa 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -35,4 +35,9 @@ add_library( ${CXX_CPP} ) +target_link_libraries( + ${PROJECT_NAME} + ${DtkWidget_LIBRARIES} + ) + install(TARGETS ${PROJECT_NAME} DESTINATION ${LIBRARY_INSTALL_PREFIX}) diff --git a/src/base/abstractcentral.cpp b/src/base/abstractcentral.cpp index 2a787c966..9173a5cc3 100644 --- a/src/base/abstractcentral.cpp +++ b/src/base/abstractcentral.cpp @@ -4,13 +4,16 @@ #include "abstractcentral.h" +#include + #include -#include + +DWIDGET_USE_NAMESPACE class AbstractCentralPrivate { friend class AbstractCentral; - QWidget *widget; + DWidget *widget; }; AbstractCentral::AbstractCentral(void *qwidget) @@ -21,8 +24,8 @@ AbstractCentral::AbstractCentral(void *qwidget) abort(); } - d->widget = static_cast(qwidget); - QWidget::connect(d->widget, &QWidget::destroyed, + d->widget = static_cast(qwidget); + DWidget::connect(d->widget, &DWidget::destroyed, d->widget, [this](){ delete this; }, Qt::UniqueConnection); diff --git a/src/common/util/eventdefinitions.h b/src/common/util/eventdefinitions.h index 4f49bec5d..73202e81b 100644 --- a/src/common/util/eventdefinitions.h +++ b/src/common/util/eventdefinitions.h @@ -84,6 +84,10 @@ OPI_OBJECT(commandLine, OPI_INTERFACE(build) ) +OPI_OBJECT(projectTemplate, + OPI_INTERFACE(newWizard) + ) + struct AnnotationInfo { struct RoleElem diff --git a/src/plugins/collaborators/collaborators.cpp b/src/plugins/collaborators/collaborators.cpp index b2bcaa959..37dc62b93 100644 --- a/src/plugins/collaborators/collaborators.cpp +++ b/src/plugins/collaborators/collaborators.cpp @@ -21,8 +21,8 @@ bool Collaborators::start() WindowService *windowService = ctx.service(WindowService::name()); if (windowService) { if (windowService->addActionNavigation) { - windowService->addActionNavigation("Git", new AbstractAction(new QAction(QIcon(":/core/images/git.png"), QAction::tr("Git")))); - windowService->addActionNavigation("Svn", new AbstractAction(new QAction(QIcon(":/core/images/subversion.png"), QAction::tr("Svn")))); + windowService->addActionNavigation("Git", new AbstractAction(new QAction(QIcon::fromTheme("git"), QAction::tr("Git")))); + windowService->addActionNavigation("Svn", new AbstractAction(new QAction(QIcon::fromTheme("svn"), QAction::tr("Svn")))); } if (windowService->addCentralNavigation) { windowService->addCentralNavigation("Git", diff --git a/src/plugins/core/builtin/actions/edit_20px.svg b/src/plugins/core/builtin/actions/edit_20px.svg new file mode 100644 index 000000000..1e52f550f --- /dev/null +++ b/src/plugins/core/builtin/actions/edit_20px.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar / edit + + + + \ No newline at end of file diff --git a/src/plugins/core/builtin/actions/git_20px.svg b/src/plugins/core/builtin/actions/git_20px.svg new file mode 100644 index 000000000..5acdb4766 --- /dev/null +++ b/src/plugins/core/builtin/actions/git_20px.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar / Git + + + + \ No newline at end of file diff --git a/src/plugins/core/builtin/actions/recent_20px.svg b/src/plugins/core/builtin/actions/recent_20px.svg new file mode 100644 index 000000000..8dadf5c28 --- /dev/null +++ b/src/plugins/core/builtin/actions/recent_20px.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar / history + + + + \ No newline at end of file diff --git a/src/plugins/core/builtin/actions/svn_20px.svg b/src/plugins/core/builtin/actions/svn_20px.svg new file mode 100644 index 000000000..d93c26839 --- /dev/null +++ b/src/plugins/core/builtin/actions/svn_20px.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar /svn + + + + \ No newline at end of file diff --git a/src/plugins/core/core.qrc b/src/plugins/core/core.qrc index 52e709a79..37e9a1573 100644 --- a/src/plugins/core/core.qrc +++ b/src/plugins/core/core.qrc @@ -46,8 +46,6 @@ images/unioncode@200.png images/debug-step-into.png images/verticalSplit.png - images/edit.png - images/recent.png images/git.png images/subversion.png images/debugger_continue.png @@ -71,5 +69,16 @@ images/open_project.png images/reverse.png images/down_arrow.png + images/recent.svg + images/svn.svg + images/edit.svg + images/git.svg + + + builtin/actions/recent_20px.svg + builtin/actions/svn_20px.svg + builtin/actions/edit_20px.svg + builtin/actions/git_20px.svg + diff --git a/src/plugins/core/images/edit.png b/src/plugins/core/images/edit.png deleted file mode 100644 index 7ad964053..000000000 Binary files a/src/plugins/core/images/edit.png and /dev/null differ diff --git a/src/plugins/core/images/edit.svg b/src/plugins/core/images/edit.svg new file mode 100644 index 000000000..1e52f550f --- /dev/null +++ b/src/plugins/core/images/edit.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar / edit + + + + \ No newline at end of file diff --git a/src/plugins/core/images/git.svg b/src/plugins/core/images/git.svg new file mode 100644 index 000000000..5acdb4766 --- /dev/null +++ b/src/plugins/core/images/git.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar / Git + + + + \ No newline at end of file diff --git a/src/plugins/core/images/recent.png b/src/plugins/core/images/recent.png deleted file mode 100644 index 2c2c36912..000000000 Binary files a/src/plugins/core/images/recent.png and /dev/null differ diff --git a/src/plugins/core/images/recent.svg b/src/plugins/core/images/recent.svg new file mode 100644 index 000000000..8dadf5c28 --- /dev/null +++ b/src/plugins/core/images/recent.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar / history + + + + \ No newline at end of file diff --git a/src/plugins/core/images/svn.svg b/src/plugins/core/images/svn.svg new file mode 100644 index 000000000..d93c26839 --- /dev/null +++ b/src/plugins/core/images/svn.svg @@ -0,0 +1,7 @@ + + + ICON / sidebar /svn + + + + \ No newline at end of file diff --git a/src/plugins/core/mainframe/windowkeeper.cpp b/src/plugins/core/mainframe/windowkeeper.cpp index 91faafe09..6a618e7f1 100644 --- a/src/plugins/core/mainframe/windowkeeper.cpp +++ b/src/plugins/core/mainframe/windowkeeper.cpp @@ -17,8 +17,9 @@ #include #include #include +#include -#include +#include #include #include #include @@ -151,7 +152,7 @@ void WindowKeeper::createNavRecent(DToolBar *toolbar) if (!toolbar) return; - QAction* navRecent = new QAction(QIcon(":/core/images/recent.png"), MWNA_RECENT, toolbar); + QAction* navRecent = new QAction(QIcon::fromTheme("recent"), MWNA_RECENT, toolbar); navRecent->setCheckable(true); d->navActionGroup->addAction(navRecent); QAction::connect(navRecent, &QAction::triggered, [=](){ @@ -168,7 +169,7 @@ void WindowKeeper::createNavEdit(DToolBar *toolbar) if (!toolbar) return; - QAction* navEdit = new QAction(QIcon(":/core/images/edit.png"), MWNA_EDIT, toolbar); + QAction* navEdit = new QAction(QIcon::fromTheme("edit"), MWNA_EDIT, toolbar); navEdit->setCheckable(true); d->navActionGroup->addAction(navEdit); QAction::connect(navEdit, &QAction::triggered, [=](){ @@ -200,6 +201,7 @@ void WindowKeeper::createMainMenu(DMenu *menu) createHelpActions(menu); } +#include void WindowKeeper::layoutWindow(DMainWindow *window) { qInfo() << __FUNCTION__; @@ -208,9 +210,20 @@ void WindowKeeper::layoutWindow(DMainWindow *window) d->toolbar = new DToolBar(DToolBar::tr("Navigation")); d->toolbar->setMovable(true); - d->toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + d->toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly); + d->toolbar->setIconSize(QSize(20, 20)); + DPalette palette = window->palette(); + palette.setColor(DPalette::Button, palette.color(DPalette::Window)); + d->toolbar->setPalette(palette); + + QObject::connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, + this, [=](){ + DPalette palette = d->toolbar->palette(); + palette.setColor(DPalette::Button, palette.color(DPalette::Window)); + d->toolbar->setPalette(palette); + }); - QWidget *titleWiget = new QWidget(); + DWidget *titleWiget = new DWidget(); titleWiget->setFixedSize(65, 29); d->toolbar->addWidget(titleWiget); @@ -219,7 +232,7 @@ void WindowKeeper::layoutWindow(DMainWindow *window) createMainMenu(d->mainMenu); - createStatusBar(window); + //createStatusBar(window); window->setWindowTitle("Deepin Union Code"); window->setWindowIcon(QIcon(":/core/images/unioncode@128.png")); @@ -333,7 +346,7 @@ void WindowKeeper::addActionNavigation(const QString &id, AbstractAction *action void WindowKeeper::addCentralNavigation(const QString &navName, AbstractCentral *central) { qInfo() << __FUNCTION__; - QWidget* inputWidget = static_cast(central->qWidget()); + DWidget* inputWidget = static_cast(central->qWidget()); if(!central || !inputWidget || navName.isEmpty()) return; diff --git a/src/plugins/recent/CMakeLists.txt b/src/plugins/recent/CMakeLists.txt index d5cbaccfa..c474908a5 100644 --- a/src/plugins/recent/CMakeLists.txt +++ b/src/plugins/recent/CMakeLists.txt @@ -23,6 +23,7 @@ add_library(${PROJECT_NAME} SHARED ${CXX_CPP} ${CXX_H} + recent.qrc ) target_link_libraries(${PROJECT_NAME} @@ -31,6 +32,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/recent/images/recentLogo1.png b/src/plugins/recent/images/recentLogo1.png new file mode 100644 index 000000000..4528211c9 Binary files /dev/null and b/src/plugins/recent/images/recentLogo1.png differ diff --git a/src/plugins/recent/images/recentLogo2.png b/src/plugins/recent/images/recentLogo2.png new file mode 100644 index 000000000..da2e2a842 Binary files /dev/null and b/src/plugins/recent/images/recentLogo2.png differ diff --git a/src/plugins/recent/mainframe/displayitemdelegate.cpp b/src/plugins/recent/mainframe/displayitemdelegate.cpp index ff4beefc1..453cfe513 100644 --- a/src/plugins/recent/mainframe/displayitemdelegate.cpp +++ b/src/plugins/recent/mainframe/displayitemdelegate.cpp @@ -4,13 +4,20 @@ #include "displayitemdelegate.h" +#include +#include +#include +#include +#include +#include + #include #include #include #include -DisplayItemDelegate::DisplayItemDelegate(QObject *parent) - : QStyledItemDelegate (parent) +DisplayItemDelegate::DisplayItemDelegate(QAbstractItemView *parent) + : DStyledItemDelegate (parent) { } @@ -19,16 +26,20 @@ void DisplayItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o 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); - initStyleOption(&drawStyle, index); - drawStyle.text = ""; //清空文本绘制 - QStyle *pStyle = drawStyle.widget ? drawStyle.widget->style() : QApplication::style(); - pStyle->drawControl(QStyle::CE_ItemViewItem, &drawStyle, painter, drawStyle.widget); + 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())); @@ -39,8 +50,6 @@ void DisplayItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o QString eliedFileName = drawStyle.fontMetrics.elidedText(fileName, Qt::ElideRight, titleTextRect.width()); pStyle->drawItemText(painter, titleTextRect, drawStyle.displayAlignment, drawStyle.palette, true, eliedFileName); - painter->save(); - //缩小字体 QFont nativeFont(drawStyle.font); nativeFont.setPointSize(drawStyle.font.pointSize() - 1); @@ -56,7 +65,7 @@ void DisplayItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o painter->drawText(nativeTextRect, textBottomAlign, eliedFilePath); painter->restore(); } else { - return QStyledItemDelegate::paint(painter, option, index); + return DStyledItemDelegate::paint(painter, option, index); } } @@ -71,5 +80,5 @@ QSize DisplayItemDelegate::sizeHint(const QStyleOptionViewItem &option, return {option.rect.width(), option.fontMetrics.height() * 2}; } } - return QStyledItemDelegate::sizeHint(option, index); + return DStyledItemDelegate::sizeHint(option, index); } diff --git a/src/plugins/recent/mainframe/displayitemdelegate.h b/src/plugins/recent/mainframe/displayitemdelegate.h index 6af14ccc0..3e7ac9048 100644 --- a/src/plugins/recent/mainframe/displayitemdelegate.h +++ b/src/plugins/recent/mainframe/displayitemdelegate.h @@ -5,12 +5,14 @@ #ifndef DISPLAYITEMDELEGATE_H #define DISPLAYITEMDELEGATE_H -#include +#include -class DisplayItemDelegate : public QStyledItemDelegate +DWIDGET_USE_NAMESPACE + +class DisplayItemDelegate : public DStyledItemDelegate { public: - explicit DisplayItemDelegate(QObject *parent = nullptr); + explicit DisplayItemDelegate(QAbstractItemView *parent = nullptr); protected: virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, diff --git a/src/plugins/recent/mainframe/displayrecentview.cpp b/src/plugins/recent/mainframe/displayrecentview.cpp index 7df53d197..df481b6b4 100644 --- a/src/plugins/recent/mainframe/displayrecentview.cpp +++ b/src/plugins/recent/mainframe/displayrecentview.cpp @@ -6,6 +6,8 @@ #include "common/common.h" #include "displayitemdelegate.h" +#include + #include #include #include @@ -66,19 +68,16 @@ QList DisplayRecentView::itemsFromFile() } DisplayRecentView::DisplayRecentView(QWidget *parent) - : QListView (parent) + : DListView (parent) , cache({}) , model(new QStandardItemModel(this)) { - QListView::viewport()->setAutoFillBackground(false); - QListView::setAttribute(Qt::WA_TranslucentBackground, true); - QListView::setBackgroundRole(QPalette::Base); - QListView::setModel(model); - QListView::setEditTriggers(QListView::NoEditTriggers); - QListView::setItemDelegate(new DisplayItemDelegate(this)); - QListView::setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - QListView::setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - QListView::setSelectionMode(QAbstractItemView::NoSelection); + DListView::setModel(model); + DListView::setEditTriggers(DListView::NoEditTriggers); + DListView::setItemDelegate(new DisplayItemDelegate(this)); + DListView::setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + DListView::setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + DListView::setSelectionMode(QAbstractItemView::NoSelection); } QString DisplayRecentView::cachePath() diff --git a/src/plugins/recent/mainframe/displayrecentview.h b/src/plugins/recent/mainframe/displayrecentview.h index f3d6b5e1e..1cdb7239e 100644 --- a/src/plugins/recent/mainframe/displayrecentview.h +++ b/src/plugins/recent/mainframe/displayrecentview.h @@ -5,12 +5,12 @@ #ifndef DISPLAYRECENTVIEW_H #define DISPLAYRECENTVIEW_H -#include +#include #include class QStandardItemModel; class QStandardItem; -class DisplayRecentView : public QListView +class DisplayRecentView : public DTK_WIDGET_NAMESPACE::DListView { Q_OBJECT QStringList cache; diff --git a/src/plugins/recent/mainframe/recentdisplay.cpp b/src/plugins/recent/mainframe/recentdisplay.cpp index 1872aaf6c..7d2a9cbf3 100644 --- a/src/plugins/recent/mainframe/recentdisplay.cpp +++ b/src/plugins/recent/mainframe/recentdisplay.cpp @@ -3,9 +3,17 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "recentdisplay.h" - #include "displayrecentview.h" +#include "services/window/windowservice.h" +#include "plugins/template/wizard/maindialog.h" + +#include +#include +#include +#include +#include +#include #include #include #include @@ -13,6 +21,8 @@ #include #include +DWIDGET_USE_NAMESPACE + static RecentDisplay *ins{nullptr}; class DisplayProView : public DisplayRecentView @@ -186,39 +196,93 @@ class RecentDisplayPrivate QVBoxLayout *vLayoutDir{nullptr}; DisplayProView *proView{nullptr}; DisplayDocView *docView{nullptr}; - QLabel *dirLabel{nullptr}; - QLabel *docLabel{nullptr}; + DLabel *dirLabel{nullptr}; + DLabel *docLabel{nullptr}; + + DPushButton *btnOpenFile{nullptr}; + DPushButton *btnOpenProject{nullptr}; + DPushButton *btnNewFileOrPro{nullptr}; }; -RecentDisplay::RecentDisplay(QWidget *parent) - : QWidget (parent) +RecentDisplay::RecentDisplay(DWidget *parent) + : DWidget (parent) , d(new RecentDisplayPrivate()) { + DFrame *navFrame = new DFrame(); + DFrame *docFrame = new DFrame(); + DFrame *proFrame = new DFrame(); + + navFrame = new DFrame(); + navFrame->setLineWidth(0); + navFrame->setContentsMargins(0, 0, 0, 0); + DStyle::setFrameRadius(navFrame, 0); + QVBoxLayout *vLayoutNav = new QVBoxLayout(); + QLabel *recentLogo = new QLabel(); + QImageReader maskIimageReader(":/recent/images/recentLogo1.png"); + maskIimageReader.setScaledSize(QSize(200, 143)); + QPixmap logo = QPixmap::fromImage(maskIimageReader.read()); + logo.setDevicePixelRatio(recentLogo->devicePixelRatioF()); + recentLogo->setPixmap(logo); + d->btnOpenFile = new DPushButton(tr("Open File")); + d->btnOpenProject = new DPushButton(tr("Open Project")); + d->btnNewFileOrPro = new DPushButton(tr("New File or Project")); + vLayoutNav->setContentsMargins(50, 200, 50, 200); + vLayoutNav->setSpacing(20); + vLayoutNav->setAlignment(Qt::AlignCenter); + vLayoutNav->addWidget(recentLogo); + vLayoutNav->addWidget(d->btnOpenFile); + vLayoutNav->addWidget(d->btnOpenProject); + vLayoutNav->addWidget(d->btnNewFileOrPro); + navFrame->setLayout(vLayoutNav); + + DLabel *recentTitle = new DLabel(tr("Recent Open")); + recentTitle->setForegroundRole(QPalette::BrightText); + recentTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + DFontSizeManager::instance()->bind(recentTitle, DFontSizeManager::T4, QFont::Medium); + + docFrame->setLineWidth(0); d->docView = new DisplayDocView(); - d->docView->setMinimumWidth(400); - d->docLabel = new QLabel(tr("Documents")); + d->docLabel = new DLabel(tr("Documents")); + d->docLabel->setForegroundRole(QPalette::BrightText); + d->docLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + DFontSizeManager::instance()->bind(d->docLabel, DFontSizeManager::T4, QFont::Medium); d->vLayoutDoc = new QVBoxLayout(); - d->vLayoutDoc->setMargin(40); + d->vLayoutDoc->setContentsMargins(10, 10, 10, 10); d->vLayoutDoc->addWidget(d->docLabel); d->vLayoutDoc->setSpacing(20); d->vLayoutDoc->addWidget(d->docView); - d->vLayoutDoc->setAlignment(d->proView, Qt::AlignRight); + docFrame->setLayout(d->vLayoutDoc); + proFrame->setLineWidth(0); d->proView = new DisplayProView(); - d->proView->setMinimumWidth(400); - d->dirLabel = new QLabel(tr("Projects")); + d->dirLabel = new DLabel(tr("Projects")); + d->dirLabel->setForegroundRole(QPalette::BrightText); + d->dirLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + DFontSizeManager::instance()->bind(d->dirLabel, DFontSizeManager::T4, QFont::Medium); d->vLayoutDir = new QVBoxLayout(); - d->vLayoutDir->setMargin(40); + d->vLayoutDir->setContentsMargins(10, 10, 10, 10); d->vLayoutDir->addWidget(d->dirLabel); d->vLayoutDir->setSpacing(20); d->vLayoutDir->addWidget(d->proView); - d->vLayoutDir->setAlignment(d->docView, Qt::AlignLeft); + proFrame->setLayout(d->vLayoutDir); + + QHBoxLayout *proAndDocLayout = new QHBoxLayout(); + proAndDocLayout->addWidget(proFrame); + proAndDocLayout->addSpacing(0); + proAndDocLayout->addWidget(docFrame); + + QVBoxLayout *recentNavLayout = new QVBoxLayout(); + recentNavLayout->setContentsMargins(20, 0, 25, 20); + recentNavLayout->addSpacing(15); + recentNavLayout->setAlignment(Qt::AlignTop); + recentNavLayout->addWidget(recentTitle); + recentNavLayout->addSpacing(15); + recentNavLayout->addLayout(proAndDocLayout); d->hLayout = new QHBoxLayout(); - d->hLayout->addStretch(); - d->hLayout->addLayout(d->vLayoutDir); - d->hLayout->addLayout(d->vLayoutDoc); - d->hLayout->addStretch(); + d->hLayout->setContentsMargins(0, 0, 0, 0); + d->hLayout->addWidget(navFrame); + d->hLayout->addLayout(recentNavLayout); setLayout(d->hLayout); QObject::connect(d->proView, &QListView::doubleClicked, @@ -228,6 +292,18 @@ RecentDisplay::RecentDisplay(QWidget *parent) QObject::connect(d->docView, &QListView::doubleClicked, this, &RecentDisplay::doDoubleCliekedDocument, Qt::UniqueConnection); + + QObject::connect(d->btnOpenFile, &DPushButton::clicked, + this, &RecentDisplay::btnOpenFileClicked, + Qt::UniqueConnection); + + QObject::connect(d->btnOpenProject, &DPushButton::clicked, + this, &RecentDisplay::btnOpenProjectClicked, + Qt::UniqueConnection); + + QObject::connect(d->btnNewFileOrPro, &DPushButton::clicked, + this, &RecentDisplay::btnNewFileOrProClicked, + Qt::UniqueConnection); } RecentDisplay::~RecentDisplay() @@ -274,3 +350,28 @@ void RecentDisplay::doDoubleCliekedDocument(const QModelIndex &index) editor.openFile(filePath); } +void RecentDisplay::btnOpenFileClicked() +{ + QString dir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); + QString filePath = DFileDialog::getOpenFileName(nullptr, dpfservice::DIALOG_OPEN_DOCUMENT_TITLE, dir); + if (filePath.isEmpty() && !QFileInfo(filePath).exists()) + return; + recent.saveOpenedFile(filePath); + editor.openFile(filePath); +} + +void RecentDisplay::btnOpenProjectClicked() +{ + QString dir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); + QString filePath = DFileDialog::getOpenFileName(nullptr, dpfservice::DIALOG_OPEN_DOCUMENT_TITLE, dir); + if (filePath.isEmpty() && !QFileInfo(filePath).exists()) + return; + recent.saveOpenedFile(filePath); + editor.openFile(filePath); +} + +void RecentDisplay::btnNewFileOrProClicked() +{ + projectTemplate.newWizard(); +} + diff --git a/src/plugins/recent/mainframe/recentdisplay.h b/src/plugins/recent/mainframe/recentdisplay.h index dd9f1f2ad..30c762b3c 100644 --- a/src/plugins/recent/mainframe/recentdisplay.h +++ b/src/plugins/recent/mainframe/recentdisplay.h @@ -5,11 +5,11 @@ #ifndef RECENTDISPLAY_H #define RECENTDISPLAY_H -#include +#include #include "common/common.h" class RecentDisplayPrivate; -class RecentDisplay : public QWidget +class RecentDisplay : public DTK_WIDGET_NAMESPACE::DWidget { Q_OBJECT RecentDisplayPrivate *const d; @@ -19,7 +19,7 @@ class RecentDisplay : public QWidget ProjectLanguage, ProjectWorkspace, }; - explicit RecentDisplay(QWidget *parent = nullptr); + explicit RecentDisplay(DTK_WIDGET_NAMESPACE::DWidget *parent = nullptr); virtual ~RecentDisplay(); static RecentDisplay *instance(); @@ -32,6 +32,10 @@ public slots: private slots: void doDoubleClickedProject(const QModelIndex &index); void doDoubleCliekedDocument(const QModelIndex &index); + + void btnOpenFileClicked(); + void btnOpenProjectClicked(); + void btnNewFileOrProClicked(); }; #endif // RECENTDISPLAY_H diff --git a/src/plugins/recent/recent.qrc b/src/plugins/recent/recent.qrc new file mode 100644 index 000000000..a4c2475ed --- /dev/null +++ b/src/plugins/recent/recent.qrc @@ -0,0 +1,6 @@ + + + images/recentLogo1.png + images/recentLogo2.png + + diff --git a/src/plugins/template/CMakeLists.txt b/src/plugins/template/CMakeLists.txt index d82b69e60..f30246863 100644 --- a/src/plugins/template/CMakeLists.txt +++ b/src/plugins/template/CMakeLists.txt @@ -7,6 +7,7 @@ set(CXX_CPP wizard/maindialog.cpp wizard/templateparser.cpp wizard/projectgenerate.cpp + transceiver/templatereceiver.cpp templatemanager.cpp templateplugin.cpp templateplugin.json @@ -17,6 +18,7 @@ set(CXX_H wizard/maindialog.h wizard/templateparser.h wizard/projectgenerate.h + transceiver/templatereceiver.h templatemanager.h templateplugin.h ) diff --git a/src/plugins/template/transceiver/templatereceiver.cpp b/src/plugins/template/transceiver/templatereceiver.cpp new file mode 100644 index 000000000..6c60b62d4 --- /dev/null +++ b/src/plugins/template/transceiver/templatereceiver.cpp @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "templatereceiver.h" +#include "templatemanager.h" +#include "common/common.h" + +TemplateReceiver::TemplateReceiver(QObject *parent) + : dpf::EventHandler (parent) + , dpf::AutoEventHandlerRegister () +{ + +} + +dpf::EventHandler::Type TemplateReceiver::type() +{ + return dpf::EventHandler::Type::Sync; +} + +QStringList TemplateReceiver::topics() +{ + return { projectTemplate.topic }; +} + +void TemplateReceiver::eventProcess(const dpf::Event &event) +{ + if (event.data() == projectTemplate.newWizard.name) { + TemplateManager::instance()->newWizard(); + } +} diff --git a/src/plugins/template/transceiver/templatereceiver.h b/src/plugins/template/transceiver/templatereceiver.h new file mode 100644 index 000000000..da504b0c5 --- /dev/null +++ b/src/plugins/template/transceiver/templatereceiver.h @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RECENTRECEIVER_H +#define RECENTRECEIVER_H + +#include + +class TemplateReceiver : public dpf::EventHandler, dpf::AutoEventHandlerRegister +{ + Q_OBJECT + friend class dpf::AutoEventHandlerRegister; +public: + explicit TemplateReceiver(QObject * parent = nullptr); + + static Type type(); + + static QStringList topics(); + + virtual void eventProcess(const dpf::Event& event) override; +}; + +class RecentProxy : public QObject +{ + Q_OBJECT + RecentProxy(){} + RecentProxy(const RecentProxy&) = delete; + +public: + static RecentProxy* instance(); + +signals: + void saveOpenedProject(const QString &kitName, + const QString &language, + const QString &workspace); + void saveOpenedFile(const QString &filePath); +}; + +#endif // RECENTRECEIVER_H diff --git a/src/plugins/template/wizard/maindialog.cpp b/src/plugins/template/wizard/maindialog.cpp index 8bd254135..7204822ec 100644 --- a/src/plugins/template/wizard/maindialog.cpp +++ b/src/plugins/template/wizard/maindialog.cpp @@ -13,10 +13,10 @@ #include #include #include +#include #include #include -#include #include #include #include