KSystemTray: The saga continues...

David Faure david at mandrakesoft.com
Sat Apr 13 22:34:30 BST 2002


On Saturday 13 April 2002 17:33, Martijn Klingens wrote:
> ... and we need help :-)
> 
> I talked with Simon about the KSystemTray problem on IRC and we're not sure 
> how to fix the problem.
> 
> In case you haven't read the previous thread, the problem is basically that 
> closing the main window of a systray app shouldn't quit the entire 
> application, but instead should make it live on in the tray. This is what the 
> style guide sais, and it is what the user would expect as well.
> 
> That can be solved by making the closeEvent() of the window call hide() 
> instead of close(). And there KSystemTray kicks in: the quit action from the 
> tray context menu just attempts to close all windows, assuming that would 
> automatically quit the app if no background processes like KIO jobs need to 
> be done.
> 
> Once the closeEvent does a hide() that no longer works. If the tray calls 
> kapp->quit directly the background KIO case would stop to work. Whatever we 
> could think of, either of those cases will be broken.

It sounds to me like your problem is simply differenciating between
* closeEvent called because the user closed the window (X button, File/Close, File/Quit)
* closeEvent called because the user asked to 'Quit' from the systray icon, which called
close() on all windows.

In the first case you want to hide(), in the second case you want to do the real close+delete+kapp->deref()

So, how to distinguish between the two? I thought about reimplementing virtual bool close(),
but that only distinguishes the X button case from all the others AFAICS - not good.
Therefore the only solution I see is an "ugly"  KMainWindow::setClosedBySystemTray() which
sets a bool internally, which tells the closeEvent to really close (instead of
"hide" when a systray exists). Then the systray code can call setClosedBySystemTray()
before calling close(), on the mainwindow, when 'Quit' is selected.

> <tronical> yes we need to ask david about this. his genious will help, I'm optimistic :)
After such compliment, I can't ignore such a mail ;)

-- 
David FAURE, david at mandrakesoft.com, faure at kde.org
http://people.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today





More information about the kde-core-devel mailing list