• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

lokalize

  • sources
  • kde-4.14
  • kdesdk
  • lokalize
  • src
main.cpp
Go to the documentation of this file.
1 /* ****************************************************************************
2  This file is part of Lokalize
3 
4  Copyright (C) 2007-2012 by Nick Shaforostoff <shafff@ukr.net>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License or (at your option) version 3 or any later version
10  accepted by the membership of KDE e.V. (or its successor approved
11  by the membership of KDE e.V.), which shall act as a proxy
12  defined in Section 14 of version 3 of the license.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 **************************************************************************** */
23 
24 
25 #include "version.h"
26 #include "prefs_lokalize.h"
27 #include "prefs.h"
28 #include "project.h"
29 #include "jobs.h"
30 #include "projectmodel.h"
31 
32 #include "lokalizemainwindow.h"
33 #include "projecttab.h"
34 
35 #include "stemming.h"
36 
37 #include "catalogstring.h"
38 #include "pos.h"
39 #include <QMetaType>
40 #include <QString>
41 #include <QFileInfo>
42 
43 #include <kapplication.h>
44 #include <kaboutdata.h>
45 #include <kcmdlineargs.h>
46 #include <klocale.h>
47 
48 #include <threadweaver/ThreadWeaver.h>
49 
50 
51 
52 
53 
54 static const char version[] = LOKALIZE_VERSION;
55 static const char description[] =
56  I18N_NOOP("Computer-aided translation system.\nDo not translate what had already been translated.");
57 
58 int main(int argc, char **argv)
59 {
60  KAboutData about("lokalize", 0, ki18nc("@title", "Lokalize"), version, ki18n(description),
61  KAboutData::License_GPL, ki18nc("@info:credit", "(c) 2007-2013 Nick Shaforostoff\n(c) 1999-2006 The KBabel developers") /*, KLocalizedString(), 0, "shafff@ukr.net"*/);
62  about.addAuthor( ki18n("Nick Shaforostoff"), KLocalizedString(), "shaforostoff@kde.ru" );
63  about.addCredit (ki18n("Google Inc."), ki18n("sponsored development as part of Google Summer Of Code program"), QByteArray(), "http://google.com");
64  about.addCredit (ki18n("Translate-toolkit"), ki18n("provided excellent cross-format converting scripts"), QByteArray(), "http://translate.sourceforge.net");
65  about.addCredit (ki18n("Viesturs Zarins"), ki18n("project tree merging translation+templates"), "viesturs.zarins@mii.lu.lv", QByteArray());
66  about.addCredit (ki18n("Stephan Johach"), ki18n("bug fixing patches"), "hunsum@gmx.de");
67  about.addCredit (ki18n("Chusslove Illich"), ki18n("bug fixing patches"), "caslav.ilic@gmx.net");
68  about.addCredit (ki18n("Jure Repinc"), ki18n("testing and bug fixing"), "jlp@holodeck1.com");
69  about.addCredit (ki18n("Stefan Asserhall"), ki18n("patches"), "stefan.asserhall@comhem.se");
70  about.addCredit (ki18n("Papp Laszlo"), ki18n("bug fixing patches"), "djszapi@archlinux.us");
71  about.addCredit (ki18n("Albert Astals Cid"), ki18n("XLIFF improvements"), "aacid@kde.org");
72 
73  KCmdLineArgs::init(argc, argv, &about);
74 
75  KCmdLineOptions options;
76  //options.add("merge-source <URL>", ki18n( "Source for the merge mode" ));
77  options.add("noprojectscan", ki18n( "Do not scan files of the project."));
78  options.add("project <filename>", ki18n( "Load specified project."));
79  options.add("+[URL]", ki18n( "Document to open" ));
80  KCmdLineArgs::addCmdLineOptions(options);
81 
82  KApplication app;
83 
84  //qDebug() is important as it aviods compile 'optimization'.
85  qDebug()<<qRegisterMetaType<DocPosition>();
86  qDebug()<<qRegisterMetaType<DocPos>();
87  qDebug()<<qRegisterMetaType<InlineTag>();
88  qDebug()<<qRegisterMetaType<CatalogString>();
89  qRegisterMetaTypeStreamOperators<InlineTag>("InlineTag");
90  qRegisterMetaTypeStreamOperators<CatalogString>("CatalogString");
91  qAddPostRoutine(&cleanupSpellers);
92 
93  // see if we are starting with session management
94  if (app.isSessionRestored())
95  kRestoreMainWindows<LokalizeMainWindow>();
96  else
97  {
98  // no session.. just start up normally
99  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
100 
101  if (!args->getOption("project").isEmpty())
102  {
103  // load needs an absolute path
104  // FIXME: I do not know how to handle urls here
105  // bug 245546 regarding symlinks
106  QFileInfo projectFileInfo(args->getOption("project").toUtf8());
107  QString projectFilePath=projectFileInfo.canonicalFilePath();
108  if (projectFilePath.isEmpty())
109  projectFilePath=projectFileInfo.absoluteFilePath();
110  Project::instance()->load( projectFilePath );
111  }
112  LokalizeMainWindow* lmw=new LokalizeMainWindow;
113  SettingsController::instance()->setMainWindowPtr(lmw);
114  lmw->show();
115 
116  KUrl::List urls;
117  for (int j=0; j<args->count(); j++)
118  urls << args->url(j);
119  if (urls.size())
120  new DelayedFileOpener(urls, lmw);
121 
122  Project::instance()->model()->setCompleteScan(args->isSet("projectscan"));
123  args->clear();
124  }
125 
126  int code=app.exec();
127 
128  ThreadWeaver::Weaver::instance()->dequeue();
129  Project::instance()->model()->weaver()->dequeue();
130 
131  if (SettingsController::instance()->dirty) //for config changes done w/o config dialog
132  Settings::self()->writeConfig();
133 
134  if (Project::instance()->isLoaded())
135  Project::instance()->save();
136 
137  qWarning()<<"QCoreApplication::processEvents()...";
138  QCoreApplication::processEvents();
139  QCoreApplication::sendPostedEvents(0,0);
140 
141  qWarning()<<"Finishing Project jobs...";
142  //Project::instance()->model()->weaver()->finish();
143  // HACK due to deadlock with libstreamanalyzer.so.0 -> libxml2.so.2 -> etree.so -> libpython2.5.so.1.0 -> PyThread_acquire_lock
144  while (!Project::instance()->model()->weaver()->isIdle())
145  {
146  QCoreApplication::processEvents();
147  QCoreApplication::sendPostedEvents(0,0);
148  }
149 
150  qWarning()<<"Finishing TM jobs...";
151  ThreadWeaver::Weaver::instance()->finish();
152 
153  return code;
154 }
155 
156 
project.h
catalogstring.h
ProjectModel::setCompleteScan
void setCompleteScan(bool enable)
Definition: projectmodel.h:168
ProjectModel::weaver
ThreadWeaver::Weaver * weaver()
Definition: projectmodel.h:167
QByteArray
main
int main(int argc, char **argv)
Definition: main.cpp:58
pos.h
Project::instance
static Project * instance()
Definition: project.cpp:67
prefs.h
DelayedFileOpener
Definition: lokalizemainwindow.h:186
projecttab.h
Settings::self
static Settings * self()
Definition: prefs_lokalize.cpp:19
QCoreApplication::processEvents
void processEvents(QFlags< QEventLoop::ProcessEventsFlag > flags)
Project::save
void save()
Definition: project.cpp:256
Project::model
ProjectModel * model()
Definition: project.cpp:265
LOKALIZE_VERSION
#define LOKALIZE_VERSION
Definition: version.h:11
lokalizemainwindow.h
QString
QFileInfo
stemming.h
SettingsController::instance
static SettingsController * instance()
Definition: prefs.cpp:70
cleanupSpellers
void cleanupSpellers()
Definition: stemming.cpp:105
Project::load
void load(const QString &file)
Definition: project.cpp:115
version.h
LokalizeMainWindow
Lokalize MDI (tabbed) window.
Definition: lokalizemainwindow.h:60
jobs.h
projectmodel.h
prefs_lokalize.h
SettingsController::setMainWindowPtr
void setMainWindowPtr(QWidget *w)
Definition: prefs.h:46
QCoreApplication::sendPostedEvents
void sendPostedEvents()
description
static const char description[]
Definition: main.cpp:55
version
static const char version[]
Definition: main.cpp:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:07 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

lokalize

Skip menu "lokalize"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal