diff options
-rw-r--r-- | lumina-config/mainUI.cpp | 66 | ||||
-rw-r--r-- | lumina-config/mainUI.h | 4 | ||||
-rw-r--r-- | lumina-config/mainUI.ui | 205 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/LSession.h | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.cpp | 23 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.h | 5 |
7 files changed, 250 insertions, 57 deletions
diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp index 204a9feb..bcf2ba31 100644 --- a/lumina-config/mainUI.cpp +++ b/lumina-config/mainUI.cpp @@ -9,6 +9,8 @@ #include <LuminaOS.h> #include <QImageReader> +#include <QTime> +#include <QDate> MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ ui->setupUi(this); //load the designer file @@ -132,7 +134,8 @@ void MainUI::setupIcons(){ ui->tool_session_newcolor->setIcon( LXDG::findIcon("preferences-desktop-color","") ); ui->push_session_resetSysDefaults->setIcon( LXDG::findIcon("pcbsd","view-refresh") ); ui->push_session_resetLuminaDefaults->setIcon( LXDG::findIcon("Lumina-DE","") ); - + ui->tool_help_time->setIcon( LXDG::findIcon("help-about","") ); + ui->tool_help_date->setIcon( LXDG::findIcon("help-about","") ); } void MainUI::setupConnections(){ @@ -227,6 +230,10 @@ void MainUI::setupConnections(){ connect(ui->push_session_setUserIcon, SIGNAL(clicked()), this, SLOT(sessionChangeUserIcon()) ); connect(ui->push_session_resetSysDefaults, SIGNAL(clicked()), this, SLOT(sessionResetSys()) ); connect(ui->push_session_resetLuminaDefaults, SIGNAL(clicked()), this, SLOT(sessionResetLumina()) ); + connect(ui->tool_help_time, SIGNAL(clicked()), this, SLOT(sessionShowTimeCodes()) ); + connect(ui->tool_help_date, SIGNAL(clicked()), this, SLOT(sessionShowDateCodes()) ); + connect(ui->line_session_time, SIGNAL(textChanged(QString)), this, SLOT(sessionLoadTimeSample()) ); + connect(ui->line_session_date, SIGNAL(textChanged(QString)), this, SLOT(sessionLoadDateSample()) ); } void MainUI::setupMenus(){ @@ -1704,6 +1711,9 @@ void MainUI::loadSessionSettings(){ ui->check_session_playloginaudio->setChecked( sessionsettings->value("PlayStartupAudio",true).toBool() ); ui->check_session_playlogoutaudio->setChecked( sessionsettings->value("PlayLogoutAudio",true).toBool() ); ui->push_session_setUserIcon->setIcon( LXDG::findIcon(QDir::homePath()+"/.loginIcon.png", "user-identity") ); + ui->line_session_time->setText( sessionsettings->value("TimeFormat","").toString() ); + ui->line_session_date->setText( sessionsettings->value("DateFormat","").toString() ); + //Now do the session theme options ui->combo_session_themefile->clear(); ui->combo_session_colorfile->clear(); @@ -1750,6 +1760,8 @@ void MainUI::loadSessionSettings(){ ui->spin_session_fontsize->setValue( current[4].section("p",0,0).toInt() ); sessionstartchanged(); //make sure to update buttons + sessionLoadTimeSample(); + sessionLoadDateSample(); } void MainUI::saveSessionSettings(){ @@ -1791,6 +1803,8 @@ void MainUI::saveSessionSettings(){ sessionsettings->setValue("EnableNumlock", ui->check_session_numlock->isChecked()); sessionsettings->setValue("PlayStartupAudio", ui->check_session_playloginaudio->isChecked()); sessionsettings->setValue("PlayLogoutAudio", ui->check_session_playlogoutaudio->isChecked()); + sessionsettings->setValue("TimeFormat", ui->line_session_time->text()); + sessionsettings->setValue("DateFormat", ui->line_session_date->text()); //Now do the theme options QString themefile = ui->combo_session_themefile->itemData( ui->combo_session_themefile->currentIndex() ).toString(); @@ -1960,3 +1974,53 @@ void MainUI::sessionResetLumina(){ LUtils::LoadSystemDefaults(true); //skip OS customizations QTimer::singleShot(500,this, SLOT(loadCurrentSettings()) ); } + +void MainUI::sessionLoadTimeSample(){ + if(ui->line_session_time->text().simplified().isEmpty()){ + ui->label_session_timesample->setText( QTime::currentTime().toString(Qt::SystemLocaleShortDate) ); + }else{ + ui->label_session_timesample->setText( QTime::currentTime().toString( ui->line_session_time->text() ) ); + } + sessionoptchanged(); +} + +void MainUI::sessionShowTimeCodes(){ + QStringList msg; + msg << tr("Valid Time Codes:") << "\n"; + msg << QString(tr("%1: Hour without leading zero (1)")).arg("h"); + msg << QString(tr("%1: Hour with leading zero (01)")).arg("hh"); + msg << QString(tr("%1: Minutes without leading zero (2)")).arg("m"); + msg << QString(tr("%1: Minutes with leading zero (02)")).arg("mm"); + msg << QString(tr("%1: Seconds without leading zero (3)")).arg("s"); + msg << QString(tr("%1: Seconds with leading zero (03)")).arg("ss"); + msg << QString(tr("%1: AM/PM (12-hour) clock (upper or lower case)")).arg("A or a"); + msg << QString(tr("%1: Timezone")).arg("t"); + QMessageBox::information(this, tr("Time Codes"), msg.join("\n") ); +} + +void MainUI::sessionLoadDateSample(){ + if(ui->line_session_date->text().simplified().isEmpty()){ + ui->label_session_datesample->setText( QDate::currentDate().toString(Qt::SystemLocaleLongDate) ); + }else{ + ui->label_session_datesample->setText( QDate::currentDate().toString( ui->line_session_date->text() ) ); + } + sessionoptchanged(); +} + +void MainUI::sessionShowDateCodes(){ + QStringList msg; + msg << tr("Valid Date Codes:") << "\n"; + msg << QString(tr("%1: Numeric day without a leading zero (1)")).arg("d"); + msg << QString(tr("%1: Numeric day with leading zero (01)")).arg("dd"); + msg << QString(tr("%1: Day as abbreviation (localized)")).arg("ddd"); + msg << QString(tr("%1: Day as full name (localized)")).arg("dddd"); + msg << QString(tr("%1: Numeric month without leading zero (2)")).arg("M"); + msg << QString(tr("%1: Numeric month with leading zero (02)")).arg("MM"); + msg << QString(tr("%1: Month as abbreviation (localized)")).arg("MMM"); + msg << QString(tr("%1: Month as full name (localized)")).arg("MMMM"); + msg << QString(tr("%1: Year as 2-digit number (15)")).arg("yy"); + msg << QString(tr("%1: Year as 4-digit number (2015)")).arg("yyyy"); + msg << tr("Text may be contained within single-quotes to ignore replacements"); + QMessageBox::information(this, tr("Date Codes"), msg.join("\n") ); +} + diff --git a/lumina-config/mainUI.h b/lumina-config/mainUI.h index 27c59968..7d655476 100644 --- a/lumina-config/mainUI.h +++ b/lumina-config/mainUI.h @@ -170,6 +170,10 @@ private slots: void sessionChangeUserIcon(); void sessionResetSys(); void sessionResetLumina(); + void sessionLoadTimeSample(); + void sessionShowTimeCodes(); + void sessionLoadDateSample(); + void sessionShowDateCodes(); }; #endif diff --git a/lumina-config/mainUI.ui b/lumina-config/mainUI.ui index 200a75ef..dcdc4d12 100644 --- a/lumina-config/mainUI.ui +++ b/lumina-config/mainUI.ui @@ -109,7 +109,7 @@ <enum>QFrame::StyledPanel</enum> </property> <property name="currentIndex"> - <number>3</number> + <number>4</number> </property> <widget class="QWidget" name="page_desktop"> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -1466,72 +1466,177 @@ <attribute name="title"> <string>General Options</string> </attribute> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QCheckBox" name="check_session_numlock"> - <property name="text"> - <string>Enable numlock on startup</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="check_session_playloginaudio"> - <property name="text"> - <string>Play chimes on startup</string> + <layout class="QGridLayout" name="gridLayout"> + <item row="5" column="0"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="check_session_playlogoutaudio"> - <property name="text"> - <string>Play chimes on exit</string> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>128</height> + </size> </property> - </widget> + </spacer> </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_14"> + <item row="0" column="0"> + <layout class="QVBoxLayout" name="verticalLayout_4"> <item> - <widget class="QPushButton" name="push_session_setUserIcon"> + <widget class="QCheckBox" name="check_session_numlock"> <property name="text"> - <string>Change User Icon</string> - </property> - <property name="iconSize"> - <size> - <width>32</width> - <height>32</height> - </size> + <string>Enable numlock on startup</string> </property> </widget> </item> <item> - <spacer name="horizontalSpacer_16"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <widget class="QCheckBox" name="check_session_playloginaudio"> + <property name="text"> + <string>Play chimes on startup</string> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> + </widget> + </item> + <item> + <widget class="QCheckBox" name="check_session_playlogoutaudio"> + <property name="text"> + <string>Play chimes on exit</string> </property> - </spacer> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_14"> + <item> + <widget class="QPushButton" name="push_session_setUserIcon"> + <property name="text"> + <string>Change User Icon</string> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_16"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> </item> </layout> </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> + <item row="0" column="1"> + <layout class="QFormLayout" name="formLayout_3"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>128</height> - </size> + <property name="labelAlignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> - </spacer> + <item row="0" column="0"> + <widget class="QLabel" name="label_24"> + <property name="text"> + <string>Time Format:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLineEdit" name="line_session_time"/> + </item> + <item> + <widget class="QToolButton" name="tool_help_time"> + <property name="toolTip"> + <string>View format codes</string> + </property> + <property name="text"> + <string notr="true">...</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_25"> + <property name="text"> + <string>Date Format:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_21"> + <item> + <widget class="QLineEdit" name="line_session_date"/> + </item> + <item> + <widget class="QToolButton" name="tool_help_date"> + <property name="toolTip"> + <string>View format codes</string> + </property> + <property name="text"> + <string notr="true">...</string> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_session_timesample"> + <property name="text"> + <string notr="true"/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_session_datesample"> + <property name="text"> + <string notr="true"/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_28"> + <property name="text"> + <string>Sample:</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_29"> + <property name="text"> + <string>Sample:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + </widget> + </item> + </layout> </item> - <item> + <item row="6" column="0" colspan="2"> <widget class="QGroupBox" name="groupBox_2"> <property name="font"> <font> diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 7016a2b7..91ecd98f 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -111,6 +111,7 @@ void LSession::setupSession(){ if(DEBUG){ qDebug() << " - Init QFileSystemWatcher:" << timer->elapsed();} watcher = new QFileSystemWatcher(this); //watcher->addPath( QDir::homePath()+"/.lumina/stylesheet.qss" ); + watcher->addPath( QDir::homePath()+"/.lumina/LuminaDE/sessionsettings.conf" ); watcher->addPath( QDir::homePath()+"/.lumina/LuminaDE/desktopsettings.conf" ); watcher->addPath( QDir::homePath()+"/.lumina/fluxbox-init" ); watcher->addPath( QDir::homePath()+"/.lumina/fluxbox-keys" ); @@ -185,6 +186,7 @@ void LSession::launchStartupApps(){ void LSession::watcherChange(QString changed){ if(DEBUG){ qDebug() << "Session Watcher Change:" << changed; } if(changed.endsWith("fluxbox-init") || changed.endsWith("fluxbox-keys")){ refreshWindowManager(); } + else if(changed.endsWith("sessionsettings.conf") ){ sessionsettings->sync(); emit SessionConfigChanged(); } else{ emit DesktopConfigChanged(); } } diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index 6dd99b55..03a4b397 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -141,7 +141,9 @@ signals: void WindowListEvent(); //General Signals void LocaleChanged(); + void IconThemeChanged(); void DesktopConfigChanged(); + void SessionConfigChanged(); }; diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp index a61eb75d..e66d83c2 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -6,6 +6,8 @@ //=========================================== #include "LClock.h" +#include "LSession.h" + LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ //Setup the widget label = new QLabel(this); @@ -15,9 +17,11 @@ LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, //Setup the timer timer = new QTimer(); - timer->setInterval(1000); //update once a second - connect(timer,SIGNAL(timeout()), this, SLOT(updateTime()) ); + timer->setInterval(1000); //update once a second + updateFormats(); updateTime(); + connect(timer,SIGNAL(timeout()), this, SLOT(updateTime()) ); + connect(QApplication::instance(), SIGNAL(SessionConfigChanged()), this, SLOT(updateFormats()) ); timer->start(); } @@ -26,10 +30,19 @@ LClock::~LClock(){ delete timer; } + void LClock::updateTime(){ QDateTime CT = QDateTime::currentDateTime(); //Now update the display - QLocale sys = QLocale::system(); - label->setText( "<b>"+CT.toString(sys.timeFormat(QLocale::ShortFormat))+"</b>" ); - label->setToolTip(CT.toString(sys.dateFormat())); + if(deftime){ label->setText( "<b>"+CT.time().toString(Qt::SystemLocaleShortDate)+"</b>" ); } + else{ label->setText( "<b>"+CT.toString(timefmt)+"</b>" ); } + if(defdate){ label->setToolTip(CT.date().toString(Qt::SystemLocaleLongDate)); } + else{ label->setToolTip(CT.toString(datefmt)); } } + +void LClock::updateFormats(){ + timefmt = LSession::handle()->sessionSettings()->value("TimeFormat","").toString(); + datefmt = LSession::handle()->sessionSettings()->value("DateFormat","").toString(); + deftime = timefmt.simplified().isEmpty(); + defdate = datefmt.simplified().isEmpty(); +}
\ No newline at end of file diff --git a/lumina-desktop/panel-plugins/clock/LClock.h b/lumina-desktop/panel-plugins/clock/LClock.h index d4de917c..8f7e38eb 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.h +++ b/lumina-desktop/panel-plugins/clock/LClock.h @@ -25,9 +25,12 @@ public: private: QTimer *timer; QLabel *label; - + QString timefmt, datefmt; + bool deftime, defdate; + private slots: void updateTime(); + void updateFormats(); }; |