diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch) | |
tree | 2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /konq-plugins/sidebar | |
download | tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konq-plugins/sidebar')
103 files changed, 9823 insertions, 0 deletions
diff --git a/konq-plugins/sidebar/Makefile.am b/konq-plugins/sidebar/Makefile.am new file mode 100644 index 0000000..165352a --- /dev/null +++ b/konq-plugins/sidebar/Makefile.am @@ -0,0 +1,5 @@ +if include_ARTS +mediaplayer_subdir = mediaplayer +endif + +SUBDIRS = $(mediaplayer_subdir) newsticker delicious metabar diff --git a/konq-plugins/sidebar/delicious/Makefile.am b/konq-plugins/sidebar/delicious/Makefile.am new file mode 100644 index 0000000..cb8eb48 --- /dev/null +++ b/konq-plugins/sidebar/delicious/Makefile.am @@ -0,0 +1,22 @@ +SUBDIRS = . pics + +METASOURCES = AUTO +INCLUDES = -I$(kde_includes)/kio $(all_includes) + +################################ +# these are the headers for your project +noinst_HEADERS = plugin.h mainWidget.h tagListItem.h bookmarkListItem.h + +kde_module_LTLIBRARIES = konqsidebar_delicious.la + +# the Part's source, library search path, and link libraries +konqsidebar_delicious_la_SOURCES = plugin.cpp widget.ui mainWidget.cpp plugin.skel tagListItem.cpp \ + bookmarkListItem.cpp +konqsidebar_delicious_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +konqsidebar_delicious_la_LIBADD = $(LIB_KPARTS) $(LIB_KIO) -lkonqsidebarplugin + +globaladddir = $(kde_datadir)/konqsidebartng/add +globaladd_DATA = delicious_add.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/konqsidebar_delicious.pot diff --git a/konq-plugins/sidebar/delicious/bookmarkListItem.cpp b/konq-plugins/sidebar/delicious/bookmarkListItem.cpp new file mode 100644 index 0000000..f4bd8f5 --- /dev/null +++ b/konq-plugins/sidebar/delicious/bookmarkListItem.cpp @@ -0,0 +1,72 @@ +////////////////////////////////////////////////////////////////////////// +// bookmarkListItem.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "bookmarkListItem.h" + +#include <kglobal.h> +#include <klocale.h> + +BookmarkListItem::BookmarkListItem( QListView *parent, const QString & url, const QString & desc, time_t time ) + : KListViewItem( parent ), m_desc( desc ) +{ + m_url = KURL::fromPathOrURL( url ); + m_dateTime.setTime_t( time ); +} + +int BookmarkListItem::compare( QListViewItem * i, int col, bool ascending ) const +{ + if ( col == 1 ) + { + QDateTime them = static_cast<BookmarkListItem *>( i )->date(); + if ( m_dateTime < them ) + return -1; + else if ( m_dateTime > them ) + return 1; + else + return 0; + } + return QListViewItem::compare( i, col, ascending ); +} + +QString BookmarkListItem::text( int column ) const +{ + if ( column == 0 ) + return m_desc; + else if ( column == 1 ) + return KGlobal::locale()->formatDateTime( m_dateTime ); + + return QString::null; +} + +KURL BookmarkListItem::url() const +{ + return m_url; +} + +QDateTime BookmarkListItem::date() const +{ + return m_dateTime; +} + +QString BookmarkListItem::desc() const +{ + return m_desc; +} diff --git a/konq-plugins/sidebar/delicious/bookmarkListItem.h b/konq-plugins/sidebar/delicious/bookmarkListItem.h new file mode 100644 index 0000000..9188fcd --- /dev/null +++ b/konq-plugins/sidebar/delicious/bookmarkListItem.h @@ -0,0 +1,51 @@ +////////////////////////////////////////////////////////////////////////// +// bookmarkListItem.h // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _BOOKMARKLISTITEM_H_ +#define _BOOKMARKLISTITEM_H_ + +#include <qdatetime.h> + +#include <klistview.h> +#include <kurl.h> + +#include <time.h> + +class QString; + +class BookmarkListItem: public KListViewItem +{ +public: + BookmarkListItem( QListView *parent, const QString & url, const QString & desc, time_t time ); + KURL url() const; + QDateTime date() const; + QString desc() const; + +protected: + virtual int compare( QListViewItem * i, int col, bool ascending ) const; + virtual QString text( int column ) const; + + KURL m_url; + QString m_desc; + QDateTime m_dateTime; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/delicious_add.desktop b/konq-plugins/sidebar/delicious/delicious_add.desktop new file mode 100644 index 0000000..b2e3e07 --- /dev/null +++ b/konq-plugins/sidebar/delicious/delicious_add.desktop @@ -0,0 +1,57 @@ +[Desktop Entry] +Type=Link +URL= +Icon=konqsidebar_delicious +Name=del.icio.us Bookmarks +Name[bg]=Отметки del.icio.us +Name[br]=Sinedoù del.icio.us +Name[ca]=Punts del.icio.us +Name[cs]=del.icio.us záložky +Name[da]=del.icio.us Bogmærker +Name[de]=Lesezeichen von del.icio.us +Name[el]=Σελιδοδείκτες del.icio.us +Name[eo]=del.icio.us legosignoj +Name[es]=Marcadores del.icio.us +Name[et]=del.icio.us järjehoidjad +Name[eu]=del.icio.us laster-markak +Name[fa]=چوب الفهای del.icio.us +Name[fi]=del.icio.us kirjanmerkit +Name[fr]=Signets del.icio.us +Name[fy]=del.icio.us-blêdwizers +Name[ga]=Leabharmharcanna del.icio.us +Name[gl]=Favoritos del.icio.us +Name[he]=סימניות של del.icio.us +Name[hr]=del.icio.us oznake +Name[hu]=Del.icio.us könyvjelzők +Name[is]=del.icio.us bókamerki +Name[it]=Segnalibri di del.icio.us +Name[ja]=del.icio.us ブックマーク +Name[ka]=del.icio.us სანიშნეები +Name[kk]=del.icio.us бетбелгілері +Name[km]=ចំណាំ del.icio.us +Name[lt]=del.icio.us žymelės +Name[mk]=Обележувачи за del.icio.us +Name[nb]=del.icio.us bokmerker +Name[nds]="del.icio.us"-Leestekens +Name[ne]=del.icio.us पुस्तकचिनोहरू +Name[nl]=del.icio.us-bladwijzers +Name[nn]=del.icio.us-bokmerke +Name[pa]=del.icio.us ਬੁੱਕਮਾਰਕ +Name[pl]=Zakładki del.icio.us +Name[pt]=Favoritos del.icio.us +Name[pt_BR]=Favorito do del.icio.us +Name[ru]=Закладки del.icio.us +Name[sk]=del.icio.us záložky +Name[sl]=Zaznamki del.icio.us +Name[sr]=ук.ус.ни маркери +Name[sr@Latn]=uk.us.ni markeri +Name[sv]=del.icio.us bokmärken +Name[tr]=del.icio.us Yer İmleri +Name[uk]=Закладки del.icio.us +Name[uz]=del.icio.us xatchoʻplari +Name[uz@cyrillic]=del.icio.us хатчўплари +Name[vi]=Dấu nhớ del.icio.us +Name[zh_CN]=del.icio.us 书签 +Open=false +X-KDE-KonqSidebarAddModule=konqsidebar_delicious +X-KDE-KonqSidebarUniversal=true diff --git a/konq-plugins/sidebar/delicious/mainWidget.cpp b/konq-plugins/sidebar/delicious/mainWidget.cpp new file mode 100644 index 0000000..759e348 --- /dev/null +++ b/konq-plugins/sidebar/delicious/mainWidget.cpp @@ -0,0 +1,354 @@ +// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +////////////////////////////////////////////////////////////////////////// +// mainWidget.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "mainWidget.h" +#include "tagListItem.h" +#include "bookmarkListItem.h" + +#include <qlistview.h> +#include <qdom.h> +#include <qpopupmenu.h> +#include <qpushbutton.h> +#include <qtimer.h> +#include <qdatetime.h> + +#include <kdebug.h> +#include <kio/job.h> +#include <krfcdate.h> +#include <klistview.h> +#include <klocale.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <kconfig.h> +#include <kinputdialog.h> + +MainWidget::MainWidget( KConfig * config, QWidget * parent ) + : MainWidget_base( parent ), m_config( config ) +{ + loadTags(); + + KIconLoader * il = KGlobal::iconLoader(); + + btnRefreshTags->setIconSet( il->loadIconSet( "reload", KIcon::Small ) ); + btnRefreshBookmarks->setIconSet( il->loadIconSet( "reload", KIcon::Small ) ); + btnNew->setIconSet( il->loadIconSet( "bookmark_add", KIcon::Small ) ); + + connect( ( QWidget * ) btnRefreshTags, SIGNAL( clicked() ), + this, SLOT( slotGetTags() ) ); + + connect( ( QWidget * ) btnRefreshBookmarks, SIGNAL( clicked() ), + this, SLOT( slotGetBookmarks() ) ); + + connect( ( QWidget * ) btnNew, SIGNAL( clicked() ), + this, SLOT( slotNewBookmark() ) ); + + connect( lvBookmarks, SIGNAL( executed( QListViewItem * ) ), + this, SLOT( slotBookmarkExecuted( QListViewItem * ) ) ); + connect( lvBookmarks, SIGNAL( mouseButtonClicked ( int, QListViewItem *, const QPoint &, int ) ), + this, SLOT( slotBookmarkClicked( int, QListViewItem *, const QPoint &, int ) ) ); + + connect( lvTags, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint &, int ) ), + this, SLOT( slotTagsContextMenu( QListViewItem *, const QPoint &, int ) ) ); + + connect( lvBookmarks, SIGNAL( contextMenuRequested( QListViewItem *, const QPoint &, int ) ), + this, SLOT( slotBookmarksContextMenu( QListViewItem *, const QPoint &, int ) ) ); + + m_updateTimer = new QTimer( this ); + connect( m_updateTimer, SIGNAL( timeout() ), SLOT( slotGetBookmarks() ) ); + + slotGetTags(); +} + +MainWidget::~MainWidget() +{ + saveTags(); +} + +void MainWidget::setCurrentURL( const KURL & url ) +{ + m_currentURL = url; +} + +void MainWidget::slotGetTags() +{ + kdDebug() << k_funcinfo << endl; + + KIO::StoredTransferJob * job = KIO::storedGet( "http://del.icio.us/api/tags/get" ); + connect( job, SIGNAL( result( KIO::Job * ) ), + this, SLOT( slotFillTags( KIO::Job * ) ) ); +} + +void MainWidget::slotFillTags( KIO::Job * job ) +{ + kdDebug() << k_funcinfo << endl; + + if ( job->error() ) + { + job->showErrorDialog( this ); + return; + } + + lvTags->clear(); + m_tags.clear(); + + // fill lvTags with job->data() + QDomDocument doc; + doc.setContent( static_cast<KIO::StoredTransferJob *>( job )->data() ); + QDomNodeList tags = doc.elementsByTagName( "tag" ); + for ( uint i = 0; i < tags.length(); ++i ) + { + QDomElement tag = tags.item( i ).toElement(); + if ( !tag.isNull() ) + { + TagListItem *item = new TagListItem( lvTags, tag.attribute( "tag" ), tag.attribute( "count" ).toInt() ); + m_tags.append( tag.attribute( "tag" ) ); + connect( item, SIGNAL( signalItemChecked( TagListItem * ) ), SLOT( itemToggled() ) ); + } + } +} + +void MainWidget::slotGetBookmarks() +{ + KURL url( "http://del.icio.us/api/posts/recent" ); + url.setQuery( "tag=" + checkedTags().join( " " ) ); + + kdDebug() << k_funcinfo << url.url() << endl; + + KIO::StoredTransferJob * job = KIO::storedGet( url ); + connect( job, SIGNAL( result( KIO::Job * ) ), + this, SLOT( slotFillBookmarks( KIO::Job * ) ) ); +} + +void MainWidget::slotFillBookmarks( KIO::Job * job ) +{ + kdDebug() << k_funcinfo << endl; + + if ( job->error() ) + { + job->showErrorDialog( this ); + return; + } + + lvBookmarks->clear(); + + // fill lvBookmarks with job->data() + QDomDocument doc; + doc.setContent( static_cast<KIO::StoredTransferJob *>( job )->data() ); + QDomNodeList posts = doc.elementsByTagName( "post" ); + + for ( uint i = 0; i < posts.length(); ++i ) + { + QDomElement post = posts.item( i ).toElement(); + if ( !post.isNull() ) + { + new BookmarkListItem( lvBookmarks, post.attribute( "href" ), post.attribute( "description" ), + KRFCDate::parseDateISO8601( post.attribute( "time" ) ) ); + } + } +} + +QStringList MainWidget::checkedTags() const +{ + QListViewItemIterator it( lvTags, QListViewItemIterator::Visible | QListViewItemIterator::Checked ); + + QStringList tmp; + + while ( it.current() ) + { + tmp.append( it.current()->text( 0 ) ); + ++it; + } + + return tmp; +} + +void MainWidget::slotBookmarkExecuted( QListViewItem * item ) +{ + BookmarkListItem * bookmark = static_cast<BookmarkListItem *>( item ); + if ( bookmark ) + { + kdDebug() << k_funcinfo << "Clicked bookmark URL: " << bookmark->url() << endl; + emit signalURLClicked( bookmark->url() ); + } +} + +void MainWidget::slotBookmarkClicked( int button, QListViewItem * item, const QPoint &, int ) +{ + BookmarkListItem * bookmark = static_cast<BookmarkListItem *>( item ); + if ( bookmark && button == Qt::MidButton ) // handle middle click + { + kdDebug() << k_funcinfo << "Middle clicked bookmark URL: " << bookmark->url() << endl; + emit signalURLMidClicked( bookmark->url() ); + } +} + +QStringList MainWidget::tags() const +{ + return m_tags; +} + +QStringList MainWidget::bookmarks() const +{ + QListViewItemIterator it( lvBookmarks ); + + QStringList tmp; + + while ( it.current() ) + { + tmp.append( static_cast<BookmarkListItem *>( it.current() )->url().url() ); + ++it; + } + + return tmp; +} + +void MainWidget::slotTagsContextMenu( QListViewItem *, const QPoint & pos, int ) +{ + if ( lvTags->childCount() == 0 ) + return; + + QPopupMenu * tagMenu = new QPopupMenu( this ); + Q_CHECK_PTR( tagMenu ); + + tagMenu->insertItem( i18n( "Check All" ), this, SLOT( slotCheckAllTags() ) ); + tagMenu->insertItem( i18n( "Uncheck All" ), this, SLOT( slotUncheckAllTags() ) ); + tagMenu->insertItem( i18n( "Toggle All" ), this, SLOT( slotToggleTags() ) ); + tagMenu->insertSeparator(); + tagMenu->insertItem( KGlobal::iconLoader()->loadIconSet( "edit", KIcon::Small ), + i18n( "Rename Tag..." ), this, SLOT( slotRenameTag() ) ); + + tagMenu->exec( pos ); +} + +void MainWidget::slotCheckAllTags() +{ + QListViewItemIterator it( lvTags ); + while ( it.current() ) + { + QCheckListItem * item = static_cast<QCheckListItem *>( *it ); + if ( item ) + item->setOn( true ); + ++it; + } +} + +void MainWidget::slotUncheckAllTags() +{ + QListViewItemIterator it( lvTags ); + while ( it.current() ) + { + QCheckListItem * item = static_cast<QCheckListItem *>( *it ); + if ( item ) + item->setOn( false ); + ++it; + } +} + +void MainWidget::slotToggleTags() +{ + QListViewItemIterator it( lvTags ); + while ( it.current() ) + { + QCheckListItem * item = static_cast<QCheckListItem *>( *it ); + if ( item ) + item->setOn( !item->isOn() ); + ++it; + } +} + +void MainWidget::itemToggled() +{ + m_updateTimer->start( 2000, true ); +} + +void MainWidget::slotNewBookmark() +{ + emit signalURLClicked( "http://del.icio.us/post/?url=" + m_currentURL.url() ); +} + +void MainWidget::saveTags() +{ + m_config->writeEntry( "Tags", m_tags ); +} + +void MainWidget::loadTags() +{ + m_tags = m_config->readListEntry( "Tags" ); +} + +void MainWidget::slotRenameTag() +{ + TagListItem * tag = static_cast<TagListItem *>( lvTags->currentItem() ); + if ( tag ) + { + QString oldName = tag->name(); + QString newName = KInputDialog::getText( i18n( "Rename Tag" ), i18n( "Provide a new name for tag '%1':" ).arg( oldName ) ); + if ( !newName.isEmpty() ) + { + KURL url( "http://del.icio.us/api/tags/rename" ); + url.addQueryItem( "old", oldName ); + url.addQueryItem( "new", newName ); + KIO::get( url ); // rename the tag + + tag->setName( newName ); + } + } +} + +void MainWidget::slotBookmarksContextMenu( QListViewItem *, const QPoint & pos, int ) +{ + if ( lvBookmarks->childCount() == 0 ) + return; + + QPopupMenu * menu = new QPopupMenu( this ); + Q_CHECK_PTR( menu ); + + menu->insertItem( KGlobal::iconLoader()->loadIconSet( "editdelete", KIcon::Small ), + i18n( "Delete Bookmark" ), this, SLOT( slotDeleteBookmark() ) ); + + menu->exec( pos ); +} + +void MainWidget::slotDeleteBookmark() +{ + BookmarkListItem * bookmark = static_cast<BookmarkListItem *>( lvBookmarks->currentItem() ); + if ( bookmark ) + { + int result = KMessageBox::warningContinueCancel( this, i18n( "Do you really want to remove the bookmark\n%1?" ).arg( bookmark->desc() ), + i18n( "Delete Bookmark" ), KStdGuiItem::del() ); + + if ( result == KMessageBox::Continue ) + { + KURL url( "http://del.icio.us/api/posts/delete" ); + url.addQueryItem( "url", bookmark->url().url() ); + kdDebug() << k_funcinfo << url << endl; + KIO::get( url ); + + delete bookmark; + + slotGetTags(); // re-read the tags + } + } +} + +#include "mainWidget.moc" diff --git a/konq-plugins/sidebar/delicious/mainWidget.h b/konq-plugins/sidebar/delicious/mainWidget.h new file mode 100644 index 0000000..5970524 --- /dev/null +++ b/konq-plugins/sidebar/delicious/mainWidget.h @@ -0,0 +1,175 @@ +// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*- +////////////////////////////////////////////////////////////////////////// +// mainWidget.h // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _MAINWIDGET_H_ +#define _MAINWIDGET_H_ + +#include "widget.h" + +#include <kio/jobclasses.h> +#include <kparts/browserextension.h> + +class QStringList; +class KURL; +class KConfig; + +/** + * Main widget of the del.icio.us bookmarks panel + */ +class MainWidget: public MainWidget_base +{ + Q_OBJECT +public: + MainWidget( KConfig * config, QWidget * parent ); + ~MainWidget(); + + /** + * @return all the tags user has + * (used in the DCOP iface) + */ + QStringList tags() const; + + /** + * @return all the (currently visible) bookmark (URLs) + * (used in the DCOP iface) + */ + QStringList bookmarks() const; + + /** + * Set the internal URL to @p url + */ + void setCurrentURL( const KURL & url ); + +public slots: + /** + * Show a dialog for adding a new bookmark + */ + void slotNewBookmark(); + +private slots: + /** + * Start the job to get the list of tags + */ + void slotGetTags(); + + /** + * Fill the Tags listview with job->data() + * (parses the XML returned by the server) + */ + void slotFillTags( KIO::Job * job ); + + /** + * Start the job to get the list of bookmarks + * for checked tags + */ + void slotGetBookmarks(); + + /** + * Fill the Bookmarks listview with job->data() + * (parses the XML returned by the server) + */ + void slotFillBookmarks( KIO::Job * job ); + + /** + * Handle clicking on a bookmark (KDE mode) + */ + void slotBookmarkExecuted( QListViewItem * item ); + + /** + * Handle middle clicking a bookmark + */ + void slotBookmarkClicked( int button, QListViewItem * item, const QPoint & pnt, int col ); + + /** + * Popup a tag context menu over @p item and position @pos + */ + void slotTagsContextMenu( QListViewItem * item, const QPoint & pos, int col ); + + /** + * Popup a bookmark context menu over @p item and position @pos + */ + void slotBookmarksContextMenu( QListViewItem * item, const QPoint & pos, int col ); + + /** + * Put a checkmark before all tags + */ + void slotCheckAllTags(); + + /** + * Cancel the checkmark before all tags + */ + void slotUncheckAllTags(); + + /** + * Toggle the checkmark before all tags + */ + void slotToggleTags(); + + /** + * Starts a singleshot timer once an item (tag) has been toggled. Timer will update bookmarks. + */ + void itemToggled(); + + /** + * Display a dialog box that allows renaming of tags + */ + void slotRenameTag(); + + /** + * Delete the selected bookmark + */ + void slotDeleteBookmark(); + +signals: + /** + * Emit a signal to the plugin interface that a @p url has been left-clicked + */ + void signalURLClicked( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + + /** + * Emit a signal to the plugin interface that a @p url has been mid-clicked + */ + void signalURLMidClicked( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + +private: + /** + * @return list of checked tags + */ + QStringList checkedTags() const; + + /** + * Save the tag list to the config file + */ + void saveTags(); + + /** + * Load the tag list from the config file + */ + void loadTags(); + + QTimer *m_updateTimer; + KURL m_currentURL; + QStringList m_tags; + KConfig * m_config; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/pics/Makefile.am b/konq-plugins/sidebar/delicious/pics/Makefile.am new file mode 100644 index 0000000..e5515a8 --- /dev/null +++ b/konq-plugins/sidebar/delicious/pics/Makefile.am @@ -0,0 +1 @@ +KDE_ICON = AUTO diff --git a/konq-plugins/sidebar/delicious/pics/cr16-app-konqsidebar_delicious.png b/konq-plugins/sidebar/delicious/pics/cr16-app-konqsidebar_delicious.png Binary files differnew file mode 100644 index 0000000..f28df92 --- /dev/null +++ b/konq-plugins/sidebar/delicious/pics/cr16-app-konqsidebar_delicious.png diff --git a/konq-plugins/sidebar/delicious/plugin.cpp b/konq-plugins/sidebar/delicious/plugin.cpp new file mode 100644 index 0000000..cd400aa --- /dev/null +++ b/konq-plugins/sidebar/delicious/plugin.cpp @@ -0,0 +1,108 @@ +////////////////////////////////////////////////////////////////////////// +// plugin.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "plugin.h" + +#include <qstring.h> + +#include <kapplication.h> +#include <klocale.h> +#include <kglobal.h> + +KonqSidebarDelicious::KonqSidebarDelicious( KInstance *instance, QObject *parent, + QWidget *widgetParent, QString &desktopName_, + const char* name ) + : KonqSidebarPlugin( instance, parent, widgetParent, desktopName_, name ), + DCOPObject( "sidebar-delicious" ) + +{ + m_widget = new MainWidget( instance->config(), widgetParent ); + connect( m_widget, SIGNAL( signalURLClicked( const KURL &, const KParts::URLArgs & ) ), + this, SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ) ); + connect( m_widget, SIGNAL( signalURLMidClicked( const KURL &, const KParts::URLArgs & ) ), + this, SIGNAL( createNewWindow( const KURL &, const KParts::URLArgs & ) ) ); +} + +KonqSidebarDelicious::~KonqSidebarDelicious() +{ + +} + +void * KonqSidebarDelicious::provides( const QString & ) +{ + return 0; +} + +QWidget * KonqSidebarDelicious::getWidget() +{ + return m_widget; +} + +void KonqSidebarDelicious::handleURL( const KURL & url ) +{ + m_widget->setCurrentURL( url ); +} + +bool KonqSidebarDelicious::universalMode() +{ + return true; +} + +extern "C" +{ + KDE_EXPORT void* create_konqsidebar_delicious( KInstance *instance, QObject *par, QWidget *widp, + QString &desktopname, const char *name ) + { + KGlobal::locale()->insertCatalogue( "konqsidebar_delicious" ); + return new KonqSidebarDelicious( instance, par, widp, desktopname, name ); + } +} + +extern "C" +{ + KDE_EXPORT bool add_konqsidebar_delicious( QString* fn, QString* /*param*/, QMap<QString,QString> *map ) + { + map->insert("Type", "Link"); + map->insert("Icon", "konqsidebar_delicious"); + map->insert("Name", i18n( "del.icio.us Bookmarks" ) ); + map->insert("Open", "false"); + map->insert("X-KDE-KonqSidebarModule", "konqsidebar_delicious"); + fn->setLatin1("delicious%1.desktop"); + return true; + } +} + +QStringList KonqSidebarDelicious::tags() const +{ + return m_widget->tags(); +} + +QStringList KonqSidebarDelicious::bookmarks() const +{ + return m_widget->bookmarks(); +} + +void KonqSidebarDelicious::newBookmark() +{ + m_widget->slotNewBookmark(); +} + +#include "plugin.moc" diff --git a/konq-plugins/sidebar/delicious/plugin.h b/konq-plugins/sidebar/delicious/plugin.h new file mode 100644 index 0000000..96f7082 --- /dev/null +++ b/konq-plugins/sidebar/delicious/plugin.h @@ -0,0 +1,85 @@ +////////////////////////////////////////////////////////////////////////// +// plugin.h // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#include "mainWidget.h" + +#include <konqsidebarplugin.h> +#include <kparts/part.h> +#include <kparts/factory.h> +#include <kparts/browserextension.h> +#include <kinstance.h> +#include <dcopobject.h> + +class QString; + +/** + * @brief del.icio.us bookmarks plugin + * @author Lukas Tinkl <[email protected]> + */ +class KonqSidebarDelicious: public KonqSidebarPlugin, DCOPObject +{ + Q_OBJECT + K_DCOP +public: + KonqSidebarDelicious( KInstance * instance, QObject * parent, QWidget * widgetParent, + QString & desktopName_, const char * name = 0 ); + ~KonqSidebarDelicious(); + virtual void * provides( const QString & ); + /** + * @return the main widget + */ + virtual QWidget * getWidget(); + +k_dcop: + QStringList tags() const; + QStringList bookmarks() const; + void newBookmark(); + +protected: + /** + * Called when the shell's @p url changes + */ + virtual void handleURL( const KURL & url ); + + /** + * @return true if we are in universal (e.g. desktop) mode + */ + bool universalMode(); + +signals: + /** + * Emitted in order to open @p url in the shell app + */ + void openURLRequest( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + + /** + * Emitted in order to open @p url in the shell app's new window + */ + void createNewWindow( const KURL & url, const KParts::URLArgs & args = KParts::URLArgs() ); + +private: + MainWidget * m_widget; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/tagListItem.cpp b/konq-plugins/sidebar/delicious/tagListItem.cpp new file mode 100644 index 0000000..866cc09 --- /dev/null +++ b/konq-plugins/sidebar/delicious/tagListItem.cpp @@ -0,0 +1,78 @@ +////////////////////////////////////////////////////////////////////////// +// tagListItem.cpp // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#include "tagListItem.h" + +TagListItem::TagListItem( QListView * parent, const QString & tagName, int count ) + : QCheckListItem( parent, tagName, QCheckListItem::CheckBox ), m_name( tagName ), m_count( count ) +{ +} + +// virtual +void TagListItem::stateChange( bool state ) +{ + QCheckListItem::stateChange( state ); + emit signalItemChecked( this ); +} + +// virtual +int TagListItem::compare( QListViewItem * i, int col, bool ascending ) const +{ + if ( col == 1 ) + { + int them = static_cast<TagListItem *>( i )->count(); + if ( m_count < them ) + return -1; + else if ( m_count > them ) + return 1; + else + return 0; + } + return QCheckListItem::compare( i, col, ascending ); +} + +int TagListItem::count() const +{ + return m_count; +} + +// virtual +QString TagListItem::text( int column ) const +{ + if ( column == 0 ) + return m_name; + else if ( column == 1 ) + return QString::number( m_count ); + else + return QString::null; +} + +QString TagListItem::name() const +{ + return m_name; +} + +void TagListItem::setName( const QString & name ) +{ + m_name = name; +} + +#include "tagListItem.moc" diff --git a/konq-plugins/sidebar/delicious/tagListItem.h b/konq-plugins/sidebar/delicious/tagListItem.h new file mode 100644 index 0000000..0bc293e --- /dev/null +++ b/konq-plugins/sidebar/delicious/tagListItem.h @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////// +// tagListItem.h // +// // +// Copyright (C) 2005 Lukas Tinkl <[email protected]> // +// // +// This program is free software; you can redistribute it and/or // +// modify it under the terms of the GNU General Public License // +// as published by the Free Software Foundation; either version 2 // +// of the License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // +// 02111-1307, USA. // +////////////////////////////////////////////////////////////////////////// + +#ifndef _TAGLISTITEM_H_ +#define _TAGLISTITEM_H_ + +#include <qobject.h> +#include <qlistview.h> + +class TagListItem: public QObject, public QCheckListItem +{ + Q_OBJECT +public: + TagListItem( QListView * parent, const QString & tagName, int count = 1 ); + int count() const; + QString name() const; + void setName( const QString & name ); + +protected: + virtual void stateChange( bool state ); + virtual int compare( QListViewItem * i, int col, bool ascending ) const; + virtual QString text( int column ) const; + +signals: + void signalItemChecked( TagListItem * ); + +private: + QString m_name; + int m_count; +}; + +#endif diff --git a/konq-plugins/sidebar/delicious/widget.ui b/konq-plugins/sidebar/delicious/widget.ui new file mode 100644 index 0000000..daccbe9 --- /dev/null +++ b/konq-plugins/sidebar/delicious/widget.ui @@ -0,0 +1,165 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>MainWidget_base</class> +<author>Lukáš Tinkl <[email protected]></author> +<widget class="QWidget"> + <property name="name"> + <cstring>Form1</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>411</width> + <height>595</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QSplitter"> + <property name="name"> + <cstring>splitter3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox2</cstring> + </property> + <property name="title"> + <string>Tags</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>btnRefreshTags</cstring> + </property> + <property name="text"> + <string>&Refresh Tags</string> + </property> + <property name="toolTip" stdset="0"> + <string>Refresh the list of tags</string> + </property> + </widget> + <widget class="QListView"> + <column> + <property name="text"> + <string>Tag</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Count</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>lvTags</cstring> + </property> + <property name="showSortIndicator"> + <bool>true</bool> + </property> + <property name="resizeMode"> + <enum>AllColumns</enum> + </property> + </widget> + </vbox> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>groupBox1</cstring> + </property> + <property name="title"> + <string>Bookmarks</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton" row="1" column="0"> + <property name="name"> + <cstring>btnRefreshBookmarks</cstring> + </property> + <property name="text"> + <string>Refresh &Bookmarks</string> + </property> + <property name="toolTip" stdset="0"> + <string>Refresh the list of bookmarks according to the selected tags</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>btnNew</cstring> + </property> + <property name="text"> + <string>Post &New...</string> + </property> + <property name="toolTip" stdset="0"> + <string>Post a new bookmark</string> + </property> + </widget> + <widget class="KListView" row="0" column="0" rowspan="1" colspan="2"> + <column> + <property name="text"> + <string>Description</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Date</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>lvBookmarks</cstring> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <property name="showSortIndicator"> + <bool>true</bool> + </property> + <property name="resizeMode"> + <enum>AllColumns</enum> + </property> + <property name="itemsMovable"> + <bool>false</bool> + </property> + </widget> + </grid> + </widget> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistview.h</includehint> +</includehints> +</UI> diff --git a/konq-plugins/sidebar/mediaplayer/AUTHORS b/konq-plugins/sidebar/mediaplayer/AUTHORS new file mode 100644 index 0000000..12b5dc2 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/AUTHORS @@ -0,0 +1,13 @@ +konqsidebarmediaplayer: +Joseph Wenninger <[email protected]> + + + +For the parts I took from kaboodle/noatun/...: + +Neil Stevens <[email protected]> +Charles Samuels <[email protected]> +Stefan Schimanski <[email protected]> +Malte Starostik <[email protected]> +Stefan Westerfeld <[email protected]> +Nikolas Zimmermann <[email protected]> diff --git a/konq-plugins/sidebar/mediaplayer/COPYING b/konq-plugins/sidebar/mediaplayer/COPYING new file mode 100644 index 0000000..5714d40 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/COPYING @@ -0,0 +1,12 @@ +There are some licenses involved in this small plugin: +1) konqsidebarplugin.h: LGPL +2) player.*, engine.* are taken from noatun/kaboodle/arts and have there own licenes. + Look in these projects for their licenses (At the time I write this I think they are licencesed under the BSD + license) + +3) All other files are copyrighted under the GPL + + +Joseph Wenninger <[email protected]> + +June 23rd 2001 diff --git a/konq-plugins/sidebar/mediaplayer/Makefile.am b/konq-plugins/sidebar/mediaplayer/Makefile.am new file mode 100644 index 0000000..12ba913 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/Makefile.am @@ -0,0 +1,33 @@ +# this has all of the subdirectories that make will recurse into. if +# there are none, comment this out +SUBDIRS = . pics + +# set the include path for X, qt and KDE +INCLUDES = -I$(kde_includes)/kio -I$(kde_includes)/arts $(all_includes) + +# these are the headers for your project +noinst_HEADERS = +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = konqsidebar_mediaplayer.la + +# the Part's source, library search path, and link libraries +konqsidebar_mediaplayer_la_SOURCES = mediawidget_skel.ui engine.cpp player.cpp mediawidget.cpp mediaplayer.cpp controls.cpp +konqsidebar_mediaplayer_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +konqsidebar_mediaplayer_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) -lkonqsidebarplugin -lqtmcop -lkmedia2_idl -lsoundserver_idl -lartskde + +globaladddir = $(kde_datadir)/konqsidebartng/add +globaladd_DATA = mplayer_add.desktop + +appsdir = $(kde_appsdir)/.hidden +apps_DATA = mediaplayerplugin.desktop + +mediawidget_skel.ui: mediawidget_skel_designer.ui + perl -p -e "s/QSlider/L33tSlider/" mediawidget_skel_designer.ui >mediawidget_skel.ui + +extendedclean: + rm mediawidget_skel.* + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/konqsidebar_mediaplayer.pot diff --git a/konq-plugins/sidebar/mediaplayer/controls.cpp b/konq-plugins/sidebar/mediaplayer/controls.cpp new file mode 100644 index 0000000..76671d5 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/controls.cpp @@ -0,0 +1,138 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#include "controls.h" + +L33tSlider::L33tSlider(QWidget * parent, const char * name) : + QSlider(parent,name), pressed(false) +{} +L33tSlider::L33tSlider(Orientation o, QWidget * parent, const char * name) : + QSlider(o,parent,name), pressed(false) +{} +L33tSlider::L33tSlider(int minValue, int maxValue, int pageStep, int value, + Orientation o, QWidget * parent, const char * name) : + QSlider(minValue, maxValue, pageStep, value, o, parent,name), pressed(false) +{} + +bool L33tSlider::currentlyPressed() const +{ + return pressed; +} + +void L33tSlider::setValue(int i) +{ + if (!pressed) + QSlider::setValue(i); +} + +void L33tSlider::mousePressEvent(QMouseEvent*e) +{ + if (e->button()!=RightButton) + { + pressed=true; + QSlider::mousePressEvent(e); + } +} + +void L33tSlider::mouseReleaseEvent(QMouseEvent*e) +{ + pressed=false; + QSlider::mouseReleaseEvent(e); + emit userChanged(value()); +} + +void L33tSlider::wheelEvent(QWheelEvent *e) +{ + QSlider::wheelEvent(e); + int newValue = value(); + + if(newValue < minValue()) + newValue = minValue(); + else if(newValue > maxValue()) + newValue = maxValue(); + + setValue(newValue); + emit userChanged(newValue); +} + +SliderAction::SliderAction(const QString& text, int accel, const QObject *receiver, + const char *member, QObject* parent, const char* name ) + : KAction( text, accel, parent, name ) +{ + m_receiver = receiver; + m_member = member; +} + +int SliderAction::plug( QWidget *w, int index ) +{ + if (!w->inherits("KToolBar")) return -1; + + KToolBar *toolBar = (KToolBar *)w; + int id = KAction::getToolButtonID(); + + //Create it. + m_slider=new L33tSlider(0, 1000, 100, 0, Horizontal, toolBar); + m_slider->setMinimumWidth(10); + toolBar->insertWidget(id, 10, m_slider, index ); + + + addContainer( toolBar, id ); + connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); + toolBar->setItemAutoSized( id, true ); + + if (w->inherits( "KToolBar" )) + connect(toolBar, SIGNAL(moved(KToolBar::BarPosition)), this, SLOT(toolbarMoved(KToolBar::BarPosition))); + + emit plugged(); + + return containerCount() - 1; +} + +void SliderAction::toolbarMoved(KToolBar::BarPosition) +{ +// I wish this worked :) +return; +/* + if (pos == KToolBar::Left || pos == KToolBar::Right) + { + m_slider->setOrientation(Vertical); + m_slider->setFixedWidth(m_slider->height()); + } + else + { + m_slider->setOrientation(Horizontal); + m_slider->resize(m_slider->height(), m_slider->height()); + } +*/ +} + +void SliderAction::unplug( QWidget *w ) +{ + KToolBar *toolBar = (KToolBar *)w; + int idx = findContainer( w ); + + toolBar->removeItem( itemId( idx ) ); + removeContainer( idx ); +} + +#include "controls.moc" diff --git a/konq-plugins/sidebar/mediaplayer/controls.h b/konq-plugins/sidebar/mediaplayer/controls.h new file mode 100644 index 0000000..d05a977 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/controls.h @@ -0,0 +1,93 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef __CONTROLS_H +#define __CONTROLS_H + +#include <qguardedptr.h> + +#include <kaction.h> +#include <ktoolbar.h> +#include <qslider.h> +#include <qstringlist.h> + +class QComboBox; +class QLabel; + +/** + * A slider that can be moved around while being + * changed internally + **/ +class L33tSlider : public QSlider +{ +Q_OBJECT +public: + L33tSlider(QWidget * parent, const char * name=0); + L33tSlider(Orientation, QWidget * parent, const char * name=0); + L33tSlider(int minValue, int maxValue, int pageStep, int value, + Orientation, QWidget * parent, const char * name=0); + + bool currentlyPressed() const; +signals: + /** + * emmited only when the user changes the value by hand + **/ + void userChanged(int value); + +public slots: + virtual void setValue(int); +protected: + virtual void mousePressEvent(QMouseEvent*); + virtual void mouseReleaseEvent(QMouseEvent*); + virtual void wheelEvent(QWheelEvent *e); + +private: + bool pressed; +}; + +/** + * A slider for your toolbar + **/ +class SliderAction : public KAction +{ +Q_OBJECT +public: + SliderAction(const QString& text, int accel, const QObject *receiver, + const char *member, QObject* parent, const char* name ); + virtual int plug( QWidget *w, int index = -1 ); + virtual void unplug( QWidget *w ); + QSlider* slider() const { return m_slider; } + +signals: + void plugged(); + +public slots: + void toolbarMoved(KToolBar::BarPosition pos); +private: + QGuardedPtr<QSlider> m_slider; + QStringList m_items; + const QObject *m_receiver; + const char *m_member; +}; + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/engine.cpp b/konq-plugins/sidebar/mediaplayer/engine.cpp new file mode 100644 index 0000000..cdb9486 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/engine.cpp @@ -0,0 +1,207 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +extern "C" +{ +#include <sys/wait.h> +} + +#include <kconfig.h> +#include <kdebug.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kmimetype.h> +#include <kstandarddirs.h> +#include <kurl.h> +#include <qtimer.h> +#include <qfile.h> +#include <qdir.h> + +#include <connect.h> +#include <dynamicrequest.h> +#include <flowsystem.h> +#include <kartsdispatcher.h> +#include <kartsserver.h> +#include <kplayobjectfactory.h> +#include <soundserver.h> + +#include "engine.h" +#include <string.h> + +using namespace std; + +class Engine::EnginePrivate +{ +public: + EnginePrivate() + : playobj(0) + , dispatcher() + , server() + { + } + + ~EnginePrivate() + { + delete playobj; + } + + KDE::PlayObject *playobj; + KArtsDispatcher dispatcher; + KArtsServer server; + KURL file; +}; + +Engine::Engine(QObject *parent) + : QObject(parent) + , d(new EnginePrivate) +{ +} + +Engine::~Engine() +{ + stop(); + delete d; +} + +bool Engine::load(const KURL &file) +{ + if(file.path().length()) + { + d->file = file; + return reload(); + } + else return false; +} + +bool Engine::reload(void) +{ + // Only You can prevent memory leaks + delete d->playobj; + d->playobj = 0; + + KDE::PlayObjectFactory factory(d->server.server()); + d->playobj = factory.createPlayObject(d->file, true); + + needReload = false; + + return !d->playobj->isNull(); +} + +void Engine::play() +{ + if(d->playobj) + { + switch(d->playobj->state()) + { + case Arts::posIdle: + if(needReload) + reload(); + d->playobj->play(); + break; + case Arts::posPaused: + d->playobj->play(); + break; + default: + break; + } + } +} + +void Engine::pause() +{ + if(d->playobj && !d->playobj->isNull()) + d->playobj->pause(); +} + +void Engine::stop() +{ + if(d->playobj && !d->playobj->isNull()) + { + d->playobj->halt(); + needReload = true; + } +} + +// pass time in msecs +void Engine::seek(unsigned long msec) +{ + Arts::poTime t; + + t.ms = (long) msec % 1000; + t.seconds = (long) ((long)msec - t.ms) / 1000; + + if(d->playobj && !d->playobj->isNull()) + d->playobj->seek(t); +} + +// return position in milliseconds +long Engine::position() +{ + if(!d->playobj || d->playobj->isNull()) return 0; + + Arts::poTime time(d->playobj->currentTime()); + return (time.ms + (time.seconds*1000)); +} + +// return track-length in milliseconds +unsigned long Engine::length() +{ + if(!d->playobj || d->playobj->isNull()) return 0; + + Arts::poTime time(d->playobj->overallTime()); + return (time.ms + (time.seconds*1000)); +} + +KMediaPlayer::Player::State Engine::state() +{ + if(!d->playobj || d->playobj->isNull()) return KMediaPlayer::Player::Empty; + + switch(d->playobj->state()) + { + case Arts::posIdle: + return KMediaPlayer::Player::Stop; + break; + case Arts::posPlaying: + return KMediaPlayer::Player::Play; + break; + case Arts::posPaused: + return KMediaPlayer::Player::Pause; + break; + default: + return KMediaPlayer::Player::Stop; + break; + } +} + +bool Engine::seekable(void) +{ + if(!d->playobj || d->playobj->isNull()) return false; + return d->playobj->capabilities() & Arts::capSeek; +} + +Arts::PlayObject Engine::playObject() const +{ + return d->playobj ? d->playobj->object() : Arts::PlayObject::null(); +} + +#include "engine.moc" diff --git a/konq-plugins/sidebar/mediaplayer/engine.h b/konq-plugins/sidebar/mediaplayer/engine.h new file mode 100644 index 0000000..1a5638f --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/engine.h @@ -0,0 +1,97 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef _ENGINE_H +#define _ENGINE_H + +#include <qobject.h> +#include <kmedia2.h> +#include <kmediaplayer/player.h> +#include <kurl.h> + +namespace Arts +{ +class PlayObject; +class SoundServerV2; +} + +/** + * Handles all playing, connecting to aRts. + * Does almost everything related to multimedia. + * Most interfacing should be done with Player + **/ +class Engine : public QObject +{ +Q_OBJECT + +public: + Engine(QObject *parent=0); + ~Engine(); + + Arts::PlayObject playObject() const; + +public slots: + /** + * Load a file + **/ + bool load(const KURL &file); + + /** + * Pause while playing + **/ + void pause(); + + /** + * Start + **/ + void play(); + + /** + * stops, and unloads + **/ + void stop(); + + /** + * skips to a time + **/ + void seek(unsigned long msec); + +public: + KMediaPlayer::Player::State state(); + long position(); // NOT unsigned + unsigned long length(); + + /** + * returns if the current track is seekable + */ + bool seekable(void); + +private: + bool reload(void); + bool needReload; + + class EnginePrivate; + EnginePrivate *d; +}; + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/mediaplayer.cpp b/konq-plugins/sidebar/mediaplayer/mediaplayer.cpp new file mode 100644 index 0000000..ce8d1af --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediaplayer.cpp @@ -0,0 +1,74 @@ +/*************************************************************************** + mediaplayer.cpp - The real sidebar plugin + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mediaplayer.h" +#include <klocale.h> +#include "mediaplayer.moc" +#include <kdebug.h> +#include <ksimpleconfig.h> +#include <kconfig.h> +#include <kstandarddirs.h> +#include <kmessagebox.h> +#include <kglobal.h> +#include <kdemacros.h> +#include "mediawidget.h" + +KonqSidebar_MediaPlayer::KonqSidebar_MediaPlayer(KInstance *instance,QObject *parent,QWidget *widgetParent, QString &desktopName_, const char* name): + KonqSidebarPlugin(instance,parent,widgetParent,desktopName_,name) + { + widget=new KSB_MediaWidget(widgetParent); + } + + +KonqSidebar_MediaPlayer::~KonqSidebar_MediaPlayer(){;} + +void* KonqSidebar_MediaPlayer::provides(const QString &) {return 0;} + +void KonqSidebar_MediaPlayer::emitStatusBarText (const QString &) {;} + +QWidget *KonqSidebar_MediaPlayer::getWidget(){return widget;} + +void KonqSidebar_MediaPlayer::handleURL(const KURL &/*url*/) + { + } + + + + +extern "C" +{ + KDE_EXPORT void* create_konqsidebar_mediaplayer(KInstance *instance,QObject *par,QWidget *widp,QString &desktopname,const char *name) + { + KGlobal::locale()->insertCatalogue("konqsidebar_mediaplayer"); + return new KonqSidebar_MediaPlayer(instance,par,widp,desktopname,name); + } +} + +extern "C" +{ + KDE_EXPORT bool add_konqsidebar_mediaplayer(QString* fn, QString* /*param*/, QMap<QString,QString> *map) + { + map->insert("Type","Link"); + map->insert("Icon","konqsidebar_mediaplayer"); + map->insert("Name",i18n("Media Player")); + map->insert("Open","false"); + map->insert("X-KDE-KonqSidebarModule","konqsidebar_mediaplayer"); + fn->setLatin1("mplayer%1.desktop"); + return true; + } +} + diff --git a/konq-plugins/sidebar/mediaplayer/mediaplayer.h b/konq-plugins/sidebar/mediaplayer/mediaplayer.h new file mode 100644 index 0000000..c563e20 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediaplayer.h @@ -0,0 +1,43 @@ +/*************************************************************************** + mediaplayer.h - The real sidebar plugin + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _konq_sidebar_mediaplayer_h_ +#define _konq_sidebar_mediaplayer_h_ +#include <konqsidebarplugin.h> +#include <kparts/part.h> +#include <kparts/factory.h> +#include <kparts/browserextension.h> + +class KSB_MediaWidget; + +class KonqSidebar_MediaPlayer: public KonqSidebarPlugin + { + Q_OBJECT + public: + KonqSidebar_MediaPlayer(KInstance *instance,QObject *parent,QWidget *widgetParent, QString &desktopName_, const char* name=0); + ~KonqSidebar_MediaPlayer(); + virtual void *provides(const QString &); + void emitStatusBarText (const QString &); + virtual QWidget *getWidget(); + protected: + virtual void handleURL(const KURL &url); + private: + KSB_MediaWidget *widget; + }; + + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/mediaplayerplugin.desktop b/konq-plugins/sidebar/mediaplayer/mediaplayerplugin.desktop new file mode 100644 index 0000000..110fd36 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediaplayerplugin.desktop @@ -0,0 +1,115 @@ +[Desktop Entry] +Name=Mediaplayer +Name[ar]=مشغل الوسائط المتعددة +Name[az]=Mediya çalğıcısı +Name[bg]=Медия плеър +Name[br]=Soner liesvedia +Name[ca]=Reproductor Multimèdia +Name[cs]=Přehrávač médií +Name[cy]=Chwaraewr Cyfryngau +Name[da]=Medieafspiller +Name[de]=Medienabspieler +Name[el]=Αναπαραγωγέας μέσων +Name[eo]=Medioludilo +Name[es]=Reproductor de medios +Name[et]=Meediafailide mängija +Name[eu]=Multimedia-erreproduzigailua +Name[fa]=پخشکنندۀ رسانه +Name[fi]=Mediasoitin +Name[fr]=Lecteur multimédia +Name[fy]=Mediaspiler +Name[he]=נגן מדיה +Name[hi]=मीडिया-प्लेयर +Name[hr]=Medijski program +Name[hu]=Médialejátszó +Name[is]=Margmiðlunarspilari +Name[it]=Multimedia +Name[ja]=メディアプレーヤ +Name[kk]=Медиа ойнатқышы +Name[km]=កម្មវិធីចាក់មេឌៀ +Name[mk]=Медијаплеер +Name[nb]=Mediaspiller +Name[nds]=Medienafspeler +Name[ne]=मिडियाप्लेएर +Name[nl]=Mediaspeler +Name[nn]=Mediespelar +Name[nso]=Sebapadi sa Media +Name[pa]=ਮੀਡਿਆਪਲੇਅਰ +Name[pl]=Odtwarzacz multimedialny +Name[pt_BR]=Reprodutor de Mídia +Name[ro]=Redare multimedia +Name[ru]=Медиаплеер +Name[sk]=Prehrávač médií +Name[sv]=Mediaspelare +Name[ta]=ஊடக இயக்கி +Name[tg]=Медиаплеер +Name[tr]=Çokluortam oynatıcı +Name[uz]=Media-pleyer +Name[uz@cyrillic]=Медиа-плейер +Name[vi]=Bộ phát nhạc/ảnh +Name[xh]=Umdlali wosasazo lwendaba +Name[zh_CN]=媒体播放器 +Name[zh_TW]=媒體播放器 +Comment=Mediaplayer plugin in Konqueror's navigation panel +Comment[ar]=ملحق يشغل الوسائط المتعددة في لوحة التنقل في كونكيورر +Comment[az]=Konqueror-un naviqasiya panelindəki mediya çalğıcı əlavəsi +Comment[bg]=Навигационен панел за плеър за мултимедийни файлове +Comment[bs]=Mediaplayer dodatak za Konqueror-ov navigatorski panel +Comment[ca]=Connector del reproductor multimèdia en el plafó de navegació de Konqueror +Comment[cs]=Přehrávací modul pro postranní lištu Konqueroru +Comment[cy]=Ategyn chwarae cyfryngau yn y panel morlywio Konqueror +Comment[da]=Medieafspiller-plugin i Konquerors navigationspanel +Comment[de]=Medienabspieler-Modul im Navigationsbereich von Konqueror +Comment[el]=Πρόσθετο αναπαραγωγέα μέσων στο πλαίσιο πλοήγησης του Konqueror +Comment[eo]=Medioludila kromaĵo en foliuma panelo de Konkeranto +Comment[es]=Complemento del reproductor de medios en el panel de navegación de Konqueror +Comment[et]=Meediafailide mängija plugin Konquerori navigeerimispaneelil +Comment[eu]=Konquerorren arakatze paneleko multimedia-erreproduzigailuaren plugina +Comment[fa]=وصلۀ پخشکنندۀ رسانه در تابلوی ناوش Konqueror +Comment[fi]=Mediasoitinsovelma Konquerorin navigaatiopaneeliin +Comment[fr]=Le module de lecteur multimédia pour la barre de navigation de Konqueror +Comment[fy]=Mediaspiler-plugin foar Konqueror's navigaasjepaneel +Comment[ga]=Breiseán Mediaplayer i bpainéal nascleanúna Konqueror +Comment[gl]=Un plugin de reproduición multimédia no painel de navegación de Konqueror +Comment[he]=תוסף נגן מדיה ללוח הניווט של Konqueror +Comment[hi]=कॉन्करर के नेविगेशन फलक में मीडियाप्लेयर प्लगइन +Comment[hr]=Medijski dodatak u navigacijskoj ploči Konquerora +Comment[hu]=Médialejátszó bővítőmodul a Konqueror navigációs paneljéhez +Comment[is]=Margmiðlunareining fyrir spjaldið í Konqueror +Comment[it]=Plugin multimediale nella barra di navigazione di Konqueror +Comment[ja]=Konqueror のナビゲーションパネル内のメディアプレーヤプラグイン +Comment[ka]=Mediaplayer მოდული Konqueror-ის ნავიგაციის პანელზე +Comment[kk]=Konqueror панеліндегі медиа ойнатқыш плагин модулі +Comment[km]=កម្មវិធីជំនួយរបស់កម្មវិធីចាក់មេឌៀនៅក្នុងបន្ទះរុករករបស់ Konqueror +Comment[lt]=Mediaplayer priedas Konqueror navigacijos pulte +Comment[mk]=Приклучок за медијаплеер во панелот за навигација на Konqueror +Comment[ms]=Plugin Mediaplayer dalam panel Pandu Arah Konqueror +Comment[nb]=Mediaspiller-modul til Konquerors navigasjonspanel +Comment[nds]=Medienafspeler-Moduul för dat Sietpaneel vun Konqueror +Comment[ne]=कन्क्वेररको नेभिगेसन प्यानलको मिडियाप्लेएर प्लगइन +Comment[nl]=Mediaspeler-plugin voor Konqueror's navigatiepaneel +Comment[nn]=Mediespelar-programtillegg til navigasjonspanelet i Konqueror +Comment[pl]=Wtyczka odtwarzacza multimediów w panelu nawigacyjnym Konquerora +Comment[pt]=Um 'plugin' de reprodução multimédia no painel de navegação do Konqueror +Comment[pt_BR]=plug-ins do reprodutor de mídia no painel de navegação do Konqueror +Comment[ro]=Modul de redare multimedia în panoul de navigare Konqueror +Comment[ru]=Модуль Konqueror для проигрывания мультимедиа +Comment[sk]=Mediaplayer modul v navigačnom panely Konquerora +Comment[sl]=Vstavek večpredstavnostnega predvajalnika v Konquerorjevi navigacijski plošči +Comment[sr]=Прикључак за медија плејер у Konqueror-овом навигационом панелу +Comment[sr@Latn]=Priključak za medija plejer u Konqueror-ovom navigacionom panelu +Comment[sv]=Instickprogram för mediaspelare i Konquerors sidopanel +Comment[ta]=கான்கொரர்ரின் நாவிகேஷன் பலகத்தில் உள்ள ஊடக இயக்கி சொருகுப்பொருள் +Comment[tg]=Модули Konqueror барои бозӣ кардани мултимедиа +Comment[tr]=Konqueror çokluortam oynatıcısı +Comment[uk]=Втулок програвача в панелі навігації Konqueror +Comment[uz]=Konqueror yon paneli uchun multimediya fayllarini oʻynash vositasi +Comment[uz@cyrillic]=Konqueror ён панели учун мультимедия файлларини ўйнаш воситаси +Comment[vi]=Bổ sung phát nhạc/ảnh trên bảng duyệt qua Konqueror +Comment[xh]=Umdlali wosasazo lwendaba zeplagi yangaphakathi seqela lenjongo ethile lolawulo lwe Konqueror +Comment[zh_CN]=Konqueror 的导航面板中的媒体播放器插件 +Comment[zh_TW]=在 Konqueror 導覽面板上的媒體播放器外掛程式 +Icon=konqsidebar_mediaplayer +X-KDE-ParentApp=konqueror +X-KDE-KonqSidebarUniversal=true +DocPath=konq-plugins/mediaplayer/index.html diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget.cpp b/konq-plugins/sidebar/mediaplayer/mediawidget.cpp new file mode 100644 index 0000000..c460c3c --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget.cpp @@ -0,0 +1,169 @@ +/*************************************************************************** + mediawidget.cpp - The main widget + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mediawidget.h" +#include "mediawidget.moc" +#include "player.h" + +#include <kdebug.h> +#include <kurl.h> +#include <kurldrag.h> +#include <klocale.h> + +#include <qlabel.h> +#include <qwidget.h> +#include <qpushbutton.h> +#include <qlcdnumber.h> +#include <qpopupmenu.h> +#include <qslider.h> +#include <qtooltip.h> + +KSB_MediaWidget::KSB_MediaWidget(QWidget *parent):KSB_MediaWidget_skel(parent) +{ + player = new Player(this); + empty(); + + QFont labelFont = time->font(); + labelFont.setPointSize(18); + labelFont.setBold(true); + time->setFont(labelFont); + + connect(Play, SIGNAL(clicked()), player, SLOT(play())); + connect(Pause, SIGNAL(clicked()), player, SLOT(pause())); + connect(Stop, SIGNAL(clicked()), player, SLOT(stop())); + + connect(player, SIGNAL(timeout()), this, SLOT(playerTimeout())); + connect(player, SIGNAL(finished()), this, SLOT(playerFinished())); + connect(player, SIGNAL(playing()), this, SLOT(playing())); + connect(player, SIGNAL(paused()), this, SLOT(paused())); + connect(player, SIGNAL(stopped()), this, SLOT(stopped())); + connect(player, SIGNAL(empty()), this, SLOT(empty())); + + connect(Position, SIGNAL(userChanged(int)), this, SLOT(skipToWrapper(int))); + connect(this, SIGNAL(skipTo(unsigned long)), player, SLOT(skipTo(unsigned long))); + setAcceptDrops(true); + + pretty=""; + needLengthUpdate=false; + + QToolTip::add(Play,i18n("Play")); + QToolTip::add(Pause,i18n("Pause")); + QToolTip::add(Stop,i18n("Stop")); +} + +void KSB_MediaWidget::skipToWrapper(int second) +{ + emit skipTo((unsigned long)(second*1000)); +} + +void KSB_MediaWidget::dragEnterEvent ( QDragEnterEvent * e) +{ + e->accept(KURLDrag::canDecode(e)); +} + +void KSB_MediaWidget::dropEvent ( QDropEvent * e) +{ + m_kuri_list.clear(); + if (KURLDrag::decode(e, m_kuri_list)) + { + playerFinished(); + } +} + + +void KSB_MediaWidget::playerTimeout() +{ + if(player->current().isEmpty()) + return; + + if(Position->currentlyPressed()) + return; + +// update the scrollbar length + if(player->getLength()) + { + int range = (int)(player->getLength() / 1000); + Position->setRange(0, range); + if (needLengthUpdate) + { + int counter = player->lengthString().length() - (player->lengthString().find("/")+1); + QString length=player->lengthString().right(counter); + needLengthUpdate=false; + } + } + else + { + Position->setRange(0, 1); + } + // set the position + Position->setValue((int)(player->getTime() / 1000)); + + // update the time label + // catch files with duration > 99mins correctly + time->setText(player->lengthString()); +} + +void KSB_MediaWidget::playerFinished() +{ + if( m_kuri_list.count() > 0 ) + { + KURL kurl = m_kuri_list.first(); + m_kuri_list.remove( kurl ); + bool validFile = player->openFile( kurl ); + if (validFile) { + currentFile->setText( kurl.fileName() ); + player->play(); + needLengthUpdate=true; + pretty=kurl.prettyURL(); + } else { + currentFile->setText( i18n("Not a sound file") ); + playerFinished(); + } + } +} + +void KSB_MediaWidget::playing() +{ + Play->setEnabled(false); + Pause->setEnabled(true); + Stop->setEnabled(true); +} + +void KSB_MediaWidget::paused() +{ + Play->setEnabled(true); + Pause->setEnabled(false); + Stop->setEnabled(true); +} + +void KSB_MediaWidget::stopped() +{ + Position->setValue(0); + time->setText("00:00/00:00"); + Play->setEnabled(true); + Pause->setEnabled(false); + Stop->setEnabled(false); +} + +void KSB_MediaWidget::empty() +{ + Position->setValue(0); + time->setText("00:00/00:00"); + Play->setEnabled(false); + Pause->setEnabled(false); + Stop->setEnabled(false); +} diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget.h b/konq-plugins/sidebar/mediaplayer/mediawidget.h new file mode 100644 index 0000000..ff2137b --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget.h @@ -0,0 +1,57 @@ +/*************************************************************************** + mediawidget.h - The main widget + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _MEDIAWIDGET_H_ +#define _MEDIAWIDGET_H_ + +#include <kurl.h> +#include "mediawidget_skel.h" + +class KSB_MediaWidget: public KSB_MediaWidget_skel +{ + Q_OBJECT +public: + KSB_MediaWidget(QWidget *parent); + ~KSB_MediaWidget(){;} + +private: + class Player *player; + QString pretty; + bool needLengthUpdate; + KURL::List m_kuri_list; + +protected: + virtual void dragEnterEvent ( QDragEnterEvent * ); + virtual void dropEvent ( QDropEvent * ); + +private slots: + void playerTimeout(); + void playerFinished(); + void playing(); + void paused(); + void stopped(); + void empty(); + +public slots: + void skipToWrapper(int); + +signals: + void skipTo(unsigned long); + +}; + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget_skel.ui b/konq-plugins/sidebar/mediaplayer/mediawidget_skel.ui new file mode 100644 index 0000000..8780a72 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget_skel.ui @@ -0,0 +1,340 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>KSB_MediaWidget_skel</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KSB_MediaWidget_skel</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>277</width> + <height>151</height> + </rect> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout6</cstring> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer5_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>Play</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image0</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Pause</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image1</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Stop</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image2</pixmap> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="L33tSlider"> + <property name="name"> + <cstring>Position</cstring> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>time</cstring> + </property> + <property name="text"> + <cstring>00:00/00:00</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>currentFile</cstring> + </property> + <property name="text"> + <cstring>Drag sound files here</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer17</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<images> + <image name="image0"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141ac02ba68c4d4c199b98323631656c62cad8c494891423ce0ee2dc4c6418208bd55a7301009c7f45ef</data> + </image> + <image name="image1"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08698b2b23294189c6254f36fad351700741b45ad</data> + </image> + <image name="image2"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa0869832140c5631aaf9b7d69a0b00046344fd</data> + </image> + <image name="image3"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08d98321280ab431682eb45124298871042b2032e846c2f4c8846fe4013abb5e602007fec45ef</data> + </image> +</images> +<includes> + <include location="global" impldecl="in declaration">controls.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget_skel_designer.ui b/konq-plugins/sidebar/mediaplayer/mediawidget_skel_designer.ui new file mode 100644 index 0000000..a88dfde --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget_skel_designer.ui @@ -0,0 +1,340 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>KSB_MediaWidget_skel</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KSB_MediaWidget_skel</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>277</width> + <height>151</height> + </rect> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout6</cstring> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer5_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>Play</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image0</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Pause</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image1</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Stop</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image2</pixmap> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QSlider"> + <property name="name"> + <cstring>Position</cstring> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>time</cstring> + </property> + <property name="text"> + <cstring>00:00/00:00</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>currentFile</cstring> + </property> + <property name="text"> + <cstring>Drag sound files here</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer17</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<images> + <image name="image0"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141ac02ba68c4d4c199b98323631656c62cad8c494891423ce0ee2dc4c6418208bd55a7301009c7f45ef</data> + </image> + <image name="image1"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08698b2b23294189c6254f36fad351700741b45ad</data> + </image> + <image name="image2"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa0869832140c5631aaf9b7d69a0b00046344fd</data> + </image> + <image name="image3"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08d98321280ab431682eb45124298871042b2032e846c2f4c8846fe4013abb5e602007fec45ef</data> + </image> +</images> +<includes> + <include location="global" impldecl="in declaration">controls.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/konq-plugins/sidebar/mediaplayer/mplayer_add.desktop b/konq-plugins/sidebar/mediaplayer/mplayer_add.desktop new file mode 100644 index 0000000..1632ec4 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mplayer_add.desktop @@ -0,0 +1,61 @@ +[Desktop Entry] +Type=Link +URL= +Icon=konqsidebar_mediaplayer +Name=Media Player +Name[bg]=Медия плеър +Name[br]=Soner liesvedia +Name[ca]=Reproductor Multimèdia +Name[cs]=Přehrávač médií +Name[cy]=Chwaraewr Cyfryngau +Name[da]=Medieafspiller +Name[de]=Medienabspieler +Name[el]=Αναπαραγωγέας μέσων +Name[eo]=Medioludilo +Name[es]=Reproductor de medios +Name[et]=Meediafailide mängija +Name[eu]=Multimedia erreproduzigailua +Name[fa]=پخشکنندۀ رسانه +Name[fi]=Mediasoitin +Name[fr]=Lecteur multimédia +Name[fy]=Mediaspiler +Name[ga]=Seinnteoir Meán +Name[gl]=Reprodutor Multimédia +Name[he]=נגן מדיה +Name[hi]=मीडिया-प्लेयर +Name[hr]=Multimedijski program +Name[hu]=Médialejátszó +Name[is]=Margmiðlunarspilari +Name[it]=Lettore multimediale +Name[ja]=メディアプレーヤ +Name[ka]=მედია დამკვრელი +Name[kk]=Медиа ойнатқышы +Name[km]=កម្មវិធីចាក់មេឌៀ +Name[lt]=Media grotuvas +Name[mk]=Медијаплеер +Name[nb]=Mediaspiller +Name[nds]=Medienafspeler +Name[ne]=मिडिया प्लेएर +Name[nl]=Mediaspeler +Name[nn]=Mediespelar +Name[pa]=ਮੀਡਿਆ ਪਲੇਅਰ +Name[pl]=Odtwarzacz multimedialny +Name[pt]=Reprodutor Multimédia +Name[pt_BR]=Reprodutor de Mídia +Name[ru]=Медиаплеер +Name[sk]=Prehrávač médií +Name[sl]=Večpredstavnostni predvajalnik +Name[sv]=Mediaspelare +Name[ta]=ஊடகங்கள் இயக்கி +Name[tg]=Медиаплеер +Name[tr]=Çokluortam Oynatıcı +Name[uk]=Медіа-програвач +Name[uz]=Media-pleyer +Name[uz@cyrillic]=Медиа-плейер +Name[vi]=Bộ phát nhạc và ảnh +Name[zh_CN]=媒体播放器 +Name[zh_TW]=媒體播放器 + +Open=false +X-KDE-KonqSidebarAddModule=konqsidebar_mediaplayer +X-KDE-KonqSidebarUniversal=true diff --git a/konq-plugins/sidebar/mediaplayer/pics/Makefile.am b/konq-plugins/sidebar/mediaplayer/pics/Makefile.am new file mode 100644 index 0000000..e5515a8 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/Makefile.am @@ -0,0 +1 @@ +KDE_ICON = AUTO diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr16-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr16-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..71e4dd5 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr16-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr22-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr22-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..838cf9d --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr22-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr32-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr32-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..87ac58b --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr32-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr48-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr48-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..509c022 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr48-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/lo32-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/lo32-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..db177a9 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/lo32-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/player.cpp b/konq-plugins/sidebar/mediaplayer/player.cpp new file mode 100644 index 0000000..360f8e8 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/player.cpp @@ -0,0 +1,180 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#include <kdebug.h> +#include <klocale.h> +#include <kurl.h> +#include <kmediaplayer/player.h> + +#include "engine.h" +#include "player.h" + +Player::Player(QObject *parent) + : QObject(parent) + , position(0) + , unfinished(false) +{ + mEngine = new Engine; + mLooping = false; + connect(&ticker, SIGNAL(timeout()), SLOT(tickerTimeout())); + ticker.start(500); + stop(); +} + +Player::~Player() +{ + delete mEngine; +} + +bool Player::isPlaying()const +{ + return mEngine->state() == KMediaPlayer::Player::Play; +} + +bool Player::isPaused()const +{ + return mEngine->state() == KMediaPlayer::Player::Pause; +} + +bool Player::isStopped()const +{ + return mEngine->state() == KMediaPlayer::Player::Stop || mEngine->state() == KMediaPlayer::Player::Empty; +} + +void Player::handleButtons() +{ + switch(mEngine->state()) + { + case KMediaPlayer::Player::Play: + emit playing(); + break; + case KMediaPlayer::Player::Pause: + emit paused(); + break; + case KMediaPlayer::Player::Stop: + emit stopped(); + break; + case KMediaPlayer::Player::Empty: + emit empty(); + break; + } +} + +void Player::stop(void) +{ + unfinished = false; + position = 0; + mEngine->stop(); +} + +void Player::play() +{ + mEngine->play(); +} + +void Player::pause() +{ + if(mEngine->state() == KMediaPlayer::Player::Play) + { + mEngine->pause(); + } +} + +// skip to a certain time in the track +void Player::skipTo(unsigned long msec) +{ + if(!mCurrent.isEmpty()) + mEngine->seek(msec); +} + +void Player::tickerTimeout() +{ + position = mEngine->position(); + mLength = mEngine->length(); + + handleButtons(); + + if(mEngine->state() == KMediaPlayer::Player::Stop && unfinished) + { + if(mLooping) + { + play(); + } + else + { + stop(); + emit finished(); + } + } + else if(mEngine->state() != KMediaPlayer::Player::Stop) + { + emit timeout(); + unfinished = true; + } + +} + +QString Player::lengthString(long _position) +{ + if(_position == -1) _position = position; + + int posSecs = (int)(_position / 1000); + int posSeconds = posSecs % 60; + int posMinutes = (posSecs - posSeconds) / 60; + + int totSecs = (int)(mLength / 1000); + int totSeconds = totSecs % 60; + int totMinutes = (totSecs - totSeconds) / 60; + + QString result; + result.sprintf("%.2d:%.2d/%.2d:%.2d", posMinutes, posSeconds, totMinutes, totSeconds); + return result; +} + +bool Player::openFile(const KURL &f) +{ + stop(); + mCurrent = f; + + bool work = mEngine->load(mCurrent); + + if(!work) + { + mCurrent = KURL(); + return false; + } + else + { + emit opened(mCurrent); + tickerTimeout(); + return true; + } +} + +void Player::setLooping(bool b) +{ + mLooping = b; + emit loopingChange(mLooping); +} + +#include "player.moc" diff --git a/konq-plugins/sidebar/mediaplayer/player.h b/konq-plugins/sidebar/mediaplayer/player.h new file mode 100644 index 0000000..6acf146 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/player.h @@ -0,0 +1,178 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef PLAYER_H +#define PLAYER_H + +#include <qobject.h> +#include <qtimer.h> +#include <kurl.h> + +class Engine; + +/** + * This class has slots for all the common media player buttons + **/ +class Player : public QObject +{ +Q_OBJECT + +friend class KaboodlePart; +public: + Player(QObject *parent = 0); + ~Player(); + + /** + * returns a string with the time that can + * be used in the UI: + * CC:CC/LL:LL (mm:ss) + **/ + QString lengthString(long _position = -1); + + bool looping(void) const { return mLooping; } + + /** + * the position in milliseconds + **/ + long getTime() const { return position; } + + /** + * the track-length in milliseconds + **/ + unsigned long getLength() const { return mLength; } + + /** + * true if we're playing + **/ + bool isPlaying()const; + + /** + * true if paused + **/ + bool isPaused()const; + + /** + * true if stopped + **/ + bool isStopped()const; + + /** + * get the current opened URL + * this may be empty + **/ + KURL current() const { return mCurrent; } + + /** + * Change the file to have open + * @return true if file is playable, false otherwise + */ + bool openFile(const KURL &f); + +public slots: + /** + * force the playing/paused/stopped/playlist shown signals to + * be sent out + **/ + void handleButtons(); + + /** + * stop playing + **/ + void stop(void); + + /** + * start playing + **/ + void play(); + + /** + * pause playing + **/ + void pause(); + + /** + * skip to the position + **/ + void skipTo(unsigned long msec); + + /** + * Set whether to restart playing when the playing is done + */ + void setLooping(bool); + +signals: + /** + * Tells you to update display information + **/ + void timeout(); + + /** + * State is to Empty + */ + void empty(); + + /** + * State is to Stopped + */ + void stopped(); + + /** + * State is to Playing + */ + void playing(); + + /** + * State is to Paused + */ + void paused(); + + /** + * The file ended, and looping was off + */ + void finished(); + + void loopingChange(bool); + + /** + * The current URL changed + */ + void opened(const KURL &); + +private slots: + void tickerTimeout(); + +protected: + Engine *engine()const { return mEngine; } + +private: + Engine *mEngine; + QTimer ticker; + long position; + bool mLooping; + unsigned long mLength; + KURL mCurrent; + bool unfinished; +}; + +#endif + diff --git a/konq-plugins/sidebar/metabar/AUTHORS b/konq-plugins/sidebar/metabar/AUTHORS new file mode 100644 index 0000000..01255ff --- /dev/null +++ b/konq-plugins/sidebar/metabar/AUTHORS @@ -0,0 +1 @@ +Florian Roth <[email protected]> diff --git a/konq-plugins/sidebar/metabar/COPYING b/konq-plugins/sidebar/metabar/COPYING new file mode 100644 index 0000000..5b6e7c6 --- /dev/null +++ b/konq-plugins/sidebar/metabar/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/konq-plugins/sidebar/metabar/ChangeLog b/konq-plugins/sidebar/metabar/ChangeLog new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/konq-plugins/sidebar/metabar/ChangeLog diff --git a/konq-plugins/sidebar/metabar/Doxyfile b/konq-plugins/sidebar/metabar/Doxyfile new file mode 100644 index 0000000..323c79e --- /dev/null +++ b/konq-plugins/sidebar/metabar/Doxyfile @@ -0,0 +1,275 @@ +# Doxyfile 1.4.1-KDevelop + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = metabar.kdevelop +PROJECT_NUMBER = 0.1 +OUTPUT_DIRECTORY = +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = /home/florian/metabar_widget/debug/src/ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 8 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = /home/florian/metabar +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.C \ + *.CC \ + *.C++ \ + *.II \ + *.I++ \ + *.H \ + *.HH \ + *.H++ \ + *.CS \ + *.PHP \ + *.PHP3 \ + *.M \ + *.MM \ + *.C \ + *.H \ + *.tlh \ + *.diff \ + *.patch \ + *.moc \ + *.xpm \ + *.dox +RECURSIVE = yes +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = * +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = YES +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = yes +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = metabar.tag +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/konq-plugins/sidebar/metabar/INSTALL b/konq-plugins/sidebar/metabar/INSTALL new file mode 100644 index 0000000..02a4a07 --- /dev/null +++ b/konq-plugins/sidebar/metabar/INSTALL @@ -0,0 +1,167 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes a while. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Type `make install' to install the programs and any data files and + documentation. + + 4. You can remove the program binaries and object files from the + source code directory by typing `make clean'. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/konq-plugins/sidebar/metabar/Makefile.am b/konq-plugins/sidebar/metabar/Makefile.am new file mode 100644 index 0000000..af437a6 --- /dev/null +++ b/konq-plugins/sidebar/metabar/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/konq-plugins/sidebar/metabar/NEWS b/konq-plugins/sidebar/metabar/NEWS new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/konq-plugins/sidebar/metabar/NEWS diff --git a/konq-plugins/sidebar/metabar/README b/konq-plugins/sidebar/metabar/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/konq-plugins/sidebar/metabar/README diff --git a/konq-plugins/sidebar/metabar/TODO b/konq-plugins/sidebar/metabar/TODO new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/konq-plugins/sidebar/metabar/TODO diff --git a/konq-plugins/sidebar/metabar/config.h.in b/konq-plugins/sidebar/metabar/config.h.in new file mode 100644 index 0000000..978129e --- /dev/null +++ b/konq-plugins/sidebar/metabar/config.h.in @@ -0,0 +1,244 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the <Carbon/Carbon.h> header file. */ +#undef HAVE_CARBON_CARBON_H + +/* Define if you have the CoreAudio API */ +#undef HAVE_COREAUDIO + +/* Define to 1 if you have the <crt_externs.h> header file. */ +#undef HAVE_CRT_EXTERNS_H + +/* Defines if your system has the crypt function */ +#undef HAVE_CRYPT + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the <inttypes.h> header file. */ +#undef HAVE_INTTYPES_H + +/* Define if you have libjpeg */ +#undef HAVE_LIBJPEG + +/* Define if you have libpng */ +#undef HAVE_LIBPNG + +/* Define if you have a working libpthread (will enable threaded code) */ +#undef HAVE_LIBPTHREAD + +/* Define if you have libz */ +#undef HAVE_LIBZ + +/* Define to 1 if you have the <memory.h> header file. */ +#undef HAVE_MEMORY_H + +/* Define if your system needs _NSGetEnviron to set up the environment */ +#undef HAVE_NSGETENVIRON + +/* Define if you have res_init */ +#undef HAVE_RES_INIT + +/* Define if you have the res_init prototype */ +#undef HAVE_RES_INIT_PROTO + +/* Define if you have a STL implementation by SGI */ +#undef HAVE_SGI_STL + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* Define to 1 if you have the <stdint.h> header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define if you have strlcat */ +#undef HAVE_STRLCAT + +/* Define if you have the strlcat prototype */ +#undef HAVE_STRLCAT_PROTO + +/* Define if you have strlcpy */ +#undef HAVE_STRLCPY + +/* Define if you have the strlcpy prototype */ +#undef HAVE_STRLCPY_PROTO + +/* Define to 1 if you have the <sys/bitypes.h> header file. */ +#undef HAVE_SYS_BITYPES_H + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* Suffix for lib directories */ +#undef KDELIBSUFF + +/* Define a safe value for MAXPATHLEN */ +#undef KDEMAXPATHLEN + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* The size of a `char *', as computed by sizeof. */ +#undef SIZEOF_CHAR_P + +/* The size of a `int', as computed by sizeof. */ +#undef SIZEOF_INT + +/* The size of a `long', as computed by sizeof. */ +#undef SIZEOF_LONG + +/* The size of a `short', as computed by sizeof. */ +#undef SIZEOF_SHORT + +/* The size of a `size_t', as computed by sizeof. */ +#undef SIZEOF_SIZE_T + +/* The size of a `unsigned long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION + +/* Defined if compiling without arts */ +#undef WITHOUT_ARTS + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* + * jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system + * headers and I'm too lazy to write a configure test as long as only + * unixware is related + */ +#ifdef _UNIXWARE +#define HAVE_BOOLEAN +#endif + + + +/* + * AIX defines FD_SET in terms of bzero, but fails to include <strings.h> + * that defines bzero. + */ + +#if defined(_AIX) +#include <strings.h> +#endif + + + +#if defined(HAVE_NSGETENVIRON) && defined(HAVE_CRT_EXTERNS_H) +# include <sys/time.h> +# include <crt_externs.h> +# define environ (*_NSGetEnviron()) +#endif + + + +#if !defined(HAVE_RES_INIT_PROTO) +#ifdef __cplusplus +extern "C" { +#endif +int res_init(void); +#ifdef __cplusplus +} +#endif +#endif + + + +#if !defined(HAVE_STRLCAT_PROTO) +#ifdef __cplusplus +extern "C" { +#endif +unsigned long strlcat(char*, const char*, unsigned long); +#ifdef __cplusplus +} +#endif +#endif + + + +#if !defined(HAVE_STRLCPY_PROTO) +#ifdef __cplusplus +extern "C" { +#endif +unsigned long strlcpy(char*, const char*, unsigned long); +#ifdef __cplusplus +} +#endif +#endif + + + +/* + * On HP-UX, the declaration of vsnprintf() is needed every time ! + */ + +#if !defined(HAVE_VSNPRINTF) || defined(hpux) +#if __STDC__ +#include <stdarg.h> +#include <stdlib.h> +#else +#include <varargs.h> +#endif +#ifdef __cplusplus +extern "C" +#endif +int vsnprintf(char *str, size_t n, char const *fmt, va_list ap); +#ifdef __cplusplus +extern "C" +#endif +int snprintf(char *str, size_t n, char const *fmt, ...); +#endif + + + +#if defined(__SVR4) && !defined(__svr4__) +#define __svr4__ 1 +#endif + + +/* type to use in place of socklen_t if not defined */ +#undef kde_socklen_t + +/* type to use in place of socklen_t if not defined (deprecated, use + kde_socklen_t) */ +#undef ksize_t diff --git a/konq-plugins/sidebar/metabar/configure.in.in b/konq-plugins/sidebar/metabar/configure.in.in new file mode 100644 index 0000000..d2a3d40 --- /dev/null +++ b/konq-plugins/sidebar/metabar/configure.in.in @@ -0,0 +1,5 @@ +#MIN_CONFIG(3.2.0) + +AM_INIT_AUTOMAKE(metabar, 0.1) +AC_C_BIGENDIAN +AC_CHECK_KDEMAXPATHLEN diff --git a/konq-plugins/sidebar/metabar/metabar.kdevelop b/konq-plugins/sidebar/metabar/metabar.kdevelop new file mode 100644 index 0000000..e87e8d9 --- /dev/null +++ b/konq-plugins/sidebar/metabar/metabar.kdevelop @@ -0,0 +1,213 @@ +<?xml version = '1.0'?> +<kdevelop> + <general> + <author>Florian Roth</author> + <email>[email protected]</email> + <version>0.1</version> + <projectmanagement>KDevKDEAutoProject</projectmanagement> + <primarylanguage>C++</primarylanguage> + <keywords> + <keyword>C++</keyword> + <keyword>Code</keyword> + <keyword>Qt</keyword> + <keyword>KDE</keyword> + <keyword>Kicker</keyword> + </keywords> + <ignoreparts/> + <projectdirectory>.</projectdirectory> + <absoluteprojectpath>false</absoluteprojectpath> + <description/> + <versioncontrol>kdevsubversion</versioncontrol> + </general> + <kdevautoproject> + <general> + <activetarget>src/konqsidebar_metabar.la</activetarget> + <useconfiguration>debug</useconfiguration> + </general> + <configurations> + <optimized> + <builddir>optimized</builddir> + <ccompiler>kdevgccoptions</ccompiler> + <cxxcompiler>kdevgppoptions</cxxcompiler> + <f77compiler>kdevg77options</f77compiler> + <cxxflags>-O2 -g0</cxxflags> + </optimized> + <debug> + <configargs>--enable-debug=full --prefix=`kde-config --prefix`</configargs> + <builddir>debug</builddir> + <ccompiler>kdevgccoptions</ccompiler> + <cxxcompiler>kdevgppoptions</cxxcompiler> + <f77compiler>kdevg77options</f77compiler> + <cxxflags>-O0 -g3</cxxflags> + <envvars/> + <topsourcedir/> + <cppflags/> + <ldflags/> + <ccompilerbinary/> + <cxxcompilerbinary/> + <f77compilerbinary/> + <cflags/> + <f77flags/> + </debug> + </configurations> + <make> + <envvars> + <envvar value="1" name="WANT_AUTOCONF_2_5" /> + <envvar value="1" name="WANT_AUTOMAKE_1_6" /> + </envvars> + <abortonerror>true</abortonerror> + <numberofjobs>1</numberofjobs> + <dontact>false</dontact> + <makebin/> + <prio>0</prio> + </make> + <run> + <directoryradio>executable</directoryradio> + <customdirectory>/</customdirectory> + <mainprogram/> + <programargs/> + <terminal>false</terminal> + <autocompile>true</autocompile> + <envvars/> + </run> + </kdevautoproject> + <kdevfileview> + <groups> + <group pattern="*.cpp;*.cxx;*.h" name="Sources" /> + <group pattern="*.ui" name="User Interface" /> + <group pattern="*.png" name="Icons" /> + <group pattern="*.po;*.ts" name="Translations" /> + <group pattern="*" name="Others" /> + <hidenonprojectfiles>false</hidenonprojectfiles> + <hidenonlocation>false</hidenonlocation> + </groups> + <tree> + <hidepatterns>*.o,*.lo,CVS</hidepatterns> + <hidenonprojectfiles>false</hidenonprojectfiles> + <showvcsfields>false</showvcsfields> + </tree> + </kdevfileview> + <kdevdoctreeview> + <ignoretocs> + <toc>ada</toc> + <toc>ada_bugs_gcc</toc> + <toc>bash</toc> + <toc>bash_bugs</toc> + <toc>clanlib</toc> + <toc>fortran_bugs_gcc</toc> + <toc>gnome1</toc> + <toc>gnustep</toc> + <toc>gtk</toc> + <toc>gtk_bugs</toc> + <toc>haskell</toc> + <toc>haskell_bugs_ghc</toc> + <toc>java_bugs_gcc</toc> + <toc>java_bugs_sun</toc> + <toc>opengl</toc> + <toc>pascal_bugs_fp</toc> + <toc>php</toc> + <toc>php_bugs</toc> + <toc>perl</toc> + <toc>perl_bugs</toc> + <toc>python</toc> + <toc>python_bugs</toc> + <toc>ruby</toc> + <toc>ruby_bugs</toc> + <toc>sdl</toc> + <toc>stl</toc> + <toc>sw</toc> + <toc>w3c-dom-level2-html</toc> + <toc>w3c-svg</toc> + <toc>w3c-uaag10</toc> + <toc>wxwidgets_bugs</toc> + </ignoretocs> + <ignoreqt_xml> + <toc>qmake User Guide</toc> + </ignoreqt_xml> + </kdevdoctreeview> + <kdevdebugger> + <general> + <dbgshell>libtool</dbgshell> + <programargs/> + <gdbpath/> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> + <breakonloadinglibs>true</breakonloadinglibs> + <separatetty>false</separatetty> + <floatingtoolbar>false</floatingtoolbar> + </general> + <display> + <staticmembers>false</staticmembers> + <demanglenames>true</demanglenames> + <outputradix>10</outputradix> + </display> + </kdevdebugger> + <kdevfilecreate> + <filetypes/> + <useglobaltypes> + <type ext="ui" /> + <type ext="cpp" /> + <type ext="h" /> + </useglobaltypes> + </kdevfilecreate> + <kdevdocumentation> + <projectdoc> + <docsystem>Doxygen-Dokumentation</docsystem> + <docurl>sidebar.tag</docurl> + <usermanualurl/> + </projectdoc> + </kdevdocumentation> + <substmap> + <APPNAME>sidebar</APPNAME> + <APPNAMELC>sidebar</APPNAMELC> + <APPNAMESC>Sidebar</APPNAMESC> + <APPNAMEUC>SIDEBAR</APPNAMEUC> + <AUTHOR>Florian Roth</AUTHOR> + <EMAIL>[email protected]</EMAIL> + <LICENSE>GPL</LICENSE> + <LICENSEFILE>COPYING</LICENSEFILE> + <VERSION>0.1</VERSION> + <YEAR>2005</YEAR> + <dest>/home/florian/sidebar</dest> + </substmap> + <cppsupportpart> + <filetemplates> + <interfacesuffix>.h</interfacesuffix> + <implementationsuffix>.cpp</implementationsuffix> + </filetemplates> + </cppsupportpart> + <kdevcppsupport> + <codecompletion> + <includeGlobalFunctions>true</includeGlobalFunctions> + <includeTypes>true</includeTypes> + <includeEnums>true</includeEnums> + <includeTypedefs>false</includeTypedefs> + <automaticCodeCompletion>true</automaticCodeCompletion> + <automaticArgumentsHint>true</automaticArgumentsHint> + <automaticHeaderCompletion>true</automaticHeaderCompletion> + <codeCompletionDelay>250</codeCompletionDelay> + <argumentsHintDelay>400</argumentsHintDelay> + <headerCompletionDelay>250</headerCompletionDelay> + </codecompletion> + <creategettersetter> + <prefixGet/> + <prefixSet>set</prefixSet> + <prefixVariable>m_,_</prefixVariable> + <parameterName>theValue</parameterName> + <inlineGet>true</inlineGet> + <inlineSet>true</inlineSet> + </creategettersetter> + <references/> + <designerintegration> + <qtdesigner> + <implementation class="ThemeEditor" path="src/editor/themeeditor.ui" implementationpath="src/editor/themeeditor.h" /> + <implementation class="ThemeEditor" path="src/editor/themeeditorui.ui" implementationpath="src/editor/themeeditor.h" /> + </qtdesigner> + </designerintegration> + </kdevcppsupport> + <ctagspart> + <customArguments/> + <customTagfilePath/> + </ctagspart> +</kdevelop> diff --git a/konq-plugins/sidebar/metabar/metabar.kdevses b/konq-plugins/sidebar/metabar/metabar.kdevses new file mode 100644 index 0000000..f28c20e --- /dev/null +++ b/konq-plugins/sidebar/metabar/metabar.kdevses @@ -0,0 +1,47 @@ +<?xml version = '1.0' encoding = 'UTF-8'?> +<!DOCTYPE KDevPrjSession> +<KDevPrjSession> + <DocsAndViews NumberOfDocuments="8" > + <Doc0 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/metabarwidget.cpp" > + <View0 Type="Source" /> + </Doc0> + <Doc1 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/metabarwidget.h" > + <View0 line="84" Type="Source" /> + </Doc1> + <Doc2 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/configdialog.cpp" > + <View0 line="109" Type="Source" /> + </Doc2> + <Doc3 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/configdialog.h" > + <View0 line="69" Type="Source" /> + </Doc3> + <Doc4 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/protocolplugin.cpp" > + <View0 line="69" Type="Source" /> + </Doc4> + <Doc5 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/defaultplugin.cpp" > + <View0 line="343" Type="Source" /> + </Doc5> + <Doc6 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/httpplugin.cpp" > + <View0 line="76" Type="Source" /> + </Doc6> + <Doc7 NumberOfViews="1" URL="file:///home/florian/metabar/metabar/src/httpplugin.h" > + <View0 line="22" Type="Source" /> + </Doc7> + </DocsAndViews> + <pluginList> + <kdevdebugger> + <breakpointList/> + </kdevdebugger> + <kdevbookmarks> + <bookmarks/> + </kdevbookmarks> + <kdevsubversion> + <subversion recurseresolve="1" recurserelocate="1" recursemerge="1" recursecommit="1" base="" recursepropget="1" recurseswitch="1" recurseupdate="1" recursepropset="1" recursediff="1" recurserevert="1" forcemove="1" recursecheckout="1" forceremove="1" recurseadd="1" recurseproplist="1" forcemerge="1" /> + </kdevsubversion> + <kdevvalgrind> + <executable path="" params="" /> + <valgrind path="" params="" /> + <calltree path="calltree" params="" /> + <kcachegrind path="/usr/kde/3.4/bin/kcachegrind" /> + </kdevvalgrind> + </pluginList> +</KDevPrjSession> diff --git a/konq-plugins/sidebar/metabar/src/Makefile.am b/konq-plugins/sidebar/metabar/src/Makefile.am new file mode 100644 index 0000000..cd18deb --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/Makefile.am @@ -0,0 +1,28 @@ +INCLUDES = $(all_includes) -I$(kde_includes)/dom +METASOURCES = AUTO + +kde_module_LTLIBRARIES = konqsidebar_metabar.la + +KDE_ICON = AUTO + +konqsidebar_metabar_la_SOURCES = metabar.cpp metabarwidget.cpp configdialog.cpp \ + serviceloader.cpp defaultplugin.cpp protocolplugin.cpp settingsplugin.cpp \ + remoteplugin.cpp httpplugin.cpp metabarfunctions.cpp +konqsidebar_metabar_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -lkonqsidebarplugin +konqsidebar_metabar_la_LIBADD = $(LIB_KIO) $(LIB_KHTML) $(LIB_KPARTS) + +metabar_entrydir = $(kde_datadir)/konqsidebartng/entries +metabar_entry_DATA = metabar.desktop +metabar_adddir = $(kde_datadir)/konqsidebartng/add +metabar_add_DATA = metabar_add.desktop +metabar_datadir = $(kde_datadir)/metabar +metabar_data_DATA = iconsrc +metabar_themedir = $(kde_datadir)/metabar/themes/default +metabar_theme_DATA = default.css layout.html + +noinst_HEADERS = metabarwidget.h protocolplugin.h defaultplugin.h \ + settingsplugin.h remoteplugin.h httpplugin.h metabarfunctions.h + +messages: + $(XGETTEXT) *.cpp *.h -o $(podir)/konqsidebar_metabar.pot + diff --git a/konq-plugins/sidebar/metabar/src/configdialog.cpp b/konq-plugins/sidebar/metabar/src/configdialog.cpp new file mode 100644 index 0000000..a6ee429 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/configdialog.cpp @@ -0,0 +1,611 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#include <qgroupbox.h> +#include <qlayout.h> +#include <qtabwidget.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qdir.h> +#include <qfileinfo.h> +#include <qmap.h> +#include <qcstring.h> +#include <qdatastream.h> + +#include <kdebug.h> +#include <klocale.h> +#include <kicondialog.h> +#include <kapplication.h> +#include <kiconloader.h> +#include <kstandarddirs.h> +#include <kfiledialog.h> +#include <ktar.h> +#include <karchive.h> +#include <dcopref.h> +#include <dcopclient.h> + +#include "configdialog.h" + +LinkEntry::LinkEntry(QString name, QString url, QString icon){ + LinkEntry::name = name; + LinkEntry::url = url; + LinkEntry::icon = icon; +} + +ActionListItem::ActionListItem(QListBox *listbox, const QString &action, const QString &text, const QPixmap &pixmap) : QListBoxPixmap(listbox, pixmap) +{ + setAction(action); + setText(text); +} + +ConfigDialog::ConfigDialog(QWidget *parent, const char *name) : QDialog(parent, name) +{ + topWidgetName = parent->topLevelWidget()->name(); + config = new KConfig("metabarrc"); + iconConfig = new KConfig(locate("data", "metabar/iconsrc")); + + setCaption(i18n("Configuration - Metabar")); + setIcon(SmallIcon("metabar")); + + ok = new KPushButton(KStdGuiItem::ok(), this); + connect(ok, SIGNAL(clicked()), this, SLOT(accept())); + + cancel = new KPushButton(KStdGuiItem::cancel(), this); + connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); + + QTabWidget *tab = new QTabWidget(this); + + //general page + config->setGroup("General"); + QWidget *general = new QWidget; + + QGroupBox *entries_group = new QGroupBox(2, Qt::Horizontal, i18n("Items"), general); + entries_group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + + QLabel *entries_label = new QLabel(i18n("Open with:"), entries_group); + max_entries = new KIntSpinBox(entries_group); + max_entries->setMinValue(1); + max_entries->setMaxValue(99); + max_entries->setLineStep(1); + max_entries->setValue(config->readNumEntry("MaxEntries", 3)); + entries_label->setBuddy(max_entries); + + QLabel *actions_label = new QLabel(i18n("Actions:"), entries_group); + max_actions = new KIntSpinBox(entries_group); + max_actions->setMinValue(1); + max_actions->setMaxValue(99); + max_actions->setLineStep(1); + max_actions->setValue(config->readNumEntry("MaxActions", 3)); + actions_label->setBuddy(max_actions); + + + QGroupBox *appearance_group = new QGroupBox(1, Qt::Horizontal, i18n("Appearance"), general); + appearance_group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + + animate = new QCheckBox(i18n("Animate resize"), appearance_group); + animate->setChecked(config->readBoolEntry("AnimateResize", false)); + + servicemenus = new QCheckBox(i18n("Show service menus"), appearance_group); + servicemenus->setChecked(config->readBoolEntry("ShowServicemenus", true)); + + showframe = new QCheckBox(i18n("Show frame"), appearance_group); + showframe->setChecked(config->readBoolEntry("ShowFrame", true)); + + QGroupBox *theme_group = new QGroupBox(2, Qt::Horizontal, i18n("Themes"), general); + theme_group->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + + themes = new KComboBox(theme_group); + themes->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + + install_theme = new KPushButton(i18n("Install New Theme..."), theme_group); + install_theme->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + connect(install_theme, SIGNAL(clicked()), this, SLOT(installTheme())); + + loadThemes(); + + //link page + QWidget *links = new QWidget; + + link_create = new KPushButton(i18n("New..."), links); + connect(link_create, SIGNAL(clicked()), this, SLOT(createLink())); + + link_delete = new KPushButton(i18n("Delete"), links); + connect(link_delete, SIGNAL(clicked()), this, SLOT(deleteLink())); + + link_edit = new KPushButton(i18n("Edit..."), links); + connect(link_edit, SIGNAL(clicked()), this, SLOT(editLink())); + + link_up = new KPushButton(links); + link_up->setIconSet(SmallIconSet("up")); + link_up->setEnabled(false); + connect(link_up, SIGNAL(clicked()), this, SLOT(moveLinkUp())); + + link_down = new KPushButton(links); + link_down->setIconSet(SmallIconSet("down")); + link_down->setEnabled(false); + connect(link_down, SIGNAL(clicked()), this, SLOT(moveLinkDown())); + + link_list = new KListView(links); + link_list->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + link_list->setSorting(-1); + link_list->setItemsMovable(TRUE); + link_list->addColumn(i18n("Name")); + link_list->addColumn(i18n("Address")); + connect(link_list, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editLink(QListViewItem*))); + connect(link_list, SIGNAL(selectionChanged()), SLOT(updateArrows())); + + QWidget *actionPage = new QWidget; + + actionSelector = new KActionSelector(actionPage); + loadAvailableActions(); + + tab->addTab(general, i18n("General")); + tab->addTab(actionPage, i18n("Actions")); + tab->addTab(links, i18n("Links")); + + //layout + QGridLayout *general_layout = new QGridLayout(general, 2, 2, 5, 5); + general_layout->addWidget(entries_group, 0, 0); + general_layout->addWidget(appearance_group, 0, 1); + general_layout->addMultiCellWidget(theme_group, 1, 1, 0, 1); + general_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 2, 0); + //general_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 0, 2); + + QVBoxLayout *link_button_layout = new QVBoxLayout(0, 0, 5); + link_button_layout->addWidget(link_create); + link_button_layout->addWidget(link_edit); + link_button_layout->addWidget(link_delete); + link_button_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding)); + link_button_layout->addWidget(link_up); + link_button_layout->addWidget(link_down); + + QHBoxLayout *link_layout = new QHBoxLayout(links, 5, 5); + link_layout->addWidget(link_list); + link_layout->addLayout(link_button_layout); + + QHBoxLayout *action_layout = new QHBoxLayout(actionPage, 5, 5); + action_layout->addWidget(actionSelector); + + QHBoxLayout *bottom_layout = new QHBoxLayout(0, 5, 5); + bottom_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum)); + bottom_layout->addWidget(ok); + bottom_layout->addWidget(cancel); + + QVBoxLayout *main_layout = new QVBoxLayout(this, 5, 5); + main_layout->addWidget(tab); + main_layout->addLayout(bottom_layout); + + //load config + config->setGroup("General"); + + QStringList _links = config->readListEntry("Links"); + + for(QStringList::Iterator it = _links.begin(); it != _links.end(); ++it){ + config->setGroup("Link_" + (*it)); + + QString icon_str = config->readEntry("Icon", "folder"); + QPixmap icon(icon_str); + if(icon.isNull()){ + icon = SmallIcon(icon_str); + } + + QListViewItem *item = new QListViewItem(link_list, link_list->lastItem(), config->readEntry("Name"), config->readEntry("URL")); + item->setPixmap(0, icon); + + linkList.insert(item, new LinkEntry(config->readEntry("Name"), config->readEntry("URL"), icon_str)); + } + + config->setGroup("General"); + QStringList actions = config->readListEntry("Actions"); + for(QStringList::Iterator it = actions.begin(); it != actions.end(); ++it){ + if((*it).startsWith("metabar/")){ + if((*it).right((*it).length() - 8) == "share"){ + QString text = i18n("Share"); + + ActionListItem *item = new ActionListItem(actionSelector->selectedListBox(), *it, text, SmallIcon("network")); + + QListBoxItem *avItem = actionSelector->availableListBox()->findItem(text, Qt::ExactMatch); + if(avItem){ + delete avItem; + } + } + } + else{ + DCOPRef action(kapp->dcopClient()->appId(), QCString(topWidgetName).append("/action/").append((*it).utf8())); + + QString text = action.call("plainText()"); + QString icon = iconConfig->readEntry(*it, action.call("icon()")); + + ActionListItem *item = new ActionListItem(actionSelector->selectedListBox(), QString(*it), text, SmallIcon(icon)); + + QListBoxItem *avItem = actionSelector->availableListBox()->findItem(text, Qt::ExactMatch); + if(avItem){ + delete avItem; + } + } + } + + resize(400, 300); +} + +ConfigDialog::~ConfigDialog() +{ + delete config; + delete iconConfig; +} + +void ConfigDialog::accept() +{ + QStringList groups = config->groupList(); + for(QStringList::Iterator it = groups.begin(); it != groups.end(); ++it){ + if((*it).startsWith("Link_")){ + config->deleteGroup(*it); + } + } + + QStringList links; + QPtrDictIterator<LinkEntry> it(linkList); + + QListViewItem *item = link_list->firstChild(); + while(item) { + LinkEntry *entry = linkList[item]; + config->setGroup("Link_" + entry->name); + config->writeEntry("Name", entry->name); + config->writeEntry("URL", entry->url); + config->writeEntry("Icon", entry->icon); + + links.append(entry->name); + + item = item->nextSibling(); + } + + QStringList actions; + QListBox *box = actionSelector->selectedListBox(); + + for(int i = 0; i < box->numRows(); i++){ + ActionListItem *item = static_cast<ActionListItem*>(box->item(i)); + if(item){ + actions.append(item->action()); + } + } + + config->setGroup("General"); + config->writeEntry("Links", links); + config->writeEntry("Actions", actions); + config->writeEntry("Theme", themes->currentText()); + + config->writeEntry("MaxEntries", max_entries->value()); + config->writeEntry("MaxActions", max_actions->value()); + + config->writeEntry("AnimateResize", animate->isChecked()); + config->writeEntry("ShowServicemenus", servicemenus->isChecked()); + config->writeEntry("ShowFrame", showframe->isChecked()); + + config->sync(); + + QDialog::accept(); +} + +void ConfigDialog::createLink() +{ + QDialog *main = new QDialog(this); + main->setCaption(i18n("Create Link")); + main->setIcon(SmallIcon("metabar")); + + KPushButton *ok = new KPushButton(KStdGuiItem::ok(), main); + connect(ok, SIGNAL(clicked()), main, SLOT(accept())); + + KPushButton *cancel = new KPushButton(KStdGuiItem::cancel(), main); + connect(cancel, SIGNAL(clicked()), main, SLOT(reject())); + + QLineEdit *name = new QLineEdit(i18n("New link"), main); + QLineEdit *url = new QLineEdit("file:/", main); + + KIconButton *icon = new KIconButton(main); + icon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + icon->setIconType(KIcon::Small, KIcon::Any); + icon->setStrictIconSize(true); + icon->setIcon("folder"); + + QHBoxLayout *bottom_layout = new QHBoxLayout(0, 0, 5); + bottom_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum)); + bottom_layout->addWidget(ok); + bottom_layout->addWidget(cancel); + + QGridLayout *layout = new QGridLayout(0, 2, 3, 0, 5); + layout->addMultiCellWidget(icon, 0, 1, 0, 0); + layout->addWidget(new QLabel(i18n("Name:"), main), 0, 1); + layout->addWidget(name, 0, 2); + layout->addWidget(new QLabel(i18n("URL:"), main), 1, 1); + layout->addWidget(url, 1, 2); + + QVBoxLayout *main_layout = new QVBoxLayout(main, 5, 5); + main_layout->addLayout(layout); + main_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding)); + main_layout->addLayout(bottom_layout); + + main->resize(300, main->sizeHint().height()); + + if(main->exec() == QDialog::Accepted){ + QString name_str = name->text(); + QString url_str = url->text(); + QString icon_str = icon->icon(); + + if(!name_str.isEmpty() && !url_str.isEmpty()){ + if(icon_str.isEmpty()){ + icon_str = kapp->iconLoader()->iconPath("folder", KIcon::Small); + } + + QPixmap icon(icon_str); + if(icon.isNull()){ + icon = SmallIcon(icon_str); + } + + QListViewItem *item = new QListViewItem(link_list, link_list->lastItem(), name_str, url_str); + item->setPixmap(0, icon); + + linkList.insert(item, new LinkEntry(name_str, url_str, icon_str)); + updateArrows(); + } + } + + delete main; +} + +void ConfigDialog::deleteLink() +{ + QListViewItem *item = link_list->selectedItem(); + if(item){ + linkList.remove(item); + delete item; + updateArrows(); + } +} + +void ConfigDialog::editLink() +{ + QListViewItem *item = link_list->selectedItem(); + editLink(item); +} + +void ConfigDialog::editLink(QListViewItem *item) +{ + if(item){ + QDialog *main = new QDialog(this); + main->setCaption(i18n("Edit Link")); + main->setIcon(SmallIcon("metabar")); + + KPushButton *ok = new KPushButton(KStdGuiItem::ok(), main); + connect(ok, SIGNAL(clicked()), main, SLOT(accept())); + + KPushButton *cancel = new KPushButton(KStdGuiItem::cancel(), main); + connect(cancel, SIGNAL(clicked()), main, SLOT(reject())); + + QLineEdit *name = new QLineEdit(linkList[item]->name, main); + QLineEdit *url = new QLineEdit(linkList[item]->url, main); + + KIconButton *icon = new KIconButton(main); + icon->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + icon->setIconType(KIcon::Small, KIcon::Any); + icon->setStrictIconSize(true); + icon->setIcon(linkList[item]->icon); + + QHBoxLayout *bottom_layout = new QHBoxLayout(0, 0, 5); + bottom_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum)); + bottom_layout->addWidget(ok); + bottom_layout->addWidget(cancel); + + QGridLayout *layout = new QGridLayout(0, 2, 3, 0, 5); + layout->addMultiCellWidget(icon, 0, 1, 0, 0); + layout->addWidget(new QLabel(i18n("Name:"), main), 0, 1); + layout->addWidget(name, 0, 2); + layout->addWidget(new QLabel(i18n("URL:"), main), 1, 1); + layout->addWidget(url, 1, 2); + + QVBoxLayout *main_layout = new QVBoxLayout(main, 5, 5); + main_layout->addLayout(layout); + main_layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding)); + main_layout->addLayout(bottom_layout); + + main->resize(300, main->sizeHint().height()); + + if(main->exec() == QDialog::Accepted){ + QString name_str = name->text(); + QString url_str = url->text(); + QString icon_str = icon->icon(); + + if(!name_str.isEmpty() && !url_str.isEmpty()){ + if(icon_str.isEmpty()){ + icon_str = kapp->iconLoader()->iconPath("folder", KIcon::Small); + } + + QPixmap icon(icon_str); + if(icon.isNull()){ + icon = SmallIcon(icon_str); + } + + linkList[item]->name = name_str; + linkList[item]->url = url_str; + linkList[item]->icon = icon_str; + + item->setText(0, name_str); + item->setText(1, url_str); + item->setPixmap(0, icon); + } + } + + delete main; + } +} + +void ConfigDialog::moveLinkUp() +{ + QListViewItem *item = link_list->selectedItem(); + if(item){ + if(link_list->itemIndex(item) > 0){ + + QListViewItem *after; + QListViewItem *above = item->itemAbove(); + if(above){ + after = above->itemAbove(); + } + + QString name = linkList[item]->name; + QString url = linkList[item]->url; + QString icon_str = linkList[item]->icon; + + QPixmap icon(icon_str); + if(icon.isNull()){ + icon = SmallIcon(icon_str); + } + + delete linkList[item]; + linkList.remove(item); + delete item; + + QListViewItem *newItem = new QListViewItem(link_list, after, name, url); + newItem->setPixmap(0, icon); + link_list->setSelected(newItem, TRUE); + + linkList.insert(newItem, new LinkEntry(name, url, icon_str)); + updateArrows(); + } + } +} + +void ConfigDialog::moveLinkDown() +{ + QListViewItem *item = link_list->selectedItem(); + if(item){ + if(link_list->itemIndex(item) < linkList.count() - 1){ + + QListViewItem *after = item->itemBelow(); + + QString name = linkList[item]->name; + QString url = linkList[item]->url; + QString icon_str = linkList[item]->icon; + + QPixmap icon(icon_str); + if(icon.isNull()){ + icon = SmallIcon(icon_str); + } + + delete linkList[item]; + linkList.remove(item); + delete item; + + QListViewItem *newItem = new QListViewItem(link_list, after, name, url); + newItem->setPixmap(0, icon); + link_list->setSelected(newItem, TRUE); + + linkList.insert(newItem, new LinkEntry(name, url, icon_str)); + updateArrows(); + } + } +} + +void ConfigDialog::loadAvailableActions() +{ + QListBox *box = actionSelector->availableListBox(); + + QByteArray data, replyData; + QCString replyType; + + if(DCOPClient::mainClient()->call(kapp->dcopClient()->appId(), topWidgetName, "actionMap()", data, replyType, replyData)){ + if(replyType == "QMap<QCString,DCOPRef>"){ + QMap<QCString,DCOPRef> actionMap; + + QDataStream reply(replyData, IO_ReadOnly); + reply >> actionMap; + + iconConfig->setGroup("Icons"); + + QMap<QCString,DCOPRef>::Iterator it; + for(it = actionMap.begin(); it != actionMap.end(); ++it){ + DCOPRef action = it.data(); + + QString text = action.call("plainText()"); + QCString cname = action.call("name()"); + QString icon = iconConfig->readEntry(QString(cname), action.call("icon()")); + + ActionListItem *item = new ActionListItem(box, QString(cname), text, SmallIcon(icon)); + } + } + } + + //metabar's own actions + ActionListItem *item = new ActionListItem(box, "metabar/share", i18n("Share"), SmallIcon("network")); +} + +void ConfigDialog::updateArrows() +{ + link_up->setEnabled( link_list->childCount()>1 && link_list->currentItem()!=link_list->firstChild() ); + link_down->setEnabled( link_list->childCount()>1 && link_list->currentItem()!=link_list->lastItem() ); +} + +void ConfigDialog::loadThemes() +{ + themes->clear(); + + QString theme = config->readEntry("Theme", "default"); + bool foundTheme = false; + + QStringList dirs = kapp->dirs()->findDirs("data", "metabar/themes"); + for(QStringList::Iterator it = dirs.begin(); it != dirs.end(); ++it){ + QStringList theme_list = QDir(*it).entryList(QDir::Dirs); + + theme_list.remove("."); + theme_list.remove(".."); + themes->insertStringList(theme_list); + + if(theme_list.find(theme) != theme_list.end()){ + foundTheme = true; + } + } + + if(foundTheme){ + themes->setCurrentText(theme); + } + else{ + themes->insertItem(theme); + } +} + +void ConfigDialog::installTheme() +{ + QString file = KFileDialog::getOpenFileName(); + if(file.isNull() && file.isEmpty()) return; + + QString themedir = locateLocal("data", "metabar/themes"); + if(themedir.isNull()) return; + + KTar archive(file); + archive.open(IO_ReadOnly); + kapp->processEvents(); + + const KArchiveDirectory* rootDir = archive.directory(); + rootDir->copyTo(themedir); + + archive.close(); + loadThemes(); +} + +#include "configdialog.moc" diff --git a/konq-plugins/sidebar/metabar/src/configdialog.h b/konq-plugins/sidebar/metabar/src/configdialog.h new file mode 100644 index 0000000..872bd8b --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/configdialog.h @@ -0,0 +1,114 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef _CONFIGDIALOG_H_ +#define _CONFIGDIALOG_H_ + +#include <qdialog.h> +#include <kpushbutton.h> +#include <klistview.h> +#include <knuminput.h> +#include <kconfig.h> +#include <qptrdict.h> +#include <qlistbox.h> +#include <kactionselector.h> +#include <qcheckbox.h> +#include <kcombobox.h> + +class LinkEntry{ + public: + LinkEntry(QString name, QString url, QString icon); + + ~LinkEntry(){} + + QString name; + QString url; + QString icon; +}; + +class ConfigDialog : public QDialog +{ + Q_OBJECT + + public: + ConfigDialog(QWidget *parent = 0, const char *name = 0); + ~ConfigDialog(); + + protected: + KPushButton *ok; + KPushButton *cancel; + + KPushButton *link_create; + KPushButton *link_delete; + KPushButton *link_edit; + KPushButton *link_up; + KPushButton *link_down; + + KPushButton *install_theme; + + KIntSpinBox *max_entries; + KIntSpinBox *max_actions; + + QCheckBox *animate; + QCheckBox *servicemenus; + QCheckBox *showframe; + + KListView *link_list; + + KComboBox *themes; + + QCString topWidgetName; + + KActionSelector *actionSelector; + + QPtrDict<LinkEntry> linkList; + + KConfig *config; + KConfig *iconConfig; + + protected slots: + void accept(); + void createLink(); + void deleteLink(); + void editLink(); + void editLink(QListViewItem *item); + void moveLinkUp(); + void moveLinkDown(); + void updateArrows(); + void installTheme(); + + private: + void loadAvailableActions(); + void loadThemes(); +}; + +class ActionListItem : public QListBoxPixmap +{ + public: + ActionListItem(QListBox *listbox, const QString &action, const QString &text, const QPixmap &pixmap); + ~ActionListItem(){} + + const QString action() { return act; } + void setAction(const QString act){ ActionListItem::act = act; } + + private: + QString act; +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/default.css b/konq-plugins/sidebar/metabar/src/default.css new file mode 100644 index 0000000..0bae4ab --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/default.css @@ -0,0 +1,64 @@ +body { + background-color: window; + font-family: sans-serif; + font-size: 11px; + color: windowtext; +} + +.frame { + background-color: threedface; + margin-bottom: 10px; + position: relative; + +} + +li { + list-style-type: none; + overflow: hidden; +} + +li ul { + margin: 0px; + padding: 0px; + height: 20px; + white-space: nowrap; +} + +a { + display: block; + padding-top: 5px; + padding-left: 24px; + background-position: 4px 2px; + background-repeat: no-repeat; + + text-decoration: none; + color: buttontext; + +} + +a:hover { + text-decoration: underline; +} + +a.title { + font-weight: bold; + border-bottom: solid 1px threeddarkshadow; + cursor: pointer; + height: 15px; + background-repeat: none; +} + +a.infotitle { + font-weight: bold; + padding-left: 5px; + cursor: pointer; +} + +.preview { + padding: 5px; + text-align: center; +} + +ul.info { + padding-left: 5px; +}
\ No newline at end of file diff --git a/konq-plugins/sidebar/metabar/src/defaultplugin.cpp b/konq-plugins/sidebar/metabar/src/defaultplugin.cpp new file mode 100644 index 0000000..6c8dec3 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/defaultplugin.cpp @@ -0,0 +1,458 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "defaultplugin.h" +#include "metabarwidget.h" + +#include <kurl.h> +#include <kstandarddirs.h> +#include <kicontheme.h> +#include <khtmlview.h> +#include <klocale.h> +#include <kapplication.h> +#include <kdesktopfile.h> +#include <ktrader.h> +#include <krun.h> +#include <kfilemetainfo.h> +#include <kconfig.h> +#include <kimageio.h> +#include <kdebug.h> +#include <kmdcodec.h> + +#include <kio/previewjob.h> + +#include <dcopclient.h> +#include <dcopref.h> + +#include <qdir.h> +#include <qfile.h> +#include <qrect.h> +#include <qpoint.h> +#include <qbuffer.h> + +#include <dom_string.h> +#include <html_image.h> + +#define EVENT_TYPE DOM::DOMString("click") +#define MODIFICATION 1 + +DefaultPlugin::DefaultPlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name) : ProtocolPlugin (html, functions, name) +{ + services = new ServiceLoader(m_html->view(), "serviceloader"); + + preview_job = 0; +} + +DefaultPlugin::~DefaultPlugin() +{ +} + +void DefaultPlugin::killJobs(){ + if(preview_job){ + preview_job->kill(); + preview_job = 0; + } +} + +void DefaultPlugin::deactivate() +{ + m_functions->hide("actions"); + m_functions->hide("open"); + m_functions->hide("info"); + m_functions->hide("preview"); +} + +void DefaultPlugin::loadActions(DOM::HTMLElement node) +{ + KFileItem *item = m_items.getFirst(); + KURL url = item->url(); + + KConfig config("metabarrc", true, false); + config.setGroup("General"); + + KConfig iconConfig(locate("data", "metabar/iconsrc")); + iconConfig.setGroup("Icons"); + + DOM::DOMString innerHTML; + + QStringList actions = config.readListEntry("Actions"); + int maxActions = config.readNumEntry("MaxActions", 5); + int actionCount = 0; + + for(QStringList::Iterator it = actions.begin(); it != actions.end(); ++it){ + if((*it).startsWith("metabar/")){ + if((*it).right((*it).length() - 8) == "share"){ + MetabarWidget::addEntry(innerHTML, i18n("Share"), "action://" + *it, "network", QString::null, actionCount < maxActions ? QString::null : QString("hiddenaction"), actionCount >= maxActions); + actionCount++; + } + } + else{ + DCOPRef action(kapp->dcopClient()->appId(), QCString(m_html->view()->topLevelWidget()->name()).append("/action/").append((*it).utf8())); + + if(!action.isNull()){ + if(action.call("enabled()")){ + QString text = action.call("plainText()"); + QString icon = iconConfig.readEntry(*it, action.call("icon()")); + + MetabarWidget::addEntry(innerHTML, text, "action://" + *it, icon, QString::null, actionCount < maxActions ? QString::null : QString("hiddenaction"), actionCount >= maxActions); + actionCount++; + } + } + } + } + + config.setGroup("General"); + if(config.readBoolEntry("ShowServicemenus", true)){ + services->loadServices(*(m_items.getFirst()), innerHTML, actionCount); + } + + if(actionCount == 0) { + m_functions->hide("actions"); + } + else{ + if(actionCount > maxActions){ + MetabarWidget::addEntry(innerHTML, i18n("More"), "more://hiddenaction", "1downarrow", "hiddenaction"); + } + + node.setInnerHTML(innerHTML); + m_functions->show("actions"); + } +} + +void DefaultPlugin::loadApplications(DOM::HTMLElement node) +{ + if(m_items.count() == 1){ + KFileItem *item = m_items.getFirst(); + KURL url = item->url(); + + QDir dir(url.path()); + dir = dir.canonicalPath(); + + if(item->isDir() || dir.isRoot()){ + m_functions->hide("open"); + node.setInnerHTML(DOM::DOMString()); + } + else{ + DOM::DOMString innerHTML; + + if(KDesktopFile::isDesktopFile(item->url().path())){ //Desktop file + KDesktopFile desktop(url.path(), TRUE); + + if(desktop.hasApplicationType ()){ + MetabarWidget::addEntry(innerHTML, i18n("Run %1").arg(desktop.readName()), "desktop://" + url.path(), desktop.readIcon()); + + m_functions->show("open"); + } + + else{ + m_functions->hide("open"); + } + } + else{ //other files + KTrader::OfferList offers; + + offers = KTrader::self()->query(item->mimetype(), "Type == 'Application'"); + if(!offers.isEmpty()){ + KConfig config("metabarrc", true, false); + config.setGroup("General"); + + int id = 0; + int max = config.readNumEntry("MaxEntries", 5); + + runMap.clear(); + KTrader::OfferList::ConstIterator it = offers.begin(); + + for(; it != offers.end(); it++){ + QString nam; + nam.setNum(id); + + bool hide = id >= max; + MetabarWidget::addEntry(innerHTML, (*it)->name(), "exec://" + nam, (*it)->icon(), QString::null, hide ? QString("hiddenapp") : QString::null, hide); + + runMap.insert(id, *it); + id++; + } + + if(id > max){ + MetabarWidget::addEntry(innerHTML, i18n("More"), "more://hiddenapp", "1downarrow", "hiddenapp"); + } + } + else{ + MetabarWidget::addEntry(innerHTML, i18n("Choose Application"), "openwith:///", "run"); + } + } + + node.setInnerHTML(innerHTML); + + m_functions->show("open"); + } + } + else{ + m_functions->hide("open"); + } +} + +void DefaultPlugin::loadInformation(DOM::HTMLElement node) +{ + if(m_items.count() == 1){ + KFileItem *item = m_items.getFirst(); + KFileItem *that = const_cast<KFileItem *>(item); + + DOM::DOMString innerHTML; + innerHTML += "<ul class=\"info\"><b>" + i18n("Type") + ": </b>"; + innerHTML += that->determineMimeType()->comment(); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Size") + ": </b>"; + innerHTML += KIO::convertSize(item->size()); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("User") + ": </b>"; + innerHTML += item->user(); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Group") + ": </b>"; + innerHTML += item->group(); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Permissions") + ": </b>"; + innerHTML += (item->permissionsString()); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Modified") + ": </b>"; + innerHTML += item->timeString(KIO::UDS_MODIFICATION_TIME); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Accessed") + ": </b>"; + innerHTML += item->timeString(KIO::UDS_ACCESS_TIME); + innerHTML += "</ul>"; + + if(item->isLink()){ + innerHTML += "<ul class=\"info\"><b>" + i18n("Linktarget") + ": </b>"; + innerHTML += item->linkDest(); + innerHTML += "</ul>"; + } + + if(!item->isDir()){ + const KFileMetaInfo &metaInfo = item->metaInfo(); + if(metaInfo.isValid()){ + QStringList groups = metaInfo.supportedGroups(); + + int id = 0; + QString nam; + + for(QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it){ + KFileMetaInfoGroup group = metaInfo.group(*it); + if(group.isValid()){ + nam.setNum(id); + + innerHTML += "<ul class=\"info\"><a class=\"infotitle\" id=\"info_" + nam + "\" href=\"more://info_" + nam + "\">" + group.translatedName() + "</a></ul>"; + + QStringList keys = group.supportedKeys(); + + for(QStringList::ConstIterator it = keys.begin(); it != keys.end(); ++it){ + const KFileMetaInfoItem metaInfoItem = group.item(*it); + + if(metaInfoItem.isValid()){ + + innerHTML += "<ul class=\"info\" style=\"display:none\"><b name=\"info_" + nam + "\">" + metaInfoItem.translatedKey() + ": </b>"; + innerHTML += metaInfoItem.string(); + innerHTML += "</ul>"; + } + } + + id++; + } + } + } + } + + node.setInnerHTML(innerHTML); + } + else{ + KIO::filesize_t size = 0; + int files = 0; + int dirs = 0; + + for(KFileItemListIterator it(m_items); it.current(); ++it){ + size += (*it)->size(); + + if((*it)->isDir()){ + dirs++; + } + else{ + files++; + } + } + + DOM::DOMString innerHTML; + innerHTML += "<ul class=\"info\"><b>" + i18n("Size") + ": </b>"; + innerHTML += KIO::convertSize(size); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Files") + ": </b>"; + innerHTML += QString().setNum(files); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Folders") + ": </b>"; + innerHTML += QString().setNum(dirs); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Total Entries") + ": </b>"; + innerHTML += QString().setNum(m_items.count()); + innerHTML += "</ul>"; + node.setInnerHTML(innerHTML); + } + m_functions->show("info"); +} + +void DefaultPlugin::loadPreview(DOM::HTMLElement node) +{ + if(m_items.count() == 1){ + KFileItem *item = m_items.getFirst(); + KURL url = item->url(); + + QDir dir(url.path()); + dir = dir.canonicalPath(); + + if(item->isDir() || dir.isRoot()){ + m_functions->hide("preview"); + } + else{ + if(item->mimetype().startsWith("audio/")){ + DOM::DOMString innerHTML("<ul><a class=\"previewdesc\" href=\"preview:///\">"); + innerHTML += i18n("Click to start preview"); + innerHTML += "</a></ul>"; + node.setInnerHTML(innerHTML); + + //m_functions->show("preview"); + } + else{ + DOM::DOMString innerHTML("<ul style=\"text-align-center\"><nobr>"); + innerHTML += i18n("Creating preview"); + innerHTML += "</nobr></ul>"; + node.setInnerHTML(innerHTML); + + //m_functions->show("preview"); + + preview_job = KIO::filePreview(KURL::List(url), m_html->view()->width() - 30); + + connect(preview_job, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)), this, SLOT(slotSetPreview(const KFileItem*, const QPixmap&))); + connect(preview_job, SIGNAL(failed(const KFileItem *)), this, SLOT(slotPreviewFailed(const KFileItem *))); + connect(preview_job, SIGNAL(result(KIO::Job *)), this, SLOT(slotJobFinished(KIO::Job *))); + } + + m_functions->show("preview"); + } + } + else{ + m_functions->hide("preview"); + } +} + +void DefaultPlugin::loadBookmarks(DOM::HTMLElement node) +{ + m_functions->hide("bookmarks"); +} + +void DefaultPlugin::slotSetPreview(const KFileItem *item, const QPixmap &pix) +{ + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = doc.getElementById("preview"); + + QByteArray data; + QBuffer buffer(data); + buffer.open(IO_WriteOnly); + pix.save(&buffer, "PNG"); + + QString src = QString::fromLatin1("data:image/png;base64,%1").arg(KCodecs::base64Encode(data)); + bool media = item->mimetype().startsWith("video/"); + + DOM::DOMString innerHTML; + + innerHTML += QString("<ul style=\"height: %1px\"><a class=\"preview\"").arg(pix.height() + 15); + + if(media){ + innerHTML += " href=\"preview:///\""; + } + innerHTML +="><img id=\"previewimage\" src=\""; + innerHTML += src; + innerHTML += "\" width=\""; + innerHTML += QString().setNum(pix.width()); + innerHTML += "\" height=\""; + innerHTML += QString().setNum(pix.height()); + innerHTML += "\" /></a></ul>"; + + if(media){ + innerHTML += "<ul><a class=\"previewdesc\" href=\"preview:///\">" + i18n("Click to start preview") + "</a></ul>"; + } + + node.setInnerHTML(innerHTML); + + //script.append("adjustPreviewSize(" + height_str + ");"); + m_functions->show("preview"); + m_functions->adjustSize("preview"); +} + +void DefaultPlugin::slotPreviewFailed(const KFileItem *item) +{ + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement preview = static_cast<DOM::HTMLElement>(doc.getElementById("preview_image")); + if(!preview.isNull()){ + preview.setAttribute(DOM::DOMString("src"), DOM::DOMString()); + } + + m_functions->hide("preview"); +} + +void DefaultPlugin::slotJobFinished(KIO::Job *job) +{ + if(preview_job && job == preview_job){ + preview_job = 0; + } +} + +bool DefaultPlugin::handleRequest(const KURL &url) +{ + QString protocol = url.protocol(); + + if(protocol == "exec"){ + int id = url.host().toInt(); + + QMap<int,KService::Ptr>::Iterator it = runMap.find(id); + if(it != runMap.end()){ + + KFileItem *item = m_items.getFirst(); + if(item){ + KRun::run( **it, KURL::List(item->url())); + return true; + } + } + } + + else if(protocol == "service"){ + QString name = url.url().right(url.url().length() - 10); + + services->runAction(name); + return true; + } + + else if(protocol == "servicepopup"){ + QString id = url.host(); + + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById("popup" + id)); + + if(!node.isNull()){ + QRect rect = node.getRect(); + QPoint p = m_html->view()->mapToGlobal(rect.bottomLeft()); + + services->showPopup(id, p); + } + + return true; + } + + return false; +} + +#include "defaultplugin.moc" diff --git a/konq-plugins/sidebar/metabar/src/defaultplugin.h b/konq-plugins/sidebar/metabar/src/defaultplugin.h new file mode 100644 index 0000000..15b2e73 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/defaultplugin.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _DEFAULT_PLUGIN_H_ +#define _DEFAULT_PLUGIN_H_ + +#include "protocolplugin.h" +#include "serviceloader.h" + +#include <kio/previewjob.h> + +#include <qdict.h> +#include <qmap.h> + +class DefaultPlugin : public ProtocolPlugin +{ + Q_OBJECT + + public: + DefaultPlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name = 0); + ~DefaultPlugin(); + + void deactivate(); + bool handleRequest(const KURL &url); + + protected: + void killJobs(); + + void loadActions(DOM::HTMLElement node); + void loadApplications(DOM::HTMLElement node); + void loadInformation(DOM::HTMLElement node); + void loadPreview(DOM::HTMLElement node); + void loadBookmarks(DOM::HTMLElement node); + + private: + QMap<int,KService::Ptr> runMap; + KIO::PreviewJob *preview_job; + + ServiceLoader *services; + + private slots: + void slotSetPreview(const KFileItem*, const QPixmap&); + void slotPreviewFailed(const KFileItem *item); + void slotJobFinished(KIO::Job *item); +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/hi128-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi128-app-metabar.png Binary files differnew file mode 100644 index 0000000..1ee89bf --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/hi128-app-metabar.png diff --git a/konq-plugins/sidebar/metabar/src/hi16-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi16-app-metabar.png Binary files differnew file mode 100644 index 0000000..c47b0b0 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/hi16-app-metabar.png diff --git a/konq-plugins/sidebar/metabar/src/hi32-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi32-app-metabar.png Binary files differnew file mode 100644 index 0000000..c0d6213 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/hi32-app-metabar.png diff --git a/konq-plugins/sidebar/metabar/src/hi48-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi48-app-metabar.png Binary files differnew file mode 100644 index 0000000..763ec38 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/hi48-app-metabar.png diff --git a/konq-plugins/sidebar/metabar/src/hi64-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi64-app-metabar.png Binary files differnew file mode 100644 index 0000000..89fa615 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/hi64-app-metabar.png diff --git a/konq-plugins/sidebar/metabar/src/hisc-app-metabar.svgz b/konq-plugins/sidebar/metabar/src/hisc-app-metabar.svgz Binary files differnew file mode 100644 index 0000000..6b955f5 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/hisc-app-metabar.svgz diff --git a/konq-plugins/sidebar/metabar/src/httpplugin.cpp b/konq-plugins/sidebar/metabar/src/httpplugin.cpp new file mode 100644 index 0000000..aec402a --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/httpplugin.cpp @@ -0,0 +1,119 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "metabarwidget.h" +#include "httpplugin.h" + +#include <kbookmark.h> +#include <kstandarddirs.h> +#include <kapplication.h> +#include <kicontheme.h> +#include <khtmlview.h> +#include <kurl.h> +#include <klocale.h> + +#include <dcopref.h> +#include <dcopclient.h> + +#include <qregexp.h> +#include <qfile.h> + +#include <dom_node.h> +#include <html_inline.h> + +HTTPPlugin::HTTPPlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name) : ProtocolPlugin (html, functions, name) +{ +} + +HTTPPlugin::~HTTPPlugin() +{ + //delete bookmarkManager; +} + +void HTTPPlugin::deactivate() +{ + m_functions->hide("actions"); + m_functions->hide("info"); +} + +void HTTPPlugin::killJobs() +{ +} + +void HTTPPlugin::loadInformation(DOM::HTMLElement node) +{ + /*DOM::DOMString innerHTML; + innerHTML += "<form action=\"find:///\" method=\"GET\">"; + innerHTML += "<ul>"; + innerHTML += i18n("Keyword"); + innerHTML += " <input onFocus=\"this.value = ''\" type=\"text\" name=\"find\" id=\"find_text\" value=\""; + innerHTML += i18n("Web search"); + innerHTML += "\"></ul>"; + innerHTML += "<ul><input type=\"submit\" id=\"find_button\" value=\""; + innerHTML += i18n("Find"); + innerHTML += "\"></ul>"; + innerHTML += "</form>"; + + node.setInnerHTML(innerHTML); + m_functions->show("info");*/ + + m_functions->hide("info"); +} + +void HTTPPlugin::loadActions(DOM::HTMLElement node) +{ + m_functions->hide("actions"); +} + +void HTTPPlugin::loadApplications(DOM::HTMLElement node) +{ + m_functions->hide("open"); +} + +void HTTPPlugin::loadPreview(DOM::HTMLElement node) +{ + m_functions->hide("preview"); +} + +void HTTPPlugin::loadBookmarks(DOM::HTMLElement node) +{ + m_functions->hide("bookmarks"); +} + +bool HTTPPlugin::handleRequest(const KURL &url) +{ + if(url.protocol() == "find"){ + QString keyword = url.queryItem("find"); + QString type = url.queryItem("type"); + + if(!keyword.isNull() && !keyword.isEmpty()){ + KURL url("http://www.google.com/search"); + url.addQueryItem("q", keyword); + + DCOPRef ref(kapp->dcopClient()->appId(), m_html->view()->topLevelWidget()->name()); + DCOPReply reply = ref.call("openURL", url.url()); + } + + return true; + } + return false; +} + +#include "httpplugin.moc" diff --git a/konq-plugins/sidebar/metabar/src/httpplugin.h b/konq-plugins/sidebar/metabar/src/httpplugin.h new file mode 100644 index 0000000..c840e8f --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/httpplugin.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _HTTP_PLUGIN_H_ +#define _HTTP_PLUGIN_H_ + +#include "protocolplugin.h" + +#include <kdirwatch.h> +#include <kbookmarkmanager.h> + +#include <dom_string.h> + +class HTTPPlugin : public ProtocolPlugin +{ + Q_OBJECT + + public: + HTTPPlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name = 0); + ~HTTPPlugin(); + + bool handleRequest(const KURL &url); + void deactivate(); + + protected: + void loadActions(DOM::HTMLElement node); + void loadApplications(DOM::HTMLElement node); + void loadPreview(DOM::HTMLElement node); + void loadBookmarks(DOM::HTMLElement node); + void loadInformation(DOM::HTMLElement node); + void killJobs(); +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/iconsrc b/konq-plugins/sidebar/metabar/src/iconsrc new file mode 100644 index 0000000..a30f532 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/iconsrc @@ -0,0 +1,4 @@ +[Icons] +rename=edit +konq_create_dir=folder_new +properties=messagebox_info
\ No newline at end of file diff --git a/konq-plugins/sidebar/metabar/src/layout.html b/konq-plugins/sidebar/metabar/src/layout.html new file mode 100644 index 0000000..6bae311 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/layout.html @@ -0,0 +1,48 @@ +<html> +<head> +<title></title> + +</head> + +<body> + +<div class="frame"> + <div class="head"><a i18n image="wizard" class="title" onClick="this.blur();" href="function://toggle/actions">Actions</a></div> + <li id="actions" expanded="true" style="height:0px"> + </li> +</div> + +<div class="frame"> + <div class="head"><a i18n image="run" class="title" onClick="this.blur();" href="function://toggle/open">Open With</a></div> + <li id="open" expanded="true" style="height:0px"> + </li> +</div> + +<div class="frame"> + <div class="head"><a i18n image="bookmark" class="title" onClick="this.blur();" href="function://toggle/bookmarks">Bookmarks</a></div> + <li id="bookmarks" expanded="true" style="height:0px"> + </li> +</div> + +<div class="frame"> + <div class="head"><a i18n image="browser" class="title" onClick="this.blur();" href="function://toggle/links">Links</a></div> + <li id="links" expanded="true" style="height:0px"> + </li> +</div> + +<div class="frame"> + <div class="head"><a i18n image="messagebox_info" class="title" onClick="this.blur();" href="function://toggle/info">Information</a></div> +<li id="info" expanded="true" style="height:0px"> +</li> +</div> + +<div class="frame"> + <div class="head"><a i18n image="player_play" class="title" onClick="this.blur();" href="function://toggle/preview">Preview</a></div> + <li id="preview" expanded="true" style="height:0px"> + </li> +</div> + + +</body> + +</html> diff --git a/konq-plugins/sidebar/metabar/src/metabar.cpp b/konq-plugins/sidebar/metabar/src/metabar.cpp new file mode 100644 index 0000000..8181a11 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabar.cpp @@ -0,0 +1,59 @@ +#include <kinstance.h> +#include <qstring.h> +#include <kimageio.h> +#include <klocale.h> + +#include "metabarwidget.h" +#include "metabar.h" +#include "metabar.moc" + +Metabar::Metabar(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name): + KonqSidebarPlugin(inst,parent,widgetParent,desktopName,name) +{ + KImageIO::registerFormats(); + KGlobal::locale()->insertCatalogue( "konqsidebar_metabar" ); + + widget = new MetabarWidget(widgetParent, "metabarwidget"); +} + + +Metabar::~Metabar() +{ +} + +void Metabar::handleURL(const KURL &url) +{ + const KFileItem *item = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, url, true); + KFileItemList list; + list.append(item); + + widget->setFileItems(list); +} + +void Metabar::handlePreview(const KFileItemList &items) +{ + widget->setFileItems(items); +} + + +extern "C" { + bool add_konqsidebar_metabar(QString* fn, QString* param, QMap<QString,QString> *map) { + Q_UNUSED(param); + + map->insert("Type", "Link"); + map->insert("Icon", "metabar"); + map->insert("Name", "Metabar"); + map->insert("Open", "true"); + map->insert("X-KDE-KonqSidebarModule","konqsidebar_metabar"); + fn->setLatin1("metabar%1.desktop"); + return true; + } +} + +extern "C" +{ + void* create_konqsidebar_metabar(KInstance *instance,QObject *par,QWidget *widp,QString &desktopname,const char *name) + { + return new Metabar(instance,par,widp,desktopname,name); + } +} diff --git a/konq-plugins/sidebar/metabar/src/metabar.desktop b/konq-plugins/sidebar/metabar/src/metabar.desktop new file mode 100644 index 0000000..9ea7917 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabar.desktop @@ -0,0 +1,81 @@ +[Desktop Entry] +Type=Link +URL= +Icon=metabar +Comment=A konqueror navigation panel plugin called Metabar +Comment[bg]=Приставка за навигация в браузъра Konqueror +Comment[ca]=Un connector del plafó de navegació del konqueror anomenat Metabar +Comment[cs]=Navigační panel pro Konqueror - Metabar +Comment[da]=Et navigationspanel-plugin for konqueror der hedder Metabar +Comment[de]=Metabar - Ein Modul für den Navigationsbereich von Konqueror +Comment[el]=Ένα πρόσθετο πίνακα πλοήγησης του konqueror που ονομάζεται γραμμή μεταδεδομένων +Comment[en_GB]=A Konqueror navigation panel plugin called Metabar +Comment[eo]=Foliuma panela kromaĵo por Konkeranto nomata Metabar +Comment[es]=Un complemento del panel de navegación de konqueror llamado metabarra +Comment[et]=Konquerori navigeerimispaneeli plugin Metabar +Comment[eu]=Metabar izeneko Konqueror-en arakatze-panelaren plugina +Comment[fa]=وصلۀ تابلوی ناوش konqueror که فرامیله نام دارد +Comment[fi]=Konquerorin Metabar-niminen selauspaneelin liitännäinen +Comment[fr]=Un module pour le panneau de navigation de Konqueror appelé Metabar +Comment[fy]=In plugin foar Konqueror's navigaasjebalke, neamd Metabalke +Comment[ga]=Breiseán i bpainéal nascleanúna Konqueror darb ainm Metabar +Comment[gl]=Un plugin de navegación para konqueror chamado Metabar +Comment[hr]=Dodatak navigacijske ploče za Konqueror, zvan Metabar +Comment[hu]=Metabar, egy navigációs bővítőmodul a Konqueror böngészőhöz +Comment[is]=Konqueror leiðarstýrispjald íforrit sem kallast Metabar +Comment[it]=Plugin di navigazione di Konqueror chiamato Metabar +Comment[ja]=Konqueror メタバー ナビゲーションパネルプラグイン +Comment[ka]=konqueror ნავიგაციის მოდული სახელად Metabar +Comment[kk]=Metabar деген Konqueror панелінің плагин модулі +Comment[km]=កម្មវិធីជំនួយបន្ទះរុករករបស់ konqueror បានហៅរបារមេតា +Comment[lt]=Metabar - Konqueror navigacijos pulto priedas +Comment[mk]=Приклучок за панел за навигација во konqueror наречен Metabar +Comment[nb]=Et Konqueror programtillegg for navigasjonspanel, kalt Metabar +Comment[nds]=En Sietpaneelmoduul för Konqueror, nöömt "Metabar" +Comment[ne]=मेटाबार भनिने एउटा कन्क्वेरर नेभिगेसन प्यानल प्लगइन +Comment[nl]=Een plugin voor Konqueror's navigatiebalk, genaamd Metabalk +Comment[nn]=Eit programtillegg som gir Konqueror eit navigasjonpanel +Comment[pl]=Panel nawigacyjny Metabar dla Konquerora +Comment[pt]=Um 'plugin' de navegação do konqueror chamado Metabar +Comment[pt_BR]=Um plugin de navegação para o Konqueror chamado de Metabar +Comment[ru]=Панель сведений Konqueror +Comment[sk]=Modul navigačného panelu pre Konqueror nazývaný Metabar +Comment[sl]=Vstavek za Konqueror z navigacijskim pasom Metabar +Comment[sr]=Прикључак за навигациону таблу konqueror-а назван Метапалета +Comment[sr@Latn]=Priključak za navigacionu tablu konqueror-a nazvan Metapaleta +Comment[sv]=Ett sidopanelinsticksprogram för Konqueror kallad Metarad +Comment[tr]=Metabar isimli Konqueror gezinme paneli eklentisi +Comment[uk]=Втулок навігаційної панелі для konqueror - Metabar +Comment[vi]=Bổ sung bảng duyệt qua Konqueror tên Siêu Thanh +Comment[zh_CN]=称为 Metabar 的 Konqueror 导航面板插件 +Comment[zh_TW]=叫做 Metabar 的 Konqueror 導覽面板外掛程式 +Name=metabar +Name[de]=Metabar +Name[el]=Γραμμή μεταδεδομένων +Name[es]=metabarra +Name[et]=Metabar +Name[fa]=فرامیله +Name[fi]=metapalkki +Name[fr]=Metabar +Name[fy]=metabalke +Name[hu]=Metabar +Name[ja]=メタバー +Name[km]=របារមេតា +Name[ne]=मेटाबार +Name[nl]=metabalk +Name[pa]=ਮੈਟਾ-ਪੱਟੀ +Name[pl]=Metabar +Name[pt_BR]=MetaBar +Name[ru]=Сведения +Name[sk]=Metabar +Name[sl]=Metabar +Name[sr]=метапалета +Name[sr@Latn]=metapaleta +Name[sv]=Metarad +Name[tr]=Metabar +Name[vi]=siêu thanh +Name[zh_CN]=Metabar + +Open=false +X-KDE-KonqSidebarModule=konqsidebar_metabar + diff --git a/konq-plugins/sidebar/metabar/src/metabar.h b/konq-plugins/sidebar/metabar/src/metabar.h new file mode 100644 index 0000000..6d43592 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabar.h @@ -0,0 +1,32 @@ +#ifndef METABAR_H +#define METABAR_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <konqsidebarplugin.h> +#include <qstring.h> +#include <kconfig.h> + + +class Metabar : public KonqSidebarPlugin +{ + Q_OBJECT + + public: + Metabar(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name=0); + ~Metabar(); + + virtual QWidget *getWidget(){ return widget; } + virtual void *provides(const QString &) { return 0; } + + protected: + MetabarWidget *widget; + + void handleURL(const KURL &url); + void handlePreview(const KFileItemList &items); + +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/metabar_add.desktop b/konq-plugins/sidebar/metabar/src/metabar_add.desktop new file mode 100644 index 0000000..e7003e9 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabar_add.desktop @@ -0,0 +1,70 @@ +[Desktop Entry] +Comment=A konqueror navigation panel plugin called Metabar +Comment[bg]=Приставка за навигация в браузъра Konqueror +Comment[ca]=Un connector del plafó de navegació del konqueror anomenat Metabar +Comment[cs]=Navigační panel pro Konqueror - Metabar +Comment[da]=Et navigationspanel-plugin for konqueror der hedder Metabar +Comment[de]=Metabar - Ein Modul für den Navigationsbereich von Konqueror +Comment[el]=Ένα πρόσθετο πίνακα πλοήγησης του konqueror που ονομάζεται γραμμή μεταδεδομένων +Comment[en_GB]=A Konqueror navigation panel plugin called Metabar +Comment[eo]=Foliuma panela kromaĵo por Konkeranto nomata Metabar +Comment[es]=Un complemento del panel de navegación de konqueror llamado metabarra +Comment[et]=Konquerori navigeerimispaneeli plugin Metabar +Comment[eu]=Metabar izeneko Konqueror-en arakatze-panelaren plugina +Comment[fa]=وصلۀ تابلوی ناوش konqueror که فرامیله نام دارد +Comment[fi]=Konquerorin Metabar -niminen selauspaneelin liitännäinen +Comment[fr]=Un module pour le panneau de navigation de Konqueror appelé Metabar +Comment[fy]=In plugin foar Konqueror's navigaasjebalke, neamd Metabalke +Comment[ga]=Breiseán i bpainéal nascleanúna Konqueror darb ainm Metabar +Comment[gl]=Un plugin de navegación para konqueror chamado Metabar +Comment[hr]=Dodatak navigacijske trake za Konqueror, nazvan Metabar +Comment[hu]=Metabar, egy navigációs bővítőmodul a Konqueror böngészőhöz +Comment[is]=Konqueror leiðarstýrispjald íforrit sem kallast Metabar +Comment[it]=Plugin di navigazione di Konqueror chiamato Metabar +Comment[ja]=Konqueror メタバー ナビゲーションパネルプラグイン +Comment[ka]=konqueror ნავიგაციის მოდული სახელად Metabar +Comment[kk]=Metabar деген Konqueror панелінің плагин модулі +Comment[km]=កម្មវិធីជំនួយបន្ទះរុករករបស់ konqueror បានហៅរបារមេតា +Comment[lt]=Metabar - Konqueror navigacijos pulto priedas +Comment[mk]=Приклучок за панел за навигација во konqueror наречен Metabar +Comment[nb]=Et Konqueror programtillegg for navigasjonspanel, kalt Metabar +Comment[nds]=En Sietpaneel för Konqueror, nöömt "Metabar" +Comment[ne]=मेटाबार भनिने एउटा कन्क्वेरर नेभिगेसन प्यानल प्लगइन +Comment[nl]=Een plugin voor Konqueror's navigatiebalk, genaamd Metabalk +Comment[nn]=Eit programtillegg som gir Konqueror eit navigasjonspanel +Comment[pl]=Wtyczka panelu nawigacyjnego Metabar dla Konquerora +Comment[pt]=Um 'plugin' de navegação do konqueror chamado Metabar +Comment[pt_BR]=Um plugin de navegação para o Konqueror chamado de MetaBar +Comment[ru]=Панель сведений Konqueror +Comment[sk]=Modul navigačného panelu pre Konqueror nazývaný Metabar +Comment[sl]=Vstavek za Konqueror z navigacijskim pasom Metabar +Comment[sr]=Прикључак за навигациону таблу konqueror-а назван Метапалета +Comment[sr@Latn]=Priključak za navigacionu tablu konqueror-a nazvan Metapaleta +Comment[sv]=Ett sidopanelinsticksprogram för Konqueror kallad Metarad +Comment[tr]=Metabar isimli Konqueror gezinme paneli eklentisi +Comment[uk]=Втулок навігаційної панелі для konqueror - Metabar +Comment[vi]=Bổ sung bảng duyệt qua Konqueror tên Siêu Thanh +Comment[zh_CN]=称为 Metabar 的 Konqueror 导航面板插件 +Comment[zh_TW]=叫做 Metabar 的 Konqueror 導覽面板外掛程式 +Icon=metabar +Name=Metabar +Name[el]=Γραμμή μεταδεδομένων +Name[eo]=MetaCrawler +Name[es]=Metabarra +Name[fa]=فرامیله +Name[fy]=Metabalke +Name[ja]=メタバー +Name[km]=របារមេតា +Name[ne]=मेटाबार +Name[nl]=Metabalk +Name[pa]=ਮੈਟਾ-ਪੱਟੀ +Name[pt_BR]=MetaBar +Name[ru]=Сведения +Name[sr]=Метапалета +Name[sr@Latn]=Metapaleta +Name[sv]=Metarad +Name[vi]=Siêu Thanh +Open=false +Type=Link +URL= +X-KDE-KonqSidebarAddModule=konqsidebar_metabar diff --git a/konq-plugins/sidebar/metabar/src/metabarfunctions.cpp b/konq-plugins/sidebar/metabar/src/metabarfunctions.cpp new file mode 100644 index 0000000..2d16e29 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabarfunctions.cpp @@ -0,0 +1,242 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "metabarfunctions.h" + +#include <html_element.h> +#include <html_document.h> +#include <css_value.h> + +#include <kconfig.h> + +#include <qrect.h> + +#define CSS_PRIORITY "important" +#define RESIZE_SPEED 5 +#define RESIZE_STEP 2 + +MetabarFunctions::MetabarFunctions(KHTMLPart *html, QObject *parent, const char* name) : QObject(parent, name), m_html(html) +{ + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(animate())); +} + +MetabarFunctions::~MetabarFunctions() +{ + if(timer->isActive()){ + timer->stop(); + } +} + +void MetabarFunctions::handleRequest(const KURL &url) +{ + QString function = url.host(); + QStringList params = QStringList::split(',', url.filename()); + + if(function == "toggle"){ + if(params.size() == 1){ + toggle(params.first()); + } + } + + else if(function == "adjustSize"){ + if(params.size() == 1){ + adjustSize(params.first()); + } + } + + else if(function == "show"){ + if(params.size() == 1){ + show(params.first()); + } + } + + else if(function == "hide"){ + if(params.size() == 1){ + hide(params.first()); + } + } +} + +void MetabarFunctions::toggle(DOM::DOMString item) +{ + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item)); + + if(!node.isNull()){ + DOM::NodeList children = node.childNodes(); + DOM::CSSStyleDeclaration style = node.style(); + DOM::DOMString expanded = node.getAttribute("expanded"); + + bool isExpanded = expanded == "true"; + + int height = 0; + if(!isExpanded){ + height = getHeight(node); + } + + DOM::DOMString att = isExpanded ? "false" : "true"; + node.setAttribute("expanded", att); + + KConfig config("metabarrc"); + config.setGroup("General"); + + if(config.readBoolEntry("AnimateResize", false)){ + resizeMap[item.string()] = height; + + if(!timer->isActive()){ + timer->start(RESIZE_SPEED); + } + } + else{ + style.setProperty("height", QString("%1px").arg(height), CSS_PRIORITY); + } + } +} + +void MetabarFunctions::adjustSize(DOM::DOMString item) +{ + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item)); + + if(!node.isNull()){ + DOM::NodeList children = node.childNodes(); + DOM::CSSStyleDeclaration style = node.style(); + DOM::DOMString expanded = node.getAttribute("expanded"); + + bool isExpanded = expanded == "true"; + + if(isExpanded){ + int height = getHeight(node); + + KConfig config("metabarrc"); + config.setGroup("General"); + + if(config.readBoolEntry("AnimateResize", false)){ + resizeMap[item.string()] = height; + + if(!timer->isActive()){ + timer->start(RESIZE_SPEED); + } + } + else{ + style.setProperty("height", QString("%1px").arg(height), CSS_PRIORITY); + } + } + } +} + +void MetabarFunctions::animate() +{ + QMap<QString, int>::Iterator it; + for(it = resizeMap.begin(); it != resizeMap.end(); ++it ) { + QString id = it.key(); + int height = it.data(); + int currentHeight = 0; + + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(id)); + DOM::CSSStyleDeclaration style = node.style(); + + QString currentHeightString = style.getPropertyValue("height").string(); + if(currentHeightString.endsWith("px")){ + currentHeight = currentHeightString.left(currentHeightString.length() - 2).toInt(); + } + + if(currentHeight == height){ + resizeMap.remove(id); + + if(resizeMap.isEmpty()){ + timer->stop(); + } + } + else{ + int diff = kAbs(currentHeight - height); + int changeValue = RESIZE_STEP; + + if(diff < RESIZE_STEP){ + changeValue = diff; + } + + int change = currentHeight < height ? changeValue : -changeValue; + style.setProperty("height", QString("%1px").arg(currentHeight + change), CSS_PRIORITY); + doc.updateRendering(); + } + } +} + +void MetabarFunctions::show(DOM::DOMString item) +{ + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item)); + if(!node.isNull()){ + DOM::HTMLElement parent = static_cast<DOM::HTMLElement>(node.parentNode()); + + DOM::CSSStyleDeclaration style = parent.style(); + style.setProperty("display", "block", CSS_PRIORITY); + } +} + +void MetabarFunctions::hide(DOM::DOMString item) +{ + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById(item)); + if(!node.isNull()){ + DOM::HTMLElement parent = static_cast<DOM::HTMLElement>(node.parentNode()); + + DOM::CSSStyleDeclaration style = parent.style(); + style.setProperty("display", "none", CSS_PRIORITY); + } +} + +int MetabarFunctions::getHeight(DOM::HTMLElement &element) +{ + int height = 0; + DOM::NodeList children = element.childNodes(); + for(uint i = 0; i < children.length(); i++){ + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(children.item(i)); + DOM::CSSStyleDeclaration style = node.style(); + + DOM::DOMString css_height = style.getPropertyValue("height"); + if(!css_height.isNull()){ + height += css_height.string().left(css_height.string().length() - 2).toInt(); + } + else{ + int h = 0; + if(!node.isNull()){ + h = node.getRect().height(); + } + + DOM::DOMString display = style.getPropertyValue("display"); + if(display == "none"){ + h = 0; + } + else if(h == 0){ + h = 20; + } + + height += h; + } + } + + return height; +} + +#include "metabarfunctions.moc" diff --git a/konq-plugins/sidebar/metabar/src/metabarfunctions.h b/konq-plugins/sidebar/metabar/src/metabarfunctions.h new file mode 100644 index 0000000..1c01998 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabarfunctions.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef METABAR_FUNCTIONS_H +#define METABAR_FUNCTIONS_H + +#include <dom_string.h> + +#include <qtimer.h> +#include <qmap.h> + +#include <kurl.h> +#include <khtml_part.h> + +class MetabarFunctions : public QObject +{ + Q_OBJECT + + public: + MetabarFunctions(KHTMLPart *html, QObject *parent = 0, const char* name=0); + ~MetabarFunctions(); + + void toggle(DOM::DOMString item); + void adjustSize(DOM::DOMString item); + void hide(DOM::DOMString item); + void show(DOM::DOMString item); + void handleRequest(const KURL &url); + + protected: + KHTMLPart *m_html; + + private: + QTimer *timer; + + QMap<QString, int> resizeMap; + int getHeight(DOM::HTMLElement &element); + + private slots: + void animate(); +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/metabarwidget.cpp b/konq-plugins/sidebar/metabar/src/metabarwidget.cpp new file mode 100644 index 0000000..f794353 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabarwidget.cpp @@ -0,0 +1,592 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "metabarwidget.h" +#include "configdialog.h" + +#include "defaultplugin.h" +#include "settingsplugin.h" +#include "remoteplugin.h" +#include "httpplugin.h" + +#include <qwidget.h> +#include <qlayout.h> +#include <qdir.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qvaluelist.h> +#include <qurl.h> +#include <qbuffer.h> + +#include <khtmlview.h> +#include <kapplication.h> +#include <kstandarddirs.h> +#include <kurl.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kicontheme.h> +#include <ktrader.h> +#include <klocale.h> +#include <krun.h> +#include <kdesktopfile.h> +#include <kpropertiesdialog.h> +#include <kaction.h> +#include <kactioncollection.h> +#include <kshortcut.h> +#include <kmimetype.h> +#include <kcmoduleinfo.h> +#include <kmdcodec.h> + +#include <kparts/browserextension.h> + +#include <dom2_events.h> +#include <dom2_views.h> +#include <dom_doc.h> +#include <dom_element.h> +#include <dom_string.h> +#include <html_element.h> +#include <html_misc.h> +#include <html_image.h> +#include <css_value.h> + +#include <dcopref.h> +#include <dcopclient.h> + +#define EVENT_TYPE DOM::DOMString("click") +#define ACTIVATION 1 + +MetabarWidget::MetabarWidget(QWidget *parent, const char *name) : QWidget(parent, name) +{ + skip = false; + loadComplete = false; + + currentItems = new KFileItemList; + currentItems->setAutoDelete(true); + + config = new KConfig("metabarrc"); + + dir_watch = new KDirWatch(); + connect(dir_watch, SIGNAL(dirty(const QString&)), this, SLOT(slotUpdateCurrentInfo(const QString&))); + connect(dir_watch, SIGNAL(created(const QString&)), this, SLOT(slotUpdateCurrentInfo(const QString&))); + connect(dir_watch, SIGNAL(deleted(const QString&)), this, SLOT(slotDeleteCurrentInfo(const QString&))); + + html = new KHTMLPart(this, "metabarhtmlpart"); + html->setJScriptEnabled(true); + html->setPluginsEnabled(true); + html->setCaretVisible(false); + html->setDNDEnabled(false); + html->setJavaEnabled(false); + html->view()->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + html->view()->hide(); + + connect(html->browserExtension(), SIGNAL(openURLRequest( const KURL &, const KParts::URLArgs & )), this, SLOT(handleURLRequest(const KURL &, const KParts::URLArgs &))); + connect(html, SIGNAL(completed()), this, SLOT(loadCompleted())); + connect(html, SIGNAL(popupMenu(const QString &, const QPoint &)), this, SLOT(slotShowPopup(const QString&, const QPoint &))); + + functions = new MetabarFunctions(html, this); + + currentPlugin = 0; + defaultPlugin = new DefaultPlugin(html, functions); + HTTPPlugin *httpPlugin = new HTTPPlugin(html, functions); + + //plugins.setAutoDelete(true); + plugins.insert("settings", new SettingsPlugin(html, functions)); + plugins.insert("remote", new RemotePlugin(html, functions)); + //plugins.insert("trash", new TrashPlugin(html, functions)); + plugins.insert("http", httpPlugin); + plugins.insert("https", httpPlugin); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->addWidget(html->view()); + + popup = new KPopupMenu(0); + KAction *configAction = new KAction(i18n("Configure %1...").arg("Metabar"), "configure", KShortcut(), this, SLOT(slotShowConfig()), html->actionCollection(), "configure"); + configAction->plug(popup); + + KAction *reloadAction = new KAction(i18n("Reload Theme"), "reload", KShortcut(), this, SLOT(setTheme()), html->actionCollection(), "reload"); + reloadAction->plug(popup); + + setTheme(); +} + +MetabarWidget::~MetabarWidget() +{ + config->sync(); + delete config; + + delete dir_watch; + delete currentItems; +} + +void MetabarWidget::setFileItems(const KFileItemList &items, bool check) +{ + if(!loadComplete){ + return; + } + + if(skip){ + skip = false; + return; + } + + if(check){ + int count = items.count(); + + KURL url(getCurrentURL()); + + KFileItem *newItem = items.getFirst(); + KFileItem *oldItem = currentItems->getFirst(); + + if(count == 0){ + if(oldItem){ + if(oldItem->url() == url){ + return; + } + } + + currentItems->clear(); + currentItems->append(new KFileItem(S_IFDIR, KFileItem::Unknown, url, true)); + } + + else if(count == 1){ + if(newItem){ + if(newItem->url().isEmpty()){ + return; + } + + if(currentItems->count() == items.count() && oldItem){ + if(newItem->url() == oldItem->url()){ + return; + } + } + } + + currentItems = new KFileItemList(items); + } + + else{ + if(currentItems && *currentItems == items){ + return; + } + currentItems = new KFileItemList(items); + } + } + else{ + currentItems = new KFileItemList(items); + } + + if(currentPlugin){ + currentPlugin->deactivate(); + } + + QString protocol = currentItems->getFirst()->url().protocol(); + currentPlugin = plugins[protocol]; + + if(!currentPlugin){ + currentPlugin = defaultPlugin; + } + + ProtocolPlugin::activePlugin = currentPlugin; + currentPlugin->setFileItems(*currentItems); +} + +QString MetabarWidget::getCurrentURL() +{ + DCOPRef ref(kapp->dcopClient()->appId(), this->topLevelWidget()->name()); + DCOPReply reply = ref.call("currentURL()"); + + if (reply.isValid()) { + QString url; + reply.get(url, "QString"); + + if(!url.isNull() && !url.isEmpty()){ + return url; + } + } + return 0; +} + +void MetabarWidget::openURL(const QString &url) +{ + DCOPRef ref(kapp->dcopClient()->appId(), this->topLevelWidget()->name()); + DCOPReply reply = ref.call("openURL", url); +} + +void MetabarWidget::openTab(const QString &url) +{ + DCOPRef ref(kapp->dcopClient()->appId(), this->topLevelWidget()->name()); + DCOPReply reply = ref.call("newTab", url); +} + +void MetabarWidget::callAction(const QString &action) +{ + DCOPRef ref(kapp->dcopClient()->appId(), QString(this->topLevelWidget()->name()).append("/action/").append(action).utf8()); + if(ref.call("enabled()")){ + ref.call("activate()"); + } +} + +void MetabarWidget::loadLinks() +{ + config->setGroup("General"); + QStringList links = config->readListEntry("Links"); + + if(links.count() == 0){ + functions->hide("links"); + } + else{ + functions->show("links"); + + DOM::HTMLDocument doc = html->htmlDocument(); + DOM::HTMLElement node = doc.getElementById("links"); + + if(!node.isNull()){ + DOM::DOMString innerHTML; + + for(QStringList::Iterator it = links.begin(); it != links.end(); ++it){ + config->setGroup("Link_" + (*it)); + addEntry(innerHTML, config->readEntry("Name"), config->readEntry("URL"), config->readEntry("Icon", "folder")); + } + + node.setInnerHTML(innerHTML); + } + + functions->adjustSize("links"); + } +} + +void MetabarWidget::loadCompleted() +{ + DOM::HTMLDocument doc = html->htmlDocument(); + + DOM::NodeList i18n_a_list = doc.getElementsByTagName("a"); + for(uint i = 0; i < i18n_a_list.length(); i++){ + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(i18n_a_list.item(i)); + if(!node.isNull()){ + if(node.hasAttribute("i18n")){ + QString text = node.innerText().string(); + node.setInnerText(DOM::DOMString(i18n(text.utf8().data()))); + } + + if(node.hasAttribute("image")){ + QString icon = node.getAttribute("image").string(); + QString url = getIconPath(icon); + QString style = QString("background-image: url(%1);").arg(url); + + node.setAttribute("style", style); + } + } + } + + DOM::NodeList i18n_ul_list = doc.getElementsByTagName("ul"); + for(uint i = 0; i < i18n_ul_list.length(); i++){ + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(i18n_ul_list.item(i)); + if(!node.isNull()){ + if(node.hasAttribute("i18n")){ + QString text = node.innerText().string(); + node.setInnerText(DOM::DOMString(i18n(text.utf8().data()))); + } + } + } + + config->setGroup("General"); + QString file = locate("data", QString("metabar/themes/%1/default.css").arg(config->readEntry("Theme", "default"))); + if(file.isNull()){ + file = locate("data", QString("metabar/themes/default/default.css")); + } + + QFile cssfile(file); + if(cssfile.open(IO_ReadOnly)){ + QTextStream stream( &cssfile ); + QString tmp = stream.read(); + cssfile.close(); + + tmp.replace("./", KURL::fromPathOrURL(file).directory(false)); + html->setUserStyleSheet(tmp); + } + + loadComplete = true; + html->view()->setFrameShape(config->readBoolEntry("ShowFrame", true) ? QFrame::StyledPanel : QFrame::NoFrame); + html->view()->show(); + + if(currentItems && !currentItems->isEmpty()){ + setFileItems(*currentItems, false); + } + else{ + QString url = getCurrentURL(); + KFileItem *item = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, KURL(url), true); + KFileItemList list; + list.append(item); + setFileItems(list, false); + } + + loadLinks(); +} + +void MetabarWidget::handleURLRequest(const KURL &url, const KParts::URLArgs &args) +{ + if(!currentPlugin){ + return; + } + + QString protocol = url.protocol(); + + if(currentPlugin->handleRequest(url)){ + return; + } + + if(protocol == "desktop"){ + QString path = url.path(); + + if(KDesktopFile::isDesktopFile(path)){ + KRun::run(new KDesktopFile(path, true), KURL::List()); + } + } + + else if(protocol == "kcmshell"){ + QString module = url.path().remove('/'); + + KRun::runCommand("kcmshell " + module); + } + + else if(protocol == "action"){ + QString action = url.url().right(url.url().length() - 9); + if(action.startsWith("metabar/")){ + QString newact = action.right(action.length() - 8); + + if(newact == "share"){ + slotShowSharingDialog(); + } + } + else{ + callAction(action); + } + } + + else if(protocol == "preview"){ + if(currentItems && !currentItems->isEmpty()){ + KFileItem *item = currentItems->getFirst(); + + DOM::HTMLDocument doc = html->htmlDocument(); + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(doc.getElementById("preview")); + DOM::HTMLImageElement image = static_cast<DOM::HTMLImageElement>(doc.getElementById("previewimage")); + + if(!node.isNull()){ + skip = true; //needed to prevent some weired reload + + DOM::DOMString innerHTML; + innerHTML += QString("<ul style=\"width: %1px; height: %1px\">").arg(image.width(), image.height()); + innerHTML += "<object class=\"preview\" type=\""; + innerHTML += item->mimetype(); + innerHTML += "\" data=\""; + innerHTML += item->url().url(); + innerHTML += "\" width=\""; + innerHTML += QString().setNum(image.width()); + innerHTML += "\" height=\""; + innerHTML += QString().setNum(image.height()); + innerHTML += "\" /></ul>"; + node.setInnerHTML(innerHTML); + } + } + } + + else if(protocol == "more"){ + QString name = url.host(); + + DOM::HTMLDocument doc = html->htmlDocument(); + DOM::NodeList list = doc.getElementsByName(name); + DOM::HTMLElement element = static_cast<DOM::HTMLElement>(doc.getElementById(name)); + bool showMore = true; + + for(uint i = 0; i < list.length(); i++){ + DOM::HTMLElement node = static_cast<DOM::HTMLElement>(list.item(i)); + if(!node.isNull()){ + DOM::HTMLElement parent = static_cast<DOM::HTMLElement>(node.parentNode()); + DOM::CSSStyleDeclaration style = parent.style(); + DOM::DOMString display = style.getPropertyValue("display"); + DOM::DOMString newDisplay = display == "none" ? "block" : "none"; + + style.setProperty("display", newDisplay, "important"); + + showMore = display == "block"; + } + } + + if(element.id().string().startsWith("hidden")){ + QString style = QString("background-image: url(%1);").arg(getIconPath(showMore ? "1downarrow" : "1uparrow")); + element.setInnerText( showMore ? i18n("More") : i18n("Less") ); + element.setAttribute("style", style); + } + + DOM::HTMLElement parent = static_cast<DOM::HTMLElement>(element.parentNode().parentNode()); + functions->adjustSize(parent.id()); + } + + else if(protocol == "function"){ + functions->handleRequest(url); + } + + else if(protocol == "configure"){ + slotShowConfig(); + } + + else if(protocol == "openwith"){ + if(currentItems && !currentItems->isEmpty()){ + KFileItem *item = currentItems->getFirst(); + + KRun::displayOpenWithDialog(KURL::List(item->url()), false); + } + } + + else{ + if(args.newTab()){ + openTab(url.url()); + } + else{ + openURL(url.url()); + } + } +} + +QString MetabarWidget::getIconPath(const QString &name) +{ + QPixmap icon = SmallIcon(name); + + QByteArray data; + QBuffer buffer(data); + buffer.open(IO_WriteOnly); + icon.save(&buffer, "PNG"); + + return QString::fromLatin1("data:image/png;base64,%1").arg(KCodecs::base64Encode(data)); +} + +void MetabarWidget::slotShowSharingDialog() +{ + if(currentItems && currentItems->count() == 1){ + KPropertiesDialog *dialog = new KPropertiesDialog(currentItems->first(), 0, 0, true); + dialog->showFileSharingPage(); + } +} + +void MetabarWidget::slotShowConfig() +{ + ConfigDialog *config_dialog = new ConfigDialog(this); + if(config_dialog->exec() == QDialog::Accepted){ + config->reparseConfiguration(); + + setFileItems(*currentItems, false); + loadLinks(); + + setTheme(); + + html->view()->setFrameShape(config->readBoolEntry("ShowFrame", true) ? QFrame::StyledPanel : QFrame::NoFrame); + } + + delete config_dialog; +} + +void MetabarWidget::slotShowPopup(const QString &url, const QPoint &point) +{ + popup->exec(point); +} + +void MetabarWidget::slotUpdateCurrentInfo(const QString &path) +{ + if(currentItems){ + KFileItem *item = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, KURL(path), true); + + if(currentItems->count() == 1){ + currentItems->clear(); + currentItems->append(item); + } + + setFileItems(*currentItems, false); + } +} + +void MetabarWidget::slotDeleteCurrentInfo(const QString&) +{ + if(currentItems && currentItems->count() == 1){ + QString url = getCurrentURL(); + KURL currentURL; + + if(currentItems){ + currentURL = currentItems->getFirst()->url(); + } + + if(!currentURL.isEmpty() && KURL(url) != currentURL){ + if(dir_watch->contains(currentURL.path())){ + dir_watch->removeDir(currentURL.path()); + } + dir_watch->addDir(url); + + KFileItem *item = new KFileItem(KFileItem::Unknown, KFileItem::Unknown, url, true); + + currentItems->clear(); + currentItems->append(item); + + setFileItems(*currentItems, false); + } + } +} + +void MetabarWidget::addEntry(DOM::DOMString &html, const QString name, const QString url, const QString icon, const QString id, const QString nameatt, bool hidden) +{ + html += "<ul"; + + if(hidden){ + html += " style=\"display: none;\""; + } + + html += "><a"; + + if(!id.isNull() && !id.isEmpty()){ + html += " id=\""; + html += id; + html += "\""; + } + + if(!nameatt.isNull() && !nameatt.isEmpty()){ + html += " name=\""; + html += nameatt; + html += "\""; + } + + html += " href=\""; + html += url; + html += "\" onClick=\"this.blur();\" style=\"background-image: url("; + html += getIconPath(icon); + html += ");\">"; + html += name; + html += "</a></ul>"; +} + +void MetabarWidget::setTheme() +{ + loadComplete = false; + + config->setGroup("General"); + QString file = locate("data", QString("metabar/themes/%1/layout.html").arg(config->readEntry("Theme", "default"))); + + html->openURL(KURL(file)); +} + +#include "metabarwidget.moc" diff --git a/konq-plugins/sidebar/metabar/src/metabarwidget.h b/konq-plugins/sidebar/metabar/src/metabarwidget.h new file mode 100644 index 0000000..a0acb41 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/metabarwidget.h @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef METABAR_WIDGET_H +#define METABAR_WIDGET_H + +#include <khtml_part.h> + +#include <kconfig.h> +#include <kfileitem.h> +#include <kurl.h> +#include <kservice.h> +#include <kpopupmenu.h> +#include <kdirwatch.h> + +#include <qmap.h> + +#include "protocolplugin.h" +#include "metabarfunctions.h" + +class MetabarWidget : public QWidget +{ + Q_OBJECT + + public: + MetabarWidget(QWidget *parent = 0, const char* name=0); + ~MetabarWidget(); + + void setFileItems(const KFileItemList &items, bool check = true); + + static QString getIconPath(const QString &name); + static void addEntry(DOM::DOMString &html, const QString name, const QString url, const QString icon, const QString id = QString::null, const QString nameatt = QString::null, bool hidden = false); + + private: + KFileItemList *currentItems; + KConfig *config; + + KHTMLPart *html; + + ProtocolPlugin *currentPlugin; + ProtocolPlugin *defaultPlugin; + + MetabarFunctions *functions; + + KDirWatch *dir_watch; + KPopupMenu *popup; + + QDict<ProtocolPlugin> plugins; + + bool skip; + bool loadComplete; + + void callAction(const QString &action); + void openURL(const QString &url); + void openTab(const QString &url); + void loadLinks(); + + QString getCurrentURL(); + + private slots: + void loadCompleted(); + void slotShowSharingDialog(); + void slotShowConfig(); + void slotShowPopup(const QString &url, const QPoint &pos); + void handleURLRequest(const KURL &url, const KParts::URLArgs &args); + void slotUpdateCurrentInfo(const QString &path); + void slotDeleteCurrentInfo(const QString &path); + void setTheme(); +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/protocolplugin.cpp b/konq-plugins/sidebar/metabar/src/protocolplugin.cpp new file mode 100644 index 0000000..10fd784 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/protocolplugin.cpp @@ -0,0 +1,157 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "protocolplugin.h" + +#include <qbuffer.h> + +#include <kimageio.h> +#include <kmdcodec.h> +#include <kiconloader.h> +#include <klocale.h> + +#include <html_document.h> +#include <html_image.h> + +ProtocolPlugin* ProtocolPlugin::activePlugin = 0; + +ProtocolPlugin::ProtocolPlugin(KHTMLPart *html, MetabarFunctions *functions, const char* name) : QObject(html, name), m_html(html), m_functions(functions) +{ +} + +ProtocolPlugin::~ProtocolPlugin() +{ +} + +void ProtocolPlugin::setFileItems(const KFileItemList &items) +{ + m_items = items; + + killJobs(); + + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement actions = doc.getElementById("actions"); + DOM::HTMLElement applications = doc.getElementById("open"); + DOM::HTMLElement info = doc.getElementById("info"); + DOM::HTMLElement preview = doc.getElementById("preview"); + DOM::HTMLElement bookmarks = doc.getElementById("bookmarks"); + + DOM::HTMLImageElement icon = (DOM::HTMLImageElement) doc.getElementById("icon"); + DOM::HTMLElement name = doc.getElementById("name"); + DOM::HTMLElement type = doc.getElementById("type"); + DOM::HTMLElement size = doc.getElementById("size"); + + if(!icon.isNull()){ + QPixmap pix; + if(m_items.count() == 1){ + pix = m_items.getFirst()->pixmap(KIcon::SizeLarge); + } + else{ + pix = DesktopIcon("kmultiple", KIcon::SizeLarge); + } + + QByteArray data; + QBuffer buffer(data); + buffer.open(IO_WriteOnly); + pix.save(&buffer, "PNG"); + QString icondata = QString::fromLatin1("data:image/png;base64,%1").arg(KCodecs::base64Encode(data)); + + icon.setSrc(icondata); + } + + if(!name.isNull()){ + if(m_items.count() == 1){ + name.setInnerText(m_items.getFirst()->name()); + } + else{ + name.setInnerText(i18n("%1 Elements").arg(m_items.count())); + } + } + + if(!type.isNull()){ + if(m_items.count() == 1){ + KFileItem *item = m_items.getFirst(); + KFileItem *that = const_cast<KFileItem *>(item); + + type.setInnerText(that->determineMimeType()->comment()); + } + else{ + int files = 0; + int dirs = 0; + + for(KFileItemListIterator it(m_items); it.current(); ++it){ + if((*it)->isDir()){ + dirs++; + } + else{ + files++; + } + } + + type.setInnerText(i18n("%1 Folders, %2 Files").arg(dirs).arg(files)); + } + + + } + + if(!size.isNull()){ + KIO::filesize_t s = 0; + + for(KFileItemListIterator it(m_items); it.current(); ++it){ + s += (*it)->size(); + } + + size.setInnerText(KIO::convertSize(s)); + } + + if(!actions.isNull()){ + loadActions(actions); + m_functions->adjustSize("actions"); + } + + if(!applications.isNull()){ + loadApplications(applications); + m_functions->adjustSize("open"); + } + + if(!info.isNull()){ + loadInformation(info); + m_functions->adjustSize("info"); + } + + if(!preview.isNull()){ + loadPreview(preview); + m_functions->adjustSize("preview"); + } + + if(!bookmarks.isNull()){ + loadBookmarks(bookmarks); + m_functions->adjustSize("bookmarks"); + } + + doc.updateRendering(); +} + +bool ProtocolPlugin::isActive() +{ + return activePlugin == this; +} + +#include "protocolplugin.moc" diff --git a/konq-plugins/sidebar/metabar/src/protocolplugin.h b/konq-plugins/sidebar/metabar/src/protocolplugin.h new file mode 100644 index 0000000..9202df3 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/protocolplugin.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _PROTOCOL_PLUGIN_H +#define _PROTOCOL_PLUGIN_H + +#include <kfileitem.h> +#include <khtml_part.h> + +#include <html_element.h> + +#include "metabarfunctions.h" + +class ProtocolPlugin : public QObject{ + Q_OBJECT + + public: + static ProtocolPlugin* activePlugin; + + ProtocolPlugin(KHTMLPart *html, MetabarFunctions *functions, const char* name = 0); + ~ProtocolPlugin(); + + void setFileItems(const KFileItemList &items); + bool isActive(); + + virtual bool handleRequest(const KURL &url) = 0; + virtual void deactivate() = 0; + + protected: + virtual void killJobs() = 0; + + virtual void loadActions(DOM::HTMLElement node) = 0; + virtual void loadApplications(DOM::HTMLElement node) = 0; + virtual void loadInformation(DOM::HTMLElement node) = 0; + virtual void loadPreview(DOM::HTMLElement node) = 0; + virtual void loadBookmarks(DOM::HTMLElement node) = 0; + + KFileItemList m_items; + KHTMLPart *m_html; + MetabarFunctions *m_functions; +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/remoteplugin.cpp b/konq-plugins/sidebar/metabar/src/remoteplugin.cpp new file mode 100644 index 0000000..6d9a2dc --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/remoteplugin.cpp @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "remoteplugin.h" + +#include <kservice.h> +#include <klocale.h> +#include <kstandarddirs.h> + +RemotePlugin::RemotePlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name) : DefaultPlugin (html, functions, name) +{ +} + +RemotePlugin::~RemotePlugin() +{ +} + +void RemotePlugin::loadActions(DOM::HTMLElement node) +{ + KService::Ptr service = KService::serviceByDesktopName("knetattach"); + + if(service && service->isValid()){ + DOM::DOMString innerHTML; + MetabarWidget::addEntry(innerHTML, i18n("Add a Network Folder"), "desktop://" + locate("apps", service->desktopEntryPath()), "wizard"); + node.setInnerHTML(innerHTML); + + m_functions->show("actions"); + } + + else{ + m_functions->hide("actions"); + } +} + +#include "remoteplugin.moc" diff --git a/konq-plugins/sidebar/metabar/src/remoteplugin.h b/konq-plugins/sidebar/metabar/src/remoteplugin.h new file mode 100644 index 0000000..f77bbfd --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/remoteplugin.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _REMOTE_PLUGIN_H_ +#define _REMOTE_PLUGIN_H_ + +#include "defaultplugin.h" + +class RemotePlugin : public DefaultPlugin +{ + Q_OBJECT + + public: + RemotePlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name = 0); + ~RemotePlugin(); + + void loadActions(DOM::HTMLElement node); +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/serviceloader.cpp b/konq-plugins/sidebar/metabar/src/serviceloader.cpp new file mode 100644 index 0000000..7c7e544 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/serviceloader.cpp @@ -0,0 +1,213 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "serviceloader.h" + +#include <qdir.h> +#include <qvaluelist.h> +#include <qptrlist.h> + +#include <dcopclient.h> + +#include <kapplication.h> +#include <kdebug.h> +#include <kactioncollection.h> +#include <kiconloader.h> +#include <kaction.h> +#include <kshortcut.h> +#include <ksimpleconfig.h> +#include <kglobal.h> +#include <kstandarddirs.h> + + +ServiceLoader::ServiceLoader(QWidget *parent, const char *name) : QObject(parent, name) +{ + popups.setAutoDelete(true); +} + +ServiceLoader::~ServiceLoader() +{ +} + +void ServiceLoader::loadServices(const KFileItem item, DOM::DOMString &html, int &count) +{ + popups.clear(); + + KURL url = item.url(); + QString mimeType = item.mimetype(); + QString mimeGroup = mimeType.left(mimeType.find('/')); + + urlList.clear(); + urlList.append(url); + + QStringList dirs = KGlobal::dirs()->findDirs( "data", "konqueror/servicemenus/" ); + KConfig config("metabarrc", true, false); + config.setGroup("General"); + int maxActions = config.readNumEntry("MaxActions"); + bool matchAll = false; // config.readBoolEntry("MatchAll"); + + int id = 0; + QString idString; + + for(QStringList::Iterator dit = dirs.begin(); dit != dirs.end(); ++dit){ + idString.setNum(id); + + QDir dir(*dit); + QStringList entries = dir.entryList("*.desktop", QDir::Files); + + for(QStringList::Iterator eit = entries.begin(); eit != entries.end(); ++eit){ + KSimpleConfig cfg( *dit + *eit, true ); + cfg.setDesktopGroup(); + + if(cfg.hasKey("X-KDE-ShowIfRunning" )){ + const QString app = cfg.readEntry( "X-KDE-ShowIfRunning" ); + if(!kapp->dcopClient()->isApplicationRegistered(app.utf8())){ + continue; + } + } + + if(cfg.hasKey("X-KDE-Protocol")){ + const QString protocol = cfg.readEntry( "X-KDE-Protocol" ); + if(protocol != url.protocol()){ + continue; + } + } + + else if(url.protocol() == "trash"){ + continue; + } + + if(cfg.hasKey("X-KDE-Require")){ + const QStringList capabilities = cfg.readListEntry( "X-KDE-Require" ); + if (capabilities.contains( "Write" )){ + continue; + } + } + + if ( cfg.hasKey( "Actions" ) && cfg.hasKey( "ServiceTypes" ) ){ + const QStringList types = cfg.readListEntry( "ServiceTypes" ); + const QStringList excludeTypes = cfg.readListEntry( "ExcludeServiceTypes" ); + bool ok = false; + + for (QStringList::ConstIterator it = types.begin(); it != types.end() && !ok; ++it){ + bool checkTheMimetypes = false; + + if(matchAll){ + // first check if we have an all mimetype + if (*it == "all/all" || *it == "allfiles"){ + checkTheMimetypes = true; + } + + // next, do we match all files? + if (!ok && !item.isDir() && *it == "all/allfiles"){ + checkTheMimetypes = true; + } + } + + // if we have a mimetype, see if we have an exact or a type globbed match + if(!ok && (!mimeType.isEmpty() && *it == mimeType) || + (!mimeGroup.isEmpty() && ((*it).right(1) == "*" && (*it).left((*it).find('/')) == mimeGroup))) + { + checkTheMimetypes = true; + } + + if(checkTheMimetypes){ + ok = true; + + for(QStringList::ConstIterator itex = excludeTypes.begin(); itex != excludeTypes.end(); ++itex){ + if( ((*itex).right(1) == "*" && (*itex).left((*itex).find('/')) == mimeGroup) || + ((*itex) == mimeType)) + { + ok = false; + break; + } + } + } + } + if (ok){ + const QString priority = cfg.readEntry("X-KDE-Priority"); + const QString submenuName = cfg.readEntry( "X-KDE-Submenu" ); + bool usePopup = false; + KPopupMenu *popup; + + if(!submenuName.isEmpty()){ + usePopup = true; + + if(popups[submenuName]){ + popup = popups[submenuName]; + } + else{ + MetabarWidget::addEntry(html, submenuName, "servicepopup://" + idString, "1rightarrow", "popup" + idString, count < maxActions ? QString::null : QString("hiddenaction"), count >= maxActions); + + popup = new KPopupMenu(); + popups.insert(idString, popup); + + count++; + } + } + + QValueList<KDEDesktopMimeType::Service> list = KDEDesktopMimeType::userDefinedServices( *dit + *eit, url.isLocalFile()); + + for (QValueList<KDEDesktopMimeType::Service>::iterator it = list.begin(); it != list.end(); ++it){ + + if(usePopup){ + KAction *action = new KAction((*it).m_strName, (*it).m_strIcon, KShortcut(), this, SLOT(runAction()), popup, idString.utf8()); + action->plug(popup); + } + else{ + MetabarWidget::addEntry(html, (*it).m_strName, "service://" + idString, (*it).m_strIcon, QString::null, count < maxActions ? QString::null : QString("hiddenaction"), count >= maxActions); + count++; + } + + services.insert(idString, *it); + id++; + idString.setNum(id); + } + } + } + } + } +} + +void ServiceLoader::runAction() +{ + KDEDesktopMimeType::Service s = services[sender()->name()]; + if(!s.isEmpty()){ + KDEDesktopMimeType::executeService(urlList, s); + } +} + +void ServiceLoader::runAction(const QString& name) +{ + KDEDesktopMimeType::Service s = services[name]; + if(!s.isEmpty()){ + KDEDesktopMimeType::executeService(urlList, s); + } +} + +void ServiceLoader::showPopup(const QString &popup, const QPoint &point) +{ + KPopupMenu *p = popups[popup]; + if(p){ + p->exec(point); + } +} + +#include "serviceloader.moc" diff --git a/konq-plugins/sidebar/metabar/src/serviceloader.h b/konq-plugins/sidebar/metabar/src/serviceloader.h new file mode 100644 index 0000000..293ae6b --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/serviceloader.h @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _SERVICELOADER_H_ +#define _SERVICELOADER_H_ + +#include <qstring.h> +#include <qdict.h> +#include <qmap.h> +#include <qwidget.h> + +#include <kpopupmenu.h> +#include <kfileitem.h> +#include <kmimetype.h> +#include <kurl.h> + +#include <dom_string.h> + +#include "metabarwidget.h" + +class ServiceLoader : public QObject +{ + Q_OBJECT + + public: + ServiceLoader(QWidget *parent, const char *name = 0); + ~ServiceLoader(); + + void loadServices(const KFileItem item, DOM::DOMString &html, int &count); + void runAction(const QString &name); + void showPopup(const QString &popup, const QPoint &point); + + private: + QDict<KPopupMenu> popups; + QMap<QString,KDEDesktopMimeType::Service> services; + KURL::List urlList; + + private slots: + void runAction(); +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/src/settingsplugin.cpp b/konq-plugins/sidebar/metabar/src/settingsplugin.cpp new file mode 100644 index 0000000..1fb9e50 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/settingsplugin.cpp @@ -0,0 +1,201 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "metabarwidget.h" +#include "settingsplugin.h" + +#include <kcmoduleinfo.h> +#include <kservice.h> +#include <klocale.h> + +#include <html_document.h> +#include <html_element.h> +#include <dom_string.h> + +SettingsPlugin::SettingsPlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name) : ProtocolPlugin (html, functions, name) +{ + list_job = 0; +} + +SettingsPlugin::~SettingsPlugin() +{ +} + +void SettingsPlugin::killJobs() +{ + if(list_job){ + list_job->kill(); + list_job = 0; + } +} + +void SettingsPlugin::deactivate() +{ + m_functions->hide("actions"); + m_functions->hide("info"); +} + +void SettingsPlugin::loadActions(DOM::HTMLElement node) +{ + KURL url = m_items.getFirst()->url(); + + if(url.path().endsWith("/")){ + list_job = KIO::listDir(url, true, false); + connect(list_job, SIGNAL(entries(KIO::Job *, const KIO::UDSEntryList &)), this, SLOT(slotGotEntries(KIO::Job *, const KIO::UDSEntryList &))); + connect(list_job, SIGNAL(result(KIO::Job *)), this, SLOT(slotJobFinished(KIO::Job *))); + + m_functions->show("actions"); + } + else{ + QString path = url.path(); + QString name = url.filename(); + + KService::Ptr service = KService::serviceByStorageId(name); + if(service && service->isValid()){ + KCModuleInfo kcminfo(service); + + DOM::DOMString innerHTML; + MetabarWidget::addEntry(innerHTML, i18n("Run"), "kcmshell:/" + name, kcminfo.icon()); + node.setInnerHTML(innerHTML); + + m_functions->show("actions"); + } + else{ + m_functions->hide("actions"); + } + } +} + +void SettingsPlugin::loadInformation(DOM::HTMLElement node) +{ + KURL url = m_items.getFirst()->url(); + if(url.path().endsWith("/")){ + m_functions->hide("info"); + } + else{ + QString path = url.path(); + QString name = url.filename(); + + KService::Ptr service = KService::serviceByStorageId(name); + if(service && service->isValid()){ + KCModuleInfo kcminfo(service); + + bool needsRoot = kcminfo.needsRootPrivileges(); + + DOM::DOMString innerHTML; + innerHTML += "<ul class=\"info\"><b>" + i18n("Name") + ": </b>"; + innerHTML += kcminfo.moduleName(); + innerHTML += "</ul><ul class=\"info\"><b>" + i18n("Comment") + ": </b>"; + innerHTML += kcminfo.comment(); + innerHTML += "</ul>"; + + if(needsRoot){ + innerHTML += "<ul class=\"info\"><b>"; + innerHTML += i18n("Needs root privileges"); + innerHTML += "</b></ul>"; + } + node.setInnerHTML(innerHTML); + + m_functions->show("info"); + } + else{ + m_functions->hide("info"); + } + } +} + +void SettingsPlugin::loadApplications(DOM::HTMLElement node) +{ + m_functions->hide("open"); +} + +void SettingsPlugin::loadPreview(DOM::HTMLElement node) +{ + m_functions->hide("preview"); +} + +void SettingsPlugin::loadBookmarks(DOM::HTMLElement node) +{ + m_functions->hide("bookmarks"); +} + +bool SettingsPlugin::handleRequest(const KURL &) +{ + return false; +} + +void SettingsPlugin::slotGotEntries(KIO::Job *job, const KIO::UDSEntryList &list) +{ + if(!job){ + return; + } + + DOM::HTMLDocument doc = m_html->htmlDocument(); + DOM::HTMLElement node = doc.getElementById("actions"); + DOM::DOMString innerHTML; + + KIO::UDSEntryList::ConstIterator it = list.begin(); + KIO::UDSEntryList::ConstIterator it_end = list.end(); + for(; it != it_end; ++it){ + QString name; + QString icon; + QString url; + long type; + + KIO::UDSEntry::ConstIterator atomit = (*it).begin(); + KIO::UDSEntry::ConstIterator atomit_end = (*it).end(); + for(; atomit != atomit_end; ++atomit){ + if((*atomit).m_uds == KIO::UDS_NAME){ + name = (*atomit).m_str; + } + else if((*atomit).m_uds == KIO::UDS_ICON_NAME){ + icon = (*atomit).m_str; + } + else if((*atomit).m_uds == KIO::UDS_URL){ + url = (*atomit).m_str; + } + + else if((*atomit).m_uds == KIO::UDS_FILE_TYPE){ + type = (*atomit).m_long; + } + } + + kdDebug() << url << endl; + + if(type == S_IFREG){ + url = "kcmshell:/" + KURL(url).filename(); + } + + MetabarWidget::addEntry(innerHTML, name, url, icon); + } + + node.setInnerHTML(innerHTML); +} + +void SettingsPlugin::slotJobFinished(KIO::Job *job) +{ + if(list_job && job == list_job){ + list_job = 0; + + m_functions->adjustSize("actions"); + } +} + +#include "settingsplugin.moc" diff --git a/konq-plugins/sidebar/metabar/src/settingsplugin.h b/konq-plugins/sidebar/metabar/src/settingsplugin.h new file mode 100644 index 0000000..27f1097 --- /dev/null +++ b/konq-plugins/sidebar/metabar/src/settingsplugin.h @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2005 by Florian Roth * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _SETTINGS_PLUGIN_H_ +#define _SETTINGS_PLUGIN_H_ + +#include "protocolplugin.h" + +#include <kio/jobclasses.h> +#include <kio/job.h> + +class SettingsPlugin : public ProtocolPlugin +{ + Q_OBJECT + + public: + SettingsPlugin(KHTMLPart* html, MetabarFunctions *functions, const char *name = 0); + ~SettingsPlugin(); + + void deactivate(); + bool handleRequest(const KURL &url); + + protected: + void killJobs(); + void loadActions(DOM::HTMLElement node); + void loadApplications(DOM::HTMLElement node); + void loadInformation(DOM::HTMLElement node); + void loadPreview(DOM::HTMLElement node); + void loadBookmarks(DOM::HTMLElement node); + + private: + KIO::ListJob *list_job; + + private slots: + void slotGotEntries(KIO::Job *job, const KIO::UDSEntryList &list); + void slotJobFinished(KIO::Job *job); +}; + +#endif diff --git a/konq-plugins/sidebar/metabar/stamp-h.in b/konq-plugins/sidebar/metabar/stamp-h.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/konq-plugins/sidebar/metabar/stamp-h.in diff --git a/konq-plugins/sidebar/newsticker/Makefile.am b/konq-plugins/sidebar/newsticker/Makefile.am new file mode 100644 index 0000000..4dc9fae --- /dev/null +++ b/konq-plugins/sidebar/newsticker/Makefile.am @@ -0,0 +1,36 @@ +SUBDIRS = . pics + +AM_CPPFLAGS = $(all_includes) +METASOURCES = AUTO + + + +################################ +# these are the headers for your project +noinst_HEADERS = nspanel.h nsstacktabwidget.h sidebar_news.h norsswidget.h + +kde_module_LTLIBRARIES = konq_sidebarnews.la + +# the Part's source, library search path, and link libraries +konq_sidebarnews_la_SOURCES = sidebar_news.cpp sidebar_news.skel nsstacktabwidget.cpp \ + nspanel.cpp nspanel.skel norsswidget.cpp \ + sidebarsettings.kcfgc \ + configfeedsbase.ui configfeeds.cpp +konq_sidebarnews_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +konq_sidebarnews_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) -lkonqsidebarplugin + + +globaladddir = $(kde_datadir)/konqsidebartng/add +globaladd_DATA = news_add.desktop + +kde_kcfg_DATA = konq_sidebarnews.kcfg + + + +############################ +# +# i18n +# +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/konqsidebar_news.pot + diff --git a/konq-plugins/sidebar/newsticker/README b/konq-plugins/sidebar/newsticker/README new file mode 100644 index 0000000..65d15e6 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/README @@ -0,0 +1,38 @@ +Konqsidebarnews is based on the rss DCOP service in +kdenetwork/dcoprss. So you most likely you want to +install it before using the sidebar applet. + + + +TODO +==== + +- better handling of starting up rssservice + +- less crashes (check for stupid user input, etc...) + +- cleanly recover from a crashing dcop service + +- documentation + +- accessibility aware UI + +- integration with kdenetwork/knewsticker + + + +THANKS TO +========= + +- Joseph Wenningen ([email protected]) + idea and original code + +- Frerich Raabe ([email protected]) + for kdenonbeta/librss where all the magic happens + +- Ian Reinhard Geiser ([email protected]) + for maintaining the DCOP service + + +--- +Marcus Camen <[email protected]> diff --git a/konq-plugins/sidebar/newsticker/configfeeds.cpp b/konq-plugins/sidebar/newsticker/configfeeds.cpp new file mode 100644 index 0000000..c682ab3 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/configfeeds.cpp @@ -0,0 +1,38 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + configfeeds.cpp + Copyright: Marcus Camen <[email protected]> + Copyright: Nathan Toone <[email protected]> +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "sidebarsettings.h" +#include "configfeeds.h" + + +namespace KSB_News { + +ConfigFeeds::ConfigFeeds(QWidget* parent, const char* name) : ConfigFeedsBase(parent, name) +{ +} + +} // namespace KSB_News + +#include "configfeeds.moc" diff --git a/konq-plugins/sidebar/newsticker/configfeeds.h b/konq-plugins/sidebar/newsticker/configfeeds.h new file mode 100644 index 0000000..555b4f5 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/configfeeds.h @@ -0,0 +1,53 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + configfeeds.h + Copyright: Marcus Camen <[email protected]> + Copyright: Nathan Toone <[email protected]> +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _konq_sidebar_news_configfeedsh_ +#define _konq_sidebar_news_configfeedsh_ + +#include "configfeedsbase.h" + + +// +// +// ATM this is just a noop wrapper +// +// + + +namespace KSB_News { + + class ConfigFeeds : public ConfigFeedsBase { + + Q_OBJECT + + public: + ConfigFeeds(QWidget* parent, const char* name = 0); + + }; + +} // namespace KSB_News + + +#endif diff --git a/konq-plugins/sidebar/newsticker/configfeedsbase.ui b/konq-plugins/sidebar/newsticker/configfeedsbase.ui new file mode 100644 index 0000000..8389747 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/configfeedsbase.ui @@ -0,0 +1,26 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>ConfigFeedsBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>ConfigFeedsBase</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KEditListBox"> + <property name="name"> + <cstring>kcfg_Sources</cstring> + </property> + <property name="title"> + <string>RSS Feeds</string> + </property> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="0"/> +<includehints> + <includehint>keditlistbox.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> diff --git a/konq-plugins/sidebar/newsticker/konq_sidebarnews.kcfg b/konq-plugins/sidebar/newsticker/konq_sidebarnews.kcfg new file mode 100644 index 0000000..7641ab2 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/konq_sidebarnews.kcfg @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="konq_sidebarnewsrc"/> + + <group name="RSS sources"> + <entry name="Sources" type="StringList"> + <label>List of RSS Sources</label> + <default>http://www.kde.org/dotkdeorg.rdf</default> + </entry> + </group> + +</kcfg> diff --git a/konq-plugins/sidebar/newsticker/news_add.desktop b/konq-plugins/sidebar/newsticker/news_add.desktop new file mode 100644 index 0000000..989abf3 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/news_add.desktop @@ -0,0 +1,44 @@ +[Desktop Entry] +Type=Link +URL= +Icon=konqsidebar_news +Name=Newsticker +Name[bs]=News Ticker +Name[ca]=Teletip de notícies +Name[da]=Nyhedstelegraf +Name[eo]=Novaĵprezentilo +Name[es]=Teletipo de noticias +Name[et]=Uudistejälgija +Name[fi]=Uutisnäyttäjä +Name[fr]=Téléscripteur de nouvelles +Name[gl]=Notícias +Name[he]=מציג חדשות +Name[hi]=न्यूज़टिकर +Name[hr]=Obavijesti o novostima +Name[hu]=Hírmegjelenítő +Name[is]=Fréttastrimill +Name[it]=NewsTicker +Name[ja]=ニュースティッカー +Name[ka]=სიახლეთა მიმღები +Name[lt]=Naujienų pranešiklis +Name[nb]=Nyhetstelegraf +Name[nds]=Narichtentelegraaf +Name[ne]=न्यूजटिकर +Name[nn]=Nyhendetelegraf +Name[pa]=ਖ਼ਬਰਸਾਰ +Name[pl]=Pasek wiadomości +Name[pt]=Notícias +Name[pt_BR]=Mostrador de Notícias +Name[ru]=Индикатор новостей +Name[sk]=Sledovanie správ +Name[sl]=Prikazovalnik novic +Name[sv]=Nyhetsövervakare +Name[ta]=புதிய நகரும் செய்தி +Name[tr]=Haber Bandı +Name[uk]=Стрічка новин +Name[vi]=Bộ theo dõi tin tức +Name[zh_CN]=新闻点点通 +Open=false +X-KDE-KonqSidebarAddModule=konq_sidebarnews +X-KDE-KonqSidebarUniversal=true +TryExec=rssservice diff --git a/konq-plugins/sidebar/newsticker/norsswidget.cpp b/konq-plugins/sidebar/newsticker/norsswidget.cpp new file mode 100644 index 0000000..d4c803a --- /dev/null +++ b/konq-plugins/sidebar/newsticker/norsswidget.cpp @@ -0,0 +1,100 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + norsswidget.cpp + Copyright: Marcus Camen <[email protected]> +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qlayout.h> +#include <qsizepolicy.h> +#include <dcopref.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kpushbutton.h> +#include <kdebug.h> +#include <kconfigdialog.h> +#include "sidebarsettings.h" +#include "configfeeds.h" +#include "norsswidget.h" + + +namespace KSB_News { + + NoRSSWidget::NoRSSWidget(QWidget *parent, const char *name) + : QWidget(parent, name) { + + QVBoxLayout *topLayout = new QVBoxLayout(this); + + topLayout->addStretch(); + + KPushButton *btn = new KPushButton(i18n("&Configure"), this); + btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); + connect(btn, SIGNAL(clicked()), this, SLOT(slotBtnClicked())); + topLayout->addWidget(btn, 0, Qt::AlignHCenter); + + topLayout->addStretch(); + } + + + void NoRSSWidget::slotBtnClicked() { + // An instance of your dialog could be already created and could be + // cached, in which case you want to display the cached dialog + // instead of creating another one + if (KConfigDialog::showDialog("settings")) + return; + + // KConfigDialog didn't find an instance of this dialog, so lets create it + m_confdlg = new KConfigDialog(this, "settings", SidebarSettings::self(), + KDialogBase::Plain, + KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Default, + KDialogBase::Ok, + true); + ConfigFeeds *conf_widget = new ConfigFeeds(0, "feedcfgdlg"); + m_confdlg->addPage(conf_widget, i18n("RSS Settings"), "pixmap_name"); + + // User edited the configuration - update your local copies of the + // configuration data + connect(m_confdlg, SIGNAL(settingsChanged()), this, + SLOT(slotConfigure_okClicked())); + + m_confdlg->show(); + } + + + void NoRSSWidget::slotConfigure_okClicked() { + DCOPRef rss_document("rssservice", "RSSService"); + + // read list of sources + QStringList m_our_rsssources = SidebarSettings::sources(); + + // add new sources + QStringList::iterator it; + for (it = m_our_rsssources.begin(); it != m_our_rsssources.end(); ++it) { + rss_document.call("add", ( *it )); + } + + // save configuration to disk + SidebarSettings::setSources(m_our_rsssources); + SidebarSettings::writeConfig(); + } + +} // namespace KSB_News + +#include "norsswidget.moc" diff --git a/konq-plugins/sidebar/newsticker/norsswidget.h b/konq-plugins/sidebar/newsticker/norsswidget.h new file mode 100644 index 0000000..cebac3b --- /dev/null +++ b/konq-plugins/sidebar/newsticker/norsswidget.h @@ -0,0 +1,51 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + Copyright: norsswidget.h + Marcus Camen <[email protected]> +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _NORSSWIDGET_H_ +#define _NORSSWIDGET_H_ + + +class KConfigDialog; + + +namespace KSB_News { + + class NoRSSWidget : public QWidget { + Q_OBJECT + + public: + NoRSSWidget(QWidget *parent = 0, const char *name = 0); + + private slots: + void slotBtnClicked(); + void slotConfigure_okClicked(); + + private: + KConfigDialog *m_confdlg; + }; + + +} // namespace KSB_News + +#endif diff --git a/konq-plugins/sidebar/newsticker/nspanel.cpp b/konq-plugins/sidebar/newsticker/nspanel.cpp new file mode 100644 index 0000000..8086b35 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/nspanel.cpp @@ -0,0 +1,181 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + Copyright: nspanel.cpp + Marcus Camen <[email protected]> +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qlistview.h> +#include <qfontmetrics.h> +#include <qtimer.h> +#include <kdebug.h> +#include <klistbox.h> +#include "nspanel.h" + + +namespace KSB_News { + +//////////////////////////////////////////////////////////////// +// ListBox including ToolTip for item +//////////////////////////////////////////////////////////////// + TTListBox::TTListBox(QWidget *parent, const char *name, WFlags f) + : KListBox(parent, name, f), + QToolTip(this) { + } + + void TTListBox::clear() { + KListBox::clear(); + } + + void TTListBox::maybeTip(const QPoint &point) { + QListBoxItem *item = itemAt(point); + if (item) { + QString text = item->text(); + if (!text.isEmpty()) { + // Show ToolTip only if necessary + QFontMetrics fm(fontMetrics()); + int textWidth = fm.width(text); + int widgetSpace = visibleWidth(); + if ((textWidth > widgetSpace) || (contentsX() > 0)) + tip(itemRect(item), text); + } + } + } + + + + NSPanel::NSPanel(QObject *parent, const char *name, const QString &key, + DCOPRef *rssservice) + :QObject(parent, name) + ,DCOPObject(QString(QString("sidebar-newsticker-")+key).latin1()) + ,m_listbox() + ,m_pixmap() +{ + kdDebug(90140) << "NSPanel: CTOR " << key << " " << rssservice << endl; + + m_rssservice = rssservice; + m_key = key; + m_rssdocument = m_rssservice->call("document(QString)", m_key); + m_isValid = false; + + connectDCOPSignal("rssservice", m_rssdocument.obj(), + "documentUpdated(DCOPRef)", + "emitDocumentUpdated(DCOPRef)", false); + connectDCOPSignal("rssservice", m_rssdocument.obj(), + "documentUpdated(DCOPRef)", + "emitTitleUpdated(DCOPRef)", false); + connectDCOPSignal("rssservice", m_rssdocument.obj(), + "pixmapUpdated(DCOPRef)", + "emitPixmapUpdated(DCOPRef)", false); + + // updating of RSS documents + m_timeoutinterval = 10 * 60 * 1000; // 10 mins + m_timer = new QTimer(this); + connect(m_timer, SIGNAL(timeout()), this, SLOT(refresh())); + m_timer->start(m_timeoutinterval); + refresh(); + } + + + void NSPanel::refresh() { + m_rssdocument.call("refresh()"); + } + + + NSPanel::~NSPanel() { + } + + + void NSPanel::setTitle(const QString &tit) { + m_title = tit; + } + + + void NSPanel::setListbox(TTListBox *lb) { + m_listbox = lb; + } + + + void NSPanel::setPixmap(const QPixmap &pm) { + m_pixmap = pm; + } + + + TTListBox *NSPanel::listbox() const { + return m_listbox; + } + + + QPixmap NSPanel::pixmap() { + return m_pixmap; + } + + + QString NSPanel::key() const { + return m_key; + } + + QString NSPanel::title() const { + return m_title; + } + + QStringList NSPanel::articles() { + return m_articles; + } + + QStringList NSPanel::articleLinks() { + return m_articlelinks; + } + + bool NSPanel::isValid() const { + return m_isValid; + } + + + void NSPanel::emitDocumentUpdated(DCOPRef /*dcopref*/) { + kdDebug(90140) << "NSPanel::emitDocumentUpdated" << endl; + + m_articles.clear(); + m_articlelinks.clear(); + m_count = m_rssdocument.call("count()"); + QString temp = m_rssdocument.call("title()"); + m_title = temp; + m_isValid = true; + for (int idx = 0; idx < m_count; ++idx) { + DCOPRef rss_article = m_rssdocument.call("article(int)", idx); + m_articles.append(rss_article.call("title()")); + m_articlelinks.append(rss_article.call("link()")); + } + + emit documentUpdated(this); + } + + void NSPanel::emitPixmapUpdated(DCOPRef /*dcopref*/) { + if (m_rssdocument.call("pixmapValid()")) { + QPixmap tmp = m_rssdocument.call("pixmap()"); + m_pixmap = tmp; + + emit pixmapUpdated(this); + } + } + +} // namespace KSB_News + +#include "nspanel.moc" diff --git a/konq-plugins/sidebar/newsticker/nspanel.h b/konq-plugins/sidebar/newsticker/nspanel.h new file mode 100644 index 0000000..0f30152 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/nspanel.h @@ -0,0 +1,109 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + Copyright: nspanel.h + Marcus Camen <[email protected]> +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _konq_sidebar_news_nspanelh_ +#define _konq_sidebar_news_nspanelh_ + +#include <qstring.h> +#include <qpixmap.h> +#include <qtooltip.h> +#include <dcopref.h> +#include <dcopobject.h> +#include <kio/job.h> +#include <klistbox.h> + + +class QBuffer; +class QTimer; + +namespace KSB_News { + +//////////////////////////////////////////////////////////////// +// ListBox including ToolTip for item +//////////////////////////////////////////////////////////////// + class TTListBox : public KListBox, QToolTip { + public: + TTListBox (QWidget *parent = 0, const char *name = 0, WFlags f = 0); + void clear(); + + protected: + virtual void maybeTip(const QPoint &); + }; + + + + class NSPanel : public QObject, public DCOPObject { + Q_OBJECT + K_DCOP + + public: + NSPanel(QObject *parent, const char *name, const QString &key, + DCOPRef *rssservice); + ~NSPanel(); + + void setTitle(const QString &tit); + void setListbox(TTListBox *lb); + void setPixmap(const QPixmap &pm); + void setPixmapBuffer(QBuffer *buf); + void setJob(KIO::Job *kio_job); + + TTListBox *listbox() const; + QPixmap pixmap(); + QString key() const; + QString title() const; + QStringList articles(); + QStringList articleLinks(); + bool isValid() const; + + k_dcop: + virtual void emitDocumentUpdated(DCOPRef); + virtual void emitPixmapUpdated(DCOPRef); + + private: + DCOPRef *m_rssservice; + DCOPRef m_rssdocument; + QString m_key; + QString m_title; + TTListBox *m_listbox; + QPixmap m_pixmap; + int m_count; + QStringList m_articles; // TODO: use proper container + QStringList m_articlelinks; // TODO: use proper container + int m_timeoutinterval; + QTimer *m_timer; + bool m_isValid; + + signals: + void documentUpdated(NSPanel *); + void pixmapUpdated(NSPanel *); + + public slots: + void refresh(); + + }; + + +} // namespace KSB_News + +#endif diff --git a/konq-plugins/sidebar/newsticker/nsstacktabwidget.cpp b/konq-plugins/sidebar/newsticker/nsstacktabwidget.cpp new file mode 100644 index 0000000..74aa07e --- /dev/null +++ b/konq-plugins/sidebar/newsticker/nsstacktabwidget.cpp @@ -0,0 +1,365 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + nsstacktabwidget.cpp - description + ------------------- + begin : Sat 07.09.2002 + copyright : (C) 2002-2004 Marcus Camen + email : [email protected] +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qpushbutton.h> +#include <qlayout.h> +#include <qscrollview.h> +#include <qptrdict.h> +#include <qsizepolicy.h> +#include <qtooltip.h> +#include <qcursor.h> +#include <qimage.h> +#include <kdebug.h> +#include <kaboutdata.h> +#include <kaboutapplication.h> +#include <kpopupmenu.h> +#include <kiconloader.h> +#include <kstringhandler.h> +#include <kapplication.h> +#include <kbugreport.h> +#include <kstdguiitem.h> +#include <kconfigdialog.h> +#include "sidebarsettings.h" +#include "configfeeds.h" +#include "nsstacktabwidget.h" + + +namespace KSB_News { + + NSStackTabWidget::NSStackTabWidget(QWidget *parent, const char *name, + QPixmap appIcon) : QWidget(parent, name) { + currentPage = 0; + layout = new QVBoxLayout(this); + + pagesheader.setAutoDelete(TRUE); + pages.setAutoDelete(TRUE); + + // about dialog + m_aboutdata = new KAboutData("konq_sidebarnews", + I18N_NOOP("Newsticker"), + KDE::versionString(), + I18N_NOOP("RSS Feed Viewer"), + KAboutData::License_LGPL, + I18N_NOOP("(c) 2002-2004, the Sidebar Newsticker developers")); + m_aboutdata->addAuthor("Marcus Camen", I18N_NOOP("Maintainer"), + "[email protected]"); + m_aboutdata->addAuthor("Frerich Raabe", "librss", + "[email protected]"); + m_aboutdata->addAuthor("Ian Reinhart Geiser", "dcoprss", + "[email protected]"); + m_aboutdata->addAuthor("Joseph Wenninger", + I18N_NOOP("Idea and former maintainer"), + "[email protected]"); + m_aboutdata->setProductName("konqueror/sidebar newsticker"); + m_about = new KAboutApplication(m_aboutdata, this); + + + // bugreport dialog + m_bugreport = new KBugReport(0, true, m_aboutdata); + + + // popup menu + popup = new KPopupMenu(this); + popup->insertItem(KStdGuiItem::configure().iconSet(), + i18n("&Configure Newsticker..."), this, + SLOT(slotConfigure())); + popup->insertItem(SmallIconSet("reload"), i18n("&Reload"), this, + SLOT(slotRefresh())); + popup->insertItem(KStdGuiItem::close().iconSet(), + KStdGuiItem::close().text(), this, SLOT(slotClose())); + popup->insertSeparator(); + + // help menu + helpmenu = new KPopupMenu(this); + helpmenu->insertItem(appIcon, i18n("&About Newsticker"), this, + SLOT(slotShowAbout())); + helpmenu->insertItem(i18n("&Report Bug..."), this, + SLOT(slotShowBugreport())); + + popup->insertItem(KStdGuiItem::help().iconSet(), + KStdGuiItem::help().text(), helpmenu); + + + // read configuration from disk and initialize widget + m_our_rsssources = SidebarSettings::sources(); + } + + + void NSStackTabWidget::addStackTab(NSPanel *nsp, QWidget *page) { + QPushButton *button = new QPushButton(this); + + button->setText(KStringHandler::rPixelSqueeze(nsp->title(), + button->fontMetrics(), + button->width() - 4 )); + button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, + QSizePolicy::Preferred)); + connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + QToolTip::add(button, nsp->title()); + + // eventFiler for the title button + button->installEventFilter(this); + + QScrollView *sv = new QScrollView(this); + sv->setResizePolicy(QScrollView::AutoOneFit); + sv->addChild(page); + sv->setFrameStyle(QFrame::NoFrame); + page->show(); + + pagesheader.insert(nsp, button); + pages.insert(nsp, sv); + + layout->addWidget(button); + layout->addWidget(sv); + button->show(); + if (pages.count() == 1) { + currentPage = sv; + sv->show(); + } else { + sv->hide(); + } + } + + + + void NSStackTabWidget::delStackTab(NSPanel *nsp) { + pages.remove(nsp); + pagesheader.remove(nsp); + + if (pages.count() >= 1) { + QPtrDictIterator<QWidget> it(pages); + QWidget *previousPage = currentPage; + currentPage = it.current(); + if (currentPage != previousPage) + currentPage->show(); + } + } + + + + void NSStackTabWidget::updateTitle(NSPanel *nsp) { + QPushButton *pb = (QPushButton *)pagesheader.find(nsp); + if (! pb->pixmap()) + pb->setText(nsp->title()); + } + + + + void NSStackTabWidget::updatePixmap(NSPanel *nsp) { + QPushButton *pb = (QPushButton *)pagesheader.find(nsp); + QPixmap pixmap = nsp->pixmap(); + if ((pixmap.width() > 88) || (pixmap.height() > 31)) { + QImage image = pixmap.convertToImage(); + pixmap.convertFromImage(image.smoothScale(88, 31, QImage::ScaleMin)); + } + pb->setPixmap(pixmap); + } + + + + + void NSStackTabWidget::buttonClicked() { + QPushButton *pb = (QPushButton*)sender(); + NSPanel *nsp = NULL; + + // Which NSPanel belongs to pb + QPtrDictIterator<QWidget> it(pagesheader); + for (; it.current(); ++it) { + QPushButton *currentWidget = (QPushButton *)it.current(); + if (currentWidget == pb) + nsp = (NSPanel *)it.currentKey(); + } + + if (! nsp) + return; + + // Find current ScrollView + QWidget *sv = pages.find(nsp); + + // Change visible page + if (currentPage != sv) { + nsp->refresh(); + if (currentPage) + currentPage->hide(); + currentPage = sv; + currentPage->show(); + } + } + + + + bool NSStackTabWidget::eventFilter(QObject *obj, QEvent *ev) { + if (ev->type() == QEvent::MouseButtonPress + && ((QMouseEvent *)ev)->button() == QMouseEvent::RightButton) { + m_last_button_rightclicked = (QPushButton *)obj; + popup->exec(QCursor::pos()); + return true; + } else if (ev->type() == QEvent::Resize) { + QPushButton *pb = (QPushButton *)obj; + + const QPixmap *pm = pb->pixmap(); + if ( ! pm ) { + // Which NSPanel belongs to pb + NSPanel *nsp = NULL; + QPtrDictIterator<QWidget> it(pagesheader); + for (; it.current(); ++it) { + QPushButton *currentWidget = (QPushButton *)it.current(); + if (currentWidget == pb) + nsp = (NSPanel *)it.currentKey(); + } + pb->setText(KStringHandler::rPixelSqueeze(nsp->title(), + pb->fontMetrics(), + pb->width() - 4 )); + } + return true; + } + return false; // pass through event + } + + + void NSStackTabWidget::slotConfigure() { + // An instance of your dialog could be already created and could be + // cached, in which case you want to display the cached dialog + // instead of creating another one + if (KConfigDialog::showDialog("settings")) + return; + + // KConfigDialog didn't find an instance of this dialog, so lets create it + m_confdlg = new KConfigDialog(this, "settings", SidebarSettings::self(), + KDialogBase::Plain, + KDialogBase::Ok|KDialogBase::Cancel| \ + KDialogBase::Default| \ + KDialogBase::Apply, + KDialogBase::Ok, + true); + ConfigFeeds *conf_widget = new ConfigFeeds(0, "feedcfgdlg"); + m_confdlg->addPage(conf_widget, i18n("RSS Settings"), QString()); + + // User edited the configuration - update your local copies of the + // configuration data + connect(m_confdlg, SIGNAL(settingsChanged()), this, + SLOT(slotConfigure_okClicked())); + + m_confdlg->show(); + } + + + void NSStackTabWidget::slotConfigure_okClicked() { + DCOPRef rss_document("rssservice", "RSSService"); + + // remove old sources and old stack tabs + QStringList::iterator it; + for (it = m_our_rsssources.begin(); it != m_our_rsssources.end(); ++it) { + rss_document.call("remove", (*it)); + } + + // read list of sources + m_our_rsssources = SidebarSettings::sources(); + + // add new sources and new stack tabs + for (it = m_our_rsssources.begin(); it != m_our_rsssources.end(); ++it) { + rss_document.call("add", (*it)); + } + + // save configuration to disk + SidebarSettings::setSources(m_our_rsssources); + SidebarSettings::writeConfig(); + } + + + void NSStackTabWidget::slotShowAbout() { + m_about->show(); + } + + + void NSStackTabWidget::slotShowBugreport() { + m_bugreport->show(); + } + + + void NSStackTabWidget::slotRefresh() { + NSPanel *nsp = NULL; + + // find appendant NSPanel + QPtrDictIterator<QWidget> it(pagesheader); + for (; it.current(); ++it) { + QPushButton *currentWidget = (QPushButton *)it.current(); + if (currentWidget == m_last_button_rightclicked) + nsp = (NSPanel *)it.currentKey(); + } + + if (! nsp) { + return; + } else { + nsp->refresh(); + } + } + + + void NSStackTabWidget::slotClose() { + NSPanel *nsp = NULL; + // find appendant NSPanel + QPtrDictIterator<QWidget> it(pagesheader); + for (; it.current(); ++it) { + QPushButton *currentWidget = (QPushButton *)it.current(); + if (currentWidget == m_last_button_rightclicked) + nsp = (NSPanel *)it.currentKey(); + } + + if (! nsp) { + return; + } else { + // TODO: check, if rssservice is available + + // deregister RSS source and save configuration to disk + m_our_rsssources.remove(nsp->key()); + SidebarSettings::setSources(m_our_rsssources); + SidebarSettings::writeConfig(); + + DCOPRef rss_document("rssservice", "RSSService"); + rss_document.call("remove", nsp->key()); + } + } + + + bool NSStackTabWidget::isEmpty() const { + return pagesheader.isEmpty(); + } + + + bool NSStackTabWidget::isRegistered(const QString &key) { + m_our_rsssources = SidebarSettings::sources(); + if (m_our_rsssources.findIndex(key) == -1) + return false; + else + return true; + } + + +} // namespace KSB_News; + + +#include "nsstacktabwidget.moc" diff --git a/konq-plugins/sidebar/newsticker/nsstacktabwidget.h b/konq-plugins/sidebar/newsticker/nsstacktabwidget.h new file mode 100644 index 0000000..7b84289 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/nsstacktabwidget.h @@ -0,0 +1,91 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + nsstacktabwidget.h - description + ------------------- + begin : Sat 07.09.2002 + copyright : (C) 2002-2004 Marcus Camen + email : [email protected] +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _NSSTACKTABWIDGET_H_ +#define _NSSTACKTABWIDGET_H_ + +#include <qptrdict.h> +#include "nspanel.h" + + +class QVBoxLayout; +class QPushButton; +class QStringList; +class KPopupMenu; +class KAboutData; +class KAboutApplication; +class KBugReport; +class KConfigDialog; + +namespace KSB_News { + + class NewRssSourceDlg; + + class NSStackTabWidget : public QWidget { + Q_OBJECT + + public: + NSStackTabWidget(QWidget *parent = 0, const char *name = 0, + QPixmap appIcon = QPixmap()); + void addStackTab(NSPanel *nsp, QWidget *page); + void delStackTab(NSPanel *nsp); + void updateTitle(NSPanel *nsp); + void updatePixmap(NSPanel *nsp); + bool isEmpty() const; + bool isRegistered(const QString &key); + + protected: + bool eventFilter(QObject *obj, QEvent *ev); + + private slots: + void buttonClicked(); + void slotShowAbout(); + void slotShowBugreport(); + void slotRefresh(); + void slotClose(); + void slotConfigure(); + void slotConfigure_okClicked(); + + private: + QPtrDict<QWidget> pages; + QPtrDict<QWidget> pagesheader; + QVBoxLayout *layout; + QWidget *currentPage; + KPopupMenu *popup, *helpmenu; + KAboutData *m_aboutdata; + KAboutApplication *m_about; + KBugReport *m_bugreport; + QPushButton *m_last_button_rightclicked; + KConfigDialog *m_confdlg; + QStringList m_our_rsssources; + }; + + +} // namespace KSB_News + + +#endif diff --git a/konq-plugins/sidebar/newsticker/pics/LICENSE b/konq-plugins/sidebar/newsticker/pics/LICENSE new file mode 100644 index 0000000..7108d2b --- /dev/null +++ b/konq-plugins/sidebar/newsticker/pics/LICENSE @@ -0,0 +1,16 @@ +cr16-app-konqsidebar_news.png is based on livemark-item.png + +You can find the original file in the mozilla AVIARY_1_0_20040515_BRANCH: +http://lxr.mozilla.org/aviarybranch/source/browser/themes/winstripe/browser/licemark-item.png, Version 1.1 + +According to +http://lxr.mozilla.org/aviarybranch/source/browser/themes/LICENSE +the file is MPL / GPL / LPGP (confirmed to me in private mail by +Stephen Horlander <[email protected]>): + "All files in this directory are assumed to be licensed under the + tri-license (MPL/GPL/LGPL) used throughout this codebase." + +-- +Marcus <[email protected]> + +
\ No newline at end of file diff --git a/konq-plugins/sidebar/newsticker/pics/Makefile.am b/konq-plugins/sidebar/newsticker/pics/Makefile.am new file mode 100644 index 0000000..e5515a8 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/pics/Makefile.am @@ -0,0 +1 @@ +KDE_ICON = AUTO diff --git a/konq-plugins/sidebar/newsticker/pics/cr16-app-konqsidebar_news.png b/konq-plugins/sidebar/newsticker/pics/cr16-app-konqsidebar_news.png Binary files differnew file mode 100644 index 0000000..4a7321a --- /dev/null +++ b/konq-plugins/sidebar/newsticker/pics/cr16-app-konqsidebar_news.png diff --git a/konq-plugins/sidebar/newsticker/pics/livemark-item.png b/konq-plugins/sidebar/newsticker/pics/livemark-item.png Binary files differnew file mode 100644 index 0000000..91cb614 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/pics/livemark-item.png diff --git a/konq-plugins/sidebar/newsticker/sidebar_news.cpp b/konq-plugins/sidebar/newsticker/sidebar_news.cpp new file mode 100644 index 0000000..f96bcd6 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/sidebar_news.cpp @@ -0,0 +1,279 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + sidebar_news.cpp - The real sidebar plugin + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001,2002 Marcus Camen, Joseph Wenninger + copyright : (C) 2003,2004 Marcus Camen + email : Marcus Camen <[email protected]> + idea and original code: [email protected] +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <dcopclient.h> +#include <qtimer.h> +#include <qbuffer.h> +#include <qwidgetstack.h> +#include <kdebug.h> +#include <kapplication.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kdesktopfile.h> +#include <kiconloader.h> +#include <kdemacros.h> +#include "sidebar_news.h" +#include "nsstacktabwidget.h" +#include "norsswidget.h" +#include "sidebarsettings.h" + + +namespace KSB_News { + + KonqSidebar_News::KonqSidebar_News(KInstance *inst, QObject *parent, + QWidget *widgetParent, + QString &desktopName, const char* name) + : KonqSidebarPlugin(inst, parent, widgetParent, desktopName, name), + DCOPObject("sidebar-newsticker") + { + // get the application icon + // FIXME: as konqueror knows the icon there might be a possibility to + // access the already present QPixmap + KDesktopFile desktopFile(desktopName, true); + QString iconName = desktopFile.readIcon(); + KIconLoader iconLoader; + m_appIcon = iconLoader.loadIcon(iconName, KIcon::Small); + + // create all sidebar widgets + widgets = new QWidgetStack(widgetParent, "main_widgetstack"); + newswidget = new NSStackTabWidget(widgets, "feedbrowser_stackchld", + m_appIcon); + noRSSwidget = new NoRSSWidget(widgets, "nofeed_stackchld"); + widgets->addWidget(newswidget); + widgets->addWidget(noRSSwidget); + widgets->raiseWidget(noRSSwidget); + noRSSwidget->show(); + + // try to connect to the DCOP service + if (checkDcopService() > 0) { + KMessageBox::sorry(widgets, + i18n("<qt>Cannot connect to RSS service. Please make " + "sure the <strong>rssservice</strong> program " + "is available (usually distributed as part " + "of kdenetwork).</qt>"), + i18n("Sidebar Newsticker")); + noRSSwidget->setEnabled(false); + } else { + m_rssservice = DCOPRef("rssservice", "RSSService"); + + QStringList reslist = SidebarSettings::sources(); + QStringList::iterator it; + for (it = reslist.begin(); it != reslist.end(); ++it) { + addedRSSSource(*it); + } + + // fetch added and removed RSS sources + connectDCOPSignal("rssservice", m_rssservice.obj(), "added(QString)", + "addedRSSSource(QString)", false); + connectDCOPSignal("rssservice", m_rssservice.obj(), "removed(QString)", + "removedRSSSource(QString)", false); + + // show special widget if there are no RSS sources available + if (newswidget->isEmpty()) { + widgets->raiseWidget(noRSSwidget); + noRSSwidget->show(); + } else { + widgets->raiseWidget(newswidget); + } + } + } + + + KonqSidebar_News::~KonqSidebar_News() { + } + + + + void *KonqSidebar_News::provides(const QString &) {return 0;} + + void KonqSidebar_News::emitStatusBarText (const QString &) {;} + + QWidget *KonqSidebar_News::getWidget(){return widgets;} + + void KonqSidebar_News::handleURL(const KURL &/*url*/) {;} + + +///////// startup of the DCOP servce /////////////////////////////////////// + + int KonqSidebar_News::checkDcopService() { + QString rdfservice_error; + int err = 0; + + if (! kapp->dcopClient()->isApplicationRegistered("rssservice")) + if (KApplication::startServiceByDesktopName("rssservice", QString(), + &rdfservice_error) > 0) + err = 1; + + return err; + } + + + +///////// helper methods /////////////////////////////////////////////////// + + NSPanel *KonqSidebar_News::getNSPanelByKey(QString key) { + NSPanel *nsp = NULL, *current_nsp; + + for (current_nsp = nspanelptrlist.first(); current_nsp; + current_nsp = nspanelptrlist.next()) { + if (current_nsp->key() == key) + nsp = current_nsp; + } + + return nsp; + } + + + void KonqSidebar_News::addedRSSSource(QString key) { + kdDebug(90140) << "KonqSidebar_News::addedRSSSource: " << key << endl; + + // Only add RSS source if we have registered the URI before in + // NSStackTabWidget. + if (newswidget->isRegistered(key)) { + NSPanel *nspanel = new NSPanel(this, + QString(QString("sidebar-newsticker-")+key).latin1(), + key, &m_rssservice); + nspanel->setTitle(key); + nspanelptrlist.append(nspanel); + + // add preliminary widgets for this newssource + if (! nspanel->listbox()) { + TTListBox *listbox = new TTListBox(newswidget, "article_lb"); + newswidget->addStackTab(nspanel, listbox); + connect(listbox, SIGNAL(executed(QListBoxItem *)), + this, SLOT(slotArticleItemExecuted(QListBoxItem *))); + listbox->insertItem(i18n("Connecting..." )); + nspanel->setListbox(listbox); + } + + // listen to updates + connect(nspanel, SIGNAL(documentUpdated(NSPanel *)), + this, SLOT(updateArticles(NSPanel *))); + connect(nspanel, SIGNAL(documentUpdated(NSPanel *)), + this, SLOT(updateTitle(NSPanel *))); + connect(nspanel, SIGNAL(pixmapUpdated(NSPanel *)), + this, SLOT(updatePixmap(NSPanel *))); + + if (widgets->visibleWidget() != newswidget) + widgets->raiseWidget(newswidget); + } + } + + + void KonqSidebar_News::removedRSSSource(QString key) { + kdDebug(90140) << "inside KonqSidebar_News::removedSource " << key << endl; + + if (NSPanel *nsp = getNSPanelByKey(key)) { + newswidget->delStackTab(nsp); + delete nspanelptrlist.take(nspanelptrlist.findRef(nsp)); + } else + kdWarning() << "removedSource called for non-existing id" << endl; + + if (newswidget->isEmpty()) + widgets->raiseWidget(noRSSwidget); + } + + +///////////////////////////////////////////////////////////////////// + + void KonqSidebar_News::slotArticleItemExecuted(QListBoxItem *item) { + if (!item) return; + + NSPanel *current_nspanel, *nspanel = NULL; + for (current_nspanel = nspanelptrlist.first(); current_nspanel; + current_nspanel = nspanelptrlist.next()) { + if (current_nspanel->listbox() == item->listBox()) + nspanel = current_nspanel; + } + + int subid = nspanel->listbox()->index(item); + QString link = nspanel->articleLinks()[subid]; + + emit openURLRequest(KURL(link)); + + } + + + +//////////// update article headlines //////////// + + void KonqSidebar_News::updateArticles(NSPanel *nsp) { + nsp->listbox()->clear(); + + QStringList articleList = nsp->articles(); + QStringList::iterator it; + for (it = articleList.begin(); it != articleList.end(); ++it) + nsp->listbox()->insertItem((*it)); + } + + +/////////// Title stuff ///////////////////////////////////// + + void KonqSidebar_News::updateTitle(NSPanel *nsp) { + newswidget->updateTitle(nsp); + } + + +/////////// Pixmap stuff ///////////////////////////////////// + + void KonqSidebar_News::updatePixmap(NSPanel *nsp) { + newswidget->updatePixmap(nsp); + } + + + +///////////////////////////////////////////////////////// + + + extern "C" { + KDE_EXPORT void* create_konq_sidebarnews(KInstance *instance, QObject *par, + QWidget *widp, + QString &desktopname, + const char *name) { + KGlobal::locale()->insertCatalogue("konqsidebar_news"); + return new KonqSidebar_News(instance, par, widp, desktopname, name); + } + } + + extern "C" { + KDE_EXPORT bool add_konq_sidebarnews(QString* fn, QString*, + QMap<QString,QString> *map) { + map->insert("Type", "Link"); + map->insert("Icon", "konqsidebar_news"); + map->insert("Name", i18n("Newsticker")); + map->insert("Open", "false"); + map->insert("X-KDE-KonqSidebarModule", "konq_sidebarnews"); + fn->setLatin1("news%1.desktop"); + return true; + } + } + +} // namespace KSB_News + +#include "sidebar_news.moc" diff --git a/konq-plugins/sidebar/newsticker/sidebar_news.h b/konq-plugins/sidebar/newsticker/sidebar_news.h new file mode 100644 index 0000000..e6da786 --- /dev/null +++ b/konq-plugins/sidebar/newsticker/sidebar_news.h @@ -0,0 +1,89 @@ +// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*- + +/*************************************************************************** + sidebar_news.h - The real sidebar plugin + ------------------- + begin : Sat July 23 20:35:30 CEST 2001 + copyright : (C) 2001,2002 Marcus Camen, Joseph Wenninger + copyright : (C) 2003,2004 Marcus Camen + email : Marcus Camen <[email protected]> + idea and original code: [email protected] +***************************************************************************/ + +/* + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef _konq_sidebar_news_h_ +#define _konq_sidebar_news_h_ + +#include <konqsidebarplugin.h> +#include "nspanel.h" + + +class QPixmap; +class QWidgetStack; + +namespace KSB_News { + + class NSStackTabWidget; + class NoRSSWidget; + + class KonqSidebar_News : public KonqSidebarPlugin, DCOPObject { + Q_OBJECT + K_DCOP + + public: + KonqSidebar_News(KInstance *instance, QObject *parent, + QWidget *widgetParent, QString &desktopName_, + const char* name=0); + ~KonqSidebar_News(); + virtual void *provides(const QString &); + void emitStatusBarText (const QString &); + virtual QWidget *getWidget(); + + k_dcop: + virtual void addedRSSSource(QString); + virtual void removedRSSSource(QString); + + protected: + virtual void handleURL(const KURL &url); + + private: + int checkDcopService(); + QWidgetStack *widgets; + NSStackTabWidget *newswidget; + NoRSSWidget *noRSSwidget; + QPtrList<NSPanel> nspanelptrlist; + NSPanel *getNSPanelByKey(QString key); + DCOPRef m_rssservice; + QPixmap m_appIcon; + + signals: + // see <konqsidebarplugin.h> + void openURLRequest(const KURL &url, + const KParts::URLArgs &args = KParts::URLArgs()); + + private slots: + void slotArticleItemExecuted(QListBoxItem *item); + void updateArticles(NSPanel *nsp); + void updateTitle(NSPanel *nsp); + void updatePixmap(NSPanel *nsp); + }; + +} // namespace KSB_News + +#endif diff --git a/konq-plugins/sidebar/newsticker/sidebarsettings.kcfgc b/konq-plugins/sidebar/newsticker/sidebarsettings.kcfgc new file mode 100644 index 0000000..6e24cde --- /dev/null +++ b/konq-plugins/sidebar/newsticker/sidebarsettings.kcfgc @@ -0,0 +1,5 @@ +File=konq_sidebarnews.kcfg +ClassName=SidebarSettings +Singleton=true +Mutators=true +NameSpace=KSB_News |