[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [patch] khelpcenter doesn't open custom documentation
From:       Stephan Kulow <coolo () kde ! org>
Date:       2002-03-05 16:02:34
[Download RAW message or body]

Hi!

I'd like to commit this patch to make it possible to open pdf/ps or whatever 
in an external browser instead of as plainly converted HTML within 
khelpcenter (most do not understand postscripts nativly I suppose)

Greetings, Stephan

RCS file: /home/kde/kdebase/khelpcenter/khc_main.cc,v
retrieving revision 1.53
diff -u -u -r1.53 khc_main.cc
--- khc_main.cc 2002/03/04 12:36:51     1.53
+++ khc_main.cc 2002/03/05 16:00:54
@@ -29,6 +29,7 @@
 #include <kcmdlineargs.h>
 #include <kpopupmenu.h>
 #include <kstringhandler.h>
+#include <kmimemagic.h>

 #include <qdir.h>
 #include <qfile.h>
@@ -193,13 +194,21 @@
 void KHMainWindow::slotOpenURLRequest( const KURL &url,
                                        const KParts::URLArgs &args)
 {
-    QString proto = url.protocol().lower();
-    if ( proto != "help" && proto != "glossentry" && proto != "about" &&
-         proto != "man" && proto != "info" && proto != "file")
-    {
-        kapp->invokeBrowser( url.url() );
-        return;
-    }
+  bool own = false;
+  QString proto = url.protocol().lower();
+  if ( proto == "help" || proto == "glossentry" || proto == "about" ||
+       proto == "man" || proto == "info")
+    own = true;
+  else if (url.isLocalFile()) {
+    KMimeMagicResult *res = KMimeMagic::self()->findFileType(url.path());
+    if (res->isValid() && res->accuracy() > 70 && res->mimeType().left(5) == 
"text/")
+      own = true;
+  }
+
+  if (!own) {
+    kapp->invokeBrowser( url.url() );
+    return;
+  }

     stop();

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic