Beispiel #1
0
void mainwid::takeOneSec(){
    if(pause_f)
        return;
    switch(current_mode){
    case COUNT_UP_M:
        tdata.addOneSec();
        this->refLCD(tdata.get_h(),tdata.get_m(),tdata.get_s());
        break;
    case COUNT_DOWN_M:
        if(tdata.decOneSec()){
            this->refLCD(tdata.get_h(),tdata.get_m(),tdata.get_s());
        }else{
            delete callaudio;
			if(this->readFromFile(audioFilePath) != false){
		         callaudio = Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(audioFilePath));
				 callaudio->play();
			}else{
			    callaudio = Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource(""));
			}
            emit finishCountDown();
            this->push_stop();
        }
        break;
    case CUSTOM_COUNT_M:
        break;
    }
    emit change_ctd_d(&tdata);
}
Beispiel #2
0
MainWindow::MainWindow()
{
	XmlParser xf;
	xf.open(config_file_path);
	xf.loadXmlData();
	enableSysTray = xf.getCheckbox(QString::fromStdString("notification"));

    real_close = false;
    w = new CentralWidget();
    connect(w,SIGNAL(change_ctd_d(const ctd_d*)),this,SLOT(changeTrayTime(const ctd_d*)));
	connect(w,SIGNAL(change_pause_f(QString)),this,SLOT(changeWindowTitle(QString)));

    sysTrayIcon = new QSystemTrayIcon(QIcon(":/photos/resource/p_icon.png"));
    sysTrayIcon->setVisible(true);//show!!
    if(enableSysTray) sysTrayIcon->showMessage(tr("gat2"),tr("Welcome to gat2!"),QSystemTrayIcon::Information,1500);
    connect(w,SIGNAL(finishCountDown()),this,SLOT(userCall()));


    config_editor = new PreferenceDialog();
	connect(config_editor,SIGNAL(chNotificationCheckBox(bool)),this,SLOT(changeNotificationCheckBox(bool)));
    about_widget = new gat_about_widget();

    a_about = new QAction(tr("&About"),this);
    a_about->setIcon(QIcon(":/photos/resource/p_icon_mini2.png"));
    connect(a_about,SIGNAL(triggered()),this,SLOT(about()));

    a_config = new QAction(tr("&Preferences"),this);
    connect(a_config,SIGNAL(triggered()),this,SLOT(callConfigDialog()));

    a_close = new QAction(tr("&Close"),this);
    connect(a_close,SIGNAL(triggered()),this,SLOT(closeApplication()));

    vSwitch = new QAction(tr("gat2"),this);
    connect(vSwitch,SIGNAL(triggered()),this,SLOT(changeVisible()));

    showTime = new QAction(tr("-----"),this);
    connect(showTime,SIGNAL(triggered()),this,SLOT(timeMessage()));


    help_bar = menuBar()->addMenu(tr("&gat2"));
    help_bar->addAction(a_about);
	help_bar->addAction(a_close);
    config_app = menuBar()->addMenu(tr("&Options"));
    config_app->addAction(a_config);
    sTaryIcon_Menu = new QMenu(tr("ContextMenu"));
    sTaryIcon_Menu->addAction(showTime);
    sTaryIcon_Menu->addSeparator();
    sTaryIcon_Menu->addAction(vSwitch);
    sTaryIcon_Menu->addAction(a_close);
    sysTrayIcon->setContextMenu(sTaryIcon_Menu);

    connect(this,SIGNAL(close_mainwid()),w,SLOT(delete_phonon_object()));

    setCentralWidget(w);
    setWindowTitle(tr("Gat2"));
    setWindowIcon(QIcon(":/photos/resource/p_icon.png"));
};