1 #include "zip-settings-dialog.h"
9 extern QString vymName;
10 extern QString zipToolPath;
11 extern QString unzipToolPath;
12 extern bool zipToolAvailable;
13 extern bool unzipToolAvailable;
15 ZipSettingsDialog::ZipSettingsDialog(QWidget *parent) : QDialog(parent)
21 QDialog::setWindowTitle("VYM - " +
22 tr("zip settings", "dialog window title"));
24 connect(ui.zipToolPathLE, SIGNAL(textChanged(const QString &)), this,
25 SLOT(zipToolPathChanged()));
26 connect(ui.zipToolButton, SIGNAL(clicked()), this,
27 SLOT(zipToolButtonPressed()));
28 connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(accept()));
30 #if defined(Q_OS_WIN32)
31 ui.zipToolLabel->setText(tr("Path to 7z.exe", "zip tool settings dialog"));
33 ui.unzipToolPathLE->hide();
34 ui.unzipToolButton->hide();
35 ui.unzipToolStatusLabel->hide();
36 ui.unzipToolLabel->hide();
38 connect(ui.unzipToolPathLE, SIGNAL(textChanged(const QString &)), this,
39 SLOT(unzipToolPathChanged()));
40 connect(ui.unzipToolButton, SIGNAL(clicked()), this,
41 SLOT(unzipToolButtonPressed()));
45 void ZipSettingsDialog::zipToolPathChanged()
47 zipToolPath = ui.zipToolPathLE->text();
51 void ZipSettingsDialog::unzipToolPathChanged()
53 unzipToolPath = ui.unzipToolPathLE->text();
57 void ZipSettingsDialog::zipToolButtonPressed()
62 #if defined(Q_OS_WIN32)
63 filter = "Windows executable (*.exe);;";
64 text = QString(tr("Set path to 7z to zip/unzip files"));
67 text = QString(tr("Set path to zip files"));
70 QString fn = QFileDialog::getOpenFileName(
71 this, vymName + " - " + text + ":", zipToolPath, filter);
75 ui.zipToolPathLE->setText(fn);
80 void ZipSettingsDialog::unzipToolButtonPressed()
85 #if defined(Q_OS_WIN32)
86 // On windows we just use 7z for both zip/unzip
90 text = QString(tr("Set path to unzip files"));
93 QString fn = QFileDialog::getOpenFileName(
94 this, vymName + " - " + text + ":", zipToolPath, filter);
98 ui.unzipToolPathLE->setText(fn);
103 void ZipSettingsDialog::init()
105 ui.zipToolPathLE->setText(zipToolPath);
106 ui.unzipToolPathLE->setText(unzipToolPath);
107 updateCheckResults();
110 void ZipSettingsDialog::updateCheckResults()
115 if (zipToolAvailable)
116 zipStatus = QString(tr("Status: %1").arg("ok"));
118 zipStatus = QString(tr("Status: %1").arg("not ok"));
119 ui.zipToolStatusLabel->setText(zipStatus);
122 if (unzipToolAvailable)
123 unzipStatus = QString(tr("Status: %1").arg("ok"));
125 unzipStatus = QString(tr("Status: %1").arg("not ok"));
126 ui.unzipToolStatusLabel->setText(unzipStatus);