diff options
author | wi <william.os4y@gmail.com> | 2015-03-29 22:14:14 +0200 |
---|---|---|
committer | wi <william.os4y@gmail.com> | 2015-03-29 22:14:14 +0200 |
commit | 029629ee702f9eb2babc21cfcc3322cfc734f4ce (patch) | |
tree | 8f574eb9913b64f166878f1aa3b8d2b664277fb3 | |
parent | put the name lumina-fileinfo (diff) | |
download | lumina-029629ee702f9eb2babc21cfcc3322cfc734f4ce.tar.gz lumina-029629ee702f9eb2babc21cfcc3322cfc734f4ce.tar.bz2 lumina-029629ee702f9eb2babc21cfcc3322cfc734f4ce.zip |
have a config directory to store templates
-rw-r--r-- | lumina-fileinfo/defaults/fileinfo-app.template (renamed from lumina-fileinfo/fileinfo-app.template) | 0 | ||||
-rw-r--r-- | lumina-fileinfo/defaults/fileinfo-link.template (renamed from lumina-fileinfo/fileinfo-link.template) | 0 | ||||
-rw-r--r-- | lumina-fileinfo/dialog.cpp | 35 | ||||
-rw-r--r-- | lumina-fileinfo/lumina-fileinfo.qrc | 6 |
4 files changed, 37 insertions, 4 deletions
diff --git a/lumina-fileinfo/fileinfo-app.template b/lumina-fileinfo/defaults/fileinfo-app.template index 8519d3a1..8519d3a1 100644 --- a/lumina-fileinfo/fileinfo-app.template +++ b/lumina-fileinfo/defaults/fileinfo-app.template diff --git a/lumina-fileinfo/fileinfo-link.template b/lumina-fileinfo/defaults/fileinfo-link.template index 4a0b7830..4a0b7830 100644 --- a/lumina-fileinfo/fileinfo-link.template +++ b/lumina-fileinfo/defaults/fileinfo-link.template diff --git a/lumina-fileinfo/dialog.cpp b/lumina-fileinfo/dialog.cpp index bcb3a14d..30d80064 100644 --- a/lumina-fileinfo/dialog.cpp +++ b/lumina-fileinfo/dialog.cpp @@ -18,6 +18,20 @@ Dialog::Dialog(QWidget *parent) : this->setWindowIcon( LXDG::findIcon("preferences-desktop-default-applications","") ); ui->pbWorkingDir->setIcon( LXDG::findIcon("folder","") ); ui->pbCommand->setIcon( LXDG::findIcon("system-search","") ); + + //we copy qrc templates in the home dir of the user. + //this allow the user to adapt those template to is own whishes + QString templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-link.template"; + if (!QFile::exists(templateFile)) { + QFile::copy(":defaults/fileinfo-link.template", templateFile); + QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); + } + templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-app.template"; + if (!QFile::exists(templateFile)) { + QFile::copy(":defaults/fileinfo-app.template", templateFile); + QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); + } + } @@ -49,7 +63,7 @@ void Dialog::Initialise(QString param) ui->lblOptions->setVisible(false); ui->lblWorkingDir->setText("URL"); //we use the WorkingDir boxes for URL desktopType="link"; - } + } } @@ -66,10 +80,23 @@ void Dialog::LoadDesktopFile(QString input) } //if proposed file does not exist, than we will create one based on the templates - //TODO: have a config directory to store templates if (!QFile::exists(input)) { - if (desktopType=="link") { QFile::copy("./fileinfo-link.template", desktopFileName);} - else { QFile::copy("./fileinfo-app.template", desktopFileName);} + if (desktopType=="link") { + if (QFile::exists(QDir::homePath() + "/.lumina/LuminaDE/fileinfo-link.template")) { + //We take the template from homedir + QFile::copy(QDir::homePath() + "/.lumina/LuminaDE/fileinfo-link.template", desktopFileName); + } else { + //last possibility os to use the qrc template. + //But based on the initialisation, this should never occurs + QFile::copy(":defaults/fileinfo-link.template", desktopFileName); + } + } else { + if (QFile::exists(QDir::homePath() + "/.lumina/LuminaDE/fileinfo-app.template")) { + QFile::copy(QDir::homePath() + "/.lumina/LuminaDE/fileinfo-app.template", desktopFileName); + } else { + QFile::copy(":defaults/fileinfo-app.template", desktopFileName); + } + } } //use the standard LXDG object and load the desktop file diff --git a/lumina-fileinfo/lumina-fileinfo.qrc b/lumina-fileinfo/lumina-fileinfo.qrc new file mode 100644 index 00000000..4667589a --- /dev/null +++ b/lumina-fileinfo/lumina-fileinfo.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource> + <file>defaults/fileinfo-app.template</file> + <file>defaults/fileinfo-link.template</file> + </qresource> +</RCC> |