mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-09 06:52:50 -04:00
Add share indication label in group view (#2742)
* When viewing a shared group, the sharing state is indicated by a label similar to the search label. * Banner shows on children of shared groups * When searching, share banner is hidden * Fixed issue where group/entry information was not updated after change
This commit is contained in:
parent
a2bd08ca8a
commit
ebb87e6379
5 changed files with 74 additions and 5 deletions
|
@ -61,8 +61,6 @@
|
||||||
#include "keeshare/KeeShare.h"
|
#include "keeshare/KeeShare.h"
|
||||||
#include "touchid/TouchID.h"
|
#include "touchid/TouchID.h"
|
||||||
|
|
||||||
#include "config-keepassx.h"
|
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
#include <sys/vfs.h>
|
#include <sys/vfs.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,6 +78,9 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
||||||
, m_previewView(new EntryPreviewWidget(this))
|
, m_previewView(new EntryPreviewWidget(this))
|
||||||
, m_previewSplitter(new QSplitter(m_mainWidget))
|
, m_previewSplitter(new QSplitter(m_mainWidget))
|
||||||
, m_searchingLabel(new QLabel(this))
|
, m_searchingLabel(new QLabel(this))
|
||||||
|
#ifdef WITH_XC_KEESHARE
|
||||||
|
, m_shareLabel(new QLabel(this))
|
||||||
|
#endif
|
||||||
, m_csvImportWizard(new CsvImportWizard(this))
|
, m_csvImportWizard(new CsvImportWizard(this))
|
||||||
, m_editEntryWidget(new EditEntryWidget(this))
|
, m_editEntryWidget(new EditEntryWidget(this))
|
||||||
, m_editGroupWidget(new EditGroupWidget(this))
|
, m_editGroupWidget(new EditGroupWidget(this))
|
||||||
|
@ -103,6 +104,9 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
||||||
auto* vbox = new QVBoxLayout();
|
auto* vbox = new QVBoxLayout();
|
||||||
vbox->setMargin(0);
|
vbox->setMargin(0);
|
||||||
vbox->addWidget(m_searchingLabel);
|
vbox->addWidget(m_searchingLabel);
|
||||||
|
#ifdef WITH_XC_KEESHARE
|
||||||
|
vbox->addWidget(m_shareLabel);
|
||||||
|
#endif
|
||||||
vbox->addWidget(m_previewSplitter);
|
vbox->addWidget(m_previewSplitter);
|
||||||
rightHandSideWidget->setLayout(vbox);
|
rightHandSideWidget->setLayout(vbox);
|
||||||
m_entryView = new EntryView(rightHandSideWidget);
|
m_entryView = new EntryView(rightHandSideWidget);
|
||||||
|
@ -134,6 +138,16 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
||||||
"border-radius: 4px;");
|
"border-radius: 4px;");
|
||||||
m_searchingLabel->setVisible(false);
|
m_searchingLabel->setVisible(false);
|
||||||
|
|
||||||
|
#ifdef WITH_XC_KEESHARE
|
||||||
|
m_shareLabel->setText(tr("Shared group..."));
|
||||||
|
m_shareLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
m_shareLabel->setStyleSheet("color: rgb(0, 0, 0);"
|
||||||
|
"background-color: rgb(255, 253, 160);"
|
||||||
|
"border: 2px solid rgb(190, 190, 190);"
|
||||||
|
"border-radius: 4px;");
|
||||||
|
m_shareLabel->setVisible(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_previewView->hide();
|
m_previewView->hide();
|
||||||
m_previewSplitter->addWidget(m_entryView);
|
m_previewSplitter->addWidget(m_entryView);
|
||||||
m_previewSplitter->addWidget(m_previewView);
|
m_previewSplitter->addWidget(m_previewView);
|
||||||
|
@ -765,9 +779,9 @@ void DatabaseWidget::switchToMainView(bool previousDialogAccepted)
|
||||||
|
|
||||||
setCurrentWidget(m_mainWidget);
|
setCurrentWidget(m_mainWidget);
|
||||||
|
|
||||||
if (sender() == m_entryView) {
|
if (sender() == m_entryView || sender() == m_editEntryWidget) {
|
||||||
onEntryChanged(m_entryView->currentEntry());
|
onEntryChanged(m_entryView->currentEntry());
|
||||||
} else if (sender() == m_groupView) {
|
} else if (sender() == m_groupView || sender() == m_editGroupWidget) {
|
||||||
onGroupChanged(m_groupView->currentGroup());
|
onGroupChanged(m_groupView->currentGroup());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1089,6 +1103,7 @@ void DatabaseWidget::search(const QString& searchtext)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_searchingLabel->setVisible(true);
|
m_searchingLabel->setVisible(true);
|
||||||
|
m_shareLabel->setVisible(false);
|
||||||
|
|
||||||
emit searchModeActivated();
|
emit searchModeActivated();
|
||||||
}
|
}
|
||||||
|
@ -1117,6 +1132,16 @@ void DatabaseWidget::onGroupChanged(Group* group)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_previewView->setGroup(group);
|
m_previewView->setGroup(group);
|
||||||
|
|
||||||
|
#ifdef WITH_XC_KEESHARE
|
||||||
|
auto shareLabel = KeeShare::sharingLabel(group);
|
||||||
|
if (!shareLabel.isEmpty()) {
|
||||||
|
m_shareLabel->setText(shareLabel);
|
||||||
|
m_shareLabel->setVisible(true);
|
||||||
|
} else {
|
||||||
|
m_shareLabel->setVisible(false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::onDatabaseModified()
|
void DatabaseWidget::onDatabaseModified()
|
||||||
|
@ -1140,6 +1165,7 @@ void DatabaseWidget::endSearch()
|
||||||
|
|
||||||
// Show the normal entry view of the current group
|
// Show the normal entry view of the current group
|
||||||
m_entryView->displayGroup(currentGroup());
|
m_entryView->displayGroup(currentGroup());
|
||||||
|
onGroupChanged(currentGroup());
|
||||||
|
|
||||||
emit listModeActivated();
|
emit listModeActivated();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include "gui/csvImport/CsvImportWizard.h"
|
#include "gui/csvImport/CsvImportWizard.h"
|
||||||
#include "gui/entry/EntryModel.h"
|
#include "gui/entry/EntryModel.h"
|
||||||
|
|
||||||
|
#include "config-keepassx.h"
|
||||||
|
|
||||||
class DatabaseOpenWidget;
|
class DatabaseOpenWidget;
|
||||||
class KeePass1OpenWidget;
|
class KeePass1OpenWidget;
|
||||||
class DatabaseSettingsDialog;
|
class DatabaseSettingsDialog;
|
||||||
|
@ -233,6 +235,9 @@ private:
|
||||||
QPointer<EntryPreviewWidget> m_previewView;
|
QPointer<EntryPreviewWidget> m_previewView;
|
||||||
QPointer<QSplitter> m_previewSplitter;
|
QPointer<QSplitter> m_previewSplitter;
|
||||||
QPointer<QLabel> m_searchingLabel;
|
QPointer<QLabel> m_searchingLabel;
|
||||||
|
#ifdef WITH_XC_KEESHARE
|
||||||
|
QPointer<QLabel> m_shareLabel;
|
||||||
|
#endif
|
||||||
QPointer<CsvImportWizard> m_csvImportWizard;
|
QPointer<CsvImportWizard> m_csvImportWizard;
|
||||||
QPointer<EditEntryWidget> m_editEntryWidget;
|
QPointer<EditEntryWidget> m_editEntryWidget;
|
||||||
QPointer<EditGroupWidget> m_editGroupWidget;
|
QPointer<EditGroupWidget> m_editGroupWidget;
|
||||||
|
|
|
@ -120,6 +120,7 @@ bool SearchWidget::eventFilter(QObject* obj, QEvent* event)
|
||||||
|
|
||||||
void SearchWidget::connectSignals(SignalMultiplexer& mx)
|
void SearchWidget::connectSignals(SignalMultiplexer& mx)
|
||||||
{
|
{
|
||||||
|
// Connects basically only to the current DatabaseWidget, but allows to switch between instances!
|
||||||
mx.connect(this, SIGNAL(search(QString)), SLOT(search(QString)));
|
mx.connect(this, SIGNAL(search(QString)), SLOT(search(QString)));
|
||||||
mx.connect(this, SIGNAL(caseSensitiveChanged(bool)), SLOT(setSearchCaseSensitive(bool)));
|
mx.connect(this, SIGNAL(caseSensitiveChanged(bool)), SLOT(setSearchCaseSensitive(bool)));
|
||||||
mx.connect(this, SIGNAL(limitGroupChanged(bool)), SLOT(setSearchLimitGroup(bool)));
|
mx.connect(this, SIGNAL(limitGroupChanged(bool)), SLOT(setSearchLimitGroup(bool)));
|
||||||
|
|
|
@ -93,7 +93,7 @@ void KeeShare::setOwn(const KeeShareSettings::Own& own)
|
||||||
|
|
||||||
bool KeeShare::isShared(const Group* group)
|
bool KeeShare::isShared(const Group* group)
|
||||||
{
|
{
|
||||||
return group->customData()->contains(KeeShare_Reference);
|
return group && group->customData()->contains(KeeShare_Reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeeShareSettings::Reference KeeShare::referenceOf(const Group* group)
|
KeeShareSettings::Reference KeeShare::referenceOf(const Group* group)
|
||||||
|
@ -142,6 +142,40 @@ bool KeeShare::isEnabled(const Group* group)
|
||||||
return (reference.isImporting() && active.in) || (reference.isExporting() && active.out);
|
return (reference.isImporting() && active.in) || (reference.isExporting() && active.out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Group* KeeShare::resolveSharedGroup(const Group* group)
|
||||||
|
{
|
||||||
|
while (group && group != group->database()->rootGroup()) {
|
||||||
|
if (isShared(group)) {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
group = group->parentGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KeeShare::sharingLabel(const Group* group)
|
||||||
|
{
|
||||||
|
auto* share = resolveSharedGroup(group);
|
||||||
|
if (!share) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto reference = referenceOf(share);
|
||||||
|
switch (reference.type) {
|
||||||
|
case KeeShareSettings::Inactive:
|
||||||
|
return tr("Disabled share %1").arg(reference.path);
|
||||||
|
case KeeShareSettings::ImportFrom:
|
||||||
|
return tr("Import from share %1").arg(reference.path);
|
||||||
|
case KeeShareSettings::ExportTo:
|
||||||
|
return tr("Export to share %1").arg(reference.path);
|
||||||
|
case KeeShareSettings::SynchronizeWith:
|
||||||
|
return tr("Synchronize with share %1").arg(reference.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap KeeShare::indicatorBadge(const Group* group, QPixmap pixmap)
|
QPixmap KeeShare::indicatorBadge(const Group* group, QPixmap pixmap)
|
||||||
{
|
{
|
||||||
if (!isShared(group)) {
|
if (!isShared(group)) {
|
||||||
|
|
|
@ -43,6 +43,9 @@ public:
|
||||||
static bool isShared(const Group* group);
|
static bool isShared(const Group* group);
|
||||||
static bool isEnabled(const Group* group);
|
static bool isEnabled(const Group* group);
|
||||||
|
|
||||||
|
static const Group* resolveSharedGroup(const Group* group);
|
||||||
|
static QString sharingLabel(const Group* group);
|
||||||
|
|
||||||
static KeeShareSettings::Own own();
|
static KeeShareSettings::Own own();
|
||||||
static KeeShareSettings::Active active();
|
static KeeShareSettings::Active active();
|
||||||
static KeeShareSettings::Foreign foreign();
|
static KeeShareSettings::Foreign foreign();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue