summaryrefslogtreecommitdiffstats
path: root/konq-plugins/sidebar/metabar/src
diff options
context:
space:
mode:
Diffstat (limited to 'konq-plugins/sidebar/metabar/src')
-rw-r--r--konq-plugins/sidebar/metabar/src/Makefile.am28
-rw-r--r--konq-plugins/sidebar/metabar/src/configdialog.cpp611
-rw-r--r--konq-plugins/sidebar/metabar/src/configdialog.h114
-rw-r--r--konq-plugins/sidebar/metabar/src/default.css64
-rw-r--r--konq-plugins/sidebar/metabar/src/defaultplugin.cpp458
-rw-r--r--konq-plugins/sidebar/metabar/src/defaultplugin.h64
-rw-r--r--konq-plugins/sidebar/metabar/src/hi128-app-metabar.pngbin0 -> 11139 bytes
-rw-r--r--konq-plugins/sidebar/metabar/src/hi16-app-metabar.pngbin0 -> 735 bytes
-rw-r--r--konq-plugins/sidebar/metabar/src/hi32-app-metabar.pngbin0 -> 1710 bytes
-rw-r--r--konq-plugins/sidebar/metabar/src/hi48-app-metabar.pngbin0 -> 2912 bytes
-rw-r--r--konq-plugins/sidebar/metabar/src/hi64-app-metabar.pngbin0 -> 4318 bytes
-rw-r--r--konq-plugins/sidebar/metabar/src/hisc-app-metabar.svgzbin0 -> 5341 bytes
-rw-r--r--konq-plugins/sidebar/metabar/src/httpplugin.cpp119
-rw-r--r--konq-plugins/sidebar/metabar/src/httpplugin.h51
-rw-r--r--konq-plugins/sidebar/metabar/src/iconsrc4
-rw-r--r--konq-plugins/sidebar/metabar/src/layout.html48
-rw-r--r--konq-plugins/sidebar/metabar/src/metabar.cpp59
-rw-r--r--konq-plugins/sidebar/metabar/src/metabar.desktop81
-rw-r--r--konq-plugins/sidebar/metabar/src/metabar.h32
-rw-r--r--konq-plugins/sidebar/metabar/src/metabar_add.desktop70
-rw-r--r--konq-plugins/sidebar/metabar/src/metabarfunctions.cpp242
-rw-r--r--konq-plugins/sidebar/metabar/src/metabarfunctions.h59
-rw-r--r--konq-plugins/sidebar/metabar/src/metabarwidget.cpp592
-rw-r--r--konq-plugins/sidebar/metabar/src/metabarwidget.h88
-rw-r--r--konq-plugins/sidebar/metabar/src/protocolplugin.cpp157
-rw-r--r--konq-plugins/sidebar/metabar/src/protocolplugin.h60
-rw-r--r--konq-plugins/sidebar/metabar/src/remoteplugin.cpp52
-rw-r--r--konq-plugins/sidebar/metabar/src/remoteplugin.h37
-rw-r--r--konq-plugins/sidebar/metabar/src/serviceloader.cpp213
-rw-r--r--konq-plugins/sidebar/metabar/src/serviceloader.h59
-rw-r--r--konq-plugins/sidebar/metabar/src/settingsplugin.cpp201
-rw-r--r--konq-plugins/sidebar/metabar/src/settingsplugin.h56
32 files changed, 3619 insertions, 0 deletions
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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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
new file mode 100644
index 0000000..1ee89bf
--- /dev/null
+++ b/konq-plugins/sidebar/metabar/src/hi128-app-metabar.png
Binary files differ
diff --git a/konq-plugins/sidebar/metabar/src/hi16-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi16-app-metabar.png
new file mode 100644
index 0000000..c47b0b0
--- /dev/null
+++ b/konq-plugins/sidebar/metabar/src/hi16-app-metabar.png
Binary files differ
diff --git a/konq-plugins/sidebar/metabar/src/hi32-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi32-app-metabar.png
new file mode 100644
index 0000000..c0d6213
--- /dev/null
+++ b/konq-plugins/sidebar/metabar/src/hi32-app-metabar.png
Binary files differ
diff --git a/konq-plugins/sidebar/metabar/src/hi48-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi48-app-metabar.png
new file mode 100644
index 0000000..763ec38
--- /dev/null
+++ b/konq-plugins/sidebar/metabar/src/hi48-app-metabar.png
Binary files differ
diff --git a/konq-plugins/sidebar/metabar/src/hi64-app-metabar.png b/konq-plugins/sidebar/metabar/src/hi64-app-metabar.png
new file mode 100644
index 0000000..89fa615
--- /dev/null
+++ b/konq-plugins/sidebar/metabar/src/hi64-app-metabar.png
Binary files differ
diff --git a/konq-plugins/sidebar/metabar/src/hisc-app-metabar.svgz b/konq-plugins/sidebar/metabar/src/hisc-app-metabar.svgz
new file mode 100644
index 0000000..6b955f5
--- /dev/null
+++ b/konq-plugins/sidebar/metabar/src/hisc-app-metabar.svgz
Binary files differ
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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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 *
+ * florian@synatic.net *
+ * *
+ * 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