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.

!nkubus

Beginner

  • "!nkubus" started this thread

Posts: 17

Location: Montreal

Occupation: Internet Solution Manager @ Bell

  • Send private message

1

Thursday, June 16th 2005, 2:15am

Autoclose app

i'm fairly new to kde Developpement, and i have made a small systray applet that display a passive popup, but i want my app to close after it has been executed but i don't know how.

i have 2 behavior

1. the app close before the popup is shown
2. the app stay in the systray after the popup.

here is my main.cpp:

i have tried to to app.ecex(); then return 0; after but it don't work

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "kmedianotify.h"
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>

static const char description[] =
    I18N_NOOP("A KDE KPart Application");

static const char version[] = "0.1";

static KCmdLineOptions options[] =
{
//    { "+[URL]", I18N_NOOP( "Document to open" ), 0 },
 {"header <string>",I18N_NOOP("Title of the notification"),""},
    {"desc <string>",I18N_NOOP("Description of the notification"),""},
    {"img <string>",I18N_NOOP("Icon to be shown in the popup"),"/usr/share/icons/crystalsvg/22x22/apps/hwinfo.png"},
    KCmdLineLastOption
};

int main(int argc, char **argv)
{
    KAboutData about("kmedianotify", I18N_NOOP("kMediaNotify"), version, description,
       KAboutData::License_GPL, "(C) 2005 Francis Bélanger", 0, 0, "francis.belanger@gmail.com");
    about.addAuthor( "Francis Bélanger", 0, "francis.belanger@gmail.com" );
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions( options );
    KApplication app;
    kMediaNotify *mainWin = 0;

    if (app.isRestored())
    {
        RESTORE(kMediaNotify);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

        /// @todo do something with the command line args here
  QString sTitle = args->getOption("header");
  QString sDesc = args->getOption("desc");
  QString sIcon = args->getOption("img");

        mainWin = new kMediaNotify(sTitle,sDesc,sIcon);
        app.setMainWidget( mainWin );
        //mainWin->show();
  mainWin->notify();

        args->clear();
    }

    // mainWin has WDestructiveClose flag by default, so it will delete itself.
    return app.exec();
}


the mainWin->show() is commented be cause my app start minimize in the systray.


any help or advise would be appreciated :)

thank you in advance

p.s. sorry for my lame english.

This post has been edited 1 times, last edit by "!nkubus" (Jun 16th 2005, 2:17am)


anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

2

Thursday, June 16th 2005, 2:44pm

You can use a QTimer if you want to close/quit after a certain timeout

Cheers,
_
Qt/KDE Developer
Debian User

!nkubus

Beginner

  • "!nkubus" started this thread

Posts: 17

Location: Montreal

Occupation: Internet Solution Manager @ Bell

  • Send private message

3

Thursday, June 16th 2005, 4:13pm

ok ill look into that :)

thank you again, i'm totally new to kde developement and this is a really good place to get help :)

!nkubus

Beginner

  • "!nkubus" started this thread

Posts: 17

Location: Montreal

Occupation: Internet Solution Manager @ Bell

  • Send private message

4

Tuesday, June 21st 2005, 1:05pm

It worked

Thank you very much