Commit c4913937 authored by Ramon Buldó's avatar Ramon Buldó

Some work on timedate page

-Use qt5 tools for translations
-Update DEPENDS
parent 811ccef1
Main developers:
Roland Singer <roland@manjaro.org>
Ramon Buldó <rbuldo@gmail.com>
Ramon Buldó <ramon@manjaro.org>
qt4 or qt5
qt5-core
qt5-webkit
pacman
keyboardctl
locale-info
mhwd
#! /bin/sh
/usr/lib/qt4/bin/lrelease src/manjaro-settings-manager/manjaro-settings-manager.pro
/usr/lib/qt4/bin/lrelease src/manjaro-settings-manager-daemon/manjaro-settings-manager-daemon.pro
/usr/lib/qt/bin/lrelease src/manjaro-settings-manager/manjaro-settings-manager.pro
/usr/lib/qt/bin/lrelease src/manjaro-settings-manager-daemon/manjaro-settings-manager-daemon.pro
#! /bin/sh
/usr/lib/qt4/bin/lupdate src/manjaro-settings-manager/manjaro-settings-manager.pro -ts src/manjaro-settings-manager/translations/msm_en.ts
/usr/lib/qt4/bin/lupdate src/manjaro-settings-manager-daemon/manjaro-settings-manager-daemon.pro -ts src/manjaro-settings-manager-daemon/translations/msmd_en.ts
/usr/lib/qt/bin/lupdate src/manjaro-settings-manager/manjaro-settings-manager.pro -ts src/manjaro-settings-manager/translations/msm_en.ts
/usr/lib/qt/bin/lupdate src/manjaro-settings-manager-daemon/manjaro-settings-manager-daemon.pro -ts src/manjaro-settings-manager-daemon/translations/msmd_en.ts
......@@ -6,8 +6,6 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = manjaro-settings-manager-daemon
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++0x
......
......@@ -106,7 +106,7 @@ void KernelListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem
int labelWidth = 0;
int labelHeight = 0;
for (auto str : labelStringList) {
for (QString str : labelStringList) {
QSize labelSize = labelFontMetrics.size(Qt::TextSingleLine, str);
if (labelSize.width() > labelWidth)
labelWidth = labelSize.width();
......@@ -189,7 +189,7 @@ void KernelListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem
int buttonWidth = 0;
int buttonHeight = 0;
for (auto str : buttonStringList) {
for (QString str : buttonStringList) {
QSize buttonSize = buttonFontMetrics.size(Qt::TextSingleLine, str);
if (buttonSize.width() > buttonWidth)
buttonWidth = buttonSize.width();
......@@ -254,7 +254,7 @@ bool KernelListViewDelegate::editorEvent(QEvent *event, QAbstractItemModel *mode
int buttonWidth = 0;
int buttonHeight = 0;
for (auto str : buttonStringList) {
for (QString str : buttonStringList) {
QSize buttonSize = buttonFontMetrics.size(Qt::TextSingleLine, str);
if (buttonSize.width() > buttonWidth)
buttonWidth = buttonSize.width();
......
......@@ -21,9 +21,9 @@
#ifndef KERNEL_INFO_DIALOG_H
#define KERNEL_INFO_DIALOG_H
#include <QDialog>
#include <QWebView>
#include <QDebug>
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtWidgets/QDialog>
namespace Ui {
class KernelInfoDialog;
......
......@@ -43,7 +43,7 @@
#include "pages/page_mhwd.h"
#include "pages/page_notifications.h"
#include "pages/page_users.h"
#include "pages/page_time_date.h"
#include "pages/PageTimeDate.h"
namespace Ui {
......
......@@ -4,9 +4,7 @@
#
#-------------------------------------------------
QT += core gui webkit webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
QT += core gui webkitwidgets dbus
LIBS += -lmhwd
TARGET = manjaro-settings-manager-gui
......@@ -22,6 +20,9 @@ SOURCES += main.cpp \
dialogs/changepassworddialog.cpp \
dialogs/kernel_info_dialog.cpp \
dialogs/previewfiledialog.cpp \
models/KernelModel.cpp \
models/Kernel.cpp \
models/TimeDate.cpp \
pages/page_kernel.cpp \
pages/page_keyboard.cpp \
pages/page_language.cpp \
......@@ -29,15 +30,13 @@ SOURCES += main.cpp \
pages/page_mhwd.cpp \
pages/page_notifications.cpp \
pages/page_users.cpp \
pages/page_time_date.cpp \
pages/PageTimeDate.cpp \
widgets/flatbutton.cpp \
widgets/listwidget.cpp \
widgets/keyboardpreview.cpp \
widgets/pagewidget.cpp \
widgets/selectlocalesdialog.cpp \
widgets/toolbarstylewidget.cpp \
models/KernelModel.cpp \
models/Kernel.cpp
widgets/toolbarstylewidget.cpp
......@@ -49,6 +48,9 @@ HEADERS += mainwindow.h \
dialogs/changepassworddialog.h \
dialogs/kernel_info_dialog.h \
dialogs/previewfiledialog.h \
models/KernelModel.h \
models/Kernel.h \
models/TimeDate.h \
pages/page_kernel.h \
pages/page_keyboard.h \
pages/page_language.h \
......@@ -56,15 +58,13 @@ HEADERS += mainwindow.h \
pages/page_mhwd.h \
pages/page_notifications.h \
pages/page_users.h \
pages/page_time_date.h \
pages/PageTimeDate.h \
widgets/flatbutton.h \
widgets/listwidget.h \
widgets/keyboardpreview.h \
widgets/pagewidget.h \
widgets/selectlocalesdialog.h \
widgets/toolbarstylewidget.h \
models/KernelModel.h \
models/Kernel.h
widgets/toolbarstylewidget.h
......@@ -81,11 +81,12 @@ FORMS += mainwindow.ui \
pages/page_mhwd.ui \
pages/page_notifications.ui \
pages/page_users.ui \
pages/page_time_date.ui \
pages/PageTimeDate.ui \
widgets/selectlocalesdialog.ui
TRANSLATIONS += translations/msm_ast.ts \
translations/msm_bg_BG.ts \
translations/msm_ca.ts \
......
#include "TimeDate.h"
#include <QDebug>
TimeDate::TimeDate(QObject *parent) :
QObject(parent)
{
dbusInterface_ = new QDBusInterface( "org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
QDBusConnection::systemBus(),
0 );
}
TimeDate::~TimeDate()
{
delete dbusInterface_;
}
QDateTime TimeDate::localDateTime()
{
return QDateTime::fromTime_t( (dbusInterface_->property("TimeUSec")).toString().left(10).toUInt() );
}
QDateTime TimeDate::utcDateTime()
{
QDateTime aux;
aux.setTime_t( (dbusInterface_->property("TimeUSec")).toString().left(10).toUInt() );
aux.setTimeSpec(Qt::LocalTime);
return aux.toUTC();
}
QDateTime TimeDate::rtcDateTime()
{
return QDateTime::fromTime_t( (dbusInterface_->property("RTCTimeUSec")).toString().left(10).toUInt() );
}
QString TimeDate::timeZone()
{
return dbusInterface_->property("Timezone").toString();
}
bool TimeDate::canNtp()
{
return dbusInterface_->property("CanNTP").toBool();
}
bool TimeDate::isNtpEnabled()
{
return dbusInterface_->property("NTP").toBool();
}
bool TimeDate::isNtpSynchronized()
{
return dbusInterface_->property("NTPSynchronized").toBool();
}
bool TimeDate::isRtcInLocalTimeZone()
{
return dbusInterface_->property("LocalRTC").toBool();
}
bool TimeDate::isDstActive()
{
return false;
}
QDateTime TimeDate::lastDstChange()
{
return QDateTime();
}
QDateTime TimeDate::nextDstChange()
{
return QDateTime();
}
void TimeDate::updateTimeZonesList()
{
}
void TimeDate::setTime(const QDateTime &time)
{
}
void TimeDate::setTimeZone(const QString &timeZone)
{
}
void TimeDate::setLocalRtc(const bool &local)
{
}
void TimeDate::setNtp(const bool &ntp)
{
}
#ifndef TIMEDATE_H
#define TIMEDATE_H
#include <QtCore/QDateTime>
#include <QtCore/QObject>
#include <QtCore/QString>
#include <QtCore/QStringListModel>
#include <QtDBus/QDBusInterface>
class TimeDate : public QObject
{
Q_OBJECT
public:
explicit TimeDate(QObject *parent = 0);
~TimeDate();
QDateTime localDateTime();
QDateTime utcDateTime();
QDateTime rtcDateTime();
QString timeZone();
bool canNtp();
bool isNtpEnabled();
bool isNtpSynchronized();
bool isRtcInLocalTimeZone();
bool isDstActive();
QDateTime lastDstChange();
QDateTime nextDstChange();
void updateTimeZonesList();
void setTime(const QDateTime &time);
void setTimeZone(const QString &timeZone);
void setLocalRtc(const bool &local);
void setNtp(const bool &ntp);
signals:
public slots:
private:
QStringListModel timeZonesList_;
QDBusInterface *dbusInterface_;
};
#endif // TIMEDATE_H
......@@ -18,19 +18,72 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "page_time_date.h"
#include "ui_page_time_date.h"
#include "PageTimeDate.h"
#include "ui_PageTimeDate.h"
#include <QtCore/QDebug>
#include <QtCore/QStringList>
#include <QtCore/QTimeZone>
#include <QtCore/QDateTime>
PageTimeDate::PageTimeDate(QWidget *parent) :
PageWidget(parent),
ui(new Ui::PageTimeDate)
ui(new Ui::PageTimeDate),
timeDate(new TimeDate)
{
ui->setupUi(this);
setTitel(tr("Time and Date"));
setIcon(QPixmap(":/images/resources/help.png"));
ui->localDateTimeEdit->setDateTime( timeDate->localDateTime() );
ui->utcDateTimeEdit->setDateTime( timeDate->utcDateTime() );
ui->rtcDateTimeEdit->setDateTime( timeDate->rtcDateTime() );
ui->timeZonelineEdit->setText( timeDate->timeZone() );
ui->canNtpCheckBox->setChecked( timeDate->canNtp() );
ui->isNtpEnabledCheckBox->setChecked( timeDate->isNtpEnabled() );
ui->isNtpSyncCheckBox->setChecked( timeDate->isNtpSynchronized() );
ui->isRtcInLocalTimezoneCheckBox->setChecked( timeDate->isRtcInLocalTimeZone() );
qDebug() << timeDate->isDstActive();
qDebug() << timeDate->lastDstChange();
qDebug() << timeDate->nextDstChange();
QList<QByteArray> ids = QTimeZone::availableTimeZoneIds();
QStringList ids2;
int current;
for (QByteArray i : ids) {
if ( i.startsWith("UTC") ) {
continue;
}
ids2.append(i);
if (&ids2.last() == ui->timeZonelineEdit->text() ) {
current = ids2.length() - 1;
}
}
QStringListModel *model = new QStringListModel();
model->setStringList(ids2);
ui->listView->setModel( model );
QModelIndex index = model->index( current );
if ( index.isValid() ) {
ui->listView->setCurrentIndex( index );
}
/*
dbusInterface.connection().connect( "org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.DBus.Properties",
"PropertiesChanged", this,
SLOT(timedateChanged() ) );
*/
}
PageTimeDate::~PageTimeDate()
{
delete ui;
delete timeDate;
}
void PageTimeDate::timedateChanged() {
qDebug() << "hi";
}
......@@ -18,9 +18,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PAGE_TIME_DATE_H
#define PAGE_TIME_DATE_H
#ifndef PAGETIMEDATE_H
#define PAGETIMEDATE_H
#include "models/TimeDate.h"
#include "widgets/pagewidget.h"
namespace Ui {
......@@ -35,8 +36,13 @@ public:
explicit PageTimeDate(QWidget *parent = 0);
~PageTimeDate();
public slots:
void timedateChanged();
private:
Ui::PageTimeDate *ui;
TimeDate *timeDate;
};
#endif // PAGE_TIME_DATE_H
#endif // PAGETIMEDATE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PageTimeDate</class>
<widget class="QWidget" name="PageTimeDate">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>717</width>
<height>542</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListView" name="listView"/>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>localDateTime</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDateTimeEdit" name="localDateTimeEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>utcDateTime</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDateTimeEdit" name="utcDateTimeEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>rtcDateTime</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>timeZone</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="timeZonelineEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>can Ntp</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="canNtpCheckBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>isNtpEnabled</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="isNtpEnabledCheckBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>isNtpSync</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>isRtcInLocalTimezone</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>isDstActive</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>lastDstChange</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>nextDstChange</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="isNtpSyncCheckBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="isRtcInLocalTimezoneCheckBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="isDstActiveCheckBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QDateTimeEdit" name="lastDstChangeDateTimeEdit"/>
</item>
<item row="10" column="1">
<widget class="QDateTimeEdit" name="nextDstChangeDateTimeEdit"/>
</item>
<item row="2" column="1">
<widget class="QDateTimeEdit" name="rtcDateTimeEdit"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>PageTimeDate</class>
<widget class="QWidget" name="PageTimeDate">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<pixmapfunction/>
<connections/>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment