Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
Konversation
Commits
89e43dba
Commit
89e43dba
authored
Jan 01, 2022
by
Friedrich W. H. Kossebau
Browse files
Hide window to systray using SNI, for consistent storing of any window info
parent
162e99df
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/application.cpp
View file @
89e43dba
...
...
@@ -14,6 +14,7 @@
#include "scriptlauncher.h"
#include "transfermanager.h"
#include "viewcontainer.h"
#include "trayicon.h"
#include "urlcatcher.h"
#include "highlight.h"
#include "sound.h"
...
...
@@ -208,7 +209,7 @@ QT_WARNING_POP
if
(
restoreMode
==
WindowRestore
)
mainWindow
->
restore
();
else
if
(
Preferences
::
self
()
->
showTrayIcon
()
&&
Preferences
::
self
()
->
hideToTrayOnStartup
())
mainWindow
->
hide
();
mainWindow
->
systemTrayIcon
()
->
hideWindow
();
else
mainWindow
->
show
();
...
...
src/mainwindow.cpp
View file @
89e43dba
...
...
@@ -621,7 +621,7 @@ void MainWindow::activateAndRaiseWindow()
if
(
isMinimized
())
KWindowSystem
::
unminimizeWindow
(
winId
());
else
if
(
Preferences
::
self
()
->
showTrayIcon
()
&&
!
isVisible
())
m_trayIcon
->
restore
();
m_trayIcon
->
restore
Window
();
KWindowSystem
::
setOnDesktop
(
winId
(),
KWindowSystem
::
currentDesktop
());
KWindowSystem
::
activateWindow
(
winId
());
...
...
@@ -658,7 +658,7 @@ bool MainWindow::queryClose()
KStandardGuiItem
::
cancel
(),
QStringLiteral
(
"HideOnCloseInfo"
))
==
KMessageBox
::
Continue
;
if
(
doit
)
hide
();
m_trayIcon
->
hideWindow
();
return
false
;
}
...
...
@@ -680,6 +680,8 @@ bool MainWindow::restore()
KConfigGroup
config
(
KConfigGui
::
sessionConfig
(),
QStringLiteral
(
"1"
));
const
bool
show
=
!
config
.
readEntry
(
"docked"
,
false
);
// TODO: also save & restore any TrayIcon state, needs API in KStatusNotifierItem
return
KXmlGuiWindow
::
restore
(
1
,
show
);
}
...
...
@@ -940,7 +942,7 @@ void MainWindow::toggleVisibility()
if
(
isActiveWindow
())
{
if
(
Preferences
::
self
()
->
showTrayIcon
())
hide
();
m_trayIcon
->
hideWindow
();
else
KWindowSystem
::
minimizeWindow
(
winId
());
}
...
...
src/viewer/trayicon.cpp
View file @
89e43dba
...
...
@@ -27,8 +27,30 @@ namespace Konversation
{
}
void
TrayIcon
::
restore
()
void
TrayIcon
::
hideWindow
()
{
QWidget
*
window
=
associatedWidget
();
if
(
window
->
isHidden
())
return
;
// hiding via the KStatusNotifierItem also stores any window system info, like "Show on all desktops"
// TODO: KStatusNotifierItem only hides if not minimized, needs new API in KStatusNotifierItem
// unminimizing instead as work-around needs to wait until the state is reached, not simple to do
// For now just doing a plain hide and losing any such info, as after all
// hiding a minimized window might not be done by many users
if
(
window
->
isMinimized
())
{
window
->
hide
();
return
;
}
// activating when the window is visible hides it
activate
(
QPoint
());
}
void
TrayIcon
::
restoreWindow
()
{
if
(
associatedWidget
()
->
isVisible
())
return
;
activate
(
QPoint
());
}
...
...
src/viewer/trayicon.h
View file @
89e43dba
...
...
@@ -24,7 +24,8 @@ namespace Konversation
bool
notificationEnabled
()
{
return
m_notificationEnabled
;
}
void
restore
();
void
restoreWindow
();
void
hideWindow
();
public
Q_SLOTS
:
void
startNotification
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment