aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-fm')
-rw-r--r--lumina-fm/BackgroundWorker.cpp44
-rw-r--r--lumina-fm/MainUI.cpp19
-rw-r--r--lumina-fm/MainUI.h1
3 files changed, 38 insertions, 26 deletions
diff --git a/lumina-fm/BackgroundWorker.cpp b/lumina-fm/BackgroundWorker.cpp
index c8d7cb17..125e0e1c 100644
--- a/lumina-fm/BackgroundWorker.cpp
+++ b/lumina-fm/BackgroundWorker.cpp
@@ -90,26 +90,34 @@ void BackgroundWorker::startDirChecks(QString path){
void BackgroundWorker::createStatusBarMsg(QFileInfoList fileList, QString path, QString message){
//collect some statistics of dir and display them in statusbar
- int i = 0;
- qreal totalSizes = 0;
- foreach (QFileInfo fileInfo, fileList )
- {
- if (fileInfo.isFile()) totalSizes += fileInfo.size();
- i += 1;
+ //Get the total size of the items
+ double totalSizes = 0;
+ for(int i=0; i<fileList.length(); i++){
+ if(!fileList[i].isDir()){
+ totalSizes += fileList[i].size(); //in Bytes
+ }
+ }
+ //Convert the size into display units
+ static QStringList units = QStringList() << tr("B") << tr("KB") << tr("MB") << tr("GB") << tr("TB");
+ int cunit = 0;
+ while(cunit < units.length() && totalSizes > 1024){
+ cunit++;
+ totalSizes = totalSizes/1024;
}
- QString msgStatusBar = QString(tr("%1: %2")).arg(message).arg(i);
- if (i>0 and totalSizes>1024*1024*1024)
- msgStatusBar += QString(tr(", size: %1 Gb")).arg(totalSizes/1024/1024/1024, 0,'f', 2);
- else if (i>0 and totalSizes>1024*1024)
- msgStatusBar += QString(tr(", size: %1 Mb")).arg(totalSizes/1024/1024, 0,'f',2);
- else if (i>0 and totalSizes>1024)
- msgStatusBar += QString(tr(", size: %1 Kb")).arg(totalSizes/1024, 0, 'f' , 2);
- else
- if (totalSizes > 0) { msgStatusBar += QString(tr(", size: %1 b")).arg(totalSizes, 0, 'f' , 2);}
+ //Assemble the message
+ QString msgStatusBar = QString(tr("%1: %2")).arg(message).arg(fileList.length());
+ if(totalSizes > 0){
+ totalSizes = qRound(totalSizes*100)/100.0; //round to 2 decimel places
+ msgStatusBar += " "+QString(tr("Total size: %1 %2")).arg(QString::number(totalSizes), units[cunit]);
+ }
+ //If a path given, get the total capacity of it (percantage)
if (!path.isEmpty()) { //path could be empty when fileList is based on user's selection
QString capacity = LOS::FileSystemCapacity(path) ;
- if (msgStatusBar.isEmpty()) msgStatusBar += tr("Capacity: ") + capacity;
- else msgStatusBar += tr(", Capacity: ") + capacity;
+ if (msgStatusBar.isEmpty()) msgStatusBar += QString(tr("Capacity: %1")).arg(capacity);
+ else msgStatusBar += " "+QString(tr("Capacity: %1")).arg(capacity);
+ }
+ //Emit the signal to show this on the UI
+ if (!msgStatusBar.isEmpty()){
+ emit Si_DisplayStatusBar(msgStatusBar);
}
- if (!msgStatusBar.isEmpty()) emit Si_DisplayStatusBar(msgStatusBar);
}
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index c4b74dbd..e14d16d0 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -445,15 +445,18 @@ void MainUI::setCurrentDir(QString dir){
//qDebug() << "History:" << history;
tabBar->setTabData(tabBar->currentIndex(), history);
//Now adjust the items as necessary
- ui->tool_goToPlayer->setVisible(false);
- ui->tool_goToRestore->setVisible(false);
- ui->tool_goToImages->setVisible(false);
+ if(rawdir != olddir){
+ //The Filesystem model will need to load the new directory (triggering the background checks)
+ ui->tool_goToPlayer->setVisible(false);
+ ui->tool_goToRestore->setVisible(false);
+ ui->tool_goToImages->setVisible(false);
+ }
//Make sure the shortcut buttons are enabled as necessary
// If the dir is already loaded into the fsmodel cache it will not emit the directoryLoaded() signal
- if(rawdir == olddir){
+ /*if(rawdir == olddir){
emit DirChanged(rawdir); //This will be automatically run when a new dir is loaded
}
- emit Si_AdaptStatusBar(fsmod->rootDirectory().entryInfoList(), rawdir, tr("Items"));
+ emit Si_AdaptStatusBar(fsmod->rootDirectory().entryInfoList(), rawdir, tr("Items"));*/
if(isUserWritable){ ui->label_dir_stats->setText(""); }
else{ ui->label_dir_stats->setText(tr("Limited Access Directory"));
}
@@ -551,7 +554,7 @@ void MainUI::AvailableBackups(QString basedir, QStringList snapdirs){
}
void MainUI::DisplayStatusBar(QString msg){
- qDebug() << "message to show in the status bar:" << msg;
+ //qDebug() << "message to show in the status bar:" << msg;
ui->statusbar->showMessage(msg);
}
@@ -846,6 +849,7 @@ void MainUI::currentDirectoryLoaded(){
ui->tool_goToRestore->setVisible(false);
ui->tool_goToImages->setVisible(false);
emit DirChanged(getCurrentDir());
+ emit Si_AdaptStatusBar(fsmod->rootDirectory().entryInfoList(), getCurrentDir(), tr("Items"));
ItemSelectionChanged();
}
@@ -978,7 +982,8 @@ void MainUI::ItemSelectionChanged(){
QFileInfoList sel = getSelectedItems();
//display info related to files selected.
//TO CHECK: impact if filesystem is very slow
- if (sel.size()>0) worker->createStatusBarMsg(sel, "", tr("Items selected"));
+ if(sel.size()>0){ emit Si_AdaptStatusBar(sel, "", tr("Items selected")); }
+ else{ emit Si_AdaptStatusBar(fsmod->rootDirectory().entryInfoList(), getCurrentDir(), tr("Items")); }
ui->tool_act_run->setEnabled(sel.length()==1);
ui->tool_act_runwith->setEnabled(sel.length()==1);
diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h
index 4744fe2a..d88492d6 100644
--- a/lumina-fm/MainUI.h
+++ b/lumina-fm/MainUI.h
@@ -114,7 +114,6 @@ private:
//Common functions for browser info/usage
QString getCurrentDir();
- QString ItemsInstatusBar(QFileInfoList fileList, QString message);
void setCurrentDir(QString);
QFileInfoList getSelectedItems();
//QModelIndexList getVisibleItems();
bgstack15