You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB

#include <stdlib.h> // EXIT_SUCCESS
#include <iostream> // cout
#include <QtGui>
#include <QRegExp>
#include <QTranslator>
14 years ago
#include "mainwindow.h"
#include "systemtray.h"
#include "argumentparser.h"
14 years ago
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(qtmindmap);
14 years ago
QApplication a(argc, argv);
// translation
QString locale = QLocale::system().name();
QTranslator translator;
14 years ago
if (locale != "C" && !translator.load(QString("qtmindmap_") + locale))
{
std::cerr << "No translation file for locale: "
<< locale.toStdString()
<< std::endl;
}
else
{
a.installTranslator(&translator);
}
// parse args
ArgumentParser argParser;
bool success;
if (!argParser.parseCmdLineArgs(success))
{
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}
// system tray?
MainWindow w;
SystemTray systemtray(&w);
if (argParser.isSystemTray() or argParser.isShowMinimized())
{
if (!QSystemTrayIcon::isSystemTrayAvailable())
{
QMessageBox::critical(0,
QObject::tr("QtMindMap Error"),
QObject::tr("I couldn't detect any system tray on this system."));
return EXIT_FAILURE;
}
QApplication::setQuitOnLastWindowClosed(false);
systemtray.setup();
systemtray.show();
}
14 years ago
14 years ago
if (!argParser.filePath().isEmpty())
w.setFileName(argParser.filePath());
if (!argParser.isShowMinimized()) w.show();
14 years ago
return a.exec();
}