diff options
Diffstat (limited to 'kdesktop/kwebdesktop')
-rw-r--r-- | kdesktop/kwebdesktop/Makefile.am | 15 | ||||
-rw-r--r-- | kdesktop/kwebdesktop/kwebdesktop.cpp | 191 | ||||
-rw-r--r-- | kdesktop/kwebdesktop/kwebdesktop.desktop | 80 | ||||
-rw-r--r-- | kdesktop/kwebdesktop/kwebdesktop.h | 70 | ||||
-rw-r--r-- | kdesktop/kwebdesktop/kwebdesktop.kcfg | 19 | ||||
-rw-r--r-- | kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc | 4 |
6 files changed, 379 insertions, 0 deletions
diff --git a/kdesktop/kwebdesktop/Makefile.am b/kdesktop/kwebdesktop/Makefile.am new file mode 100644 index 000000000..def6fa938 --- /dev/null +++ b/kdesktop/kwebdesktop/Makefile.am @@ -0,0 +1,15 @@ + +INCLUDES= $(all_includes) +LDADD = $(LIB_KHTML) + +bin_PROGRAMS = kwebdesktop + +METASOURCES = AUTO + +kwebdesktop_SOURCES = kwebdesktop.cpp kwebdesktopsettings.kcfgc +kwebdesktop_LDFLAGS = $(all_libraries) $(KDE_RPATH) + +kdesktop_kwebdesktop_data_DATA = kwebdesktop.desktop +kdesktop_kwebdesktop_datadir = $(kde_datadir)/kdesktop/programs + +kde_kcfg_DATA = kwebdesktop.kcfg diff --git a/kdesktop/kwebdesktop/kwebdesktop.cpp b/kdesktop/kwebdesktop/kwebdesktop.cpp new file mode 100644 index 000000000..e7010f06d --- /dev/null +++ b/kdesktop/kwebdesktop/kwebdesktop.cpp @@ -0,0 +1,191 @@ +/* This file is part of the KDE project + Copyright (C) 2000 David Faure <faure@kde.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +// Idea by Gael Duval +// Implementation by David Faure + +#include <config.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <klocale.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> +#include <kurifilter.h> +#include <kio/job.h> + +#include <qscrollview.h> +#include "kwebdesktop.h" +#include <kmimetype.h> +#include <kparts/componentfactory.h> +#include "kwebdesktopsettings.h" + +#include "kwebdesktop.moc" + +static KCmdLineOptions options[] = +{ + { "+width", I18N_NOOP("Width of the image to create"), 0 }, + { "+height", I18N_NOOP("Height of the image to create"), 0 }, + { "+file", I18N_NOOP("File sname where to dump the output in png format"), 0 }, + { "+[URL]", I18N_NOOP("URL to open (if not specified, it is read from kwebdesktoprc)"), 0 }, + KCmdLineLastOption +}; + +KWebDesktopRun::KWebDesktopRun( KWebDesktop* webDesktop, const KURL & url ) + : m_webDesktop(webDesktop), m_url(url) +{ + kdDebug() << "KWebDesktopRun::KWebDesktopRun starting get" << endl; + KIO::Job * job = KIO::get(m_url, false, false); + connect( job, SIGNAL( result( KIO::Job *)), + this, SLOT( slotFinished(KIO::Job *))); + connect( job, SIGNAL( mimetype( KIO::Job *, const QString &)), + this, SLOT( slotMimetype(KIO::Job *, const QString &))); +} + +void KWebDesktopRun::slotMimetype( KIO::Job *job, const QString &_type ) +{ + KIO::SimpleJob *sjob = static_cast<KIO::SimpleJob *>(job); + // Update our URL in case of a redirection + m_url = sjob->url(); + QString type = _type; // necessary copy if we plan to use it + sjob->putOnHold(); + kdDebug() << "slotMimetype : " << type << endl; + + KParts::ReadOnlyPart* part = m_webDesktop->createPart( type ); + // Now open the URL in the part + if ( part ) + part->openURL( m_url ); +} + +void KWebDesktopRun::slotFinished( KIO::Job * job ) +{ + // The whole point of all this is to abort silently on error + if (job->error()) + { + kdDebug() << job->errorString() << endl; + kapp->exit(1); + } +} + + +int main( int argc, char **argv ) +{ + KAboutData data( "kwebdesktop", I18N_NOOP("KDE Web Desktop"), + VERSION, + I18N_NOOP("Displays an HTML page as the background of the desktop"), + KAboutData::License_GPL, + "(c) 2000, David Faure <faure@kde.org>" ); + data.addAuthor( "David Faure", I18N_NOOP("developer and maintainer"), "faure@kde.org" ); + + KCmdLineArgs::init( argc, argv, &data ); + + KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. + + KApplication app; + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + if ( args->count() != 3 && args->count() != 4 ) + { + args->usage(); + return 1; + } + const int width = QCString(args->arg(0)).toInt(); + const int height = QCString(args->arg(1)).toInt(); + QCString imageFile = args->arg(2); + QString url; + if (args->count() == 4) + url = QString::fromLocal8Bit(args->arg(3)); + + KWebDesktop *webDesktop = new KWebDesktop( 0, imageFile, width, height ); + + if (url.isEmpty()) + url = KWebDesktopSettings::uRL(); + // Apply uri filter + KURIFilterData uridata = url; + KURIFilter::self()->filterURI( uridata ); + KURL u = uridata.uri(); + + // Now start getting, to ensure mimetype and possible connection + KWebDesktopRun * run = new KWebDesktopRun( webDesktop, u ); + + int ret = app.exec(); + + KIO::SimpleJob::removeOnHold(); // Kill any slave that was put on hold. + delete webDesktop; + delete run; + //khtml::Cache::clear(); + + return ret; +} + +void KWebDesktop::slotCompleted() +{ + kdDebug() << "KWebDesktop::slotCompleted" << endl; + // Dump image to m_imageFile + QPixmap snapshot = QPixmap::grabWidget( m_part->widget() ); + snapshot.save( m_imageFile, "PNG" ); + // And terminate the app. + kapp->quit(); +} + +KParts::ReadOnlyPart* KWebDesktop::createPart( const QString& mimeType ) +{ + delete m_part; + m_part = 0; + + KMimeType::Ptr mime = KMimeType::mimeType( mimeType ); + if ( !mime || mime == KMimeType::defaultMimeTypePtr() ) + return 0; + if ( mime->is( "text/html" ) || mime->is( "text/xml" ) || mime->is( "application/xhtml+xml" ) ) + { + KHTMLPart* htmlPart = new KHTMLPart; + htmlPart->widget()->resize(m_width,m_height); + + htmlPart->setMetaRefreshEnabled(false); + htmlPart->setJScriptEnabled(false); + htmlPart->setJavaEnabled(false); + + ((QScrollView *)htmlPart->widget())->setHScrollBarMode( QScrollView::AlwaysOff ); + ((QScrollView *)htmlPart->widget())->setVScrollBarMode( QScrollView::AlwaysOff ); + + connect( htmlPart, SIGNAL( completed() ), this, SLOT( slotCompleted() ) ); + m_part = htmlPart; + } else { + // Try to find an appropriate viewer component + m_part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart> + ( mimeType, QString::null, 0, 0, this, 0 ); + if ( !m_part ) + kdWarning() << "No handler found for " << mimeType << endl; + else { + kdDebug() << "Loaded " << m_part->className() << endl; + connect( m_part, SIGNAL( completed() ), + this, SLOT( slotCompleted() ) ); + } + } + if ( m_part ) { + connect( m_part, SIGNAL( canceled(const QString &) ), + this, SLOT( slotCompleted() ) ); + } + return m_part; +} + +KWebDesktop::~KWebDesktop() +{ + delete m_part; +} diff --git a/kdesktop/kwebdesktop/kwebdesktop.desktop b/kdesktop/kwebdesktop/kwebdesktop.desktop new file mode 100644 index 000000000..747140f15 --- /dev/null +++ b/kdesktop/kwebdesktop/kwebdesktop.desktop @@ -0,0 +1,80 @@ +[KDE Desktop Program] +Comment=KDE Web Desktop +Comment[af]=KDE Web Werkskerm +Comment[ar]=سطح المكتب KDE للشبكة +Comment[az]=KDE Veb Masa üstü +Comment[be]=Працоўны стол Web +Comment[bn]=কে.ডি.ই. ওয়েব ডেস্কটপ +Comment[br]=Burev gwiad KDE +Comment[bs]=KDE Web radna površina +Comment[ca]=Escriptori Web KDE +Comment[cs]=Aktivní plocha KDE +Comment[csb]=Pùlt w sztélu sécë WWW +Comment[cy]=Penbwrdd Gwe KDE +Comment[da]=KDE-net-desktop +Comment[de]=KDE-Web-Arbeitsfläche +Comment[el]=Επιφάνεια εργασίας Ιστού του KDE +Comment[eo]=KDEa TTT-tabulo +Comment[es]=Escritorio Web para KDE +Comment[et]=KDE veebitöölaud +Comment[eu]=KDE web mahaigaina +Comment[fa]=رومیزی وب KDE +Comment[fi]=KDE:n web-työpöytä +Comment[fr]=Bureau web de KDE +Comment[fy]=KDE Web Buroblêd +Comment[gl]=Escritório Web de KDE +Comment[he]=שולחן העבודה האינטרנטי של KDE +Comment[hi]=केडीई वेब डेस्कटॉप +Comment[hr]=KDE web radna površina +Comment[hu]=KDE internetes munkaasztal +Comment[id]=Desktop Web KDE +Comment[is]=KDE vefskjáborð +Comment[it]=Desktop Web di KDE +Comment[ja]=KDE ウェブデスクトップ +Comment[ka]=KDE ვებ სამუშაო დაფა +Comment[km]=ផ្ទៃតុបណ្ដាញ KDE +Comment[lo]=ພື້ນທີ່ທຳງານບົນເວ໊ບ KDE +Comment[lt]=KDE žiniatinklio darbastalis +Comment[lv]=KDE Web Darbvirsma +Comment[mk]=KDE веб-површина +Comment[mn]=КДЭ-Вэб-Ажлын тавцан +Comment[ms]=Desktop Web KDE +Comment[mt]=Desktop Web KDE +Comment[nb]=KDE nettskrivebord +Comment[nds]=KDE-Nettschriefdisch +Comment[ne]=KDE वेब डेस्कटप +Comment[nl]=KDE Web Bureaublad +Comment[nn]=KDE Vevskrivebord +Comment[nso]=Desktop ya Web ya KDE +Comment[oc]=BurèU Web KDE +Comment[pa]=KDE ਵੈੱਬ ਵੇਹੜਾ +Comment[pl]=Pulpit w stylu sieci WWW +Comment[pt]=Ecrã Web do KDE +Comment[pt_BR]=Área de Trabalho Web do KDE +Comment[ro]=Ecran web pentru KDE +Comment[rw]=KDE Ibiro Rubugamakuru +Comment[se]=KDE Web-čállinbeavdi +Comment[sk]=KDE Web pracovná plocha +Comment[sl]=Spletno namizje KDE +Comment[sr]=KDE веб радна површина +Comment[sr@Latn]=KDE veb radna površina +Comment[sv]=KDE-webbskrivbord +Comment[ta]=KDE வலை மேல்மேசை +Comment[te]=కెడిఈ వెబ్ రంగస్థలం +Comment[tg]=Мизи кории KDE Вэб +Comment[th]=พื้นที่ทำงาน KDE แบบเว็บ +Comment[tr]=KDE Web Masaüstü +Comment[tt]=KDE Web Östäl +Comment[uk]=Стільниця "а ля Web" для KDE +Comment[uz]=KDE veb-ish stoli +Comment[uz@cyrillic]=KDE веб-иш столи +Comment[ven]=Webe ya desikithopo ya KDE +Comment[vi]=màn hình nền kiểu trang mạng của KDE +Comment[wa]=Sicribanne waibe KDE +Comment[zh_CN]=KDE Web 桌面 +Comment[zh_TW]=KDE 網頁桌面 +Comment[zu]=I-Desktop ye-Web ye-KDE +Executable=kwebdesktop +Command=kwebdesktop %x %y %f http://www.kde.org/ +PreviewCommand=kwebdesktop %x %y %f http://www.kde.org/ +Refresh=10 diff --git a/kdesktop/kwebdesktop/kwebdesktop.h b/kdesktop/kwebdesktop/kwebdesktop.h new file mode 100644 index 000000000..d364f8022 --- /dev/null +++ b/kdesktop/kwebdesktop/kwebdesktop.h @@ -0,0 +1,70 @@ +/* This file is part of the KDE project + Copyright (C) 2000 David Faure <faure@kde.org> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef KWEBDESKTOP_H +#define KWEBDESKTOP_H + +#include <qobject.h> +#include <qcstring.h> +#include <kparts/browserextension.h> +#include <khtml_part.h> + +namespace KIO { class Job; } + +class KWebDesktop : public QObject +{ + Q_OBJECT +public: + KWebDesktop( QObject* parent, const QCString & imageFile, int width, int height ) + : QObject( parent ), + m_part( 0 ), + m_imageFile( imageFile ), + m_width( width ), + m_height( height ) {} + ~KWebDesktop(); + + KParts::ReadOnlyPart* createPart( const QString& mimeType ); + +private slots: + void slotCompleted(); + +private: + KParts::ReadOnlyPart* m_part; + QCString m_imageFile; + int m_width; + int m_height; +}; + + +class KWebDesktopRun : public QObject +{ + Q_OBJECT +public: + KWebDesktopRun( KWebDesktop* webDesktop, const KURL & url ); + ~KWebDesktopRun() {} + +protected slots: + void slotMimetype( KIO::Job *job, const QString &_type ); + void slotFinished( KIO::Job * job ); + +private: + KWebDesktop* m_webDesktop; + KURL m_url; +}; + +#endif diff --git a/kdesktop/kwebdesktop/kwebdesktop.kcfg b/kdesktop/kwebdesktop/kwebdesktop.kcfg new file mode 100644 index 000000000..fad395a19 --- /dev/null +++ b/kdesktop/kwebdesktop/kwebdesktop.kcfg @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <kcfgfile name="kwebdesktoprc" /> + <!-- generated by KConfig XTraKtor --> + + <group name="Settings"> + <entry key="URL" type="String"> + <default>http://www.kde.org/</default> + <label></label> + <whatsthis></whatsthis> + <!-- kdiconview.cc:1103 --> + <!-- cfg.readEntry( "URL" ) == "trash:/" ) { --> + </entry> + </group> + +</kcfg> diff --git a/kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc b/kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc new file mode 100644 index 000000000..6989a0071 --- /dev/null +++ b/kdesktop/kwebdesktop/kwebdesktopsettings.kcfgc @@ -0,0 +1,4 @@ +File=kwebdesktop.kcfg +ClassName=KWebDesktopSettings +Singleton=true +Mutators=true |