mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 23:39:45 -05:00
Correct window transitions from browser plugin
* Eliminated multiple state variables * Fix #1643, window is brought to front
This commit is contained in:
parent
ca39f6e159
commit
d3a424cc74
@ -54,8 +54,7 @@ BrowserService::BrowserService(DatabaseTabWidget* parent)
|
||||
: m_dbTabWidget(parent)
|
||||
, m_dialogActive(false)
|
||||
, m_bringToFrontRequested(false)
|
||||
, m_wasMinimized(false)
|
||||
, m_wasHidden(false)
|
||||
, m_prevWindowState(WindowState::Normal)
|
||||
, m_keepassBrowserUUID(Tools::hexToUuid("de887cc3036343b8974b5911b8816224"))
|
||||
{
|
||||
// Don't connect the signals when used from DatabaseSettingsWidgetBrowser (parent is nullptr)
|
||||
@ -1009,29 +1008,42 @@ bool BrowserService::checkLegacySettings()
|
||||
|
||||
void BrowserService::hideWindow() const
|
||||
{
|
||||
if (m_wasMinimized) {
|
||||
if (m_prevWindowState == WindowState::Minimized) {
|
||||
getMainWindow()->showMinimized();
|
||||
} else {
|
||||
#ifdef Q_OS_MACOS
|
||||
if (m_wasHidden) {
|
||||
if (m_prevWindowState == WindowState::Hidden) {
|
||||
macUtils()->hideOwnWindow();
|
||||
} else {
|
||||
macUtils()->raiseLastActiveWindow();
|
||||
}
|
||||
#else
|
||||
getMainWindow()->lower();
|
||||
if (m_prevWindowState == WindowState::Hidden) {
|
||||
getMainWindow()->hideWindow();
|
||||
} else {
|
||||
getMainWindow()->lower();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserService::raiseWindow(const bool force)
|
||||
{
|
||||
m_wasMinimized = getMainWindow()->isMinimized();
|
||||
m_prevWindowState = WindowState::Normal;
|
||||
if (getMainWindow()->isMinimized()) {
|
||||
m_prevWindowState = WindowState::Minimized;
|
||||
}
|
||||
#ifdef Q_OS_MACOS
|
||||
m_wasHidden = macUtils()->isHidden();
|
||||
if (macUtils()->isHidden()) {
|
||||
m_prevWindowState = WindowState::Hidden;
|
||||
}
|
||||
macUtils()->raiseOwnWindow();
|
||||
Tools::wait(500);
|
||||
#else
|
||||
if (getMainWindow()->isHidden()) {
|
||||
m_prevWindowState = WindowState::Hidden;
|
||||
}
|
||||
|
||||
if (force) {
|
||||
getMainWindow()->bringToFront();
|
||||
}
|
||||
|
@ -97,6 +97,13 @@ private:
|
||||
Allowed
|
||||
};
|
||||
|
||||
enum WindowState
|
||||
{
|
||||
Normal,
|
||||
Minimized,
|
||||
Hidden
|
||||
};
|
||||
|
||||
private:
|
||||
QList<Entry*> sortEntries(QList<Entry*>& pwEntries, const QString& host, const QString& submitUrl);
|
||||
bool confirmEntries(QList<Entry*>& pwEntriesToConfirm,
|
||||
@ -125,8 +132,7 @@ private:
|
||||
DatabaseTabWidget* const m_dbTabWidget;
|
||||
bool m_dialogActive;
|
||||
bool m_bringToFrontRequested;
|
||||
bool m_wasMinimized;
|
||||
bool m_wasHidden;
|
||||
WindowState m_prevWindowState;
|
||||
QUuid m_keepassBrowserUUID;
|
||||
};
|
||||
|
||||
|
@ -1162,7 +1162,7 @@ void MainWindow::hideYubiKeyPopup()
|
||||
void MainWindow::bringToFront()
|
||||
{
|
||||
ensurePolished();
|
||||
setWindowState(windowState() & ~Qt::WindowMinimized);
|
||||
setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
|
Loading…
Reference in New Issue
Block a user