diff options
Diffstat (limited to 'konq-plugins/crashes')
-rw-r--r-- | konq-plugins/crashes/Makefile.am | 16 | ||||
-rw-r--r-- | konq-plugins/crashes/crashesplugin.cpp | 193 | ||||
-rw-r--r-- | konq-plugins/crashes/crashesplugin.desktop | 124 | ||||
-rw-r--r-- | konq-plugins/crashes/crashesplugin.h | 70 | ||||
-rw-r--r-- | konq-plugins/crashes/crashesplugin.rc | 11 |
5 files changed, 414 insertions, 0 deletions
diff --git a/konq-plugins/crashes/Makefile.am b/konq-plugins/crashes/Makefile.am new file mode 100644 index 0000000..710ec6e --- /dev/null +++ b/konq-plugins/crashes/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = libcrashesplugin.la +libcrashesplugin_la_SOURCES = crashesplugin.cpp +libcrashesplugin_la_LIBADD = $(LIB_KHTML) -lkonq +libcrashesplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) + +pluginsdir = $(kde_datadir)/khtml/kpartplugins +plugins_DATA = crashesplugin.rc crashesplugin.desktop + +appsdir = $(kde_appsdir)/.hidden +apps_DATA = crashesplugin.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/crashesplugin.pot diff --git a/konq-plugins/crashes/crashesplugin.cpp b/konq-plugins/crashes/crashesplugin.cpp new file mode 100644 index 0000000..8d01553 --- /dev/null +++ b/konq-plugins/crashes/crashesplugin.cpp @@ -0,0 +1,193 @@ +/* + Copyright (c) 2002-2003 Alexander Kellett <lypanov@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License (LGPL) as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later + version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kdebug.h> +#include <kaction.h> +#include <kglobal.h> +#include <kconfig.h> +#include <kinstance.h> +#include <khtml_part.h> +#include <kgenericfactory.h> + +#include <krun.h> +#include <kservice.h> + +#include <kpopupmenu.h> +#include <kbookmarkimporter_crash.h> + +#include "crashesplugin.h" + +typedef KGenericFactory<CrashesPlugin> CrashesPluginFactory; +K_EXPORT_COMPONENT_FACTORY( libcrashesplugin, CrashesPluginFactory( "crashesplugin" ) ) + +CrashesPlugin::CrashesPlugin( QObject* parent, const char* name, const QStringList & ) +: KParts::Plugin( parent, name ) +{ + m_part = (parent && parent->inherits( "KHTMLPart" )) ? static_cast<KHTMLPart*>(parent) : 0L; + + m_pCrashesMenu = new KActionMenu( i18n("&Crashes"), "core", + actionCollection(), "crashes" ); + + m_pCrashesMenu->setDelayed( false ); + m_pCrashesMenu->setEnabled( true ); + + connect( m_pCrashesMenu->popupMenu(), SIGNAL( aboutToShow() ), + this, SLOT( slotAboutToShow() ) ); +} + +CrashesPlugin::~CrashesPlugin() +{ +} + +void CrashesPlugin::slotAboutToShow() +{ + m_pCrashesMenu->popupMenu()->clear(); + + KCrashBookmarkImporter importer(KCrashBookmarkImporter::crashBookmarksDir()); + + connect( &importer, SIGNAL( newBookmark( const QString &, const QCString &, const QString &) ), + SLOT( newBookmarkCallback( const QString &, const QCString &, const QString & ) ) ); + + connect( &importer, SIGNAL( endFolder() ), SLOT( endFolderCallback() ) ); + + int count = m_pCrashesMenu->popupMenu()->count(); + + m_crashesList.clear(); + m_crashRangesList.clear(); + importer.parseCrashBookmarks( false ); + + bool gotSep = true; // don't start with a sep + bool enable = true; + int firstItem = count; // item ids grow up from count + int crashGroup = INT_MAX; // group ids grow down from INT_MAX + if (m_crashesList.count() > 0) { + CrashesList::ConstIterator e = m_crashesList.begin(); + for( ; e != m_crashesList.end(); ++e ) { + if ( ((*e).first == "-") + && ((*e).second == "-") + ) { + if (!gotSep) { + if (count - firstItem > 1) + { + m_crashRangesList.append( CrashRange(firstItem, count) ); + m_pCrashesMenu->popupMenu()->insertItem( + i18n("All Pages of This Crash"), this, + SLOT(slotGroupSelected(int)), + 0, crashGroup--); + } + m_pCrashesMenu->popupMenu()->insertSeparator(); + } + gotSep = true; + firstItem = ++count; + } else { + QString str = (*e).first; + if (str.length() > 48) { + str.truncate(48); + str.append("..."); + } + m_pCrashesMenu->popupMenu()->insertItem( + str, this, + SLOT(slotItemSelected(int)), + 0, ++count ); + gotSep = false; + } + } + if (count - firstItem > 1) { + m_crashRangesList.append( CrashRange(firstItem, count) ); + m_pCrashesMenu->popupMenu()->insertItem( + i18n("All Pages of This Crash"), this, + SLOT(slotGroupSelected(int)), + 0, crashGroup--); + } + } else { + m_pCrashesMenu->popupMenu()->insertItem( + i18n("No Recovered Crashes"), this, + SLOT(slotItemSelected(int)), + 0, ++count ); + gotSep = false; + enable = false; + } + + if (!gotSep) { + // don't have an extra sep + m_pCrashesMenu->popupMenu()->insertSeparator(); + } + + int id =m_pCrashesMenu->popupMenu()->insertItem( i18n("&Clear List of Crashes"), this, + SLOT(slotClearCrashes()), + 0, ++count ); + m_pCrashesMenu->popupMenu()->setItemEnabled( id, enable); +} + +void CrashesPlugin::newBookmarkCallback( const QString & text, const QCString & url, + const QString & ) +{ + m_crashesList.prepend(qMakePair(text,url)); +} + +void CrashesPlugin::endFolderCallback( ) +{ + m_crashesList.prepend(qMakePair(QString("-"),QCString("-"))); +} + +void CrashesPlugin::slotClearCrashes() { + KCrashBookmarkImporter importer(KCrashBookmarkImporter::crashBookmarksDir()); + importer.parseCrashBookmarks( true ); + slotAboutToShow(); +} + +void CrashesPlugin::slotItemSelected( int id ) +{ + if (m_crashesList.count() == 0) + return; + KURL url( m_crashesList[id-1].second ); + if (m_part) + emit m_part->browserExtension()->openURLRequest( url ); +} + +void CrashesPlugin::slotGroupSelected( int range ) +{ + if (!m_part) + return; + + range = INT_MAX - range; + + if (m_crashesList.count() == 0 || m_crashRangesList.count() == 0) + return; + + CrashRange r = m_crashRangesList[range]; + int from = r.first; + int i = from; + + if (m_part) { + KParts::URLArgs urlargs; + urlargs.setNewTab( true ); + do { + KURL url( m_crashesList[i].second ); + // Open first one in current tab + if (i == from) + emit m_part->browserExtension()->openURLRequest( url ); + else + emit m_part->browserExtension()->createNewWindow( url, urlargs ); + } while (++i < r.second); + } +} + +#include "crashesplugin.moc" diff --git a/konq-plugins/crashes/crashesplugin.desktop b/konq-plugins/crashes/crashesplugin.desktop new file mode 100644 index 0000000..c806383 --- /dev/null +++ b/konq-plugins/crashes/crashesplugin.desktop @@ -0,0 +1,124 @@ +[Desktop Entry] +X-KDE-Library=Crashes +X-KDE-PluginInfo-Author=Alexander Kellett +X-KDE-PluginInfo-Email=lypanov@kde.org +X-KDE-PluginInfo-Name=Crashes +X-KDE-PluginInfo-Version=3.3 +X-KDE-PluginInfo-Website= +X-KDE-PluginInfo-Category=Tools +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false +Name=Crashes Monitor +Name[bg]=Монитор на блокирали процеси +Name[bs]=Praćenje krahova +Name[ca]=Monitor de petades +Name[cs]=Monitor pádů +Name[da]=Sammenbrudsovervågning +Name[de]=Absturzmonitor +Name[el]=Επόπτης καταρρεύσεων +Name[eo]=Kraŝa observilo +Name[es]=Monitor de bloqueos +Name[et]=Krahhide monitor +Name[eu]=Kaskraduren monitorea +Name[fa]=نمایشگر فروپاشیها +Name[fi]=Kaatumisenvalvonta +Name[fr]=Indicateur de plantages +Name[fy]=Fêstrinnersmonitor +Name[gl]=Monitor de Colgues +Name[he]=צג התרסקויות +Name[hi]=क्रैशेस मॉनीटर +Name[hr]=Nadzor padova +Name[hu]=Programhiba-figyelő +Name[is]=Hruns-eftirlit +Name[it]=Monitor dei crash +Name[ja]=クラッシュモニタ +Name[ka]=ავარიების მონიტორი +Name[kk]=Жаңылыстарды қадағалау +Name[km]=កម្មវិធីត្រួតពិនិត្យការគាំង +Name[lt]=Lūžimų stebėjimo priemonė +Name[mk]=Набљудувач на паѓања +Name[ms]=Monitor Rosak +Name[nb]=Krasjovervåker +Name[nds]=Afstörten-Kieker +Name[ne]=क्र्यास मनिटर +Name[nl]=Crash monitor +Name[nn]=Krasjovervaking +Name[pa]=ਨਸ਼ਟ ਨਿਗਰਾਨ +Name[pl]=Monitor awarii programu +Name[pt]=Monitor de Estoiros +Name[pt_BR]=Monitor de Travamentos +Name[ru]=Монитор сбоев +Name[sk]=Monitor pádov +Name[sl]=Nadzornik zrušenj +Name[sr]=Надгледање падова +Name[sr@Latn]=Nadgledanje padova +Name[sv]=Kraschövervakare +Name[ta]=திரை செயல் இழந்தது +Name[tg]=Нуқсонҳои монитор +Name[tr]=Monitörü Bozar +Name[uk]=Монітор аварій +Name[vi]=Bộ theo dõi sụp đổ +Name[zh_CN]=崩溃监视器 +Name[zh_TW]=當機監視器 +Comment=Crashes monitor +Comment[af]=Verongeluk monitor +Comment[ar]=مراقب الإنهيارات +Comment[az]=İflas izləyici +Comment[bg]=Монитор на блокирали процеси в KDE +Comment[bs]=Praćenje krahova +Comment[ca]=Monitor de petades +Comment[cs]=Monitor pádů +Comment[cy]=Gwarchodydd chwalfeydd +Comment[da]=Sammenbrudsovervåger +Comment[de]=Absturzmonitor +Comment[el]=Επόπτης καταρρεύσεων +Comment[eo]=Kraŝa observilo +Comment[es]=Monitor de bloqueos +Comment[et]=Krahhide monitor +Comment[eu]=Monitorea kraskarazten du +Comment[fa]=نمایشگر فروپاشیها +Comment[fi]=Kaatumistenvalvonta +Comment[fr]=Gestion des plantages logiciels +Comment[fy]=Fêstrinnersmonitor +Comment[gl]=Monitorea os petes das aplicacións +Comment[he]=צג התרסקויות +Comment[hi]=क्रैश मॉनीटर +Comment[hr]=Nadzor padova +Comment[hu]=Programhiba-monitor +Comment[is]=Hruns-eftirlit +Comment[it]=Monitorizza i crash +Comment[ja]=クラッシュモニタ +Comment[ka]=ავარიების მონიტორი +Comment[kk]=Жаңылыстарды қадағалау +Comment[km]=កម្មវិធីត្រួតពិនិត្យការគាំង +Comment[lt]=Lūžimų stebėtojas +Comment[mk]=Набљудувач на паѓања +Comment[ms]=Monitor rosak +Comment[nb]=Overvåker krasj +Comment[nds]=Afstörten-Kieker +Comment[ne]=मनिटर क्र्यास गर्छ +Comment[nl]=Vastlopers-monitor +Comment[nn]=Overvakar krasj +Comment[pa]=ਕਰੈਂਸ਼ ਨਿਗਰਾਨ +Comment[pl]=Monitor awarii programu +Comment[pt]=Monitor de estoiros +Comment[pt_BR]=Monitor de sistema +Comment[ro]=Program de monitorizare a prăbuşirii programelor +Comment[ru]=Монитор сбоев +Comment[sk]=Monitor pádov +Comment[sl]=Nadzornik zrušenj +Comment[sr]=Надгледање падова +Comment[sr@Latn]=Nadgledanje padova +Comment[sv]=Övervakar programkrascher +Comment[ta]=திரை செயல் இழந்தது +Comment[tg]=Нуқсонҳои монитор +Comment[tr]=Monitörü bozar +Comment[uk]=Монітор аварій +Comment[vi]=Bộ theo dõi sụp đổ +Comment[xh]=Ingqubana necebo lokubonisa +Comment[zh_CN]=崩溃监视器 +Comment[zh_TW]=當機監視器 +X-KDE-ParentApp=konqueror +Icon=core +DocPath=konq-plugins/crashes/index.html diff --git a/konq-plugins/crashes/crashesplugin.h b/konq-plugins/crashes/crashesplugin.h new file mode 100644 index 0000000..cff0831 --- /dev/null +++ b/konq-plugins/crashes/crashesplugin.h @@ -0,0 +1,70 @@ +/* + Copyright (c) 2002-2003 Alexander Kellett <lypanov@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License (LGPL) as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later + version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __CRASHES_PLUGIN_H +#define __CRASHES_PLUGIN_H + +#include <qmap.h> +#include <qvaluelist.h> +#include <qstringlist.h> + +#include <kurl.h> +#include <klibloader.h> +#include <kparts/plugin.h> + +class KHTMLPart; +class KActionMenu; + +class CrashesPlugin : public KParts::Plugin +{ + Q_OBJECT + +public: + CrashesPlugin( QObject* parent, const char* name, + const QStringList & ); + ~CrashesPlugin(); + +protected slots: + void slotAboutToShow(); + void slotClearCrashes(); + void slotItemSelected(int); + void slotGroupSelected(int); + void newBookmarkCallback( const QString &, const QCString &, const QString & ); + void endFolderCallback( ); + +private: + int m_selectedItem; + + KHTMLPart* m_part; + KActionMenu* m_pCrashesMenu; + + typedef QPair<QString,QCString> Crash; + typedef QValueList<Crash> CrashesList; + + CrashesList m_crashesList; + + typedef QPair<int, int> CrashRange; + typedef QValueList<CrashRange> CrashRangesList; + + CrashRangesList m_crashRangesList; + +}; + +#endif diff --git a/konq-plugins/crashes/crashesplugin.rc b/konq-plugins/crashes/crashesplugin.rc new file mode 100644 index 0000000..35fc070 --- /dev/null +++ b/konq-plugins/crashes/crashesplugin.rc @@ -0,0 +1,11 @@ +<!DOCTYPE kpartplugin> +<kpartplugin name="Crashes" library="libcrashesplugin"> +<MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="crashes"/> + </Menu> +</MenuBar> +<ToolBar name="extraToolBar"><text>Extra Toolbar</text> + <Action name="crashes"/> +</ToolBar> +</kpartplugin> |