Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/keeshare/group/EditGroupWidgetKeeShare.cpp')
-rw-r--r--src/keeshare/group/EditGroupWidgetKeeShare.cpp87
1 files changed, 33 insertions, 54 deletions
diff --git a/src/keeshare/group/EditGroupWidgetKeeShare.cpp b/src/keeshare/group/EditGroupWidgetKeeShare.cpp
index 5df9f13ee..a3b71220f 100644
--- a/src/keeshare/group/EditGroupWidgetKeeShare.cpp
+++ b/src/keeshare/group/EditGroupWidgetKeeShare.cpp
@@ -20,9 +20,9 @@
#include "core/Config.h"
#include "core/CustomData.h"
-#include "core/FilePath.h"
#include "core/Group.h"
#include "core/Metadata.h"
+#include "core/Resources.h"
#include "crypto/ssh/OpenSSHKey.h"
#include "gui/FileDialog.h"
#include "keeshare/KeeShare.h"
@@ -36,27 +36,20 @@ EditGroupWidgetKeeShare::EditGroupWidgetKeeShare(QWidget* parent)
{
m_ui->setupUi(this);
- m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
- m_ui->togglePasswordGeneratorButton->setIcon(filePath()->icon("actions", "password-generator", false));
-
- m_ui->passwordGenerator->layout()->setContentsMargins(0, 0, 0, 0);
- m_ui->passwordGenerator->hide();
- m_ui->passwordGenerator->reset();
-
m_ui->messageWidget->hide();
m_ui->messageWidget->setCloseButtonVisible(false);
m_ui->messageWidget->setAutoHideTimeout(-1);
+ m_ui->messageWidget->setAnimate(false);
+
+ m_ui->passwordEdit->enablePasswordGenerator();
- connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), m_ui->passwordEdit, SLOT(setShowPassword(bool)));
- connect(m_ui->togglePasswordGeneratorButton, SIGNAL(toggled(bool)), SLOT(togglePasswordGeneratorButton(bool)));
connect(m_ui->passwordEdit, SIGNAL(textChanged(QString)), SLOT(selectPassword()));
- connect(m_ui->passwordGenerator, SIGNAL(appliedPassword(QString)), SLOT(setGeneratedPassword(QString)));
connect(m_ui->pathEdit, SIGNAL(editingFinished()), SLOT(selectPath()));
connect(m_ui->pathSelectionButton, SIGNAL(pressed()), SLOT(launchPathSelectionDialog()));
connect(m_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(selectType()));
connect(m_ui->clearButton, SIGNAL(clicked(bool)), SLOT(clearInputs()));
- connect(KeeShare::instance(), SIGNAL(activeChanged()), SLOT(showSharingState()));
+ connect(KeeShare::instance(), SIGNAL(activeChanged()), SLOT(updateSharingState()));
const auto types = QList<KeeShareSettings::Type>()
<< KeeShareSettings::Inactive << KeeShareSettings::ImportFrom << KeeShareSettings::ExportTo
@@ -101,9 +94,16 @@ void EditGroupWidgetKeeShare::setGroup(Group* temporaryGroup, QSharedPointer<Dat
update();
}
-void EditGroupWidgetKeeShare::showSharingState()
+void EditGroupWidgetKeeShare::updateSharingState()
{
- if (!m_temporaryGroup) {
+ // Only enable controls if we are active
+ bool isEnabled = m_ui->typeComboBox->currentData().toInt() > KeeShareSettings::Inactive;
+ m_ui->pathEdit->setEnabled(isEnabled);
+ m_ui->pathSelectionButton->setEnabled(isEnabled);
+ m_ui->passwordEdit->setEnabled(isEnabled);
+
+ if (!m_temporaryGroup || !isEnabled) {
+ m_ui->messageWidget->hideMessage();
return;
}
@@ -114,6 +114,8 @@ void EditGroupWidgetKeeShare::showSharingState()
#if defined(WITH_XC_KEESHARE_SECURE)
supportedExtensions << KeeShare::signedContainerFileType();
#endif
+
+ // Custom message for active KeeShare reference
const auto reference = KeeShare::referenceOf(m_temporaryGroup);
if (!reference.path.isEmpty()) {
bool supported = false;
@@ -164,26 +166,23 @@ void EditGroupWidgetKeeShare::showSharingState()
MessageWidget::Warning);
return;
}
-
- m_ui->messageWidget->hide();
}
+
+ // Standard message for state of KeeShare service
const auto active = KeeShare::active();
if (!active.in && !active.out) {
m_ui->messageWidget->showMessage(
tr("KeeShare is currently disabled. You can enable import/export in the application settings.",
"KeeShare is a proper noun"),
MessageWidget::Information);
- return;
- }
- if (active.in && !active.out) {
+ } else if (active.in && !active.out) {
m_ui->messageWidget->showMessage(tr("Database export is currently disabled by application settings."),
MessageWidget::Information);
- return;
- }
- if (!active.in && active.out) {
+ } else if (!active.in && active.out) {
m_ui->messageWidget->showMessage(tr("Database import is currently disabled by application settings."),
MessageWidget::Information);
- return;
+ } else {
+ m_ui->messageWidget->hideMessage();
}
}
@@ -198,13 +197,9 @@ void EditGroupWidgetKeeShare::update()
m_ui->typeComboBox->setCurrentIndex(reference.type);
m_ui->passwordEdit->setText(reference.password);
m_ui->pathEdit->setText(reference.path);
-
- showSharingState();
}
- m_ui->passwordGenerator->hide();
- m_ui->togglePasswordGeneratorButton->setChecked(false);
- m_ui->togglePasswordButton->setChecked(false);
+ updateSharingState();
}
void EditGroupWidgetKeeShare::clearInputs()
@@ -215,24 +210,7 @@ void EditGroupWidgetKeeShare::clearInputs()
m_ui->passwordEdit->clear();
m_ui->pathEdit->clear();
m_ui->typeComboBox->setCurrentIndex(KeeShareSettings::Inactive);
- m_ui->passwordGenerator->setVisible(false);
-}
-
-void EditGroupWidgetKeeShare::togglePasswordGeneratorButton(bool checked)
-{
- m_ui->passwordGenerator->regeneratePassword();
- m_ui->passwordGenerator->setVisible(checked);
-}
-
-void EditGroupWidgetKeeShare::setGeneratedPassword(const QString& password)
-{
- if (!m_temporaryGroup) {
- return;
- }
- auto reference = KeeShare::referenceOf(m_temporaryGroup);
- reference.password = password;
- KeeShare::setReferenceTo(m_temporaryGroup, reference);
- m_ui->togglePasswordGeneratorButton->setChecked(false);
+ updateSharingState();
}
void EditGroupWidgetKeeShare::selectPath()
@@ -250,7 +228,7 @@ void EditGroupWidgetKeeShare::launchPathSelectionDialog()
if (!m_temporaryGroup) {
return;
}
- QString defaultDirPath = config()->get("KeeShare/LastShareDir").toString();
+ QString defaultDirPath = config()->get(Config::KeeShare_LastShareDir).toString();
const bool dirExists = !defaultDirPath.isEmpty() && QDir(defaultDirPath).exists();
if (!dirExists) {
defaultDirPath = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).first();
@@ -284,17 +262,14 @@ void EditGroupWidgetKeeShare::launchPathSelectionDialog()
}
switch (reference.type) {
case KeeShareSettings::ImportFrom:
- filename = fileDialog()->getFileName(
- this, tr("Select import source"), defaultDirPath, filters, nullptr, QFileDialog::DontConfirmOverwrite);
+ filename = fileDialog()->getOpenFileName(this, tr("Select import source"), defaultDirPath, filters);
break;
case KeeShareSettings::ExportTo:
- filename = fileDialog()->getFileName(
- this, tr("Select export target"), defaultDirPath, filters, nullptr, QFileDialog::Option(0));
+ filename = fileDialog()->getSaveFileName(this, tr("Select export target"), defaultDirPath, filters);
break;
case KeeShareSettings::SynchronizeWith:
case KeeShareSettings::Inactive:
- filename = fileDialog()->getFileName(
- this, tr("Select import/export file"), defaultDirPath, filters, nullptr, QFileDialog::Option(0));
+ filename = fileDialog()->getSaveFileName(this, tr("Select import/export file"), defaultDirPath, filters);
break;
}
@@ -314,7 +289,9 @@ void EditGroupWidgetKeeShare::launchPathSelectionDialog()
m_ui->pathEdit->setText(filename);
selectPath();
- config()->set("KeeShare/LastShareDir", QFileInfo(filename).absolutePath());
+ config()->set(Config::KeeShare_LastShareDir, QFileInfo(filename).absolutePath());
+
+ updateSharingState();
}
void EditGroupWidgetKeeShare::selectPassword()
@@ -335,4 +312,6 @@ void EditGroupWidgetKeeShare::selectType()
auto reference = KeeShare::referenceOf(m_temporaryGroup);
reference.type = static_cast<KeeShareSettings::Type>(m_ui->typeComboBox->currentData().toInt());
KeeShare::setReferenceTo(m_temporaryGroup, reference);
+
+ updateSharingState();
}