r18153 by jghali - #11419: File open dialog broken when pressing Escape

scribus-commit scribus-commit at lists.scribus.net
Wed Feb 20 22:58:07 UTC 2013


Author: jghali
Date: Wed Feb 20 22:58:07 2013
New Revision: 18153

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18153
Log:
#11419: File open dialog broken when pressing Escape

Added:
    branches/Version14x/Scribus/scribus/scescapecatcher.cpp
    branches/Version14x/Scribus/scribus/scescapecatcher.h
Modified:
    branches/Version14x/Scribus/scribus/CMakeLists.txt
    branches/Version14x/Scribus/scribus/newfile.cpp
    branches/Version14x/Scribus/scribus/scfilewidget.cpp
    branches/Version14x/Scribus/scribus/scfilewidget.h
    branches/Version14x/Scribus/win32/vc9/scribus-exe/scribus.vcproj

Modified: branches/Version14x/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18153&path=/branches/Version14x/Scribus/scribus/CMakeLists.txt
==============================================================================
--- branches/Version14x/Scribus/scribus/CMakeLists.txt (original)
+++ branches/Version14x/Scribus/scribus/CMakeLists.txt Wed Feb 20 22:58:07 2013
@@ -210,6 +210,7 @@
   replaceonecolor.h
   rulermover.h
   sampleitem.h
+  scescapecatcher.h
   scfilewidget.h
   scgtplugin.h
   schelptreemodel.h
@@ -500,6 +501,7 @@
   sccombobox.cpp
   scdocoutput.cpp
   scdocoutput_ps2.cpp
+  scescapecatcher.cpp
   scfilewidget.cpp
   scfonts.cpp
   scgtplugin.cpp

Modified: branches/Version14x/Scribus/scribus/newfile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18153&path=/branches/Version14x/Scribus/scribus/newfile.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/newfile.cpp (original)
+++ branches/Version14x/Scribus/scribus/newfile.cpp Wed Feb 20 22:58:07 2013
@@ -10,39 +10,38 @@
 #include <QGridLayout>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
-#include <QSpacerItem>
-#include <QListWidgetItem>
+
+#include <QCheckBox>
+#include <QDir>
+#include <QFileDialog>
 #include <QFrame>
 #include <QGroupBox>
 #include <QLabel>
+#include <QListWidgetItem>
+#include <QPixmap>
+#include <QPoint>
+#include <QPushButton>
+#include <QSpacerItem>
 #include <QSpinBox>
-#include <QCheckBox>
 #include <QTabWidget>
-#include <QPushButton>
-#include <QPixmap>
 #include <QToolTip>
-#include <QDir>
-#include <QPoint>
-#if QT_VERSION  >= 0x040300
-	#include <QFileDialog>
-#else
-	#include "customfdialog.h"
-#endif
-
+
+#include "scconfig.h"
+
+#include "commonstrings.h"
 #include "fileloader.h"
-#include "prefsfile.h"
-#include "units.h"
+#include "marginwidget.h"
 #include "pagesize.h"
-#include "marginwidget.h"
-#include "scconfig.h"
-#include "scribuscore.h"
-#include "prefsmanager.h"
 #include "pagelayout.h"
 #include "pagestructs.h"
-#include "commonstrings.h"
+#include "prefsfile.h"
+#include "prefsmanager.h"
+#include "sccombobox.h"
+#include "scescapecatcher.h"
+#include "scribuscore.h"
 #include "scrspinbox.h"
-#include "sccombobox.h"
 #include "util_icon.h"
+#include "units.h"
 
 PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : QListWidget(parent)
 {
@@ -362,14 +361,11 @@
 	openDocLayout->setMargin(5);
 	openDocLayout->setSpacing(5);
 	m_selectedFile = "";
-#if QT_VERSION  >= 0x040300
+
 	fileDialog = new QFileDialog(openDocFrame, tr("Open"), docDir, formats);
 	fileDialog->setFileMode(QFileDialog::ExistingFile);
 	fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
 	fileDialog->setReadOnly(true);
-#else
-	fileDialog = new CustomFDialog(openDocFrame, docDir, tr("Open"), formats, fdNone);
-#endif
 	fileDialog->setSizeGripEnabled(false);
 	fileDialog->setModal(false);
 	QList<QPushButton *> b = fileDialog->findChildren<QPushButton *>();
@@ -378,11 +374,15 @@
 		i.next()->setVisible(false);
 	fileDialog->setWindowFlags(Qt::Widget);
 	openDocLayout->addWidget(fileDialog);
-#if QT_VERSION  >= 0x040300
+
+	ScEscapeCatcher* keyCatcher = new ScEscapeCatcher(this);
+	QList<QListView *> lv = fileDialog->findChildren<QListView *>();
+	QListIterator<QListView *> lvi(lv);
+	while (lvi.hasNext())
+		lvi.next()->installEventFilter(keyCatcher);
+	connect(keyCatcher, SIGNAL(escapePressed()), this, SLOT(reject()));
+
 	connect(fileDialog, SIGNAL(filesSelected(const QStringList &)), this, SLOT(openFile()));
-#else
-	connect(fileDialog, SIGNAL(fileSelected (const QString &)), this, SLOT(openFile()));
-#endif
 }
 
 void NewDoc::openFile()
@@ -568,13 +568,9 @@
 		}
 		else if (m_tabSelected == NewDoc::OpenExistingTab) // open existing doc
 		{
-#if QT_VERSION  >= 0x040300
 			QStringList files = fileDialog->selectedFiles();
 			if (files.count() != 0)
 				m_selectedFile = QDir::fromNativeSeparators(files[0]);
-#else
-			m_selectedFile = QDir::fromNativeSeparators(fileDialog->selectedFile());
-#endif
 		}
 		else if (m_tabSelected == NewDoc::OpenRecentTab) // open recent doc
 		{

Modified: branches/Version14x/Scribus/scribus/scfilewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18153&path=/branches/Version14x/Scribus/scribus/scfilewidget.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scfilewidget.cpp (original)
+++ branches/Version14x/Scribus/scribus/scfilewidget.cpp Wed Feb 20 22:58:07 2013
@@ -5,8 +5,10 @@
 for which a new license (GPL+exception) is in place.
 */
 #include <QPushButton>
+#include <QListView>
 #include <QUrl>
 
+#include "scescapecatcher.h"
 #include "scfilewidget.h"
 
 
@@ -17,7 +19,6 @@
 	setModal(false);
 	setViewMode(QFileDialog::List);
 	setWindowFlags(Qt::Widget);
-
 
 #ifdef Q_OS_MAC
 	QList<QUrl> urls;
@@ -30,6 +31,14 @@
 	//desktop too?	QUrl computer(QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)));
 	setSidebarUrls(urls);
 #endif
+
+	ScEscapeCatcher* keyCatcher = new ScEscapeCatcher(this);
+	QList<QListView *> lv = findChildren<QListView *>();
+	QListIterator<QListView *> lvi(lv);
+	while (lvi.hasNext())
+		lvi.next()->installEventFilter(keyCatcher);
+	connect(keyCatcher, SIGNAL(escapePressed()), this, SLOT(reject()));
+
 	QList<QPushButton *> b = findChildren<QPushButton *>();
 	QListIterator<QPushButton *> i(b);
 	while (i.hasNext())

Modified: branches/Version14x/Scribus/scribus/scfilewidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18153&path=/branches/Version14x/Scribus/scribus/scfilewidget.h
==============================================================================
--- branches/Version14x/Scribus/scribus/scfilewidget.h (original)
+++ branches/Version14x/Scribus/scribus/scfilewidget.h Wed Feb 20 22:58:07 2013
@@ -26,11 +26,10 @@
 {
 	Q_OBJECT
 
-	public:
-		ScFileWidget(QWidget * parent);
+public:
+	ScFileWidget(QWidget * parent);
 
-		QString selectedFile();
-
+	QString selectedFile();
 };
 
 #endif

Modified: branches/Version14x/Scribus/win32/vc9/scribus-exe/scribus.vcproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18153&path=/branches/Version14x/Scribus/win32/vc9/scribus-exe/scribus.vcproj
==============================================================================
--- branches/Version14x/Scribus/win32/vc9/scribus-exe/scribus.vcproj (original)
+++ branches/Version14x/Scribus/win32/vc9/scribus-exe/scribus.vcproj Wed Feb 20 22:58:07 2013
@@ -1574,6 +1574,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\scescapecatcher.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\fonts\scface.cpp"
 				>
 			</File>
@@ -7387,6 +7391,38 @@
 				</FileConfiguration>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\scescapecatcher.h"
+				>
+				<FileConfiguration
+					Name="Debug-cairo|Win32"
+					>
+					<Tool
+						Name="moc"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release-cairo|Win32"
+					>
+					<Tool
+						Name="moc"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Debug-arthur|Win32"
+					>
+					<Tool
+						Name="moc"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release-arthur|Win32"
+					>
+					<Tool
+						Name="moc"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\fonts\scface.h"
 				>
 			</File>
@@ -11089,6 +11125,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\moc_scescapecatcher.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\moc_scfilewidget.cpp"
 				>
 			</File>




More information about the scribus-commit mailing list