diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index e9f2f2559da4e999ee1c63683f1fd4e4fca52c5b..cdc054dedc0c79db035197f902dd1dfe48abff80 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -476,13 +476,12 @@ 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("Save Flight Data Log"), + qgcApp()->mavlinkLogFilesLocation(), + tr("Flight Data Log (*.mavlink)"), + "mavlink"); if (!saveFilename.isEmpty()) { QFile::copy(tempLogfile, saveFilename); } diff --git a/src/QGCFileDialog.cc b/src/QGCFileDialog.cc index b8ad69832f5e7dc0850bfa86e024e8bc74262116..5888ddeed3e39c9214b91349d60497fd4d4e44f9 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,57 +46,57 @@ 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, + const QString& defaultSuffix, + Options options) { - _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, defaultSuffix, options); } else #endif { @@ -104,12 +105,13 @@ QString QGCFileDialog::getSaveFileName(QWidget* parent, if (options) { dlg.setOptions(options); } - if (defaultSuffix) { + if (!defaultSuffix.isEmpty()) { + QString suffixCopy(defaultSuffix); //-- Make sure dot is not present - if (defaultSuffix->startsWith(".")) { - defaultSuffix->remove(0,1); + if (suffixCopy.startsWith(".")) { + suffixCopy.remove(0,1); } - dlg.setDefaultSuffix(*defaultSuffix); + dlg.setDefaultSuffix(suffixCopy); } if (dlg.exec()) { if (dlg.selectedFiles().count()) { @@ -121,17 +123,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..3de8c43301cb1316b5d66eea87bbbafba9015419 100644 --- a/src/QGCFileDialog.h +++ b/src/QGCFileDialog.h @@ -31,10 +31,21 @@ /// @author Don Gagne /*! - Subclass of QFileDialog which re-implements the static public functions. The reason for this - is that the QFileDialog implementations of these use the native os dialogs. On OSX these - these can intermittently hang. So instead here we use the native dialogs. It also allows - use to catch these dialogs for unit testing. + Subclass of QFileDialog which re-implements the static public functions. The reason for this + is that the QFileDialog implementations of these use the native os dialogs. On OSX these + these can intermittently hang. So instead here we use the native dialogs. It also allows + use to catch these dialogs for unit testing. + @remark If you need to know what type of file was returned by these functions, you can use something like: + @code{.cpp} + QString filename = QGCFileDialog::getSaveFileName(this, tr("Save File"), "~/", "Foo files (*.foo);;All Files (*.*)", "foo"); + if (!filename.isEmpty()) { + QFileInfo fi(filename); + QString fileExtension(fi.suffix()); + if (fileExtension == QString("foo")) { + // do something + } + } + @endcode */ class QGCFileDialog : public QFileDialog { @@ -50,10 +61,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 +73,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 +90,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,29 +107,28 @@ 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). + @param[in] options Set the various options that affect the look and feel of the dialog. @return The full path and filename to be used to save the file or \c QString("") if none. @sa QFileDialog::getSaveFileName() @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(), + const QString& defaultSuffix = QString(), + Options options = 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 because 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..4a403c1c0642937dc24842ce9b0b4d845e5d2d55 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, + const QString& defaultSuffix, + QFileDialog::Options options) { Q_UNUSED(parent); Q_UNUSED(caption); @@ -354,11 +349,9 @@ QString UnitTest::_getSaveFileName(QWidget* parent, Q_UNUSED(filter); Q_UNUSED(options); - if(defaultSuffix) - Q_ASSERT(defaultSuffix->startsWith(".") == false); - - // Support for selectedFilter is not yet implemented - Q_ASSERT(selectedFilter == NULL); + if(!defaultSuffix.isEmpty()) { + Q_ASSERT(defaultSuffix.startsWith(".") == false); + } return _fileDialogResponseSingle(getSaveFileName); } diff --git a/src/qgcunittest/UnitTest.h b/src/qgcunittest/UnitTest.h index 44e39ea6c1cbedc1090a3f0143b93e8ae27c76d6..bbc78acb191500f23203e74edba0fb0f7569e2a1 100644 --- a/src/qgcunittest/UnitTest.h +++ b/src/qgcunittest/UnitTest.h @@ -118,33 +118,34 @@ 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, + const QString& defaultSuffix, + QFileDialog::Options options); + static QString _fileDialogResponseSingle(enum FileDialogType type); // This allows the private calls to the file dialog methods diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 3ba4b9a4612e8be001b14c20ea3e5d6d0dd0aff2..d5bc4f960c6a0cb17285754bdd3e3db37a667a93 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -836,16 +836,17 @@ 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), + format); delete videoTimer; videoTimer = new QTimer(this); } diff --git a/src/ui/QGCBaseParamWidget.cc b/src/ui/QGCBaseParamWidget.cc index 2d8c96997afcf70da528b24b84fae9aedd59d365..a70db99a6aac24350fa65b7e2caa896f85b31689 100644 --- a/src/ui/QGCBaseParamWidget.cc +++ b/src/ui/QGCBaseParamWidget.cc @@ -105,8 +105,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)"), "txt"); QFile file(fileName); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { return; @@ -123,7 +122,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..ac4a024971b69a62a9d900b3e95e3d21f0b87ca0 100644 --- a/src/ui/QGCDataPlot2D.cc +++ b/src/ui/QGCDataPlot2D.cc @@ -100,13 +100,17 @@ void QGCDataPlot2D::loadFile() void QGCDataPlot2D::loadFile(QString file) { + // TODO This "filename" is a private/protected member variable. It should be named in such way + // it indicates so. This same name is used in several places within this file in local scopes. fileName = file; - if (QFileInfo(fileName).isReadable()) { - if (fileName.contains(".raw") || fileName.contains(".imu")) { + QFileInfo fi(fileName); + if (fi.isReadable()) { + if (fi.suffix() == QString("raw") || fi.suffix() == QString("imu")) { loadRawLog(fileName); - } else if (fileName.contains(".txt") || fileName.contains(".csv") || fileName.contains(".csv")) { + } else if (fi.suffix() == QString("txt") || fi.suffix() == QString("csv")) { loadCsvLog(fileName); } + // TODO Else, tell the user it doesn't know what to do with the file... } } @@ -115,12 +119,10 @@ void QGCDataPlot2D::loadFile(QString file) */ QString QGCDataPlot2D::getSavePlotFilename() { - QString defaultSuffix("pdf"); QString fileName = QGCFileDialog::getSaveFileName( - this, "Export File Name", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), + this, "Save Plot File", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), "PDF Documents (*.pdf);;SVG Images (*.svg)", - 0,0, - &defaultSuffix); + "pdf"); return fileName; } @@ -133,11 +135,13 @@ void QGCDataPlot2D::savePlot() if (fileName.isEmpty()) return; + // TODO This will change once we add "strict" file types in file selection dialogs while(!(fileName.endsWith(".svg") || fileName.endsWith(".pdf"))) { - QMessageBox::StandardButton button = QGCMessageBox::critical(tr("Unsuitable file extension for PDF or SVG"), - tr("Please choose .pdf or .svg as file extension. Click OK to change the file extension, cancel to not save the file."), - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Ok); + QMessageBox::StandardButton button = QGCMessageBox::warning( + tr("Unsuitable file extension for Plot document type."), + tr("Please choose .pdf or .svg as file extension. Click OK to change the file extension, cancel to not save the file."), + QMessageBox::Ok | QMessageBox::Cancel, + QMessageBox::Ok); // Abort if cancelled if (button == QMessageBox::Cancel) { return; @@ -690,12 +694,10 @@ bool QGCDataPlot2D::linearRegression(double *x, double *y, int n, double *a, dou void QGCDataPlot2D::saveCsvLog() { - QString defaultSuffix("csv"); QString fileName = QGCFileDialog::getSaveFileName( - this, "Export CSV File Name", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), + this, "Save CSV Log File", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), "CSV file (*.csv);;Text file (*.txt)", - 0,0, - &defaultSuffix); + "csv"); if (fileName.isEmpty()) return; //User cancelled diff --git a/src/ui/WaypointList.cc b/src/ui/WaypointList.cc index b019cd35942afdb4ad3727a7c3a5837ee201b214..5354cf2af2fab78607423e7871b41ca347dd33b8 100644 --- a/src/ui/WaypointList.cc +++ b/src/ui/WaypointList.cc @@ -217,14 +217,15 @@ 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); + // TODO Need better default directory + // TODO Need better extension than .txt + QString fileName = QGCFileDialog::getSaveFileName(this, tr("Save Waypoint File"), "./waypoints.txt", tr("Waypoint File (*.txt)"), "txt"); WPM->saveWaypoints(fileName); } void WaypointList::loadWaypoints() { - QString fileName = QGCFileDialog::getOpenFileName(this, tr("Load File"), ".", tr("Waypoint File (*.txt)")); + QString fileName = QGCFileDialog::getOpenFileName(this, tr("Load Waypoint File"), ".", tr("Waypoint File (*.txt)")); WPM->loadWaypoints(fileName); } diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index 61c565c77a1ef1f882685edf7ce1c53abc15ad4e..55c71c104543526ff36bad63a29262e8499dccbf 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -571,14 +571,12 @@ void QGCToolWidget::widgetRemoved() void QGCToolWidget::exportWidget() { - QString defaultSuffix("qgw"); const QString widgetFileExtension(".qgw"); QString fileName = QGCFileDialog::getSaveFileName( - this, tr("Specify File Name"), + this, tr("Save Widget File"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), tr("QGroundControl Widget (*%1)").arg(widgetFileExtension), - 0,0, - &defaultSuffix); + "qgw"); //-- Note that if the user enters foo.bar, this will end up foo.bar.qgw if (!fileName.endsWith(widgetFileExtension)) { @@ -591,7 +589,7 @@ void QGCToolWidget::exportWidget() void QGCToolWidget::importWidget() { const QString widgetFileExtension(".qgw"); - QString fileName = QGCFileDialog::getOpenFileName(this, tr("Specify File Name"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), tr("QGroundControl Widget (*%1)").arg(widgetFileExtension)); + QString fileName = QGCFileDialog::getOpenFileName(this, tr("Load Widget File"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), tr("QGroundControl Widget (*%1)").arg(widgetFileExtension)); loadSettings(fileName); } diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 0975bb7215cdaa76c7e0e52e95d4a4eb3786defe..69705ed3ccd7c46fe48714af86efcc09b05fc536 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -433,13 +433,11 @@ void LinechartWidget::refresh() QString LinechartWidget::getLogSaveFilename() { - QString defaultSuffix("log"); QString fileName = QGCFileDialog::getSaveFileName(this, - tr("Specify log file name"), + tr("Save Log File"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), - tr("Logfile (*.log)"), - 0,0, - &defaultSuffix); + tr("Log file (*.log)"), + "log"); return fileName; }