Skip to content

Commit

Permalink
feat: DTK Change-Mainwindow and menu
Browse files Browse the repository at this point in the history
Log: DTK Change-Mainwindow and menu
  • Loading branch information
N0rthHXD committed Nov 13, 2023
1 parent ab3c543 commit 7326b76
Show file tree
Hide file tree
Showing 27 changed files with 324 additions and 279 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ target_link_libraries(
common
${QtUseModules}
${PkgUseModule}
${DtkWidget_LIBRARIES}
)

install(TARGETS ${PROJECT_NAME} DESTINATION ${RUNTIME_INSTALL_RPEFIX})
15 changes: 10 additions & 5 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

#include <framework/framework.h>
#include <framework/lifecycle/pluginsetting.h>

#include <DApplication>

#include <QApplication>
#include <QStyleFactory>

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";
Expand Down Expand Up @@ -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
Expand All @@ -118,8 +126,5 @@ int main(int argc, char *argv[])
abort();
}

QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);

return a.exec();
}
1 change: 1 addition & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ target_link_libraries(
${PROJECT_NAME}
unioncode-jsonrpcclient
Qt5::Network
${DtkWidget_LIBRARIES}
)

install(TARGETS ${PROJECT_NAME} DESTINATION ${LIBRARY_INSTALL_PREFIX})
6 changes: 3 additions & 3 deletions src/common/widget/elidedlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ElidedLabelPrivate
};

ElidedLabel::ElidedLabel(QWidget *parent)
: QLabel (parent)
: DLabel (parent)
, d (new ElidedLabelPrivate)
{

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/common/widget/elidedlabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef ELIDEDLABEL_H
#define ELIDEDLABEL_H

#include <QLabel>
#include <DLabel>

class ElidedLabelPrivate;
class ElidedLabel : public QLabel
class ElidedLabel : public DTK_WIDGET_NAMESPACE::DLabel
{
Q_OBJECT
ElidedLabelPrivate *const d;
Expand Down
1 change: 1 addition & 0 deletions src/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ target_link_libraries(
stdc++fs
${QtUseModules}
${PkgUseModules}
${DtkWidget_LIBRARIES}
)

target_include_directories(${PROJECT_NAME}
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,7 +14,6 @@ set(CXX_CPP
)

set(CXX_H
mainframe/windowtheme.h
mainframe/windowkeeper.h
mainframe/windowstatusbar.h
mainframe/progressbar.h
Expand All @@ -42,6 +40,7 @@ target_link_libraries(${PROJECT_NAME}
services
${QtUseModules}
${PkgUserModules}
${DtkWidget_LIBRARIES}
)

install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,11 @@

#include "core.h"
#include "mainframe/windowkeeper.h"
#include "mainframe/windowtheme.h"
#include "services/window/windowservice.h"

#include <framework/framework.h>
#include "common/common.h"

#include <QStatusBar>
#include <QApplication>
#include <QMainWindow>
#include <QMenuBar>
#include <QFileDialog>

using namespace dpfservice;

void Core::initialize()
Expand Down Expand Up @@ -48,7 +41,6 @@ bool Core::start()
}

WindowKeeper::instace();
WindowTheme::setTheme(":/dark.css");

QObject::connect(&dpf::Listener::instance(), &dpf::Listener::pluginsStarted, [=] {
ActionManager::getInstance()->readUserSetting();
Expand Down
38 changes: 26 additions & 12 deletions src/plugins/core/mainframe/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
#include "aboutdialog.h"
#include "common/common.h"

#include <DLabel>
#include <DPushButton>
#include <DTextEdit>
#include <DMessageBox>
#include <DTitlebar>

#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QLatin1String>
#include <QDateTime>
#include <QDesktopServices>

DWIDGET_USE_NAMESPACE

const QString ICON_LOGO_128PX = ":/core/images/[email protected]";

AboutDialog::AboutDialog(QDialog *parent)
: QDialog(parent)
AboutDialog::AboutDialog(QWidget *parent)
: DAbstractDialog(parent)
{
setupUi();
}
Expand All @@ -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("<br/>Built on %1 %2 in %3<br/>")
Expand All @@ -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);
}

Expand All @@ -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);
Expand All @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/core/mainframe/aboutdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <QDialog>
#include <DAbstractDialog>

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:
Expand Down
Loading

0 comments on commit 7326b76

Please sign in to comment.