diff --git a/CMakeLists.txt b/CMakeLists.txt index 3db2239bc7..4b71fb1474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "enable special timezone file on deepin" OFF) +set(DEEPIN_TIME_ZONE_PATH "/usr/share/dde/zoneinfo/zone1970.tab" CACHE STRING "deepin timezone path") # asan 自己有内存泄露,暂不使用 if (CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -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}) @@ -249,10 +256,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 diff --git a/debian/rules b/debian/rules index 660d76c670..8514aed34a 100755 --- a/debian/rules +++ b/debian/rules @@ -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 diff --git a/src/plugin-datetime/operation/datetimedbusproxy.cpp b/src/plugin-datetime/operation/datetimedbusproxy.cpp index d088ec4a93..f3f368005f 100644 --- a/src/plugin-datetime/operation/datetimedbusproxy.cpp +++ b/src/plugin-datetime/operation/datetimedbusproxy.cpp @@ -190,10 +190,11 @@ bool DatetimeDBusProxy::GetZoneInfo(const QString &zone, QObject *receiver, cons argumentList << QVariant::fromValue(zone); return m_timedateInter->callWithCallback(QStringLiteral("GetZoneInfo"), argumentList, receiver, member); } + // System Timedate -void DatetimeDBusProxy::SetTimezone(const QString &timezone, const QString &message) +void DatetimeDBusProxy::SetTimezone(const QString &timezone) { - m_systemtimedatedInter->asyncCall(QStringLiteral("SetTimezone"), timezone, message); + m_timedateInter->asyncCall(QStringLiteral("SetTimezone"), timezone); } void DatetimeDBusProxy::SetNTPServer(const QString &server, const QString &message) diff --git a/src/plugin-datetime/operation/datetimedbusproxy.h b/src/plugin-datetime/operation/datetimedbusproxy.h index fa3888ce83..3689bebfaf 100644 --- a/src/plugin-datetime/operation/datetimedbusproxy.h +++ b/src/plugin-datetime/operation/datetimedbusproxy.h @@ -131,7 +131,7 @@ public Q_SLOTS: ZoneInfo GetZoneInfo(const QString &zone); bool GetZoneInfo(const QString &zone, QObject *receiver, const char *member); // System Timedate - void SetTimezone(const QString &timezone, const QString &message); + void SetTimezone(const QString &timezone); void SetNTPServer(const QString &server, const QString &message); void SetNTPServer(const QString &server, const QString &message, diff --git a/src/plugin-datetime/operation/datetimeworker.cpp b/src/plugin-datetime/operation/datetimeworker.cpp index 9e1ca77bfc..9fba158650 100644 --- a/src/plugin-datetime/operation/datetimeworker.cpp +++ b/src/plugin-datetime/operation/datetimeworker.cpp @@ -41,7 +41,7 @@ DatetimeWorker::DatetimeWorker(DatetimeModel *model, QObject *parent) connect(m_timedateInter, &DatetimeDBusProxy::TimezoneChanged, m_model, &DatetimeModel::setTimeZoneInfo); m_model->setCurrentTimeZone(GetZoneInfo(QTimeZone::systemTimeZoneId())); - m_model->setCurrentUseTimeZone(GetZoneInfo(QTimeZone::systemTimeZoneId())); + m_model->setCurrentUseTimeZone(GetZoneInfo(m_timedateInter->timezone())); m_model->set24HourFormat(m_timedateInter->use24HourFormat()); refreshNtpServerList(); @@ -116,7 +116,7 @@ void DatetimeWorker::set24HourType(bool state) #ifndef DCC_DISABLE_TIMEZONE void DatetimeWorker::setTimezone(const QString &timezone) { - m_timedateInter->SetTimezone(timezone, tr("Authentication is required to set the system timezone")); + m_timedateInter->SetTimezone(timezone); } void DatetimeWorker::removeUserTimeZone(const ZoneInfo &info) diff --git a/src/plugin-datetime/window/widgets/timezone.cpp b/src/plugin-datetime/window/widgets/timezone.cpp index b6e5b20d45..25fd246c92 100644 --- a/src/plugin-datetime/window/widgets/timezone.cpp +++ b/src/plugin-datetime/window/widgets/timezone.cpp @@ -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"; @@ -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); diff --git a/src/plugin-datetime/window/widgets/timezone_map.cpp b/src/plugin-datetime/window/widgets/timezone_map.cpp index 6d2983bc61..30872ddc82 100644 --- a/src/plugin-datetime/window/widgets/timezone_map.cpp +++ b/src/plugin-datetime/window/widgets/timezone_map.cpp @@ -72,7 +72,7 @@ bool TimezoneMap::setTimezone(const QString &timezone) return true; } else { // NOTE(xushaohua): "Etc/UTC" can not be set on the map - qWarning() << "Timezone not found:" << timezone; + qInfo() << "Timezone not found:" << timezone; } return false;