Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/actions/system-help.svg
share/icons/application/scalable/actions/system-search.svg
share/icons/application/scalable/actions/system-software-update.svg
share/icons/application/scalable/actions/sweep.svg
share/icons/application/scalable/actions/tag.svg
share/icons/application/scalable/actions/tag-multiple.svg
share/icons/application/scalable/actions/tag-search.svg
Expand Down
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/sweep.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<file>application/scalable/actions/system-help.svg</file>
<file>application/scalable/actions/system-search.svg</file>
<file>application/scalable/actions/system-software-update.svg</file>
<file>application/scalable/actions/sweep.svg</file>
<file>application/scalable/actions/tag.svg</file>
<file>application/scalable/actions/tag-multiple.svg</file>
<file>application/scalable/actions/tag-search.svg</file>
Expand Down
4 changes: 4 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6432,6 +6432,10 @@ Expect some bugs and minor issues, this version is meant for testing purposes.</
<numerusform></numerusform>
</translation>
</message>
<message>
<source>Clear the clipboard immediately</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ManageDatabase</name>
Expand Down
22 changes: 22 additions & 0 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,25 @@ MainWindow::MainWindow()
m_progressBarLabel = new QLabel(statusBar());
m_progressBarLabel->setVisible(false);
statusBar()->addPermanentWidget(m_progressBarLabel);

m_progressBar = new QProgressBar(statusBar());
m_progressBar->setVisible(false);
m_progressBar->setTextVisible(false);
m_progressBar->setMaximumWidth(100);
m_progressBar->setFixedHeight(15);
m_progressBar->setMaximum(100);
statusBar()->addPermanentWidget(m_progressBar);

m_clearClipboardButton = new QToolButton(statusBar());
m_clearClipboardButton->setIcon(icons()->icon("sweep"));
m_clearClipboardButton->setToolTip(tr("Clear the clipboard immediately"));
m_clearClipboardButton->setObjectName("clearClipboardButton");
m_clearClipboardButton->setVisible(false);
m_clearClipboardButton->setStyleSheet("QToolButton { border: none; background-color: transparent; }");
statusBar()->addPermanentWidget(m_clearClipboardButton);

connect(clipboard(), &Clipboard::updateCountdown, this, &MainWindow::updateProgressBar);
connect(m_clearClipboardButton.data(), &QToolButton::clicked, this, &MainWindow::clearClipboard);
m_actionMultiplexer.connect(SIGNAL(updateSyncProgress(int, QString)), this, SLOT(updateProgressBar(int, QString)));
m_actionMultiplexer.connect(SIGNAL(databaseSyncInProgress()), this, SLOT(disableMenuAndToolbar()));
m_actionMultiplexer.connect(SIGNAL(databaseSyncCompleted(QString)), this, SLOT(enableMenuAndToolbar()));
Expand Down Expand Up @@ -1535,6 +1546,11 @@ void MainWindow::clearSSHAgent()
#endif
}

void MainWindow::clearClipboard()
{
clipboard()->clearCopiedText();
}

void MainWindow::saveWindowInformation()
{
if (isVisible()) {
Expand Down Expand Up @@ -1633,11 +1649,17 @@ void MainWindow::updateProgressBar(int percentage, QString message)
if (percentage < 0) {
m_progressBar->setVisible(false);
m_progressBarLabel->setVisible(false);
m_clearClipboardButton->setVisible(false);
} else {
m_progressBar->setValue(percentage);
m_progressBar->setVisible(true);
m_progressBarLabel->setText(message);
m_progressBarLabel->setVisible(true);

Clipboard* cb = qobject_cast<Clipboard*>(sender());
if (cb) {
m_clearClipboardButton->setVisible(true);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <QProgressBar>
#include <QSystemTrayIcon>
#include <QTimer>
#include <QToolButton>

#include "core/SignalMultiplexer.h"
#include "gui/DatabaseWidget.h"
Expand Down Expand Up @@ -155,6 +156,7 @@ private slots:
void enableMenuAndToolbar();
void disableMenuAndToolbar();
void clearSSHAgent();
void clearClipboard();

private:
static const QString BaseWindowTitle;
Expand Down Expand Up @@ -190,6 +192,7 @@ private slots:
QPointer<QProgressBar> m_progressBar;
QPointer<QLabel> m_progressBarLabel;
QPointer<QLabel> m_statusBarLabel;
QPointer<QToolButton> m_clearClipboardButton;

Q_DISABLE_COPY(MainWindow)

Expand Down
20 changes: 20 additions & 0 deletions tests/gui/TestGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,26 @@ void TestGui::addCannedEntries()
QTest::mouseClick(editEntryWidgetButtonBox->button(QDialogButtonBox::Ok), Qt::LeftButton);
}

void TestGui::testClearClipboard()
{
addCannedEntries();

EntryView* entryView = m_dbWidget->findChild<EntryView*>("entryView");
QVERIFY(entryView->isVisible());

QClipboard* clipboard = QApplication::clipboard();

clickIndex(entryView->model()->index(1, 1), entryView, Qt::LeftButton);
QTRY_VERIFY(entryView->hasFocus());
QTest::keyClick(entryView, Qt::Key_C, Qt::ControlModifier);
QTRY_COMPARE(clipboard->text(), entryView->currentEntry()->password());

QToolButton* clearClipboardButton = m_mainWindow->findChild<QToolButton*>("clearClipboardButton");
QTRY_VERIFY(clearClipboardButton->isVisible());
clearClipboardButton->click();
QCOMPARE(clipboard->text(), QString());
}

void TestGui::checkDatabase(const QString& filePath, const QString& expectedDbName)
{
auto key = QSharedPointer<CompositeKey>::create();
Expand Down
1 change: 1 addition & 0 deletions tests/gui/TestGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private slots:
void testTrayRestoreHide();
void testShortcutConfig();
void testMenuActionStates();
void testClearClipboard();

private:
void addCannedEntries();
Expand Down
Loading