[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kget/kget_plug_in
From: Pino Toscano <toscano.pino () tiscali ! it>
Date: 2005-07-17 22:44:11
Message-ID: 1121640251.435737.27231.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 435719 by pino:
Backport some changes from the make_kget_cool branch for the konqueror plugin:
* Slightly improved toolbar, which has text left to icon by default, and a
Select All button to easily select all the links from the list
* The plugin can do its job even if the konqueror window from where the user
opened the KGet window is closed
* a bit of cleanup and indentation fixes
M +51 -19 kget_linkview.cpp
M +1 -1 kget_linkview.h
M +7 -26 kget_plug_in.cpp
M +0 -1 kget_plug_in.h
M +8 -10 kget_plug_in.rc
--- trunk/KDE/kdenetwork/kget/kget_plug_in/kget_linkview.cpp #435718:435719
@@ -1,11 +1,15 @@
+#include "kget_linkview.h"
+
+#include <dcopclient.h>
#include <kaction.h>
+#include <kapplication.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kstdaction.h>
#include <ktoolbar.h>
-#include "kget_linkview.h"
-
#define COL_NAME 0
#define COL_DESC 1
#define COL_MIME 2
@@ -35,26 +39,19 @@
{
setPlainCaption( i18n( "KGet" ) );
- KActionCollection *coll = actionCollection();
+ KAction* actionDownload = new KAction( i18n("Download Selected Files"),
+ "khtml_kget", CTRL+Key_D,
+ this, SLOT( slotStartLeech() ),
+ actionCollection(), "startDownload" );
- (void ) new KAction( i18n("Download Selected Files"),
- "khtml_kget",
- CTRL+Key_D,
- this, SLOT( slotStartLeech() ),
- actionCollection(), "startDownload" );
+ KAction* actionSelectAll = KStdAction::selectAll( this, SLOT( slotSelectAll() ),
+ actionCollection() );
m_links.setAutoDelete( true );
- coll->action( "startDownload" )->plug( toolBar() );
+ actionDownload->plug( toolBar() );
+ toolBar()->insertLineSeparator();
+ actionSelectAll->plug( toolBar() );
- initView();
-}
-
-KGetLinkView::~KGetLinkView()
-{
-}
-
-void KGetLinkView::initView()
-{
m_view = new KListView( this, "listview" );
m_view->setSelectionMode( QListView::Extended );
m_view->addColumn( i18n("File Name") );
@@ -64,8 +61,17 @@
m_view->setShowSortIndicator( true );
setCentralWidget( m_view );
+
+ // setting a fixed (not floating) toolbar
+ toolBar()->setMovingEnabled( false );
+ // setting Text next to Icons
+ toolBar()->setIconText( KToolBar::IconTextRight );
}
+KGetLinkView::~KGetLinkView()
+{
+}
+
void KGetLinkView::setLinks( QPtrList<LinkItem>& links )
{
m_links = links; // now we 0wn them
@@ -98,7 +104,28 @@
i18n("You did not select any files to download."),
i18n("No Files Selected") );
else
- emit leechURLs( urls );
+ {
+ DCOPClient* p_dcopServer = new DCOPClient();
+ p_dcopServer->attach();
+
+ if ( !p_dcopServer->isApplicationRegistered( "kget" ) )
+ {
+ KApplication::startServiceByDesktopName( "kget" );
+ }
+ kapp->updateRemoteUserTimestamp( "kget" );
+
+ QByteArray data;
+ QDataStream stream( data, IO_WriteOnly );
+ stream << urls << QString::null;
+ bool ok = DCOPClient::mainClient()->send( "kget", "KGet-Interface",
+ "addTransfers(KURL::List, QString)",
+ data );
+
+ kdDebug() << "*** startDownload: " << ok << endl;
+
+ p_dcopServer->detach();
+ delete p_dcopServer;
+ }
}
void KGetLinkView::setPageURL( const QString& url )
@@ -106,4 +133,9 @@
setPlainCaption( i18n( "Links in: %1 - KGet" ).arg( url ) );
}
+void KGetLinkView::slotSelectAll()
+{
+ m_view->selectAll( true );
+}
+
#include "kget_linkview.moc"
--- trunk/KDE/kdenetwork/kget/kget_plug_in/kget_linkview.h #435718:435719
@@ -40,9 +40,9 @@
private slots:
void slotStartLeech();
+ void slotSelectAll();
private:
- void initView();
void showLinks( const QPtrList<LinkItem>& links );
QPtrList<LinkItem> m_links;
--- trunk/KDE/kdenetwork/kget/kget_plug_in/kget_plug_in.cpp #435718:435719
@@ -18,11 +18,9 @@
* *
***************************************************************************/
-#include <kdatastream.h>
#include "kget_plug_in.h"
#include <dcopref.h>
-#include <kapplication.h>
#include <kdatastream.h>
#include <kdebug.h>
#include <khtml_part.h>
@@ -52,7 +50,7 @@
QPixmap pix = KGlobal::iconLoader()->loadIcon("khtml_kget",
KIcon::MainToolbar);
KActionMenu *menu = new KActionMenu( i18n("Download Manager"), pix,
- actionCollection(), "kget_menu" );
+ actionCollection(), "kget_menu" );
menu->setDelayed( false );
connect( menu->popupMenu(), SIGNAL( aboutToShow() ), SLOT( showPopup() ));
@@ -60,7 +58,7 @@
KShortcut(),
this, SLOT(slotShowDrop()),
actionCollection(), "show_drop" );
- m_paToggleDropTarget->setCheckedState(i18n("Hide Drop Target"));
+
menu->insert( m_paToggleDropTarget );
KAction *action = new KAction(i18n("List All Links"), KShortcut(),
@@ -154,30 +152,11 @@
KGetLinkView *view = new KGetLinkView();
QString url = doc.URL().string();
view->setPageURL( url );
- connect( view, SIGNAL( leechURLs( const KURL::List& ) ),
- SLOT( startDownload( const KURL::List& ) ));
view->setLinks( linkList );
view->show();
}
-void KGet_plug_in::startDownload( const KURL::List& urls )
-{
- if (!p_dcopServer->isApplicationRegistered ("kget")) {
- KApplication::startServiceByDesktopName("kget");
- }
-
- kapp->updateRemoteUserTimestamp("kget");
- QByteArray data;
- QDataStream stream( data, IO_WriteOnly );
- stream << urls << QString::null;
- bool ok = DCOPClient::mainClient()->send( "kget", "KGet-Interface",
- "addTransfers(KURL::List, QString)",
- data );
-
- kdDebug() << "*** startDownload: " << ok << endl;
-}
-
KPluginFactory::KPluginFactory( QObject* parent, const char* name )
: KLibFactory( parent, name )
{
@@ -189,15 +168,17 @@
QObject *obj = new KGet_plug_in( parent, name );
return obj;
}
+
KPluginFactory::~KPluginFactory()
-{ delete s_instance; }
+{
+ delete s_instance;
+}
-
extern "C"
{
KDE_EXPORT void* init_khtml_kget()
{
- KGlobal::locale()->insertCatalogue("kget");
+ KGlobal::locale()->insertCatalogue("kget");
return new KPluginFactory;
}
--- trunk/KDE/kdenetwork/kget/kget_plug_in/kget_plug_in.h #435718:435719
@@ -37,7 +37,6 @@
void slotShowDrop();
void slotShowLinks();
void showPopup();
- void startDownload( const KURL::List& urls );
};
--- trunk/KDE/kdenetwork/kget/kget_plug_in/kget_plug_in.rc #435718:435719
@@ -1,13 +1,11 @@
<!DOCTYPE kpartgui>
<kpartgui library="khtml_kget" name="khtml_kget" version="3" >
- <MenuBar>
- <Menu name="tools">
- <Text>&Tools</Text>
-<Action name="kget_menu"/>
- </Menu>
- </MenuBar>
- <ToolBar name="mainToolBar">
- <Action name="kget_menu"/>
- </ToolBar>
+<MenuBar>
+ <Menu name="tools"><Text>&Tools</Text>
+ <Action name="kget_menu"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="mainToolBar">
+ <Action name="kget_menu"/>
+</ToolBar>
</kpartgui>
-
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic