Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1104157
  • 博文数量: 121
  • 博客积分: 8910
  • 博客等级: 上将
  • 技术积分: 2915
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-18 09:36
文章分类

全部博文(121)

文章存档

2011年(3)

2010年(100)

2008年(18)

分类: BSD

2008-04-26 17:08:50

一个简单的KDE4程序


main.cpp 文件


#include "simple.h"
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <KDE/KLocale>

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

static const char version[] = "0.1";

int main(int argc, char **argv)
{
    KAboutData about("simple", 0, ki18n("simple"), version, ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2007 dbhrscom"), KLocalizedString(), 0, "dbhrscom@gmail.com");
    about.addAuthor( ki18n("dbhrscom"), KLocalizedString(), "dbhrscom@gmail.com" );
    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("+[URL]", ki18n( "Document to open" ));
    KCmdLineArgs::addCmdLineOptions(options);
    KApplication app;

    simple *widget = new simple;

    // see if we are starting with session management

    if (app.isSessionRestored())
    {
        RESTORE(simple);
    }
    else
    {
        // no session.. just start up normally

        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
        if (args->count() == 0)
        {
            //simple *widget = new simple;

            widget->show();
        }
        else
        {
            int i = 0;
            for (; i < args->count(); i++)
            {
                //simple *widget = new simple;

                widget->show();
            }
        }
        args->clear();
    }

    return app.exec();
}

阅读(2994) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~