~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to lokalize/src/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ****************************************************************************
 
2
  This file is part of KAider
 
3
 
 
4
  Copyright (C) 2007 by Nick Shaforostoff <shafff@ukr.net>
 
5
 
 
6
  This program is free software; you can redistribute it and/or modify
 
7
  it under the terms of the GNU General Public License as published by
 
8
  the Free Software Foundation; either version 2 of the License, or
 
9
  (at your option) any later version.
 
10
 
 
11
  This program is distributed in the hope that it will be useful,
 
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
  GNU General Public License for more details.
 
15
 
 
16
  You should have received a copy of the GNU General Public License
 
17
  along with this program; if not, write to the Free Software
 
18
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 
 
20
  In addition, as a special exception, the copyright holders give
 
21
  permission to link the code of this program with any edition of
 
22
  the Qt library by Trolltech AS, Norway (or with modified versions
 
23
  of Qt that use the same license as Qt), and distribute linked
 
24
  combinations including the two.  You must obey the GNU General
 
25
  Public License in all respects for all of the code used other than
 
26
  Qt. If you modify this file, you may extend this exception to
 
27
  your version of the file, but you are not obligated to do so.  If
 
28
  you do not wish to do so, delete this exception statement from
 
29
  your version.
 
30
 
 
31
**************************************************************************** */
 
32
 
 
33
 
 
34
#include "version.h"
 
35
#include "kaider.h"
 
36
 
 
37
#include "project.h"
 
38
#include "jobs.h"
 
39
 
 
40
#include <kapplication.h>
 
41
#include <kaboutdata.h>
 
42
#include <kcmdlineargs.h>
 
43
#include <klocale.h>
 
44
 
 
45
#include <threadweaver/ThreadWeaver.h>
 
46
 
 
47
static const char version[] = KAIDER_VERSION;
 
48
static const char description[] =
 
49
    I18N_NOOP("Computer-aided translation system.\nDon't translate what had already been translated!");
 
50
 
 
51
int main(int argc, char **argv)
 
52
{
 
53
    KAboutData about("lokalize", 0, ki18nc("@title", "Lokalize"), version, ki18n(description),
 
54
                     KAboutData::License_GPL, ki18nc("@info:credit", "(c) 2007-2008 Nick Shaforostoff\n(c) 1999-2006 The KBabel developers") /*, KLocalizedString(), 0, "shafff@ukr.net"*/);
 
55
    about.addAuthor( ki18n("Nick Shaforostoff"), KLocalizedString(), "shaforostoff@kde.ru" );
 
56
    about.addCredit (ki18n("Google Inc."), ki18n("sponsored development as part of Google Summer Of Code program"), QByteArray(), "http://google.com");
 
57
    about.addCredit (ki18n("Stephan Johach"), ki18n("bug fixing patches"), "hunsum@gmx.de");
 
58
    KCmdLineArgs::init(argc, argv, &about);
 
59
 
 
60
    KCmdLineOptions options;
 
61
    options.add("merge-source <URL>", ki18n( "Source for the merge mode" ));
 
62
    options.add("project <filename>", ki18n( "Project file. "
 
63
                                 "Opens specified project-file in Project Manager if no translation files specified" ));
 
64
    options.add("+[URL]", ki18n( "Document to open" ));
 
65
    KCmdLineArgs::addCmdLineOptions(options);
 
66
 
 
67
    KApplication app;
 
68
 
 
69
    // see if we are starting with session management
 
70
    if (app.isSessionRestored())
 
71
    {
 
72
        RESTORE(KAider);
 
73
    }
 
74
    else
 
75
    {
 
76
        // no session.. just start up normally
 
77
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
78
 
 
79
        if (!args->getOption("project").isEmpty())
 
80
        {
 
81
            QString path = args->getOption("project").toUtf8();
 
82
            // load needs an absolute path
 
83
            // FIXME: I do not know how to handle urls here
 
84
            QFileInfo info( path );
 
85
            Project::instance()->load( info.absoluteFilePath() );
 
86
        }
 
87
        if (args->count() == 0)
 
88
        {
 
89
            if(Project::instance()->isLoaded())
 
90
            {
 
91
                Project::instance()->openProjectWindow();
 
92
                //delete widget;
 
93
            }
 
94
            else
 
95
                (new KAider)->show();
 
96
        }
 
97
        else
 
98
        {
 
99
            KAider *widget = new KAider;
 
100
            widget->fileOpen(args->url(0));
 
101
            if (!args->getOption("merge-source").isEmpty())
 
102
                widget->mergeOpen(KCmdLineArgs::makeURL(args->getOption("merge-source").toUtf8()));
 
103
//             KUrl a(args->arg(0));
 
104
//             QMetaObject::invokeMethod(widget,
 
105
//                                       SLOT(fileOpen(KUrl)),
 
106
//                                       Qt::QueuedConnection,
 
107
//                                       Q_ARG(KUrl,a));
 
108
            widget->show();
 
109
        }
 
110
        args->clear();
 
111
    }
 
112
 
 
113
    int code=app.exec();
 
114
 
 
115
    if (Project::instance()->isLoaded())
 
116
    {
 
117
        ThreadWeaver::Weaver::instance()->dequeue();
 
118
 
 
119
        kWarning()<<"Finishing jobs...";
 
120
        Project::instance()->save();
 
121
/*        CloseDBJob* closeDBJob=new CloseDBJob(Project::instance()->id(),Project::instance());
 
122
//         connect(closeDBJob,SIGNAL(failed(ThreadWeaver::Job*)),Project::instance(),SLOT(deleteScanJob(ThreadWeaver::Job*)));
 
123
//         connect(closeDBJob,SIGNAL(done(ThreadWeaver::Job*)),Project::instance(),SLOT(deleteScanJob(ThreadWeaver::Job*)));
 
124
        ThreadWeaver::Weaver::instance()->enqueue(closeDBJob);*/
 
125
        ThreadWeaver::Weaver::instance()->finish();
 
126
    }
 
127
    return code;
 
128
}
 
129
 
 
130