From 19ac40b1974583197fe62f167442bb0d52e62b01 Mon Sep 17 00:00:00 2001 From: Nils Achtergarde Date: Sun, 31 Dec 2017 01:25:06 +0100 Subject: recommit of ed8fb7fab377f277811368229b5d056e7edd860a (automatically restart gpg4usb after changing keydb path (and add note that restart is done)) --- settingsdialog.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'settingsdialog.cpp') diff --git a/settingsdialog.cpp b/settingsdialog.cpp index ac41092..86d6fbf 100755 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -31,11 +31,13 @@ SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent) mimeTab = new MimeTab; keyserverTab = new KeyserverTab; advancedTab = new AdvancedTab; + gpgPathsTab = new GpgPathsTab; tabWidget->addTab(generalTab, tr("General")); tabWidget->addTab(appearanceTab, tr("Appearance")); tabWidget->addTab(mimeTab, tr("PGP/Mime")); tabWidget->addTab(keyserverTab, tr("Keyserver")); + tabWidget->addTab(gpgPathsTab, tr("Gpg paths")); tabWidget->addTab(advancedTab, tr("Advanced")); buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok @@ -81,6 +83,7 @@ void SettingsDialog::slotAccept() appearanceTab->applySettings(); keyserverTab->applySettings(); advancedTab->applySettings(); + gpgPathsTab->applySettings(); if (getRestartNeeded()) { emit signalRestartNeeded(true); } @@ -611,3 +614,79 @@ void AdvancedTab::applySettings() QSettings settings; settings.setValue("advanced/steganography", steganoCheckBox->isChecked()); } + +GpgPathsTab::GpgPathsTab(QWidget *parent) + : QWidget(parent) +{ + setSettings(); + + /***************************************** + * Keydb Box + *****************************************/ + QGroupBox *keydbBox = new QGroupBox(tr("Relative path to keydb")); + QGridLayout *keydbBoxLayout = new QGridLayout(); + + // Label containing the current keydbpath relative to default keydb path + keydbLabel = new QLabel(accKeydbPath,this); + + QPushButton *keydbButton = new QPushButton("Choose keydb path",this); + connect(keydbButton, SIGNAL(clicked()), this, SLOT(chooseKeydbDir())); + QPushButton *keydbDefaultButton = new QPushButton("Set keydb to default path",this); + connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(setKeydbPathToDefault())); + + keydbBox->setLayout(keydbBoxLayout); + keydbBoxLayout->addWidget(keydbLabel,1,1); + keydbBoxLayout->addWidget(keydbButton,1,2); + keydbBoxLayout->addWidget(keydbDefaultButton,2,2); + keydbBoxLayout->addWidget(new QLabel(tr("NOTE: Gpg4usb will restart automatically if you change the keydb path!")),3,1); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(keydbBox); + mainLayout->addStretch(1); + setLayout(mainLayout); +} + +QString GpgPathsTab::getRelativePath(const QString dir1,const QString dir2) +{ + QDir dir(dir1); + QString s; + + s = dir.relativeFilePath(dir2); + qDebug() << "relative path: " << s; + if (s.isEmpty()) { + s = "."; + } + return s; +} + +void GpgPathsTab::setKeydbPathToDefault() +{ + accKeydbPath = "."; + keydbLabel->setText("."); +} + +QString GpgPathsTab::chooseKeydbDir() +{ + QString dir = QFileDialog::getExistingDirectory(this,tr ("Choose keydb directory"),accKeydbPath,QFileDialog::ShowDirsOnly); + + accKeydbPath = getRelativePath(defKeydbPath, dir); + keydbLabel->setText(accKeydbPath); + return ""; +} + +void GpgPathsTab::setSettings() +{ + defKeydbPath = qApp->applicationDirPath() + "/keydb"; + + QSettings settings; + accKeydbPath = settings.value("gpgpaths/keydbpath").toString(); + if (accKeydbPath.isEmpty()) { + accKeydbPath = "."; + } +} + +void GpgPathsTab::applySettings() +{ + QSettings settings; + settings.setValue("gpgpaths/keydbpath",accKeydbPath); +} -- cgit v1.2.3 From d783d8e456a3d130a8e8055ec6ccd8f97762f35c Mon Sep 17 00:00:00 2001 From: Nils Achtergarde Date: Sun, 31 Dec 2017 01:31:51 +0100 Subject: recommit of dbe66cf033cf8b450b74e2e3fd510310169bce24 (minor changes for keydbpath in settingsdialog) --- settingsdialog.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'settingsdialog.cpp') diff --git a/settingsdialog.cpp b/settingsdialog.cpp index 86d6fbf..c4eda75 100755 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -629,16 +629,17 @@ GpgPathsTab::GpgPathsTab(QWidget *parent) // Label containing the current keydbpath relative to default keydb path keydbLabel = new QLabel(accKeydbPath,this); - QPushButton *keydbButton = new QPushButton("Choose keydb path",this); + QPushButton *keydbButton = new QPushButton("Change keydb path",this); connect(keydbButton, SIGNAL(clicked()), this, SLOT(chooseKeydbDir())); QPushButton *keydbDefaultButton = new QPushButton("Set keydb to default path",this); connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(setKeydbPathToDefault())); keydbBox->setLayout(keydbBoxLayout); - keydbBoxLayout->addWidget(keydbLabel,1,1); - keydbBoxLayout->addWidget(keydbButton,1,2); - keydbBoxLayout->addWidget(keydbDefaultButton,2,2); - keydbBoxLayout->addWidget(new QLabel(tr("NOTE: Gpg4usb will restart automatically if you change the keydb path!")),3,1); + keydbBoxLayout->addWidget(new QLabel(tr("Current keydb path: ")),1,1); + keydbBoxLayout->addWidget(keydbLabel,1,2); + keydbBoxLayout->addWidget(keydbButton,1,3); + keydbBoxLayout->addWidget(keydbDefaultButton,2,3); + keydbBoxLayout->addWidget(new QLabel(tr("NOTE: Gpg4usb will restart automatically if you change the keydb path!")),3,1,1,3); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(keydbBox); -- cgit v1.2.3