From 029629ee702f9eb2babc21cfcc3322cfc734f4ce Mon Sep 17 00:00:00 2001 From: wi Date: Sun, 29 Mar 2015 22:14:14 +0200 Subject: have a config directory to store templates --- lumina-fileinfo/defaults/fileinfo-app.template | 11 ++++++++ lumina-fileinfo/defaults/fileinfo-link.template | 7 +++++ lumina-fileinfo/dialog.cpp | 35 ++++++++++++++++++++++--- lumina-fileinfo/fileinfo-app.template | 11 -------- lumina-fileinfo/fileinfo-link.template | 7 ----- lumina-fileinfo/lumina-fileinfo.qrc | 6 +++++ 6 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 lumina-fileinfo/defaults/fileinfo-app.template create mode 100644 lumina-fileinfo/defaults/fileinfo-link.template delete mode 100644 lumina-fileinfo/fileinfo-app.template delete mode 100644 lumina-fileinfo/fileinfo-link.template create mode 100644 lumina-fileinfo/lumina-fileinfo.qrc diff --git a/lumina-fileinfo/defaults/fileinfo-app.template b/lumina-fileinfo/defaults/fileinfo-app.template new file mode 100644 index 00000000..8519d3a1 --- /dev/null +++ b/lumina-fileinfo/defaults/fileinfo-app.template @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Encoding=UTF-8 +Name=Name +Exec=Command +Icon=system-help.png +StartupNotify=false +Terminal=false +Type=Application +Categories=Application +Comment=Comment diff --git a/lumina-fileinfo/defaults/fileinfo-link.template b/lumina-fileinfo/defaults/fileinfo-link.template new file mode 100644 index 00000000..4a0b7830 --- /dev/null +++ b/lumina-fileinfo/defaults/fileinfo-link.template @@ -0,0 +1,7 @@ +[Desktop Entry] +Version=1.0 +Encoding=UTF-8 +Name=Name +Icon=system-help.png +Type=Link +Comment=Comment 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/fileinfo-app.template b/lumina-fileinfo/fileinfo-app.template deleted file mode 100644 index 8519d3a1..00000000 --- a/lumina-fileinfo/fileinfo-app.template +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Version=1.0 -Encoding=UTF-8 -Name=Name -Exec=Command -Icon=system-help.png -StartupNotify=false -Terminal=false -Type=Application -Categories=Application -Comment=Comment diff --git a/lumina-fileinfo/fileinfo-link.template b/lumina-fileinfo/fileinfo-link.template deleted file mode 100644 index 4a0b7830..00000000 --- a/lumina-fileinfo/fileinfo-link.template +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Version=1.0 -Encoding=UTF-8 -Name=Name -Icon=system-help.png -Type=Link -Comment=Comment 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 @@ + + + defaults/fileinfo-app.template + defaults/fileinfo-link.template + + -- cgit