]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/FileDialog.cpp
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / FileDialog.cpp
index 92ed6d349a83a2834c0bb8f322c1f7529b797b84..50d98c59eb5407fb848229f33e3ba53d9d8be984 100644 (file)
 
 #include <config.h>
 
-#include "frontends/FileDialog.h"
+#include "FileDialog.h"
 
 #include "LyXFileDialog.h"
 #include "qt_helpers.h"
 
-#include "debug.h"
-#include "gettext.h"
-
+#include "support/debug.h"
 #include "support/FileFilterList.h"
+#include "support/FileName.h"
+#include "support/gettext.h"
 #include "support/os.h"
 
 /** when this is defined, the code will use
  * - the dialog does not use the quick directory buttons (Button
  *   parameters);
  * - with Qt/Mac or Qt/Win, the dialogs native to the environment are used.
+ * - with Qt/Win and Qt <= 4.3.0, there was a number of bugs with our own
+ *   file dialog (http://bugzilla.lyx.org/show_bug.cgi?id=3907).
  *
  * Therefore there is a tradeoff in enabling or disabling this (JMarc)
  */
-#ifdef Q_WS_MACX
+#if defined(Q_WS_MACX) || (defined(Q_WS_WIN) && !defined(Q_CYGWIN_WIN))
 #define USE_NATIVE_FILEDIALOG 1
 #endif
 
 #ifdef USE_NATIVE_FILEDIALOG
-#include <qapplication.h>
+#include <QApplication>
 #include "support/filetools.h"
 
 using lyx::support::makeAbsPath;
@@ -46,7 +48,6 @@ namespace lyx {
 
 using support::FileFilterList;
 using support::os::internal_path;
-using std::endl;
 
 
 class FileDialog::Private {
@@ -56,13 +57,9 @@ public:
 };
 
 
-FileDialog::FileDialog(docstring const & t,
-                      kb_action s, Button b1, Button b2)
+FileDialog::FileDialog(docstring const & t, kb_action s)
        : private_(new FileDialog::Private), title_(t), success_(s)
-{
-       private_->b1 = b1;
-       private_->b2 = b2;
-}
+{}
 
 
 FileDialog::~FileDialog()
@@ -71,13 +68,27 @@ FileDialog::~FileDialog()
 }
 
 
+void FileDialog::setButton1(docstring const & label, docstring const & dir)
+{
+       private_->b1.first = label;
+       private_->b1.second = dir;
+}
+
+
+void FileDialog::setButton2(docstring const & label, docstring const & dir)
+{
+       private_->b2.first = label;
+       private_->b2.second = dir;
+}
+
+
 FileDialog::Result const FileDialog::save(docstring const & path,
                                          FileFilterList const & filters,
                                          docstring const & suggested)
 {
-       LYXERR(Debug::GUI) << "Select with path \"" << to_utf8(path)
+       LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
                           << "\", mask \"" << to_utf8(filters.as_string())
-                          << "\", suggested \"" << to_utf8(suggested) << '"' << endl;
+                          << "\", suggested \"" << to_utf8(suggested) << '"');
        FileDialog::Result result;
        result.first = FileDialog::Chosen;
 
@@ -103,9 +114,9 @@ FileDialog::Result const FileDialog::save(docstring const & path,
        if (!suggested.empty())
                dlg.selectFile(toqstr(suggested));
 
-       LYXERR(Debug::GUI) << "Synchronous FileDialog: " << endl;
+       LYXERR(Debug::GUI, "Synchronous FileDialog: ");
        int res = dlg.exec();
-       LYXERR(Debug::GUI) << "result " << res << endl;
+       LYXERR(Debug::GUI, "result " << res);
        if (res == QDialog::Accepted)
                result.second = from_utf8(internal_path(
                                        fromqstr(dlg.selectedFiles()[0])));
@@ -119,9 +130,9 @@ FileDialog::Result const FileDialog::open(docstring const & path,
                                          FileFilterList const & filters,
                                          docstring const & suggested)
 {
-       LYXERR(Debug::GUI) << "Select with path \"" << to_utf8(path)
+       LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
                           << "\", mask \"" << to_utf8(filters.as_string())
-                          << "\", suggested \"" << to_utf8(suggested) << '"' << endl;
+                          << "\", suggested \"" << to_utf8(suggested) << '"');
        FileDialog::Result result;
        result.first = FileDialog::Chosen;
 
@@ -137,9 +148,9 @@ FileDialog::Result const FileDialog::open(docstring const & path,
        if (!suggested.empty())
                dlg.selectFile(toqstr(suggested));
 
-       LYXERR(Debug::GUI) << "Synchronous FileDialog: " << endl;
+       LYXERR(Debug::GUI, "Synchronous FileDialog: ");
        int res = dlg.exec();
-       LYXERR(Debug::GUI) << "result " << res << endl;
+       LYXERR(Debug::GUI, "result " << res);
        if (res == QDialog::Accepted)
                result.second = from_utf8(internal_path(
                                        fromqstr(dlg.selectedFiles()[0])));
@@ -152,8 +163,8 @@ FileDialog::Result const FileDialog::open(docstring const & path,
 FileDialog::Result const FileDialog::opendir(docstring const & path,
                                            docstring const & suggested)
 {
-       LYXERR(Debug::GUI) << "Select with path \"" << to_utf8(path)
-                          << "\", suggested \"" << to_utf8(suggested) << '"' << endl;
+       LYXERR(Debug::GUI, "Select with path \"" << to_utf8(path)
+                          << "\", suggested \"" << to_utf8(suggested) << '"');
        FileDialog::Result result;
        result.first = FileDialog::Chosen;
 
@@ -173,9 +184,9 @@ FileDialog::Result const FileDialog::opendir(docstring const & path,
        if (!suggested.empty())
                dlg.selectFile(toqstr(suggested));
 
-       LYXERR(Debug::GUI) << "Synchronous FileDialog: " << endl;
+       LYXERR(Debug::GUI, "Synchronous FileDialog: ");
        int res = dlg.exec();
-       LYXERR(Debug::GUI) << "result " << res << endl;
+       LYXERR(Debug::GUI, "result " << res);
        if (res == QDialog::Accepted)
                result.second = from_utf8(internal_path(
                                        fromqstr(dlg.selectedFiles()[0])));