diff options
-rw-r--r-- | libLumina/LuminaOS-Debian.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-DragonFly.cpp | 8 | ||||
-rw-r--r-- | libLumina/LuminaOS-FreeBSD.cpp | 9 | ||||
-rw-r--r-- | libLumina/LuminaOS-Linux.cpp | 9 | ||||
-rw-r--r-- | libLumina/LuminaOS-OpenBSD.cpp | 15 | ||||
-rw-r--r-- | libLumina/LuminaOS-kFreeBSD.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-template.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS.h | 3 | ||||
-rw-r--r-- | lumina-fm/BackgroundWorker.cpp | 29 | ||||
-rw-r--r-- | lumina-fm/BackgroundWorker.h | 7 | ||||
-rw-r--r-- | lumina-fm/MainUI.cpp | 20 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 7 | ||||
-rw-r--r-- | lumina-open/main.cpp | 2 |
13 files changed, 119 insertions, 5 deletions
diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp index 4f2032fa..aad65ece 100644 --- a/libLumina/LuminaOS-Debian.cpp +++ b/libLumina/LuminaOS-Debian.cpp @@ -198,4 +198,9 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp return QStringList(); } +//file system capacity +QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command + return QString; +} + #endif diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp index 35bff04c..2e4ae358 100644 --- a/libLumina/LuminaOS-DragonFly.cpp +++ b/libLumina/LuminaOS-DragonFly.cpp @@ -176,4 +176,12 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp return QStringList(); } +//file system capacity +QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command + QStringList mountInfo = LUtils::getCmdOutput("df " + dir); + QString::SectionFlag skipEmpty = QString::SectionSkipEmpty; + //we take the 5th word on the 2 line + QString capacity = mountInfo[1].section(" ",4,4, skipEmpty); + return capacity; +} #endif diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index d454ce22..dfc413b4 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -195,4 +195,13 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp } return info; } + +//file system capacity +QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command + QStringList mountInfo = LUtils::getCmdOutput("df " + dir); + QString::SectionFlag skipEmpty = QString::SectionSkipEmpty; + //we take the 5th word on the 2 line + QString capacity = mountInfo[1].section(" ",4,4, skipEmpty); + return capacity; + #endif diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp index 7587a29b..ecf0adeb 100644 --- a/libLumina/LuminaOS-Linux.cpp +++ b/libLumina/LuminaOS-Linux.cpp @@ -194,4 +194,13 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file return QStringList(); } + +//file system capacity +QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command + QStringList mountInfo = LUtils::getCmdOutput("df " + dir); + QString::SectionFlag skipEmpty = QString::SectionSkipEmpty; + //we take the 5th word on the 2 line + QString capacity = mountInfo[1].section(" ",4,4, skipEmpty); + return capacity; +} #endif diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp index b6996795..dc8df0a7 100644 --- a/libLumina/LuminaOS-OpenBSD.cpp +++ b/libLumina/LuminaOS-OpenBSD.cpp @@ -207,4 +207,19 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp } return info; } + +//file system capacity +QString LOS::FileSystemCapacity(QString dir) { + // on OpenBSD, df has the following layout: + //>df /home/wi + //>Filesystem 512-blocks Used Avail Capacity Mounted on + //>/dev/sd2l 14334588 739900 12877960 5% /home + + QStringList mountInfo = LUtils::getCmdOutput("df " + dir); + QString::SectionFlag skipEmpty = QString::SectionSkipEmpty; + //we take the 5th word on the 2 line + QString capacity = mountInfo[1].section(" ",4,4, skipEmpty); + return capacity; +} + #endif diff --git a/libLumina/LuminaOS-kFreeBSD.cpp b/libLumina/LuminaOS-kFreeBSD.cpp index 16c8e6eb..b0c98abb 100644 --- a/libLumina/LuminaOS-kFreeBSD.cpp +++ b/libLumina/LuminaOS-kFreeBSD.cpp @@ -158,5 +158,10 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp return QStringList(); } +//file system capacity +QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command + return QString; +} + #endif #endif diff --git a/libLumina/LuminaOS-template.cpp b/libLumina/LuminaOS-template.cpp index c06b8b11..38e54816 100644 --- a/libLumina/LuminaOS-template.cpp +++ b/libLumina/LuminaOS-template.cpp @@ -106,4 +106,9 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp return QStringList(); } +//file system capacity +QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command + return QString; +} + #endif diff --git a/libLumina/LuminaOS.h b/libLumina/LuminaOS.h index 92a7dc7e..091a8d96 100644 --- a/libLumina/LuminaOS.h +++ b/libLumina/LuminaOS.h @@ -83,6 +83,9 @@ public: //Get the checksum for a file static QStringList Checksums(QStringList filepaths); //Return: checksum of each input file (same order) + + //Get the filesystem capacity + static QString FileSystemCapacity(QString dir) ; //Return: percentage capacity as give by the df command }; #endif diff --git a/lumina-fm/BackgroundWorker.cpp b/lumina-fm/BackgroundWorker.cpp index 1438f71e..c8d7cb17 100644 --- a/lumina-fm/BackgroundWorker.cpp +++ b/lumina-fm/BackgroundWorker.cpp @@ -85,4 +85,31 @@ 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 + int i = 0; + qreal totalSizes = 0; + foreach (QFileInfo fileInfo, fileList ) + { + if (fileInfo.isFile()) totalSizes += fileInfo.size(); + i += 1; + } + 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);} + 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()) 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..c4b74dbd 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -12,6 +12,8 @@ #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 +216,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()) ); @@ -447,8 +453,11 @@ void MainUI::setCurrentDir(QString dir){ 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 +550,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(); @@ -962,6 +976,10 @@ 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) worker->createStatusBarMsg(sel, "", tr("Items selected")); + 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..4744fe2a 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(); @@ -219,13 +220,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 diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp index 8b79682d..657ffc07 100644 --- a/lumina-open/main.cpp +++ b/lumina-open/main.cpp @@ -327,7 +327,7 @@ int main(int argc, char **argv){ //qDebug() << "[lumina-open] Finished Cmd:" << cmd << retcode << p->exitStatus(); //if(retcode!=0 ){ - if(p->exitStatus() == QProcess::CrashExit){ + if(p->exitStatus() == QProcess::CrashExit or retcode > 0){ qDebug() << "[lumina-open] Application Error:" << retcode; QString err = QString(p->readAllStandardError()); if(err.isEmpty()){ err = QString(p->readAllStandardOutput()); } |