Skip to content
Snippets Groups Projects
Select Git revision
  • a6bfa00ee83b2f9ea267e44503911cc3714c0ab0
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/windowsReleaseTest
  • release/releaseTest
  • release/releaseWindowsTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 4.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
31 results

SFLPhoneapplication.cpp

  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    SFLPhoneapplication.cpp 2.84 KiB
    #include "SFLPhoneapplication.h"
    
    
    #include <KCmdLineArgs>
    #include <KIconLoader>
    #include <KStandardDirs>
    #include <KNotification>
    #include <KMainWindow>
    #include "SFLPhone.h"
    
    
    /**
     * The application constructor
     */
    SFLPhoneApplication::SFLPhoneApplication()
      : KApplication()
      , sflphoneWindow_(0)
    //  , quitSelected_(false)
    {
      // SFLPhoneApplication is created from main.cpp.
      // It continues the initialisation of the application.
    
      // Install a message handler, so KMESS_ASSERT won't do a exit(1) or abort()
      // It makes debugging output on Windows disappear, so don't use it there
    
      // Start remaining initialisation
      initializePaths();
      initializeMainWindow();
    
      // test notif
      KNotification *notification = new KNotification( "contact online" );
      notification->setText( "text" );
      notification->sendEvent();
    }
    
    
    
    /**
     * Destructor
     */
    SFLPhoneApplication::~SFLPhoneApplication()
    {
      // automatically destroyed
      sflphoneWindow_ = 0;
    }
    
    
    
    /**
     * Return the sflphone window
     */
    SFLPhone* SFLPhoneApplication::getSFLPhoneWindow() const
    {
      return sflphoneWindow_;
    }
    
    
    /**
     * Initialisation of the main window.
     */
    void SFLPhoneApplication::initializeMainWindow()
    {
      // Fetch the command line arguments
      KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    
      // Enable KDE session restore.
      int restoredWindow = -1;
      if( kapp->isSessionRestored() )
      {
        int n = 0;
        while( KMainWindow::canBeRestored( ++n ) )
        {
          if( KMainWindow::classNameOfToplevel( n ) != QLatin1String( "SFLPhone" ) )
          {
            continue;
          }
    
          restoredWindow = n;
          break;
        }
      }
    
      // Create the main window and initialize it
      sflphoneWindow_ = new SFLPhone();
      if( ! sflphoneWindow_->initialize() )
      {
        exit(1);
        return;
      }
    
      // Initialize KApplication
      //setTopWidget( sflphoneWindow_ );
      sflphoneWindow_->show();
    
      // We found session data for the Contact List, to restore it
      /*if( kapp->isSessionRestored() && restoredWindow != -1 )
      {
        sflphoneWindow_->restore( restoredWindow, false );
      }
      else
      {
        if( ! args->isSet( "hidden" ) )
        {
          sflphoneWindow_->show();
        }
      }*/
    }
    
    
    
    /**
     * Initialize additional paths
     */
    void SFLPhoneApplication::initializePaths()
    {
      // Add compile time paths as fallback
      KGlobal::dirs()       -> addPrefix( QString("/home/mlhamel/Documents/sflphone/sflphone-client-kde/data/") );
      KIconLoader::global() -> addAppDir( QString("/home/mlhamel/Documents/sflphone/sflphone-client-kde/data/") );
    
      qDebug() << "KGlobal::dirs" << QString(DATA_INSTALL_DIR);
      // Test whether the prefix is correct.
      if( KGlobal::dirs()->findResource( "appdata", "icons/hi128-apps-sflphone-client-kde.png" ).isNull() )
      {
        kWarning() << "SFLPhone could not find resources in the search paths: "
                   << KGlobal::dirs()->findDirs( "appdata", QString::null ).join(", ") << endl;
      }
    }
    
    
    #include "SFLPhoneapplication.moc"