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

scribus-commit scribus-commit at lists.scribus.net
Wed Feb 20 23:01:18 UTC 2013


Author: jghali
Date: Wed Feb 20 23:01:18 2013
New Revision: 18154

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

Added:
    trunk/Scribus/scribus/ui/scescapecatcher.cpp
    trunk/Scribus/scribus/ui/scescapecatcher.h
Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/ui/newfile.cpp
    trunk/Scribus/scribus/ui/scfilewidget.cpp
    trunk/Scribus/scribus/ui/scfilewidget.h
    trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18154&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Wed Feb 20 23:01:18 2013
@@ -421,13 +421,14 @@
   ui/replaceonecolor.h
   ui/rulermover.h
   ui/scdockpalette.h
+  ui/scescapecatcher.h
   ui/scfilewidget.h
   ui/scinputdialog.h
   ui/sclistwidgetdelegate.h
   ui/scmenu.h
   ui/scmessagebox.h
+  ui/scmwmenumanager.h
   ui/scrapbookpalette.h
-  ui/scmwmenumanager.h
   ui/scrpalettebase.h
   ui/scrspinbox.h
   ui/sctablewidget.h
@@ -867,14 +868,15 @@
   ui/rulermover.cpp
   ui/sccombobox.cpp
   ui/scdockpalette.cpp
+  ui/scescapecatcher.cpp
   ui/scfilewidget.cpp
   ui/scinputdialog.cpp
   ui/sclistwidgetdelegate.cpp
   ui/scmenu.cpp
   ui/scmessagebox.cpp
+  ui/scmwmenumanager.cpp
   ui/scrapbookpalette.cpp
   ui/scresizecursor.cpp
-  ui/scmwmenumanager.cpp
   ui/scrpalettebase.cpp
   ui/scrspinbox.cpp
   ui/sctablewidget.cpp

Modified: trunk/Scribus/scribus/ui/newfile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18154&path=/trunk/Scribus/scribus/ui/newfile.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/newfile.cpp (original)
+++ trunk/Scribus/scribus/ui/newfile.cpp Wed Feb 20 23:01:18 2013
@@ -10,38 +10,37 @@
 #include <QGridLayout>
 #include <QHBoxLayout>
 #include <QVBoxLayout>
-#include <QSpacerItem>
-#include <QListWidgetItem>
+
+#include <QDir>
+#include <QCheckBox>
+#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 "ui/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 "scrspinbox.h"
-#include "sccombobox.h"
+#include "units.h"
 #include "util_icon.h"
 
 PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : QListWidget(parent)
@@ -363,20 +362,14 @@
 	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->setOption(QFileDialog::DontUseNativeDialog);
-#if QT_VERSION >= 0x040600
 	fileDialog->setNameFilterDetailsVisible(false);
-#else
-	fileDialog->setOption(QFileDialog::HideNameFilterDetails);
-#endif
 	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 *>();
@@ -385,11 +378,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()
@@ -577,13 +574,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: trunk/Scribus/scribus/ui/scfilewidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18154&path=/trunk/Scribus/scribus/ui/scfilewidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scfilewidget.cpp (original)
+++ trunk/Scribus/scribus/ui/scfilewidget.cpp Wed Feb 20 23:01:18 2013
@@ -6,9 +6,11 @@
 */
 
 #include <QDesktopServices>
+#include <QListView>
 #include <QPushButton>
 #include <QUrl>
 
+#include "scescapecatcher.h"
 #include "scfilewidget.h"
 
 
@@ -30,6 +32,13 @@
 	//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);

Modified: trunk/Scribus/scribus/ui/scfilewidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18154&path=/trunk/Scribus/scribus/ui/scfilewidget.h
==============================================================================
--- trunk/Scribus/scribus/ui/scfilewidget.h (original)
+++ trunk/Scribus/scribus/ui/scfilewidget.h Wed Feb 20 23:01:18 2013
@@ -26,13 +26,13 @@
 {
 	Q_OBJECT
 
-	public:
-		ScFileWidget(QWidget * parent);
+public:
+	ScFileWidget(QWidget * parent);
 
-		QString selectedFile();
-	public slots:
-		void accept();
+	QString selectedFile();
 
+public slots:
+	void accept();
 };
 
 #endif

Modified: trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18154&path=/trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj
==============================================================================
--- trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj (original)
+++ trunk/Scribus/win32/vc9/scribus-main/Scribus.vcproj Wed Feb 20 23:01:18 2013
@@ -1635,6 +1635,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\ui\scescapecatcher.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\fonts\scface.cpp"
 				>
 			</File>
@@ -6864,6 +6868,24 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\ui\scescapecatcher.h"
+				>
+				<FileConfiguration
+					Name="Debug-cairo|Win32"
+					>
+					<Tool
+						Name="moc"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release-cairo|Win32"
+					>
+					<Tool
+						Name="moc"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\fonts\scface.h"
 				>
 			</File>
@@ -10116,6 +10138,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\..\..\scribus\ui\moc_scescapecatcher.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\..\..\scribus\ui\moc_scfilewidget.cpp"
 				>
 			</File>




More information about the scribus-commit mailing list