gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r9880 - in gnunet-qt/src: common include plugins/fs


From: gnunet
Subject: [GNUnet-SVN] r9880 - in gnunet-qt/src: common include plugins/fs
Date: Wed, 23 Dec 2009 20:57:16 +0100

Author: durner
Date: 2009-12-23 20:57:16 +0100 (Wed, 23 Dec 2009)
New Revision: 9880

Added:
   gnunet-qt/src/common/desktopServices.cc
   gnunet-qt/src/common/desktopServices.h
Modified:
   gnunet-qt/src/common/Makefile.am
   gnunet-qt/src/include/gnunet_qt_common.h
   gnunet-qt/src/plugins/fs/fs.cc
Log:
fix "open downloaded file"

Modified: gnunet-qt/src/common/Makefile.am
===================================================================
--- gnunet-qt/src/common/Makefile.am    2009-12-23 18:41:13 UTC (rev 9879)
+++ gnunet-qt/src/common/Makefile.am    2009-12-23 19:57:16 UTC (rev 9880)
@@ -6,6 +6,8 @@
 libgnunetqt_common_la_SOURCES = \
   ../include/gnunet_qt_common.h \
   assert.cc \
+  desktopServices.cc \
+  desktopServices.h \
   pluginLoader.cc \
   gstring.cc \
   event.cc \

Added: gnunet-qt/src/common/desktopServices.cc
===================================================================
--- gnunet-qt/src/common/desktopServices.cc                             (rev 0)
+++ gnunet-qt/src/common/desktopServices.cc     2009-12-23 19:57:16 UTC (rev 
9880)
@@ -0,0 +1,50 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2009 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+#include <QDesktopServices>
+#include <windows.h>
+#include "desktopServices.h"
+
+/**
+ * @file src/common/desktopServices.cc
+ * @brief Desktop integration
+ * @author Nils Durner
+ */
+
+/**
+ * @brief Opens a file in its default viewer
+ * @param strPath path to the file
+ * @return true on success
+ */
+bool GDesktopServices::openDocument(QString strPath)
+{
+#if defined(Q_OS_WIN32)
+  // Qt 4.2 URL encodes files which is not understood by Windows, so
+  // we call ShellExecute directly instead of openUrl()
+  return ((unsigned int) ShellExecuteA(0, 0, qPrintable(strPath), 0, 0, 
SW_SHOWNORMAL)) > 32;
+#else
+  QUrl url;
+
+  url.setScheme("file");
+  url.setPath(strPath);
+
+  return QDesktopServices::openUrl(url);
+#endif
+}

Added: gnunet-qt/src/common/desktopServices.h
===================================================================
--- gnunet-qt/src/common/desktopServices.h                              (rev 0)
+++ gnunet-qt/src/common/desktopServices.h      2009-12-23 19:57:16 UTC (rev 
9880)
@@ -0,0 +1,36 @@
+/*
+     This file is part of gnunet-qt.
+     (C) 2009 Nils Durner (and other contributing authors)
+
+     gnunet-qt 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, or (at your
+     option) any later version.
+
+     gnunet-qt 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 GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/common/desktopServices.h
+ * @brief Desktop integration
+ * @author Nils Durner
+ */
+
+class GDesktopServices
+{
+public:
+  /**
+   * @brief Opens a file in its default viewer
+   * @param strPath path to the file
+   * @return true on success
+   */
+  static bool openDocument(QString strPath);
+};

Modified: gnunet-qt/src/include/gnunet_qt_common.h
===================================================================
--- gnunet-qt/src/include/gnunet_qt_common.h    2009-12-23 18:41:13 UTC (rev 
9879)
+++ gnunet-qt/src/include/gnunet_qt_common.h    2009-12-23 19:57:16 UTC (rev 
9880)
@@ -32,6 +32,7 @@
 #include <QLibrary>
 #include <QPersistentModelIndex>
 
+#include "../common/desktopServices.h"
 #include "../common/event.h"
 #include "../common/eventDispatcher.h"
 #include "../common/itemModel.h"

Modified: gnunet-qt/src/plugins/fs/fs.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs.cc      2009-12-23 18:41:13 UTC (rev 9879)
+++ gnunet-qt/src/plugins/fs/fs.cc      2009-12-23 19:57:16 UTC (rev 9880)
@@ -285,12 +285,7 @@
       QFileInfo info(name);
 
       // Open file
-      QUrl url;
-
-      url.setScheme("file");
-      url.setPath(info.absoluteFilePath());
-
-      QDesktopServices::openUrl(url);
+      GDesktopServices::openDocument(info.absoluteFilePath());
     }
   }
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]