Skip to content

Commit

Permalink
Use signal/slot for updating the view after CloneDialog is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Feb 5, 2023
1 parent d91acd1 commit c2dc24c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/gui/CloneDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ void CloneDialog::cloneEntry()
Entry* entry = m_entry->clone(flags);
entry->setGroup(m_entry->group());

m_parent->entryView()->setCurrentEntry(entry);
m_parent->refreshSearch();
emit entryCloned(entry);
close();
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/CloneDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class CloneDialog : public QDialog
explicit CloneDialog(DatabaseWidget* parent = nullptr, Database* db = nullptr, Entry* entry = nullptr);
~CloneDialog() override;

signals:
void entryCloned(Entry* clone);

private:
QScopedPointer<Ui::CloneDialog> m_ui;

Expand Down
7 changes: 7 additions & 0 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,16 @@ void DatabaseWidget::cloneEntry()
}

auto cloneDialog = new CloneDialog(this, m_db.data(), currentEntry);
connect(cloneDialog, &CloneDialog::entryCloned, this, &DatabaseWidget::entryCloned);
cloneDialog->show();
}

void DatabaseWidget::entryCloned(Entry* clone)
{
m_entryView->setCurrentEntry(clone);
refreshSearch();
}

void DatabaseWidget::showTotp()
{
auto currentEntry = currentSelectedEntry();
Expand Down
1 change: 1 addition & 0 deletions src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public slots:

private slots:
void entryActivationSignalReceived(Entry* entry, EntryModel::ModelColumn column);
void entryCloned(Entry* clone);
void switchBackToEntryEdit();
void switchToHistoryView(Entry* entry);
void switchToEntryEdit(Entry*);
Expand Down

0 comments on commit c2dc24c

Please sign in to comment.