diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index e9f2f2559da4e999ee1c63683f1fd4e4fca52c5b..8c6ad72d6e27521557b8bb66a818c5e96632f301 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -477,12 +477,13 @@ void QGCApplication::criticalMessageBoxOnMainThread(const QString& title, const void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile) { QString defaultSuffix("mavlink"); - QString saveFilename = QGCFileDialog::getSaveFileName(MainWindow::instance(), - tr("Select file to save Flight Data Log"), - qgcApp()->mavlinkLogFilesLocation(), - tr("Flight Data Log (*.mavlink)"), - 0,0, - &defaultSuffix); + QString saveFilename = QGCFileDialog::getSaveFileName( + MainWindow::instance(), + tr("Select file to save Flight Data Log"), + qgcApp()->mavlinkLogFilesLocation(), + tr("Flight Data Log (*.mavlink)"), + 0, + &defaultSuffix); if (!saveFilename.isEmpty()) { QFile::copy(tempLogfile, saveFilename); } diff --git a/src/QGCFileDialog.cc b/src/QGCFileDialog.cc index b3cb51805c3bd309b3b41e694ea554379d4e5f6f..45a934ef6947dd5e0eacfc607854470c06e9907e 100644 --- a/src/QGCFileDialog.cc +++ b/src/QGCFileDialog.cc @@ -28,12 +28,13 @@ #include "UnitTest.h" #endif -QString QGCFileDialog::getExistingDirectory(QWidget* parent, - const QString& caption, - const QString& dir, - Options options) +QString QGCFileDialog::getExistingDirectory( + QWidget* parent, + const QString& caption, + const QString& dir, + Options options) { - _validate(NULL, options); + _validate(options); #ifdef QT_DEBUG if (qgcApp()->runningUnitTests()) { @@ -45,65 +46,62 @@ QString QGCFileDialog::getExistingDirectory(QWidget* parent, } } -QString QGCFileDialog::getOpenFileName(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - Options options) +QString QGCFileDialog::getOpenFileName( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + Options options) { - _validate(selectedFilter, options); + _validate(options); #ifdef QT_DEBUG if (qgcApp()->runningUnitTests()) { - return UnitTest::_getOpenFileName(parent, caption, dir, filter, selectedFilter, options); + return UnitTest::_getOpenFileName(parent, caption, dir, filter, options); } else #endif { - return QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options); + return QFileDialog::getOpenFileName(parent, caption, dir, filter, NULL, options); } } -QStringList QGCFileDialog::getOpenFileNames(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - Options options) +QStringList QGCFileDialog::getOpenFileNames( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + Options options) { - _validate(selectedFilter, options); + _validate(options); #ifdef QT_DEBUG if (qgcApp()->runningUnitTests()) { - return UnitTest::_getOpenFileNames(parent, caption, dir, filter, selectedFilter, options); + return UnitTest::_getOpenFileNames(parent, caption, dir, filter, options); } else #endif { - return QFileDialog::getOpenFileNames(parent, caption, dir, filter, selectedFilter, options); + return QFileDialog::getOpenFileNames(parent, caption, dir, filter, NULL, options); } } -QString QGCFileDialog::getSaveFileName(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - Options options, - QString* defaultSuffix) +QString QGCFileDialog::getSaveFileName( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + Options options, + QString* defaultSuffix) { - _validate(selectedFilter, options); + _validate(options); #ifdef QT_DEBUG if (qgcApp()->runningUnitTests()) { - return UnitTest::_getSaveFileName(parent, caption, dir, filter, selectedFilter, options, defaultSuffix); + return UnitTest::_getSaveFileName(parent, caption, dir, filter, options, defaultSuffix); } else #endif { QFileDialog dlg(parent, caption, dir, filter); dlg.setAcceptMode(QFileDialog::AcceptSave); - if (selectedFilter) { - dlg.selectNameFilter(*selectedFilter); - } if (options) { dlg.setOptions(options); } @@ -124,17 +122,13 @@ QString QGCFileDialog::getSaveFileName(QWidget* parent, } /// @brief Validates and updates the parameters for the file dialog calls -void QGCFileDialog::_validate(QString* selectedFilter, Options& options) +void QGCFileDialog::_validate(Options& options) { // You can't use QGCFileDialog if QGCApplication is not created yet. Q_ASSERT(qgcApp()); Q_ASSERT_X(QThread::currentThread() == qgcApp()->thread(), "Threading issue", "QGCFileDialog can only be called from main thread"); - // Support for selectedFilter is not yet implemented through the unit test framework - Q_UNUSED(selectedFilter); - Q_ASSERT(selectedFilter == NULL); - // On OSX native dialog can hang so we always use Qt dialogs options |= DontUseNativeDialog; diff --git a/src/QGCFileDialog.h b/src/QGCFileDialog.h index 7dea53cae9997b65d5e207c34a0ce1e167b40442..0351da91a2b4e29c45cbf5ebe8c1830c369ff861 100644 --- a/src/QGCFileDialog.h +++ b/src/QGCFileDialog.h @@ -50,10 +50,11 @@ public: @return The chosen path or \c QString("") if none. @sa QFileDialog::getExistingDirectory() */ - static QString getExistingDirectory(QWidget* parent = 0, - const QString& caption = QString(), - const QString& dir = QString(), - Options options = ShowDirsOnly); + static QString getExistingDirectory( + QWidget* parent = 0, + const QString& caption = QString(), + const QString& dir = QString(), + Options options = ShowDirsOnly); //! Static helper that invokes a File Open dialog where the user can select a file to be opened. /*! @@ -61,17 +62,16 @@ public: @param[in] caption The caption displayed at the top of the dialog. @param[in] dir The initial directory shown to the user. @param[in] filter The filter used for selecting the file type. - @param[out] selectedFilter **NOT IMPLEMENTED - Set to NULL** Returns the filter that the user selected in the file dialog. @param[in] options Set the various options that affect the look and feel of the dialog. @return The full path and filename to be opened or \c QString("") if none. @sa QFileDialog::getOpenFileName() */ - static QString getOpenFileName(QWidget* parent = 0, - const QString& caption = QString(), - const QString& dir = QString(), - const QString& filter = QString(), - QString* selectedFilter = 0, - Options options = 0); + static QString getOpenFileName( + QWidget* parent = 0, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& filter = QString(), + Options options = 0); //! Static helper that invokes a File Open dialog where the user can select one or more files to be opened. /*! @@ -79,17 +79,16 @@ public: @param[in] caption The caption displayed at the top of the dialog. @param[in] dir The initial directory shown to the user. @param[in] filter The filter used for selecting the file type. - @param[out] selectedFilter **NOT IMPLEMENTED - Set to NULL** Returns the filter that the user selected in the file dialog. @param[in] options Set the various options that affect the look and feel of the dialog. @return A QStringList object containing zero or more files to be opened. @sa QFileDialog::getOpenFileNames() */ - static QStringList getOpenFileNames(QWidget* parent = 0, - const QString& caption = QString(), - const QString& dir = QString(), - const QString& filter = QString(), - QString* selectedFilter = 0, - Options options = 0); + static QStringList getOpenFileNames( + QWidget* parent = 0, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& filter = QString(), + Options options = 0); //! Static helper that invokes a File Save dialog where the user can select a directory and enter a filename to be saved. /*! @@ -97,7 +96,6 @@ public: @param[in] caption The caption displayed at the top of the dialog. @param[in] dir The initial directory shown to the user. @param[in] filter The filter used for selecting the file type. - @param[out] selectedFilter **NOT IMPLEMENTED - Set to NULL** Returns the filter that the user selected in the file dialog. @param[in] options Set the various options that affect the look and feel of the dialog. @param[in] defaultSuffix Specifies a string that will be added to the filename if it has no suffix already. The suffix is typically used to indicate the file type (e.g. "txt" indicates a text file). @return The full path and filename to be used to save the file or \c QString("") if none. @@ -105,21 +103,21 @@ public: @remark If a default suffix is given, it will be appended to the filename if the user does not enter one themselves. That is, if the user simply enters \e foo and the default suffix is set to \e bar, the returned filename will be \e foo.bar. However, if the user specifies a suffix, none will be added. That is, if the user enters \e foo.txt, that's what you will receive in return. */ - static QString getSaveFileName(QWidget* parent = 0, - const QString& caption = QString(), - const QString& dir = QString(), - const QString& filter = QString(), - QString* selectedFilter = 0, - Options options = 0, - QString* defaultSuffix = 0); + static QString getSaveFileName( + QWidget* parent = 0, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& filter = QString(), + Options options = 0, + QString* defaultSuffix = 0); private slots: - /// @brief The exec slot is private becasue when only want QGCFileDialog users to use the static methods. Otherwise it will break - /// unit testing. + /// @brief The exec slot is private becasue we only want QGCFileDialog users to use the static methods. Otherwise it will break + /// unit testing. int exec(void) { return QGCFileDialog::exec(); } private: - static void _validate(QString* selectedFilter, Options& options); + static void _validate(Options& options); }; diff --git a/src/qgcunittest/UnitTest.cc b/src/qgcunittest/UnitTest.cc index eaa164675935b082db1f2b7aeae04b9428dd4f79..d8e9c15fbf1effc587401a7fafd5df43048ac735 100644 --- a/src/qgcunittest/UnitTest.cc +++ b/src/qgcunittest/UnitTest.cc @@ -273,10 +273,11 @@ QString UnitTest::_fileDialogResponseSingle(enum FileDialogType type) return retFile; } -QString UnitTest::_getExistingDirectory(QWidget* parent, - const QString& caption, - const QString& dir, - QFileDialog::Options options) +QString UnitTest::_getExistingDirectory( + QWidget* parent, + const QString& caption, + const QString& dir, + QFileDialog::Options options) { Q_UNUSED(parent); Q_UNUSED(caption); @@ -286,12 +287,12 @@ QString UnitTest::_getExistingDirectory(QWidget* parent, return _fileDialogResponseSingle(getExistingDirectory); } -QString UnitTest::_getOpenFileName(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - QFileDialog::Options options) +QString UnitTest::_getOpenFileName( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + QFileDialog::Options options) { Q_UNUSED(parent); Q_UNUSED(caption); @@ -299,18 +300,15 @@ QString UnitTest::_getOpenFileName(QWidget* parent, Q_UNUSED(filter); Q_UNUSED(options); - // Support for selectedFilter is not yet implemented - Q_ASSERT(selectedFilter == NULL); - return _fileDialogResponseSingle(getOpenFileName); } -QStringList UnitTest::_getOpenFileNames(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - QFileDialog::Options options) +QStringList UnitTest::_getOpenFileNames( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + QFileDialog::Options options) { Q_UNUSED(parent); Q_UNUSED(caption); @@ -318,9 +316,6 @@ QStringList UnitTest::_getOpenFileNames(QWidget* parent, Q_UNUSED(filter); Q_UNUSED(options); - // Support for selectedFilter is not yet implemented - Q_ASSERT(selectedFilter == NULL); - QStringList retFiles; if (!_fileDialogResponseSet || _fileDialogExpectedType != getOpenFileNames) { @@ -340,13 +335,13 @@ QStringList UnitTest::_getOpenFileNames(QWidget* parent, return retFiles; } -QString UnitTest::_getSaveFileName(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - QFileDialog::Options options, - QString* defaultSuffix) +QString UnitTest::_getSaveFileName( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + QFileDialog::Options options, + QString* defaultSuffix) { Q_UNUSED(parent); Q_UNUSED(caption); @@ -357,8 +352,5 @@ QString UnitTest::_getSaveFileName(QWidget* parent, if(defaultSuffix) Q_ASSERT(defaultSuffix->startsWith(".") == false); - // Support for selectedFilter is not yet implemented - Q_ASSERT(selectedFilter == NULL); - return _fileDialogResponseSingle(getSaveFileName); } diff --git a/src/qgcunittest/UnitTest.h b/src/qgcunittest/UnitTest.h index 44e39ea6c1cbedc1090a3f0143b93e8ae27c76d6..ce50b5b58f18090bae2dbacdb51e80e7b8a83d8c 100644 --- a/src/qgcunittest/UnitTest.h +++ b/src/qgcunittest/UnitTest.h @@ -118,32 +118,33 @@ private: // When the app is running in unit test mode the QGCFileDialog methods are re-routed here. - static QString _getExistingDirectory(QWidget* parent, - const QString& caption, - const QString& dir, - QFileDialog::Options options); - - static QString _getOpenFileName(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - QFileDialog::Options options); - - static QStringList _getOpenFileNames(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - QFileDialog::Options options); - - static QString _getSaveFileName(QWidget* parent, - const QString& caption, - const QString& dir, - const QString& filter, - QString* selectedFilter, - QFileDialog::Options options, - QString* defaultSuffix); + static QString _getExistingDirectory( + QWidget* parent, + const QString& caption, + const QString& dir, + QFileDialog::Options options); + + static QString _getOpenFileName( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + QFileDialog::Options options); + + static QStringList _getOpenFileNames( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + QFileDialog::Options options); + + static QString _getSaveFileName( + QWidget* parent, + const QString& caption, + const QString& dir, + const QString& filter, + QFileDialog::Options options, + QString* defaultSuffix); static QString _fileDialogResponseSingle(enum FileDialogType type); diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 3ba4b9a4612e8be001b14c20ea3e5d6d0dd0aff2..f943edbd0569ba88b27367e1274256a79b9e10fa 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -836,16 +836,18 @@ void MainWindow::configureWindowName() void MainWindow::startVideoCapture() { + // TODO: What is this? What kind of "Video" is saved to bmp? QString format("bmp"); QString initialPath = QDir::currentPath() + tr("/untitled.") + format; - QString screenFileName = QGCFileDialog::getSaveFileName(this, tr("Save As"), - initialPath, - tr("%1 Files (*.%2);;All Files (*)") - .arg(format.toUpper()) - .arg(format), - 0,0, - &format); + QString screenFileName = QGCFileDialog::getSaveFileName( + this, tr("Save Video Capture"), + initialPath, + tr("%1 Files (*.%2);;All Files (*)") + .arg(format.toUpper()) + .arg(format), + 0, + &format); delete videoTimer; videoTimer = new QTimer(this); } diff --git a/src/ui/QGCBaseParamWidget.cc b/src/ui/QGCBaseParamWidget.cc index 2d8c96997afcf70da528b24b84fae9aedd59d365..ac39a1c416e2eaa7172f8b0ffd1b4b964efb8539 100644 --- a/src/ui/QGCBaseParamWidget.cc +++ b/src/ui/QGCBaseParamWidget.cc @@ -106,7 +106,7 @@ void QGCBaseParamWidget::saveParametersToFile() if (!mav) return; QString defaultSuffix("txt"); - QString fileName = QGCFileDialog::getSaveFileName(this, tr("Save File"), qgcApp()->savedParameterFilesLocation(), tr("Parameter File (*.txt)"), 0, 0, &defaultSuffix); + QString fileName = QGCFileDialog::getSaveFileName(this, tr("Save Parameters"), qgcApp()->savedParameterFilesLocation(), tr("Parameter File (*.txt)"), 0, &defaultSuffix); QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { return; @@ -123,7 +123,7 @@ void QGCBaseParamWidget::loadParametersFromFile() if (!mav) return; - QString fileName = QGCFileDialog::getOpenFileName(this, tr("Load File"), qgcApp()->savedParameterFilesLocation(), tr("Parameter file (*.txt)")); + QString fileName = QGCFileDialog::getOpenFileName(this, tr("Load Parameters"), qgcApp()->savedParameterFilesLocation(), tr("Parameter file (*.txt)")); QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; diff --git a/src/ui/QGCDataPlot2D.cc b/src/ui/QGCDataPlot2D.cc index 952fa0e0d7c99ec50e217ffd79ee992d2b7823d1..236f134339541ff4517ddbb1e1ec5d4860b610db 100644 --- a/src/ui/QGCDataPlot2D.cc +++ b/src/ui/QGCDataPlot2D.cc @@ -119,7 +119,7 @@ QString QGCDataPlot2D::getSavePlotFilename() QString fileName = QGCFileDialog::getSaveFileName( this, "Export File Name", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), "PDF Documents (*.pdf);;SVG Images (*.svg)", - 0,0, + 0, &defaultSuffix); return fileName; } @@ -694,7 +694,7 @@ void QGCDataPlot2D::saveCsvLog() QString fileName = QGCFileDialog::getSaveFileName( this, "Export CSV File Name", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), "CSV file (*.csv);;Text file (*.txt)", - 0,0, + 0, &defaultSuffix); if (fileName.isEmpty()) diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index b019cd35942afdb4ad3727a7c3a5837ee201b214..30e7abec774f55c0409743b24d8b99dab036d660 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -218,7 +218,7 @@ void WaypointList::setUAS(UASInterface* uas) void WaypointList::saveWaypoints() { QString defaultSuffix("txt"); - QString fileName = QGCFileDialog::getSaveFileName(this, tr("Save File"), "./waypoints.txt", tr("Waypoint File (*.txt)"), 0, 0, &defaultSuffix); + QString fileName = QGCFileDialog::getSaveFileName(this, tr("Save File"), "./waypoints.txt", tr("Waypoint File (*.txt)"), 0, &defaultSuffix); WPM->saveWaypoints(fileName); } diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index 61c565c77a1ef1f882685edf7ce1c53abc15ad4e..34e94f974092c138f17bd6bc0d8c4f82473f3065 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -574,10 +574,10 @@ void QGCToolWidget::exportWidget() QString defaultSuffix("qgw"); const QString widgetFileExtension(".qgw"); QString fileName = QGCFileDialog::getSaveFileName( - this, tr("Specify File Name"), + this, tr("Specify Widget File Name"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), tr("QGroundControl Widget (*%1)").arg(widgetFileExtension), - 0,0, + 0, &defaultSuffix); //-- Note that if the user enters foo.bar, this will end up foo.bar.qgw if (!fileName.endsWith(widgetFileExtension)) diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 0975bb7215cdaa76c7e0e52e95d4a4eb3786defe..fa39e9ba9effa848c2920273cb520077f94bb042 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -435,10 +435,10 @@ QString LinechartWidget::getLogSaveFilename() { QString defaultSuffix("log"); QString fileName = QGCFileDialog::getSaveFileName(this, - tr("Specify log file name"), + tr("Specify Log File Name"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), - tr("Logfile (*.log)"), - 0,0, + tr("Log file (*.log)"), + 0, &defaultSuffix); return fileName; }