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

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since e020f6a was e020f6a, checked in by Ken Moore <ken@…>, 12 months ago

Fix compilation of pc-mounttray on 10.x

  • 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  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()) );
52    connect(checkDiskAutoTimer, SIGNAL(clicked(bool)),this,SLOT(slotUpdateUI()) );
53    connect(spinDiskRefreshMin, SIGNAL(valueChanged(int)),this,SLOT(slotUpdateUI()) );
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(){
74  applyButton->setEnabled(TRUE);
75  //Could do check for visible/invisible options here as well
76}
77
78
79
Note: See TracBrowser for help on using the repository browser.