Skip to content
Snippets Groups Projects
main.cpp 1.43 KiB
Newer Older
pospelov's avatar
pospelov committed
#include "mainwindow.h"
#include "SplashScreen.h"
Mohammad Mahadi Hasan's avatar
Mohammad Mahadi Hasan committed

pospelov's avatar
pospelov committed
#include <QApplication>
Mohammad Mahadi Hasan's avatar
Mohammad Mahadi Hasan committed
#include <QDebug>
#include <QTime>
pospelov's avatar
pospelov committed

void messageHandler(QtMsgType type, const QMessageLogContext &, const QString &msg)
{
     Q_UNUSED(type);
     Q_UNUSED(msg);
}

pospelov's avatar
pospelov committed
int main(int argc, char *argv[])
{
Mohammad Mahadi Hasan's avatar
Mohammad Mahadi Hasan committed

pospelov's avatar
pospelov committed
    QApplication a(argc, argv);
Mohammad Mahadi Hasan's avatar
Mohammad Mahadi Hasan committed

    if(!a.arguments().contains(QLatin1String("--with-debug"))) {
        qInstallMessageHandler(messageHandler);
    }

    if(a.arguments().contains(QLatin1String("--help")) || a.arguments().contains(QLatin1String("-h"))) {
        std::cout << "Available options:" << std::endl;
        std::cout << "--help          print available options" << std::endl;
        std::cout << "--with-debug    print debug information" << std::endl;
        std::cout << "--no-splash     do not use splash screen" << std::endl;
        return 0;
    }
    SplashScreen *splash(0);
    if(!a.arguments().contains(QLatin1String("--no-splash"))) {
        splash = new SplashScreen();
        splash->show();

        int time(1500);
        QTime dieTime = QTime::currentTime().addMSecs(time);
        QTime timer;
        timer.start();
        while( QTime::currentTime() < dieTime )
        {
            splash->setProgress(timer.elapsed()/(time/100));
            QCoreApplication::processEvents( QEventLoop::AllEvents, 100 );
        }
pospelov's avatar
pospelov committed
    w.show();
Mohammad Mahadi Hasan's avatar
Mohammad Mahadi Hasan committed

    if(splash)
        splash->finish(&w);
    return a.exec();
pospelov's avatar
pospelov committed
}