source: src-qt4/EasyPBI/preferencesDialog.cpp

Last change on this file was 791b5df, checked in by Ken Moore <ken@…>, 4 months ago

Update EasyPBI to version 2.4!
This update allows it work work with and create PBING modules (no more build functionality).

  • Property mode set to 100644
File size: 6.8 KB
Line 
1#include "preferencesDialog.h"
2#include "ui_preferencesDialog.h"
3#include <QDebug>
4
5PreferencesDialog::PreferencesDialog(QWidget *parent) :
6    QDialog(parent),
7    ui(new Ui::PreferencesDialog)
8{
9       
10       //Setup Initial state of GUI objects and connect signal/slots
11       ui->setupUi(this);  //load the main UI from designer
12        //Setup the dialog icons
13        //ui->push_pbioutdir->setIcon(Backend::icon("load"));
14        //ui->push_sigfile->setIcon(Backend::icon("file"));
15        ui->push_moduledir->setIcon(Backend::icon("load"));
16        ui->push_icondir->setIcon(Backend::icon("load"));
17        ui->push_defaulticon->setIcon(Backend::icon("file"));
18        ui->push_suutility->setIcon(Backend::icon("file"));
19        //ui->push_makeport->setIcon(Backend::icon("file"));
20        //ui->push_pbicreate->setIcon(Backend::icon("file"));
21        ui->push_resetutils->setIcon(Backend::icon("refresh"));
22       
23        //Setup the internal settings structure
24        settings = new Config();
25        settings->scanForExternalUtilities();   
26        settings->loadSettingsFile();
27       
28        //Put the current settings into the GUI
29        resetGUI();
30}
31
32PreferencesDialog::~PreferencesDialog(){
33}
34
35//Setup the UI
36void PreferencesDialog::resetGUI(){
37  //Put the current settings into all the dialog widgets
38        //pbi tab
39        //ui->line_pbioutdir->setText(settings->value("pbidir"));
40        //ui->check_signpbi->setChecked(settings->check("usesignature"));
41        //ui->line_sigfile->setText(settings->value("sigfile"));
42        //paths tab
43        ui->line_moduledir->setText(settings->value("moduledir"));
44        ui->line_icondir->setText(settings->value("icondir"));
45        ui->line_defaulticon->setText(settings->value("defaulticon"));
46        ui->line_suutility->setText(settings->value("su_cmd"));
47        //ui->line_pbicreate->setText(settings->value("pbi_create"));
48        //ui->line_makeport->setText(settings->value("pbi_makeport"));
49        updateGUI();
50}
51
52void PreferencesDialog::updateGUI(){
53        //Now adjust the visibility of the necessary elements
54        //pbi tab
55        //if( ui->check_signpbi->isChecked() ){ ui->groupBox_sig->setVisible(TRUE); }
56        //else{ ui->groupBox_sig->setVisible(FALSE); }
57}
58
59//Save/Cancel buttons
60void PreferencesDialog::on_buttonBox_accepted(){
61    //Save the settings in the GUI to the stucture
62    //settings->setValue("pbidir", ui->line_pbioutdir->text() );
63    //settings->setCheck("usesignature", ui->check_signpbi->isChecked() );
64    //settings->setValue("sigfile", ui->line_sigfile->text() );
65    settings->setValue("moduledir", ui->line_moduledir->text() );
66    settings->setValue("icondir", ui->line_icondir->text() );
67    settings->setValue("defaulticon", ui->line_defaulticon->text() );
68    settings->setValue("su_cmd", ui->line_suutility->text() );
69    //settings->setValue("pbi_create", ui->line_pbicreate->text() );
70    //settings->setValue("pbi_makeport", ui->line_makeport->text() );
71    //Now save the settings to disk
72    settings->saveSettingsFile();
73    //Now close the dialog
74    this->close();
75}
76
77void PreferencesDialog::on_buttonBox_rejected(){
78    //Don't save any of the settings and just close the dialog
79    this->close();
80}
81
82// ===== PBI Settings Tab =====
83/*void PreferencesDialog::on_push_pbioutdir_clicked(){
84  //Get the desired directory
85  QString seldir = QFileDialog::getExistingDirectory(this, tr("Select PBI Output Directory"), QDir::homePath() );
86  if(seldir.isEmpty()){ return; } //action cancelled
87  //Save the selection to the GUI
88  ui->line_pbioutdir->setText(seldir);
89}*/
90
91/*void PreferencesDialog::on_push_sigfile_clicked(){
92  //Get the desired directory
93  QString seldir = QFileDialog::getOpenFileName(this, tr("Select Digital Signature File"), QDir::homePath(), tr("Signature Files (*)") );
94  if(seldir.isEmpty()){ return; } //action cancelled
95  //Save the selection to the GUI
96  ui->line_sigfile->setText(seldir);
97}*/
98
99/*void PreferencesDialog::on_check_signpbi_stateChanged(int state){
100  if(state == Qt::Checked){ ui->groupBox_sig->setVisible(TRUE); }
101  else{ ui->groupBox_sig->setVisible(FALSE); }
102}*/
103
104// ===== Paths Tab ===== 
105void PreferencesDialog::on_push_moduledir_clicked(){
106  //Get the desired directory
107  QString seldir = QFileDialog::getExistingDirectory(this, tr("Select Default Module Directory"), QDir::homePath() );
108  if(seldir.isEmpty()){ return; } //action cancelled
109  //Save the selection to the GUI
110  ui->line_moduledir->setText(seldir); 
111}
112
113void PreferencesDialog::on_push_icondir_clicked(){
114  //Get the desired directory
115  QString seldir = QFileDialog::getExistingDirectory(this, tr("Select Default Directory To Find Icon Files"), QDir::homePath() );
116  if(seldir.isEmpty()){ return; } //action cancelled
117  //Save the selection to the GUI
118  ui->line_icondir->setText(seldir); 
119}
120void PreferencesDialog::on_push_defaulticon_clicked(){
121  //Get the desired directory
122  QString seldir = QFileDialog::getOpenFileName(this, tr("Select Default Icon FIle"), QDir::homePath(), tr("PNG Images (*.png)") );
123  if(seldir.isEmpty()){ return; } //action cancelled
124  //Save the selection to the GUI
125  ui->line_defaulticon->setText(seldir); 
126}
127
128// ===== Utilities Tab =====
129void PreferencesDialog::on_push_suutility_clicked(){
130  //Get the desired directory
131  QString seldir = QFileDialog::getOpenFileName(this, tr("Select Graphical Switch-User Utility"), QDir::homePath() );
132  if(seldir.isEmpty()){ return; } //action cancelled
133  //Save the selection to the GUI
134  ui->line_suutility->setText(seldir); 
135}
136
137/*void PreferencesDialog::on_push_pbicreate_clicked(){
138  //Get the desired directory
139  QString seldir = QFileDialog::getOpenFileName(this, tr("Select 'pbi_create' File Location"), QDir::homePath(), "(pbi_create)" );
140  if(seldir.isEmpty()){ return; } //action cancelled
141  //Save the selection to the GUI
142  ui->line_pbicreate->setText(seldir);
143}
144
145void PreferencesDialog::on_push_makeport_clicked(){
146  //Get the desired directory
147  QString seldir = QFileDialog::getOpenFileName(this, tr("Select 'pbi_makeport' File Location"), QDir::homePath(), "(pbi_makeport)" );
148  if(seldir.isEmpty()){ return; } //action cancelled
149  //Save the selection to the GUI
150  ui->line_makeport->setText(seldir);
151}*/
152
153void PreferencesDialog::on_push_resetutils_clicked(){
154  //Verify that this is what the user really wants to do
155  QMessageBox verify(this);
156  verify.setText(tr("Are you sure you wish to return to the automatically detected utility paths?"));
157  verify.setInformativeText(tr("This will remove any customized path settings for the external utilities."));
158  verify.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
159  verify.setDefaultButton(QMessageBox::Yes);
160  int ret = verify.exec();
161  if(ret != QMessageBox::Yes){return;}
162  //Rescan for external utilities
163  settings->scanForExternalUtilities();
164  //Reset the values in the structure (will revert to detected values if any)
165  settings->setValue("pbi_makeport","");
166  //settings->setValue("pbi_create","");
167  //settings->setValue("su_cmd","");
168  //Reset the utilities on the GUI     
169  ui->line_suutility->setText(settings->value("su_cmd"));
170  //ui->line_pbicreate->setText(settings->value("pbi_create"));
171  //ui->line_makeport->setText(settings->value("pbi_makeport"));
172}
Note: See TracBrowser for help on using the repository browser.