Unverified Commit 72419e60 authored by Ramon Buldó's avatar Ramon Buldó Committed by GitHub

Merge pull request #129 from vfjpl/fixed_ntp_settings

timedate improvements
parents cfa6aee9 a6469bd4
/* === This file is part of Calamares - <http://github.com/calamares> === /* === This file is part of Calamares - <http://github.com/calamares> ===
* *
* Copyright 2014, Teo Mrnjavac <teo@kde.org> * Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Kacper Piwiński
* *
* Originally from the Manjaro Installation Framework * Originally from the Manjaro Installation Framework
* by Roland Singer <roland@manjaro.org> * by Roland Singer <roland@manjaro.org>
...@@ -25,7 +26,8 @@ ...@@ -25,7 +26,8 @@
QHash<QString, QHash<QString, QList<LocaleGlobal::Locale> > > LocaleGlobal::locales; QHash<QString, QHash<QString, QList<LocaleGlobal::Locale> > > LocaleGlobal::locales;
QHash<QString, QList<LocaleGlobal::Location> > LocaleGlobal::locations; QHash<QString, QList<LocaleGlobal::Location> > LocaleGlobal::locations;
void LocaleGlobal::init() void
LocaleGlobal::init()
{ {
// TODO: Error handling // TODO: Error handling
initLocales(); initLocales();
...@@ -47,7 +49,8 @@ LocaleGlobal::getLocations() ...@@ -47,7 +49,8 @@ LocaleGlobal::getLocations()
} }
void LocaleGlobal::initLocales() void
LocaleGlobal::initLocales()
{ {
locales.clear(); locales.clear();
...@@ -70,7 +73,11 @@ void LocaleGlobal::initLocales() ...@@ -70,7 +73,11 @@ void LocaleGlobal::initLocales()
while ( !in.atEnd() ) while ( !in.atEnd() )
{ {
QString line = in.readLine().trimmed(); QString line = in.readLine().trimmed();
QStringList split = line.split( commentChar, QString::KeepEmptyParts ).first().split( QRegExp( " (?=[^\"]*(\"[^\"]*\"[^\"]*)*$)" ), QString::SkipEmptyParts );
QStringList split = line
.split( commentChar, QString::KeepEmptyParts )
.first()
.split( QRegExp( " (?=[^\"]*(\"[^\"]*\"[^\"]*)*$)" ), QString::SkipEmptyParts );
if ( split.size() < 2 ) if ( split.size() < 2 )
continue; continue;
...@@ -96,7 +103,8 @@ void LocaleGlobal::initLocales() ...@@ -96,7 +103,8 @@ void LocaleGlobal::initLocales()
} }
void LocaleGlobal::initLocations() void
LocaleGlobal::initLocations()
{ {
locations.clear(); locations.clear();
QFile file( TZ_DATA_FILE ); QFile file( TZ_DATA_FILE );
...@@ -131,7 +139,8 @@ void LocaleGlobal::initLocations() ...@@ -131,7 +139,8 @@ void LocaleGlobal::initLocations()
} }
double LocaleGlobal::getRightGeoLocation( QString str ) double
LocaleGlobal::getRightGeoLocation( QString str )
{ {
double sign = 1, num = 0.00; double sign = 1, num = 0.00;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* This file is part of Manjaro Settings Manager. * This file is part of Manjaro Settings Manager.
* *
* Ramon Buldó <ramon@manjaro.org> * Ramon Buldó <ramon@manjaro.org>
* Kacper Piwiński
* *
* Manjaro Settings Manager is free software: you can redistribute it and/or modify * Manjaro Settings Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -17,14 +18,12 @@ ...@@ -17,14 +18,12 @@
* along with Manjaro Settings Manager. If not, see <http://www.gnu.org/licenses/>. * along with Manjaro Settings Manager. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "TimeDateCommon.h" #include "TimeDateCommon.h"
#include "TimeZoneDialog.h" #include "TimeZoneDialog.h"
#include <QtCore/QTimeZone> #include <QtCore/QTimeZone>
#include <QDebug> #include <QDebug>
QString QString
TimeDateCommon::getName() TimeDateCommon::getName()
{ {
...@@ -91,15 +90,23 @@ void ...@@ -91,15 +90,23 @@ void
TimeDateCommon::updateUi( Ui::PageTimeDate* ui, TimeDateService* timeDateService, TimeDateCommon::updateUi( Ui::PageTimeDate* ui, TimeDateService* timeDateService,
bool isTimeEdited, bool isDateEdited, QString currentTimeZone ) bool isTimeEdited, bool isDateEdited, QString currentTimeZone )
{ {
ui->isNtpEnabledCheckBox->blockSignals( true );
if ( timeDateService->canNtp() ) if ( timeDateService->canNtp() )
{
ui->isNtpEnabledCheckBox->setChecked( timeDateService->isNtpEnabled() ); ui->isNtpEnabledCheckBox->setChecked( timeDateService->isNtpEnabled() );
ui->timeEdit->setEnabled( !ui->isNtpEnabledCheckBox->isChecked() );
ui->dateEdit->setEnabled( !ui->isNtpEnabledCheckBox->isChecked() );
}
else else
{ {
ui->isNtpEnabledCheckBox->setChecked( false ); ui->isNtpEnabledCheckBox->setChecked( false );
ui->isNtpEnabledCheckBox->setEnabled( false ); ui->isNtpEnabledCheckBox->setEnabled( false );
} }
ui->isNtpEnabledCheckBox->blockSignals( false );
ui->isRtcLocalCheckBox->blockSignals( true );
ui->isRtcLocalCheckBox->setChecked( timeDateService->isRtcInLocalTimeZone() ); ui->isRtcLocalCheckBox->setChecked( timeDateService->isRtcInLocalTimeZone() );
ui->isRtcLocalCheckBox->blockSignals( false );
QTimeZone timeZone = QTimeZone( currentTimeZone.toLatin1() ); QTimeZone timeZone = QTimeZone( currentTimeZone.toLatin1() );
if ( timeZone.isValid() ) if ( timeZone.isValid() )
......
/* /*
* Manjaro Settings Manager * Manjaro Settings Manager
* Ramon Buldó <ramon@manjaro.org> * Ramon Buldó <ramon@manjaro.org>
* Kacper Piwiński
* *
* Copyright (C) 2007 Free Software Foundation, Inc. * Copyright (C) 2007 Free Software Foundation, Inc.
* *
...@@ -43,7 +44,8 @@ TimeDateKcm::TimeDateKcm( QWidget* parent, const QVariantList& args ) : ...@@ -43,7 +44,8 @@ TimeDateKcm::TimeDateKcm( QWidget* parent, const QVariantList& args ) :
hBoxLayout->addWidget( m_timeDateModule ); hBoxLayout->addWidget( m_timeDateModule );
connect( m_timeDateModule, &TimeDateModule::changed, [this] () connect( m_timeDateModule, &TimeDateModule::changed,
[this] ()
{ {
emit changed(); emit changed();
} ); } );
...@@ -52,20 +54,26 @@ TimeDateKcm::TimeDateKcm( QWidget* parent, const QVariantList& args ) : ...@@ -52,20 +54,26 @@ TimeDateKcm::TimeDateKcm( QWidget* parent, const QVariantList& args ) :
TimeDateKcm::~TimeDateKcm() TimeDateKcm::~TimeDateKcm()
{ {
delete m_timeDateModule;
} }
void TimeDateKcm::load()
void
TimeDateKcm::load()
{ {
m_timeDateModule->load(); m_timeDateModule->load();
} }
void TimeDateKcm::save()
void
TimeDateKcm::save()
{ {
m_timeDateModule->save(); m_timeDateModule->save();
} }
void TimeDateKcm::defaults()
void
TimeDateKcm::defaults()
{ {
m_timeDateModule->defaults(); m_timeDateModule->defaults();
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* This file is part of Manjaro Settings Manager. * This file is part of Manjaro Settings Manager.
* *
* Ramon Buldó <ramon@manjaro.org> * Ramon Buldó <ramon@manjaro.org>
* Kacper Piwiński
* *
* Manjaro Settings Manager is free software: you can redistribute it and/or modify * Manjaro Settings Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -61,19 +62,22 @@ TimeDateModule::TimeDateModule( QWidget* parent, const QVariantList& args ) : ...@@ -61,19 +62,22 @@ TimeDateModule::TimeDateModule( QWidget* parent, const QVariantList& args ) :
ui->setupUi( this ); ui->setupUi( this );
connect( m_timeFieldsTimer, &QTimer::timeout, connect( m_timeFieldsTimer, &QTimer::timeout,
[=] ( ) [this] ()
{ {
TimeDateCommon::updateTimeFields( ui, m_timeDateService, m_isTimeEdited, m_isDateEdited ); TimeDateCommon::updateTimeFields( ui, m_timeDateService, m_isTimeEdited, m_isDateEdited );
} ); } );
connect( ui->isNtpEnabledCheckBox, &QCheckBox::toggled, connect( ui->isNtpEnabledCheckBox, &QCheckBox::toggled,
[=] ( bool checked ) [this] ( bool checked )
{ {
ui->timeEdit->setEnabled( !checked ); ui->timeEdit->setEnabled( !checked );
ui->dateEdit->setEnabled( !checked ); ui->dateEdit->setEnabled( !checked );
emit changed();
} ); } );
connect( ui->timeZonePushButton, &QPushButton::clicked, [=] ( bool checked )
connect( ui->timeZonePushButton, &QPushButton::clicked,
[this] ()
{ {
Q_UNUSED( checked )
QString newTimeZone = TimeDateCommon::showTimeZoneSelector( m_timeZone ); QString newTimeZone = TimeDateCommon::showTimeZoneSelector( m_timeZone );
if ( !newTimeZone.isEmpty() ) if ( !newTimeZone.isEmpty() )
{ {
...@@ -82,18 +86,21 @@ TimeDateModule::TimeDateModule( QWidget* parent, const QVariantList& args ) : ...@@ -82,18 +86,21 @@ TimeDateModule::TimeDateModule( QWidget* parent, const QVariantList& args ) :
emit changed(); emit changed();
} }
} ); } );
connect( ui->timeEdit, &QTimeEdit::timeChanged, connect( ui->timeEdit, &QTimeEdit::timeChanged,
[this] () [this] ()
{ {
m_isTimeEdited = true; m_isTimeEdited = true;
emit changed(); emit changed();
} ); } );
connect( ui->dateEdit, &QTimeEdit::dateChanged, connect( ui->dateEdit, &QTimeEdit::dateChanged,
[this] () [this] ()
{ {
m_isDateEdited = true; m_isDateEdited = true;
emit changed(); emit changed();
} ); } );
connect( ui->isRtcLocalCheckBox, &QCheckBox::toggled, connect( ui->isRtcLocalCheckBox, &QCheckBox::toggled,
[this] () [this] ()
{ {
...@@ -106,6 +113,7 @@ TimeDateModule::~TimeDateModule() ...@@ -106,6 +113,7 @@ TimeDateModule::~TimeDateModule()
{ {
delete ui; delete ui;
delete m_timeDateService; delete m_timeDateService;
delete m_timeFieldsTimer;
} }
...@@ -134,5 +142,4 @@ TimeDateModule::defaults() ...@@ -134,5 +142,4 @@ TimeDateModule::defaults()
load(); load();
} }
#include "TimeDateModule.moc" #include "TimeDateModule.moc"
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* This file is part of Manjaro Settings Manager. * This file is part of Manjaro Settings Manager.
* *
* Ramon Buldó <ramon@manjaro.org> * Ramon Buldó <ramon@manjaro.org>
* Kacper Piwiński
* *
* Manjaro Settings Manager is free software: you can redistribute it and/or modify * Manjaro Settings Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -29,7 +30,6 @@ ...@@ -29,7 +30,6 @@
#include <QtCore/QDateTime> #include <QtCore/QDateTime>
#include <QtCore/QTimer> #include <QtCore/QTimer>
TimeDatePage::TimeDatePage( QWidget* parent ) : TimeDatePage::TimeDatePage( QWidget* parent ) :
PageWidget( parent ), PageWidget( parent ),
ui( new Ui::PageTimeDate ), ui( new Ui::PageTimeDate ),
...@@ -43,20 +43,22 @@ TimeDatePage::TimeDatePage( QWidget* parent ) : ...@@ -43,20 +43,22 @@ TimeDatePage::TimeDatePage( QWidget* parent ) :
setName( TimeDateCommon::getName() ); setName( TimeDateCommon::getName() );
connect( m_timeFieldsTimer, &QTimer::timeout, connect( m_timeFieldsTimer, &QTimer::timeout,
[=] ( ) [this] ()
{ {
TimeDateCommon::updateTimeFields( ui, m_timeDateService, m_isTimeEdited, m_isDateEdited ); TimeDateCommon::updateTimeFields( ui, m_timeDateService, m_isTimeEdited, m_isDateEdited );
} ); } );
connect( ui->isNtpEnabledCheckBox, &QCheckBox::toggled, connect( ui->isNtpEnabledCheckBox, &QCheckBox::toggled,
[=] ( bool checked ) [this] ( bool checked )
{ {
ui->timeEdit->setEnabled( !checked ); ui->timeEdit->setEnabled( !checked );
ui->dateEdit->setEnabled( !checked ); ui->dateEdit->setEnabled( !checked );
this -> setApplyEnabled( this, true );
} ); } );
connect( ui->timeZonePushButton, &QPushButton::clicked, connect( ui->timeZonePushButton, &QPushButton::clicked,
[=] ( bool checked ) [this] ()
{ {
Q_UNUSED( checked )
QString newTimeZone = TimeDateCommon::showTimeZoneSelector( m_timeZone ); QString newTimeZone = TimeDateCommon::showTimeZoneSelector( m_timeZone );
if ( !newTimeZone.isEmpty() ) if ( !newTimeZone.isEmpty() )
{ {
...@@ -72,12 +74,14 @@ TimeDatePage::TimeDatePage( QWidget* parent ) : ...@@ -72,12 +74,14 @@ TimeDatePage::TimeDatePage( QWidget* parent ) :
m_isTimeEdited = true; m_isTimeEdited = true;
this -> setApplyEnabled( this, true ); this -> setApplyEnabled( this, true );
} ); } );
connect( ui->dateEdit, &QTimeEdit::dateChanged, connect( ui->dateEdit, &QTimeEdit::dateChanged,
[this] () [this] ()
{ {
m_isDateEdited = true; m_isDateEdited = true;
this -> setApplyEnabled( this, true ); this -> setApplyEnabled( this, true );
} ); } );
connect( ui->isRtcLocalCheckBox, &QCheckBox::toggled, connect( ui->isRtcLocalCheckBox, &QCheckBox::toggled,
[this] () [this] ()
{ {
...@@ -90,6 +94,7 @@ TimeDatePage::~TimeDatePage() ...@@ -90,6 +94,7 @@ TimeDatePage::~TimeDatePage()
{ {
delete ui; delete ui;
delete m_timeDateService; delete m_timeDateService;
delete m_timeFieldsTimer;
} }
......
...@@ -45,7 +45,6 @@ private: ...@@ -45,7 +45,6 @@ private:
Ui::PageTimeDate* ui; Ui::PageTimeDate* ui;
TimeDateService* m_timeDateService; TimeDateService* m_timeDateService;
QTimer* m_timeFieldsTimer; QTimer* m_timeFieldsTimer;
TimeZoneWidget m_timeZoneWidget;
bool m_isTimeEdited; bool m_isTimeEdited;
bool m_isDateEdited; bool m_isDateEdited;
QString m_timeZone; QString m_timeZone;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* This file is part of Manjaro Settings Manager. * This file is part of Manjaro Settings Manager.
* *
* Ramon Buldó <ramon@manjaro.org> * Ramon Buldó <ramon@manjaro.org>
* Kacper Piwiński
* *
* Manjaro Settings Manager is free software: you can redistribute it and/or modify * Manjaro Settings Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -31,6 +32,7 @@ TimeDateService::TimeDateService( QObject* parent ) : ...@@ -31,6 +32,7 @@ TimeDateService::TimeDateService( QObject* parent ) :
0 ); 0 );
} }
TimeDateService::~TimeDateService() TimeDateService::~TimeDateService()
{ {
delete m_dbusInterface; delete m_dbusInterface;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* This file is part of Manjaro Settings Manager. * This file is part of Manjaro Settings Manager.
* *
* Ramon Buldó <ramon@manjaro.org> * Ramon Buldó <ramon@manjaro.org>
* Kacper Piwiński
* *
* Manjaro Settings Manager is free software: you can redistribute it and/or modify * Manjaro Settings Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* This file is part of Manjaro Settings Manager. * This file is part of Manjaro Settings Manager.
* *
* Ramon Buldó <ramon@manjaro.org> * Ramon Buldó <ramon@manjaro.org>
* Kacper Piwiński
* *
* Manjaro Settings Manager is free software: you can redistribute it and/or modify * Manjaro Settings Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
......
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