Skip to content

Commit

Permalink
Add date/time settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Nov 30, 2020
1 parent c2302d4 commit 41d4cd1
Show file tree
Hide file tree
Showing 356 changed files with 15,216 additions and 1 deletion.
2 changes: 1 addition & 1 deletion desktop/defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ videos.loop=/usr/share/thedesk/media/welcome3.webm
[StatusCenter]
panesOrder=OverviewPane:NetworkManagerPane:NotificationsPane
quickSwitchOrder=NetworkFlight:NetworkWireless:NetworkCellular:Redshift
settingsOrder=DisplaySettings:ThemeSettings:InputSettings:PowerSettings:LocaleSettings:UsersSettings:AccessibilitySettings:SystemPluginManagement:SystemRecovery:SystemAbout
settingsOrder=DisplaySettings:ThemeSettings:InputSettings:PowerSettings:LocaleSettings:UsersSettings:DateTimeSettings:AccessibilitySettings:SystemPluginManagement:SystemRecovery:SystemAbout

[Locale]
locales=en
Expand Down
8 changes: 8 additions & 0 deletions plugins/TimeDatePlugin/Plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Date and Time management",
"icon": "preferences-system-time",
"uuid": "e8e71dad-f372-4f96-a2c9-3462af834ada",
"vi": {
"name": "Quản lý ngày và giờ"
}
}
48 changes: 48 additions & 0 deletions plugins/TimeDatePlugin/TimeDatePlugin.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
QT += gui widgets

TEMPLATE = lib
CONFIG += plugin

CONFIG += c++11

# Include the-libs build tools
include(/usr/share/the-libs/pri/gentranslations.pri)

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
onboarding/onboardingtimezone.cpp \
plugin.cpp \
popovers/settimezonepopover.cpp \
settings/datetimepane.cpp \
timezonesmodel.cpp

HEADERS += \
onboarding/onboardingtimezone.h \
plugin.h \
popovers/settimezonepopover.h \
settings/datetimepane.h \
timezonesmodel.h

DISTFILES += \
Plugin.json \
defaults.conf

unix {
translations.files = translations/*.qm
translations.path = /usr/share/thedesk/TimeDatePlugin/translations

defaults.files = defaults.conf
defaults.path = /etc/theSuite/theDesk/TimeDatePlugin/

INSTALLS += translations defaults
}

include(../plugins.pri)

FORMS += \
onboarding/onboardingtimezone.ui \
popovers/settimezonepopover.ui \
settings/datetimepane.ui
Empty file.
81 changes: 81 additions & 0 deletions plugins/TimeDatePlugin/onboarding/onboardingtimezone.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/****************************************
*
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
* Copyright (C) 2020 Victor Tran
*
* 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
* (at your option) 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 <http://www.gnu.org/licenses/>.
*
* *************************************/
#include "onboardingtimezone.h"
#include "ui_onboardingtimezone.h"

#include <statemanager.h>
#include <onboardingmanager.h>
#include "timezonesmodel.h"

struct OnboardingTimeZonePrivate {
TimezonesModel* model;
};

OnboardingTimeZone::OnboardingTimeZone(QWidget* parent) :
OnboardingPage(parent),
ui(new Ui::OnboardingTimeZone) {
ui->setupUi(this);
d = new OnboardingTimeZonePrivate();
d->model = new TimezonesModel();

ui->titleLabel->setBackButtonShown(true);
ui->listView->setModel(d->model);
ui->listView->setItemDelegate(new TimezonesModelDelegate());
ui->nextButton->setEnabled(false);
}

OnboardingTimeZone::~OnboardingTimeZone() {
delete ui;
}

QString OnboardingTimeZone::name() {
return QStringLiteral("OnboardingTimeZone");
}

QString OnboardingTimeZone::displayName() {
return tr("Time Zone");
}

void OnboardingTimeZone::on_titleLabel_backButtonClicked() {
StateManager::onboardingManager()->previousStep();
}

void OnboardingTimeZone::on_nextButton_clicked() {
StateManager::onboardingManager()->nextStep();
}

void OnboardingTimeZone::on_searchBox_textChanged(const QString& arg1) {
d->model->search(arg1);
}

void OnboardingTimeZone::on_listView_activated(const QModelIndex& index) {
QDBusMessage setTimezoneMessage = QDBusMessage::createMethodCall("org.freedesktop.timedate1", "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "SetTimezone");
setTimezoneMessage.setArguments({index.data(Qt::UserRole).toString(), true});
QDBusConnection::systemBus().call(setTimezoneMessage, QDBus::NoBlock);

StateManager::onboardingManager()->setDateVisible(true);
ui->nextButton->setEnabled(true);
}

void OnboardingTimeZone::on_ntpCheckbox_toggled(bool checked) {
QDBusMessage setNtpMessage = QDBusMessage::createMethodCall("org.freedesktop.timedate1", "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "SetNTP");
setNtpMessage.setArguments({checked, true});
QDBusConnection::systemBus().call(setNtpMessage);
}
54 changes: 54 additions & 0 deletions plugins/TimeDatePlugin/onboarding/onboardingtimezone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/****************************************
*
* INSERT-PROJECT-NAME-HERE - INSERT-GENERIC-NAME-HERE
* Copyright (C) 2020 Victor Tran
*
* 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
* (at your option) 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 <http://www.gnu.org/licenses/>.
*
* *************************************/
#ifndef ONBOARDINGTIMEZONE_H
#define ONBOARDINGTIMEZONE_H

#include <QWidget>
#include <onboardingpage.h>

namespace Ui {
class OnboardingTimeZone;
}

struct OnboardingTimeZonePrivate;
class OnboardingTimeZone : public OnboardingPage {
Q_OBJECT

public:
explicit OnboardingTimeZone(QWidget* parent = nullptr);
~OnboardingTimeZone();

private:
Ui::OnboardingTimeZone* ui;
OnboardingTimeZonePrivate* d;

// OnboardingPage interface
public:
QString name();
QString displayName();
private slots:
void on_titleLabel_backButtonClicked();
void on_nextButton_clicked();
void on_searchBox_textChanged(const QString& arg1);
void on_listView_activated(const QModelIndex& index);
void on_ntpCheckbox_toggled(bool checked);
};

#endif // ONBOARDINGTIMEZONE_H
Loading

0 comments on commit 41d4cd1

Please sign in to comment.