aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-09-11 12:03:31 -0400
committerKen Moore <moorekou@gmail.com>2015-09-11 12:03:31 -0400
commit0d434549cba673fbd4a362313fa8548c03f6b158 (patch)
treec758909719d24de8c2ee3e383928fbb13fef64e5
parentAdd the option for wallpaper layout/format to lumina-config. (diff)
parentMerge pull request #155 from harcobbit/issue/11400 (diff)
downloadlumina-0d434549cba673fbd4a362313fa8548c03f6b158.tar.gz
lumina-0d434549cba673fbd4a362313fa8548c03f6b158.tar.bz2
lumina-0d434549cba673fbd4a362313fa8548c03f6b158.zip
Merge branch 'master' of github.com:pcbsd/lumina
-rw-r--r--lumina-config/mainUI.cpp4
-rw-r--r--lumina-desktop/panel-plugins/clock/LClock.cpp6
-rw-r--r--lumina-fm/widgets/DirWidget.cpp71
-rw-r--r--lumina-fm/widgets/DirWidget.h25
4 files changed, 75 insertions, 31 deletions
diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp
index 27ec0008..5b4cb66b 100644
--- a/lumina-config/mainUI.cpp
+++ b/lumina-config/mainUI.cpp
@@ -1977,7 +1977,7 @@ void MainUI::sessionResetLumina(){
void MainUI::sessionLoadTimeSample(){
if(ui->line_session_time->text().simplified().isEmpty()){
- ui->label_session_timesample->setText( QTime::currentTime().toString(Qt::SystemLocaleShortDate) );
+ ui->label_session_timesample->setText( QTime::currentTime().toString(Qt::DefaultLocaleShortDate) );
}else{
ui->label_session_timesample->setText( QTime::currentTime().toString( ui->line_session_time->text() ) );
}
@@ -2000,7 +2000,7 @@ void MainUI::sessionShowTimeCodes(){
void MainUI::sessionLoadDateSample(){
if(ui->line_session_date->text().simplified().isEmpty()){
- ui->label_session_datesample->setText( QDate::currentDate().toString(Qt::SystemLocaleLongDate) );
+ ui->label_session_datesample->setText( QDate::currentDate().toString(Qt::DefaultLocaleShortDate) );
}else{
ui->label_session_datesample->setText( QDate::currentDate().toString( ui->line_session_date->text() ) );
}
diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp
index f704647e..2c7e3e07 100644
--- a/lumina-desktop/panel-plugins/clock/LClock.cpp
+++ b/lumina-desktop/panel-plugins/clock/LClock.cpp
@@ -55,9 +55,9 @@ void LClock::updateTime(bool adjustformat){
QString label;
QString timelabel;
QString datelabel;
- if(deftime){ timelabel = CT.time().toString(Qt::SystemLocaleShortDate) ; }
+ if(deftime){ timelabel = CT.time().toString(Qt::DefaultLocaleShortDate) ; }
else{ timelabel=CT.toString(timefmt); }
- if(defdate){ datelabel = CT.date().toString(Qt::SystemLocaleLongDate); }
+ if(defdate){ datelabel = CT.date().toString(Qt::DefaultLocaleShortDate); }
else{ datelabel = CT.toString(datefmt); }
if(datetimeorder == "dateonly"){
label = datelabel;
@@ -255,4 +255,4 @@ void LClock::OrientationChange(){
}
updateTime(true); //re-adjust the font/spacings
this->layout()->update();
-} \ No newline at end of file
+}
diff --git a/lumina-fm/widgets/DirWidget.cpp b/lumina-fm/widgets/DirWidget.cpp
index 22879c1b..6e5c3941 100644
--- a/lumina-fm/widgets/DirWidget.cpp
+++ b/lumina-fm/widgets/DirWidget.cpp
@@ -14,6 +14,7 @@
#include <QTimer>
#include <QInputDialog>
#include <QScrollBar>
+#include <QSettings>
#include <LuminaOS.h>
#include <LuminaXDG.h>
@@ -25,6 +26,9 @@
#define DEBUG 0
#endif
+
+const QString sessionsettings_config_file = QDir::homePath() + "/.lumina/LuminaDE/sessionsettings.conf";
+
DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new Ui::DirWidget){
ui->setupUi(this); //load the designer file
ID = objID;
@@ -64,6 +68,7 @@ DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new U
//Now update the rest of the UI
canmodify = false; //initial value
contextMenu = new QMenu(this);
+ setDateFormat();
setShowDetails(true);
setShowThumbnails(true);
UpdateIcons();
@@ -155,6 +160,22 @@ void DirWidget::setShowCloseButton(bool show){
ui->actionClose_Browser->setVisible(show);
}
+QStringList DirWidget::getDateFormat() {
+ return date_format;
+}
+
+// This function is only called if user changes sessionsettings. By doing so, operations like sorting by date
+// are faster because the date format is already stored in DirWidget::date_format static variable
+void DirWidget::setDateFormat() {
+ if(!date_format.isEmpty())
+ date_format.clear();
+ QSettings settings("LuminaDE","sessionsettings");
+ // If value doesn't exist or is not setted, empty string is returned
+ date_format << settings.value("DateFormat").toString();
+ date_format << settings.value("TimeFormat").toString();
+}
+
+
// ================
// PUBLIC SLOTS
// ================
@@ -233,6 +254,8 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){
if(!watcher->directories().isEmpty()){ watcher->removePaths(watcher->directories()); }
if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); }
watcher->addPath(CDIR);
+ // add sessionsettings to watcher so date_format can be update based on user settings
+ watcher->addPath(sessionsettings_config_file);
ui->actionStopLoad->setVisible(true);
stopload = false;
//Clear the display widget (if a new directory)
@@ -318,12 +341,39 @@ void DirWidget::LoadDir(QString dir, QList<LFileInfo> list){
case TYPE:
it->setText(t, list[i].mimetype());
break;
- case DATEMOD:
- it->setText(t, list[i].lastModified().toString(Qt::DefaultLocaleShortDate) );
- break;
- case DATECREATE:
- it->setText(t, list[i].created().toString(Qt::DefaultLocaleShortDate) );
- break;
+ case DATEMOD:
+ {
+ QStringList datetime_format = getDateFormat();
+ // Save datetime in WhatThis value. Lately will be used by CQTreeWidgetItem for sorting by date
+ it->setWhatsThis(DATEMOD, list[i].lastModified().toString("yyyyMMddhhmmsszzz"));
+ // Default configurition. Fallback to Qt::DefaultLocaleShortDate for formats
+ if(datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty())
+ it->setText(t, list[i].lastModified().toString(Qt::DefaultLocaleShortDate) );
+ // Date is setted but time not. Time goes to default
+ else if(!datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty())
+ it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(Qt::DefaultLocaleShortDate));
+ // Time is setted but date not. Date goes to default
+ else if(datetime_format.at(0).isEmpty() && !datetime_format.at(1).isEmpty())
+ it->setText(t, list[i].lastModified().date().toString(Qt::DefaultLocaleShortDate) + " " + list[i].lastModified().time().toString(datetime_format.at(1)));
+ // Both time and date setted.
+ else
+ it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(datetime_format.at(1)));
+ break;
+ }
+ case DATECREATE:
+ {
+ QStringList datetime_format = getDateFormat();
+ it->setWhatsThis(DATECREATE, list[i].lastModified().toString("yyyyMMddhhmmsszzz"));
+ if(datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty())
+ it->setText(t, list[i].lastModified().toString(Qt::DefaultLocaleShortDate) );
+ else if(!datetime_format.at(0).isEmpty() && datetime_format.at(1).isEmpty())
+ it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(Qt::DefaultLocaleShortDate));
+ else if(datetime_format.at(0).isEmpty() && !datetime_format.at(1).isEmpty())
+ it->setText(t, list[i].lastModified().date().toString(Qt::DefaultLocaleShortDate) + " " + list[i].lastModified().time().toString(datetime_format.at(1)));
+ else
+ it->setText(t, list[i].lastModified().date().toString(datetime_format.at(0)) + " " + list[i].lastModified().time().toString(datetime_format.at(1)));
+ break;
+ }
}
}
if(addnew){ treeWidget->addTopLevelItem(it); }
@@ -499,8 +549,8 @@ void DirWidget::setupConnections(){
connect(deleteFilesShort, SIGNAL(activated()), this, SLOT( on_tool_act_rm_clicked() ) );
connect(refreshShort, SIGNAL(activated()), this, SLOT( refresh()) );
//Filesystem Watcher
- connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(startSync()) );
- connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(startSync()) ); //just in case
+ connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(startSync(const QString &)) );
+ connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(startSync(const QString &)) ); //just in case
connect(synctimer, SIGNAL(timeout()), this, SLOT(refresh()) );
}
@@ -846,7 +896,10 @@ void DirWidget::SelectionChanged(){
ui->tool_act_runwith->setEnabled(hasselection);
}
-void DirWidget::startSync(){
+void DirWidget::startSync(const QString &file){
+ //Update date_format based on user settings
+ if(file == sessionsettings_config_file)
+ setDateFormat();
if(synctimer->isActive()){ synctimer->stop(); }
synctimer->start();
}
diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h
index 514b3e7f..adf349a9 100644
--- a/lumina-fm/widgets/DirWidget.h
+++ b/lumina-fm/widgets/DirWidget.h
@@ -52,6 +52,10 @@ public:
void setDetails(QList<DETAILTYPES> list); //Which details to show and in which order (L->R)
void setThumbnailSize(int px);
void setShowCloseButton(bool show);
+
+ //Date format for show items
+ QStringList getDateFormat();
+ void setDateFormat();
public slots:
void LoadDir(QString dir, LFileInfoList list);
@@ -94,6 +98,7 @@ private:
//Functions for internal use
void setupConnections();
QStringList currentSelection();
+ QStringList date_format;
private slots:
//UI BUTTONS/Actions
@@ -132,7 +137,7 @@ private slots:
//Browser Functions
void OpenContextMenu();
void SelectionChanged();
- void startSync(); //used internally to collect/pause before updating the dir
+ void startSync(const QString &file); //used internally to collect/pause before updating the dir
signals:
//Directory loading/finding signals
@@ -180,22 +185,8 @@ public:
inline virtual bool operator<(const QTreeWidgetItem &tmp) const {
int column = this->treeWidget()->sortColumn();
// We are in date text
- if(column == DirWidget::DATEMOD || column == DirWidget::DATECREATE) {
- // Get the stored text and try to convert to QDateTime
- QString text = this->text(column);
- QString text_tmp = tmp.text(column);
- QDateTime date_time = QDateTime::fromString(text, Qt::DefaultLocaleShortDate);
- QDateTime date_time_tmp = QDateTime::fromString(text_tmp, Qt::DefaultLocaleShortDate);
- // If the conversion are ok in both objects, compare them
- if(date_time.isValid() && date_time_tmp.isValid())
- return date_time < date_time_tmp;
- // If some of the dates are invalid, use the base class implementation (order by string)
- else {
- if(DEBUG)
- qDebug() << "Cannot convert the date. Texts arrived are " << text << " and " << text_tmp;
- return QTreeWidgetItem::operator <(tmp);
- }
- }
+ if(column == DirWidget::DATEMOD || column == DirWidget::DATECREATE)
+ return this->whatsThis(column) < tmp.whatsThis(column);
// We are in size text
else if(column == DirWidget::SIZE) {
QString text = this->text(column);
bgstack15