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

List:       kde-commits
Subject:    kdenox/konq-embed
From:       Stefan Eilers <stefan.eilers () basyskom ! de>
Date:       2008-05-26 15:48:14
Message-ID: 1211816894.492732.18714.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 812912 by eilers:

Show loading indicator while manually loading images..


 M  +2 -0      ChangeLog  
 M  +9 -2      src/mainwindowbase.cc  
 M  +2 -1      src/mainwindowbase.h  
 M  +0 -1      src/urlcombo.cpp  
 M  +83 -1     src/view.cc  
 M  +20 -3     src/view.h  


--- trunk/kdenox/konq-embed/ChangeLog #812911:812912
@@ -1,3 +1,5 @@
+2008-05-26 Stefan Eilers <stefan.eilers@basyskom.de>
+    * Enable loading inidcator when loading images manually.
 2008-05-23 Stefan Eilers <stefan.eilers@basyskom.de>
     * User entry in URL line edit field will not be destroyed while page is loaded.
 2008-05-21 Stefan Eilers <stefan.eilers@basyskom.de>
--- trunk/kdenox/konq-embed/src/mainwindowbase.cc #812911:812912
@@ -701,7 +701,7 @@
 		    this, SLOT( popupMenu( KHTMLPart *, const QString & ) ) );
 
 	disconnect( this, SIGNAL( loadImages() ),
-		    bview->document(), SLOT( slotLoadImages() ) );
+		    this, SLOT( slotLoadImages() ) );
     }
 
     disconnect( this, SIGNAL( zoomValueSelected( int ) ),
@@ -745,7 +745,7 @@
 		 this, SLOT( popupMenu( KHTMLPart *, const QString & ) ) );
 
 	connect( this, SIGNAL( loadImages() ),
-		 bview->document(), SLOT( slotLoadImages() ) );
+		 this, SLOT( slotLoadImages() ) );
     }
 
     connect( this, SIGNAL( zoomValueSelected( int ) ),
@@ -1466,6 +1466,7 @@
     qDebug( "MainWindowBase::operationCompleted()" );
     if ( ! m_locationCombo )
 	return;
+    
 #ifdef KONQ_GUI_ROAD
     QString url_class_name = m_locationCombo->metaObject()->className();
     qDebug( "url class name: %s", url_class_name.latin1() );
@@ -1477,6 +1478,12 @@
 #endif
 }
 
+// Manually load images.
+void MainWindowBase::slotLoadImages()
+{
+    m_currentView->loadingImages();
+}
+
 /*
 void MainWindowBase::setEncoding( const QString &encoding )
 {
--- trunk/kdenox/konq-embed/src/mainwindowbase.h #812911:812912
@@ -175,7 +175,8 @@
     void findBlinkOff();
     
     void operationCompleted();
-
+    void slotLoadImages();
+    
 signals:
     void zoomValueSelected( int );
 
--- trunk/kdenox/konq-embed/src/urlcombo.cpp #812911:812912
@@ -131,7 +131,6 @@
 void URLCombo::setDirtyFlag( bool dirty )
 {
     qDebug( "URLCombo::setDirtyFlag( %s )", dirty ? "true" : "false" );
-    // if ( dirty == false ) __asm__("int3");
     m_isDirty = dirty;
 }
 
--- trunk/kdenox/konq-embed/src/view.cc #812911:812912
@@ -151,6 +151,11 @@
 	     ( m_part && m_part->actionCollection()->child( name ) ) );
 }
 
+void View::loadingImages()
+{
+    qDebug( "View::loadingImages()" );
+}
+
 void View::openURL( const KURL &url, const QString &/*mimeType*/, const \
KParts::URLArgs &_args )  {
     openURL( url, _args );
@@ -202,7 +207,7 @@
 
 BrowserView::BrowserView( const QString &frameName, QWidget *parentWidget,
 	    const char *widgetName, QObject *parent, const char *name, bool status )
-    : View( parent, name ), m_frameName( frameName ), m_pageSecurity( -1 ), \
m_openedByJS(false) +    : View( parent, name ), m_frameName( frameName ), \
m_pageSecurity( -1 ), m_openedByJS(false), m_manualDocLoader( NULL )  {
     m_history.setAutoDelete( true );
 
@@ -414,6 +419,83 @@
     return m_pageSecurity;
 }
 
+void BrowserView::loadingImages()
+{
+    // Manually load images.
+    m_manuallyImagesLoading.clear(); // FIXME:Sure?
+    
+    m_manualDocLoader = NULL;
+    
+    // Receive signals when documents starts to load and when it finishes..
+    connect( khtml::Cache::loader(), SIGNAL( requestDone( khtml::DocLoader* , \
khtml::CachedObject * ) ), +	     this, SLOT( slotImageLoaded( khtml::DocLoader* , \
khtml::CachedObject * ) ) ); +    connect( khtml::Cache::loader(), SIGNAL( \
requestStarted( khtml::DocLoader*, khtml::CachedObject* ) ), +	     this, SLOT( \
slotStartImageLoad( khtml::DocLoader* , khtml::CachedObject* ) ) ); +    connect( \
this, SIGNAL( startLoadingImagesNow() ), +	     this->document(), SLOT( \
slotLoadImages() ) ); +    connect( &m_manualImageLoadTimer, SIGNAL( timeout() ),
+	      this, SLOT( slotTimeoutImageLoad() ) );
+    
+    // In fact this signal is really useless.. We need it because "slotLoadImages()" \
is private.. +    // Now load images
+    if ( m_stop ) m_stop->setEnabled( true );
+    m_manualImageLoadTimer.start( 1000, true ); // Give up if no images were \
received after a short time. +    emit startLoadingImagesNow();	
+
+}
+
+// Called when an image is started to load ( just if images were loaded manually..
+void BrowserView::slotStartImageLoad( khtml::DocLoader* loader, khtml::CachedObject* \
obj ) +{
+    // HACK: We receive signals from various views simultanously. I don't see any \
way how to detect which +    // images belongs to me. Thus, I save the loader of the \
first received image and use it as filter  +    // for the furture. This should be \
ok, because the signal "slotStartImageLoad()" is not dependent  +    // to any \
loading process. Thus network delays should not have an impact here which may confuse \
the order. +    // If the loading indicator is not stopping, I'm wrong.. (se)
+    if ( !m_manualDocLoader )
+	m_manualDocLoader = loader;
+    
+    if ( m_manualDocLoader != loader ){
+	return; // Signal not for me..
+    }
+    
+    m_manualImageLoadTimer.stop();
+    
+    qDebug( "BrowserView::slotStartImageLoad" );
+    m_manuallyImagesLoading.append( obj );
+}
+
+// Called when image was loaded (just if images were loaded manually)
+void BrowserView::slotImageLoaded( khtml::DocLoader* loader, khtml::CachedObject* \
obj ) +{
+    m_manuallyImagesLoading.remove( obj );
+    
+    // If no images left, stop loading indicator and do some cleanup
+    if ( m_manuallyImagesLoading.isEmpty() )
+    {
+	// Cleanup
+	disconnect( khtml::Cache::loader(), SIGNAL( requestDone( khtml::DocLoader* , \
khtml::CachedObject * ) ), +		    this, SLOT( slotImageLoaded( khtml::DocLoader* , \
khtml::CachedObject * ) ) ); +	disconnect( khtml::Cache::loader(), SIGNAL( \
requestStarted( khtml::DocLoader* dl, khtml::CachedObject* obj ) ), +		    this, \
SLOT( slotStartImageLoad( khtml::DocLoader* , khtml::CachedObject * ) ) ); \
+	disconnect( this, SIGNAL( startLoadingImagesNow() ), +		      this->document(), \
SLOT( slotLoadImages() ) ); +	disconnect( &m_manualImageLoadTimer, SIGNAL( timeout() \
), +		  this, SLOT( slotTimeoutImageLoad() ) );
+
+
+	m_manualDocLoader = NULL;
+	if ( m_stop ) m_stop->setEnabled( false );
+	if ( m_collection.action( "view_autoload_images" )  )  m_collection.action( \
"view_autoload_images" )->setEnabled( false ); +    }
+}
+
+void BrowserView::slotTimeoutImageLoad()
+{
+    qDebug( "BrowserView::slotTimeoutImageLoad()" );
+    if ( m_stop ) m_stop->setEnabled( false );
+}
+
 void BrowserView::runError()
 {
     setLocationBarURL( m_oldLocationBarURL );
--- trunk/kdenox/konq-embed/src/view.h #812911:812912
@@ -89,6 +89,8 @@
     bool localVisible( const char *name ) { return m_collection.child( name ); }
 
     bool itemVisible( const char *name );
+    
+    virtual void loadingImages();
 
 public slots:
     virtual void openURL( const KURL &url, const KParts::URLArgs &args = \
KParts::URLArgs() ); @@ -117,6 +119,8 @@
     void actionChanged( const char * );
     
     void operationCompleted();
+    
+    void startLoadingImagesNow();
 
 protected slots:
     void setLocationBarURL( const QString &url );
@@ -138,14 +142,14 @@
     int m_zoom;
 
     bool m_status;
+    
+    KActionCollection m_collection;
 
 private:
     QString m_caption;
 
     QString m_sbtext;
 
-    KActionCollection m_collection;
-
     QString m_findText;
 };
 
@@ -192,6 +196,8 @@
     bool openedByJS() { return m_openedByJS; }
     void setOpenedByJS(bool opened) { m_openedByJS = opened; }
 
+    void loadingImages();
+    
     static QStringList childFrameNames( KParts::ReadOnlyPart *part );
 
     static KParts::BrowserHostExtension *hostExtension( KParts::ReadOnlyPart *part, \
const QString &name ); @@ -203,7 +209,7 @@
     static bool showStatusBar;
 
     static int zoomFactor;
-
+    
 public slots:
     virtual void openURL( const KURL &url, const KParts::URLArgs &args = \
KParts::URLArgs() );  
@@ -237,7 +243,12 @@
     void openURLNotify();
 
     void setPageSecurity( int );
+    
+    void slotStartImageLoad( khtml::DocLoader* , khtml::CachedObject * );
+    void slotImageLoaded( khtml::DocLoader* , khtml::CachedObject * );
+    void slotTimeoutImageLoad();
 
+
 protected:
     HTMLView *m_doc;
 
@@ -275,6 +286,12 @@
     int m_pageSecurity;
 
     bool m_openedByJS;
+    
+        
+    // Stores the pointer of images which are currently loaded manually
+    QValueList<khtml::CachedObject*> m_manuallyImagesLoading; 
+    khtml::DocLoader* m_manualDocLoader;
+    QTimer m_manualImageLoadTimer;
 };
 
 #endif


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

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