diff options
Diffstat (limited to 'lumina-fm')
-rw-r--r-- | lumina-fm/MainUI.cpp | 37 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 3 |
2 files changed, 38 insertions, 2 deletions
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index fa892dfd..d445a9cd 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -396,6 +396,27 @@ QString MainUI::getCurrentDir(){ return currentDir->whatsThis(); } +QString MainUI::ItemsInstatusBar(QFileInfoList fileList, QString message){ + int i = 0; + qreal totalSizes = 0; + foreach (QFileInfo fileInfo, fileList ) + { + if (fileInfo.isFile()) totalSizes += fileInfo.size(); + i += 1; + } + if (i==0) return ""; + QString strSize = QString(tr("%1: %2")).arg(message).arg(i); + if (i>0 and totalSizes>1024*1024*1024) + strSize += QString(tr(", size: %1 Gb")).arg(totalSizes/1024/1024/1024, 0,'f', 2); + else if (i>0 and totalSizes>1024*1024) + strSize += QString(tr(", size: %1 Mb")).arg(totalSizes/1024/1024, 0,'f',2); + else if (i>0 and totalSizes>1024) + strSize += QString(tr(", size: %1 Kb")).arg(totalSizes/1024, 0, 'f' , 2); + else + if (totalSizes > 0) { strSize += QString(tr(", size: %1 b")).arg(totalSizes, 0, 'f' , 2);} + return strSize; +} + void MainUI::setCurrentDir(QString dir){ if(dir.isEmpty()){ return; } if(syncTimer->isActive()){ syncTimer->stop(); } //already loading the info @@ -446,7 +467,18 @@ void MainUI::setCurrentDir(QString dir){ emit DirChanged(rawdir); //This will be automatically run when a new dir is loaded //} if(isUserWritable){ ui->label_dir_stats->setText(""); } - else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); } + else{ ui->label_dir_stats->setText(tr("Limited Access Directory")); + } + QFileInfoList fileList = fsmod->rootDirectory().entryInfoList(); + QString msgStatusBar = ItemsInstatusBar(fileList, tr("Items")); + //3 following lines should be in LOS + QStringList mountInfo = LUtils::getCmdOutput("df " + dir); + QString::SectionFlag skipEmpty = QString::SectionSkipEmpty; + QString capacity = mountInfo[1].section(" ",4,4, skipEmpty); + if (msgStatusBar.isEmpty()) msgStatusBar += tr("Capacity: ") + capacity; + else msgStatusBar += tr(", Capacity: ") + capacity; + if (!msgStatusBar.isEmpty()) ui->statusbar->showMessage(msgStatusBar); + ui->tool_addToDir->setVisible(isUserWritable); ui->tool_addNewFile->setVisible(isUserWritable); ui->actionUpDir->setEnabled(dir!="/"); @@ -959,6 +991,9 @@ void MainUI::OpenContextMenu(const QPoint &pt){ void MainUI::ItemSelectionChanged(){ //Enable/disable the action buttons QFileInfoList sel = getSelectedItems(); + QString msgStatusBar = ItemsInstatusBar(sel, tr("Items selected")); + if (!msgStatusBar.isEmpty()) ui->statusbar->showMessage(msgStatusBar); + ui->tool_act_run->setEnabled(sel.length()==1); ui->tool_act_runwith->setEnabled(sel.length()==1); ui->tool_act_rm->setEnabled(!sel.isEmpty() && isUserWritable); diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index 97cadf86..43607be0 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -114,6 +114,7 @@ private: //Common functions for browser info/usage QString getCurrentDir(); + QString ItemsInstatusBar(QFileInfoList fileList, QString message); void setCurrentDir(QString); QFileInfoList getSelectedItems(); //QModelIndexList getVisibleItems(); @@ -228,4 +229,4 @@ protected: }; -#endif
\ No newline at end of file +#endif |