Example #1
0
void MountTray::programInit()
{
  DCheck = new DevCheck(); //initialize class for checking devices
  qDebug() << "pc-mounttray: starting up";
  MTINIT=true; //set the flag that the mount tray is initializing;
  //getInitialUsername(); //try to detect the non-root user who is running the program with root permissions
  getFileManager();
    
  loadSavedSettings();
  
  trayIcon = new QSystemTrayIcon(this);
  trayIconMenu = new QMenu();
  //Generate the system menu options (these don't change)
  sysMenu = new QMenu( tr("More Options") );
    sysMenu->setIcon( QIcon(":icons/config.png") );
    //Add the additional options
    sysMenu->addAction( QIcon(":icons/folder.png"), tr("Open Media Directory"), this, SLOT(slotOpenMediaDir()) );
    sysMenu->addAction( QIcon(":icons/harddrive.png"), tr("View Disk Usage"),this,SLOT(slotOpenFSDialog()) );
    sysMenu->addAction( QIcon(":icons/refresh.png"),tr("Rescan Devices"), this, SLOT(slotRescan()) );
    //Add the setting dialog option seperately
    sysMenu->addSeparator();
    sysMenu->addAction( QIcon(":icons/dvd.png"), tr("Load ISO File"), this, SLOT(slotOpenISO()) );
    sysMenu->addAction( QIcon(":icons/config.png"), tr("Change Settings"), this, SLOT(slotOpenSettings()) );
    //Add the Close button seperately
    sysMenu->addSeparator();
    sysMenu->addAction( QIcon(":icons/application-exit.png"), tr("Close Tray"), this, SLOT(closeTray()) );
  
  // 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();

  //Do an initial scan of the devices with dmesg
  qDebug() << "-Performing initial device scan";
  scanInitialDevices();
  
  //Startup the devd watching process
  qDebug() << "-Starting up the DEVD watcher";
  devdTimer = new QTimer();
  devdTimer->setSingleShot(TRUE);
  connect(devdTimer,SIGNAL(timeout()),this,SLOT(slotDevChanges()));
  startupDevdProc();
  
  //Start up the filesystem watcher
  diskWatcher = new FSWatcher();
  connect(diskWatcher,SIGNAL(FSWarning(QString,QString)),this,SLOT(slotDisplayWarning(QString,QString)));
  if(useDiskWatcher){ 
    qDebug() << "-Starting up the disk space alert system";
    diskWatcher->start(diskTimerMaxMS); 
  }
  
  //Update the tray menu and icons
  updateMenu();

  qDebug() << "-Program now ready for use";
  QTimer::singleShot(500, this, SLOT(slotDoneWithInit()) ); //give it 1/2 a second to settle
}
Example #2
0
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{
    slotTrayActivated(); //Open up the menu
  }

}
Example #3
0
void MountTray::slotRescan(){
  //Display a notification
  qDebug() << "Re-scanning devices:";
  slotDisplayPopup(tr("Please Wait"),tr("Rescanning devices attached to the system"));
  //Rescan the device list for new devices
  UpdateDeviceMenu(false, true); //flag this as a refresh (don't show notifications)
  //Run the disk check if appropriate
  if(useDiskWatcher){ diskWatcher->checkFS(); }
  //Re-open the menu
  slotTrayActivated();
}
Example #4
0
void UpdaterTray::programInit()
{
  QString tmp, command;
  autoStatus = AUTOINACTIVE;
  doingCheck=false;
  shownPopup=false;

  // Use built-in frequency until we load another
  updateFrequency = -1;

  sysTimer = new QTimer(this);
  pbiTimer = new QTimer(this);

  connect( sysTimer, SIGNAL(timeout()), this, SLOT(slotScheduledSystemCheck()) );
  connect( pbiTimer, SIGNAL(timeout()), this, SLOT(slotScheduledPBICheck()) );

  // Get the username of the person running X
  username = getlogin();

  // Setup our Context Menu
  QIcon contextIcon;
  contextIcon.addFile(":/images/updated.png");


  trayIconMenu = new QMenu(this);
  trayIconMenu->setIcon(contextIcon);
  trayIconMenu->addSeparator();
  trayIconMenu->addAction( QIcon(":/images/sysupdater.png"), tr("Start the Update Manager"),  this, SLOT(slotOpenUpdateManager()));
  trayIconMenu->addAction( QIcon(":/images/pkgmanager.png"), tr("Start the Package Manager"), this, SLOT(slotOpenPackageManager()));
  trayIconMenu->addSeparator();
  trayIconMenu->addAction( QIcon(":/images/appcafe.png"),    tr("Start the AppCafe"), this, SLOT(slotOpenSoftwareManager()));
  trayIconMenu->addAction( QIcon(":/images/warden.png"),     tr("Start the Warden"),  this, SLOT(slotOpenJailManager()));
  trayIconMenu->addSeparator();
  trayIconMenu->addAction( QIcon(":/images/view-refresh.png"),tr("Check for updates"),this, SLOT(slotCheckAllUpdates()));
  trayIconMenu->addSeparator();
  runAction = trayIconMenu->addAction( tr("Run at startup"), this, SLOT(slotChangeRunStartup()) );
  runAction->setCheckable( TRUE );
  runAction->setChecked( TRUE );
  popAction = trayIconMenu->addAction( tr("Display notifications"), this, SLOT(slotChangePopup()) );
  popAction->setCheckable( TRUE );
  popAction->setChecked( TRUE );
  trayIconMenu->addSeparator();
  trayIconMenu->addAction( tr("Quit"), this, SLOT(slotQuitTray()) );
  
  // Init the tray icon
  trayIcon = new QSystemTrayIcon(this);
  trayIcon->setContextMenu(trayIconMenu);
  QIcon Icon(":/images/working.png");
  trayIcon->setIcon(Icon);
  trayIcon->show();
  connect( trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayActivated(QSystemTrayIcon::ActivationReason) ) );

  // Load the program preferences
  loadUpdaterPrefs();

  // Start the monitor service for system updates
  QTimer::singleShot(1000, this, SLOT(slotScheduledSystemCheck()));

  // Start the monitor service for PBI updates
  QTimer::singleShot(60000, this, SLOT(slotScheduledPBICheck()));

  // Monitor if we need to start any update checks
  QTimer::singleShot(500, this, SLOT(slotMonitorForChanges()));

  // Watch our trigger file, to see if any automated updates are being downloaded
  QFile sysTrig( SYSTRIGGER );
  if ( sysTrig.open( QIODevice::WriteOnly ) ) {
    QTextStream streamTrig( &sysTrig );
     streamTrig << QDateTime::currentDateTime().toString("hhmmss");
  }
  sysTrig.close();

  // Start our file watchers
  fileWatcherAutoUpdate = new QFileSystemWatcher();
  fileWatcherAutoUpdate->addPath(SYSTRIGGER);
  connect(fileWatcherAutoUpdate, SIGNAL(fileChanged(const QString&)), this, SLOT(slotSetTimerReadAutoStatus() ));

  // Watch for PBI updates and refresh
  QFile pbiTrig( PBITRIGGER );
  if ( pbiTrig.open( QIODevice::WriteOnly ) ) {
    QTextStream streamTrig1( &pbiTrig );
     streamTrig1 << QDateTime::currentDateTime().toString("hhmmss");
     pbiTrig.close();
  }
  pbiWatcherAutoUpdate = new QFileSystemWatcher();
  pbiWatcherAutoUpdate->addPath(PBITRIGGER);
  connect(pbiWatcherAutoUpdate, SIGNAL(fileChanged(const QString&)), this, SLOT(slotScheduledPBICheck() ));

  // Watch our trigger file, to see if any automated updates are being downloaded
  fileWatcherSys = new QFileSystemWatcher();
  fileWatcherSys->addPath(PREFIX + "/share/pcbsd/pc-updatemanager/conf/sysupdate.conf");
  connect(fileWatcherSys, SIGNAL(fileChanged(const QString&)), this, SLOT(slotScheduledSystemCheck() ));
}