]> git.lyx.org Git - lyx.git/commitdiff
qt filedialog fix
authorJohn Levon <levon@movementarian.org>
Sun, 17 Nov 2002 08:32:09 +0000 (08:32 +0000)
committerJohn Levon <levon@movementarian.org>
Sun, 17 Nov 2002 08:32:09 +0000 (08:32 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5652 a592a061-630c-0410-9148-cb99ea01b6c8

21 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/frontends/ChangeLog
src/frontends/FileDialog.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlExternal.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/ControlPrefs.C
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/helper_funcs.C
src/frontends/controllers/helper_funcs.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/FileDialog.C
src/frontends/qt2/QPrefsDialog.C
src/frontends/qt2/ui/QPrefColorsModule.ui
src/frontends/xforms/ChangeLog
src/frontends/xforms/FileDialog.C
src/lyx_cb.C
src/lyxfunc.C

index a191d219d9d23c57737d4c10d78f9c0a24ab7080..bf2e53f2c70f013e2ec2e3c6479e1c7b1a7c83a5 100644 (file)
@@ -857,7 +857,7 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen)
                                  string(AddPath(system_lyxdir, "examples"))));
 
                FileDialog::Result result =
-                       fileDlg.Select(initpath,
+                       fileDlg.open(initpath,
                                       _("*.lyx| LyX Documents (*.lyx)"));
 
                if (result.first == FileDialog::Later)
index 460fea54ca53753bef6d36069a261ccecca8650f..af15a4c52ba29414d21349916b3166113a5e98da 100644 (file)
@@ -1,3 +1,9 @@
+2002-11-17  John Levon  <levon@movementarian.org>
+
+       * BufferView_pimpl.C:
+       * lyx_cb.C:
+       * lyxfunc.C: split filedialog into open/save
 2002-11-08  Juergen Vigna  <jug@sad.it>
 
        * undo_funcs.C (textHandleUndo): fixed problems with undo introduced
index ae4c266f2d92bc35f70a632443811938596ab374..6029d4177295168d379e5f43d7418e37720d6d57 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-17  John Levon  <levon@movementarian.org>
+
+       * FileDialog.h: split Select() into open()/save() for
+         benefit of Qt
 2002-11-01  Herbert Voss  <voss@perce.de>
  
        * ControlGraphics.C: "Default" is now a part of the rotate-list
index 40f154f0558b3c9bc54fe53882bb847cf32066f3..633eba4401042f1196c683a0253b35ff6411eeb0 100644 (file)
@@ -47,7 +47,7 @@ public:
        /**
         * Constructs a file dialog attached to LyXView \param lv, with
         * title \param title. If \param a is \const LFUN_SELECT_FILE_SYNC
-        * then a value will be returned immediately upon performing a Select(),
+        * then a value will be returned immediately upon performing a open(),
         * otherwise a callback Dispatch() will be invoked with the filename as
         * argument, of action \param a.
         *
@@ -64,7 +64,7 @@ public:
        ~FileDialog();
 
        /**
-        * Choose a file for selection, starting in directory \param
+        * Choose a file for opening, starting in directory \param
         * path, with the file selection \param mask. The \param mask
         * string is of the form :
         *
@@ -74,7 +74,20 @@ public:
         *
         * FIXME: should support multiple lines of these for different file types.
         */
-       Result const Select(string const & path = string(),
+       Result const open(string const & path = string(),
+               string const & mask = string(),
+               string const & suggested = string());
+
+       /**
+        * Choose a file for saving, starting in directory \param
+        * path, with the file selection \param mask. The \param mask
+        * string is of the form :
+        *
+        * <glob to match> | <description>
+        *
+        * for example, "*.ps | PostScript files (*.ps)".
+        */
+       Result const save(string const & path = string(),
                string const & mask = string(),
                string const & suggested = string());
 
index 508fadbc944dd59b6a1ab483e5fa80de7dc75d9b..1fcb51d51ce27f6d16ddae0ee8096b8c19257ac9 100644 (file)
@@ -1,3 +1,7 @@
+2002-11-17  John Levon  <levon@movementarian.org>
+
+       * helper_funcs.C and users: specify save/open in file dialog
 2002-11-15  John Levon  <levon@movementarian.org>
 
        * ControlPrefs.h:
index a6833fca2948bf0d9920ef839db62cb1d7fa9c06..96e4507cb80ff6cfa4cc70c32973afaa7f1d36a0 100644 (file)
@@ -63,7 +63,7 @@ string const ControlBibtex::Browse(string const & in_name,
        pair<string, string> dir1(_("Documents|#o#O"),
                                  string(lyxrc.document_path));
        return browseRelFile(&lv_, in_name, buffer()->filePath(),
-                            title, pattern, dir1);
+                            title, pattern, false, dir1);
 }
 
 
index 3c613af0232a455a4b9889b38dc7a4f1d61c2962..e66829189fedf27f4e30ca06ad9ddf4cb841a85f 100644 (file)
@@ -154,5 +154,5 @@ string const ControlExternal::Browse(string const & input) const
        std::pair<string, string> dir1(N_("Documents|#o#O"),
                                  string(lyxrc.document_path));
 
-       return browseRelFile(&lv_, input, bufpath, title, pattern, dir1);
+       return browseRelFile(&lv_, input, bufpath, title, pattern, false, dir1);
 }
index a6f9713c03916e28e31770b7f2603735aef5aaaf..9faad1ccbaf298bbbec3bf0d02bf4d25bd21fc10 100644 (file)
@@ -93,7 +93,7 @@ string const ControlGraphics::Browse(string const & in_name)
        pair<string, string> dir2(_("Documents|#o#O"), string(lyxrc.document_path));
        // Show the file browser dialog
        return browseRelFile(&lv_, in_name, buffer()->filePath(),
-                            title, "*.*", dir1, dir2);
+                            title, "*.*", false, dir1, dir2);
 }
 
 
index d1c8c123f20a9b58bb87aa697f7544c9230641ad..078b91d23b81c21a555e0d2521b60c4738db8bbe 100644 (file)
@@ -72,7 +72,7 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
 
        string const docpath = OnlyPath(params().masterFilename_);
 
-       return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
+       return browseRelFile(&lv_, in_name, docpath, title, pattern, false, dir1);
 }
 
 
index b36d2ee2fc84187d5463c4b924be21d0bd7aecf1..00ea4f672e1972e62d766c404dbd385f60f0c439 100644 (file)
@@ -70,7 +70,7 @@ string const ControlPrefs::browsebind(string const & file)
        name = _("User Bind|#U#u");
        pair<string,string> dir2(name, dir);
  
-       return browseFile(&lv_, file, _("Choose bind file"), "*.bind", dir1, dir2);
+       return browseFile(&lv_, file, _("Choose bind file"), "*.bind", false, dir1, dir2);
 }
 
 
@@ -86,7 +86,7 @@ string const ControlPrefs::browseUI(string const & file)
        name = _("User UI|#U#u");
        pair<string,string> dir2(name, dir);
  
-       return browseFile(&lv_, file, _("Choose UI file"), "*.ui", dir1, dir2);
+       return browseFile(&lv_, file, _("Choose UI file"), "*.ui", false, dir1, dir2);
 }
 
  
@@ -96,7 +96,7 @@ string const ControlPrefs::browsekbmap(string const & file)
        string const name = _("Key maps|#K#k");
        pair<string, string> dir1(name, dir);
  
-       return browseFile(&lv_, file, _("Choose keyboard map"), "*.kmap", dir1);
+       return browseFile(&lv_, file, _("Choose keyboard map"), "*.kmap", false, dir1);
 }
 
  
@@ -108,7 +108,7 @@ string const ControlPrefs::browsedict(string const & file)
  
 string const ControlPrefs::browse(string const & file, string const & title)
 {
-       return browseFile(&lv_, file, title, "*");
+       return browseFile(&lv_, file, title, "*", true);
 }
 
 
index 53f303e0906ee1a996f661c2f89c7f1ff9094560..2b151bc4f3305b59f3d5d4075fa1abcdf4831dae 100644 (file)
@@ -80,7 +80,7 @@ string const ControlPrint::Browse(string const & in_name)
 
        // Show the file browser dialog
        return browseRelFile(&lv_, in_name, buffer()->filePath(),
-                            title, pattern);
+                            title, pattern, true);
 }
 
 
index f189856d6db2dfaaa19ceada4a03aab59aa3b20a..780200049004f8d54e160f8b16046d285ba0dfe4 100644 (file)
@@ -32,6 +32,7 @@ using std::make_pair;
 string const browseFile(LyXView * lv, string const & filename,
                        string const & title,
                        string const & pattern,
+                       bool save,
                        pair<string,string> const & dir1,
                        pair<string,string> const & dir2)
 {
@@ -44,8 +45,12 @@ string const browseFile(LyXView * lv, string const & filename,
        FileDialog::Result result;
 
        while (true) {
-               result = fileDlg.Select(lastPath, pattern,
-                                       OnlyFilename(filename));
+               if (save) 
+                       result = fileDlg.save(lastPath, pattern,
+                               OnlyFilename(filename));
+               else
+                       result = fileDlg.open(lastPath, pattern,
+                               OnlyFilename(filename));
 
                if (result.second.empty())
                        return result.second;
@@ -68,12 +73,13 @@ string const browseRelFile(LyXView * lv, string const & filename,
                        string const & refpath,
                        string const & title,
                        string const & pattern,
+                       bool save = false,
                        pair<string,string> const & dir1,
                        pair<string,string> const & dir2)
 {
        string const fname = MakeAbsPath(filename, refpath);
 
-       string const outname = browseFile(lv, fname, title, pattern,
+       string const outname = browseFile(lv, fname, title, pattern, save,
                                          dir1, dir2);
        string const reloutname = MakeRelPath(outname, refpath);
        if (prefixIs(reloutname, "../"))
index 440ebca3fed5d3e513f0270a590382f7516e6d2c..fa1e689e052ee22d4e00cbc1ea1ba32e46ad5ae1 100644 (file)
@@ -30,9 +30,10 @@ class LyXView;
     dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
 */
 string const
-browseFile(LyXView *lv, string const & filename,
+browseFile(LyXView * lv, string const & filename,
           string const & title,
           string const & pattern,
+          bool save = false,
           std::pair<string,string> const & dir1 =
           std::make_pair(string(), string()),
           std::pair<string,string> const & dir2 =
@@ -46,10 +47,11 @@ browseFile(LyXView *lv, string const & filename,
    intended to be useful for insets which encapsulate files/
 */
 string const
-browseRelFile(LyXView *lv, string const & filename,
+browseRelFile(LyXView * lv, string const & filename,
              string const & refpath,
              string const & title,
              string const & pattern,
+             bool save = false,
              std::pair<string,string> const & dir1 =
              std::make_pair(string(), string()),
              std::pair<string,string> const & dir2 =
index e005efade687327ddd11854f39b70811b0940ab4..045a88bb64348608af739a82ce66beed643caab4 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-17  John Levon  <levon@movementarian.org>
+
+       * FileDialog.C:  split into open/save so open
+         no longer says "Save" !
 2002-11-17  John Levon  <levon@movementarian.org>
 
        * QPrefsDialog.h:
index 48c726bc237134f6bcb655d1458221db76dfc15a..e3fbc5ffdb2076c63aafc9c7515bd91a7348534f 100644 (file)
@@ -51,7 +51,7 @@ FileDialog::~FileDialog()
 }
 
 
-FileDialog::Result const FileDialog::Select(string const & path,
+FileDialog::Result const FileDialog::save(string const & path,
                                            string const & mask,
                                            string const & suggested)
 {
@@ -69,9 +69,33 @@ FileDialog::Result const FileDialog::Select(string const & path,
        if (!suggested.empty())
                dlg.setSelection(suggested.c_str());
 
-       // This code relies on DestructiveClose which is broken
-       // in Qt < 3.0.5. So we just don't allow it for now.
-       //if (success_ == LFUN_SELECT_FILE_SYNC) {
+       FileDialog::Result result;
+       lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
+       result.first = FileDialog::Chosen;
+       int res = dlg.exec();
+       lyxerr[Debug::GUI] << "result " << res << endl;
+       if (res == QDialog::Accepted)
+               result.second = string(dlg.selectedFile().data());
+       dlg.hide();
+       return result;
+}
+
+FileDialog::Result const FileDialog::open(string const & path,
+                                           string const & mask,
+                                           string const & suggested)
+{
+       string filter(mask);
+       if (mask.empty())
+               filter = _("*|All files");
+
+       LyXFileDialog dlg(path, filter, title_, private_->b1, private_->b2);
+       lyxerr[Debug::GUI] << "Select with path \"" << path
+                          << "\", mask \"" << filter
+                          << "\", suggested \"" << suggested << endl;
+
+       if (!suggested.empty())
+               dlg.setSelection(suggested.c_str());
 
        FileDialog::Result result;
        lyxerr[Debug::GUI] << "Synchronous FileDialog : " << endl;
@@ -82,8 +106,4 @@ FileDialog::Result const FileDialog::Select(string const & path,
                result.second = string(dlg.selectedFile().data());
        dlg.hide();
        return result;
-#if 0
-       dlg->show();
-       return make_pair(FileDialog::Later, string());
-#endif
 }
index f7f3db00adf38f1985d4a518c413eaf110a18061..95f48034468fd5107fb7f8a93fba7023fc1f7fd2 100644 (file)
@@ -312,7 +312,7 @@ void QPrefsDialog::switch_converter(int nr)
 }
 
  
-// FIXME: we would like to highlight the new entry ... also user must
+// FIXME: user must
 // specify unique from/to or it doesn't appear. This is really bad UI
 void QPrefsDialog::new_converter()
 { 
@@ -325,6 +325,7 @@ void QPrefsDialog::new_converter()
                form_->converters_.updateLast(form_->formats_);
        }
        updateConverters();
+       convertersModule->convertersLB->setCurrentItem(convertersModule->convertersLB->count() - 1); 
 }
 
 
index 8e33e0747119b81939dbfb438222cb61ef556f4b..5914f49d44839b7dc53b819a0df1970f8ed0cdf3 100644 (file)
@@ -13,7 +13,7 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>305</width>
+            <width>301</width>
             <height>259</height>
         </rect>
     </property>
@@ -21,7 +21,7 @@
         <name>caption</name>
         <string>Colors</string>
     </property>
-    <grid>
+    <hbox>
         <property stdset="1">
             <name>margin</name>
             <number>11</number>
             <name>spacing</name>
             <number>6</number>
         </property>
-        <widget row="1"  column="0"  rowspan="2"  colspan="1" >
-            <class>QListBox</class>
-            <item>
-                <property>
-                    <name>text</name>
-                    <string>New Item</string>
-                </property>
-            </item>
-            <property stdset="1">
-                <name>name</name>
-                <cstring>lyxObjectsLB</cstring>
-            </property>
-        </widget>
-        <widget row="0"  column="0" >
-            <class>QLabel</class>
+        <widget>
+            <class>QLayoutWidget</class>
             <property stdset="1">
                 <name>name</name>
-                <cstring>lyxObjectsLA</cstring>
-            </property>
-            <property stdset="1">
-                <name>text</name>
-                <string>LyX &amp;Objects:</string>
-            </property>
-            <property>
-                <name>buddy</name>
-                <cstring>lyxObjectsLB</cstring>
-            </property>
-        </widget>
-        <widget row="1"  column="1" >
-            <class>QPushButton</class>
-            <property stdset="1">
-                <name>name</name>
-                <cstring>colorChangePB</cstring>
-            </property>
-            <property stdset="1">
-                <name>text</name>
-                <string>Chan&amp;ge Color...</string>
+                <cstring>Layout2</cstring>
             </property>
+            <vbox>
+                <property stdset="1">
+                    <name>margin</name>
+                    <number>0</number>
+                </property>
+                <property stdset="1">
+                    <name>spacing</name>
+                    <number>6</number>
+                </property>
+                <widget>
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>lyxObjectsLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>&amp;Colors</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>lyxObjectsLB</cstring>
+                    </property>
+                </widget>
+                <widget>
+                    <class>QListBox</class>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>New Item</string>
+                        </property>
+                    </item>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>lyxObjectsLB</cstring>
+                    </property>
+                </widget>
+                <widget>
+                    <class>QLayoutWidget</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>Layout1</cstring>
+                    </property>
+                    <hbox>
+                        <property stdset="1">
+                            <name>margin</name>
+                            <number>0</number>
+                        </property>
+                        <property stdset="1">
+                            <name>spacing</name>
+                            <number>6</number>
+                        </property>
+                        <widget>
+                            <class>QPushButton</class>
+                            <property stdset="1">
+                                <name>name</name>
+                                <cstring>colorChangePB</cstring>
+                            </property>
+                            <property stdset="1">
+                                <name>text</name>
+                                <string>&amp;Alter ...</string>
+                            </property>
+                        </widget>
+                        <spacer>
+                            <property>
+                                <name>name</name>
+                                <cstring>Spacer3</cstring>
+                            </property>
+                            <property stdset="1">
+                                <name>orientation</name>
+                                <enum>Horizontal</enum>
+                            </property>
+                            <property stdset="1">
+                                <name>sizeType</name>
+                                <enum>Expanding</enum>
+                            </property>
+                            <property>
+                                <name>sizeHint</name>
+                                <size>
+                                    <width>20</width>
+                                    <height>20</height>
+                                </size>
+                            </property>
+                        </spacer>
+                    </hbox>
+                </widget>
+            </vbox>
         </widget>
-        <spacer row="2"  column="1" >
+        <spacer>
             <property>
                 <name>name</name>
-                <cstring>Spacer6</cstring>
+                <cstring>Spacer2</cstring>
             </property>
             <property stdset="1">
                 <name>orientation</name>
-                <enum>Vertical</enum>
+                <enum>Horizontal</enum>
             </property>
             <property stdset="1">
                 <name>sizeType</name>
                 </size>
             </property>
         </spacer>
-    </grid>
+    </hbox>
 </widget>
 </UI>
index 4fb76ab589a617cb68533d6cd9a2abcbaa1cbafb..683b0c7aa5d8093600b8c16c4932a6394a144823 100644 (file)
@@ -1,3 +1,7 @@
+2002-11-17  John Levon  <levon@movementarian.org>
+
+       * FileDialog.C: open/save name change
 2002-11-15  John Levon  <levon@movementarian.org>
 
        * Dialogs2.C:
index b7021cd25d84901b9236a4c92e77cf1ed01e5727..3dad83636904dcccd2a6ef60cd6cfce6d79458de 100644 (file)
@@ -48,7 +48,13 @@ FileDialog::~FileDialog()
 }
 
 
-FileDialog::Result const FileDialog::Select(string const & path, string const & mask, string const & suggested)
+FileDialog::Result const FileDialog::save(string const & path, string const & mask, string const & suggested)
+{
+       open(path, mask, suggested);
+}
+
+FileDialog::Result const FileDialog::open(string const & path, string const & mask, string const & suggested)
 {
        string filter = mask;
 
@@ -60,7 +66,8 @@ FileDialog::Result const FileDialog::Select(string const & path, string const &
                        filter = mask;
        }
 
-       lyxerr[Debug::GUI] << "Select with path \"" << path << "\", mask \"" << filter << "\", suggested \"" << suggested << "\"" << endl;
+       lyxerr[Debug::GUI] << "filedialog open  with path \"" << path << "\", mask \""
+               << filter << "\", suggested \"" << suggested << "\"" << endl;
 
        // no support for asynchronous selection yet
 
index 040f63f29d8dc741e7d4cb7771d71c0b6a890853..3e41b36bfff59ed31c1f449a069fef4b04b0e495 100644 (file)
@@ -115,7 +115,7 @@ bool WriteAs(BufferView * bv, Buffer * buffer, string const & filename)
                        fname += ".lyx";
 
                FileDialog::Result result =
-                       fileDlg.Select(OnlyPath(fname),
+                       fileDlg.save(OnlyPath(fname),
                                       _("*.lyx|LyX Documents (*.lyx)"),
                                       OnlyFilename(fname));
 
@@ -419,7 +419,7 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
                FileDialog fileDlg(bv->owner(), _("Select file to insert"),
                        (asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
 
-               FileDialog::Result result = fileDlg.Select(bv->owner()->buffer()->filePath());
+               FileDialog::Result result = fileDlg.open(bv->owner()->buffer()->filePath());
 
                if (result.first == FileDialog::Later)
                        return string();
index f4208f820c55898c386639c48a3dbd1353b26014..79fd0e8efdb87447aad0372c99e30d8d06ed4514 100644 (file)
@@ -1594,7 +1594,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
                                  string(lyxrc.template_path)));
 
                FileDialog::Result result =
-                       fileDlg.Select(lyxrc.template_path,
+                       fileDlg.open(lyxrc.template_path,
                                       _("*.lyx|LyX Documents (*.lyx)"));
 
                if (result.first == FileDialog::Later)
@@ -1633,7 +1633,7 @@ void LyXFunc::open(string const & fname)
                                  string(AddPath(system_lyxdir, "examples"))));
 
                FileDialog::Result result =
-                       fileDlg.Select(initpath,
+                       fileDlg.open(initpath,
                                       "*.lyx|LyX Documents (*.lyx)");
 
                if (result.first == FileDialog::Later)
@@ -1722,7 +1722,7 @@ void LyXFunc::doImport(string const & argument)
                        + "| " + formats.prettyName(format)
                        + " (*." + formats.extension(format) + ")";
 
-               FileDialog::Result result = fileDlg.Select(initpath,
+               FileDialog::Result result = fileDlg.open(initpath,
                                                           extension);
 
                if (result.first == FileDialog::Later)