Exemplo n.º 1
0
//PUBLIC
TrayUI::TrayUI() : QSystemTrayIcon(){
  qDebug() << "Starting Up System Updater Tray...";
  PerformingCheck = false; //initial value
  settings = new QSettings("PCBSD");
    settings->sync();
  watcher = new QFileSystemWatcher();
    connect(watcher, SIGNAL( fileChanged(QString) ), this, SLOT(watcherFileChange(QString)) ); //specific file changed
    connect(watcher, SIGNAL( directoryChanged(QString) ), this, SLOT(watcherDirChange()) ); //directory changed
	
  checkTimer = new QTimer(this);
    checkTimer->setInterval(5*60000); //every 5 minutes
    connect(checkTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()) );
	
  //Create the Menu
  mainMenu = new QMenu();
    this->setContextMenu( mainMenu ); 
    connect(mainMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotItemClicked(QAction*)) );
  //Populate the menu
  QAction *tmp = mainMenu->addAction(QIcon(":/images/updated.png"), tr("Start the Update Manager") );
	tmp->setWhatsThis("sys");
  mainMenu->addSeparator();
  tmp = mainMenu->addAction(QIcon(":/images/appcafe.png"), tr("Start the AppCafe") );
	tmp->setWhatsThis("pkg");
  tmp = mainMenu->addAction(QIcon(":/images/warden.png"), tr("Start the Warden") );
	tmp->setWhatsThis("warden");
  mainMenu->addSeparator();
  tmp = mainMenu->addAction(QIcon(":/images/view-refresh.png"), tr("Check for Updates") );
	tmp->setWhatsThis("update");
  mainMenu->addSeparator();
  // - Now the special checkboxes
  runAtStartup = new QCheckBox(tr("Run At Startup"));
    runAtStartup->setChecked(settings->value("/PC-BSD/SystemUpdater/runAtStartup",true).toBool() );
    connect(runAtStartup, SIGNAL(clicked()), this, SLOT(slotRunAtStartupClicked()) );
  rasA = new QWidgetAction(this);
    rasA->setDefaultWidget(runAtStartup);
  mainMenu->addAction(rasA);
  showNotifications = new QCheckBox(tr("Display Notifications"));
    showNotifications->setChecked(settings->value("/PC-BSD/SystemUpdater/displayPopup",true).toBool() );
    connect(showNotifications, SIGNAL(clicked()), this, SLOT(slotShowMessagesClicked()) );
  snA = new QWidgetAction(this);
    snA->setDefaultWidget(showNotifications);
  mainMenu->addAction(snA);
  checkJails = new QCheckBox(tr("Check Jails"));
    checkJails->setChecked(settings->value("/PC-BSD/SystemUpdater/watchJails",false).toBool() );
    connect(checkJails, SIGNAL(clicked()), this, SLOT(slotCheckJailsClicked()) );
 cjA = new QWidgetAction(this);
    cjA->setDefaultWidget(checkJails);
  mainMenu->addAction(cjA);
  mainMenu->addSeparator();
  torMode = new QCheckBox(tr("Routing through Tor"));
    torMode->setChecked( CSTAT.InTorMode() );
    connect(torMode, SIGNAL(clicked()), this, SLOT(slotToggleTorMode()) );
  tmA = new QWidgetAction(this);
    tmA->setDefaultWidget(torMode);
  mainMenu->addAction(tmA);
  mainMenu->addAction(QIcon(":/images/tor.png"), tr("Check Tor connection"), this, SLOT(slotCheckTorStatus()) );
  mainMenu->addSeparator();
  // - Now the quit option
  tmp = mainMenu->addAction(tr("Quit") );
	tmp->setWhatsThis("quit");
  //Initialize the backend systems  
  UpdateAUNotice(); //make sure that we get an icon/info right away
  QTimer::singleShot(1000, this, SLOT(BackendResync()) ); //wait one second before prodding syscache to start a sync
  QTimer::singleShot(15000, this, SLOT(checkForUpdates()) ); //Wait 15 seconds to perform the first update check
  checkTimer->start();
}
Exemplo n.º 2
0
//PUBLIC
TrayUI::TrayUI() : QSystemTrayIcon(){
  qDebug() << "Starting Up System Updater Tray...";
  //Set all the initial flags ( <0 means do initial checks if appropriate)
  PKGSTATUS=-1;
  SYSSTATUS=-1;
  WARDENSTATUS=-1;
  noInternet = false; //assume internet is available until we get a failure
  wasworking = false;
  //Load the tray settings file
  settings = new QSettings("PCBSD");
    settings->sync(); //make sure to load it right away
  //Setup the checktimer
  chktime = new QTimer(this);
	chktime->setInterval(1000 * 60 * 60 * 24); //every 24 hours
	connect(chktime, SIGNAL(timeout()), this, SLOT(checkForUpdates()) );
  //Generate the Menu
  menu = new QMenu(0);
  this->setContextMenu(menu);
  connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(slotItemClicked(QAction*)) );
  //Now fill the menu with items
    // - System Update Manager
  QAction* act = new QAction( QIcon(":/images/sysupdater.png"), tr("Start the Update Manager"), this);
	act->setWhatsThis("sys"); //system updater code
	menu->addAction(act);
    // - Separator
  menu->addSeparator();
    // - AppCafe
  act = new QAction( QIcon(":/images/appcafe.png"), tr("Start the AppCafe"), this);
	act->setWhatsThis("pkg"); // PKG code
	menu->addAction(act);
    // - Warden
  act = new QAction( QIcon(":/images/warden.png"), tr("Start the Warden"), this);
	act->setWhatsThis("warden"); //warden code
	menu->addAction(act);
    // - Separator
  menu->addSeparator();
    // - Check for Updates
  act = new QAction( QIcon(":/images/view-refresh.png"), tr("Check For Updates"), this);
	act->setWhatsThis("update"); //update check code
	menu->addAction(act);
    // - Separator
  menu->addSeparator();
    // - Run At Startup Checkbox
  runAtStartup = new QCheckBox(tr("Run At Startup"), 0);
    runAtStartup->setChecked( settings->value("/PC-BSD/SystemUpdater/runAtStartup",true).toBool() );
    connect(runAtStartup, SIGNAL(clicked()), this, SLOT(slotRunAtStartupClicked()) );
  rasAct = new QWidgetAction(this);
    rasAct->setDefaultWidget(runAtStartup);
    menu->addAction(rasAct);
    // - Display Notifications Checkbox
  showNotifications = new QCheckBox(tr("Display Notifications"), 0);
    showNotifications->setChecked( settings->value("/PC-BSD/SystemUpdater/displayPopup",true).toBool() );
    connect(showNotifications, SIGNAL(clicked()), this, SLOT(slotShowMessagesClicked()) );
  snAct = new QWidgetAction(this);
    snAct->setDefaultWidget(showNotifications);
    menu->addAction(snAct);   

  makeScheduleMenu();
  menu->addAction(tr("Automatic updates check"))->setMenu(schedule_menu);

    // - Separator
  menu->addSeparator();
    // - Warden
  act = new QAction( tr("Quit"), this);
	act->setWhatsThis("quit"); //system updater code
	menu->addAction(act);

  //Now Update the tray visuals
  updateTrayIcon();
  updateToolTip();
  //Start up the system flag watcher and connect the signals/slots
  watcher = new SystemFlagWatcher(this);
	connect(watcher,SIGNAL(FlagChanged(SystemFlags::SYSFLAG, SystemFlags::SYSMESSAGE)),this,SLOT(watcherMessage(SystemFlags::SYSFLAG, SystemFlags::SYSMESSAGE)) );
  //watcher->checkForRecent(10); //Check for flags in the last 10 minutes
  
  //Now connect the tray clicked signal
  connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)) );
  connect(this, SIGNAL(messageClicked()), this, SLOT(launchApp()) );
  
  //Startup the initial checks in 1 minute
  QTimer::singleShot(60000, this, SLOT(startupChecks()));

  //Periodically check timer start
  checkTimer=new QTimer(this);
  checkTimer->setInterval(60000); // 1min
  connect(checkTimer, SIGNAL(timeout()), this, SLOT(slotCheckTimer()));
  checkTimer->start();

}