Hi Michael (and others arround),

just solved a bug which occured under Windows when opening a movie in a top 
level dirctory! 

In that case for instance 'C:' (without trailing slash!) was stored in lastdir 
and the next time when openFileNames() was called the Dialog didn't show up, 
but instead returned with an empty file list!

It took me a while to solve this, since this damn QFileDialog don't shows an 
error message in case of an improper directory... for the user it just 
happend NOTHING! 

So, we now have a little console message (just in case) and an appended '/' in 
case of a ':' as last character under windows.

I also implemented the possibility to have a fixed 'lastdir' by setting 
   /lastdir/update=false 
(which also could have been solved the bug).

BTW, /lastdir is now called /lastdir/name  ...I was to lazy to implement a 
format conversion, so your 'lastdir' gets lost the first time you start up 
with this patch... but hey, it's not such an important parameter... ;-)

May it's also a good idea to group the settings for the wheel* or jog* 
entries...?

ciao
Ralph

PS: Due to an user request we now recognize also *.trp files which come from 
ClarkeTech DVB-receivers...

diff -Naur svn/ChangeLog r113-lastdirfix/ChangeLog
--- svn/ChangeLog	2008-02-10 18:58:41.000000000 +0100
+++ r113-lastdirfix/ChangeLog	2008-02-10 20:05:47.000000000 +0100
@@ -1,3 +1,13 @@
+2008-02-10  Ralph Glasstetter  <[EMAIL PROTECTED]>  (mr)
+
+	* src/dvbcut.cpp:
+	* src/settings.cpp:
+	* src/settings.h:
+		Fixed bug with 'lastdir' & toplevel directories 
+                under Windows and implemented possibility to use 
+                a fixed 'lastdir'.
+		Added *.trp to recognized files.
+
 2008-02-04  Michael Riepe  <[EMAIL PROTECTED]>
 
 	* SConstruct:
diff -Naur svn/src/dvbcut.cpp r113-lastdirfix/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2008-02-10 19:34:19.000000000 +0100
+++ r113-lastdirfix/src/dvbcut.cpp	2008-02-10 19:52:57.000000000 +0100
@@ -1608,22 +1608,33 @@
       this,
       "Open file...",
       "Choose one or more MPEG files to open");
-    if (fn.empty())
+    if (fn.empty()) {
+      fprintf(stderr,"open(): QFileDialog::getOpenFileNames() returned EMPTY filelist!!!\n");    
+      fprintf(stderr,"        If you didn't saw a FileDialog, please check your 'lastdir' settings variable...");    
       return;
+    }  
     for (QStringList::Iterator it = fn.begin(); it != fn.end(); ++it)
       filenames.push_back((const char*)*it);
 
-    // remember directory
-    QString dir = fn.front();
-    int n = dir.findRev('/');
-    if (n > 0)
-      dir = dir.left(n);
-    else if (n == 0)
-      dir = "/";
-    settings().lastdir = dir;
-  }
+    // remember last directory if requested
+    if (settings().lastdir_update) {
+      QString dir = fn.front();
+      int n = dir.findRev('/');
+      if (n > 0)
+        dir = dir.left(n);
+      else if (n == 0)
+        dir = "/";
+#ifdef __WIN32__
+      // there has to be a / after the device name in case of a top level directory (i.e. 'C:/' and NOT 'C:')
+      if (dir.findRev(':') == int(dir.length())-1)
+        dir = dir+"/"; 
+#endif /* __WIN32__ */      
+      settings().lastdir = dir;
+    }
+  } 
 
-  if (filenames.empty())
+  // hmmmm,... do we really need this? With fn.empty() we never reach this line...
+  if (filenames.empty()) 
     return;
 
   make_canonical(filenames);
diff -Naur svn/src/settings.cpp r113-lastdirfix/src/settings.cpp
--- svn/src/settings.cpp	2008-01-16 22:34:05.000000000 +0100
+++ r113-lastdirfix/src/settings.cpp	2008-02-10 19:56:14.000000000 +0100
@@ -33,9 +33,9 @@
 #define DVBCUT_QSETTINGS_PATH "/" DVBCUT_QSETTINGS_DOMAIN "/" DVBCUT_QSETTINGS_PRODUCT "/"
 
 #define DVBCUT_DEFAULT_LOADFILTER \
-	"Recognized files (*.dvbcut *.mpg *.rec* *.ts *.tts* *.vdr);;" \
+	"Recognized files (*.dvbcut *.mpg *.rec* *.ts *.tts* *.trp *.vdr);;" \
 	"dvbcut project files (*.dvbcut);;" \
-	"MPEG files (*.mpg *.rec* *.ts *.tts* *.vdr);;" \
+	"MPEG files (*.mpg *.rec* *.ts *.tts* *.trp *.vdr);;" \
 	"All files (*)"
 #define DVBCUT_DEFAULT_IDXFILTER \
 	"dvbcut index files (*.idx);;All files (*)"
@@ -115,7 +115,10 @@
   lin_interval = readNumEntry("/lin_interval", 3600);
   if (lin_interval < 0)
     lin_interval = 0;
-  lastdir = readEntry("/lastdir", ".");
+  beginGroup("/lastdir");
+    lastdir = readEntry("/name", ".");
+    lastdir_update = readBoolEntry("/update", true);
+  endGroup(); // lastdir
   idxfilter = readEntry("/idxfilter", DVBCUT_DEFAULT_IDXFILTER);
   prjfilter = readEntry("/prjfilter", DVBCUT_DEFAULT_PRJFILTER);
   loadfilter = readEntry("/loadfilter", DVBCUT_DEFAULT_LOADFILTER);
@@ -229,7 +232,10 @@
   writeEntry("/jog_offset", jog_offset);
   writeEntry("/jog_interval", jog_interval);
   writeEntry("/lin_interval", lin_interval);
-  writeEntry("/lastdir", lastdir);
+  beginGroup("/lastdir");
+    writeEntry("/name", lastdir);
+    writeEntry("/update", lastdir_update);
+  endGroup();	// lastdir
   writeEntry("/idxfilter", idxfilter);
   writeEntry("/prjfilter", prjfilter);
   writeEntry("/loadfilter", loadfilter);
diff -Naur svn/src/settings.h r113-lastdirfix/src/settings.h
--- svn/src/settings.h	2008-01-16 22:34:05.000000000 +0100
+++ r113-lastdirfix/src/settings.h	2008-02-10 19:07:14.000000000 +0100
@@ -45,6 +45,7 @@
   bool loaded;
 
   QString lastdir;
+  bool lastdir_update;
   QString idxfilter;
   QString prjfilter;
   QString loadfilter;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to