[Patch] Open File Dialog File Location Text Misaligned

Long Wu wulong at comp.nus.edu.sg
Tue Mar 18 08:33:06 PDT 2014


Hi Lubomir,

I have an alternative way of fixing this problem, it is set the option with
QFileDialog::DontUseNativeDialog,

The dialog looks closer to the original dialog. And without modify much
code.

[image: Inline image 2]

Best regards,

Wu Long


On Tue, Mar 18, 2014 at 1:45 AM, Tomaz Canabrava <tcanabrava at kde.org> wrote:

>
> it seems that the need to modify the dialog should occour only on mac, so
> a #ifdef seems necessary ( or a fix on qt itself )
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140318/1e1e7129/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 98690 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140318/1e1e7129/attachment-0001.png>
-------------- next part --------------
From a4c634d038ccb57282e918146aa9e629563207d7 Mon Sep 17 00:00:00 2001
From: Hugle <wulong at comp.nus.edu.sg>
Date: Tue, 18 Mar 2014 23:13:50 +0800
Subject: [PATCH] Set QFileDialog To Option DontUseNativeDialog

As the default QFileDialog's directory path text misaligned in Qt4.8.
By setting the QFileDialog with option QFileDialog::DontuseNativeDialog fix this problem.

The alternative way of fixing this is by creating a QFileDialog object,
but that need to add more lines of codes.

Signed-off-by: Hugle <wulong at comp.nus.edu.sg>
---
 qt-ui/mainwindow.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 02c424f..9ca026c 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -150,7 +150,7 @@ void MainWindow::on_actionOpen_triggered()
 		QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before opening a new file."));
 		return;
 	}
-	QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), lastUsedDir(), filter());
+    QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), lastUsedDir(), filter(), 0, QFileDialog::DontUseNativeDialog);
 	if (filename.isEmpty())
 		return;
 	updateLastUsedDir(QFileInfo(filename).dir().path());
@@ -256,7 +256,7 @@ void MainWindow::on_actionExportUDDF_triggered()
 {
 	QFileInfo fi(system_default_filename());
 	QString filename = QFileDialog::getSaveFileName(this, tr("Save File as"), fi.absolutePath(),
-							tr("UDDF files (*.uddf *.UDDF)"));
+                            tr("UDDF files (*.uddf *.UDDF)"), 0, QFileDialog::DontUseNativeDialog);
 	if (!filename.isNull() && !filename.isEmpty())
 		export_dives_uddf(filename.toUtf8(), false);
 }
@@ -894,7 +894,7 @@ int MainWindow::file_save_as(void)
 	else
 		default_filename = prefs.default_filename;
 	filename = QFileDialog::getSaveFileName(this, tr("Save File as"), default_filename,
-						tr("Subsurface XML files (*.ssrf *.xml *.XML)"));
+                        tr("Subsurface XML files (*.ssrf *.xml *.XML)"), 0, QFileDialog::DontUseNativeDialog);
 	if (filename.isNull() || filename.isEmpty())
 		return report_error("No filename to save into");
 
@@ -1015,7 +1015,7 @@ void MainWindow::loadFiles(const QStringList fileNames)
 
 void MainWindow::on_actionImportDiveLog_triggered()
 {
-	QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Dive Log File"), lastUsedDir(), tr("Dive Log Files (*.xml *.uddf *.udcf *.csv *.jlb *.dld *.sde *.db);;XML Files (*.xml);;UDDF/UDCF Files(*.uddf *.udcf);;JDiveLog Files(*.jlb);;Suunto Files(*.sde *.db);;CSV Files(*.csv);;All Files(*)"));
+    QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Dive Log File"), lastUsedDir(), tr("Dive Log Files (*.xml *.uddf *.udcf *.csv *.jlb *.dld *.sde *.db);;XML Files (*.xml);;UDDF/UDCF Files(*.uddf *.udcf);;JDiveLog Files(*.jlb);;Suunto Files(*.sde *.db);;CSV Files(*.csv);;All Files(*)"), 0, QFileDialog::DontUseNativeDialog);
 
 	if (fileNames.isEmpty())
 		return;
-- 
1.7.11.1



More information about the subsurface mailing list