source: src-qt4/pc-mounttray/settingsDialog.cpp @ 92b4ba0

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

Add a new mount tray widget for changing configuration settings, and add some new icons. The new widget works great, I just need to tie it in to actually be used now.

  • Property mode set to 100644
File size: 3.0 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  spinDiskRefreshMin->setValue(diskRefreshMS/60000);
48    //Apply signals/slots AFTER setting the values
49    connect(groupDiskWatch, SIGNAL(clicked(bool)),this,SLOT(slotUpdateUI(bool)) );
50    connect(checkDiskAutoTimer, SIGNAL(clicked(bool)),this,SLOT(slotUpdateUI(bool)) );
51    connect(spinDiskRefreshMin, SIGNAL(valueChanged(int)),this,SLOT(slotUpdateUI(int)) );
52  this->exec();
53       
54}
55
56void SettingsDialog::slotApply(){
57  //get the values from the UI
58  useDiskWatcher = groupDiskWatch->isChecked();
59  useDiskAutoTimer = checkDiskAutoTimer->isChecked();
60  diskRefreshMS = spinDiskRefreshMin->value() * 60000;
61  //Flag that there are saved values and quit
62  SettingsChanged=TRUE;
63  this->close();
64}
65
66void SettingsDialog::slotCloseDialog(){
67  SettingsChanged=FALSE;
68  this->close();
69}
70
71void SettingsDialog::slotUpdateUI(bool checked){
72  applyButton->setEnabled(TRUE);
73  //Could do check for visible/invisible options here as well
74}
75
76void SettingsDialog::slotUpdateUI(int value){
77  applyButton->setEnabled(TRUE);
78  //Could do check for visible/invisible options here as well
79}
80
81
Note: See TracBrowser for help on using the repository browser.