Permalink
Browse files

Fix the mount tray message clicked functionality, it should now eithe…

…r mount the device and/or open up where the device is mounted in the file manager.
  • Loading branch information...
1 parent 1f40abc commit 176289d7306c6be56d89e17cfff6aace47497189 @beanpole135 beanpole135 committed Aug 16, 2013
Showing with 39 additions and 13 deletions.
  1. +3 −2 src-qt4/pc-mounttray/menuItem.h
  2. +32 −8 src-qt4/pc-mounttray/mountTray.cpp
  3. +4 −3 src-qt4/pc-mounttray/mountTray.h
View
5 src-qt4/pc-mounttray/menuItem.h
@@ -38,7 +38,8 @@ class MenuItem : public QWidgetAction
//Setters
void updateItem();
-
+ void mountItem(); //be careful calling this on it's own
+
//Getters
QString getDeviceName();
@@ -57,7 +58,7 @@ class MenuItem : public QWidgetAction
QPushButton* pushMount;
QCheckBox* checkAutomount;
- void mountItem();
+ //void mountItem();
void unmountItem();
void updateSizes();
QString getSizeDisplay(int);
View
40 src-qt4/pc-mounttray/mountTray.cpp
@@ -41,7 +41,8 @@ void MountTray::programInit()
// Tie the left-click signal to open the context menu
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayActivated(QSystemTrayIcon::ActivationReason)) );
-
+ //Connect the message clicked slot
+ connect(trayIcon,SIGNAL(messageClicked()),this,SLOT(slotPopupClicked()) );
//Set the default Tray Icon (will change once tray menus are set)
trayIcon->setIcon(QIcon(":icons/CDdevices-inactive.png"));
trayIcon->show();
@@ -193,7 +194,7 @@ void MountTray::slotDevChanges(bool showPopup){
//Get the current list of devices
QStringList nsd = DCheck->devChildren("");
//Remove all the currently managed devices
- qDebug() << "Rescanning Device List:" << nsd;
+ qDebug() << "Rescanning Device List";
for(int i=0; i<deviceList.length(); i++){
QString dev = deviceList[i]->device.section("/",-1);
if(DEBUG_MODE){ qDebug() << " - Check device:" << dev; }
@@ -230,7 +231,7 @@ void MountTray::slotDevChanges(bool showPopup){
if(showPopup && added){ //make sure this is not shown for previously added devices
QString title = tr("New Device");
QString message = QString( tr("%1 can now be accessed")).arg(dlabel);
- slotDisplayPopup(title, message);
+ slotDisplayPopup(title, message, nsd[i]);
}
}
}
@@ -374,22 +375,45 @@ void MountTray::slotSingleInstance()
trayIcon->show();
}
-void MountTray::slotDisplayPopup(QString title, QString msg){
+void MountTray::slotDisplayPopup(QString title, QString msg, QString device){
+ popupSave = device; //so we know what to do when it is clicked
//Display a popup bubble with the given message for 3 seconds
trayIcon->contextMenu()->hide(); //close the menu list
- disconnect(trayIcon, SIGNAL(messageClicked()),0,0); //make sure only one signal/slot connection
- connect(trayIcon,SIGNAL(messageClicked()),this,SLOT(slotOpenMediaDir()) );
trayIcon->showMessage(title, msg , QSystemTrayIcon::NoIcon,3000 );
}
void MountTray::slotDisplayWarning(QString title, QString msg){
+ popupSave="FSCHECK";
//Display a popup bubble with the given message for 5 seconds
trayIcon->contextMenu()->hide(); //close the menu list
- disconnect(trayIcon, SIGNAL(messageClicked()),0,0); //make sure only one signal/slot connection
- connect(trayIcon,SIGNAL(messageClicked()),this,SLOT(slotOpenFSDialog()) );
trayIcon->showMessage(title, msg , QSystemTrayIcon::Warning,5000 );
}
+void MountTray::slotPopupClicked(){
+ //Check the saved variable for what to do with this popup
+ if(popupSave == "FSCHECK"){
+ //Open up the filesystem disk space UI
+ slotOpenFSDialog();
+ }else if(!popupSave.isEmpty()){
+ //Check if it is a currently valid device
+ if(!popupSave.startsWith(DEVICEDIR)){ popupSave.prepend(DEVICEDIR); }
+ for(int i=0; i<deviceList.length(); i++){
+ if( deviceList[i]->device == popupSave){
+ //See if the device is mounted
+ if(deviceList[i]->isMounted()){
+ //Open up the mountpoint directory
+ openMediaDir(deviceList[i]->mountpoint);
+ }else{
+ //Mount the device
+ deviceList[i]->mountItem();
+ }
+ break;
+ }
+ }
+ }
+
+}
+
void MountTray::loadSavedSettings(){
//The saved settings file
QString filename = QDir::homePath()+"/.mounttray.settings";
View
7 src-qt4/pc-mounttray/mountTray.h
@@ -47,8 +47,9 @@ private slots:
void slotTrayActivated(QSystemTrayIcon::ActivationReason);
void slotOpenMediaDir();
void openMediaDir(QString);
- void slotDisplayPopup(QString,QString);
+ void slotDisplayPopup(QString,QString, QString device = "");
void slotDisplayWarning(QString,QString);
+ void slotPopupClicked();
void removeDevice(QString);
void slotRescan();
void slotOpenFSDialog();
@@ -64,13 +65,13 @@ private slots:
QSystemTrayIcon* trayIcon;
QMenu *trayIconMenu, *sysMenu;
QList<MenuItem*> deviceList;
- QStringList oldsysdev;
+ //QStringList oldsysdev;
FSWatcher *diskWatcher;
FSDialog *diskDisplay;
//Saved Settings
bool useDiskWatcher, useDiskTimerDevd;
int diskTimerMaxMS; //milliseconds
-
+ QString popupSave; //for saving the device for the latest pop-up message
void updateMenu();
void scanInitialDevices();

0 comments on commit 176289d

Please sign in to comment.