代码拉取完成,页面将自动刷新
#include "option_dialog.h"
#include "ui_option_dialog.h"
#include "snap_timer_mainwindow.h"
#include <QSettings>
#include <QFileDialog>
#include <QMessageBox>
#include <QProcess>
#include <QSoundEffect>
#include <QtCore/QtCore>
int is_play_music;
int is_run_program;
int is_display_message;
extern QString time_out_msg;
extern QString exe_file_name ;
extern QString wav_file_name ;
QString settingsName_option = "./Config.ini";
QSettings *setting = new QSettings(settingsName_option, QSettings::IniFormat);
option_dialog::option_dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::option_dialog)
{
ui->setupUi(this);
//init
//set the default value
if( setting->value("Alarm/display_message").toString().isEmpty ()){
setting->setValue ("Alarm/display_message","时间到了,如果不想报工伤的话,就起来转转吧!!!");
}
if( setting->value("Alarm/is_display_message").toString ().isEmpty ()){
setting->setValue ("Alarm/is_display_message",2);
}
if ( setting ->value("General/jiJie").toString().isEmpty()){
setting->setValue("General/jiJie",0);
}
ui->jiJie_comboBOx->setCurrentIndex(setting ->value("General/jiJie").toInt());
ui->starting_position->setCurrentIndex(setting->value("General/startingPositon").toInt());
ui->always_on_top_CB->setChecked(setting->value("General/isalways_on_top").toBool());
ui->click_time_to_start_CB->setChecked(setting->value("General/is_click_time_to_start").toBool());
ui->display_message_label->setChecked(setting->value("Alarm/is_display_message").toBool());
ui->display_message_lineEdit->setText(setting->value("Alarm/display_message").toString());
ui->playWaveFile_lineEdit->setText(setting->value("Alarm/playWaveFilePath").toString());
ui->runProgram_lineEdit->setText(setting->value("Alarm/runProgramPath").toString());
ui->run_program_label->setChecked (setting->value ("Alarm/isRunProgram").toBool ());
ui->playWaveFIle_label->setChecked (setting->value ("Alarm/isPlayWaveFile").toBool ());
wav_file_name = ui->playWaveFile_lineEdit->text();
exe_file_name = ui->runProgram_lineEdit->text();
//ui->option_ok_cancel_buttonBox->
//end of init
}
option_dialog::~option_dialog()
{
delete ui;
}
void option_dialog::on_starting_position_currentIndexChanged(const QString &arg1)
{
setting->setValue("General/startingPositon", ui->starting_position->currentIndex());
}
void option_dialog::on_always_on_top_CB_stateChanged(int arg1)
{
setting->setValue("General/isalways_on_top", ui->always_on_top_CB->checkState());
}
void option_dialog::on_click_time_to_start_CB_stateChanged(int arg1)
{
setting->setValue("General/is_click_time_to_start", ui->click_time_to_start_CB->checkState());
}
void option_dialog::on_display_message_label_stateChanged(int arg1)
{
}
void option_dialog::on_display_message_lineEdit_textEdited(const QString &arg1)
{
setting->setValue("Alarm/display_message",ui->display_message_lineEdit->text());
}
void option_dialog::on_dis_msg_tst_btn_clicked()
{
time_out_msg = ui->display_message_lineEdit->text ();
timeout_messagebox_show(time_out_msg);
}
void option_dialog::on_playWaveFile_browse_btn_clicked()
{
QWidget *qwidget = new QWidget();
//get the absolute path of the choose file
wav_file_name = QFileDialog::getOpenFileName(qwidget,"choose sounds file","./debug/sounds",tr("WAVE File (*.wav);;ALL file (*.*)"));
//show the path
//QMessageBox::warning(NULL,"show path",filename_play_music);
//filename echo
ui->playWaveFile_lineEdit->setText(wav_file_name);
}
void option_dialog::on_runProgram_browser_btn_clicked()
{
QWidget *qwidget = new QWidget();
//get the absolute path of the choose file
exe_file_name = QFileDialog::getOpenFileName(qwidget,"choose the exe file","",tr("EXE (*.exe);;ALL file (*.*)"));
//show the path
//QMessageBox::warning(NULL,"show path",filename_play_music);
//filename echo
ui->runProgram_lineEdit->setText(exe_file_name);
}
void run_program_button_slot(QString exe_file_name){
//run the select program
QProcess* caller = new QProcess();//创建对象,指定父类指针
caller->start(exe_file_name);//启动notepaid
}
void play_music_button_slot(QString wav_file_name){
QSoundEffect *soundEffect = new QSoundEffect();
soundEffect->setSource(QUrl::fromLocalFile(wav_file_name));
soundEffect->play();
}
void option_dialog::on_playWaveFile_btn_clicked()
{
play_music_button_slot(wav_file_name);
}
void option_dialog::on_runProgram_test_btn_clicked()
{
run_program_button_slot(exe_file_name);
}
void option_dialog::on_playWaveFile_lineEdit_textChanged(const QString &arg1)
{
setting->setValue("Alarm/playWaveFilePath",arg1);
}
void option_dialog::on_runProgram_lineEdit_textChanged(const QString &arg1)
{
setting->setValue("Alarm/runProgramPath",arg1);
}
void option_dialog::on_run_program_label_clicked()
{
is_run_program = ui->run_program_label->checkState ();
setting->setValue ("Alarm/isRunProgram",ui->run_program_label->checkState ());
}
void option_dialog::on_playWaveFIle_label_clicked()
{
is_play_music = ui->playWaveFIle_label->checkState ();
setting->setValue ("Alarm/isPlayWaveFile",ui->playWaveFIle_label->checkState ());
}
void option_dialog::on_display_message_label_clicked()
{
is_display_message = ui->display_message_label->checkState ();
setting->setValue ("Alarm/is_display_message",ui->display_message_label->checkState ());
}
void option_dialog::on_run_program_label_stateChanged(int arg1)
{
}
void option_dialog::on_playWaveFIle_label_stateChanged(int arg1)
{
}
void option_dialog::on_show_tray_popup_label_stateChanged(int arg1)
{
}
void option_dialog::on_playWaveFile_lineEdit_textEdited(const QString &arg1)
{
}
void option_dialog::on_runProgram_lineEdit_textEdited(const QString &arg1)
{
}
void option_dialog::on_option_ok_cancel_buttonBox_accepted (){
}
void option_dialog::on_display_message_lineEdit_textChanged(const QString &arg1)
{
}
void option_dialog::on_starting_position_currentIndexChanged(int index)
{
}
void option_dialog::on_jiJie_comboBOx_currentIndexChanged(int index)
{
switch (index) {
case 0:
setting->setValue("General/jiJie",0);
break;
case 1:
setting->setValue("General/jiJie",1);
break;
case 2:
setting->setValue("General/jiJie",2);
break;
default:
break;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。