diff --git a/src/CredentialsManagement.cpp b/src/CredentialsManagement.cpp index 69243b1f..6915f123 100755 --- a/src/CredentialsManagement.cpp +++ b/src/CredentialsManagement.cpp @@ -680,6 +680,14 @@ void CredentialsManagement::saveChanges() emit wantSaveMemMode(); } +void CredentialsManagement::onMainWindowActivated() +{ + if (wsClient->get_memMgmtMode() && wsClient->isMPBLE()) + { + onClipboardDataChanged(); + } +} + void CredentialsManagement::keyPressEvent(QKeyEvent *event) { QWidget::keyPressEvent(event); @@ -1995,6 +2003,17 @@ void CredentialsManagement::onClipboardDataChanged() QClipboard *clipboard = QGuiApplication::clipboard(); QImage clipImage = clipboard->image(); + static QImage lastImage; + if (clipImage == lastImage) + { + // Only process image from clipboard one time. + return; + } + else + { + lastImage = clipImage; + } + if (!clipImage.isNull() && !m_processingQRImage) { m_processingQRImage = true; diff --git a/src/CredentialsManagement.h b/src/CredentialsManagement.h index f17631ea..c6a4ad39 100755 --- a/src/CredentialsManagement.h +++ b/src/CredentialsManagement.h @@ -57,6 +57,7 @@ class CredentialsManagement : public QWidget public slots: bool confirmDiscardUneditedCredentialChanges(const QModelIndex &proxyIndex = {}); void saveChanges(); + void onMainWindowActivated(); protected: virtual void keyPressEvent(QKeyEvent *event) override; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 4d4c9e10..7fdd8496 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -250,6 +250,13 @@ MainWindow::MainWindow(WSClient *client, DbMasterController *mc, QWidget *parent } }); +#ifdef Q_OS_MAC + // For Mac clipboard changed event is not working when app is in background, + // so need to check the clipboard content when window is activated. + connect(this, &MainWindow::mainWindowActivated, + ui->widgetCredentials, &CredentialsManagement::onMainWindowActivated); +#endif + ui->pushButtonExportFile->setStyleSheet(CSS_BLUE_BUTTON); ui->pushButtonImportFile->setStyleSheet(CSS_BLUE_BUTTON); ui->pushButtonSettingsReset->setStyleSheet(CSS_BLUE_BUTTON); @@ -805,6 +812,13 @@ void MainWindow::changeEvent(QEvent *event) ui->retranslateUi(this); retranslateUi(); } + if (event->type() == QEvent::ActivationChange) + { + if (isActiveWindow()) + { + emit mainWindowActivated(); + } + } QMainWindow::changeEvent(event); } diff --git a/src/MainWindow.h b/src/MainWindow.h index 06be87dd..61a4e0e9 100755 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -87,6 +87,7 @@ class MainWindow : public QMainWindow void windowCloseRequested(); void iconChangeRequested(); void saveMMMChanges(); + void mainWindowActivated(); public slots: void wantImportDatabase();