From c239abeb2e72d023c61af41728f2568596eb518e Mon Sep 17 00:00:00 2001 From: Agoston Szepessy Date: Fri, 9 Jan 2026 00:58:29 -0800 Subject: [PATCH] Add button to clear clipboard Calls a slot that clears the clipboard. `Clipboard::clearCopiedText()` already has a signal to clear the keyboard and make the progress bar and label disappear. --- src/gui/MainWindow.cpp | 19 +++++++++++++++++++ src/gui/MainWindow.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index d51588ac5..6af03b3a2 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -679,6 +679,7 @@ 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); @@ -686,7 +687,14 @@ MainWindow::MainWindow() m_progressBar->setFixedHeight(15); m_progressBar->setMaximum(100); statusBar()->addPermanentWidget(m_progressBar); + + m_clearClipboardButton = new QPushButton(statusBar()); + m_clearClipboardButton->setText(tr("Clear Clipboard")); + m_clearClipboardButton->setVisible(false); + statusBar()->addPermanentWidget(m_clearClipboardButton); + connect(clipboard(), &Clipboard::updateCountdown, this, &MainWindow::updateProgressBar); + connect(m_clearClipboardButton.data(), &QPushButton::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())); @@ -1535,6 +1543,11 @@ void MainWindow::clearSSHAgent() #endif } +void MainWindow::clearClipboard() +{ + clipboard()->clearCopiedText(); +} + void MainWindow::saveWindowInformation() { if (isVisible()) { @@ -1633,11 +1646,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(sender()); + if(cb) { + m_clearClipboardButton->setVisible(true); + } } } diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 8effd06f4..d6b8ef56e 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -25,6 +25,7 @@ #include #include #include +#include #include "core/SignalMultiplexer.h" #include "gui/DatabaseWidget.h" @@ -155,6 +156,7 @@ private slots: void enableMenuAndToolbar(); void disableMenuAndToolbar(); void clearSSHAgent(); + void clearClipboard(); private: static const QString BaseWindowTitle; @@ -190,6 +192,7 @@ private: QPointer m_progressBar; QPointer m_progressBarLabel; QPointer m_statusBarLabel; + QPointer m_clearClipboardButton; Q_DISABLE_COPY(MainWindow)