Skip to content

Commit

Permalink
Save unsaved data when application gets unfocused
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Holecek <[email protected]>
  • Loading branch information
hluk committed May 9, 2020
1 parent 4b14bff commit 01d0eff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/clipboardserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include <QAction>
#include <QApplication>
#include <QApplicationStateChangeEvent>
#include <QKeyEvent>
#include <QMenu>
#include <QMessageBox>
Expand Down Expand Up @@ -578,6 +579,13 @@ bool ClipboardServer::eventFilter(QObject *object, QEvent *ev)
QTextEdit *editor = qobject_cast<QTextEdit*>(object);
if (editor)
setTabWidth(editor, m_textTabSize);
} else if ( type == QEvent::ApplicationStateChange ) {
const auto stateChangeEvent = static_cast<QApplicationStateChangeEvent*>(ev);
const auto state = stateChangeEvent->applicationState();
if (state != Qt::ApplicationActive) {
COPYQ_LOG( QString("Saving items on application state change (%1)").arg(state) );
m_wnd->saveTabs();
}
}

return false;
Expand Down

0 comments on commit 01d0eff

Please sign in to comment.