I hope this is the right list for this, as I saw in the archives there was 
already some talk about the applet. 

I have a habit (started by the same plasmoid) of going through comic from the 
first one to the last one. I found it annoying having to wait for the next 
strip to load, while most of the time I was reading and the network was free. 
So I implemented a very simeple prefetching technique: When a strip is loaded, 
the next one is requested from the engine. Since the engine uses caching, it is 
immediately available upon pressing the "next" arrow.

I found if very useful and even included a patch for it against today's trunk. 
I know the compilation is in some kind of a freeze so this may not be a good 
time, but it might be useful to have in the next release. 
Index: comic.h
===================================================================
--- comic.h	(revision 1070107)
+++ comic.h	(working copy)
@@ -136,6 +136,7 @@ class ComicApplet : public Plasma::Popup
         void slotStorePosition();
         void slotSizeChanged();
         void slotShowMaxSize();
+	void slotSetPrefetch();
         void applyConfig();
         void checkDayChanged();
         void buttonBar();
@@ -186,6 +187,7 @@ class ComicApplet : public Plasma::Popup
         bool mShowComicIdentifier;
         bool mArrowsOnHover;
         bool mMiddleClick;
+	bool mPrefetch;
         QTimer *mDateChangedTimer;
         QTimer *mReloadTimer;
         QList<QAction*> mActions;
@@ -197,6 +199,7 @@ class ComicApplet : public Plasma::Popup
         QAction *mActionScaleContent;
         QAction *mActionShop;
         QAction *mActionStorePosition;
+	QAction *mActionPrefetchNext;
         QMap< QString, int > mFirstStripNum;
         QMap< QString, int > mMaxStripNum;
         QSizeF mMaxSize;
Index: comic.cpp
===================================================================
--- comic.cpp	(revision 1070107)
+++ comic.cpp	(working copy)
@@ -191,6 +191,12 @@ void ComicApplet::init()
     mActions.append( mActionStorePosition );
     connect( mActionStorePosition, SIGNAL( triggered( bool ) ), this, SLOT( slotStorePosition() ) );
 
+    mActionPrefetchNext = new QAction( i18nc( "@option:check Context menu of comic image", "Pre&fetch next Strip" ), this );
+    mActionPrefetchNext->setCheckable( true );
+    mActionPrefetchNext->setChecked( mPrefetch );
+    mActions.append( mActionPrefetchNext );
+    connect( mActionPrefetchNext, SIGNAL( triggered( bool ) ), this, SLOT( slotSetPrefetch() ) );
+    
     updateTabBar();
     changeComic( true );
 }
@@ -381,6 +387,10 @@ void ComicApplet::dataUpdated( const QSt
     }
     Plasma::ToolTipManager::self()->setContent( this, toolTipData );
 
+    if ( mPrefetch && !mNextIdentifierSuffix.isEmpty()) {
+	mEngine->query(mComicIdentifier + ':' + mNextIdentifierSuffix);
+    }
+    
     if ( !mImage.isNull() ) {
         QTimer::singleShot( 1, this, SLOT( updateSize()) );//HACK
     }
@@ -514,6 +524,7 @@ void ComicApplet::loadConfig()
     mSwitchTabs = cg.readEntry( "switchTabs", false );
     mSavingDir = cg.readEntry( "savingDir", QString() );
     mOldSource = mComicIdentifier + ':' + mStoredIdentifierSuffix;
+    mPrefetch = cg.readEntry( "autoPrefetch", true );
 
     buttonBar();
 }
@@ -535,6 +546,7 @@ void ComicApplet::saveConfig()
     cg.writeEntry( "useTabs", mUseTabs );
     cg.writeEntry( "switchTabs", mSwitchTabs );
     cg.writeEntry( "savingDir", mSavingDir );
+    cg.writeEntry( "autoPrefetch", mPrefetch );
 }
 
 void ComicApplet::slotChosenDay( const QDate &date )
@@ -934,6 +946,11 @@ void ComicApplet::slotScaleToContent()
     updateSize();
 }
 
+void ComicApplet::slotSetPrefetch()
+{
+    mPrefetch = mActionPrefetchNext->isChecked();
+}
+
 void ComicApplet::buttonBar()
 {
     if ( mArrowsOnHover ) {
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to