[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kst/portto4/kst/src/libkstapp
From:       Nicolas Brisset <nicolas.brisset () eurocopter ! com>
Date:       2013-06-01 21:11:52
Message-ID: 20130601211152.A8CBEAC85D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1356751 by brisset:

Always use the absolute path to recent files in the menus, otherwise they're not reusable between \
sessions  if kst2 is not started from the same directory. This should incidentally also fix the problem \
that we could  have duplicate entries at the bottom of the File menu since only the file name was shown \
and the relative  path was tested for duplicates.
Also restore the application directory after loading.


 M  +4 -1      document.cpp  
 M  +5 -3      mainwindow.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/document.cpp #1356750:1356751
@@ -233,7 +233,8 @@
     _lastError = QObject::tr("File could not be opened for reading.");
     return false;
   }
-  // Set the application dir to the current dir to be able to load data using the "fileRelative" \
attribute +  // Temporarily set the application dir to the current dir to be able to load data using the \
"fileRelative" attribute +  QString restorePath = QDir::currentPath();
   QDir::setCurrent(file.left(file.lastIndexOf('/')) + '/');
   _fileName = file;
 
@@ -414,6 +415,8 @@
 
   UpdateManager::self()->doUpdates(true);
   setChanged(false);
+  // Restore current app path
+  QDir::setCurrent(restorePath);
 
   return _isOpen = true;
 }
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1356750:1356751
@@ -350,6 +350,8 @@
 
 void MainWindow::updateRecentFiles(const QString& key, QMenu* menu, QList<QAction*>& actions, QMenu* \
submenu, const QString& newfilename, const char* openslot)  {
+  // Always add absolute paths to the recent file lists, otherwise they are not very reusable
+  QString absoluteFilePath = newfilename.startsWith("/") ? newfilename : QDir::currentPath() + "/" + \
newfilename;  foreach(QAction* it, actions) {
     menu->removeAction(it);
     delete it;
@@ -360,9 +362,9 @@
   if (recentFiles.removeDuplicates() > 0) {
     settings.setValue(key, recentFiles);
   }
-  if (!newfilename.isEmpty()) {
-    recentFiles.removeOne(newfilename);
-    recentFiles.push_front(newfilename);
+  if (!absoluteFilePath.isEmpty()) {
+    recentFiles.removeOne(absoluteFilePath);
+    recentFiles.push_front(absoluteFilePath);
     recentFiles = recentFiles.mid(0, 30);
     settings.setValue(key, recentFiles);
   }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic