aboutsummaryrefslogtreecommitdiff
path: root/lumina-fileinfo/dialog.cpp
diff options
context:
space:
mode:
authorwi <william.os4y@gmail.com>2015-03-29 22:14:14 +0200
committerwi <william.os4y@gmail.com>2015-03-29 22:14:14 +0200
commit029629ee702f9eb2babc21cfcc3322cfc734f4ce (patch)
tree8f574eb9913b64f166878f1aa3b8d2b664277fb3 /lumina-fileinfo/dialog.cpp
parentput the name lumina-fileinfo (diff)
downloadlumina-029629ee702f9eb2babc21cfcc3322cfc734f4ce.tar.gz
lumina-029629ee702f9eb2babc21cfcc3322cfc734f4ce.tar.bz2
lumina-029629ee702f9eb2babc21cfcc3322cfc734f4ce.zip
have a config directory to store templates
Diffstat (limited to 'lumina-fileinfo/dialog.cpp')
-rw-r--r--lumina-fileinfo/dialog.cpp35
1 files changed, 31 insertions, 4 deletions
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
bgstack15