[rkward-cvs] [rkward] rkward: Experimental: Work around hang when selecting dirs on Windows.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Feb 2 19:25:23 UTC 2015


Git commit 7a819914099588847aa5ea48b8e07850a8d1316c by Thomas Friedrichsmeier.
Committed on 02/02/2015 at 19:24.
Pushed by tfry into branch 'master'.

Experimental: Work around hang when selecting dirs on Windows.

M  +19   -1    rkward/misc/getfilenamewidget.cpp
M  +5    -1    rkward/misc/getfilenamewidget.h
M  +6    -1    rkward/settings/rksettingsmoduler.cpp

http://commits.kde.org/rkward/7a819914099588847aa5ea48b8e07850a8d1316c

diff --git a/rkward/misc/getfilenamewidget.cpp b/rkward/misc/getfilenamewidget.cpp
index 9f89817..efba428 100644
--- a/rkward/misc/getfilenamewidget.cpp
+++ b/rkward/misc/getfilenamewidget.cpp
@@ -2,7 +2,7 @@
                           getfilenamewidget  -  description
                              -------------------
     begin                : Tue Aug 24 2004
-    copyright            : (C) 2004, 2007, 2009, 2010, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007, 2009, 2010, 2012, 2015 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -18,6 +18,7 @@
 
 #include <qlabel.h>
 #include <QVBoxLayout>
+#include <QFileDialog>
 
 #include <klocale.h>
 #include <klineedit.h>
@@ -42,6 +43,12 @@ GetFileNameWidget::GetFileNameWidget (QWidget *parent, FileType mode, bool only_
 	KFile::Modes mode_flags;
 	if (mode == ExistingDirectory) {
 		mode_flags = KFile::Directory | KFile::ExistingOnly;
+#ifdef Q_WS_WIN
+		// TODO: Hang on Windows when trying to select any dir (also in KFileDialog::getExistingDirectory ()). KDE 4.10
+		// this hack works around this, by using QFileDialog::getExistingDirectory ().
+		edit->button ()->disconnect (SIGNAL (clicked()));
+		connect (edit->button (), SIGNAL (clicked()), this, SLOT(hackOverrideDirDialog()));
+#endif
 	} else if (mode == ExistingFile) {
 		mode_flags = KFile::File | KFile::ExistingOnly;
 	} else if (mode == SaveFile) {
@@ -73,6 +80,17 @@ void GetFileNameWidget::setLocation (const QString &new_location) {
 	if (edit->text () != new_location) edit->setUrl (new_location);
 }
 
+#ifdef Q_WS_WIN
+void GetFileNameWidget::hackOverrideDirDialog () {
+	RK_TRACE (MISC);
+	QUrl res = QFileDialog::getExistingDirectory (this, edit->windowTitle (), edit->startDir ().toLocalFile ());
+	if (res.isValid ()) {
+		edit->setUrl (res);
+		emit (locationChanged ());
+	}
+}
+#endif
+
 void GetFileNameWidget::locationEditChanged (const QString &) {
 	RK_TRACE (MISC);
 	emit (locationChanged ());
diff --git a/rkward/misc/getfilenamewidget.h b/rkward/misc/getfilenamewidget.h
index dc115e5..f0a1c17 100644
--- a/rkward/misc/getfilenamewidget.h
+++ b/rkward/misc/getfilenamewidget.h
@@ -2,7 +2,7 @@
                           getfilenamewidget  -  description
                              -------------------
     begin                : Tue Aug 24 2004
-    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2007, 2015 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -48,6 +48,10 @@ public slots:
 	void locationEditChanged (const QString &);
 signals:
 	void locationChanged ();
+#ifdef Q_WS_WIN
+private slots:
+	void hackOverrideDirDialog ();
+#endif
 private:
 	KUrlRequester *edit;
 };
diff --git a/rkward/settings/rksettingsmoduler.cpp b/rkward/settings/rksettingsmoduler.cpp
index 7074522..729fa0d 100644
--- a/rkward/settings/rksettingsmoduler.cpp
+++ b/rkward/settings/rksettingsmoduler.cpp
@@ -2,7 +2,7 @@
                           rksettingsmoduler  -  description
                              -------------------
     begin                : Wed Jul 28 2004
-    copyright            : (C) 2004-2013 by Thomas Friedrichsmeier
+    copyright            : (C) 2004-2015 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -416,7 +416,12 @@ void RKSettingsModuleRPackages::settingChanged () {
 
 void RKSettingsModuleRPackages::addLibLoc (QStringList *string_list) {
 	RK_TRACE (SETTINGS);
+#ifdef Q_WS_WIN
+	// TODO: Hang on Windows when trying to select any dir using KFileDialog::getExistingDirectory (). KDE 4.10
+	QString new_string = QFileDialog::getExistingDirectory (this, i18n ("Add R Library Directory"));
+#else
 	QString new_string = KFileDialog::getExistingDirectory (KUrl (), this, i18n ("Add R Library Directory"));
+#endif
 	if (!new_string.isEmpty ()) {
 		(*string_list).append (new_string);
 	}


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
rkward-cvs mailing list
rkward-cvs at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rkward-cvs


More information about the rkward-tracker mailing list