Skip to content

Commit

Permalink
feat: can set special timezone when on deepin
Browse files Browse the repository at this point in the history
Log:
  • Loading branch information
Decodetalkers committed Oct 24, 2023
1 parent 1542865 commit bc2965e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ option(ENABLE_ASAN "Enable asan" OFF)
option(DISABLE_AUTHENTICATION "disable build authentication plugins" OFF)
option(DISABLE_UPDATE "disable build update plugins" OFF)
option(DISABLE_LANGUAGE "disable lanugage settings in control center" OFF)
option(USE_DEEPIN_ZONE "disable lanugage settings in control center" OFF)
set(DEEPIN_TIME_ZONE_PATH "/usr/share/dde/zoneinfo/zone1970.tab" CACHE STRING "deepin timezone path")

# asan 自己有内存泄露,暂不使用
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Expand Down Expand Up @@ -56,6 +58,11 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(UT_COMPILER -fprofile-instr-generate -ftest-coverage)
endif()

if (USE_DEEPIN_ZONE)
add_definitions(-DUSE_DEEPIN_ZONE)
add_definitions(-DDEEPIN_TIME_ZONE_PATH="${DEEPIN_TIME_ZONE_PATH}")
endif ()

# 增加安全编译参数
ADD_DEFINITIONS(${SAFE_COMPILER})

Expand Down Expand Up @@ -247,10 +254,10 @@ install(FILES misc/dde-control-center.desktop DESTINATION ${CMAKE_INSTALL_DATARO

#service
configure_file(
${CMAKE_SOURCE_DIR}/misc/org.deepin.dde.ControlCenter1.service.in
${CMAKE_CURRENT_BINARY_DIR}/org.deepin.dde.ControlCenter1.service
${CMAKE_SOURCE_DIR}/misc/org.deepin.dde.ControlCenter1.service.in
${CMAKE_CURRENT_BINARY_DIR}/org.deepin.dde.ControlCenter1.service
@ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.deepin.dde.ControlCenter1.service
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.deepin.dde.ControlCenter1.service
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/services)

# dev files
Expand Down
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ PACK_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}')
%:
dh $@ --parallel
override_dh_auto_configure:
dh_auto_configure -- -DCVERSION=$(DEB_VERSION_UPSTREAM) -DDVERSION=$(PACK_VER)
dh_auto_configure -- -DCVERSION=$(DEB_VERSION_UPSTREAM) -DDVERSION=$(PACK_VER) -DUSE_DEEPIN_ZONE=ON

16 changes: 15 additions & 1 deletion src/plugin-datetime/window/widgets/timezone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ const QString tzDirPath = std::visit([] {
return tzDirPath;
});

#if USE_DEEPIN_ZONE
const QString kZoneTabFileDeepin = QStringLiteral(DEEPIN_TIME_ZONE_PATH);
const QString kZoneTabFile = std::visit([] {
if (QFile(kZoneTabFileDeepin).exists()) {
return kZoneTabFileDeepin;
}
return tzDirPath + "/zone1970.tab";
});
#else
// Absolute path to zone.tab file.
const QString kZoneTabFile = std::visit([] {
return tzDirPath + "/zone1970.tab";
});
#endif

// Absolute path to backward timezone file.
const char kTimezoneAliasFile[] = "/timezone_alias";
Expand Down Expand Up @@ -179,7 +189,11 @@ QString GetLocalTimezoneName(const QString &timezone, const QString &locale)
if (timezone.isEmpty()) {
return false;
}

#if USE_DEEPIN_ZONE
if (kZoneTabFile == kZoneTabFileDeepin && QFile(kZoneTabFile).exists()) {
return true;
}
#endif
// If |filepath| is a file or a symbolic link to file, it is a valid timezone.
const QString filepath(tzDirPath + QDir::separator() + timezone);
return QFile::exists(filepath);
Expand Down

0 comments on commit bc2965e

Please sign in to comment.