Small refactoring in DatabaseWidget.

This commit is contained in:
Florian Geyer 2013-12-01 09:59:43 +01:00
parent 4a3da3abe7
commit 2308099260
2 changed files with 12 additions and 26 deletions

View File

@ -296,11 +296,7 @@ void DatabaseWidget::copyTitle()
return; return;
} }
clipboard()->setText(currentEntry->title()); setClipboardTextAndMinimize(currentEntry->title());
if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized();
}
} }
void DatabaseWidget::copyUsername() void DatabaseWidget::copyUsername()
@ -311,11 +307,7 @@ void DatabaseWidget::copyUsername()
return; return;
} }
clipboard()->setText(currentEntry->username()); setClipboardTextAndMinimize(currentEntry->username());
if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized();
}
} }
void DatabaseWidget::copyPassword() void DatabaseWidget::copyPassword()
@ -326,11 +318,7 @@ void DatabaseWidget::copyPassword()
return; return;
} }
clipboard()->setText(currentEntry->password()); setClipboardTextAndMinimize(currentEntry->password());
if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized();
}
} }
void DatabaseWidget::copyURL() void DatabaseWidget::copyURL()
@ -341,11 +329,7 @@ void DatabaseWidget::copyURL()
return; return;
} }
clipboard()->setText(currentEntry->url()); setClipboardTextAndMinimize(currentEntry->url());
if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized();
}
} }
void DatabaseWidget::copyNotes() void DatabaseWidget::copyNotes()
@ -356,11 +340,7 @@ void DatabaseWidget::copyNotes()
return; return;
} }
clipboard()->setText(currentEntry->notes()); setClipboardTextAndMinimize(currentEntry->notes());
if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized();
}
} }
void DatabaseWidget::copyAttribute(QAction* action) void DatabaseWidget::copyAttribute(QAction* action)
@ -371,8 +351,12 @@ void DatabaseWidget::copyAttribute(QAction* action)
return; return;
} }
clipboard()->setText(currentEntry->attributes()->value(action->text())); setClipboardTextAndMinimize(currentEntry->attributes()->value(action->text()));
}
void DatabaseWidget::setClipboardTextAndMinimize(const QString& text)
{
clipboard()->setText(text);
if (config()->get("MinimizeOnCopy").toBool()) { if (config()->get("MinimizeOnCopy").toBool()) {
window()->showMinimized(); window()->showMinimized();
} }

View File

@ -128,6 +128,8 @@ private Q_SLOTS:
void closeSearch(); void closeSearch();
private: private:
void setClipboardTextAndMinimize(const QString& text);
Database* m_db; Database* m_db;
const QScopedPointer<Ui::SearchWidget> m_searchUi; const QScopedPointer<Ui::SearchWidget> m_searchUi;
QWidget* const m_searchWidget; QWidget* const m_searchWidget;