Commit 7afea485 authored by Volker Krause's avatar Volker Krause

Delay initialization and show Nuno's pretty splash screen in the

meantime.

svn path=/trunk/KDE/kdepim/mobile/; revision=1158266
parent 9f8a1826
......@@ -45,7 +45,6 @@ using namespace KCal;
MainView::MainView( QWidget* parent ) : KDeclarativeMainView( "korganizer-mobile", 0 /* TODO */, parent )
{
m_calendar = 0;
QTimer::singleShot(0, this, SLOT(delayedInit()));
}
MainView::~MainView()
......@@ -55,13 +54,15 @@ MainView::~MainView()
void MainView::delayedInit()
{
KDeclarativeMainView::delayedInit();
addMimeType( IncidenceMimeTypeVisitor::eventMimeType() );
addMimeType( IncidenceMimeTypeVisitor::todoMimeType() );
itemFetchScope().fetchFullPayload();
m_calendar = new Akonadi::Calendar( entityTreeModel(), regularSelectedItems(), KSystemTimeZones::local() );
engine()->rootContext()->setContextProperty( "calendarModel", QVariant::fromValue( static_cast<QObject*>( m_calendar ) ) );
QDBusConnection::sessionBus().registerService("org.kde.korganizer"); //register also as the real korganizer, so kmail can communicate with it
CalendarInterface* calendarIface = new CalendarInterface();
new CalendarAdaptor(calendarIface);
......
......@@ -48,7 +48,7 @@ public slots:
void newTodo();
void editIncidence( const Akonadi::Item &item, const QDate &date );
private slots:
protected slots:
void delayedInit();
private:
......
......@@ -193,6 +193,11 @@ ContactEditorView::ContactEditorView( QWidget *parent )
d( new Private( this ) )
{
setAttribute(Qt::WA_DeleteOnClose);
}
void ContactEditorView::delayedInit()
{
KDeclarativeFullScreenView::delayedInit();
qmlRegisterType<DeclarativeEditorGeneral>( "org.kde.contacteditors", 4, 5, "ContactEditorGeneral" );
qmlRegisterType<DeclarativeEditorBusiness>( "org.kde.contacteditors", 4, 5, "ContactEditorBusiness" );
......
......@@ -64,7 +64,10 @@ class ContactEditorView : public KDeclarativeFullScreenView
protected:
void closeEvent( QCloseEvent *event );
protected slots:
virtual void delayedInit();
private:
class Private;
Private *const d;
......
......@@ -159,11 +159,17 @@ ContactGroupEditorView::ContactGroupEditorView( QWidget *parent )
d( new Private( this ) )
{
setAttribute(Qt::WA_DeleteOnClose);
}
void ContactGroupEditorView::delayedInit()
{
KDeclarativeFullScreenView::delayedInit();
qmlRegisterType<DeclarativeEditorContactGroup>( "org.kde.contacteditors", 4, 5, "ContactGroupEditor" );
connect( d->mItemManager, SIGNAL( itemSaveFinished() ), SLOT( saveFinished() ) );
connect( d->mItemManager, SIGNAL( itemSaveFailed( QString ) ), SLOT( saveFailed( QString ) ) );
}
}
ContactGroupEditorView::~ContactGroupEditorView()
{
......
......@@ -52,7 +52,10 @@ class ContactGroupEditorView : public KDeclarativeFullScreenView
protected:
void closeEvent( QCloseEvent *event );
protected slots:
virtual void delayedInit();
private:
class Private;
Private *const d;
......
......@@ -30,6 +30,12 @@
MainView::MainView( QWidget *parent ) : KDeclarativeMainView( "kaddressbook-mobile", new ContactListProxy, parent )
{
}
void MainView::delayedInit()
{
KDeclarativeMainView::delayedInit();
addMimeType( KABC::Addressee::mimeType() );
addMimeType( KABC::ContactGroup::mimeType() );
itemFetchScope().fetchFullPayload();
......
......@@ -40,6 +40,9 @@ class MainView : public KDeclarativeMainView
void newContactGroup();
void editContactGroup( const Akonadi::Item &item );
protected slots:
virtual void delayedInit();
};
#endif // MAINVIEW_H
......@@ -57,7 +57,11 @@ IncidenceView::IncidenceView( QWidget* parent )
, mEditorDateTime( 0 )
{
setAttribute(Qt::WA_DeleteOnClose);
}
void IncidenceView::delayedInit()
{
KDeclarativeFullScreenView::delayedInit();
qmlRegisterType<DCollectionCombo>( "org.kde.incidenceeditors", 4, 5, "CollectionCombo" );
qmlRegisterType<DIEGeneral>( "org.kde.incidenceeditors", 4, 5, "GeneralEditor" );
qmlRegisterType<DIEMore>( "org.kde.incidenceeditors", 4, 5, "MoreEditor" );
......
......@@ -68,6 +68,9 @@ class MOBILEUI_EXPORT IncidenceView : public KDeclarativeFullScreenView, public
void save(); /// Ok clicked in the user interface
void cancel(); /// Cancel clicked in the user interface
protected slots:
void delayedInit();
private slots:
void slotSaveFinished(Akonadi::EditorItemManager::SaveAction action );
void slotSaveFailed( Akonadi::EditorItemManager::SaveAction action, const QString &message );
......
......@@ -32,6 +32,7 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QTimer>
#include <QtGui/QLabel>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusMessage>
#include <QtDeclarative/QDeclarativeContext>
......@@ -43,10 +44,9 @@
KDeclarativeFullScreenView::KDeclarativeFullScreenView(const QString& qmlFileName, QWidget* parent) :
QDeclarativeView( parent )
QDeclarativeView( parent ),
m_qmlFileName( qmlFileName )
{
static const bool debugTiming = KCmdLineArgs::parsedArgs()->isSet("timeit");
#ifndef Q_OS_WINCE
// make MainView use OpenGL ES2 backend for better performance
// right now, the best performance can be achieved with a GLWidget
......@@ -58,12 +58,6 @@ KDeclarativeFullScreenView::KDeclarativeFullScreenView(const QString& qmlFileNam
setViewport(glWidget);
#endif
QTime t;
if ( debugTiming ) {
t.start();
kWarning() << "Start KDeclarativeFullScreenView ctor" << &t << " - " << QDateTime::currentDateTime();
}
setResizeMode( QDeclarativeView::SizeRootObjectToView );
#ifdef Q_WS_MAEMO_5
setWindowState( Qt::WindowFullScreen );
......@@ -71,6 +65,19 @@ KDeclarativeFullScreenView::KDeclarativeFullScreenView(const QString& qmlFileNam
setPalette( KGlobalSettings::createApplicationPalette( KGlobal::config() ) );
#endif
m_splashScreen = new QLabel( this );
QPixmap splashBackground;
splashBackground.load( KStandardDirs::locate( "data", QLatin1String( "mobileui" ) + QDir::separator() + QLatin1String( "splashscreenstatic.png" ) ) );
m_splashScreen->setPixmap( splashBackground );
QMetaObject::invokeMethod( this, "delayedInit", Qt::QueuedConnection );
}
void KDeclarativeFullScreenView::delayedInit()
{
kDebug();
static const bool debugTiming = KCmdLineArgs::parsedArgs()->isSet("timeit");
QTime t;
if ( debugTiming ) {
kWarning() << "Applying style" << t.elapsed() << &t;
}
......@@ -89,14 +96,14 @@ KDeclarativeFullScreenView::KDeclarativeFullScreenView(const QString& qmlFileNam
}
foreach ( const QString &importPath, KGlobal::dirs()->findDirs( "module", "imports" ) )
engine()->addImportPath( importPath );
QString qmlPath = KStandardDirs::locate( "appdata", qmlFileName + ".qml" );
QString qmlPath = KStandardDirs::locate( "appdata", m_qmlFileName + ".qml" );
if ( debugTiming ) {
kWarning() << "Applying style done" << t.elapsed() << &t;
}
if ( qmlPath.isEmpty() ) // Try harder
qmlPath = KStandardDirs::locate( "data", QLatin1String( "mobileui" ) + QDir::separator() + qmlFileName + ".qml" );
qmlPath = KStandardDirs::locate( "data", QLatin1String( "mobileui" ) + QDir::separator() + m_qmlFileName + ".qml" );
// call setSource() only once our derived classes have set up everything
QMetaObject::invokeMethod( this, "setQmlFile", Qt::QueuedConnection, Q_ARG( QString, qmlPath ) );
......@@ -149,6 +156,9 @@ void KDeclarativeFullScreenView::slotStatusChanged ( QDeclarativeView::Status st
KMessageBox::error( this, i18n( "Application loading failed: %1", errorMessages.join( QLatin1String( "\n" ) ) ) );
QCoreApplication::instance()->exit( 1 );
}
if ( status == QDeclarativeView::Ready )
m_splashScreen->deleteLater();
}
KActionCollection* KDeclarativeFullScreenView::actionCollection() const
......@@ -161,5 +171,4 @@ QObject* KDeclarativeFullScreenView::getAction( const QString &name ) const
return mActionCollection->action( name );
}
#include "kdeclarativefullscreenview.moc"
......@@ -30,6 +30,7 @@
#include "mobileui_export.h"
class KActionCollection;
class QLabel;
/**
* Full screen view for mobile applications. This class is just to share code and therefore
......@@ -54,6 +55,12 @@ class MOBILEUI_EXPORT KDeclarativeFullScreenView : public QDeclarativeView
QObject* getAction( const QString &name ) const;
KActionCollection* actionCollection() const;
protected slots:
/** Most initialization work should be done here instead of the ctor.
* @note: Remember to call the base class implementation when overwriting this.
*/
virtual void delayedInit();
private slots:
void setQmlFile( const QString &source );
void slotStatusChanged ( QDeclarativeView::Status );
......@@ -63,6 +70,8 @@ class MOBILEUI_EXPORT KDeclarativeFullScreenView : public QDeclarativeView
#ifndef Q_OS_WINCE
QGLWidget *glWidget;
#endif
QString m_qmlFileName;
QLabel *m_splashScreen;
};
#endif
......@@ -66,6 +66,13 @@ KDeclarativeMainView::KDeclarativeMainView( const QString &appName, ListProxy *l
: KDeclarativeFullScreenView( appName, parent )
, d( new KDeclarativeMainViewPrivate )
{
d->mListProxy = listProxy;
}
void KDeclarativeMainView::delayedInit()
{
kDebug();
KDeclarativeFullScreenView::delayedInit();
static const bool debugTiming = KCmdLineArgs::parsedArgs()->isSet("timeit");
......@@ -81,11 +88,6 @@ KDeclarativeMainView::KDeclarativeMainView( const QString &appName, ListProxy *l
kWarning() << "Catalog inserted" << t.elapsed() << &t;
}
setResizeMode( QDeclarativeView::SizeRootObjectToView );
#ifdef Q_WS_MAEMO_5
setWindowState( Qt::WindowFullScreen );
#endif
d->mChangeRecorder = new Akonadi::ChangeRecorder( this );
d->mChangeRecorder->fetchCollection( true );
d->mChangeRecorder->setCollectionMonitored( Akonadi::Collection::root() );
......@@ -108,10 +110,9 @@ KDeclarativeMainView::KDeclarativeMainView( const QString &appName, ListProxy *l
d->mItemFilter->setSourceModel( d->mBnf->unfilteredChildItemModel() );
d->mItemFilter->addMimeTypeExclusionFilter( Akonadi::Collection::mimeType() );
d->mListProxy = listProxy;
if ( listProxy ) {
listProxy->setParent( this ); // Make sure the proxy gets deleted when this gets deleted.
listProxy->setSourceModel( d->mItemFilter );
if ( d->mListProxy ) {
d->mListProxy->setParent( this ); // Make sure the proxy gets deleted when this gets deleted.
d->mListProxy->setSourceModel( d->mItemFilter );
}
if ( debugTiming ) {
......@@ -129,8 +130,8 @@ KDeclarativeMainView::KDeclarativeMainView( const QString &appName, ListProxy *l
engine()->rootContext()->setContextProperty( "breadcrumbCollectionsModel", QVariant::fromValue( static_cast<QObject*>( resettingModel ) ) );
engine()->rootContext()->setContextProperty( "childCollectionsModel", QVariant::fromValue( static_cast<QObject*>( d->mBnf->childItemModel() ) ) );
engine()->rootContext()->setContextProperty( "folderSelectionModel", QVariant::fromValue( static_cast<QObject*>( d->mBnf->selectionModel() ) ) );
if ( listProxy )
engine()->rootContext()->setContextProperty( "itemModel", QVariant::fromValue( static_cast<QObject*>( listProxy ) ) );
if ( d->mListProxy )
engine()->rootContext()->setContextProperty( "itemModel", QVariant::fromValue( static_cast<QObject*>( d->mListProxy ) ) );
engine()->rootContext()->setContextProperty( "application", QVariant::fromValue( static_cast<QObject*>( this ) ) );
......@@ -160,7 +161,7 @@ KDeclarativeMainView::KDeclarativeMainView( const QString &appName, ListProxy *l
engine()->rootContext()->setContextProperty( "favoritesList", QVariant::fromValue( static_cast<QObject*>( favsList ) ) );
engine()->rootContext()->setContextProperty( "allFoldersModel", QVariant::fromValue( static_cast<QObject*>( allFoldersModel ) ) );
d->mItemSelectionModel = new QItemSelectionModel( listProxy ? static_cast<QAbstractItemModel *>( listProxy ) : static_cast<QAbstractItemModel *>( d->mItemFilter ), this );
d->mItemSelectionModel = new QItemSelectionModel( d->mListProxy ? static_cast<QAbstractItemModel *>( d->mListProxy ) : static_cast<QAbstractItemModel *>( d->mItemFilter ), this );
if ( debugTiming ) {
......
......@@ -67,6 +67,9 @@ protected:
*/
bool isLoadingSelected();
protected slots:
void delayedInit();
public:
virtual ~KDeclarativeMainView();
......
......@@ -78,6 +78,12 @@ ComposerView::ComposerView(QWidget* parent) :
{
setSubject( QString() );
setAttribute(Qt::WA_DeleteOnClose);
}
void ComposerView::delayedInit()
{
kDebug();
KDeclarativeFullScreenView::delayedInit();
qmlRegisterType<DeclarativeEditor>( "org.kde.messagecomposer", 4, 5, "Editor" );
qmlRegisterType<DeclarativeIdentityComboBox>( "org.kde.kpimidentities", 4, 5, "IdentityComboBox" );
......
......@@ -80,6 +80,9 @@ class ComposerView : public KDeclarativeFullScreenView
void changed();
void busyChanged();
protected slots:
void delayedInit();
private slots:
void qmlLoaded ( QDeclarativeView::Status );
void addAttachment();
......
......@@ -49,6 +49,12 @@
MainView::MainView(QWidget* parent) :
KDeclarativeMainView( QLatin1String( "kmail-mobile" ), new MessageListProxy, parent )
{
}
void MainView::delayedInit()
{
kDebug();
KDeclarativeMainView::delayedInit();
static const bool debugTiming = KCmdLineArgs::parsedArgs()->isSet("timeit");
QTime t;
......
......@@ -53,6 +53,9 @@ class MainView : public KDeclarativeMainView
// HACK until mark-as-read logic is in messageviewer
virtual void setListSelectedRow(int row);
protected slots:
void delayedInit();
private slots:
void replyFetchResult( KJob *job );
void forwardInlineFetchResult( KJob *job );
......
......@@ -40,6 +40,12 @@ using namespace Akonadi;
MainView::MainView( QWidget *parent ) : KDeclarativeMainView( "notes", new NoteListProxy( Akonadi::EntityTreeModel::UserRole ), parent )
{
}
void MainView::delayedInit()
{
KDeclarativeMainView::delayedInit();
addMimeType( "text/x-vnd.akonadi.note" );
itemFetchScope().fetchFullPayload();
}
......
......@@ -43,7 +43,10 @@ class MainView : public KDeclarativeMainView
void startComposer();
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
private:
protected slots:
virtual void delayedInit();
private:
Akonadi::Collection suitableContainerCollection(const QModelIndex &parent = QModelIndex());
};
......
......@@ -3,5 +3,6 @@ install(FILES
delete-button.png
edit-button.png
top.png
splashscreenstatic.png
DESTINATION ${DATA_INSTALL_DIR}/mobileui)
......@@ -39,6 +39,12 @@ using namespace Akonadi;
MainView::MainView( QWidget *parent ) : KDeclarativeMainView( "tasks", new TaskListProxy, parent )
{
}
void MainView::delayedInit()
{
KDeclarativeMainView::delayedInit();
addMimeType( IncidenceMimeTypeVisitor::todoMimeType() );
itemFetchScope().fetchFullPayload();
}
......
......@@ -34,6 +34,9 @@ public slots:
void newTask();
void setPercentComplete(int row, int percentComplete);
void editIncidence( const Akonadi::Item &item );
protected slots:
virtual void delayedInit();
};
#endif // MAINVIEW_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment