diff options
author | Ken Moore <ken@pcbsd.org> | 2014-10-08 14:21:05 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2014-10-08 14:21:05 -0400 |
commit | 2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d (patch) | |
tree | 07a6748fd0d2f6199fd799d0e579c42bfc6df9e7 /lumina-open | |
parent | Clean up the default filemanager/terminal settings. Put them in the main sess... (diff) | |
download | lumina-2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d.tar.gz lumina-2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d.tar.bz2 lumina-2a2869aa6e1e673d3a1e29fc3b1dfd9c7d21ba6d.zip |
Add better binary detection to LuminaUtils, and setup lumina-open to use it.
Diffstat (limited to 'lumina-open')
-rw-r--r-- | lumina-open/LFileDialog.cpp | 10 | ||||
-rw-r--r-- | lumina-open/LFileDialog.h | 3 | ||||
-rw-r--r-- | lumina-open/main.cpp | 11 |
3 files changed, 13 insertions, 11 deletions
diff --git a/lumina-open/LFileDialog.cpp b/lumina-open/LFileDialog.cpp index e720bd65..dfd70ba2 100644 --- a/lumina-open/LFileDialog.cpp +++ b/lumina-open/LFileDialog.cpp @@ -127,10 +127,9 @@ void LFileDialog::updateUI(){ bool good = false; if(ui->radio_custom->isChecked()){ if(!ui->line_bin->text().isEmpty()){ - good = true; + good = LUtils::isValidBinary(ui->line_bin->text()); //Now verify that the file exists and is executable - QFileInfo FI(ui->line_bin->text()); - if( FI.exists() && FI.isExecutable() && FI.isFile() ){ + if( good ){ ui->label_goodbin->setPixmap(QPixmap(":/icons/good.png")); }else{ ui->label_goodbin->setPixmap(QPixmap(":/icons/bad.png")); @@ -206,7 +205,7 @@ void LFileDialog::radioChanged(){ }else{ ui->stackedWidget->setCurrentWidget(ui->page_custom); } - ui->check_default->setEnabled( !ui->radio_custom->isChecked() ); + //ui->check_default->setEnabled( !ui->radio_custom->isChecked() ); updateUI(); } @@ -219,6 +218,7 @@ void LFileDialog::radioChanged(){ void LFileDialog::on_tool_ok_clicked(){ appSelected = true; + setDefault = ui->check_default->isChecked(); if(ui->radio_custom->isChecked()){ appExec = ui->line_bin->text(); }else if(ui->radio_rec->isChecked()){ @@ -226,7 +226,6 @@ void LFileDialog::on_tool_ok_clicked(){ bool ok = false; XDGDesktop app = LXDG::loadDesktopFile(PREFAPPS[ui->combo_rec->currentIndex()], ok); //Set the output variables - setDefault = ui->check_default->isChecked(); appExec = app.exec; appPath = app.path; appFile = app.filePath; @@ -236,7 +235,6 @@ void LFileDialog::on_tool_ok_clicked(){ bool ok = false; XDGDesktop app = LXDG::loadDesktopFile(ui->tree_apps->currentItem()->whatsThis(0), ok); //Set the output variables - setDefault = ui->check_default->isChecked(); appExec = app.exec; appPath = app.path; appFile = app.filePath; diff --git a/lumina-open/LFileDialog.h b/lumina-open/LFileDialog.h index e6a8f1fc..27f038d6 100644 --- a/lumina-open/LFileDialog.h +++ b/lumina-open/LFileDialog.h @@ -20,7 +20,8 @@ #include <QTextStream> #include <QTreeWidgetItem> -#include "LuminaXDG.h" //From libLuminaUtils +#include <LuminaXDG.h> //From libLuminaUtils +#include <LuminaUtils.h> namespace Ui{ class LFileDialog; diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp index b0f43a79..46053cef 100644 --- a/lumina-open/main.cpp +++ b/lumina-open/main.cpp @@ -27,6 +27,7 @@ #include "LFileDialog.h" #include <LuminaXDG.h> +#include <LuminaUtils.h> #include <LuminaOS.h> void printUsageInfo(){ @@ -93,7 +94,7 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS } }else{ //Only binary given - if(QFile::exists(defApp)){ + if(LUtils::isValidBinary(defApp)){ qDebug() << "[lumina-open] Using default application:" << defApp << "File:" << inFile; return defApp; //just use the binary } @@ -137,8 +138,10 @@ QString cmdFromUser(int argc, char **argv, QString inFile, QString extension, QS if(!w.appPath.isEmpty()){ path = w.appPath; } //Just do the default application registration here for now // might move it to the runtime phase later after seeing that the app has successfully started - if(w.setDefault){ LFileDialog::setDefaultApp(extension, w.appFile); } - else{ LFileDialog::setDefaultApp(extension, ""); } + if(w.setDefault){ + if(!w.appFile.isEmpty()){ LFileDialog::setDefaultApp(extension, w.appFile); } + else{ LFileDialog::setDefaultApp(extension, w.appExec); } + }else{ LFileDialog::setDefaultApp(extension, ""); } //Now return the resulting application command return w.appExec; } @@ -192,7 +195,7 @@ void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& pat //Make sure that it is a valid file/URL bool isFile=false; bool isUrl=false; if(QFile::exists(inFile)){ isFile=true; } - else if(QUrl(inFile).isValid()){ isUrl=true; } + else if(QUrl(inFile).isValid() && !inFile.startsWith("/") ){ isUrl=true; } if( !isFile && !isUrl ){ qDebug() << "Error: Invalid file or URL"; return;} //Determing the type of file (extension) QString extension; |