source: src-qt4/pc-mounttray/settingsDialog.cpp @ 891636a

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 891636a was 891636a, checked in by Ken Moore <ken@…>, 18 months ago

Get the mountTray saving/loading it's settings properly, and integrate those settings with the new Settings dlialog. You can now turn the disk space watcher off/on and set the refresh times/flags within the settings dialog.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1#include "settingsDialog.h"
2
3SettingsDialog::SettingsDialog() : QDialog(){
4  //Window settings
5  this->setWindowTitle( tr("Mount Tray Settings") );
6  this->setWindowIcon( QIcon(":icons/config.png"));
7  //Now Create the UI
8  QVBoxLayout *vlayout = new QVBoxLayout();
9    //Disk space watcher settings
10    QFormLayout *flayout = new QFormLayout;
11    groupDiskWatch = new QGroupBox(tr("Monitor disk storage space"));
12      groupDiskWatch->setCheckable(TRUE);
13      groupDiskWatch->setFlat(FALSE); //make sure the frame is drawn
14    checkDiskAutoTimer = new QCheckBox(tr("Perform check on device notifications"));
15    QLabel *spinLabel = new QLabel(tr("Maximum time between checks (minutes)"));
16    spinDiskRefreshMin = new QSpinBox(); //(in Minutes)
17      spinDiskRefreshMin->setMinimum(1); // 1 minute minimum
18      spinDiskRefreshMin->setMaximum(1440); //24 hours maximum
19      flayout->addRow(spinDiskRefreshMin, spinLabel);
20      flayout->addRow(checkDiskAutoTimer);
21    groupDiskWatch->setLayout(flayout);
22    vlayout->addWidget(groupDiskWatch);
23    //Now add the apply/close buttons to the bottom
24    QHBoxLayout *hb = new QHBoxLayout();
25    hb->addStretch();
26    closeButton = new QPushButton(QIcon(":icons/application-exit.png"),tr("Cancel"));
27    applyButton = new QPushButton(QIcon(":icons/checkmark.png"),tr("Apply"));
28      applyButton->setEnabled(FALSE);
29    hb->addWidget(applyButton);
30    hb->addWidget(closeButton);
31    vlayout->addLayout(hb);
32    connect(closeButton,SIGNAL(clicked()),this,SLOT(slotCloseDialog()));
33    connect(applyButton,SIGNAL(clicked()),this,SLOT(slotApply()));
34  //Now set the layout for the dialog
35  this->setLayout(vlayout);
36  //Now resize the dialog to fit the widget appropriately
37  this->adjustSize(); //still not working right -- need research on this
38}
39
40SettingsDialog::~SettingsDialog(){
41}
42
43void SettingsDialog::showDialog(){
44  //apply the values to the UI
45  groupDiskWatch->setChecked(useDiskWatcher);
46  checkDiskAutoTimer->setChecked(useDiskAutoTimer);
47  int minutes = diskRefreshMS/60000;
48  //qDebug() << "Refresh Time:"<< QString::number(diskRefreshMS)+" ms, "+QString::number(minutes)+" min";
49  spinDiskRefreshMin->setValue(minutes);
50    //Apply signals/slots AFTER setting the values
51    connect(groupDiskWatch, SIGNAL(clicked(bool)),this,SLOT(slotUpdateUI(bool)) );
52    connect(checkDiskAutoTimer, SIGNAL(clicked(bool)),this,SLOT(slotUpdateUI(bool)) );
53    connect(spinDiskRefreshMin, SIGNAL(valueChanged(int)),this,SLOT(slotUpdateUI(int)) );
54  this->exec();
55       
56}
57
58void SettingsDialog::slotApply(){
59  //get the values from the UI
60  useDiskWatcher = groupDiskWatch->isChecked();
61  useDiskAutoTimer = checkDiskAutoTimer->isChecked();
62  diskRefreshMS = spinDiskRefreshMin->value() * 60000;
63  //Flag that there are saved values and quit
64  SettingsChanged=TRUE;
65  this->close();
66}
67
68void SettingsDialog::slotCloseDialog(){
69  SettingsChanged=FALSE;
70  this->close();
71}
72
73void SettingsDialog::slotUpdateUI(bool checked){
74  applyButton->setEnabled(TRUE);
75  //Could do check for visible/invisible options here as well
76}
77
78void SettingsDialog::slotUpdateUI(int value){
79  applyButton->setEnabled(TRUE);
80  //Could do check for visible/invisible options here as well
81}
82
83
Note: See TracBrowser for help on using the repository browser.