Use more FileUtils based file dialogs

Change-Id: I1e7ec0493c26afe58e17afb8923a2b1023f6dcd4
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-08-17 16:36:42 +02:00
parent 6e8c4aa835
commit 584217a52f
33 changed files with 226 additions and 226 deletions

View File

@@ -34,12 +34,13 @@
#include <QApplication> #include <QApplication>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
#include <QMessageBox> #include <QMessageBox>
#include <QProcess> #include <QProcess>
#include <QStandardPaths> #include <QStandardPaths>
using namespace Utils;
namespace QSsh { namespace QSsh {
SshKeyCreationDialog::SshKeyCreationDialog(QWidget *parent) SshKeyCreationDialog::SshKeyCreationDialog(QWidget *parent)
@@ -112,9 +113,9 @@ void SshKeyCreationDialog::generateKeys()
void SshKeyCreationDialog::handleBrowseButtonClicked() void SshKeyCreationDialog::handleBrowseButtonClicked()
{ {
const QString filePath = QFileDialog::getSaveFileName(this, tr("Choose Private Key File Name")); const FilePath filePath = FileUtils::getSaveFilePath(this, tr("Choose Private Key File Name"));
if (!filePath.isEmpty()) if (!filePath.isEmpty())
setPrivateKeyFile(filePath); setPrivateKeyFile(filePath.toString());
} }
void SshKeyCreationDialog::setPrivateKeyFile(const QString &filePath) void SshKeyCreationDialog::setPrivateKeyFile(const QString &filePath)

View File

@@ -27,6 +27,7 @@
#include "hostosinfo.h" #include "hostosinfo.h"
#include "stringutils.h" #include "stringutils.h"
#include "fileutils.h"
#include <QDebug> #include <QDebug>
#include <QFileDialog> #include <QFileDialog>
@@ -122,17 +123,13 @@ PathListEditor::PathListEditor(QWidget *parent) :
d(new PathListEditorPrivate) d(new PathListEditorPrivate)
{ {
setLayout(d->layout); setLayout(d->layout);
addButton(tr("Insert..."), this, [this](){ addButton(tr("Insert..."), this, [this] {
const QString dir = QFileDialog::getExistingDirectory(this, d->fileDialogTitle); const FilePath dir = FileUtils::getExistingDirectory(this, d->fileDialogTitle);
if (!dir.isEmpty()) if (!dir.isEmpty())
insertPathAtCursor(QDir::toNativeSeparators(dir)); insertPathAtCursor(dir.toUserOutput());
});
addButton(tr("Delete Line"), this, [this](){
deletePathAtCursor();
});
addButton(tr("Clear"), this, [this](){
d->edit->clear();
}); });
addButton(tr("Delete Line"), this, [this] { deletePathAtCursor(); });
addButton(tr("Clear"), this, [this] { d->edit->clear(); });
} }
PathListEditor::~PathListEditor() PathListEditor::~PathListEditor()

View File

@@ -169,9 +169,9 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
if (!validateUserInput()) if (!validateUserInput())
return; return;
m_keystoreFilePath = Utils::FilePath::fromString(QFileDialog::getSaveFileName(this, tr("Keystore Filename"), m_keystoreFilePath = FileUtils::getSaveFilePath(this, tr("Keystore Filename"),
QDir::homePath() + QLatin1String("/android_release.keystore"), FileUtils::homePath() / "android_release.keystore",
tr("Keystore files (*.keystore *.jks)"))); tr("Keystore files (*.keystore *.jks)"));
if (m_keystoreFilePath.isEmpty()) if (m_keystoreFilePath.isEmpty())
return; return;
QString distinguishedNames(QString::fromLatin1("CN=%1, O=%2, L=%3, C=%4") QString distinguishedNames(QString::fromLatin1("CN=%1, O=%2, L=%3, C=%4")

View File

@@ -68,6 +68,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
using namespace Core; using namespace Core;
using namespace Utils;
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
@@ -712,15 +713,14 @@ void TestResultsPane::onCopyWholeTriggered()
void TestResultsPane::onSaveWholeTriggered() void TestResultsPane::onSaveWholeTriggered()
{ {
const QString fileName = QFileDialog::getSaveFileName(ICore::dialogParent(), const FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Output To"));
tr("Save Output To")); if (filePath.isEmpty())
if (fileName.isEmpty())
return; return;
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text); FileSaver saver(filePath, QIODevice::Text);
if (!saver.write(getWholeOutput().toUtf8()) || !saver.finalize()) { if (!saver.write(getWholeOutput().toUtf8()) || !saver.finalize()) {
QMessageBox::critical(ICore::dialogParent(), tr("Error"), QMessageBox::critical(ICore::dialogParent(), tr("Error"),
tr("Failed to write \"%1\".\n\n%2").arg(fileName) tr("Failed to write \"%1\".\n\n%2").arg(filePath.toUserOutput())
.arg(saver.errorString())); .arg(saver.errorString()));
} }
} }

View File

@@ -790,22 +790,20 @@ void ClangTool::initDiagnosticView()
void ClangTool::loadDiagnosticsFromFiles() void ClangTool::loadDiagnosticsFromFiles()
{ {
// Ask user for files // Ask user for files
const QStringList filePaths const FilePaths filePaths
= QFileDialog::getOpenFileNames(Core::ICore::dialogParent(), = FileUtils::getOpenFilePaths(nullptr,
tr("Select YAML Files with Diagnostics"), tr("Select YAML Files with Diagnostics"),
QDir::homePath(), FileUtils::homePath(),
tr("YAML Files (*.yml *.yaml);;All Files (*)")); tr("YAML Files (*.yml *.yaml);;All Files (*)"));
if (filePaths.isEmpty()) if (filePaths.isEmpty())
return; return;
// Load files // Load files
Diagnostics diagnostics; Diagnostics diagnostics;
QString errors; QString errors;
for (const QString &filePath : filePaths) { for (const FilePath &filePath : filePaths) {
QString currentError; QString currentError;
diagnostics << readExportedDiagnostics(Utils::FilePath::fromString(filePath), diagnostics << readExportedDiagnostics(filePath, {}, &currentError);
{},
&currentError);
if (!currentError.isEmpty()) { if (!currentError.isEmpty()) {
if (!errors.isEmpty()) if (!errors.isEmpty())

View File

@@ -797,15 +797,15 @@ QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter
} }
QString DocumentManager::getSaveFileName(const QString &title, const QString &pathIn, QString DocumentManager::getSaveFileName(const QString &title, const QString &pathIn,
const QString &filter, QString *selectedFilter) const QString &filter, QString *selectedFilter)
{ {
const QString &path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn; const FilePath path = FilePath::fromString(pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn);
QString fileName; QString fileName;
bool repeat; bool repeat;
do { do {
repeat = false; repeat = false;
fileName = QFileDialog::getSaveFileName( fileName = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter,
ICore::dialogParent(), title, path, filter, selectedFilter, QFileDialog::DontConfirmOverwrite); QFileDialog::DontConfirmOverwrite).toString();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
// If the selected filter is All Files (*) we leave the name exactly as the user // If the selected filter is All Files (*) we leave the name exactly as the user
// specified. Otherwise the suffix must be one available in the selected filter. If // specified. Otherwise the suffix must be one available in the selected filter. If

View File

@@ -241,9 +241,9 @@ bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
void DirectoryFilter::handleAddDirectory() void DirectoryFilter::handleAddDirectory()
{ {
QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Select Directory")); FilePath dir = FileUtils::getExistingDirectory(m_dialog, tr("Select Directory"));
if (!dir.isEmpty()) if (!dir.isEmpty())
m_ui->directoryList->addItem(dir); m_ui->directoryList->addItem(dir.toUserOutput());
} }
void DirectoryFilter::handleEditDirectory() void DirectoryFilter::handleEditDirectory()
@@ -251,10 +251,10 @@ void DirectoryFilter::handleEditDirectory()
if (m_ui->directoryList->selectedItems().count() < 1) if (m_ui->directoryList->selectedItems().count() < 1)
return; return;
QListWidgetItem *currentItem = m_ui->directoryList->selectedItems().at(0); QListWidgetItem *currentItem = m_ui->directoryList->selectedItems().at(0);
QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Select Directory"), FilePath dir = FileUtils::getExistingDirectory(m_dialog, tr("Select Directory"),
currentItem->text()); FilePath::fromUserInput(currentItem->text()));
if (!dir.isEmpty()) if (!dir.isEmpty())
currentItem->setText(dir); currentItem->setText(dir.toUserOutput());
} }
void DirectoryFilter::handleRemoveDirectory() void DirectoryFilter::handleRemoveDirectory()

View File

@@ -51,6 +51,8 @@
#include <QTextCodec> #include <QTextCodec>
#include <QTextStream> #include <QTextStream>
using namespace Utils;
namespace CppTools { namespace CppTools {
namespace Internal { namespace Internal {
@@ -271,8 +273,8 @@ public:
private: private:
void slotEdit(); void slotEdit();
QString licenseTemplatePath() const; FilePath licenseTemplatePath() const;
void setLicenseTemplatePath(const QString &); void setLicenseTemplatePath(const FilePath &);
Ui::CppFileSettingsPage m_ui; Ui::CppFileSettingsPage m_ui;
CppFileSettings *m_settings = nullptr; CppFileSettings *m_settings = nullptr;
@@ -301,14 +303,14 @@ CppFileSettingsWidget::CppFileSettingsWidget(CppFileSettings *settings)
setSettings(*m_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) static QStringList trimmedPaths(const QString &paths)
@@ -330,7 +332,7 @@ void CppFileSettingsWidget::apply()
rc.sourceSuffix = m_ui.sourceSuffixComboBox->currentText(); rc.sourceSuffix = m_ui.sourceSuffixComboBox->currentText();
rc.headerSearchPaths = trimmedPaths(m_ui.headerSearchPathsEdit->text()); rc.headerSearchPaths = trimmedPaths(m_ui.headerSearchPathsEdit->text());
rc.sourceSearchPaths = trimmedPaths(m_ui.sourceSearchPathsEdit->text()); rc.sourceSearchPaths = trimmedPaths(m_ui.sourceSearchPathsEdit->text());
rc.licenseTemplatePath = licenseTemplatePath(); rc.licenseTemplatePath = licenseTemplatePath().toString();
if (rc == *m_settings) if (rc == *m_settings)
return; return;
@@ -358,18 +360,18 @@ void CppFileSettingsWidget::setSettings(const CppFileSettings &s)
setComboText(m_ui.sourceSuffixComboBox, s.sourceSuffix); setComboText(m_ui.sourceSuffixComboBox, s.sourceSuffix);
m_ui.headerSearchPathsEdit->setText(s.headerSearchPaths.join(comma)); m_ui.headerSearchPathsEdit->setText(s.headerSearchPaths.join(comma));
m_ui.sourceSearchPathsEdit->setText(s.sourceSearchPaths.join(comma)); m_ui.sourceSearchPathsEdit->setText(s.sourceSearchPaths.join(comma));
setLicenseTemplatePath(s.licenseTemplatePath); setLicenseTemplatePath(FilePath::fromString(s.licenseTemplatePath));
} }
void CppFileSettingsWidget::slotEdit() void CppFileSettingsWidget::slotEdit()
{ {
QString path = licenseTemplatePath(); FilePath path = licenseTemplatePath();
if (path.isEmpty()) { if (path.isEmpty()) {
// Pick a file name and write new template, edit with C++ // 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()) if (path.isEmpty())
return; 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()); saver.write(tr(licenseTemplateTemplate).arg(Core::Constants::IDE_DISPLAY_NAME).toUtf8());
if (!saver.finalize(this)) if (!saver.finalize(this))
return; return;

View File

@@ -1971,11 +1971,11 @@ void DebuggerPluginPrivate::dumpLog()
LogWindow *logWindow = engine->logWindow(); LogWindow *logWindow = engine->logWindow();
QTC_ASSERT(logWindow, return); QTC_ASSERT(logWindow, return);
QString fileName = QFileDialog::getSaveFileName(ICore::dialogParent(), FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Debugger Log"),
tr("Save Debugger Log"), Utils::TemporaryDirectory::masterDirectoryPath()); FilePath::fromString(TemporaryDirectory::masterDirectoryPath()));
if (fileName.isEmpty()) if (filePath.isEmpty())
return; return;
FileSaver saver(Utils::FilePath::fromUserInput(fileName)); FileSaver saver(filePath);
if (!saver.hasError()) { if (!saver.hasError()) {
QTextStream ts(saver.file()); QTextStream ts(saver.file());
ts << logWindow->inputContents(); ts << logWindow->inputContents();

View File

@@ -404,11 +404,11 @@ void DebuggerSourcePathMappingWidget::slotAdd()
void DebuggerSourcePathMappingWidget::slotAddQt() void DebuggerSourcePathMappingWidget::slotAddQt()
{ {
// Add a mapping for various Qt build locations in case of unpatched builds. // Add a mapping for various Qt build locations in case of unpatched builds.
const QString qtSourcesPath = QFileDialog::getExistingDirectory(this, tr("Qt Sources")); const FilePath qtSourcesPath = FileUtils::getExistingDirectory(this, tr("Qt Sources"));
if (qtSourcesPath.isEmpty()) if (qtSourcesPath.isEmpty())
return; return;
for (const QString &buildPath : qtBuildPaths()) for (const QString &buildPath : qtBuildPaths())
m_model->addMapping(buildPath, qtSourcesPath); m_model->addMapping(buildPath, qtSourcesPath.toString());
resizeColumns(); resizeColumns();
setCurrentRow(m_model->rowCount() - 1); setCurrentRow(m_model->rowCount() - 1);
} }

View File

@@ -56,6 +56,8 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/theme/theme.h> #include <utils/theme/theme.h>
using namespace Utils;
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -94,10 +96,10 @@ static bool writeLogContents(const QPlainTextEdit *editor, QWidget *parent)
{ {
bool success = false; bool success = false;
while (!success) { while (!success) {
const QString fileName = QFileDialog::getSaveFileName(parent, LogWindow::tr("Log File")); const FilePath filePath = FileUtils::getSaveFilePath(parent, LogWindow::tr("Log File"));
if (fileName.isEmpty()) if (filePath.isEmpty())
break; break;
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text); FileSaver saver(filePath, QIODevice::Text);
saver.write(editor->toPlainText().toUtf8()); saver.write(editor->toPlainText().toUtf8());
if (saver.finalize(parent)) if (saver.finalize(parent))
success = true; success = true;

View File

@@ -454,10 +454,9 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
// Ask the user for a repository to retrieve the change. // Ask the user for a repository to retrieve the change.
const QString title = const QString title =
tr("Enter Local Repository for \"%1\" (%2)").arg(change->project, change->branch); tr("Enter Local Repository for \"%1\" (%2)").arg(change->project, change->branch);
const QString suggestedRespository = const FilePath suggestedRespository =
findLocalRepository(change->project, change->branch); FilePath::fromString(findLocalRepository(change->project, change->branch));
repository = FilePath::fromString(QFileDialog::getExistingDirectory(m_dialog.data(), repository = FileUtils::getExistingDirectory(m_dialog.data(), title, suggestedRespository);
title, suggestedRespository));
} }
if (repository.isEmpty()) if (repository.isEmpty())

View File

@@ -1239,16 +1239,16 @@ void GitClient::archive(const FilePath &workingDirectory, QString commit)
if (synchronousRevParseCmd(repoDirectory, commit, &output)) if (synchronousRevParseCmd(repoDirectory, commit, &output))
commit = output.trimmed(); commit = output.trimmed();
QString archiveName = QFileDialog::getSaveFileName( FilePath archiveName = FileUtils::getSaveFilePath(
ICore::dialogParent(), nullptr,
tr("Generate %1 archive").arg(repoName), tr("Generate %1 archive").arg(repoName),
repoDirectory.toString() + QString("/../%1-%2").arg(repoName).arg(commit.left(8)), repoDirectory.pathAppended(QString("../%1-%2").arg(repoName).arg(commit.left(8))),
filters.keys().join(";;"), filters.keys().join(";;"),
&selectedFilter); &selectedFilter);
if (archiveName.isEmpty()) if (archiveName.isEmpty())
return; return;
QString extension = filters.value(selectedFilter); QString extension = filters.value(selectedFilter);
QFileInfo archive(archiveName); QFileInfo archive(archiveName.toString());
if (extension != "." + archive.completeSuffix()) { if (extension != "." + archive.completeSuffix()) {
archive = QFileInfo(archive.filePath() + extension); archive = QFileInfo(archive.filePath() + extension);
} }

View File

@@ -44,6 +44,8 @@
#include <algorithm> #include <algorithm>
using namespace Utils;
namespace Help { namespace Help {
namespace Internal { namespace Internal {
@@ -97,7 +99,7 @@ private:
Ui::DocSettingsPage m_ui; Ui::DocSettingsPage m_ui;
QString m_recentDialogPath; FilePath m_recentDialogPath;
using NameSpaceToPathHash = QMultiHash<QString, QString>; using NameSpaceToPathHash = QMultiHash<QString, QString>;
NameSpaceToPathHash m_filesToRegister; NameSpaceToPathHash m_filesToRegister;
@@ -200,29 +202,29 @@ DocSettingsPageWidget::DocSettingsPageWidget()
void DocSettingsPageWidget::addDocumentation() void DocSettingsPageWidget::addDocumentation()
{ {
const QStringList &files = const FilePaths files =
QFileDialog::getOpenFileNames(m_ui.addButton->parentWidget(), FileUtils::getOpenFilePaths(m_ui.addButton->parentWidget(),
tr("Add Documentation"), m_recentDialogPath, tr("Qt Help Files (*.qch)")); tr("Add Documentation"), m_recentDialogPath, tr("Qt Help Files (*.qch)"));
if (files.isEmpty()) if (files.isEmpty())
return; return;
m_recentDialogPath = QFileInfo(files.first()).canonicalPath(); m_recentDialogPath = files.first().canonicalPath();
NameSpaceToPathHash docsUnableToRegister; NameSpaceToPathHash docsUnableToRegister;
for (const QString &file : files) { for (const FilePath &file : files) {
const QString filePath = QDir::cleanPath(file); const QString filePath = file.cleanPath().toString();
const QString &nameSpace = HelpManager::namespaceFromFile(filePath); const QString &nameSpace = HelpManager::namespaceFromFile(filePath);
if (nameSpace.isEmpty()) { if (nameSpace.isEmpty()) {
docsUnableToRegister.insert("UnknownNamespace", QDir::toNativeSeparators(filePath)); docsUnableToRegister.insert("UnknownNamespace", file.toUserOutput());
continue; continue;
} }
if (m_filesToRegister.contains(nameSpace)) { if (m_filesToRegister.contains(nameSpace)) {
docsUnableToRegister.insert(nameSpace, QDir::toNativeSeparators(filePath)); docsUnableToRegister.insert(nameSpace, file.toUserOutput());
continue; continue;
} }
m_model.insertEntry(createEntry(nameSpace, file, true /* user managed */)); m_model.insertEntry(createEntry(nameSpace, file.toString(), true /* user managed */));
m_filesToRegister.insert(nameSpace, filePath); m_filesToRegister.insert(nameSpace, filePath);
m_filesToRegisterUserManaged.insert(nameSpace, true/*user managed*/); m_filesToRegisterUserManaged.insert(nameSpace, true/*user managed*/);

View File

@@ -36,7 +36,6 @@
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
#include <coreplugin/icore.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
@@ -46,10 +45,12 @@
#include <QTextStream> #include <QTextStream>
#include <QApplication> #include <QApplication>
#include <QFileDialog>
using namespace Core; using namespace Core;
using namespace Help::Internal; using namespace Utils;
namespace Help {
namespace Internal {
GeneralSettingsPage::GeneralSettingsPage() GeneralSettingsPage::GeneralSettingsPage()
{ {
@@ -219,13 +220,13 @@ void GeneralSettingsPage::importBookmarks()
{ {
m_ui->errorLabel->setVisible(false); m_ui->errorLabel->setVisible(false);
QString fileName = QFileDialog::getOpenFileName(ICore::dialogParent(), FilePath filePath = FileUtils::getOpenFilePath(nullptr,
tr("Import Bookmarks"), QDir::currentPath(), tr("Files (*.xbel)")); tr("Import Bookmarks"), FilePath::fromString(QDir::currentPath()), tr("Files (*.xbel)"));
if (fileName.isEmpty()) if (filePath.isEmpty())
return; return;
QFile file(fileName); QFile file(filePath.toString());
if (file.open(QIODevice::ReadOnly)) { if (file.open(QIODevice::ReadOnly)) {
const BookmarkManager &manager = LocalHelpManager::bookmarkManager(); const BookmarkManager &manager = LocalHelpManager::bookmarkManager();
XbelReader reader(manager.treeBookmarkModel(), manager.listBookmarkModel()); XbelReader reader(manager.treeBookmarkModel(), manager.listBookmarkModel());
@@ -241,14 +242,14 @@ void GeneralSettingsPage::exportBookmarks()
{ {
m_ui->errorLabel->setVisible(false); m_ui->errorLabel->setVisible(false);
QString fileName = QFileDialog::getSaveFileName(ICore::dialogParent(), FilePath filePath = FileUtils::getSaveFilePath(nullptr,
tr("Save File"), "untitled.xbel", tr("Files (*.xbel)")); tr("Save File"), "untitled.xbel", tr("Files (*.xbel)"));
QLatin1String suffix(".xbel"); QLatin1String suffix(".xbel");
if (!fileName.endsWith(suffix)) if (!filePath.endsWith(suffix))
fileName.append(suffix); filePath = filePath + suffix;
Utils::FileSaver saver(Utils::FilePath::fromString(fileName)); Utils::FileSaver saver(filePath);
if (!saver.hasError()) { if (!saver.hasError()) {
XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel()); XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
writer.writeToFile(saver.file()); writer.writeToFile(saver.file());
@@ -366,3 +367,6 @@ void GeneralSettingsPage::finish()
delete m_ui; delete m_ui;
m_ui = nullptr; m_ui = nullptr;
} }
} // Internal
} // Help

View File

@@ -36,7 +36,6 @@
#include <QDialog> #include <QDialog>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QFileDialog>
#include <QFormLayout> #include <QFormLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QHeaderView> #include <QHeaderView>
@@ -49,6 +48,7 @@
#include <QTreeView> #include <QTreeView>
using namespace LanguageServerProtocol; using namespace LanguageServerProtocol;
using namespace Utils;
namespace LanguageClient { namespace LanguageClient {
@@ -322,10 +322,10 @@ void LspLogWidget::saveLog()
stream << "\n\n"; stream << "\n\n";
}); });
const QString fileName = QFileDialog::getSaveFileName(this, LspInspector::tr("Log File")); const FilePath filePath = FileUtils::getSaveFilePath(this, LspInspector::tr("Log File"));
if (fileName.isEmpty()) if (filePath.isEmpty())
return; return;
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text); FileSaver saver(filePath, QIODevice::Text);
saver.write(contents.toUtf8()); saver.write(contents.toUtf8());
if (!saver.finalize(this)) if (!saver.finalize(this))
saveLog(); saveLog();

View File

@@ -106,6 +106,8 @@
#include <algorithm> #include <algorithm>
using namespace Utils;
namespace ModelEditor { namespace ModelEditor {
namespace Internal { namespace Internal {
@@ -595,10 +597,10 @@ void ModelEditor::exportToImage(bool selectedElements)
#ifndef QT_NO_SVG #ifndef QT_NO_SVG
filter += tr(";;SVG (*.svg)"); filter += tr(";;SVG (*.svg)");
#endif // QT_NO_SVG #endif // QT_NO_SVG
QString fileName = QFileDialog::getSaveFileName( QString fileName = FileUtils::getSaveFilePath(
Core::ICore::dialogParent(), nullptr,
selectedElements ? tr("Export Selected Elements") : tr("Export Diagram"), selectedElements ? tr("Export Selected Elements") : tr("Export Diagram"),
d->lastExportDirPath, filter); FilePath::fromString(d->lastExportDirPath), filter).toString();
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
qmt::DocumentController *documentController = d->document->documentController(); qmt::DocumentController *documentController = d->document->documentController();
qmt::DiagramSceneModel *sceneModel = documentController->diagramsManager()->diagramSceneModel(diagram); qmt::DiagramSceneModel *sceneModel = documentController->diagramsManager()->diagramSceneModel(diagram);

View File

@@ -841,11 +841,9 @@ void PerforcePluginPrivate::annotateCurrentFile()
void PerforcePluginPrivate::annotateFile() void PerforcePluginPrivate::annotateFile()
{ {
const QString file = QFileDialog::getOpenFileName(ICore::dialogParent(), tr("p4 annotate")); const FilePath filePath = FileUtils::getOpenFilePath(nullptr, tr("p4 annotate"));
if (!file.isEmpty()) { if (!filePath.isEmpty())
const QFileInfo fi(file); annotate(filePath.parentDir(), filePath.fileName());
annotate(FilePath::fromString(fi.absolutePath()), fi.fileName());
}
} }
void PerforcePluginPrivate::annotate(const FilePath &workingDir, void PerforcePluginPrivate::annotate(const FilePath &workingDir,

View File

@@ -33,7 +33,7 @@
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <QFileDialog> using namespace Utils;
namespace PerfProfiler { namespace PerfProfiler {
namespace Internal { namespace Internal {
@@ -75,23 +75,23 @@ ProjectExplorer::Kit *PerfLoadDialog::kit() const
void PerfLoadDialog::on_browseTraceFileButton_pressed() void PerfLoadDialog::on_browseTraceFileButton_pressed()
{ {
QString fileName = QFileDialog::getOpenFileName( FilePath filePath = FileUtils::getOpenFilePath(
this, tr("Choose Perf Trace"), QString(), this, tr("Choose Perf Trace"), {},
tr("Perf traces (*%1)").arg(QLatin1String(Constants::TraceFileExtension))); tr("Perf traces (*%1)").arg(Constants::TraceFileExtension));
if (fileName.isEmpty()) if (filePath.isEmpty())
return; return;
ui->traceFileLineEdit->setText(fileName); ui->traceFileLineEdit->setText(filePath.toUserOutput());
} }
void PerfLoadDialog::on_browseExecutableDirButton_pressed() void PerfLoadDialog::on_browseExecutableDirButton_pressed()
{ {
QString fileName = QFileDialog::getExistingDirectory( FilePath filePath = FileUtils::getExistingDirectory(
this, tr("Choose Directory of Executable")); this, tr("Choose Directory of Executable"));
if (fileName.isEmpty()) if (filePath.isEmpty())
return; return;
ui->executableDirLineEdit->setText(fileName); ui->executableDirLineEdit->setText(filePath.toUserOutput());
} }
void PerfLoadDialog::chooseDefaults() void PerfLoadDialog::chooseDefaults()

View File

@@ -619,10 +619,9 @@ void PerfProfilerTool::showLoadTraceDialog()
{ {
m_perspective.select(); m_perspective.select();
QString filename = QFileDialog::getOpenFileName( FilePath filePath = FileUtils::getOpenFilePath(nullptr, tr("Load Trace File"),
ICore::dialogParent(), tr("Load Trace File"), {}, tr("Trace File (*.ptq)"));
"", tr("Trace File (*.ptq)")); if (filePath.isEmpty())
if (filename.isEmpty())
return; return;
startLoading(); startLoading();
@@ -632,23 +631,22 @@ void PerfProfilerTool::showLoadTraceDialog()
const Kit *kit = target ? target->kit() : nullptr; const Kit *kit = target ? target->kit() : nullptr;
populateFileFinder(currentProject, kit); populateFileFinder(currentProject, kit);
m_traceManager->loadFromTraceFile(filename); m_traceManager->loadFromTraceFile(filePath.toString());
} }
void PerfProfilerTool::showSaveTraceDialog() void PerfProfilerTool::showSaveTraceDialog()
{ {
m_perspective.select(); m_perspective.select();
QString filename = QFileDialog::getSaveFileName( FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Trace File"),
ICore::dialogParent(), tr("Save Trace File"), {}, tr("Trace File (*.ptq)"));
"", tr("Trace File (*.ptq)")); if (filePath.isEmpty())
if (filename.isEmpty())
return; return;
if (!filename.endsWith(".ptq")) if (!filePath.endsWith(".ptq"))
filename += ".ptq"; filePath = filePath + ".ptq";
setToolActionsEnabled(false); setToolActionsEnabled(false);
m_traceManager->saveToTraceFile(filename); m_traceManager->saveToTraceFile(filePath.toString());
} }
void PerfProfilerTool::setAggregated(bool aggregated) void PerfProfilerTool::setAggregated(bool aggregated)

View File

@@ -102,10 +102,9 @@ public:
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(addButton, &QPushButton::clicked, this, [this] { connect(addButton, &QPushButton::clicked, this, [this] {
const QString dir = QDir::toNativeSeparators( const FilePath dir = FileUtils::getExistingDirectory(this, tr("Choose Directory"));
QFileDialog::getExistingDirectory(this, tr("Choose Directory")));
if (!dir.isEmpty()) if (!dir.isEmpty())
addPath(dir); addPath(dir.toUserOutput());
}); });
connect(removeButton, &QPushButton::clicked, this, [this] { connect(removeButton, &QPushButton::clicked, this, [this] {
const QList<QTreeWidgetItem *> selected = m_view.selectedItems(); const QList<QTreeWidgetItem *> selected = m_view.selectedItems();
@@ -486,12 +485,11 @@ void EnvironmentWidget::unsetEnvironmentButtonClicked()
void EnvironmentWidget::amendPathList(Utils::NameValueItem::Operation op) void EnvironmentWidget::amendPathList(Utils::NameValueItem::Operation op)
{ {
const QString varName = d->m_model->indexToVariable(d->m_environmentView->currentIndex()); const QString varName = d->m_model->indexToVariable(d->m_environmentView->currentIndex());
const QString dir = QDir::toNativeSeparators( const FilePath dir = FileUtils::getExistingDirectory(this, tr("Choose Directory"));
QFileDialog::getExistingDirectory(this, tr("Choose Directory")));
if (dir.isEmpty()) if (dir.isEmpty())
return; return;
Utils::NameValueItems changes = d->m_model->userChanges(); Utils::NameValueItems changes = d->m_model->userChanges();
changes.append({varName, dir, op}); changes.append({varName, dir.toUserOutput(), op});
d->m_model->setUserChanges(changes); d->m_model->setUserChanges(changes);
} }

View File

@@ -308,17 +308,17 @@ void KitManagerConfigWidget::setIcon()
action->setIconVisibleInMenu(true); action->setIconVisibleInMenu(true);
} }
iconMenu.addSeparator(); iconMenu.addSeparator();
iconMenu.addAction(Utils::PathChooser::browseButtonLabel(), [this] { iconMenu.addAction(PathChooser::browseButtonLabel(), [this] {
const QString path = QFileDialog::getOpenFileName(this, tr("Select Icon"), const FilePath path = FileUtils::getOpenFilePath(this, tr("Select Icon"),
m_modifiedKit->iconPath().toString(), m_modifiedKit->iconPath(),
tr("Images (*.png *.xpm *.jpg)")); tr("Images (*.png *.xpm *.jpg)"));
if (path.isEmpty()) if (path.isEmpty())
return; return;
const QIcon icon(path); const QIcon icon(path.toString());
if (icon.isNull()) if (icon.isNull())
return; return;
m_iconButton->setIcon(icon); m_iconButton->setIcon(icon);
m_modifiedKit->setIconPath(Utils::FilePath::fromString(path)); m_modifiedKit->setIconPath(path);
emit dirty(); emit dirty();
}); });
iconMenu.exec(mapToGlobal(m_iconButton->pos())); iconMenu.exec(mapToGlobal(m_iconButton->pos()));

View File

@@ -49,6 +49,8 @@
#include <memory> #include <memory>
using namespace Utils;
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
@@ -73,14 +75,14 @@ ParseIssuesDialog::ParseIssuesDialog(QWidget *parent) : QDialog(parent), d(new P
const auto loadFileButton = new QPushButton(tr("Load from File...")); const auto loadFileButton = new QPushButton(tr("Load from File..."));
connect(loadFileButton, &QPushButton::clicked, this, [this] { connect(loadFileButton, &QPushButton::clicked, this, [this] {
const QString filePath = QFileDialog::getOpenFileName(this, tr("Choose File")); const FilePath filePath = FileUtils::getOpenFilePath(this, tr("Choose File"));
if (filePath.isEmpty()) if (filePath.isEmpty())
return; return;
QFile file(filePath); QFile file(filePath.toString());
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, tr("Could Not Open File"), QMessageBox::critical(this, tr("Could Not Open File"),
tr("Could not open file: \"%1\": %2") tr("Could not open file: \"%1\": %2")
.arg(filePath, file.errorString())); .arg(filePath.toUserOutput(), file.errorString()));
return; return;
} }
d->compileOutputEdit.setPlainText(QString::fromLocal8Bit(file.readAll())); d->compileOutputEdit.setPlainText(QString::fromLocal8Bit(file.readAll()));

View File

@@ -586,11 +586,11 @@ void QmlProfilerTool::showErrorDialog(const QString &error)
errorDialog->show(); errorDialog->show();
} }
void saveLastTraceFile(const QString &filename) static void saveLastTraceFile(const FilePath &filePath)
{ {
QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings(); QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings();
if (filename != settings->lastTraceFile.value()) { if (filePath != settings->lastTraceFile.filePath()) {
settings->lastTraceFile.setValue(filename); settings->lastTraceFile.setFilePath(filePath);
settings->writeGlobalSettings(); settings->writeGlobalSettings();
} }
} }
@@ -599,16 +599,16 @@ void QmlProfilerTool::showSaveDialog()
{ {
QLatin1String tFile(QtdFileExtension); QLatin1String tFile(QtdFileExtension);
QLatin1String zFile(QztFileExtension); QLatin1String zFile(QztFileExtension);
QString filename = QFileDialog::getSaveFileName( FilePath filePath = FileUtils::getSaveFilePath(
ICore::dialogParent(), tr("Save QML Trace"), nullptr, tr("Save QML Trace"),
QmlProfilerPlugin::globalSettings()->lastTraceFile.value(), QmlProfilerPlugin::globalSettings()->lastTraceFile.filePath(),
tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile)); tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
if (!filename.isEmpty()) { if (!filePath.isEmpty()) {
if (!filename.endsWith(zFile) && !filename.endsWith(tFile)) if (!filePath.endsWith(zFile) && !filePath.endsWith(tFile))
filename += zFile; filePath = filePath + zFile;
saveLastTraceFile(filename); saveLastTraceFile(filePath);
Debugger::enableMainWindow(false); Debugger::enableMainWindow(false);
Core::ProgressManager::addTask(d->m_profilerModelManager->save(filename), Core::ProgressManager::addTask(d->m_profilerModelManager->save(filePath.toString()),
tr("Saving Trace Data"), TASK_SAVE, tr("Saving Trace Data"), TASK_SAVE,
Core::ProgressManager::ShowInApplicationIcon); Core::ProgressManager::ShowInApplicationIcon);
} }
@@ -623,18 +623,18 @@ void QmlProfilerTool::showLoadDialog()
QLatin1String tFile(QtdFileExtension); QLatin1String tFile(QtdFileExtension);
QLatin1String zFile(QztFileExtension); QLatin1String zFile(QztFileExtension);
QString filename = QFileDialog::getOpenFileName( FilePath filePath = FileUtils::getOpenFilePath(
ICore::dialogParent(), tr("Load QML Trace"), nullptr, tr("Load QML Trace"),
QmlProfilerPlugin::globalSettings()->lastTraceFile.value(), QmlProfilerPlugin::globalSettings()->lastTraceFile.filePath(),
tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile)); tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
if (!filename.isEmpty()) { if (!filePath.isEmpty()) {
saveLastTraceFile(filename); saveLastTraceFile(filePath);
Debugger::enableMainWindow(false); Debugger::enableMainWindow(false);
connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged, connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged,
this, &QmlProfilerTool::setRecordedFeatures); this, &QmlProfilerTool::setRecordedFeatures);
d->m_profilerModelManager->populateFileFinder(); d->m_profilerModelManager->populateFileFinder();
Core::ProgressManager::addTask(d->m_profilerModelManager->load(filename), Core::ProgressManager::addTask(d->m_profilerModelManager->load(filePath.toString()),
tr("Loading Trace Data"), TASK_LOAD); tr("Loading Trace Data"), TASK_LOAD);
} }
} }

View File

@@ -35,9 +35,10 @@
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
using namespace Utils;
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
@@ -107,16 +108,16 @@ void QnxSettingsWidget::addConfiguration()
{ {
QString filter; QString filter;
if (Utils::HostOsInfo::isWindowsHost()) if (Utils::HostOsInfo::isWindowsHost())
filter = QLatin1String("*.bat file"); filter = "*.bat file";
else else
filter = QLatin1String("*.sh file"); filter = "*.sh file";
const QString envFile = QFileDialog::getOpenFileName(this, tr("Select QNX Environment File"), const FilePath envFile = FileUtils::getOpenFilePath(this, tr("Select QNX Environment File"),
QString(), filter); {}, filter);
if (envFile.isEmpty()) if (envFile.isEmpty())
return; return;
QnxConfiguration *config = new QnxConfiguration(Utils::FilePath::fromString(envFile)); QnxConfiguration *config = new QnxConfiguration(envFile);
if (m_qnxConfigManager->configurations().contains(config) if (m_qnxConfigManager->configurations().contains(config)
|| !config->isValid()) { || !config->isValid()) {
QMessageBox::warning(Core::ICore::dialogParent(), QMessageBox::warning(Core::ICore::dialogParent(),

View File

@@ -58,7 +58,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QDir> #include <QDir>
#include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QTextBrowser> #include <QTextBrowser>
@@ -602,13 +601,12 @@ QtOptionsPageWidget::~QtOptionsPageWidget()
void QtOptionsPageWidget::addQtDir() void QtOptionsPageWidget::addQtDir()
{ {
FilePath qtVersion = FilePath::fromString( FilePath qtVersion = FileUtils::getOpenFilePath(this,
QFileDialog::getOpenFileName(this, tr("Select a qmake Executable"),
tr("Select a qmake Executable"), {},
QString(), BuildableHelperLibrary::filterForQmakeFileDialog(),
BuildableHelperLibrary::filterForQmakeFileDialog(), 0,
0, QFileDialog::DontResolveSymlinks);
QFileDialog::DontResolveSymlinks));
if (qtVersion.isEmpty()) if (qtVersion.isEmpty())
return; return;
@@ -672,14 +670,13 @@ void QtOptionsPageWidget::removeQtDir()
void QtOptionsPageWidget::editPath() void QtOptionsPageWidget::editPath()
{ {
BaseQtVersion *current = currentVersion(); BaseQtVersion *current = currentVersion();
QString dir = currentVersion()->qmakeFilePath().toFileInfo().absolutePath(); FilePath qtVersion =
FilePath qtVersion = FilePath::fromString( FileUtils::getOpenFilePath(this,
QFileDialog::getOpenFileName(this, tr("Select a qmake Executable"),
tr("Select a qmake Executable"), current->qmakeFilePath().absolutePath(),
dir, BuildableHelperLibrary::filterForQmakeFileDialog(),
BuildableHelperLibrary::filterForQmakeFileDialog(), nullptr,
nullptr, QFileDialog::DontResolveSymlinks);
QFileDialog::DontResolveSymlinks));
if (qtVersion.isEmpty()) if (qtVersion.isEmpty())
return; return;
BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(qtVersion); BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(qtVersion);

View File

@@ -31,9 +31,8 @@
#include <ssh/sshconnection.h> #include <ssh/sshconnection.h>
#include <utils/theme/theme.h> #include <utils/theme/theme.h>
#include <QFileDialog>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
@@ -50,14 +49,13 @@ using namespace Internal;
PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog( PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(
const IDevice::ConstPtr &deviceConfig, QWidget *parent) const IDevice::ConstPtr &deviceConfig, QWidget *parent)
{ {
const QString &dir = QFileInfo(deviceConfig->sshParameters().privateKeyFile).path(); const FilePath dir = FilePath::fromString(deviceConfig->sshParameters().privateKeyFile).parentDir();
const QString publicKeyFileName = QFileDialog::getOpenFileName(parent const FilePath publicKeyFileName = FileUtils::getOpenFilePath(nullptr,
? parent : Core::ICore::dialogParent(),
tr("Choose Public Key File"), dir, tr("Choose Public Key File"), dir,
tr("Public Key Files (*.pub);;All Files (*)")); tr("Public Key Files (*.pub);;All Files (*)"));
if (publicKeyFileName.isEmpty()) if (publicKeyFileName.isEmpty())
return nullptr; return nullptr;
return new PublicKeyDeploymentDialog(deviceConfig, publicKeyFileName, parent); return new PublicKeyDeploymentDialog(deviceConfig, publicKeyFileName.toString(), parent);
} }
PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const IDevice::ConstPtr &deviceConfig, PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const IDevice::ConstPtr &deviceConfig,

View File

@@ -426,11 +426,11 @@ void MainWidget::exportToImage()
.arg(lastFolder) .arg(lastFolder)
.arg(suggestedFileName) .arg(suggestedFileName)
.arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss")); .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"));
const QString selectedFileName = QFileDialog::getSaveFileName(this, const FilePath filePath = FileUtils::getSaveFilePath(this,
tr("Export Canvas to Image"), tr("Export Canvas to Image"),
suggestedFileName, FilePath::fromString(suggestedFileName),
saveImageFileFilter()); saveImageFileFilter());
if (!selectedFileName.isEmpty()) { if (!filePath.isEmpty()) {
const QRectF r = view->scene()->itemsBoundingRect(); const QRectF r = view->scene()->itemsBoundingRect();
QImage image(r.size().toSize(), QImage::Format_ARGB32); QImage image(r.size().toSize(), QImage::Format_ARGB32);
image.fill(QColor(0xef, 0xef, 0xef)); image.fill(QColor(0xef, 0xef, 0xef));
@@ -438,9 +438,8 @@ void MainWidget::exportToImage()
QPainter painter(&image); QPainter painter(&image);
view->scene()->render(&painter, QRectF(), r); view->scene()->render(&painter, QRectF(), r);
if (image.save(selectedFileName)) { if (image.save(filePath.toString())) {
s->setValue(Constants::C_SETTINGS_LASTEXPORTFOLDER, s->setValue(Constants::C_SETTINGS_LASTEXPORTFOLDER, filePath.parentDir().toString());
QFileInfo(selectedFileName).absolutePath());
} else { } else {
QMessageBox::warning(this, tr("Export Failed"), tr("Could not export to image.")); QMessageBox::warning(this, tr("Export Failed"), tr("Could not export to image."));
} }
@@ -455,18 +454,17 @@ void MainWidget::saveScreenShot()
QSettings *s = Core::ICore::settings(); QSettings *s = Core::ICore::settings();
const QString documentsLocation = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); const QString documentsLocation = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
const QString lastFolder = const FilePath lastFolder = FilePath::fromVariant(
s->value(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER, documentsLocation).toString(); s->value(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER, documentsLocation));
const QString filename = QFileDialog::getSaveFileName(this, const FilePath filePath = FileUtils::getSaveFilePath(this,
tr("Save Screenshot"), tr("Save Screenshot"),
lastFolder + "/scxml_screenshot.png", lastFolder / "scxml_screenshot.png",
saveImageFileFilter()); saveImageFileFilter());
if (!filename.isEmpty()) { if (!filePath.isEmpty()) {
const QImage image = view->view()->grabView(); const QImage image = view->view()->grabView();
if (image.save(filename)) { if (image.save(filePath.toString())) {
s->setValue(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER, s->setValue(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER, filePath.parentDir().toVariant());
QFileInfo(filename).absolutePath());
} else { } else {
QMessageBox::warning(this, tr("Saving Failed"), tr("Could not save the screenshot.")); QMessageBox::warning(this, tr("Saving Failed"), tr("Could not save the screenshot."));
} }

View File

@@ -41,6 +41,7 @@
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
using namespace ScxmlEditor::OutputPane; using namespace ScxmlEditor::OutputPane;
using namespace Utils;
ErrorWidget::ErrorWidget(QWidget *parent) ErrorWidget::ErrorWidget(QWidget *parent)
: OutputPane(parent) : OutputPane(parent)
@@ -203,13 +204,13 @@ QString ErrorWidget::modifyExportedValue(const QString &val)
void ErrorWidget::exportWarnings() void ErrorWidget::exportWarnings()
{ {
QString fileName = QFileDialog::getSaveFileName(this, tr("Export to File"), QString(), tr("CSV files (*.csv)")); FilePath fileName = FileUtils::getSaveFilePath(this, tr("Export to File"), {}, tr("CSV files (*.csv)"));
if (fileName.isEmpty()) if (fileName.isEmpty())
return; return;
QFile file(fileName); QFile file(fileName.toString());
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(this, tr("Export Failed"), tr("Cannot open file %1.").arg(fileName)); QMessageBox::warning(this, tr("Export Failed"), tr("Cannot open file %1.").arg(fileName.toUserOutput()));
file.close(); file.close();
return; return;
} }

View File

@@ -43,6 +43,7 @@
#include <QDebug> #include <QDebug>
using namespace TextEditor; using namespace TextEditor;
using namespace Utils;
namespace TextEditor { namespace TextEditor {
namespace Internal { namespace Internal {
@@ -150,8 +151,7 @@ CodeStyleDialog::~CodeStyleDialog()
delete m_codeStyle; delete m_codeStyle;
} }
} } // Internal
}
CodeStyleSelectorWidget::CodeStyleSelectorWidget(ICodeStylePreferencesFactory *factory, QWidget *parent) : CodeStyleSelectorWidget::CodeStyleSelectorWidget(ICodeStylePreferencesFactory *factory, QWidget *parent) :
QWidget(parent), QWidget(parent),
@@ -326,9 +326,9 @@ void CodeStyleSelectorWidget::slotRemoveClicked()
void CodeStyleSelectorWidget::slotImportClicked() void CodeStyleSelectorWidget::slotImportClicked()
{ {
const Utils::FilePath fileName = const FilePath fileName =
Utils::FilePath::fromString(QFileDialog::getOpenFileName(this, tr("Import Code Style"), QString(), FileUtils::getOpenFilePath(this, tr("Import Code Style"), {},
tr("Code styles (*.xml);;All files (*)"))); tr("Code styles (*.xml);;All files (*)"));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
CodeStylePool *codeStylePool = m_codeStyle->delegatingPool(); CodeStylePool *codeStylePool = m_codeStyle->delegatingPool();
ICodeStylePreferences *importedStyle = codeStylePool->importCodeStyle(fileName); ICodeStylePreferences *importedStyle = codeStylePool->importCodeStyle(fileName);
@@ -343,12 +343,12 @@ void CodeStyleSelectorWidget::slotImportClicked()
void CodeStyleSelectorWidget::slotExportClicked() void CodeStyleSelectorWidget::slotExportClicked()
{ {
ICodeStylePreferences *currentPreferences = m_codeStyle->currentPreferences(); ICodeStylePreferences *currentPreferences = m_codeStyle->currentPreferences();
const QString fileName = QFileDialog::getSaveFileName(this, tr("Export Code Style"), const FilePath filePath = FileUtils::getSaveFilePath(this, tr("Export Code Style"),
QString::fromUtf8(currentPreferences->id() + ".xml"), FilePath::fromString(QString::fromUtf8(currentPreferences->id() + ".xml")),
tr("Code styles (*.xml);;All files (*)")); tr("Code styles (*.xml);;All files (*)"));
if (!fileName.isEmpty()) { if (!filePath.isEmpty()) {
CodeStylePool *codeStylePool = m_codeStyle->delegatingPool(); CodeStylePool *codeStylePool = m_codeStyle->delegatingPool();
codeStylePool->exportCodeStyle(Utils::FilePath::fromString(fileName), currentPreferences); codeStylePool->exportCodeStyle(filePath, currentPreferences);
} }
} }
@@ -422,4 +422,6 @@ QString CodeStyleSelectorWidget::displayName(ICodeStylePreferences *codeStyle) c
return name; return name;
} }
} // TextEditor
#include "codestyleselectorwidget.moc" #include "codestyleselectorwidget.moc"

View File

@@ -874,17 +874,18 @@ void CallgrindToolPrivate::slotRequestDump()
void CallgrindToolPrivate::loadExternalLogFile() void CallgrindToolPrivate::loadExternalLogFile()
{ {
const QString filePath = QFileDialog::getOpenFileName( const FilePath filePath = FileUtils::getOpenFilePath(
ICore::dialogParent(), nullptr,
CallgrindTool::tr("Open Callgrind Log File"), CallgrindTool::tr("Open Callgrind Log File"),
QString(), {},
CallgrindTool::tr("Callgrind Output (callgrind.out*);;All Files (*)")); CallgrindTool::tr("Callgrind Output (callgrind.out*);;All Files (*)"));
if (filePath.isEmpty()) if (filePath.isEmpty())
return; return;
QFile logFile(filePath); QFile logFile(filePath.toString());
if (!logFile.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!logFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString msg = CallgrindTool::tr("Callgrind: Failed to open file for reading: %1").arg(filePath); QString msg = CallgrindTool::tr("Callgrind: Failed to open file for reading: %1")
.arg(filePath.toUserOutput());
TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID); TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID);
TaskHub::requestPopup(); TaskHub::requestPopup();
return; return;

View File

@@ -1017,16 +1017,16 @@ void MemcheckToolPrivate::loadShowXmlLogFile(const QString &filePath, const QStr
void MemcheckToolPrivate::loadExternalXmlLogFile() void MemcheckToolPrivate::loadExternalXmlLogFile()
{ {
const QString filePath = QFileDialog::getOpenFileName( const FilePath filePath = FileUtils::getOpenFilePath(
ICore::dialogParent(), nullptr,
MemcheckTool::tr("Open Memcheck XML Log File"), MemcheckTool::tr("Open Memcheck XML Log File"),
QString(), {},
MemcheckTool::tr("XML Files (*.xml);;All Files (*)")); MemcheckTool::tr("XML Files (*.xml);;All Files (*)"));
if (filePath.isEmpty()) if (filePath.isEmpty())
return; return;
m_exitMsg.clear(); m_exitMsg.clear();
loadXmlLogFile(filePath); loadXmlLogFile(filePath.toString());
} }
void MemcheckToolPrivate::loadXmlLogFile(const QString &filePath) void MemcheckToolPrivate::loadXmlLogFile(const QString &filePath)

View File

@@ -38,7 +38,6 @@
#include <valgrind/xmlprotocol/error.h> #include <valgrind/xmlprotocol/error.h>
#include <QDebug> #include <QDebug>
#include <QFileDialog>
#include <QListView> #include <QListView>
#include <QPushButton> #include <QPushButton>
#include <QSettings> #include <QSettings>
@@ -104,16 +103,16 @@ void SuppressionAspectPrivate::slotAddSuppression()
{ {
ValgrindGlobalSettings *conf = ValgrindGlobalSettings::instance(); ValgrindGlobalSettings *conf = ValgrindGlobalSettings::instance();
QTC_ASSERT(conf, return); QTC_ASSERT(conf, return);
const QStringList files = const FilePaths files =
QFileDialog::getOpenFileNames(Core::ICore::dialogParent(), FileUtils::getOpenFilePaths(nullptr,
tr("Valgrind Suppression Files"), tr("Valgrind Suppression Files"),
conf->lastSuppressionDirectory.value(), conf->lastSuppressionDirectory.filePath(),
tr("Valgrind Suppression File (*.supp);;All Files (*)")); tr("Valgrind Suppression File (*.supp);;All Files (*)"));
//dialog.setHistory(conf->lastSuppressionDialogHistory()); //dialog.setHistory(conf->lastSuppressionDialogHistory());
if (!files.isEmpty()) { if (!files.isEmpty()) {
for (const QString &file : files) for (const FilePath &file : files)
m_model.appendRow(new QStandardItem(file)); m_model.appendRow(new QStandardItem(file.toString()));
conf->lastSuppressionDirectory.setValue(QFileInfo(files.at(0)).absolutePath()); conf->lastSuppressionDirectory.setFilePath(files.at(0).absolutePath());
//conf->setLastSuppressionDialogHistory(dialog.history()); //conf->setLastSuppressionDialogHistory(dialog.history());
if (!isGlobal) if (!isGlobal)
q->apply(); q->apply();