aboutsummaryrefslogtreecommitdiff
path: root/lumina-fm
diff options
context:
space:
mode:
Diffstat (limited to 'lumina-fm')
-rw-r--r--lumina-fm/BackgroundWorker.cpp37
-rw-r--r--lumina-fm/BackgroundWorker.h7
-rw-r--r--lumina-fm/MainUI.cpp34
-rw-r--r--lumina-fm/MainUI.h6
4 files changed, 76 insertions, 8 deletions
diff --git a/lumina-fm/BackgroundWorker.cpp b/lumina-fm/BackgroundWorker.cpp
index 1438f71e..125e0e1c 100644
--- a/lumina-fm/BackgroundWorker.cpp
+++ b/lumina-fm/BackgroundWorker.cpp
@@ -85,4 +85,39 @@ void BackgroundWorker::startDirChecks(QString path){
if(!snapDirs.isEmpty()){ emit SnapshotsAvailable(baseSnapDir, snapDirs); }
qDebug() << "Found snapshots";
}
-} \ No newline at end of file
+}
+
+
+void BackgroundWorker::createStatusBarMsg(QFileInfoList fileList, QString path, QString message){
+ //collect some statistics of dir and display them in statusbar
+ //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;
+ }
+ //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 += 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);
+ }
+}
diff --git a/lumina-fm/BackgroundWorker.h b/lumina-fm/BackgroundWorker.h
index 25becb53..d50612fa 100644
--- a/lumina-fm/BackgroundWorker.h
+++ b/lumina-fm/BackgroundWorker.h
@@ -16,6 +16,8 @@
#include <QDir>
#include <QDateTime>
+#include <LuminaOS.h>
+
class BackgroundWorker : public QObject{
Q_OBJECT
@@ -26,17 +28,20 @@ public:
private:
QStringList multiFilter, imgFilter;
QString cdir, csnapdir; //last directory checked (and base snapshot dir found)
+ QString ItemsInstatusBar(QFileInfoList, QString);
public slots:
//Kickoff processes with these slots
// and then listen for the appropriate signals when finished
void startDirChecks(QString path);
+ void createStatusBarMsg(QFileInfoList fileList, QString path, QString message);
signals:
void ImagesAvailable(QStringList files);
void MultimediaAvailable(QStringList files);
void SnapshotsAvailable(QString basedir, QStringList snappaths);
+ void Si_DisplayStatusBar(QString);
};
-#endif \ No newline at end of file
+#endif
diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp
index 9d66bc36..604e4c9c 100644
--- a/lumina-fm/MainUI.cpp
+++ b/lumina-fm/MainUI.cpp
@@ -8,10 +8,13 @@
#include "ui_MainUI.h"
#include <QImageWriter>
+#include <QFileInfo>
#define DEBUG 0
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
+ //for Signal/slot we must register the Typedef of QFileInfoList
+ qRegisterMetaType<QFileInfoList>("QFileInfoList");
ui->setupUi(this);
if(DEBUG){ qDebug() << "Initilization:"; }
//Be careful about the QSettings setup, it must match the lumina-desktop setup
@@ -214,6 +217,10 @@ void MainUI::setupConnections(){
connect(worker, SIGNAL(ImagesAvailable(QStringList)), this, SLOT(AvailablePictures(QStringList)) );
connect(worker, SIGNAL(MultimediaAvailable(QStringList)), this, SLOT(AvailableMultimediaFiles(QStringList)) );
connect(worker, SIGNAL(SnapshotsAvailable(QString, QStringList)), this, SLOT(AvailableBackups(QString, QStringList)) );
+
+ //Background worker class for statusbar
+ connect(this, SIGNAL(Si_AdaptStatusBar(QFileInfoList, QString, QString)), worker, SLOT(createStatusBarMsg(QFileInfoList, QString, QString)) );
+ connect(worker, SIGNAL(Si_DisplayStatusBar(QString)), this, SLOT(DisplayStatusBar(QString)) );
//Action buttons on browser page
connect(ui->tool_act_run, SIGNAL(clicked()), this, SLOT(OpenItem()) );
@@ -439,16 +446,22 @@ 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"));*/
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"));
+ }
+
ui->tool_addToDir->setVisible(isUserWritable);
ui->tool_addNewFile->setVisible(isUserWritable);
ui->actionUpDir->setEnabled(dir!="/");
@@ -541,6 +554,11 @@ void MainUI::AvailableBackups(QString basedir, QStringList snapdirs){
ui->tool_goToRestore->setVisible(!snapDirs.isEmpty());
}
+void MainUI::DisplayStatusBar(QString msg){
+ //qDebug() << "message to show in the status bar:" << msg;
+ ui->statusbar->showMessage(msg);
+}
+
void MainUI::AvailablePictures(QStringList pics){
if(!pics.isEmpty()){
QString citem = ui->combo_image_name->currentText();
@@ -832,6 +850,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();
}
@@ -962,6 +981,11 @@ void MainUI::OpenContextMenu(const QPoint &pt){
void MainUI::ItemSelectionChanged(){
//Enable/disable the action buttons
QFileInfoList sel = getSelectedItems();
+ //display info related to files selected.
+ //TO CHECK: impact if filesystem is very slow
+ 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);
ui->tool_act_rm->setEnabled(!sel.isEmpty() && isUserWritable);
diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h
index 97cadf86..d88492d6 100644
--- a/lumina-fm/MainUI.h
+++ b/lumina-fm/MainUI.h
@@ -219,13 +219,17 @@ private slots:
void CopyItems();
void PasteItems();
void ChecksumItems();
+
+ //file info in status bar
+ void DisplayStatusBar(QString);
signals:
void DirChanged(QString path);
+ void Si_AdaptStatusBar(QFileInfoList fileList, QString path, QString message);
protected:
void resizeEvent(QResizeEvent*);
};
-#endif \ No newline at end of file
+#endif
bgstack15