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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
/*
* qdacco: offline Dacco Catalan <-> English dictionary
* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011 Carles Pina i Estany <carles@pina.cat>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2 or any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <iostream>
#include <QApplication>
#include <QDialog>
#include <QLocale>
#include <QMessageBox>
#include "AuxiliarGUI.h"
#include "configure.h"
#include "loadconfig.h"
#include "main.h"
#include "oneinstance.h"
#include "trayicon.h"
//qdaccolib
#include <qdacco/auxiliar.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
if (app.argc()>1 && strcmp(app.argv()[1],"-d")==0) {
qDebug() << "Debug enabled";
Auxiliar::setDebug(1);
}
else {
Auxiliar::setDebug(0);
}
if (app.argc()>1 && strcmp(app.argv()[1],"-d")!=0) {
qDebug() << "qdacco use:";
qDebug() << "qdacco -d: to enable debug mode";
qDebug() << "Just qdacco to just use qdacco";
exit(1);
}
std::cout << qPrintable(QString("qdacco %1 Copyright (C) %2 Carles Pina i Estany").arg(AuxiliarGUI::getVersion()).arg(AuxiliarGUI::getCopyrightDate())) << std::endl;
std::cout << "This program comes with ABSOLUTELY NO WARRANTY" << std::endl;
std::cout << "This is free software, and you are welcome to redistribute it" << std::endl;
std::cout << "under certain conditions" << std::endl;
std::cout << "Program: GPL v3. Data: LGPL" << std::endl;
QSettings qs("dacco","qdacco");
int idioma = qs.value("/dacco/idioma_per_defecte",1).toInt();
QTranslator translator;
if (idioma==0) {
if (translator.load(":/qdacco_ca.qm")) {
app.installTranslator(&translator);
}
}
if (idioma==1) {
//default language, don't change anything
}
if (idioma==2) {
QLocale a;
QString locale=a.name();
if (locale.startsWith("ca")) {
qs.setValue("/dacco/idioma_per_defecte",1);
if (translator.load(":/qdacco_ca.qm")) {
app.installTranslator(&translator);
}
}
}
// Debug info
if (Auxiliar::isWindows()) {
Auxiliar::debug("isWindows: true");
}
else {
Auxiliar::debug("isWindows: false");
}
if (Auxiliar::isMac()) {
Auxiliar::debug("isMac: true");
}
else {
Auxiliar::debug("isMac: false");
}
// End of debug info
qs.sync();
LoadConfig loadconfig;
oneInstance myOneInstance;
int single = loadconfig.getSingleInstance();
if (single==1) {
bool otherinstance = myOneInstance.isAnotherInstance();
if (otherinstance==TRUE) {
myOneInstance.sendRestore();
qDebug() << "qdacco already running, restoring otherinstance";
exit(1);
}
TrayIcon *trayicon = new TrayIcon;
trayicon->SetOneInstance(&myOneInstance);
}
myOneInstance.registerInstance();
int ret = app.exec();
return ret;
}
|