diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c8a64e0f..546714e3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -171,9 +171,6 @@ set(UI_FILES
ui/channel/store_daemon_proxy.cpp
ui/channel/store_daemon_proxy.h
- ui/utils/theme_manager.cpp
- ui/utils/theme_manager.h
-
ui/widgets/image_viewer.cpp
ui/widgets/image_viewer.h
ui/widgets/search_button.cpp
@@ -200,38 +197,38 @@ add_custom_target(update-qm DEPENDS ${DMAN_TRANSLATION_QM})
# Update angular dist/. Works on x86 based platforms.
add_custom_command(OUTPUT npm-update-web-dist
COMMAND sh -c "PATH=./node_modules/.bin:$PATH npm run build"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/web"
- VERBATIM
- )
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/web"
+ VERBATIM
+ )
add_custom_target(update-web-dist DEPENDS npm-update-web-dist)
add_executable(deepin-appstore
app/deepin_appstore.cpp
- ${BASE_FILES}
- ${DBUS_FILES}
- ${RESOURCES_FILES}
- ${SERVICES_FILES}
- ${UI_FILES}
- )
+ ${BASE_FILES}
+ ${DBUS_FILES}
+ ${RESOURCES_FILES}
+ ${SERVICES_FILES}
+ ${UI_FILES}
+ )
target_link_libraries(deepin-appstore ${LINK_LIBS})
if (CMAKE_BUILD_TYPE MATCHES Release)
add_dependencies(deepin-appstore
update-qm
- update-web-dist)
+ update-web-dist)
endif()
if (CMAKE_BUILD_TYPE MATCHES Debug)
add_executable(test-launcher
app/test_launcher.cpp
- base/launcher.cpp
- base/launcher.h
- )
+ base/launcher.cpp
+ base/launcher.h
+ )
target_link_libraries(test-launcher ${LINK_LIBS})
add_executable(test-base64-image
app/base64_image.cpp
- base/file_util.cpp
- base/file_util.h
- )
+ base/file_util.cpp
+ base/file_util.h
+ )
target_link_libraries(test-base64-image ${LINK_LIBS})
add_executable(qurl-demo app/qurl_demo.cpp)
@@ -240,15 +237,15 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
add_executable(test-image-viewer
app/test_image_viewer.cpp
- base/file_util.cpp
- base/file_util.h
- ui/utils/theme_manager.cpp
- ui/utils/theme_manager.h
- ui/widgets/image_viewer.cpp
- ui/widgets/image_viewer.h
+ base/file_util.cpp
+ base/file_util.h
+ ui/utils/theme_manager.cpp
+ ui/utils/theme_manager.h
+ ui/widgets/image_viewer.cpp
+ ui/widgets/image_viewer.h
- resources/themes/themes.qrc
- )
+ resources/themes/themes.qrc
+ )
target_link_libraries(test-image-viewer ${LINK_LIBS})
endif()
@@ -256,16 +253,16 @@ add_executable(deepin-appstore-metadata
app/deepin_appstore_metadata.cpp
- ${BASE_FILES}
- ${DBUS_FILES}
- ${SERVICES_FILES}
- )
+ ${BASE_FILES}
+ ${DBUS_FILES}
+ ${SERVICES_FILES}
+ )
target_link_libraries(deepin-appstore-metadata ${Qt_LIBS})
install(TARGETS
deepin-appstore
- deepin-appstore-metadata
- DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ deepin-appstore-metadata
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/web_dist
diff --git a/src/app/deepin_appstore.cpp b/src/app/deepin_appstore.cpp
index 52c439f4..a4a10e50 100644
--- a/src/app/deepin_appstore.cpp
+++ b/src/app/deepin_appstore.cpp
@@ -36,7 +36,7 @@ const char kDisableGpu[] = "--disable-gpu";
const char kEnableLogging[] = "--enable-logging";
const char kLogLevel[] = "--log-level";
-} // namespace
+} // namespace
int main(int argc, char** argv) {
qputenv("DXCB_FAKE_PLATFORM_NAME_XCB", "true");
@@ -45,15 +45,17 @@ int main(int argc, char** argv) {
QCefGlobalSettings settings;
// Do not use sandbox.
settings.setNoSandbox(true);
-#ifndef NDEBUG
- // Open http://localhost:9222 in chromium browser to see dev tools.
- settings.setRemoteDebug(true);
- settings.setIgnoresCertificateErrors(true);
-#else
- settings.setRemoteDebug(false);
-#endif
+
+ if (qEnvironmentVariableIntValue("DSTORE_DEBUG") == 1) {
+ // Open http://localhost:9222 in chromium browser to see dev tools.
+ settings.setRemoteDebug(true);
+ settings.setLogSeverity(QCefGlobalSettings::LogSeverity::Verbose);
+ } else {
+ settings.setRemoteDebug(false);
+ settings.setLogSeverity(QCefGlobalSettings::LogSeverity::Error);
+ }
+
settings.setIgnoresCertificateErrors(true);
- settings.setLogSeverity(QCefGlobalSettings::LogSeverity::Error);
// Disable GPU process.
settings.addCommandLineSwitch(kDisableGpu, "");
diff --git a/src/base/consts.cpp b/src/base/consts.cpp
index b7cc72d4..7a17aa7d 100644
--- a/src/base/consts.cpp
+++ b/src/base/consts.cpp
@@ -23,7 +23,7 @@ const char kAppName[] = "deepin-appstore";
const char kAppVersion[] = "5.0.2.2";
#ifndef NDEBUG
-const char kIndexPage[] = "http://localhost:4200/";
+const char kIndexPage[] = "http://localhost:4200/china/";
#else
const char kIndexPage[] = "rcc://web/index.html";
#endif // NDEBUG
diff --git a/src/resources/themes/light/ImageViewer.css b/src/resources/themes/dark/dstore--ImageViewer.theme
similarity index 100%
rename from src/resources/themes/light/ImageViewer.css
rename to src/resources/themes/dark/dstore--ImageViewer.theme
diff --git a/src/resources/themes/light/SearchCompletionWindow.css b/src/resources/themes/dark/dstore--SearchCompletionWindow.theme
similarity index 100%
rename from src/resources/themes/light/SearchCompletionWindow.css
rename to src/resources/themes/dark/dstore--SearchCompletionWindow.theme
diff --git a/src/resources/themes/dark/dstore--TitleBar.theme b/src/resources/themes/dark/dstore--TitleBar.theme
new file mode 100644
index 00000000..ce32fa5d
--- /dev/null
+++ b/src/resources/themes/dark/dstore--TitleBar.theme
@@ -0,0 +1,18 @@
+
+#AppIcon {
+ image: url(:/common/images/deepin-appstore.svg);
+}
+
+#BackButton {
+ qproperty-normalPic: url(:/dark/images/backward_normal.svg);
+ qproperty-hoverPic: url(:/dark/images/backward_hover.svg);
+ qproperty-pressPic: url(:/dark/images/backward_press.svg);
+ qproperty-disabledPic: url(:/dark/images/backward_insensitive.svg);
+}
+
+#ForwardButton {
+ qproperty-normalPic: url(:/dark/images/forward_normal.svg);
+ qproperty-hoverPic: url(:/dark/images/forward_hover.svg);
+ qproperty-pressPic: url(:/dark/images/forward_press.svg);
+ qproperty-disabledPic: url(:/dark/images/forward_insensitive.svg);
+}
diff --git a/src/resources/themes/dark/dstore--WebWindow.theme b/src/resources/themes/dark/dstore--WebWindow.theme
new file mode 100644
index 00000000..a211a0b5
--- /dev/null
+++ b/src/resources/themes/dark/dstore--WebWindow.theme
@@ -0,0 +1,4 @@
+Dtk--Widget--DMainWindow {
+ qproperty-borderColor: rgba(16, 16, 16, 80%);
+ background-color: transparent;
+}
diff --git a/src/resources/themes/dark/images/back_hover.svg b/src/resources/themes/dark/images/back_hover.svg
new file mode 100644
index 00000000..af7a5672
--- /dev/null
+++ b/src/resources/themes/dark/images/back_hover.svg
@@ -0,0 +1,14 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/back_normal.svg b/src/resources/themes/dark/images/back_normal.svg
new file mode 100644
index 00000000..bed39c87
--- /dev/null
+++ b/src/resources/themes/dark/images/back_normal.svg
@@ -0,0 +1,16 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/back_press.svg b/src/resources/themes/dark/images/back_press.svg
new file mode 100644
index 00000000..c0c93f03
--- /dev/null
+++ b/src/resources/themes/dark/images/back_press.svg
@@ -0,0 +1,14 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/backward_hover.svg b/src/resources/themes/dark/images/backward_hover.svg
new file mode 100644
index 00000000..f0acb43f
--- /dev/null
+++ b/src/resources/themes/dark/images/backward_hover.svg
@@ -0,0 +1,29 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/backward_insensitive.svg b/src/resources/themes/dark/images/backward_insensitive.svg
new file mode 100644
index 00000000..58e024da
--- /dev/null
+++ b/src/resources/themes/dark/images/backward_insensitive.svg
@@ -0,0 +1,35 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/backward_normal.svg b/src/resources/themes/dark/images/backward_normal.svg
new file mode 100644
index 00000000..e4212033
--- /dev/null
+++ b/src/resources/themes/dark/images/backward_normal.svg
@@ -0,0 +1,35 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/backward_press.svg b/src/resources/themes/dark/images/backward_press.svg
new file mode 100644
index 00000000..b060f556
--- /dev/null
+++ b/src/resources/themes/dark/images/backward_press.svg
@@ -0,0 +1,29 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/close_hover.svg b/src/resources/themes/dark/images/close_hover.svg
new file mode 100644
index 00000000..9e6b13df
--- /dev/null
+++ b/src/resources/themes/dark/images/close_hover.svg
@@ -0,0 +1,21 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/close_normal.svg b/src/resources/themes/dark/images/close_normal.svg
new file mode 100644
index 00000000..2a2d1e7e
--- /dev/null
+++ b/src/resources/themes/dark/images/close_normal.svg
@@ -0,0 +1,21 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/close_press.svg b/src/resources/themes/dark/images/close_press.svg
new file mode 100644
index 00000000..5724082e
--- /dev/null
+++ b/src/resources/themes/dark/images/close_press.svg
@@ -0,0 +1,21 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/forward_hover.svg b/src/resources/themes/dark/images/forward_hover.svg
new file mode 100644
index 00000000..b4b6b5dc
--- /dev/null
+++ b/src/resources/themes/dark/images/forward_hover.svg
@@ -0,0 +1,29 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/forward_insensitive.svg b/src/resources/themes/dark/images/forward_insensitive.svg
new file mode 100644
index 00000000..60749cc7
--- /dev/null
+++ b/src/resources/themes/dark/images/forward_insensitive.svg
@@ -0,0 +1,34 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/forward_normal.svg b/src/resources/themes/dark/images/forward_normal.svg
new file mode 100644
index 00000000..d827b0f0
--- /dev/null
+++ b/src/resources/themes/dark/images/forward_normal.svg
@@ -0,0 +1,34 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/forward_press.svg b/src/resources/themes/dark/images/forward_press.svg
new file mode 100644
index 00000000..396e3466
--- /dev/null
+++ b/src/resources/themes/dark/images/forward_press.svg
@@ -0,0 +1,29 @@
+
+
\ No newline at end of file
diff --git a/src/resources/themes/dark/images/next_hover.svg b/src/resources/themes/dark/images/next_hover.svg
new file mode 100644
index 00000000..ec6f86a6
--- /dev/null
+++ b/src/resources/themes/dark/images/next_hover.svg
@@ -0,0 +1,9 @@
+
diff --git a/src/resources/themes/dark/images/next_normal.svg b/src/resources/themes/dark/images/next_normal.svg
new file mode 100644
index 00000000..7480a6bc
--- /dev/null
+++ b/src/resources/themes/dark/images/next_normal.svg
@@ -0,0 +1,6 @@
+
diff --git a/src/resources/themes/dark/images/next_press.svg b/src/resources/themes/dark/images/next_press.svg
new file mode 100644
index 00000000..cc1f2448
--- /dev/null
+++ b/src/resources/themes/dark/images/next_press.svg
@@ -0,0 +1,19 @@
+
diff --git a/src/resources/themes/dark/images/previous_hover.svg b/src/resources/themes/dark/images/previous_hover.svg
new file mode 100644
index 00000000..8acbe647
--- /dev/null
+++ b/src/resources/themes/dark/images/previous_hover.svg
@@ -0,0 +1,9 @@
+
diff --git a/src/resources/themes/dark/images/previous_normal.svg b/src/resources/themes/dark/images/previous_normal.svg
new file mode 100644
index 00000000..39a70240
--- /dev/null
+++ b/src/resources/themes/dark/images/previous_normal.svg
@@ -0,0 +1,6 @@
+
diff --git a/src/resources/themes/dark/images/previous_press.svg b/src/resources/themes/dark/images/previous_press.svg
new file mode 100644
index 00000000..ceca6523
--- /dev/null
+++ b/src/resources/themes/dark/images/previous_press.svg
@@ -0,0 +1,21 @@
+
diff --git a/src/resources/themes/light/RecommendApp.css b/src/resources/themes/light/RecommendApp.css
deleted file mode 100644
index 54a76d28..00000000
--- a/src/resources/themes/light/RecommendApp.css
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#ImageLabel {
- /*box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.30);*/
-}
-
-#CloseButton {
- qproperty-normalPic: url(:/light/images/close_normal.svg);
- qproperty-hoverPic: url(:/light/images/close_hover.svg);
- qproperty-pressPic: url(:/light/images/close_press.svg);
-}
\ No newline at end of file
diff --git a/src/resources/themes/light/dstore--ImageViewer.theme b/src/resources/themes/light/dstore--ImageViewer.theme
new file mode 100644
index 00000000..2ab2ffd8
--- /dev/null
+++ b/src/resources/themes/light/dstore--ImageViewer.theme
@@ -0,0 +1,22 @@
+
+#ImageLabel {
+ /*box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.30);*/
+}
+
+#CloseButton {
+ qproperty-normalPic: url(:/light/images/close_normal.svg);
+ qproperty-hoverPic: url(:/light/images/close_hover.svg);
+ qproperty-pressPic: url(:/light/images/close_press.svg);
+}
+
+#PreviousButton {
+ qproperty-normalPic: url(:/light/images/previous_normal.svg);
+ qproperty-hoverPic: url(:/light/images/previous_hover.svg);
+ qproperty-pressPic: url(:/light/images/previous_press.svg);
+}
+
+#NextButton {
+ qproperty-normalPic: url(:/light/images/next_normal.svg);
+ qproperty-hoverPic: url(:/light/images/next_hover.svg);
+ qproperty-pressPic: url(:/light/images/next_press.svg);
+}
\ No newline at end of file
diff --git a/src/resources/themes/light/dstore--SearchCompletionWindow.theme b/src/resources/themes/light/dstore--SearchCompletionWindow.theme
new file mode 100644
index 00000000..b1ea82a6
--- /dev/null
+++ b/src/resources/themes/light/dstore--SearchCompletionWindow.theme
@@ -0,0 +1,39 @@
+
+#SearchCompletionWindow {
+ border: 1px solid rgba(0, 0, 0, 0.1);
+ border-radius: 4px;
+ background-color: rgba(255, 255,255, 1);
+}
+
+#ResultList {
+ color: black;
+ font-size: 12px;
+ margin: 0;
+ border: none;
+ border-bottom: 1px solid rgba(0, 0, 0, 0.04);
+}
+
+#ResultList::item {
+ background-color: rgba(255, 255, 255, 1.0);
+ height: 25px;
+ padding-left: 7px;
+}
+#ResultList::item:selected {
+ color: white;
+ background-color: #2ca7f8;
+}
+
+#SearchButton{
+ color: black;
+ font-size: 12px;
+ padding-left: 9px;
+ text-align:left;
+ border: none;
+ color: #666666;
+ background-color: rgba(255, 255, 255, 1.0);
+}
+#SearchButton:checked{
+ color: white;
+ background-color: #2ca7f8;
+}
+
diff --git a/src/resources/themes/light/TitleBar.css b/src/resources/themes/light/dstore--TitleBar.theme
similarity index 99%
rename from src/resources/themes/light/TitleBar.css
rename to src/resources/themes/light/dstore--TitleBar.theme
index 062ce90e..f79e5969 100644
--- a/src/resources/themes/light/TitleBar.css
+++ b/src/resources/themes/light/dstore--TitleBar.theme
@@ -15,4 +15,4 @@
qproperty-hoverPic: url(:/light/images/forward_hover.svg);
qproperty-pressPic: url(:/light/images/forward_press.svg);
qproperty-disabledPic: url(:/light/images/forward_insensitive.svg);
-}
\ No newline at end of file
+}
diff --git a/src/resources/themes/light/dstore--WebWindow.theme b/src/resources/themes/light/dstore--WebWindow.theme
new file mode 100644
index 00000000..18a53a79
--- /dev/null
+++ b/src/resources/themes/light/dstore--WebWindow.theme
@@ -0,0 +1,4 @@
+Dtk--Widget--DMainWindow {
+ qproperty-borderColor: rgba(0, 0, 0, 10%);
+ background-color: transparent;
+}
diff --git a/src/resources/themes/themes.qrc b/src/resources/themes/themes.qrc
index a9ef10ed..1d872d03 100644
--- a/src/resources/themes/themes.qrc
+++ b/src/resources/themes/themes.qrc
@@ -1,5 +1,4 @@
-
-
+
common/images/deepin-appstore.svg
light/images/backward_hover.svg
@@ -19,10 +18,33 @@
light/images/previous_hover.svg
light/images/previous_normal.svg
light/images/previous_press.svg
-
- light/ImageViewer.css
- light/RecommendApp.css
- light/SearchCompletionWindow.css
- light/TitleBar.css
+ light/dstore--ImageViewer.theme
+ light/dstore--SearchCompletionWindow.theme
+ light/dstore--TitleBar.theme
+ dark/images/back_hover.svg
+ dark/images/back_normal.svg
+ dark/images/back_press.svg
+ dark/images/backward_hover.svg
+ dark/images/backward_insensitive.svg
+ dark/images/backward_normal.svg
+ dark/images/backward_press.svg
+ dark/images/close_hover.svg
+ dark/images/close_normal.svg
+ dark/images/close_press.svg
+ dark/images/forward_hover.svg
+ dark/images/forward_insensitive.svg
+ dark/images/forward_normal.svg
+ dark/images/forward_press.svg
+ dark/images/next_hover.svg
+ dark/images/next_normal.svg
+ dark/images/next_press.svg
+ dark/images/previous_hover.svg
+ dark/images/previous_normal.svg
+ dark/images/previous_press.svg
+ dark/dstore--ImageViewer.theme
+ dark/dstore--SearchCompletionWindow.theme
+ dark/dstore--TitleBar.theme
+ light/dstore--WebWindow.theme
+ dark/dstore--WebWindow.theme
-
\ No newline at end of file
+
diff --git a/src/services/settings_manager.cpp b/src/services/settings_manager.cpp
index ab43def0..8b391fcd 100644
--- a/src/services/settings_manager.cpp
+++ b/src/services/settings_manager.cpp
@@ -34,6 +34,7 @@ const char kOperationPrimaryServer[] = "operationPrimary";
const char kOperationSecondaryServer[] = "operationSecondary";
const char kOperationDefault[] = "operationDefault";
const char kRegionName[] = "currentRegion";
+const char kThemeName[] = "themeName";
QVariant GetSystemSettingsValue(const QString& key) {
QSettings settings(SETTINGS_FILE, QSettings::IniFormat);
@@ -67,6 +68,17 @@ QString GetOperationServer() {
}
}
+void SetThemeName (const QString &themeName) {
+ QSettings settings(GetSessionSettingsFile(), QSettings::IniFormat);
+ settings.setValue(kThemeName, themeName);
+}
+
+QString GetThemeName() {
+ QSettings settings(GetSessionSettingsFile(), QSettings::IniFormat);
+ QString themeName = settings.value(kThemeName, "light").toString();
+ return themeName;
+}
+
void SetRegion(OperationServerRegion region) {
QSettings settings(GetSessionSettingsFile(), QSettings::IniFormat);
settings.setValue(kRegionName, static_cast(region));
@@ -109,4 +121,4 @@ bool AllowSwitchRegion() {
return GetOperationType() == OperationType::OperationCommunity;
}
-} // namespace dstore
\ No newline at end of file
+} // namespace dstore
diff --git a/src/services/settings_manager.h b/src/services/settings_manager.h
index 4ff26591..b33e1681 100644
--- a/src/services/settings_manager.h
+++ b/src/services/settings_manager.h
@@ -49,6 +49,9 @@ void SetRegion(OperationServerRegion region);
// Always returns the primary server on professional and loongson.
OperationServerRegion GetRegion();
+QString GetThemeName();
+void SetThemeName (const QString &themeName);
+
QString GetSessionSettingsFile();
OperationType GetOperationType();
diff --git a/src/ui/channel/menu_proxy.h b/src/ui/channel/menu_proxy.h
index cbde1434..704d6254 100644
--- a/src/ui/channel/menu_proxy.h
+++ b/src/ui/channel/menu_proxy.h
@@ -43,6 +43,10 @@ class MenuProxy : public QObject {
*/
void recommendAppRequested();
+ /**
+ * this signal is emitted when user click menu
+ */
+ void switchThemeRequested(QString themeName);
/**
* Login state shall be updated. This signal is emitted on web page
diff --git a/src/ui/channel/settings_proxy.cpp b/src/ui/channel/settings_proxy.cpp
index fb9b74b6..8852aba6 100644
--- a/src/ui/channel/settings_proxy.cpp
+++ b/src/ui/channel/settings_proxy.cpp
@@ -47,6 +47,7 @@ const QVariantMap SettingsProxy::getServers() {
return QVariantMap {
{ "metadataServer", GetMetadataServer() },
{ "operationServer", GetOperationServer() },
+ { "themeName", GetThemeName() },
};
}
@@ -58,4 +59,4 @@ bool SettingsProxy::upyunBannerVisible() {
return UpyunBannerVisible();
}
-} // namespace dstore
\ No newline at end of file
+} // namespace dstore
diff --git a/src/ui/utils/theme_manager.cpp b/src/ui/utils/theme_manager.cpp
deleted file mode 100644
index 3b1dc382..00000000
--- a/src/ui/utils/theme_manager.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "ui/utils/theme_manager.h"
-
-#include
-#include
-#include
-#include
-
-#include "base/file_util.h"
-
-namespace dstore {
-
-namespace {
-
-ThemeManager* g_theme_manager = nullptr;
-
-QString GetQssContent(const QString& theme, const QString& qss_filename) {
- const QString filepath = QString(":/%1/%2.css").arg(theme).arg(qss_filename);
- return ReadFile(filepath);
-}
-
-} // namespace
-
-ThemeManager::ThemeManager(QObject* parent)
- : QObject(parent),
- widgets_(),
- theme_( Dtk::Widget::DThemeManager::instance()->theme()) {
-}
-
-ThemeManager::~ThemeManager() {
-
-}
-
-ThemeManager* ThemeManager::instance() {
- if (g_theme_manager == nullptr) {
- g_theme_manager = new ThemeManager();
- }
- Q_ASSERT(g_theme_manager != nullptr);
- return g_theme_manager;
-}
-
-void ThemeManager::registerWidget(QWidget* widget) {
- Q_ASSERT(widget != nullptr);
- Q_ASSERT(!widgets_.contains(widget));
-
- widgets_.append(widget);
- QString qss_filename = widget->property("_d_QSSFilename").toString();
- if (qss_filename.isEmpty()) {
- qss_filename = widget->objectName();
- }
- if (qss_filename.isEmpty()) {
- qss_filename = widget->metaObject()->className();
- }
-
- widget->style()->unpolish(widget);
- widget->style()->polish(widget);
-
- // TODO(Shaohua): Save base stylesheet.
- widget->setStyleSheet(GetQssContent(theme_, qss_filename));
- connect(this, &ThemeManager::themeUpdated, [=](const QString& theme) {
- Q_ASSERT(widget != nullptr);
- if (widget != nullptr) {
- widget->setStyleSheet(GetQssContent(theme, qss_filename));
- widget->style()->unpolish(widget);
- widget->style()->polish(widget);
- }
- });
-}
-
-void ThemeManager::setTheme(const QString& theme) {
- if (theme == theme_) {
- return;
- }
-
- theme_ = theme;
- Dtk::Widget::DThemeManager::instance()->setTheme(theme_);
- emit this->themeUpdated(theme_);
-}
-
-} // namespace dstore
\ No newline at end of file
diff --git a/src/ui/utils/theme_manager.h b/src/ui/utils/theme_manager.h
deleted file mode 100644
index 0b7477ee..00000000
--- a/src/ui/utils/theme_manager.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef DEEPIN_APPSTORE_UI_UTILS_THEME_MANAGER_H
-#define DEEPIN_APPSTORE_UI_UTILS_THEME_MANAGER_H
-
-#include
-#include
-
-namespace dstore {
-
-// Auto-update styles of registered widgets when theme name is reset.
-class ThemeManager : public QObject {
- Q_OBJECT
- Q_PROPERTY(QString theme READ theme WRITE setTheme)
-
- public:
- // Get global instance of theme manager.
- // NOTE: Only call this method in UI thread.
- static ThemeManager* instance();
-
- const QString& theme() const {
- return theme_;
- }
-
- // Let theme manager manages stylesheet of |widget|.
- void registerWidget(QWidget* widget);
-
- signals:
- // Emitted when setTheme() is called and current theme updated.
- void themeUpdated(const QString& theme);
-
- public slots:
- void setTheme(const QString& theme);
-
- private:
- explicit ThemeManager(QObject* parent = nullptr);
- ~ThemeManager() override;
-
- QVector widgets_;
-
- // Current theme name.
- QString theme_;
-};
-
-} // namespace dstore
-
-#endif // DEEPIN_APPSTORE_UI_UTILS_THEME_MANAGER_H
diff --git a/src/ui/web_window.cpp b/src/ui/web_window.cpp
index 8d7ed6fc..cd350b82 100644
--- a/src/ui/web_window.cpp
+++ b/src/ui/web_window.cpp
@@ -18,6 +18,8 @@
#include "ui/web_window.h"
#include
+#include
+
#include
#include
#include
@@ -179,6 +181,10 @@ void WebWindow::initConnections() {
menu_proxy_, &MenuProxy::recommendAppRequested);
connect(tool_bar_menu_, &TitleBarMenu::loginRequested,
menu_proxy_, &MenuProxy::loginRequested);
+ connect(tool_bar_menu_, &TitleBarMenu::switchThemeRequested,
+ menu_proxy_, &MenuProxy::switchThemeRequested);
+ connect(tool_bar_menu_, &TitleBarMenu::switchThemeRequested,
+ this, &WebWindow::onThemeChaged);
connect(tool_bar_menu_, &TitleBarMenu::regionChanged,
this, &WebWindow::onRegionChanged);
connect(tool_bar_menu_, &TitleBarMenu::clearCacheRequested,
@@ -215,6 +221,10 @@ void WebWindow::initProxy() {
}
void WebWindow::initUI() {
+// :/dark/Dtk--Widget--DAboutDialog.theme
+// :/dark/WebWindow.css
+ Dtk::Widget::DThemeManager::instance()->registerWidget(this);
+
web_view_ = new QCefWebView();
this->setCentralWidget(web_view_);
@@ -238,6 +248,8 @@ void WebWindow::initUI() {
web_view_->page()->setEventDelegate(web_event_delegate_);
this->setFocusPolicy(Qt::ClickFocus);
+
+ Dtk::Widget::DThemeManager::instance()->setTheme(GetThemeName());
}
void WebWindow::initServices() {
@@ -365,6 +377,11 @@ void WebWindow::onTitleBarEntered() {
}
}
+void WebWindow::onThemeChaged(const QString theme_name)
+{
+ Dtk::Widget::DThemeManager::instance()->setTheme(theme_name);
+}
+
void WebWindow::onWebViewUrlChanged(const QUrl& url) {
Q_UNUSED(url);
}
diff --git a/src/ui/web_window.h b/src/ui/web_window.h
index 9f1afcc9..fa15c1dd 100644
--- a/src/ui/web_window.h
+++ b/src/ui/web_window.h
@@ -104,9 +104,10 @@ class WebWindow : public Dtk::Widget::DMainWindow {
void onSearchTextChanged(const QString& text);
void onSearchTextChangedDelay();
void onTitleBarEntered();
+ void onThemeChaged(const QString theme_name);
void onWebViewUrlChanged(const QUrl& url);
-
+
void onLoadingStateChanged(bool is_loading,
bool can_go_back,
bool can_go_forward);
diff --git a/src/ui/widgets/image_viewer.cpp b/src/ui/widgets/image_viewer.cpp
index ff0bded3..f32e6974 100644
--- a/src/ui/widgets/image_viewer.cpp
+++ b/src/ui/widgets/image_viewer.cpp
@@ -18,6 +18,7 @@
#include "ui/widgets/image_viewer.h"
#include
+#include
#include
#include
#include
@@ -27,7 +28,6 @@
#include
#include
-#include "ui/utils/theme_manager.h"
namespace dstore {
@@ -173,7 +173,7 @@ void ImageViewer::initUI() {
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setModal(true);
- ThemeManager::instance()->registerWidget(this);
+ Dtk::Widget::DThemeManager::instance()->registerWidget(this);
}
void ImageViewer::mousePressEvent(QMouseEvent* event) {
@@ -187,4 +187,4 @@ void ImageViewer::paintEvent(QPaintEvent* event) {
painter.fillRect(0, 0, this->width(), this->height(), QColor(0, 0, 0, 77));
}
-} // namespace dstore
\ No newline at end of file
+} // namespace dstore
diff --git a/src/ui/widgets/search_completion_window.cpp b/src/ui/widgets/search_completion_window.cpp
index 58d1e605..c3e649b0 100644
--- a/src/ui/widgets/search_completion_window.cpp
+++ b/src/ui/widgets/search_completion_window.cpp
@@ -19,8 +19,8 @@
#include
#include
+#include
-#include "ui/utils/theme_manager.h"
#include "ui/widgets/search_button.h"
namespace dstore {
@@ -180,7 +180,7 @@ void SearchCompletionWindow::initUI() {
Qt::BypassWindowManagerHint);
this->setAttribute(Qt::WA_NativeWindow, true);
- ThemeManager::instance()->registerWidget(this);
+ Dtk::Widget::DThemeManager::instance()->registerWidget(this);
}
void SearchCompletionWindow::onResultListClicked(const QModelIndex& index) {
diff --git a/src/ui/widgets/title_bar.cpp b/src/ui/widgets/title_bar.cpp
index 35853a01..2f1994e7 100644
--- a/src/ui/widgets/title_bar.cpp
+++ b/src/ui/widgets/title_bar.cpp
@@ -19,8 +19,8 @@
#include
#include
+#include
-#include "ui/utils/theme_manager.h"
#include "ui/widgets/search_edit.h"
namespace dstore {
@@ -105,7 +105,7 @@ void TitleBar::initUI() {
this->setAttribute(Qt::WA_TranslucentBackground, true);
- ThemeManager::instance()->registerWidget(this);
+ Dtk::Widget::DThemeManager::instance()->registerWidget(this);
}
void TitleBar::onSearchTextChanged() {
diff --git a/src/ui/widgets/title_bar_menu.cpp b/src/ui/widgets/title_bar_menu.cpp
index 157f13db..88e07a75 100644
--- a/src/ui/widgets/title_bar_menu.cpp
+++ b/src/ui/widgets/title_bar_menu.cpp
@@ -38,10 +38,6 @@ bool TitleBarMenu::isLoggedIn() const {
return is_signed_in_;
}
-bool TitleBarMenu::isDarkTheme() const {
- return is_dark_theme_;
-}
-
void TitleBarMenu::setLoginState(bool login) {
Q_ASSERT(support_sign_in_);
@@ -67,13 +63,14 @@ void TitleBarMenu::setRegion(bool is_china) {
}
}
-void TitleBarMenu::setDarkTheme(bool is_dark_theme) {
- is_dark_theme_ = is_dark_theme;
-// if (is_dark_theme) {
-// switch_theme_action_->setText(QObject::tr("Light Theme"));
-// } else {
-// switch_theme_action_->setText(QObject::tr("Dark Theme"));
-// }
+void TitleBarMenu::setThemeName(QString theme_name) {
+ theme_name_ = theme_name;
+ SetThemeName(theme_name_);
+ if (theme_name_ == "light") {
+ switch_theme_action_->setChecked(false);
+ } else {
+ switch_theme_action_->setChecked(true);
+ }
}
void TitleBarMenu::initActions() {
@@ -116,9 +113,12 @@ void TitleBarMenu::initActions() {
this->addAction(QObject::tr("Clear Cache"),
this, &TitleBarMenu::clearCacheRequested);
-// switch_theme_action_ = this->addAction(QObject::tr("Dark Theme"));
-// connect(switch_theme_action_, &QAction::triggered,
-// this, &TitleBarMenu::onThemeActionTriggered);
+ const QString themeName = GetThemeName();
+ switch_theme_action_ = this->addAction(QObject::tr("Dark Theme"));
+ switch_theme_action_->setCheckable(true);
+ connect(switch_theme_action_, &QAction::triggered,
+ this, &TitleBarMenu::onThemeActionTriggered);
+ this->setThemeName(themeName);
this->addSeparator();
}
@@ -128,7 +128,13 @@ void TitleBarMenu::onSignInActionTriggered() {
}
void TitleBarMenu::onThemeActionTriggered() {
- emit this->switchThemeRequested(!is_dark_theme_);
+ if(theme_name_ == "light") {
+ theme_name_ = "dark";
+ } else {
+ theme_name_ = "light";
+ }
+ this->setThemeName(theme_name_);
+ emit this->switchThemeRequested(theme_name_);
}
void TitleBarMenu::onRegionGroupTriggered(QAction* action) {
@@ -141,4 +147,4 @@ void TitleBarMenu::onRegionGroupTriggered(QAction* action) {
emit this->regionChanged();
}
-} // namespace dstore
\ No newline at end of file
+} // namespace dstore
diff --git a/src/ui/widgets/title_bar_menu.h b/src/ui/widgets/title_bar_menu.h
index 48dd6ab0..4d506394 100644
--- a/src/ui/widgets/title_bar_menu.h
+++ b/src/ui/widgets/title_bar_menu.h
@@ -28,10 +28,6 @@ class TitleBarMenu : public QMenu {
READ isLoggedIn
WRITE setLoginState
NOTIFY loginRequested)
- Q_PROPERTY(bool darkTheme
- READ isDarkTheme
- WRITE setDarkTheme
- NOTIFY switchThemeRequested)
public:
explicit TitleBarMenu(bool support_sign_in, QWidget* parent = nullptr);
@@ -39,11 +35,9 @@ class TitleBarMenu : public QMenu {
bool isLoggedIn() const;
- bool isDarkTheme() const;
-
signals:
void loginRequested(bool login);
- void switchThemeRequested(bool is_dark_theme);
+ void switchThemeRequested(QString themeName);
void recommendAppRequested();
void regionChanged();
void clearCacheRequested();
@@ -51,7 +45,7 @@ class TitleBarMenu : public QMenu {
public slots:
void setLoginState(bool login);
void setRegion(bool is_china);
- void setDarkTheme(bool is_dark_theme);
+ void setThemeName(QString themeName);
private:
void initActions();
@@ -63,7 +57,7 @@ class TitleBarMenu : public QMenu {
QActionGroup* region_group_ = nullptr;
QAction* region_china_ = nullptr;
QAction* region_international_ = nullptr;
- bool is_dark_theme_ = false;
+ QString theme_name_ = "light";
QAction* switch_theme_action_ = nullptr;
private slots:
diff --git a/translations/deepin-appstore.ts b/translations/deepin-appstore.ts
index d998a386..61a0add3 100644
--- a/translations/deepin-appstore.ts
+++ b/translations/deepin-appstore.ts
@@ -3,16 +3,6 @@
QObject
-
-
-
-
-
-
-
-
-
-
@@ -25,38 +15,43 @@
-
+
-
-
+
+
-
+
+
+
+
+
+
-
+
-
+
-
+
-
+
diff --git a/translations/deepin-appstore_zh_CN.ts b/translations/deepin-appstore_zh_CN.ts
index 5ff91f2f..3232cff6 100644
--- a/translations/deepin-appstore_zh_CN.ts
+++ b/translations/deepin-appstore_zh_CN.ts
@@ -1,16 +1,8 @@
-
+
+
+
QObject
-
-
-
- 深度商店
-
-
-
-
- 深度商店是一款品质精良、内容丰富的应用商店。精选热门推荐、新品应用和专题介绍。支持一键式下载安装、更新、卸载等功能。
-
@@ -23,38 +15,43 @@
搜索
-
+
退出登录
-
-
+
+
登录
-
+
+
+ 深色主题
+
+
+
推荐应用
-
+
选择地区
-
+
中国区
-
+
国际区
-
+
清除缓存
@@ -95,4 +92,4 @@
全选
-
\ No newline at end of file
+