Logo Search packages:      
Sourcecode: ultracopier version File versions  Download package

UIcon::UIcon (  )

Constructor of the systray icon.

See also:
~UIcon()

Definition at line 35 of file UIcon.cpp.

References actionCopy, actionMenuAbout, actionMenuQuit, actionMove, actionOptions, CatchAction(), CopyAction(), copyMenu, HelpAction(), iconActivBool, IconAdd, IconInfo, IconOptions, IconQuit, localServer, MoveAction(), newConnexionUI(), preloadOneInstance(), QuitAction(), showDelayedPopup(), ShowPopupMessage(), sysTrayIcon, systrayMenu, TextOfTheDelayedPopup, theHelpDialog, TheOptions, TimeOutQLocalSocket, TimerForDelayedAllocation, TimerForTheDelayedPopup, UIconIsListen, UpdateSsystrayIcon(), UpdateStyle(), and windowIsPreloaded.

{
      DEBUGCONSOLE(90,"UIcon::UIcon","start");
        UIconIsListen = false;
      localServer = new QLocalServer(this);
        #ifdef Q_OS_UNIX
        //prevent of problem of socket not removed
        localServer->removeServer(PATHSOCKET);
        #endif
        on_listen();
        
        theHelpDialog         = NULL;
      if(!UIconIsListen)
      {
            QMessageBox::critical(NULL,"Openning error","Ultracopier already open!");
            DEBUGCONSOLE(10,"UIcon::UIcon","Cannot create local server");
                QuitAction();
            QCoreApplication::exit();
      }
      else
      {
            connect(localServer, SIGNAL(newConnection()), this, SLOT(newConnexionUI()));
            
            //setup the systray icon
            sysTrayIcon = new QSystemTrayIcon(this);
            
            //setup menu
            systrayMenu =           new QMenu();
            IconQuit =        new QIcon(loadImage("exit.png"));
            IconInfo =        new QIcon(loadImage("info.png"));
            IconOptions =           new QIcon(loadImage("tools.png"));
            IconAdd =         new QIcon(loadImage("add.png"));
            #if (DEBUG_ULTRACOPIER>0)
            if(IconQuit->isNull() || IconInfo->isNull() || IconOptions->isNull() || IconAdd->isNull())
                  DEBUGCONSOLE(10,"UIcon::UIcon","error loading the icons");
            #endif
            actionMenuQuit =  new QAction(tr("&Quit"),this);
            #if (DEBUG_ULTRACOPIER<=0)
            actionMenuAbout = new QAction(tr("&About"),this);
            #else
            actionMenuAbout = new QAction(tr("&About/Debug/Log"),this);
            #endif
            actionOptions =         new QAction(tr("&Options"),this);
            
            copyMenu =        new QMenu();
            actionCopy =            new QAction(tr("Add &copy"),this);
            actionMove =            new QAction(tr("Add &move"),this);
            copyMenu->addAction(actionCopy);
            copyMenu->addAction(actionMove);
            copyMenu->setTitle(tr("A&dd copy/moving"));
            
            systrayMenu->addMenu(copyMenu);
            systrayMenu->addAction(actionOptions);
            systrayMenu->addAction(actionMenuAbout);
            systrayMenu->addAction(actionMenuQuit);
            systrayMenu->insertSeparator(actionOptions);
            
            sysTrayIcon->setContextMenu(systrayMenu);
            
            //connect for the action
            connect(actionMove,     SIGNAL(triggered()), this, SLOT(MoveAction()));
            connect(actionCopy,     SIGNAL(triggered()), this, SLOT(CopyAction()));
            connect(actionOptions,  SIGNAL(triggered()), this, SLOT(OptiAction()));
            connect(actionMenuQuit, SIGNAL(triggered()), this, SLOT(QuitAction()));
            connect(actionMenuAbout,SIGNAL(triggered()), this, SLOT(HelpAction()));
            
            connect(sysTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(CatchAction(QSystemTrayIcon::ActivationReason)));
            connect(this,SIGNAL(SignalPopup(QString)),this,SLOT(showDelayedPopup(QString)));

            iconActivBool=true;
            UpdateSsystrayIcon();
            TimerForTheDelayedPopup.setInterval(250);
            TimerForTheDelayedPopup.setSingleShot(true);
            connect(&TimerForTheDelayedPopup, SIGNAL(timeout()), this, SLOT(ShowPopupMessage()));
            TextOfTheDelayedPopup="";
            #if defined (Q_OS_WIN32) && (defined (_M_X64) || defined (_WIN64))
            sysTrayIcon->setToolTip(QString("Ultracopier x64"));
            #else
            sysTrayIcon->setToolTip(QString("Ultracopier"));
            #endif
            sysTrayIcon->show();
            
            TheOptions = NULL;
            
            //for dectect the timeout on QLocalSocket
            TimeOutQLocalSocket.setInterval(500);
            TimeOutQLocalSocket.setSingleShot(true);
            connect(&TimeOutQLocalSocket, SIGNAL(timeout()), this, SLOT(timeoutDectectedQLocalSocket()));

            //how many time wait before preallocation copy windows
            TimerForDelayedAllocation.setInterval(1000);
            TimerForDelayedAllocation.setSingleShot(true);
            connect(&TimerForDelayedAllocation, SIGNAL(timeout()), this, SLOT(preloadOneInstance()));
            
            //load the settings
            iconActivBool=false;
            QSettings *theSettings=getSettingsRes();
            if(theSettings->status()==QSettings::NoError)
            {
                  theSettings->beginGroup("starting");
                  if(theSettings->contains("checkBoxEnabledStart"))
                        iconActivBool=theSettings->value("checkBoxEnabledStart").toBool();
                  else
                        iconActivBool=true;
                  theSettings->endGroup();
                  theSettings->beginGroup("Interface");
                  if(theSettings->contains("comboBoxStyleWidget"))
                        if(QStyleFactory::keys().indexOf(theSettings->value("comboBoxStyleWidget").toString())!=-1)
                        {
                              DEBUGCONSOLE(90,"UIcon::UIcon","style applied: "+theSettings->value("comboBoxStyleWidget").toString());
                              QApplication::setStyle(theSettings->value("comboBoxStyleWidget").toString());
                        }
                  theSettings->endGroup();
            }
            QString errorMessage=setSystemCopyCatched(iconActivBool);
            if(errorMessage!="")
            {
                  DEBUGCONSOLE(30,"UIcon::UIcon","errorMessage: "+errorMessage);
                  iconActivBool=getSystemCopyCatched();
            }
            
            UpdateSsystrayIcon();

            windowIsPreloaded = false;

            //preload 1 windows
            preloadOneInstance();
            
            //update the style
            this->UpdateStyle();

            #if (DEBUG_ULTRACOPIER>0)
            //check if it had crash
            if(QFile::exists(giveWritablePath("log/stdout.log.html.crash")))
            {
                  QMessageBox::StandardButton reply=QMessageBox::question(NULL,tr("Crash of ultracopier"),tr("Ultracopier seem had been crashed.\nDo you want save the old log for report it?"),QMessageBox::Yes|QMessageBox::No);
                  if(reply==QMessageBox::Yes)
                  {
                        QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save file"),
                              "ultracopier-repport.log.html",
                              tr("Log file")+" (*.log)");
                        if(fileName=="")
                               return;
                        if(QFile::exists(fileName))
                              QFile::remove(fileName);
                        if(!QFile::copy(giveWritablePath("log/stdout.log.html.crash"),fileName))
                              QMessageBox::critical(NULL,"Error","Unable to save advanced repport");
                  }
                  QFile::remove(giveWritablePath("log/stdout.log.html.crash"));
            }
            #endif
      }
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index