bool mainwid::readFromFile(QString& path){ XmlParser xf; if(xf.open(config_file_path) == false){ return false; } xf.loadXmlData(); path = xf.getAlarmFile(); return true; }
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")); };
/*! * pathでaudio fileへのPATHを受け取ってファイルに書き出す */ bool configDialog::writeToFile(const QString &path){ XmlParser xf; if(xf.open(config_file_path) == false){ std::cout<<"Failed to save xml"<<std::endl; return false; } xf.loadXmlData(); xf.setAlarmFile(path); xf.save(); return true; };
void configDialog::notificationCheckChanged(int n){ QString s = "notification"; std::cout<<"Notification check box changed.["<<n<<"]"<<std::endl; XmlParser xf; if(xf.open(config_file_path) == false){ std::cout<<"Failed to save xml"<<std::endl; return; } xf.loadXmlData(); if(n == 0){ xf.setCheckbox(s,false); emit chNotificationCheckBox(false); }else{ xf.setCheckbox(s,true); emit chNotificationCheckBox(true); } xf.save(); }
configDialog::configDialog(QWidget* parent): QDialog(parent) { audioFileEdit = new QLineEdit();audioFileEdit->setReadOnly(true); notificationCheck = new QCheckBox("Notification"); connect(notificationCheck,SIGNAL(stateChanged(int)),this,SLOT(notificationCheckChanged(int))); /*xml read*/ XmlParser xf; xf.open(config_file_path); xf.loadXmlData(); audioFileEdit->setText(xf.getAlarmFile()); if(xf.getCheckbox(QString::fromStdString("notification")) == true){ notificationCheck->setChecked(true); }else{ notificationCheck->setChecked(false); } /*--------*/ QString a = QCoreApplication::applicationFilePath(); audioFileEditLabel = new QLabel(tr("audio file")); audioFileEditCallPathDialogButton = new QPushButton(tr("Choice")); connect(audioFileEditCallPathDialogButton,SIGNAL(clicked()),this,SLOT(audioFileEditCallPathDialogButton_is_Pushed())); QHBoxLayout *audioFileEditLayout = new QHBoxLayout(); audioFileEditLayout->addWidget(audioFileEditLabel); audioFileEditLayout->addWidget(audioFileEdit); audioFileEditLayout->addWidget(audioFileEditCallPathDialogButton); QVBoxLayout *checkboxes = new QVBoxLayout(); checkboxes->addWidget(notificationCheck); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->addLayout(audioFileEditLayout); mainLayout->addSpacing(12); mainLayout->addLayout(checkboxes); setLayout(mainLayout); };