diff options
author | hjk <hjk@qt.io> | 2021-08-17 16:36:42 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2021-08-19 08:33:22 +0000 |
commit | 584217a52f23212d1d56a2beda95ea4438c33aeb (patch) | |
tree | 4703c37de7523a3149864bd9687862163417a762 /src/plugins/cpptools | |
parent | 6e8c4aa835273d4bf4d5c35f54e3c613a3542420 (diff) |
Use more FileUtils based file dialogs
Change-Id: I1e7ec0493c26afe58e17afb8923a2b1023f6dcd4
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r-- | src/plugins/cpptools/cppfilesettingspage.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp index f63eb41b24..d289e6334e 100644 --- a/src/plugins/cpptools/cppfilesettingspage.cpp +++ b/src/plugins/cpptools/cppfilesettingspage.cpp @@ -51,6 +51,8 @@ #include <QTextCodec> #include <QTextStream> +using namespace Utils; + namespace CppTools { namespace Internal { @@ -271,8 +273,8 @@ public: private: void slotEdit(); - QString licenseTemplatePath() const; - void setLicenseTemplatePath(const QString &); + FilePath licenseTemplatePath() const; + void setLicenseTemplatePath(const FilePath &); Ui::CppFileSettingsPage m_ui; CppFileSettings *m_settings = nullptr; @@ -301,14 +303,14 @@ CppFileSettingsWidget::CppFileSettingsWidget(CppFileSettings *settings) setSettings(*m_settings); } -QString CppFileSettingsWidget::licenseTemplatePath() const +FilePath CppFileSettingsWidget::licenseTemplatePath() const { - return m_ui.licenseTemplatePathChooser->filePath().toString(); + return m_ui.licenseTemplatePathChooser->filePath(); } -void CppFileSettingsWidget::setLicenseTemplatePath(const QString &lp) +void CppFileSettingsWidget::setLicenseTemplatePath(const FilePath &lp) { - m_ui.licenseTemplatePathChooser->setPath(lp); + m_ui.licenseTemplatePathChooser->setFilePath(lp); } static QStringList trimmedPaths(const QString &paths) @@ -330,7 +332,7 @@ void CppFileSettingsWidget::apply() rc.sourceSuffix = m_ui.sourceSuffixComboBox->currentText(); rc.headerSearchPaths = trimmedPaths(m_ui.headerSearchPathsEdit->text()); rc.sourceSearchPaths = trimmedPaths(m_ui.sourceSearchPathsEdit->text()); - rc.licenseTemplatePath = licenseTemplatePath(); + rc.licenseTemplatePath = licenseTemplatePath().toString(); if (rc == *m_settings) return; @@ -358,18 +360,18 @@ void CppFileSettingsWidget::setSettings(const CppFileSettings &s) setComboText(m_ui.sourceSuffixComboBox, s.sourceSuffix); m_ui.headerSearchPathsEdit->setText(s.headerSearchPaths.join(comma)); m_ui.sourceSearchPathsEdit->setText(s.sourceSearchPaths.join(comma)); - setLicenseTemplatePath(s.licenseTemplatePath); + setLicenseTemplatePath(FilePath::fromString(s.licenseTemplatePath)); } void CppFileSettingsWidget::slotEdit() { - QString path = licenseTemplatePath(); + FilePath path = licenseTemplatePath(); if (path.isEmpty()) { // Pick a file name and write new template, edit with C++ - path = QFileDialog::getSaveFileName(this, tr("Choose Location for New License Template File")); + path = FileUtils::getSaveFilePath(this, tr("Choose Location for New License Template File")); if (path.isEmpty()) return; - Utils::FileSaver saver(Utils::FilePath::fromString(path), QIODevice::Text); + FileSaver saver(path, QIODevice::Text); saver.write(tr(licenseTemplateTemplate).arg(Core::Constants::IDE_DISPLAY_NAME).toUtf8()); if (!saver.finalize(this)) return; |