mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -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
@ -61,8 +61,6 @@
|
||||
#include "keeshare/KeeShare.h"
|
||||
#include "touchid/TouchID.h"
|
||||
|
||||
#include "config-keepassx.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
@ -80,6 +78,9 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
||||
, m_previewView(new EntryPreviewWidget(this))
|
||||
, m_previewSplitter(new QSplitter(m_mainWidget))
|
||||
, m_searchingLabel(new QLabel(this))
|
||||
#ifdef WITH_XC_KEESHARE
|
||||
, m_shareLabel(new QLabel(this))
|
||||
#endif
|
||||
, m_csvImportWizard(new CsvImportWizard(this))
|
||||
, m_editEntryWidget(new EditEntryWidget(this))
|
||||
, m_editGroupWidget(new EditGroupWidget(this))
|
||||
@ -103,6 +104,9 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
||||
auto* vbox = new QVBoxLayout();
|
||||
vbox->setMargin(0);
|
||||
vbox->addWidget(m_searchingLabel);
|
||||
#ifdef WITH_XC_KEESHARE
|
||||
vbox->addWidget(m_shareLabel);
|
||||
#endif
|
||||
vbox->addWidget(m_previewSplitter);
|
||||
rightHandSideWidget->setLayout(vbox);
|
||||
m_entryView = new EntryView(rightHandSideWidget);
|
||||
@ -134,6 +138,16 @@ DatabaseWidget::DatabaseWidget(QSharedPointer<Database> db, QWidget* parent)
|
||||
"border-radius: 4px;");
|
||||
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_previewSplitter->addWidget(m_entryView);
|
||||
m_previewSplitter->addWidget(m_previewView);
|
||||
@ -765,9 +779,9 @@ void DatabaseWidget::switchToMainView(bool previousDialogAccepted)
|
||||
|
||||
setCurrentWidget(m_mainWidget);
|
||||
|
||||
if (sender() == m_entryView) {
|
||||
if (sender() == m_entryView || sender() == m_editEntryWidget) {
|
||||
onEntryChanged(m_entryView->currentEntry());
|
||||
} else if (sender() == m_groupView) {
|
||||
} else if (sender() == m_groupView || sender() == m_editGroupWidget) {
|
||||
onGroupChanged(m_groupView->currentGroup());
|
||||
}
|
||||
}
|
||||
@ -1089,6 +1103,7 @@ void DatabaseWidget::search(const QString& searchtext)
|
||||
}
|
||||
|
||||
m_searchingLabel->setVisible(true);
|
||||
m_shareLabel->setVisible(false);
|
||||
|
||||
emit searchModeActivated();
|
||||
}
|
||||
@ -1117,6 +1132,16 @@ void DatabaseWidget::onGroupChanged(Group* 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()
|
||||
@ -1140,6 +1165,7 @@ void DatabaseWidget::endSearch()
|
||||
|
||||
// Show the normal entry view of the current group
|
||||
m_entryView->displayGroup(currentGroup());
|
||||
onGroupChanged(currentGroup());
|
||||
|
||||
emit listModeActivated();
|
||||
}
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "gui/csvImport/CsvImportWizard.h"
|
||||
#include "gui/entry/EntryModel.h"
|
||||
|
||||
#include "config-keepassx.h"
|
||||
|
||||
class DatabaseOpenWidget;
|
||||
class KeePass1OpenWidget;
|
||||
class DatabaseSettingsDialog;
|
||||
@ -233,6 +235,9 @@ private:
|
||||
QPointer<EntryPreviewWidget> m_previewView;
|
||||
QPointer<QSplitter> m_previewSplitter;
|
||||
QPointer<QLabel> m_searchingLabel;
|
||||
#ifdef WITH_XC_KEESHARE
|
||||
QPointer<QLabel> m_shareLabel;
|
||||
#endif
|
||||
QPointer<CsvImportWizard> m_csvImportWizard;
|
||||
QPointer<EditEntryWidget> m_editEntryWidget;
|
||||
QPointer<EditGroupWidget> m_editGroupWidget;
|
||||
|
@ -120,6 +120,7 @@ bool SearchWidget::eventFilter(QObject* obj, QEvent* event)
|
||||
|
||||
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(caseSensitiveChanged(bool)), SLOT(setSearchCaseSensitive(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)
|
||||
{
|
||||
return group->customData()->contains(KeeShare_Reference);
|
||||
return group && group->customData()->contains(KeeShare_Reference);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (!isShared(group)) {
|
||||
|
@ -43,6 +43,9 @@ public:
|
||||
static bool isShared(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::Active active();
|
||||
static KeeShareSettings::Foreign foreign();
|
||||
|
Loading…
Reference in New Issue
Block a user