summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Gehad elrobey <gehadelrobey@gmail.com>2015-07-28 09:05:58 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-07-28 11:38:59 +0300
commit1dd2518624cc001afacead74caed854ac78a5b6a (patch)
tree133da189961019886d1e61429bb9f6c698f4b883 /qt-ui
parentfc9cba692eb0e5a570854e2b10c38dbddcdfce83 (diff)
downloadsubsurface-1dd2518624cc001afacead74caed854ac78a5b6a.tar.gz
Printing: support importing/exporting of templates
Implement 'import/export' features, so it's easier to share customized printing templates. Also support deleting existing templates. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/printoptions.cpp37
-rw-r--r--qt-ui/printoptions.h3
2 files changed, 40 insertions, 0 deletions
diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp
index 6cfbed481..916d9d696 100644
--- a/qt-ui/printoptions.cpp
+++ b/qt-ui/printoptions.cpp
@@ -1,6 +1,10 @@
#include "printoptions.h"
#include "templateedit.h"
+#include "helpers.h"
+
#include <QDebug>
+#include <QFileDialog>
+#include <QMessageBox>
PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt, struct template_options *templateOpt)
{
@@ -97,6 +101,39 @@ void PrintOptions::on_editButton_clicked()
setup();
}
+void PrintOptions::on_importButton_clicked()
+{
+ QString filename = QFileDialog::getOpenFileName(this, tr("Import Template file"), "",
+ tr("HTML files (*.html)"));
+ QFileInfo fileInfo(filename);
+ QFile::copy(filename, getSubsurfaceDataPath("printing_templates") + QDir::separator() + fileInfo.fileName());
+ find_all_templates();
+ setup();
+}
+
+void PrintOptions::on_exportButton_clicked()
+{
+ QString filename = QFileDialog::getSaveFileName(this, tr("Export Template files as"), "",
+ tr("HTML files (*.html)"));
+ QFile::copy(getSubsurfaceDataPath("printing_templates") + QDir::separator() + getSelectedTemplate(), filename);
+}
+
+void PrintOptions::on_deleteButton_clicked()
+{
+ QString templateName = getSelectedTemplate();
+ QMessageBox msgBox;
+ msgBox.setText("This action cannot be undone!");
+ msgBox.setInformativeText("Delete '" + templateName + "' template?");
+ msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Cancel);
+ if (msgBox.exec() == QMessageBox::Ok) {
+ QFile f(getSubsurfaceDataPath("printing_templates") + QDir::separator() + templateName);
+ f.remove();
+ find_all_templates();
+ setup();
+ }
+}
+
QString PrintOptions::getSelectedTemplate()
{
return ui.printTemplate->currentData().toString();
diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h
index b9912d2ed..528c5ed4d 100644
--- a/qt-ui/printoptions.h
+++ b/qt-ui/printoptions.h
@@ -69,6 +69,9 @@ slots:
void on_radioDiveListPrint_clicked(bool check);
void on_printTemplate_currentIndexChanged(int index);
void on_editButton_clicked();
+ void on_importButton_clicked();
+ void on_exportButton_clicked();
+ void on_deleteButton_clicked();
};
#endif // PRINTOPTIONS_H