=================================================================== RCS file: /cvsroot/ParaView3/ParaView3/Qt/Components/pqAnimationManager.h,v retrieving revision 1.15 diff -u -r1.15 pqAnimationManager.h --- pqAnimationManager.h 4 Apr 2008 13:30:37 -0000 1.15 +++ pqAnimationManager.h 5 Nov 2008 22:21:41 -0000 @@ -85,6 +85,12 @@ // Saves the animation geometry from the active scene // as visible in the given view. bool saveGeometry(const QString& filename, pqView* view); + + /// Save the settings of "save animation" with QSettings. + void saveSettings(); + + /// Apply the settings from QSettings to "save animation". + void restoreSettings(); signals: /// emitted when the active scene changes (\c scene may be NULL). @@ -127,6 +133,9 @@ class pqInternals; pqInternals* Internals; + + // the most recently used file extension + QString AnimationExtension; }; =================================================================== RCS file: /cvsroot/ParaView3/ParaView3/Qt/Components/pqAnimationManager.cxx,v retrieving revision 1.30 diff -u -r1.30 pqAnimationManager.cxx --- pqAnimationManager.cxx 21 Aug 2008 13:46:27 -0000 1.30 +++ pqAnimationManager.cxx 5 Nov 2008 22:23:00 -0000 @@ -64,6 +64,7 @@ #include "pqSMAdaptor.h" #include "pqView.h" #include "pqViewManager.h" +#include "pqSettings.h" #define SEQUENCE 0 #define REALTIME 1 @@ -99,11 +100,14 @@ this, SLOT(updateViewModules())); QObject::connect(smmodel, SIGNAL(viewRemoved(pqView*)), this, SLOT(updateViewModules())); + + this->restoreSettings(); } //----------------------------------------------------------------------------- pqAnimationManager::~pqAnimationManager() { + this->saveSettings(); delete this->Internals; } @@ -444,6 +448,7 @@ disconnect_and_save? scene->getServer() : 0, parent_window, tr("Save Animation"), QString(), filters); + file_dialog->setRecentlyUsedExtension(this->AnimationExtension); file_dialog->setObjectName("FileSaveAnimationDialog"); file_dialog->setFileMode(pqFileDialog::AnyFile); if (file_dialog->exec() != QDialog::Accepted) @@ -452,7 +457,10 @@ return false; } - QStringList files = file_dialog->getSelectedFiles(); + QStringList files = file_dialog->getSelectedFiles(); + QFileInfo fileInfo = QFileInfo( files[0] ); + this->AnimationExtension = QString("*.") + fileInfo.suffix(); + // essential to destroy file dialog, before we disconnect from the server, if // at all. delete file_dialog; @@ -616,6 +624,30 @@ } //----------------------------------------------------------------------------- +void pqAnimationManager::restoreSettings() +{ + // Load the most recently used file extension from QSettings, if available. + pqSettings* settings = pqApplicationCore::instance()->settings(); + + if ( settings->contains("extensions/AnimationExtension") ) + { + this->AnimationExtension = settings->value("extensions/AnimationExtension").toString(); + } + else + { + this->AnimationExtension = QString(); + } +} + +//----------------------------------------------------------------------------- +void pqAnimationManager::saveSettings() +{ + // Save the most recently used file extension to QSettings. + pqSettings* settings = pqApplicationCore::instance()->settings(); + settings->setValue("extensions/AnimationExtension", this->AnimationExtension); +} + +//----------------------------------------------------------------------------- void pqAnimationManager::onTick(int progress) { emit this->saveProgress("Saving Animation", progress); =================================================================== RCS file: /cvsroot/ParaView3/ParaView3/Qt/Components/pqMainWindowCore.h,v retrieving revision 1.98 diff -u -r1.98 pqMainWindowCore.h --- pqMainWindowCore.h 5 Nov 2008 15:43:51 -0000 1.98 +++ pqMainWindowCore.h 6 Nov 2008 14:03:28 -0000 @@ -263,6 +263,12 @@ /// Provides access to the menu manager used for the sources menu. pqProxyMenuManager* sourcesMenuManager() const; + + /// Save the settings of "save data" and "save screenshot" with QSettings. + void saveSettings(); + + /// Apply the settings from QSettings to "save data" and "save screenshot". + void restoreSettings(); signals: void enableFileLoadServerState(bool); @@ -495,6 +501,9 @@ class pqImplementation; pqImplementation* Implementation; void constructorHelper(QWidget *parent); + + QString ScreenshotExtension; + QString DataExtension; }; #endif // !_pqMainWindowCore_h =================================================================== RCS file: /cvsroot/ParaView3/ParaView3/Qt/Components/pqMainWindowCore.cxx,v retrieving revision 1.293 diff -u -r1.293 pqMainWindowCore.cxx --- pqMainWindowCore.cxx 8 Nov 2008 12:31:31 -0000 1.293 +++ pqMainWindowCore.cxx 21 Nov 2008 15:12:53 -0000 @@ -630,11 +630,15 @@ // can be used by the display panels. core->registerManager("COLOR_SCALE_EDITOR", this->getColorScaleEditorManager()); + + // the most recently used file extensions + this->restoreSettings(); } //----------------------------------------------------------------------------- pqMainWindowCore::~pqMainWindowCore() { + this->saveSettings(); delete Implementation; } @@ -1522,6 +1526,41 @@ } //----------------------------------------------------------------------------- +void pqMainWindowCore::restoreSettings() +{ + // Load the most recently used file extensions from QSettings, if available. + pqSettings* settings = pqApplicationCore::instance()->settings(); + + if ( settings->contains("extensions/ScreenshotExtension") ) + { + this->ScreenshotExtension = + settings->value("extensions/ScreenshotExtension").toString(); + } + else + { + this->ScreenshotExtension = QString(); + } + + if ( settings->contains("extensions/DataExtension") ) + { + this->DataExtension = settings->value("extensions/DataExtension").toString(); + } + else + { + this->DataExtension = QString(); + } +} + +//----------------------------------------------------------------------------- +void pqMainWindowCore::saveSettings() +{ + // Save the most recently used file extensions to QSettings. + pqSettings* settings = pqApplicationCore::instance()->settings(); + settings->setValue("extensions/ScreenshotExtension", this->ScreenshotExtension); + settings->setValue("extensions/DataExtension", this->DataExtension); +} + +//----------------------------------------------------------------------------- void pqMainWindowCore::makeDefaultConnectionIfNoneExists() { if (this->getActiveServer()) @@ -1731,11 +1770,18 @@ pqFileDialog file_dialog(port->getServer(), this->Implementation->Parent, tr("Save File:"), QString(), filters); + file_dialog.setRecentlyUsedExtension(this->DataExtension); file_dialog.setObjectName("FileSaveDialog"); file_dialog.setFileMode(pqFileDialog::AnyFile); QObject::connect(&file_dialog, SIGNAL(filesSelected(const QStringList&)), this, SLOT(onFileSaveData(const QStringList&))); - file_dialog.exec(); + + if ( file_dialog.exec() == QDialog::Accepted ) + { + QString selectedFile = file_dialog.getSelectedFiles()[0]; + QFileInfo fileInfo = QFileInfo( selectedFile ); + this->DataExtension = QString("*.") + fileInfo.suffix(); + } } //----------------------------------------------------------------------------- @@ -1851,12 +1897,16 @@ filters += ";;PDF file (*.pdf)"; pqFileDialog* const file_dialog = new pqFileDialog(NULL, this->Implementation->Parent, tr("Save Screenshot:"), QString(), filters); + file_dialog->setRecentlyUsedExtension(this->ScreenshotExtension); file_dialog->setObjectName("FileSaveScreenshotDialog"); file_dialog->setFileMode(pqFileDialog::AnyFile); if (file_dialog->exec() == QDialog::Accepted) { vtkSmartPointer img; QString file = file_dialog->getSelectedFiles()[0]; + QFileInfo fileInfo = QFileInfo( file ); + this->ScreenshotExtension = QString("*.") + fileInfo.suffix(); + if (ssDialog.saveAllViews()) { img.TakeReference(this->multiViewManager().captureImage( =================================================================== RCS file: /cvsroot/ParaView3/ParaView3/Qt/Core/pqFileDialog.h,v retrieving revision 1.9 diff -u -r1.9 pqFileDialog.h --- pqFileDialog.h 15 Apr 2008 20:22:22 -0000 1.9 +++ pqFileDialog.h 5 Nov 2008 22:19:23 -0000 @@ -109,6 +109,9 @@ /// set the file mode void setFileMode(FileMode); + /// set the most recently used file extension + void setRecentlyUsedExtension(const QString& fileExtension); + /// Returns the set of files QStringList getSelectedFiles(); =================================================================== RCS file: /cvsroot/ParaView3/ParaView3/Qt/Core/pqFileDialog.cxx,v retrieving revision 1.35 diff -u -r1.35 pqFileDialog.cxx --- pqFileDialog.cxx 17 Sep 2008 17:27:21 -0000 1.35 +++ pqFileDialog.cxx 5 Nov 2008 22:20:54 -0000 @@ -437,7 +437,6 @@ menu.exec(this->Implementation->Ui.Files->mapToGlobal(menuPos)); } - //----------------------------------------------------------------------------- void pqFileDialog::setFileMode(pqFileDialog::FileMode mode) { @@ -470,6 +469,27 @@ } //----------------------------------------------------------------------------- +void pqFileDialog::setRecentlyUsedExtension(const QString& fileExtension) +{ + if ( fileExtension == QString() ) + { + // upon the initial use of any kind (e.g., data or screenshot) of dialog + // 'fileExtension' is equal /set to an empty string. + // In this case, no any user preferences are considered + this->Implementation->Ui.FileType->setCurrentIndex(0); + } + else + { + int index = this->Implementation->Ui.FileType->findText(fileExtension, + Qt::MatchContains); + // just in case the provided extension is not in the combobox list + index = (index == -1) ? 0 : index; + + this->Implementation->Ui.FileType->setCurrentIndex(index); + } +} + +//----------------------------------------------------------------------------- void pqFileDialog::emitFilesSelected(const QStringList& files) { // Ensure that we are hidden before broadcasting the selection,