summaryrefslogtreecommitdiffstats
path: root/src/configdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/configdialog.cpp')
-rw-r--r--src/configdialog.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/configdialog.cpp b/src/configdialog.cpp
index 4a711b03..4c9f227d 100644
--- a/src/configdialog.cpp
+++ b/src/configdialog.cpp
@@ -3,6 +3,7 @@
#include "mainwindow.h"
#include "qtpasssettings.h"
#include "ui_configdialog.h"
+#include "util.h"
#include <QClipboard>
#include <QDir>
#include <QFileDialog>
@@ -97,7 +98,8 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
useTemplate(QtPassSettings::isUseTemplate());
ui->profileTable->verticalHeader()->hide();
- ui->profileTable->horizontalHeader()->setStretchLastSection(true);
+ ui->profileTable->horizontalHeader()->setSectionResizeMode(
+ 1, QHeaderView::Stretch);
ui->label->setText(ui->label->text() + VERSION);
ui->comboBoxClipboard->clear();
@@ -170,7 +172,7 @@ void ConfigDialog::validate(QTableWidgetItem *item) {
for (int j = 0; j < ui->profileTable->columnCount(); j++) {
QTableWidgetItem *_item = ui->profileTable->item(i, j);
- if (_item->text().isEmpty()) {
+ if (_item->text().isEmpty() && j != 2) {
_item->setBackground(Qt::red);
status = false;
break;
@@ -181,7 +183,7 @@ void ConfigDialog::validate(QTableWidgetItem *item) {
break;
}
} else {
- if (item->text().isEmpty()) {
+ if (item->text().isEmpty() && item->column() != 2) {
item->setBackground(Qt::red);
status = false;
}
@@ -303,7 +305,7 @@ QString ConfigDialog::selectExecutable() {
dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setOption(QFileDialog::ReadOnly);
if (dialog.exec())
- return dialog.selectedFiles().first();
+ return dialog.selectedFiles().constFirst();
return QString();
}
@@ -318,7 +320,7 @@ QString ConfigDialog::selectFolder() {
dialog.setFilter(QDir::NoFilter);
dialog.setOption(QFileDialog::ShowDirsOnly);
if (dialog.exec())
- return dialog.selectedFiles().first();
+ return dialog.selectedFiles().constFirst();
return QString();
}
@@ -460,8 +462,8 @@ void ConfigDialog::genKey(QString batch, QDialog *dialog) {
* @param profiles
* @param profile
*/
-void ConfigDialog::setProfiles(QHash<QString, QString> profiles,
- QString profile) {
+void ConfigDialog::setProfiles(QHash<QString, QHash<QString, QString>> profiles,
+ QString currentProfile) {
// dbg()<< profiles;
if (profiles.contains("")) {
profiles.remove("");
@@ -469,15 +471,18 @@ void ConfigDialog::setProfiles(QHash<QString, QString> profiles,
}
ui->profileTable->setRowCount(profiles.count());
- QHashIterator<QString, QString> i(profiles);
+ QHashIterator<QString, QHash<QString, QString>> i(profiles);
int n = 0;
while (i.hasNext()) {
i.next();
if (!i.value().isEmpty() && !i.key().isEmpty()) {
ui->profileTable->setItem(n, 0, new QTableWidgetItem(i.key()));
- ui->profileTable->setItem(n, 1, new QTableWidgetItem(i.value()));
+ ui->profileTable->setItem(n, 1,
+ new QTableWidgetItem(i.value().value("path")));
+ ui->profileTable->setItem(
+ n, 2, new QTableWidgetItem(i.value().value("signingKey")));
// dbg()<< "naam:" + i.key();
- if (i.key() == profile)
+ if (i.key() == currentProfile)
ui->profileTable->selectRow(n);
}
++n;
@@ -488,17 +493,23 @@ void ConfigDialog::setProfiles(QHash<QString, QString> profiles,
* @brief ConfigDialog::getProfiles return profile list.
* @return
*/
-QHash<QString, QString> ConfigDialog::getProfiles() {
- QHash<QString, QString> profiles;
+QHash<QString, QHash<QString, QString>> ConfigDialog::getProfiles() {
+ QHash<QString, QHash<QString, QString>> profiles;
// Check?
for (int i = 0; i < ui->profileTable->rowCount(); ++i) {
+ QHash<QString, QString> profile;
QTableWidgetItem *pathItem = ui->profileTable->item(i, 1);
if (nullptr != pathItem) {
QTableWidgetItem *item = ui->profileTable->item(i, 0);
if (item == nullptr) {
continue;
}
- profiles.insert(item->text(), pathItem->text());
+ profile["path"] = pathItem->text();
+ QTableWidgetItem *signingKeyItem = ui->profileTable->item(i, 2);
+ if (nullptr != signingKeyItem) {
+ profile["signingKey"] = signingKeyItem->text();
+ }
+ profiles.insert(item->text(), profile);
}
}
return profiles;
@@ -512,6 +523,7 @@ void ConfigDialog::on_addButton_clicked() {
ui->profileTable->insertRow(n);
ui->profileTable->setItem(n, 0, new QTableWidgetItem());
ui->profileTable->setItem(n, 1, new QTableWidgetItem(ui->storePath->text()));
+ ui->profileTable->setItem(n, 2, new QTableWidgetItem());
ui->profileTable->selectRow(n);
ui->deleteButton->setEnabled(true);