2 Copyright 2013-2015 Mats Sjöberg
4 This file is part of the Pumpa programme.
6 Pumpa is free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Pumpa is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Pumpa. If not, see <http://www.gnu.org/licenses/>.
20 #include <QApplication>
22 #include <QStyleFactory>
27 #include "pumpa_defines.h"
28 #include "pumpasettings.h"
30 #include <QTranslator>
33 //------------------------------------------------------------------------------
35 int testMarkup(QString str
) {
37 // str = "Hello *world*, [Some Url](http://www.foo.bar/baz). Some\n"
38 // "> block quoted text\n\n"
39 // str = "markdowned [url](http://saz.im)\n\n"
40 // "url on line http://saz.im and http://foo.bar\n"
41 // "http://saz.im\n\n"
42 // "with underlines: http://saz.im/foo_bar_baz.html ...\n"
43 // "<b>bold</b> and <i>broken html\n";
44 str
= "![piktur](https://cloud.openmailbox.org/index.php/apps/files_sharing/ajax/publicpreview.php?x=1440&y=801&a=true&file=/bicinueva.JPG&t=4b267cd7510c0317681088a4b9a87588&scalingup=0)";
46 addTextMarkup(str
, true);
50 //------------------------------------------------------------------------------
52 int main(int argc
, char** argv
) {
53 QApplication
app(argc
, argv
);
55 app
.setApplicationName(CLIENT_FANCY_NAME
);
56 app
.setApplicationVersion(CLIENT_VERSION
);
58 QString locale
= QLocale::system().name();
60 app
.setStyle(QStyleFactory::create("Fusion"));
64 QStringList args
= app
.arguments();
65 if (args
.count() > 1) {
67 if (arg
== "testmarkup")
68 return testMarkup(argc
> 2 ? args
[2] : "");
69 else if (arg
== "testfeedint") {
70 qDebug() << PumpaSettingsDialog::feedIntToComboIndex(args
[2].toInt());
73 else if (arg
== "autotestfeedint") {
74 int (*f
)(int) = PumpaSettingsDialog::feedIntToComboIndex
;
88 Q_ASSERT(f(255) == 0);
91 else if (arg
== "autotestcomboindex") {
92 int (*f
)(int) = PumpaSettingsDialog::comboIndexToFeedInt
;
99 Q_ASSERT(f(255) == 0);
102 else if (arg
== "-l" && argc
== 3) {
104 } else if (arg
== "-c" && argc
== 3) {
105 settingsFile
= args
[2];
108 qDebug() << "Usage: ./pumpa [-c alternative.conf] [-l locale]";
113 PumpaSettings
* settings
=
114 PumpaSettings::getSettings(true, settingsFile
, &app
);
115 QString sLocale
= settings
->locale();
116 if (!sLocale
.isEmpty())
119 qDebug() << "Using locale" << locale
;
121 QTranslator qtTranslator
;
122 qtTranslator
.load("qt_" + locale
,
123 QLibraryInfo::location(QLibraryInfo::TranslationsPath
));
124 app
.installTranslator(&qtTranslator
);
126 QTranslator translator
;
127 bool ok
= translator
.load(QString("pumpa_%1").arg(locale
),
129 app
.installTranslator(&translator
);
132 qDebug() << "Successfully loaded translation";
134 PumpApp
papp(settings
, locale
);