[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim
From:       Volker Krause <vkrause () kde ! org>
Date:       2010-12-08 9:11:09
Message-ID: 20101208091109.703ADAC8A6 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1204584 by vkrause:

Make the mobile apps unique applications, you usually don't want
multiple instances when only having limited memory resources.


 M  +2 -2      kleopatra/main.cpp  
 M  +1 -5      mobile/calendar/main.cpp  
 M  +1 -4      mobile/contacts/main.cpp  
 M  +9 -8      mobile/lib/kdeclarativeapplication.cpp  
 M  +32 -3     mobile/lib/kdeclarativeapplication.h  
 M  +1 -4      mobile/mail/main.cpp  
 M  +1 -5      mobile/notes/main.cpp  
 M  +1 -4      mobile/tasks/main.cpp  


--- trunk/KDE/kdepim/kleopatra/main.cpp #1204583:1204584
@@ -210,7 +210,7 @@
   KCmdLineArgs::init(argc, argv, &aboutData);
 
 #ifdef KDEPIM_MOBILE_UI
-  KDeclarativeApplication::preApplicationSetup( \
KleopatraApplication::commandLineOptions() ); +  \
KDeclarativeApplicationBase::preApplicationSetup( \
KleopatraApplication::commandLineOptions() );  #else
   KCmdLineArgs::addCmdLineOptions( KleopatraApplication::commandLineOptions() );
 #endif
@@ -219,7 +219,7 @@
 
   KleopatraApplication app;
 #ifdef KDEPIM_MOBILE_UI
-  KDeclarativeApplication::postApplicationSetup();
+  KDeclarativeApplicationBase::postApplicationSetup();
 #endif
 
   qDebug() << "Startup timing:" << timer.elapsed() << "ms elapsed: Application \
                created";
--- trunk/KDE/kdepim/mobile/calendar/main.cpp #1204583:1204584
@@ -60,18 +60,14 @@
   aboutData.setProductName( "KOrganizer Mobile/calendar" ); //has to match the \
bugzilla product name  
   KCmdLineArgs::init( argc, argv, &aboutData );
-  KDeclarativeApplication app;
+  KDeclarativeApplication<MainView> app;
 
   KGlobal::locale()->insertCatalog( "libkcalutils" );
   KGlobal::locale()->insertCatalog( "libincidenceeditors" );
   KGlobal::locale()->insertCatalog( "calendarsupport" );
 
-  MainView view;
-
 #ifdef Q_OS_WINCE
   SetCursor( LoadCursor( NULL, NULL ) );
-#else
-  view.show();
 #endif
 
   return app.exec();
--- trunk/KDE/kdepim/mobile/contacts/main.cpp #1204583:1204584
@@ -47,17 +47,14 @@
   aboutData.setProductName( "KAddressbook Mobile" ); //has to match the bugzilla \
product name  
   KCmdLineArgs::init( argc, argv, &aboutData );
-  KDeclarativeApplication app;
+  KDeclarativeApplication<MainView> app;
 
   KGlobal::locale()->insertCatalog( "kabc" );
   KGlobal::locale()->insertCatalog( "akonadicontact" );
   KGlobal::locale()->insertCatalog( "libkdepim" );
 
-  MainView view;
 #ifdef Q_OS_WINCE
   SetCursor( LoadCursor( NULL, NULL ) );
-#else
-  view.show();
 #endif
 
   return app.exec();
--- trunk/KDE/kdepim/mobile/lib/kdeclarativeapplication.cpp #1204583:1204584
@@ -28,27 +28,28 @@
 #endif
 
 static inline bool runPreApplicationSetup( const KCmdLineOptions & opts ) {
+  Q_UNUSED( opts );
 #ifdef _WIN32_WCE
   QThread::currentThread()->setPriority(QThread::HighPriority);
 #endif
-    KDeclarativeApplication::preApplicationSetup();
+    KDeclarativeApplicationBase::preApplicationSetup();
     return true; // <-- default value of KApplication(bool) ctor
 }
 
-KDeclarativeApplication::KDeclarativeApplication()
-    : KApplication( runPreApplicationSetup( KCmdLineOptions() ) ) // inject some \
code before KApplication ctor runs \
+KDeclarativeApplicationBase::KDeclarativeApplicationBase() +    : \
KUniqueApplication( runPreApplicationSetup( KCmdLineOptions() ) ) // inject some code \
before KApplication ctor runs  {
     postApplicationSetup();
 }
 
-KDeclarativeApplication::KDeclarativeApplication( const KCmdLineOptions & opts )
-    : KApplication( runPreApplicationSetup( opts ) ) // inject some code before \
KApplication ctor runs +KDeclarativeApplicationBase::KDeclarativeApplicationBase( \
const KCmdLineOptions & opts ) +    : KUniqueApplication( runPreApplicationSetup( \
opts ) ) // inject some code before KApplication ctor runs  {
     postApplicationSetup();
 }
 
 // static
-void KDeclarativeApplication::postApplicationSetup()
+void KDeclarativeApplicationBase::postApplicationSetup()
 {
   static bool run = false;
 
@@ -107,14 +108,14 @@
 }
 
 // static
-void KDeclarativeApplication::preApplicationSetup()
+void KDeclarativeApplicationBase::preApplicationSetup()
 {
   preApplicationSetup( KCmdLineOptions() );
 }
 
 
 // static
-void KDeclarativeApplication::preApplicationSetup( const KCmdLineOptions & \
appOptions ) +void KDeclarativeApplicationBase::preApplicationSetup( const \
KCmdLineOptions & appOptions )  {
   static bool run = false;
 
--- trunk/KDE/kdepim/mobile/lib/kdeclarativeapplication.h #1204583:1204584
@@ -22,15 +22,16 @@
 
 #include "mobileui_export.h"
 #include <kuniqueapplication.h>
+#include <kdebug.h>
 
 class KCmdLineOptions;
 
-class MOBILEUI_EXPORT KDeclarativeApplication : public KApplication
+class MOBILEUI_EXPORT KDeclarativeApplicationBase : public KUniqueApplication
 {
   Q_OBJECT
   public:
-    KDeclarativeApplication();
-    explicit KDeclarativeApplication( const KCmdLineOptions & applicationOptions );
+    KDeclarativeApplicationBase();
+    explicit KDeclarativeApplicationBase( const KCmdLineOptions & applicationOptions \
);  
     /** Sets up some stuff. Only needs to be called (before the
         KApplication constructor) if you don't use
@@ -51,4 +52,32 @@
     static void postApplicationSetup();
 };
 
+template <typename T>
+class KDeclarativeApplication : public KDeclarativeApplicationBase
+{
+  public:
+    KDeclarativeApplication() : KDeclarativeApplicationBase(), m_mainView( 0 ) {}
+    explicit KDeclarativeApplication( const KCmdLineOptions &applicationOptions ) : \
KDeclarativeApplicationBase( applicationOptions ), m_mainView( 0 ) {} +    virtual \
~KDeclarativeApplication() +    {
+      delete m_mainView;
+    }
+
+    int newInstance()
+    {
+      kDebug();
+      if ( !m_mainView ) {
+        m_mainView = new T;
+        m_mainView->show();
+      } else {
+        m_mainView->raise();
+      }
+
+      return 0;
+    }
+
+  private:
+    T* m_mainView;
+};
+
 #endif
--- trunk/KDE/kdepim/mobile/mail/main.cpp #1204583:1204584
@@ -62,7 +62,7 @@
   aboutData.setProductName( "KMail Mobile" ); //has to match the bugzilla product \
name  
   KCmdLineArgs::init( argc, argv, &aboutData );
-  KDeclarativeApplication app;
+  KDeclarativeApplication<MainView> app;
 
   KGlobal::locale()->insertCatalog( "libakonadi-kmime" );
   KGlobal::locale()->insertCatalog( "libmessagecore" );
@@ -73,11 +73,8 @@
   KGlobal::locale()->insertCatalog( "kmail" ); // for identity dialog
   KGlobal::locale()->insertCatalog( "libksieve" ); // for out of office reply dialog
 
-  MainView view;
 #ifdef Q_OS_WINCE
   SetCursor( LoadCursor( NULL, NULL ) );
-#else
-  view.show();
 #endif
 
   return app.exec();
--- trunk/KDE/kdepim/mobile/notes/main.cpp #1204583:1204584
@@ -48,14 +48,10 @@
   aboutData.setProductName( "KJots Mobile" ); //has to match the bugzilla product \
name  
   KCmdLineArgs::init( argc, argv, &aboutData );
-  KDeclarativeApplication app;
+  KDeclarativeApplication<MainView> app;
 
-  MainView view;
-
 #ifdef Q_OS_WINCE
   SetCursor( LoadCursor( NULL, NULL ) );
-#else
-  view.show();
 #endif
 
   return app.exec();
--- trunk/KDE/kdepim/mobile/tasks/main.cpp #1204583:1204584
@@ -57,16 +57,13 @@
   aboutData.setProductName( "KOrganizer Mobile/tasks" ); //has to match the bugzilla \
product name  
   KCmdLineArgs::init( argc, argv, &aboutData );
-  KDeclarativeApplication app;
+  KDeclarativeApplication<MainView> app;
 
   KGlobal::locale()->insertCatalog( "libkcalutils" );
   KGlobal::locale()->insertCatalog( "libincidenceeditors" );
 
-  MainView view;
 #ifdef Q_OS_WINCE
   SetCursor( LoadCursor( NULL, NULL ) );
-#else
-  view.show();
 #endif
 
   return app.exec();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic