You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

jweinraub

Beginner

  • "jweinraub" started this thread

Posts: 6

Location: US

Occupation: IT

  • Send private message

1

Tuesday, April 26th 2005, 4:56pm

display KDE error when app is minimised to tray

Hi, I am designing code so that when the application is attempted to be launched multiple times, I want an error message coming up saying so. (qWarning is silly bc nobody sees that as program is loaded from icon on desktop).

but i get a run time warning on console is i am doing a lot of tihs in vi.

Source code

1
2
3
4
5
6
KUniqueApplication::addCmdLineOptions();
if ( !KUniqueApplication::start() )
{
   KMessageBox::information( 0, "Already running", "myApp is already running! Please check the taskbar.");
   std::exit(0);
}


When run, the second time, i get this:
QPaintDevice: Must construct a QApplication before a QPaintDevice

Is there a different class I can use to achieve this?

thnx

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Tuesday, April 26th 2005, 8:41pm

Not sure why you want to do this, the other instance will usually come to the foreground.
See documentation of KUniqueApplication::newInstance, default behaviour

Cheers,
_
Qt/KDE Developer
Debian User

jweinraub

Beginner

  • "jweinraub" started this thread

Posts: 6

Location: US

Occupation: IT

  • Send private message

3

Tuesday, April 26th 2005, 8:54pm

so in other words, the expected behaviour would be if user runs the programme again, the original instance would restore?

in my app, if i close the window with the X, it doesnt shut down but retain in tray area by the clock. there a user can right click and do more features if he needs to. if a user is silly and forgets that programme is still running it should restore the original instance and go from there, rather than make error msg. is this what you mean in your comment?

if so, ill read about it in the KDE manual and see what i can get to compile.

Regards.

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

4

Tuesday, April 26th 2005, 9:00pm

Hmm, yes, at least that is what the docs say.
Could be more difficult if the window was closed.

In this case you might have to subclass KUniqueApplication and overwrite newInstance so that it can open the window before calling the base implementation.

Cheers
_
Qt/KDE Developer
Debian User

jweinraub

Beginner

  • "jweinraub" started this thread

Posts: 6

Location: US

Occupation: IT

  • Send private message

5

Tuesday, April 26th 2005, 9:14pm

essentially i am just restoring the app, which is done if i click the tray icon with the mouse, so can i simulate i did that so it just calls the slot showNormal or something similar?

i am just trying to prevent multiple instances of the program from running. that is why i thought error msg could be gut or i can just simply use restore for users convienence.

regards

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

6

Wednesday, April 27th 2005, 3:15pm

Well, restoring the window is standard behaviour, I guess this is already implemented in KSystemTray.

Anyway, as you are not using it for a reason I don't know, I think you can just call show before calling the base implementation of newInstance

Cheers,
_
Qt/KDE Developer
Debian User