-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add deepinfiledialog theme #188
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
add_subdirectory(deepintheme) | ||
add_subdirectory(deepinfiledialogtheme) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS DBus Widgets) | ||
set(QT_LIBS Qt${QT_VERSION_MAJOR}::DBus Qt${QT_VERSION_MAJOR}::Widgets) | ||
if(QT_VERSION_MAJOR EQUAL 5) | ||
find_package(Qt5X11Extras REQUIRED) | ||
list(APPEND QT_LIBS Qt5::X11Extras) | ||
if(QT_VERSION_MINOR GREATER_EQUAL 8) # Qt5.8 | ||
find_package(Qt5ThemeSupport REQUIRED) | ||
list(APPEND QT_LIBS Qt5::ThemeSupportPrivate) | ||
else() | ||
list(APPEND QT_LIBS Qt5::PlatformSupportPrivate) | ||
endif() | ||
else() | ||
list(APPEND QT_LIBS Qt6::GuiPrivate) | ||
endif() | ||
|
||
include(../filedialog/filedialog.cmake) | ||
|
||
dtk_add_plugin( | ||
NAME | ||
qdeepinfiledialog | ||
OUTPUT_DIR | ||
${PLUGIN_OUTPUT_BASE_DIR}/platformthemes | ||
INCLUDE_DIRS | ||
${CMAKE_CURRENT_LIST_DIR}/../filedialog | ||
SOURCES | ||
${DFM_DLG_SOURCES} | ||
qdeepintheme.cpp | ||
main.cpp | ||
${DBUS_INTERFACES} | ||
HEADERS | ||
${DFM_DLG_HEADERS} | ||
qdeepintheme.h | ||
DEPENDENCIES | ||
${QT_LIBS} | ||
DEFINITIONS | ||
${DEFS} | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"Keys" : [ "deepinfiledialog", "deepin", "DDE" ] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2017 - 2023 UnionTech Software Technology Co., Ltd. | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
#include <qpa/qplatformthemeplugin.h> | ||
#include "qdeepintheme.h" | ||
|
||
QT_BEGIN_NAMESPACE | ||
class QDeepinFileDialogThemePlugin : public QPlatformThemePlugin | ||
{ | ||
Q_OBJECT | ||
Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "deepinfiledialog.json") | ||
|
||
public: | ||
QPlatformTheme *create(const QString &key, const QStringList ¶ms) Q_DECL_OVERRIDE; | ||
}; | ||
|
||
QPlatformTheme *QDeepinFileDialogThemePlugin::create(const QString &key, const QStringList ¶ms) | ||
{ | ||
Q_UNUSED(params); | ||
const QStringList &keys = {"deepinfiledialog", QLatin1String(QDeepinTheme::name), QLatin1String("DDE")}; | ||
if (keys.contains(key, Qt::CaseInsensitive)) | ||
return new QDeepinTheme; | ||
|
||
return nullptr; | ||
} | ||
|
||
QT_END_NAMESPACE | ||
|
||
#include "main.moc" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2017 - 2023 UnionTech Software Technology Co., Ltd. | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
#include "qdeepintheme.h" | ||
#include "qdeepinfiledialoghelper.h" | ||
#include "filedialogmanager_interface.h" | ||
|
||
#include <QGuiApplication> | ||
#include <QIconEnginePlugin> | ||
|
||
#include <private/qguiapplication_p.h> | ||
#include <qpa/qwindowsysteminterface_p.h> | ||
#include <qpa/qplatformscreen.h> | ||
#include <qpa/qplatformcursor.h> | ||
|
||
#undef signals | ||
#include <X11/Xlib.h> | ||
|
||
|
||
QT_BEGIN_NAMESPACE | ||
|
||
const char *QDeepinTheme::name = "deepin"; | ||
bool QDeepinTheme::m_usePlatformNativeDialog = true; | ||
|
||
QDeepinTheme::QDeepinTheme() | ||
{ | ||
} | ||
|
||
QDeepinTheme::~QDeepinTheme() | ||
{ | ||
if (QDeepinFileDialogHelper::manager) { | ||
QDeepinFileDialogHelper::manager->deleteLater(); | ||
QDeepinFileDialogHelper::manager = Q_NULLPTR; | ||
} | ||
} | ||
|
||
bool QDeepinTheme::usePlatformNativeDialog(DialogType type) const | ||
{ | ||
if (type == FileDialog) { | ||
if (qgetenv("_d_disableDBusFileDialog") == "true") | ||
return false; | ||
|
||
static bool dbusDialogManagerInitialized = false; | ||
|
||
if (!dbusDialogManagerInitialized) { | ||
dbusDialogManagerInitialized = true; | ||
QDeepinFileDialogHelper::initDBusFileDialogManager(); | ||
} | ||
|
||
return m_usePlatformNativeDialog | ||
&& QDeepinFileDialogHelper::manager | ||
&& QDeepinFileDialogHelper::manager->isUseFileChooserDialog(); | ||
} | ||
|
||
return QGenericUnixTheme::usePlatformNativeDialog(type); | ||
} | ||
|
||
QPlatformDialogHelper *QDeepinTheme::createPlatformDialogHelper(DialogType type) const | ||
{ | ||
if (type == FileDialog && usePlatformNativeDialog(type)) | ||
return new QDeepinFileDialogHelper(); | ||
|
||
return QGenericUnixTheme::createPlatformDialogHelper(type); | ||
} | ||
|
||
QT_END_NAMESPACE | ||
|
||
#include "qdeepintheme.moc" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2017-2023 UnionTech Software Technology Co., Ltd. | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
#ifndef QDEEPINTHEME_H | ||
#define QDEEPINTHEME_H | ||
|
||
#include <QMimeDatabase> | ||
|
||
#include <private/qgenericunixthemes_p.h> | ||
#include <qpa/qplatformwindow.h> | ||
#include <qpa/qplatformnativeinterface.h> | ||
|
||
class DThemeSettings; | ||
class QDeepinTheme : public QGenericUnixTheme | ||
{ | ||
public: | ||
QDeepinTheme(); | ||
~QDeepinTheme(); | ||
|
||
bool usePlatformNativeDialog(DialogType type) const Q_DECL_OVERRIDE; | ||
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const Q_DECL_OVERRIDE; | ||
|
||
static const char *name; | ||
|
||
private: | ||
static bool m_usePlatformNativeDialog; | ||
|
||
friend class QDeepinFileDialogHelper; | ||
}; | ||
|
||
#endif // QDEEPINTHEME_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,30 +31,28 @@ pkg_check_modules(Deps REQUIRED IMPORTED_TARGET mtdev) | |
if(ENABLE_QT_XDG_ICON_LOADER) | ||
set(DEFS -DXDG_ICON_VERSION_MAR=${XDG_ICON_VERSION_MAJOR}) | ||
endif() | ||
if(QT_VERSION_MAJOR EQUAL 5) | ||
qt5_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialog.xml filedialog_interface) | ||
qt5_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialogmanager.xml filedialogmanager_interface) | ||
else() | ||
qt6_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialog.xml filedialog_interface) | ||
qt6_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialogmanager.xml filedialogmanager_interface) | ||
endif() | ||
|
||
include(../filedialog/filedialog.cmake) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里如果是为了源码共享,可以使用OBJECT或者INTERFACE的TARGET类型共享 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同下 |
||
|
||
dtk_add_plugin( | ||
NAME | ||
qdeepin | ||
OUTPUT_DIR | ||
${PLUGIN_OUTPUT_BASE_DIR}/platformthemes | ||
INSTALL_DIR | ||
${PLUGIN_INSTALL_BASE_DIR}/platformthemes | ||
INCLUDE_DIRS | ||
${CMAKE_CURRENT_LIST_DIR}/../filedialog | ||
SOURCES | ||
dthemesettings.cpp | ||
qdeepinfiledialoghelper.cpp | ||
${DFM_DLG_SOURCES} | ||
qdeepintheme.cpp | ||
${3RD_PARTY_SOURCES} | ||
main.cpp | ||
${DBUS_INTERFACES} | ||
HEADERS | ||
dthemesettings.h | ||
qdeepinfiledialoghelper.h | ||
${DFM_DLG_HEADERS} | ||
qdeepintheme.h | ||
${3RD_PARTY_HEADERS} | ||
RESOURCES | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
#include "filedialogmanager_interface.h" | ||
#include "dthemesettings.h" | ||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | ||
#include "../3rdparty/qdbustrayicon_p.h" | ||
#include "../../3rdparty/qdbustrayicon_p.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 避免在源码中使用相对目录,使用target_include_directories |
||
#endif | ||
|
||
#include <DGuiApplicationHelper> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
if(QT_VERSION_MAJOR EQUAL 5) | ||
qt5_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialog.xml filedialog_interface) | ||
qt5_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialogmanager.xml filedialogmanager_interface) | ||
else() | ||
qt6_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialog.xml filedialog_interface) | ||
qt6_add_dbus_interface(DBUS_INTERFACES ${CMAKE_CURRENT_LIST_DIR}/xmls/com.deepin.filemanager.filedialogmanager.xml filedialogmanager_interface) | ||
endif() | ||
|
||
set(DFM_DLG_HEADERS ${CMAKE_CURRENT_LIST_DIR}/qdeepinfiledialoghelper.h) | ||
set(DFM_DLG_SOURCES ${CMAKE_CURRENT_LIST_DIR}/qdeepinfiledialoghelper.cpp) | ||
Comment on lines
+1
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议使用target的方式共享 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. target 就把俩plugin关联在一起了。 现在这种方式可以只编译一个。没有dtk的依赖。换成target是不是需要带入另外一个theme的编译依赖呢 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不需要,是这个文件夹里面的内容单独做一个target,两个theme都依赖这一个target。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 仅仅是使用target的方式共享需要共享的源码,本质上和你这里的cmake一样,但是以target的方式,会更加灵活,不需要依赖于目录。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,6 @@ | |
|
||
#include <X11/Xlib.h> | ||
|
||
#include <DPlatformHandle> | ||
DGUI_USE_NAMESPACE | ||
Comment on lines
-30
to
-31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里为什么不使用dtkgui的内容呢 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 就是想要纯粹的文管的filedialog服务,不想引入dtk依赖, 比如一个安装在opt目录下的自带qt 某一个版本的应用(很多,如网易云音乐,有道词典等)需要用我们的文管对话框,这个时候就可以简单的编译deepin-file-dialog的theme来实现 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 但是我记得qdeepinfiledialog本身有dtkwidget的依赖吧 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 没有。仅仅有的dtkgui的都移除了。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我们这整个项目都有dtkwidget的依赖,如果想要单独编出这个插件,还要做一些修改 |
||
|
||
QT_BEGIN_NAMESPACE | ||
#ifndef DIALOG_SERVICE | ||
|
@@ -117,6 +115,20 @@ static inline void setTransientForHint(WId wid, WId propWid) | |
XSetTransientForHint(DISPLAY, wid, propWid); | ||
} | ||
|
||
static inline bool isDXcbPlatform() | ||
{ | ||
if (!qApp) | ||
return false; | ||
|
||
#define DXCB_PLUGIN_KEY "dxcb" | ||
#define DXCB_PLUGIN_SYMBOLIC_PROPERTY "_d_isDxcb" | ||
|
||
static bool _is_dxcb = qApp->platformName() == DXCB_PLUGIN_KEY || | ||
qApp->property(DXCB_PLUGIN_SYMBOLIC_PROPERTY).toBool(); | ||
|
||
return _is_dxcb; | ||
} | ||
|
||
void QDeepinFileDialogHelper::onWindowActiveChanged() | ||
{ | ||
if (!filedlgInterface) | ||
|
@@ -131,7 +143,7 @@ void QDeepinFileDialogHelper::onWindowActiveChanged() | |
setTransientForHint(fileDlgWId, parentWId); | ||
} | ||
|
||
if (DPlatformHandle::isDXcbPlatform()) { | ||
if (isDXcbPlatform()) { | ||
QWindow *focus_window = qApp->focusWindow(); | ||
if (!focus_window) | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个文件名最好修改一下。