Пример #1
0
void MainWindow::setUpApp( const QString& volume )
{
	this->setLocalizationLanguage() ;
	m_ui = new Ui::MainWindow ;
	m_ui->setupUi( this ) ;

	this->setFixedSize( this->size() ) ;

	m_ui->tableWidget->setColumnWidth( 0,220 ) ;
	m_ui->tableWidget->setColumnWidth( 1,320 ) ;
	m_ui->tableWidget->setColumnWidth( 2,145 ) ;
	m_ui->tableWidget->setColumnWidth( 4,87 ) ;
	m_ui->tableWidget->setColumnWidth( 5,87 ) ;
	m_ui->tableWidget->hideColumn( 3 ) ;

#if QT_VERSION < QT_VERSION_CHECK( 5,0,0 )
	m_ui->tableWidget->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ) ;
#else
	m_ui->tableWidget->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents ) ;
#endif
	m_ui->tableWidget->verticalHeader()->setMinimumSectionSize( 30 ) ;

	this->setAcceptDrops( true ) ;
	this->setWindowIcon( QIcon( ":/zuluMount.png" ) ) ;

	m_ui->tableWidget->setMouseTracking( true ) ;

	connect( m_ui->tableWidget,SIGNAL( itemEntered( QTableWidgetItem * ) ),this,SLOT( itemEntered( QTableWidgetItem * ) ) ) ;
	connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ),
		 this,SLOT( slotCurrentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ;
	connect( m_ui->pbmount,SIGNAL( clicked() ),this,SLOT( pbMount() ) ) ;
	connect( m_ui->pbupdate,SIGNAL( clicked()),this,SLOT( pbUpdate() ) ) ;
	connect( m_ui->pbclose,SIGNAL( clicked() ),this,SLOT( pbClose() ) ) ;
	connect( m_ui->tableWidget,SIGNAL( itemClicked( QTableWidgetItem * ) ),this,SLOT( itemClicked( QTableWidgetItem * ) ) ) ;
	connect( m_ui->pbunlockencfs,SIGNAL( clicked() ),this,SLOT( unlockencfs() ) ) ;

	connect( this,SIGNAL( unlistVolume( QString ) ),this,SLOT( removeVolume( QString ) ) ) ;

	this->setUpShortCuts() ;

	this->setUpFont() ;

	m_trayIcon = new QSystemTrayIcon( this ) ;
	m_trayIcon->setIcon( QIcon( ":/zuluMount.png" ) ) ;

	auto trayMenu = new QMenu( this ) ;

	m_autoMountAction = new QAction( this ) ;
	m_autoMount = this->autoMount() ;
	m_autoMountAction->setCheckable( true ) ;
	m_autoMountAction->setChecked( m_autoMount ) ;

	m_autoMountAction->setText( tr( "Automount Volumes" ) ) ;

	connect( m_autoMountAction,SIGNAL( toggled( bool ) ),this,SLOT( autoMountToggled( bool ) ) ) ;

	trayMenu->addAction( m_autoMountAction ) ;

	auto autoOpenFolderOnMount = new QAction( this ) ;
	autoOpenFolderOnMount->setCheckable( true ) ;
	m_autoOpenFolderOnMount = this->autoOpenFolderOnMount() ;
	autoOpenFolderOnMount->setChecked( m_autoOpenFolderOnMount ) ;
	autoOpenFolderOnMount->setText( tr( "Auto Open Mount Point" ) ) ;
	connect( autoOpenFolderOnMount,SIGNAL( toggled( bool ) ),this,SLOT( autoOpenFolderOnMount( bool ) ) ) ;

	trayMenu->addAction( autoOpenFolderOnMount ) ;

	auto ac = new QAction( this ) ;
	ac->setText( tr( "Show The Interface" ) ) ;
	connect( ac,SIGNAL( triggered() ),this,SLOT( raiseWindow() ) ) ;

	trayMenu->addAction( ac ) ;

	ac = new QAction( this ) ;
	ac->setText( tr( "Unmount All" ) ) ;
	connect( ac,SIGNAL( triggered() ),this,SLOT( unMountAll() ) ) ;

	trayMenu->addAction( ac ) ;

	m_favorite_menu = trayMenu->addMenu( tr( "Favorites" ) ) ;
	connect( m_favorite_menu,SIGNAL( triggered( QAction * ) ),this,SLOT( favoriteClicked( QAction * ) ) ) ;
	connect( m_favorite_menu,SIGNAL( aboutToShow() ),this,SLOT( showFavorites() ) ) ;

	m_not_hidden_volume_menu = trayMenu->addMenu( tr( "Hide Volume From View" ) ) ;
	connect( m_not_hidden_volume_menu,SIGNAL( triggered( QAction * ) ),this,SLOT( removeVolumeFromVisibleVolumeList( QAction * ) ) ) ;
	connect( m_not_hidden_volume_menu,SIGNAL( aboutToShow() ),this,SLOT( showVisibleVolumeList() ) ) ;

	m_hidden_volume_menu = trayMenu->addMenu( tr( "Unhide Volume From View" ) ) ;
	connect( m_hidden_volume_menu,SIGNAL( triggered( QAction * ) ),this,SLOT( removeVolumeFromHiddenVolumeList( QAction * ) ) ) ;
	connect( m_hidden_volume_menu,SIGNAL( aboutToShow() ),this,SLOT( showHiddenVolumeList() ) ) ;

	ac = new QAction( this ) ;
	ac->setText( tr( "About" ) ) ;
	connect( ac,SIGNAL( triggered() ),this,SLOT( licenseInfo() ) ) ;
	trayMenu->addAction( ac ) ;

	trayMenu->addAction( tr( "Quit" ),this,SLOT( pbClose() ) ) ;
	m_trayIcon->setContextMenu( trayMenu ) ;

	connect( m_trayIcon,SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ),
		 this,SLOT( slotTrayClicked( QSystemTrayIcon::ActivationReason ) ) ) ;

	m_trayIcon->show() ;

	QString dirPath = utility::homePath() + "/.zuluCrypt/" ;
	QDir dir( dirPath ) ;

	if( !dir.exists() ){
		dir.mkdir( dirPath ) ;
	}

	this->disableAll() ;

	this->startAutoMonitor() ;

	this->updateVolumeList( zuluMountTask::updateVolumeList().await() ) ;

	if( volume.isEmpty() ) {
		this->enableAll() ;
	}else{
		this->showMoungDialog( volume ) ;
	}
}
Пример #2
0
//PUBLIC
LPTray::LPTray() : QSystemTrayIcon() {
    qDebug() << "Starting up Life-preserver Tray...";
    //Start up the log file watcher and connect the signals/slots
    watcher = new LPWatcher();
    connect(watcher,SIGNAL(MessageAvailable(QString)),this,SLOT(watcherMessage(QString)) );
    connect(watcher,SIGNAL(StatusUpdated()),this,SLOT(watcherMessage()) );
    //Load the tray settings file
    settings = new QSettings(QSettings::UserScope,"PCBSD", "life-preserver-tray");
    //Create the notification option widgets
    nShowAll = new QRadioButton(tr("Show all"));
    naAll = new QWidgetAction(this);
    naAll->setDefaultWidget(nShowAll);
    nShowError = new QRadioButton(tr("Warnings Only"));
    naErr = new QWidgetAction(this);
    naErr->setDefaultWidget(nShowError);
    nShowNone = new QRadioButton(tr("None"));
    naNone = new QWidgetAction(this);
    naNone->setDefaultWidget(nShowNone);
    //Create notification menu
    notificationMenu = new QMenu(tr("Popup Settings"));
    notificationMenu->setIcon( QIcon(":/images/configure.png") );
    notificationMenu->addAction(naAll);
    notificationMenu->addAction(naErr);
    notificationMenu->addAction(naNone);
    //Activate the proper notification setting widget
    QString popset = settings->value("popup-policy", "").toString();
    qDebug() << "Current Popup Policy:" << popset;
    if(popset=="all") {
        nShowAll->setChecked(true);
        popupPolicy = 2;
    }
    else if(popset=="errors") {
        nShowError->setChecked(true);
        popupPolicy = 1;
    }
    else if(popset=="none") {
        nShowNone->setChecked(true);
        popupPolicy = 0;
    }
    else {
        nShowError->setChecked(true);
        settings->setValue("popup-policy","errors"); //save the proper setting
        popupPolicy = 1;
    }
    //Now connect the popup settings signals/slots
    connect(nShowAll, SIGNAL(clicked()), this, SLOT(changePopupPolicy()) );
    connect(nShowError, SIGNAL(clicked()), this, SLOT(changePopupPolicy()) );
    connect(nShowNone, SIGNAL(clicked()), this, SLOT(changePopupPolicy()) );
    //Setup the context menu
    menu = new QMenu;
    menu->addAction(QIcon(":/images/tray-icon-idle.png"),tr("Open Life Preserver"),this,SLOT(startGUI()) );
    menu->addSeparator();
    menu->addAction(QIcon(":/images/backup-failed.png"),tr("View Messages"),this,SLOT(startMessageDialog()) );
    menu->addMenu(notificationMenu);
    menu->addAction(QIcon(":/images/refresh.png"),tr("Refresh Tray"),this,SLOT(refreshStatus()) );
    menu->addSeparator();
    menu->addAction(QIcon(":/images/application-exit.png"),tr("Close Tray"),this,SLOT(slotClose()) );
    this->setContextMenu(menu);
    //Setup initial icon for the tray
    this->setIcon( QIcon(":/images/tray-icon-idle.png") );
    //Create the messages GUI
    msgdlg = new LPMessages();
    //connect other signals/slots
    connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)) );
    //Start up the watcher
    watcher->start();
    updateTrayIcon();
    updateToolTip();
}
Пример #3
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();

}
Пример #4
0
void MainWindow::setUpApp()
{
	this->setLocalizationLanguage() ;
	m_ui = new Ui::MainWindow ;
	m_ui->setupUi( this ) ;

	this->setFixedSize( this->size() ) ;

	m_ui->tableWidget->setColumnWidth( 0,225 ) ;
	m_ui->tableWidget->setColumnWidth( 1,320 ) ;
	m_ui->tableWidget->setColumnWidth( 2,105 ) ;
	m_ui->tableWidget->hideColumn( 3 ) ;
	m_ui->tableWidget->setColumnWidth( 4,87 ) ;
	m_ui->tableWidget->setColumnWidth( 5,87 ) ;

#if QT_VERSION < QT_VERSION_CHECK( 5,0,0 )
	m_ui->tableWidget->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ) ;
#else
	m_ui->tableWidget->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents ) ;
#endif
	m_ui->tableWidget->verticalHeader()->setMinimumSectionSize( 30 ) ;

	this->setAcceptDrops( true ) ;
	this->setWindowIcon( QIcon( QString( ":/zuluMount.png" ) ) ) ;

	m_ui->tableWidget->setMouseTracking( true ) ;

	connect( m_ui->tableWidget,SIGNAL( itemEntered( QTableWidgetItem * ) ),this,SLOT( itemEntered( QTableWidgetItem * ) ) ) ;
	connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ),
		 this,SLOT( slotCurrentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ;
	connect( m_ui->pbmount,SIGNAL( clicked() ),this,SLOT( pbMount() ) ) ;
	connect( m_ui->pbupdate,SIGNAL( clicked()),this,SLOT(pbUpdate() ) ) ;
	connect( m_ui->pbclose,SIGNAL( clicked() ),this,SLOT( pbClose() ) ) ;
	connect( m_ui->tableWidget,SIGNAL( itemClicked( QTableWidgetItem * ) ),this,SLOT( itemClicked( QTableWidgetItem * ) ) ) ;

	this->setUpShortCuts() ;

	this->setUpFont() ;

	m_trayIcon = new QSystemTrayIcon( this ) ;
	m_trayIcon->setIcon( QIcon( QString( ":/zuluMount.png" ) ) ) ;

	QMenu * trayMenu = new QMenu( this ) ;

	m_autoMountAction = new QAction( this ) ;
	m_autoMount = this->autoMount() ;
	m_autoMountAction->setCheckable( true ) ;
	m_autoMountAction->setChecked( m_autoMount ) ;

	m_autoMountAction->setText( tr( "automount volumes" ) ) ;

	connect( m_autoMountAction,SIGNAL( toggled( bool ) ),this,SLOT( autoMountToggled( bool ) ) ) ;

	trayMenu->addAction( m_autoMountAction ) ;

	QAction * autoOpenFolderOnMount = new QAction( this ) ;
	autoOpenFolderOnMount->setCheckable( true ) ;
	m_autoOpenFolderOnMount = this->autoOpenFolderOnMount() ;
	autoOpenFolderOnMount->setChecked( m_autoOpenFolderOnMount ) ;
	autoOpenFolderOnMount->setText( tr( "auto open mount point" ) ) ;
	connect( autoOpenFolderOnMount,SIGNAL( toggled( bool ) ),this,SLOT( autoOpenFolderOnMount( bool ) ) ) ;

	trayMenu->addAction( autoOpenFolderOnMount ) ;

	trayMenu->addAction( tr( "quit" ),this,SLOT( pbClose() ) ) ;
	m_trayIcon->setContextMenu( trayMenu ) ;

	connect( m_trayIcon,SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ),
		 this,SLOT( slotTrayClicked( QSystemTrayIcon::ActivationReason ) ) ) ;

	m_trayIcon->show() ;

	QString dirPath = QDir::homePath() + QString( "/.zuluCrypt/" ) ;
	QDir dir( dirPath ) ;

	if( !dir.exists() ){
		dir.mkdir( dirPath ) ;
	}

	Task * t = new Task() ;

	this->disableAll() ;

	connect( t,SIGNAL( signalMountedList( QStringList,QStringList ) ),
		 this,SLOT( slotMountedList( QStringList,QStringList ) ) ) ;
	connect( t,SIGNAL( done() ),this,SLOT( openVolumeFromArgumentList() ) ) ;
	connect( t,SIGNAL( done() ),this,SLOT( started() ) ) ;

	t->start( Task::Update ) ;

	this->startAutoMonitor() ;
}