Exemplo n.º 1
0
void *TUIMod::Task( void * )
{
    vector<string> list;
    bool first_ent = true;
    QImage ico_t;
    time_t st_time = time(NULL);
    vector<TMess::SRec> recs;

    //> Init locale setLocale
    QLocale::setDefault(QLocale(Mess->lang().c_str()));

    //> Qt application object init
    QApplication *QtApp = new QApplication(mod->qtArgC, (char**)&mod->qtArgV);
    QtApp->setApplicationName(PACKAGE_STRING);
    QtApp->setQuitOnLastWindowClosed(false);
    mod->run_st = true;

    //> Create I18N translator
    I18NTranslator translator;
    QtApp->installTranslator(&translator);

    //> Start splash create
    if(!ico_t.load(TUIS::icoGet(SYS->id()+"_splash",NULL,true).c_str())) ico_t.load(":/images/splash.png");
    QSplashScreen *splash = new QSplashScreen(QPixmap::fromImage(ico_t));
    splash->show();
    QFont wFnt = splash->font();
    wFnt.setPixelSize(10);
    splash->setFont(wFnt);

    while(!mod->startCom() && !mod->endRun())
    {
	SYS->archive().at().messGet(st_time, time(NULL), recs, "", TMess::Debug, BUF_ARCH_NM);
	QString mess;
	for(int i_m = recs.size()-1; i_m >= 0 && i_m > ((int)recs.size()-10); i_m--)
	    mess += QString("\n%1: %2").arg(recs[i_m].categ.c_str()).arg(recs[i_m].mess.c_str());
	recs.clear();
	splash->showMessage(mess,Qt::AlignBottom|Qt::AlignLeft);
	QtApp->processEvents();
	TSYS::sysSleep(0.5);
    }

    //> Start external modules
    WinControl *winCntr = new WinControl( );

    int op_wnd = 0;
    mod->owner().modList(list);
    for(unsigned i_l = 0; i_l < list.size(); i_l++)
	if(mod->owner().modAt(list[i_l]).at().modInfo("SubType") == "QT" &&
		mod->owner().modAt(list[i_l]).at().modFuncPresent("QMainWindow *openWindow();"))
	{
	    //>> Search module into start list
	    int i_off = 0;
	    string s_el;
	    while((s_el=TSYS::strSepParse(mod->start_mod,0,';',&i_off)).size())
		if(s_el == list[i_l])	break;
	    if(!s_el.empty() || !i_off)
		if(winCntr->callQTModule(list[i_l])) op_wnd++;
	}

    delete splash;

    //> Start call dialog
    if(QApplication::topLevelWidgets().isEmpty()) winCntr->startDialog( );

    QObject::connect(QtApp, SIGNAL(lastWindowClosed()), winCntr, SLOT(lastWinClose()));

    QtApp->exec();
    delete winCntr;

    //> Stop splash create
    if(!ico_t.load(TUIS::icoGet(SYS->id()+"_splash_exit",NULL,true).c_str())) ico_t.load(":/images/splash.png");
    splash = new QSplashScreen(QPixmap::fromImage(ico_t));
    splash->show();
    splash->setFont(wFnt);

    st_time = time(NULL);
    while(!mod->endRun())
    {
	SYS->archive().at().messGet( st_time, time(NULL), recs, "", TMess::Debug, BUF_ARCH_NM );
	QString mess;
	for(int i_m = recs.size()-1; i_m >= 0 && i_m > ((int)recs.size()-10); i_m--)
	    mess += QString("\n%1: %2").arg(recs[i_m].categ.c_str()).arg(recs[i_m].mess.c_str());
	recs.clear();
	splash->showMessage(mess,Qt::AlignBottom|Qt::AlignLeft);
	QtApp->processEvents();
	TSYS::sysSleep(0.5);
    }
    delete splash;

    //> Qt application object free
    delete QtApp;
    first_ent = false;

    mod->run_st = false;

    return NULL;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{

    QDir dir;
    QString path=dir.absolutePath();

    QDate data = QDate::currentDate();
    int DaysInMonths = data.daysInMonth();
    int ActualDay = data.day();

    int currentExitCode = 0;

    do
    {
            QApplication a(argc, argv);
            a.setStyle("fusion");

            QFont font("Calibri Light", 12, QFont::Light ,false);
            QFont font_main("Calibri Light", 10, QFont::Light ,false);
            QFont splash_font("Calibri Light", 24, QFont::Bold);

            LoginDialog *logindialog = new LoginDialog;
            MainWindow w;

            logindialog->setWindowFlags(((logindialog->windowFlags() | Qt::CustomizeWindowHint) & Qt::WindowCloseButtonHint & ~Qt::WindowContextHelpButtonHint) );

            /* Ekran startowy*/
            if(currentExitCode != MainWindow::EXIT_CODE_REBOOT)
            {
                QSplashScreen * splash = new QSplashScreen;
                splash->setPixmap(QPixmap(path+"/obrazy/splash.png"));
                splash->setFont(splash_font);
                splash->show();
                splash->showMessage(QObject::tr("Uruchamianie programu "),
                                Qt::AlignLeft | Qt::AlignTop, Qt::black);  //This line represents the alignment of text, color and position

                qApp->processEvents();
                QTimer::singleShot(2000,splash,SLOT(close()));
                QString Splash_string = "Uruchamianie programu";
                QString Splash_string_add = "Uruchamianie programu";

                for(int i=0;i<12;i++)
                {
                    QThread::msleep(150);
                    Splash_string_add = Splash_string_add + ".";

                    if(i==3 || i==7 || i==11) Splash_string_add = Splash_string;

                    splash->showMessage(Splash_string_add,
                                    Qt::AlignLeft | Qt::AlignTop, Qt::black);  //This line represents the alignment of text, color and position
                }
            }



            /* signal-slot - connect login and password from logindialog with MainWindow */
            QObject::connect(logindialog, SIGNAL(sendAccess(QString,QString)),
                             &w, SLOT(receiveAccess(QString,QString)));



            logindialog->setWindowIcon(QIcon(path+"/obrazy/log_icon.png"));
            logindialog->setWindowTitle("SERWIS - Logowanie");
            logindialog->setFont(font);
            if (logindialog->exec() != QDialog::Accepted) {
                a.quit();
                return 0;
            } else {
                delete logindialog;
                w.showMaximized();
                w.setWindowTitle("SERWIS");
                w.setWindowIcon(QIcon(path+"/obrazy/services_icon.png"));
                w.setFont(font_main);
                w.show();

                QFile file;
                QString file_name="AUTO_BACKUP.txt";
                file.setFileName(file_name);
                if(!file.exists() && (DaysInMonths-ActualDay)==1){

                    QMessageBox::warning(&w,"Informacja","****************** Do końca miesiąca został 1 dzień! *******************\n"
                                                         "Wykonany zostanie automatyczny zapis kopii zapasowej bazy danych. \n"
                                                         "*************************************************************************");
                    QTimer::singleShot(500,&w,SLOT(create_backup()));

                    qDebug() << "Doesn't exists: "<<file_name;
                    file.open(QIODevice::ReadWrite | QIODevice::Text);
                    QTextStream stream(&file);
                    file.close();

                }else if (file.exists() && (DaysInMonths-ActualDay)!=1){
                    qDebug() << file_name <<" removing ...";
                    file.remove();
                }else if (file.exists() && (DaysInMonths-ActualDay)==1)
                {
                    qDebug() << file_name <<" already created ...";
                }

            }
             currentExitCode = a.exec();
     } while( currentExitCode == MainWindow::EXIT_CODE_REBOOT );

    return currentExitCode;
}
Exemplo n.º 3
0
int gui_main(int argc, char **argv) {

	File_logger* initialization_log = new File_logger("sgems_status.log");
	initialization_log->subscribe(GsTLlog);

	QTscribe* qt_error_scribe = new QTscribe;
	qt_error_scribe->subscribe(GsTLcerr);

	GsTLlog << gstlIO::no_wait_end;
	//-----

	//---------------------
	// Initialize the libraries, manage the splash-screen, and set-up the
	// main application window

	QApplication app(argc, argv);
	QApplication::addLibraryPath(path_to_plugins());

	//QPixmap pixmap(path_to_splash_image());
  QPixmap pixmap(":/sgems-main/new_splash2-beta.bmp");

	QSplashScreen* splash = new QSplashScreen(pixmap);
  splash->show();

	splash->setFont(QFont("Times", 8, QFont::Bold));
	splash->showMessage("Initializing...");
	app.processEvents();

	Lib_initializer::init();

	splash->showMessage("Loading colormaps...");
	app.processEvents();
	Lib_initializer::load_colormaps();

	splash->showMessage("Loading geostat plugins...");
	app.processEvents();
	Lib_initializer::load_geostat_algos();
	Lib_initializer::load_filters_plugins();

	splash->showMessage("Loading action plugins...");
	app.processEvents();
	Lib_initializer::load_action_plugins();
	Lib_initializer::load_python_scripts();
	Lib_initializer::load_python_group_scripts();

	SoDB::init();
	//  QSP_application* appli = new QSP_application( 0 );
	//  SoQt::init( appli );
	//SoClipPlaneManip::initClass();
	//  GsTL_SoClipPlaneManip::initClass();
	GsTL_SoNode::initClass();
	SoVolumeRendering::init();

	QSP_application* appli = new QSP_application(0);
	SoQt::init(appli);

	//deprecated
	//app.setMainWidget( appli );

	Status_bar_scribe* statusbar_scribe = new Status_bar_scribe(appli->statusBar());
	statusbar_scribe->subscribe(GsTLcerr);
	statusbar_scribe->subscribe(GsTLcout);

	appli->init();  
	appli->setWindowTitle("SGeMS beta");

	// restore preferences
	QSettings settings;
	settings.setPath(QSettings::NativeFormat, QSettings::UserScope, "scrf.stanford.edu");
	int height = settings.value("/geometry/height", 480).toInt();
	int width = settings.value("/geometry/width", 640).toInt();
	appli->resize(QSize(width, height));

	bool show_algo_panel = settings.value("/panels/algo", true).toBool();
	bool show_cli_panel = settings.value("/panels/cli", false).toBool();

	appli->setWindowIcon(QIcon(":/sgems-main/new_icon6_32x32.bmp"));
  //QIcon windowIcon("d:/code-dev/GsTLAppli-qt4/GsTLAppli/main/new_icon6_32x32.bmp");
  //appli->setWindowIcon(windowIcon);
  
	appli->show();
  appli->show_algo_panel(show_algo_panel);
	appli->show_commands_panel(show_cli_panel);

	//------------------
	SmartPtr<Named_interface> ni = Root::instance()->interface(projects_manager + "/" + "project");
	GsTL_project* project = dynamic_cast<GsTL_project*> (ni.raw_ptr());
	appli_assert( project );
	Python_project_wrapper::set_project(project);
	//------------------


	splash->finish(appli);
	delete splash;

	//------------------------
	// Everything is now ready. We set up one more logging device, and it's done

	GsTLlog << gstlIO::wait_end;

	initialization_log->unsubscribe(GsTLlog);

	File_logger* main_log = new File_logger("sgems_history.log");
	main_log->subscribe(GsTLlog);
	main_log->append_newline(true);

	/*
	 //-------------
	 QSP_application appli( 0 );
	 SoQt::init( &appli );

	 app.setMainWidget( &appli );

	 Status_bar_scribe* statusbar_scribe = new Status_bar_scribe( appli.statusBar() );
	 statusbar_scribe->subscribe( GsTLcerr );

	 appli.init();
	 appli.show();
	 appli.setCaption( "SGeMS" );
	 //--------------
	 */
	SoQt::mainLoop();

	//delete appli;
	Lib_initializer::release();

	Root::instance()->list_all(std::cout);

	return 0;
}
Exemplo n.º 4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    dal_main = new DAL_main(this);
    QCoreApplication::setApplicationName("pocskaf2");
    QCoreApplication::setOrganizationName("team2");
    QSettings prevSettings("team2", "pocskaf2");
    if (prevSettings.value("databaseName").isNull() || prevSettings.value("port").isNull() || prevSettings.value("username").isNull() || prevSettings.value("password").isNull() || prevSettings.value("host").isNull())
    {
        accessdb *access = new accessdb(this);
        access->marker = 1;
        access->exec();
    }
    else
    {
        if( dal_main->setConnection(prevSettings.value("databaseName").toString(),prevSettings.value("port").toInt(),prevSettings.value("host").toString(),prevSettings.value("username").toString(),prevSettings.value("password").toString()))
        {
            QMessageBox::information(this, tr("Соединение успешно"), tr("Соединение с базой данных установлено"));
        }
        else
        {
            QMessageBox::critical(this, tr("Ошибка подключения"), tr("Соединение с базой данных невозможно"));
            accessdb *access = new accessdb(this);
            access->marker = 1;
            access->exec();
        }
    }
    Authorization *w=new Authorization(this) ;
    w->setWindowFlags(Qt::Dialog | Qt::Desktop);
    w->exec();

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(showTime()));
    timer->start(1000);
    showTime();

    QPixmap pixmap(":/img/img/pocs2.png");
    QSplashScreen *splash = new QSplashScreen(pixmap);
    QFont splashFont;
    splashFont.setPixelSize(17);
    splash->setFont(splashFont);
    splash->show();
    QTime time;
    time.start();
    for (int i = 0; i < 100; )
    {
        if (time.elapsed() > 5)
        {
            time.start();
            ++i;
        }
        splash->showMessage(tr("     Загрузка системы: ") + QString::number(i) + "%", Qt::AlignLeft | Qt::AlignBottom , Qt::black);
        QCoreApplication::processEvents();
    }

    QSqlQuery * empNameQuery = new QSqlQuery(dal_main->db);
    empNameQuery->prepare("SELECT st_fio, st_photo FROM is_sotrudniki where id_sotr = " + QString::number(dal_main->getCurrentEmployee()));
    empNameQuery->exec();
    empNameQuery->first();
    if(empNameQuery->isValid())
        this->setWindowTitle("SMT v. 1.0 (текущий пользователь - " + empNameQuery->value(0).toString() + ")");


    checkNaznPoruch = new QSqlQuery(dal_main->db);
    checkNaznPoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where  checkPoruch = 0 and poruchitel = " + QString::number(dal_main->getCurrentEmployee()));
    checkIspolPoruch = new QSqlQuery(dal_main->db);
    checkIspolPoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where  checkIspoln = 0 and ispolnitel = " + QString::number(dal_main->getCurrentEmployee()));
    checker = new QTimer;
    //        checkDatePoruch = new QSqlQuery(dal_main->db);
    //        checkDatePoruch->prepare("SELECT count(id_poruchenie) FROM is_porucheniya where check_date  and checkIspoln = 1 and ispolnitel = " + QString::number(dal_main->getCurrentEmployee()));
    connect(checker,SIGNAL(timeout()),this,SLOT(on_check()));
    checker->setInterval(10000);
    checker->start();
    icon = new QSystemTrayIcon(this);
    icon->setIcon(QIcon(":/img/img/institution_icon.png"));
    icon->show();
    //icon->setContextMenu(ui->menu_file);
    connect(icon,SIGNAL(messageClicked()),this,SLOT(on_actionChecks())); //Open form Request

    ui->pushButton_show->setVisible(false);
    ui->pushButton_show->setFlat(true);
    ui->pushButton_hide->setFlat(true);
    ui->groupBox_main->setContentsMargins(0,0,0,0);
    ui->mdiArea->setVisible(false);
    QGraphicsDropShadowEffect * ef1 =  new QGraphicsDropShadowEffect;
    ef1->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef2 =  new QGraphicsDropShadowEffect;
    ef2->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef3 =  new QGraphicsDropShadowEffect;
    ef3->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef4 =  new QGraphicsDropShadowEffect;
    ef4->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef5 =  new QGraphicsDropShadowEffect;
    ef5->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef6 =  new QGraphicsDropShadowEffect;
    ef6->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef7 =  new QGraphicsDropShadowEffect;
    ef7->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef8 =  new QGraphicsDropShadowEffect;
    ef8->setBlurRadius(15);
    QGraphicsDropShadowEffect * ef9 =  new QGraphicsDropShadowEffect;
    ef9->setBlurRadius(15);
    ui->pushButton1->setGraphicsEffect(ef1);
    ui->pushButton2->setGraphicsEffect(ef2);
    ui->pushButton3->setGraphicsEffect(ef3);
    ui->pushButton4->setGraphicsEffect(ef4);
    ui->pushButton5->setGraphicsEffect(ef5);
    ui->pushButton6->setGraphicsEffect(ef6);
    ui->pushButton7->setGraphicsEffect(ef7);
    ui->pushButton8->setGraphicsEffect(ef8);
    ui->pushButton9->setGraphicsEffect(ef9);
    //    this->setCentralWidget(ui->mdiArea);

    // Настраиваем виджет перекрытия
    QLightBoxWidget* lightBox = new QLightBoxWidget(this);
    QLabel* lbTitle = new QLabel(empNameQuery->value(0).toString());
    lbTitle->setStyleSheet("font-size: 28px; font-weight: bold; color: white");
    QLabel* lbProgress = new QLabel;
    QMovie* progressMovie = new QMovie(empNameQuery->value(1).toString());
    progressMovie->setScaledSize(QSize(250,200));
    lbProgress->setMovie(progressMovie);
    progressMovie->start();
    QLabel* lbDescription = new QLabel(tr("Для входа в систему нажмите Войти"));
    lbDescription->setStyleSheet("color: white");
    QPushButton* lbClose = new QPushButton(tr("Войти"));
    QGridLayout* lbLayout = new QGridLayout;
    lbLayout->setRowStretch(0, 1);
    lbLayout->setColumnStretch(0, 1);
    lbLayout->addWidget(lbTitle, 1, 1);
    lbLayout->addWidget(lbProgress, 1, 2, Qt::AlignRight);
    lbLayout->setColumnStretch(3, 1);
    lbLayout->addWidget(lbDescription, 2, 1, 1, 2);
    lbLayout->addWidget(lbClose, 3, 2);
    lbLayout->setRowStretch(4, 1);
    connect(ui->action_Oteshel, SIGNAL(triggered()), lightBox, SLOT(show()));
    connect(lbClose, SIGNAL(clicked()), lightBox, SLOT(hide()));
    lightBox->setLayout(lbLayout);
//    ui->menuBar->setVisible(false);
    ui->mainToolBar->setVisible(false);
    ui->groupBox->setVisible(false);
    splash->finish(this);

    /*QGridLayout *userl = new QGridLayout(ui->userWidget);
    ui->userWidget->setLayout(userl);
    QLabel* lbProgress1 = new QLabel;
    QMovie* progressMovie1 = new QMovie(empNameQuery->value(1).toString());
    progressMovie1->setScaledSize(QSize(250,200));
    lbProgress1->setMovie(progressMovie1);
    progressMovie1->start();
    userl->addWidget(lbProgress1);*/
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    int dummy = errno;
    QApplication a(argc, argv);
    Debug::init(0);
    //mediaPipeline::init(argc, argv);

	// Set the Application Language
#if 0
	//if (QLocale::system().name() == "zh_CN")
	{
		QTranslator *translator = new QTranslator(&a);
		bool ok = translator->load("vscloudnode_zh.qm",
			QCoreApplication::applicationDirPath() + "/translations");
		
		if (ok)
		{
			qDebug("Translation Files loaded.");
			a.installTranslator(translator);
		}
	}
#endif

    QPixmap pixmap(":/logo/resources/splash.png");
    QSplashScreen *splash = new QSplashScreen(pixmap);
    QFont splashFont;
    //splashFont.setFamily("Arial");
    splashFont.setBold(true);

    splash->setStyleSheet(QStringLiteral("color : red;"));
    splash->setFont(splashFont);
    
    splash->show();

    //QApplication::setStyle(QStyleFactory::create("Fusion"));
	//QApplication::setStyle(QStyleFactory::create("Plastique"));
    //QApplication::setStyle("WindowsVista"); 
#if 0
	QFile f(":qdarkstyle/style.qss");
	if (!f.exists())
	{
		printf("Unable to set stylesheet, file not found\n");
	}
	else 
	{
		f.open(QFile::ReadOnly | QFile::Text);
		QTextStream ts(&f);
		a.setStyleSheet(ts.readAll());
	}
#endif


    gFactory = new Factory;
    splash->showMessage("Starting ...");

   if (gFactory->Init() == FALSE)
   {
#ifdef WIN32
       astring strPath = "C:\\";//TODO get the hdd from hdd
       VSCHddDevice hdd;
       hdd.show();
       hdd.exec();
       s32 size = hdd.GetDiskSize();
       hdd.GetDiskPath(strPath);
#else

	astring strPath = "ve/";//TODO get the hdd from hdd
	s32 size = 2;
#endif
       gFactory->SetSystemPath(strPath);
       splash->showMessage("Create Video Database ...");
       gFactory->Init();
#ifndef WIN32
	//gFactory->AddHDD(strPath, size);
#endif
   }

   VEvent::Init(*gFactory);
   VServiceMgr *pServiceMgr = VServiceMgr::CreateObject(*gFactory);

    VSCMainWindows w;
    //w.setWindowIcon(QIcon(":/logo/resources/vscsmall.jpg"));
    //w.show();
    //Sleep(1000);
    //w.setWindowFlags(Qt::FramelessWindowHint );
    //w.setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint );
    w.showMaximized();
    //w.showFullScreen();
    splash->finish(&w);

	//stacked s;
	//s.show();

    delete splash;
    /* Every thread is ready, start the factory thread */
    gFactory->start();
    return a.exec();
}