Changeset 891636a
- Timestamp:
- Apr 18, 2013 7:56:14 AM (5 weeks ago)
- Branches:
- master, 9.1-release
- Children:
- aa082fc
- Parents:
- 92b4ba0
- Location:
- src-qt4/pc-mounttray
- Files:
-
- 10 edited
-
fsDialog.cpp (modified) (1 diff)
-
fsDialog.h (modified) (1 diff)
-
fsWatcher.cpp (modified) (4 diffs)
-
fsWatcher.h (modified) (2 diffs)
-
mountTray.cpp (modified) (8 diffs)
-
mountTray.h (modified) (4 diffs)
-
pc-mounttray.pro (modified) (2 diffs)
-
pc-mounttray.qrc (modified) (1 diff)
-
settingsDialog.cpp (modified) (1 diff)
-
settingsDialog.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src-qt4/pc-mounttray/fsDialog.cpp
r7639577 r891636a 61 61 QHBoxLayout *hb = new QHBoxLayout(); 62 62 hb->addStretch(); 63 QPushButton *closeButton = new QPushButton( "Close");63 QPushButton *closeButton = new QPushButton(QIcon(":icons/application-exit.png"),tr("Close")); 64 64 hb->addWidget(closeButton); 65 65 hb->addStretch(); -
src-qt4/pc-mounttray/fsDialog.h
rbe298e4 r891636a 12 12 #include <QBrush> 13 13 #include <QColor> 14 #include <QIcon> 14 15 15 16 #include "fsWatcher.h" -
src-qt4/pc-mounttray/fsWatcher.cpp
rbb6089a r891636a 4 4 //setup the timer 5 5 timer = new QTimer(); 6 timer->setSingleShot(TRUE); 6 7 QObject::connect(timer, SIGNAL(timeout()), this, SLOT(checkFS())); 7 8 } … … 11 12 12 13 void FSWatcher::start(int ms){ 13 timer->start(ms); 14 timer->stop(); 15 timer->setInterval(ms); //max time between system checks 16 timer->start(); 14 17 QTimer::singleShot(2000,this,SLOT(checkFS()) ); //make sure to perform a check when it starts up 15 18 } … … 100 103 } 101 104 102 //====== P rivateSlot =======105 //====== Public Slot ======= 103 106 void FSWatcher::checkFS(){ 104 107 QStringList devList = getFSmountpoints(); … … 117 120 emit FSWarning(title,message); 118 121 } 122 timer->start(); //reset the timer again 119 123 } 120 124 125 //===== Calculate Percentages ===== 121 126 int FSWatcher::calculatePercentage(int used, int total){ 122 127 double U = used; -
src-qt4/pc-mounttray/fsWatcher.h
rbb6089a r891636a 10 10 #include <QCoreApplication> 11 11 #include <QDebug> 12 12 13 13 14 class FSWatcher : public QObject … … 31 32 static int calculatePercentage(int,int); 32 33 33 p rivateslots:34 public slots: 34 35 void checkFS(); //function in a timer loop 35 36 -
src-qt4/pc-mounttray/mountTray.cpp
rd386893 r891636a 21 21 getInitialUsername(); //try to detect the non-root user who is running the program with root permissions 22 22 getDefaultFileManager(); //try to detect the default file-manager for opening the mount directory 23 loadSavedSettings(); 23 24 24 25 trayIcon = new QSystemTrayIcon(this); … … 33 34 //Add the setting dialog option seperately 34 35 sysMenu->addSeparator(); 35 sysMenu->addAction( QIcon(":icons/config.png"), tr(" Settings"), this, SLOT(slotOpenSettings()) );36 sysMenu->addAction( QIcon(":icons/config.png"), tr("Change Settings"), this, SLOT(slotOpenSettings()) ); 36 37 //Add the Close button seperately 37 38 sysMenu->addSeparator(); … … 57 58 58 59 //Start up the filesystem watcher 59 qDebug() << "-Starting up the disk space alert system";60 60 diskWatcher = new FSWatcher(); 61 61 connect(diskWatcher,SIGNAL(FSWarning(QString,QString)),this,SLOT(slotDisplayWarning(QString,QString))); 62 diskWatcher->start(3600000); // check every 1 hour in milliseconds 62 if(useDiskWatcher){ 63 qDebug() << "-Starting up the disk space alert system"; 64 diskWatcher->start(diskTimerMaxMS); 65 } 63 66 64 67 //Update the tray menu and icons … … 173 176 174 177 void MountTray::newDevdMessage(){ 175 devdTimer->start(1 000); //wait 1.5 seconds before checking for device changes178 devdTimer->start(1500); //wait 1.5 seconds before checking for device changes 176 179 return; 177 180 } … … 251 254 } 252 255 } //end loop over cd/dvd devices 256 257 //Run the disk space check if appropriate 258 if(useDiskWatcher && useDiskTimerDevd && showPopup){ diskWatcher->checkFS(); } 253 259 } 254 260 … … 340 346 deviceList[i]->updateItem(); 341 347 } 348 //Run the disk check if appropriate 349 if(useDiskWatcher){ diskWatcher->checkFS(); } 342 350 } 343 351 … … 349 357 350 358 void MountTray::slotOpenSettings(){ 359 //Stop the refresh timer on the watcher 360 diskWatcher->stop(); 351 361 //Open up the settings window and apply changes as necessary 352 qDebug() << "Settings window not implemented yet"; 362 SettingsDialog *sdlg = new SettingsDialog(); 363 sdlg->useDiskWatcher = useDiskWatcher; 364 sdlg->useDiskAutoTimer = useDiskTimerDevd; 365 sdlg->diskRefreshMS = diskTimerMaxMS; 366 sdlg->showDialog(); 367 //Now parse the output and save if necessary 368 if(sdlg->SettingsChanged){ 369 useDiskWatcher = sdlg->useDiskWatcher; 370 useDiskTimerDevd = sdlg->useDiskAutoTimer; 371 diskTimerMaxMS = sdlg->diskRefreshMS; 372 qDebug() << "INFO: Saving updated settings to file"; 373 saveCurrentSettings(); //update the saved settings 374 } 375 //Now restart the disk watcher if enabled 376 if(useDiskWatcher){ diskWatcher->start(diskTimerMaxMS); } 353 377 } 354 378 … … 373 397 trayIcon->showMessage(title, msg , QSystemTrayIcon::Warning,5000 ); 374 398 } 399 400 void MountTray::loadSavedSettings(){ 401 //The saved settings file 402 QString filename = QDir::homePath()+"/.mounttray.settings"; 403 //Set the defaults 404 useDiskWatcher=TRUE; useDiskTimerDevd=TRUE; 405 diskTimerMaxMS=3600000; //1 hour refresh timer 406 //Now load the file 407 QFile file(filename); 408 if(file.exists()){ 409 if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ 410 qDebug() << "-Could not open settings file: using defaults"; 411 return; 412 } 413 QTextStream in(&file); 414 while(!in.atEnd()){ 415 QString line = in.readLine(); 416 if(!line.startsWith("#")){ //skip comment lines 417 QString var = line.section(")",0,0,QString::SectionSkipEmpty).simplified(); 418 QString val = line.section(")",1,30,QString::SectionSkipEmpty).simplified(); 419 if(var=="UseDiskSpaceMonitoring"){ 420 if(val.toLower() == "true"){ useDiskWatcher = TRUE;} 421 else{ useDiskWatcher = FALSE; } 422 }else if(var=="UseDiskSpaceDevdTiming"){ 423 if(val.toLower() == "true"){ useDiskTimerDevd = TRUE;} 424 else{ useDiskTimerDevd = FALSE; } 425 }else if(var=="DiskSpaceTimingMaxMilliseconds"){ 426 diskTimerMaxMS = val.toInt(); 427 } 428 } 429 } 430 file.close(); 431 }else{ 432 qDebug() << "-Creating new settings file with defaults"; 433 saveCurrentSettings(); 434 } 435 } 436 437 void MountTray::saveCurrentSettings(){ 438 //The saved settings file 439 QString filename = QDir::homePath()+"/.mounttray.settings"; 440 //Now write the current values to the file 441 QFile file(filename); 442 if(!file.open(QIODevice::WriteOnly | QIODevice::Text)){ 443 qDebug() << "ERROR: Could not open file to save settings:"<<filename; 444 return; 445 } 446 QTextStream out(&file); 447 out << "#pc-mounttray saved settings file\n"; 448 out << "# DO NOT EDIT: Use the settings dialog in the application instead!!\n"; 449 //Save the settings 450 out << "UseDiskSpaceMonitoring)"; 451 if(useDiskWatcher){ out << "true\n";} 452 else{ out << "false\n"; } 453 out << "UseDiskSpaceDevdTiming)"; 454 if(useDiskTimerDevd){ out << "true\n";} 455 else{ out << "false\n"; } 456 out << "DiskSpaceTimingMaxMilliseconds)"+QString::number(diskTimerMaxMS)+"\n"; 457 //Now close the file 458 file.close(); 459 } -
src-qt4/pc-mounttray/mountTray.h
rd386893 r891636a 11 11 #include <QList> 12 12 #include <QTimer> 13 #include <QDir> 14 #include <QFile> 15 #include <QTextStream> 13 16 14 17 #include "menuItem.h" … … 16 19 #include "fsWatcher.h" 17 20 #include "fsDialog.h" 21 #include "settingsDialog.h" 18 22 19 23 extern bool DEBUG_MODE; … … 62 66 FSWatcher *diskWatcher; 63 67 FSDialog *diskDisplay; 68 //Saved Settings 69 bool useDiskWatcher, useDiskTimerDevd; 70 int diskTimerMaxMS; //milliseconds 64 71 65 72 … … 71 78 void getInitialUsername(); 72 79 void getDefaultFileManager(); 80 void loadSavedSettings(); 81 void saveCurrentSettings(); 73 82 74 83 }; -
src-qt4/pc-mounttray/pc-mounttray.pro
rbb6089a r891636a 11 11 devCheck.h \ 12 12 fsWatcher.h \ 13 fsDialog.h 13 fsDialog.h \ 14 settingsDialog.h 14 15 15 16 SOURCES += main.cpp \ … … 18 19 devCheck.cpp \ 19 20 fsWatcher.cpp \ 20 fsDialog.cpp 21 fsDialog.cpp \ 22 settingsDialog.cpp 21 23 22 24 RESOURCES += pc-mounttray.qrc -
src-qt4/pc-mounttray/pc-mounttray.qrc
rd386893 r891636a 14 14 <file>icons/refresh.png</file> 15 15 <file>icons/config.png</file> 16 <file>icons/checkmark.png</file> 16 17 </qresource> 17 18 </RCC> -
src-qt4/pc-mounttray/settingsDialog.cpp
r92b4ba0 r891636a 45 45 groupDiskWatch->setChecked(useDiskWatcher); 46 46 checkDiskAutoTimer->setChecked(useDiskAutoTimer); 47 spinDiskRefreshMin->setValue(diskRefreshMS/60000); 47 int minutes = diskRefreshMS/60000; 48 //qDebug() << "Refresh Time:"<< QString::number(diskRefreshMS)+" ms, "+QString::number(minutes)+" min"; 49 spinDiskRefreshMin->setValue(minutes); 48 50 //Apply signals/slots AFTER setting the values 49 51 connect(groupDiskWatch, SIGNAL(clicked(bool)),this,SLOT(slotUpdateUI(bool)) ); -
src-qt4/pc-mounttray/settingsDialog.h
r92b4ba0 r891636a 14 14 #include <QLabel> 15 15 #include <QIcon> 16 #include <QDebug> 16 17 17 18 class SettingsDialog : public QDialog{
Note: See TracChangeset
for help on using the changeset viewer.
