forked from qt-creator/qt-creator
Use more FileUtils based file dialogs
Change-Id: I1e7ec0493c26afe58e17afb8923a2b1023f6dcd4 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -34,12 +34,13 @@
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace QSsh {
|
||||
|
||||
SshKeyCreationDialog::SshKeyCreationDialog(QWidget *parent)
|
||||
@@ -112,9 +113,9 @@ void SshKeyCreationDialog::generateKeys()
|
||||
|
||||
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())
|
||||
setPrivateKeyFile(filePath);
|
||||
setPrivateKeyFile(filePath.toString());
|
||||
}
|
||||
|
||||
void SshKeyCreationDialog::setPrivateKeyFile(const QString &filePath)
|
||||
|
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "hostosinfo.h"
|
||||
#include "stringutils.h"
|
||||
#include "fileutils.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
@@ -122,17 +123,13 @@ PathListEditor::PathListEditor(QWidget *parent) :
|
||||
d(new PathListEditorPrivate)
|
||||
{
|
||||
setLayout(d->layout);
|
||||
addButton(tr("Insert..."), this, [this](){
|
||||
const QString dir = QFileDialog::getExistingDirectory(this, d->fileDialogTitle);
|
||||
addButton(tr("Insert..."), this, [this] {
|
||||
const FilePath dir = FileUtils::getExistingDirectory(this, d->fileDialogTitle);
|
||||
if (!dir.isEmpty())
|
||||
insertPathAtCursor(QDir::toNativeSeparators(dir));
|
||||
});
|
||||
addButton(tr("Delete Line"), this, [this](){
|
||||
deletePathAtCursor();
|
||||
});
|
||||
addButton(tr("Clear"), this, [this](){
|
||||
d->edit->clear();
|
||||
insertPathAtCursor(dir.toUserOutput());
|
||||
});
|
||||
addButton(tr("Delete Line"), this, [this] { deletePathAtCursor(); });
|
||||
addButton(tr("Clear"), this, [this] { d->edit->clear(); });
|
||||
}
|
||||
|
||||
PathListEditor::~PathListEditor()
|
||||
|
@@ -169,9 +169,9 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
|
||||
if (!validateUserInput())
|
||||
return;
|
||||
|
||||
m_keystoreFilePath = Utils::FilePath::fromString(QFileDialog::getSaveFileName(this, tr("Keystore Filename"),
|
||||
QDir::homePath() + QLatin1String("/android_release.keystore"),
|
||||
tr("Keystore files (*.keystore *.jks)")));
|
||||
m_keystoreFilePath = FileUtils::getSaveFilePath(this, tr("Keystore Filename"),
|
||||
FileUtils::homePath() / "android_release.keystore",
|
||||
tr("Keystore files (*.keystore *.jks)"));
|
||||
if (m_keystoreFilePath.isEmpty())
|
||||
return;
|
||||
QString distinguishedNames(QString::fromLatin1("CN=%1, O=%2, L=%3, C=%4")
|
||||
|
@@ -68,6 +68,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
@@ -712,15 +713,14 @@ void TestResultsPane::onCopyWholeTriggered()
|
||||
|
||||
void TestResultsPane::onSaveWholeTriggered()
|
||||
{
|
||||
const QString fileName = QFileDialog::getSaveFileName(ICore::dialogParent(),
|
||||
tr("Save Output To"));
|
||||
if (fileName.isEmpty())
|
||||
const FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Output To"));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text);
|
||||
FileSaver saver(filePath, QIODevice::Text);
|
||||
if (!saver.write(getWholeOutput().toUtf8()) || !saver.finalize()) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
@@ -790,10 +790,10 @@ void ClangTool::initDiagnosticView()
|
||||
void ClangTool::loadDiagnosticsFromFiles()
|
||||
{
|
||||
// Ask user for files
|
||||
const QStringList filePaths
|
||||
= QFileDialog::getOpenFileNames(Core::ICore::dialogParent(),
|
||||
const FilePaths filePaths
|
||||
= FileUtils::getOpenFilePaths(nullptr,
|
||||
tr("Select YAML Files with Diagnostics"),
|
||||
QDir::homePath(),
|
||||
FileUtils::homePath(),
|
||||
tr("YAML Files (*.yml *.yaml);;All Files (*)"));
|
||||
if (filePaths.isEmpty())
|
||||
return;
|
||||
@@ -801,11 +801,9 @@ void ClangTool::loadDiagnosticsFromFiles()
|
||||
// Load files
|
||||
Diagnostics diagnostics;
|
||||
QString errors;
|
||||
for (const QString &filePath : filePaths) {
|
||||
for (const FilePath &filePath : filePaths) {
|
||||
QString currentError;
|
||||
diagnostics << readExportedDiagnostics(Utils::FilePath::fromString(filePath),
|
||||
{},
|
||||
¤tError);
|
||||
diagnostics << readExportedDiagnostics(filePath, {}, ¤tError);
|
||||
|
||||
if (!currentError.isEmpty()) {
|
||||
if (!errors.isEmpty())
|
||||
|
@@ -799,13 +799,13 @@ QString DocumentManager::allDocumentFactoryFiltersString(QString *allFilesFilter
|
||||
QString DocumentManager::getSaveFileName(const QString &title, const QString &pathIn,
|
||||
const QString &filter, QString *selectedFilter)
|
||||
{
|
||||
const QString &path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn;
|
||||
const FilePath path = FilePath::fromString(pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn);
|
||||
QString fileName;
|
||||
bool repeat;
|
||||
do {
|
||||
repeat = false;
|
||||
fileName = QFileDialog::getSaveFileName(
|
||||
ICore::dialogParent(), title, path, filter, selectedFilter, QFileDialog::DontConfirmOverwrite);
|
||||
fileName = FileUtils::getSaveFilePath(nullptr, title, path, filter, selectedFilter,
|
||||
QFileDialog::DontConfirmOverwrite).toString();
|
||||
if (!fileName.isEmpty()) {
|
||||
// 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
|
||||
|
@@ -241,9 +241,9 @@ bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
||||
|
||||
void DirectoryFilter::handleAddDirectory()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Select Directory"));
|
||||
FilePath dir = FileUtils::getExistingDirectory(m_dialog, tr("Select Directory"));
|
||||
if (!dir.isEmpty())
|
||||
m_ui->directoryList->addItem(dir);
|
||||
m_ui->directoryList->addItem(dir.toUserOutput());
|
||||
}
|
||||
|
||||
void DirectoryFilter::handleEditDirectory()
|
||||
@@ -251,10 +251,10 @@ void DirectoryFilter::handleEditDirectory()
|
||||
if (m_ui->directoryList->selectedItems().count() < 1)
|
||||
return;
|
||||
QListWidgetItem *currentItem = m_ui->directoryList->selectedItems().at(0);
|
||||
QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Select Directory"),
|
||||
currentItem->text());
|
||||
FilePath dir = FileUtils::getExistingDirectory(m_dialog, tr("Select Directory"),
|
||||
FilePath::fromUserInput(currentItem->text()));
|
||||
if (!dir.isEmpty())
|
||||
currentItem->setText(dir);
|
||||
currentItem->setText(dir.toUserOutput());
|
||||
}
|
||||
|
||||
void DirectoryFilter::handleRemoveDirectory()
|
||||
|
@@ -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;
|
||||
|
@@ -1971,11 +1971,11 @@ void DebuggerPluginPrivate::dumpLog()
|
||||
LogWindow *logWindow = engine->logWindow();
|
||||
QTC_ASSERT(logWindow, return);
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(ICore::dialogParent(),
|
||||
tr("Save Debugger Log"), Utils::TemporaryDirectory::masterDirectoryPath());
|
||||
if (fileName.isEmpty())
|
||||
FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Debugger Log"),
|
||||
FilePath::fromString(TemporaryDirectory::masterDirectoryPath()));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
FileSaver saver(Utils::FilePath::fromUserInput(fileName));
|
||||
FileSaver saver(filePath);
|
||||
if (!saver.hasError()) {
|
||||
QTextStream ts(saver.file());
|
||||
ts << logWindow->inputContents();
|
||||
|
@@ -404,11 +404,11 @@ void DebuggerSourcePathMappingWidget::slotAdd()
|
||||
void DebuggerSourcePathMappingWidget::slotAddQt()
|
||||
{
|
||||
// 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())
|
||||
return;
|
||||
for (const QString &buildPath : qtBuildPaths())
|
||||
m_model->addMapping(buildPath, qtSourcesPath);
|
||||
m_model->addMapping(buildPath, qtSourcesPath.toString());
|
||||
resizeColumns();
|
||||
setCurrentRow(m_model->rowCount() - 1);
|
||||
}
|
||||
|
@@ -56,6 +56,8 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
@@ -94,10 +96,10 @@ static bool writeLogContents(const QPlainTextEdit *editor, QWidget *parent)
|
||||
{
|
||||
bool success = false;
|
||||
while (!success) {
|
||||
const QString fileName = QFileDialog::getSaveFileName(parent, LogWindow::tr("Log File"));
|
||||
if (fileName.isEmpty())
|
||||
const FilePath filePath = FileUtils::getSaveFilePath(parent, LogWindow::tr("Log File"));
|
||||
if (filePath.isEmpty())
|
||||
break;
|
||||
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text);
|
||||
FileSaver saver(filePath, QIODevice::Text);
|
||||
saver.write(editor->toPlainText().toUtf8());
|
||||
if (saver.finalize(parent))
|
||||
success = true;
|
||||
|
@@ -454,10 +454,9 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
// Ask the user for a repository to retrieve the change.
|
||||
const QString title =
|
||||
tr("Enter Local Repository for \"%1\" (%2)").arg(change->project, change->branch);
|
||||
const QString suggestedRespository =
|
||||
findLocalRepository(change->project, change->branch);
|
||||
repository = FilePath::fromString(QFileDialog::getExistingDirectory(m_dialog.data(),
|
||||
title, suggestedRespository));
|
||||
const FilePath suggestedRespository =
|
||||
FilePath::fromString(findLocalRepository(change->project, change->branch));
|
||||
repository = FileUtils::getExistingDirectory(m_dialog.data(), title, suggestedRespository);
|
||||
}
|
||||
|
||||
if (repository.isEmpty())
|
||||
|
@@ -1239,16 +1239,16 @@ void GitClient::archive(const FilePath &workingDirectory, QString commit)
|
||||
if (synchronousRevParseCmd(repoDirectory, commit, &output))
|
||||
commit = output.trimmed();
|
||||
|
||||
QString archiveName = QFileDialog::getSaveFileName(
|
||||
ICore::dialogParent(),
|
||||
FilePath archiveName = FileUtils::getSaveFilePath(
|
||||
nullptr,
|
||||
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(";;"),
|
||||
&selectedFilter);
|
||||
if (archiveName.isEmpty())
|
||||
return;
|
||||
QString extension = filters.value(selectedFilter);
|
||||
QFileInfo archive(archiveName);
|
||||
QFileInfo archive(archiveName.toString());
|
||||
if (extension != "." + archive.completeSuffix()) {
|
||||
archive = QFileInfo(archive.filePath() + extension);
|
||||
}
|
||||
|
@@ -44,6 +44,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Help {
|
||||
namespace Internal {
|
||||
|
||||
@@ -97,7 +99,7 @@ private:
|
||||
|
||||
Ui::DocSettingsPage m_ui;
|
||||
|
||||
QString m_recentDialogPath;
|
||||
FilePath m_recentDialogPath;
|
||||
|
||||
using NameSpaceToPathHash = QMultiHash<QString, QString>;
|
||||
NameSpaceToPathHash m_filesToRegister;
|
||||
@@ -200,29 +202,29 @@ DocSettingsPageWidget::DocSettingsPageWidget()
|
||||
|
||||
void DocSettingsPageWidget::addDocumentation()
|
||||
{
|
||||
const QStringList &files =
|
||||
QFileDialog::getOpenFileNames(m_ui.addButton->parentWidget(),
|
||||
const FilePaths files =
|
||||
FileUtils::getOpenFilePaths(m_ui.addButton->parentWidget(),
|
||||
tr("Add Documentation"), m_recentDialogPath, tr("Qt Help Files (*.qch)"));
|
||||
|
||||
if (files.isEmpty())
|
||||
return;
|
||||
m_recentDialogPath = QFileInfo(files.first()).canonicalPath();
|
||||
m_recentDialogPath = files.first().canonicalPath();
|
||||
|
||||
NameSpaceToPathHash docsUnableToRegister;
|
||||
for (const QString &file : files) {
|
||||
const QString filePath = QDir::cleanPath(file);
|
||||
for (const FilePath &file : files) {
|
||||
const QString filePath = file.cleanPath().toString();
|
||||
const QString &nameSpace = HelpManager::namespaceFromFile(filePath);
|
||||
if (nameSpace.isEmpty()) {
|
||||
docsUnableToRegister.insert("UnknownNamespace", QDir::toNativeSeparators(filePath));
|
||||
docsUnableToRegister.insert("UnknownNamespace", file.toUserOutput());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_filesToRegister.contains(nameSpace)) {
|
||||
docsUnableToRegister.insert(nameSpace, QDir::toNativeSeparators(filePath));
|
||||
docsUnableToRegister.insert(nameSpace, file.toUserOutput());
|
||||
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_filesToRegisterUserManaged.insert(nameSpace, true/*user managed*/);
|
||||
|
@@ -36,7 +36,6 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
@@ -46,10 +45,12 @@
|
||||
#include <QTextStream>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Help::Internal;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Help {
|
||||
namespace Internal {
|
||||
|
||||
GeneralSettingsPage::GeneralSettingsPage()
|
||||
{
|
||||
@@ -219,13 +220,13 @@ void GeneralSettingsPage::importBookmarks()
|
||||
{
|
||||
m_ui->errorLabel->setVisible(false);
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(ICore::dialogParent(),
|
||||
tr("Import Bookmarks"), QDir::currentPath(), tr("Files (*.xbel)"));
|
||||
FilePath filePath = FileUtils::getOpenFilePath(nullptr,
|
||||
tr("Import Bookmarks"), FilePath::fromString(QDir::currentPath()), tr("Files (*.xbel)"));
|
||||
|
||||
if (fileName.isEmpty())
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
QFile file(fileName);
|
||||
QFile file(filePath.toString());
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
const BookmarkManager &manager = LocalHelpManager::bookmarkManager();
|
||||
XbelReader reader(manager.treeBookmarkModel(), manager.listBookmarkModel());
|
||||
@@ -241,14 +242,14 @@ void GeneralSettingsPage::exportBookmarks()
|
||||
{
|
||||
m_ui->errorLabel->setVisible(false);
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(ICore::dialogParent(),
|
||||
FilePath filePath = FileUtils::getSaveFilePath(nullptr,
|
||||
tr("Save File"), "untitled.xbel", tr("Files (*.xbel)"));
|
||||
|
||||
QLatin1String suffix(".xbel");
|
||||
if (!fileName.endsWith(suffix))
|
||||
fileName.append(suffix);
|
||||
if (!filePath.endsWith(suffix))
|
||||
filePath = filePath + suffix;
|
||||
|
||||
Utils::FileSaver saver(Utils::FilePath::fromString(fileName));
|
||||
Utils::FileSaver saver(filePath);
|
||||
if (!saver.hasError()) {
|
||||
XbelWriter writer(LocalHelpManager::bookmarkManager().treeBookmarkModel());
|
||||
writer.writeToFile(saver.file());
|
||||
@@ -366,3 +367,6 @@ void GeneralSettingsPage::finish()
|
||||
delete m_ui;
|
||||
m_ui = nullptr;
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // Help
|
||||
|
@@ -36,7 +36,6 @@
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QElapsedTimer>
|
||||
#include <QFileDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHeaderView>
|
||||
@@ -49,6 +48,7 @@
|
||||
#include <QTreeView>
|
||||
|
||||
using namespace LanguageServerProtocol;
|
||||
using namespace Utils;
|
||||
|
||||
namespace LanguageClient {
|
||||
|
||||
@@ -322,10 +322,10 @@ void LspLogWidget::saveLog()
|
||||
stream << "\n\n";
|
||||
});
|
||||
|
||||
const QString fileName = QFileDialog::getSaveFileName(this, LspInspector::tr("Log File"));
|
||||
if (fileName.isEmpty())
|
||||
const FilePath filePath = FileUtils::getSaveFilePath(this, LspInspector::tr("Log File"));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
Utils::FileSaver saver(Utils::FilePath::fromString(fileName), QIODevice::Text);
|
||||
FileSaver saver(filePath, QIODevice::Text);
|
||||
saver.write(contents.toUtf8());
|
||||
if (!saver.finalize(this))
|
||||
saveLog();
|
||||
|
@@ -106,6 +106,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ModelEditor {
|
||||
namespace Internal {
|
||||
|
||||
@@ -595,10 +597,10 @@ void ModelEditor::exportToImage(bool selectedElements)
|
||||
#ifndef QT_NO_SVG
|
||||
filter += tr(";;SVG (*.svg)");
|
||||
#endif // QT_NO_SVG
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
Core::ICore::dialogParent(),
|
||||
QString fileName = FileUtils::getSaveFilePath(
|
||||
nullptr,
|
||||
selectedElements ? tr("Export Selected Elements") : tr("Export Diagram"),
|
||||
d->lastExportDirPath, filter);
|
||||
FilePath::fromString(d->lastExportDirPath), filter).toString();
|
||||
if (!fileName.isEmpty()) {
|
||||
qmt::DocumentController *documentController = d->document->documentController();
|
||||
qmt::DiagramSceneModel *sceneModel = documentController->diagramsManager()->diagramSceneModel(diagram);
|
||||
|
@@ -841,11 +841,9 @@ void PerforcePluginPrivate::annotateCurrentFile()
|
||||
|
||||
void PerforcePluginPrivate::annotateFile()
|
||||
{
|
||||
const QString file = QFileDialog::getOpenFileName(ICore::dialogParent(), tr("p4 annotate"));
|
||||
if (!file.isEmpty()) {
|
||||
const QFileInfo fi(file);
|
||||
annotate(FilePath::fromString(fi.absolutePath()), fi.fileName());
|
||||
}
|
||||
const FilePath filePath = FileUtils::getOpenFilePath(nullptr, tr("p4 annotate"));
|
||||
if (!filePath.isEmpty())
|
||||
annotate(filePath.parentDir(), filePath.fileName());
|
||||
}
|
||||
|
||||
void PerforcePluginPrivate::annotate(const FilePath &workingDir,
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
using namespace Utils;
|
||||
|
||||
namespace PerfProfiler {
|
||||
namespace Internal {
|
||||
@@ -75,23 +75,23 @@ ProjectExplorer::Kit *PerfLoadDialog::kit() const
|
||||
|
||||
void PerfLoadDialog::on_browseTraceFileButton_pressed()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(
|
||||
this, tr("Choose Perf Trace"), QString(),
|
||||
tr("Perf traces (*%1)").arg(QLatin1String(Constants::TraceFileExtension)));
|
||||
if (fileName.isEmpty())
|
||||
FilePath filePath = FileUtils::getOpenFilePath(
|
||||
this, tr("Choose Perf Trace"), {},
|
||||
tr("Perf traces (*%1)").arg(Constants::TraceFileExtension));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
ui->traceFileLineEdit->setText(fileName);
|
||||
ui->traceFileLineEdit->setText(filePath.toUserOutput());
|
||||
}
|
||||
|
||||
void PerfLoadDialog::on_browseExecutableDirButton_pressed()
|
||||
{
|
||||
QString fileName = QFileDialog::getExistingDirectory(
|
||||
FilePath filePath = FileUtils::getExistingDirectory(
|
||||
this, tr("Choose Directory of Executable"));
|
||||
if (fileName.isEmpty())
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
ui->executableDirLineEdit->setText(fileName);
|
||||
ui->executableDirLineEdit->setText(filePath.toUserOutput());
|
||||
}
|
||||
|
||||
void PerfLoadDialog::chooseDefaults()
|
||||
|
@@ -619,10 +619,9 @@ void PerfProfilerTool::showLoadTraceDialog()
|
||||
{
|
||||
m_perspective.select();
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
ICore::dialogParent(), tr("Load Trace File"),
|
||||
"", tr("Trace File (*.ptq)"));
|
||||
if (filename.isEmpty())
|
||||
FilePath filePath = FileUtils::getOpenFilePath(nullptr, tr("Load Trace File"),
|
||||
{}, tr("Trace File (*.ptq)"));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
startLoading();
|
||||
@@ -632,23 +631,22 @@ void PerfProfilerTool::showLoadTraceDialog()
|
||||
const Kit *kit = target ? target->kit() : nullptr;
|
||||
populateFileFinder(currentProject, kit);
|
||||
|
||||
m_traceManager->loadFromTraceFile(filename);
|
||||
m_traceManager->loadFromTraceFile(filePath.toString());
|
||||
}
|
||||
|
||||
void PerfProfilerTool::showSaveTraceDialog()
|
||||
{
|
||||
m_perspective.select();
|
||||
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
ICore::dialogParent(), tr("Save Trace File"),
|
||||
"", tr("Trace File (*.ptq)"));
|
||||
if (filename.isEmpty())
|
||||
FilePath filePath = FileUtils::getSaveFilePath(nullptr, tr("Save Trace File"),
|
||||
{}, tr("Trace File (*.ptq)"));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
if (!filename.endsWith(".ptq"))
|
||||
filename += ".ptq";
|
||||
if (!filePath.endsWith(".ptq"))
|
||||
filePath = filePath + ".ptq";
|
||||
|
||||
setToolActionsEnabled(false);
|
||||
m_traceManager->saveToTraceFile(filename);
|
||||
m_traceManager->saveToTraceFile(filePath.toString());
|
||||
}
|
||||
|
||||
void PerfProfilerTool::setAggregated(bool aggregated)
|
||||
|
@@ -102,10 +102,9 @@ public:
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(addButton, &QPushButton::clicked, this, [this] {
|
||||
const QString dir = QDir::toNativeSeparators(
|
||||
QFileDialog::getExistingDirectory(this, tr("Choose Directory")));
|
||||
const FilePath dir = FileUtils::getExistingDirectory(this, tr("Choose Directory"));
|
||||
if (!dir.isEmpty())
|
||||
addPath(dir);
|
||||
addPath(dir.toUserOutput());
|
||||
});
|
||||
connect(removeButton, &QPushButton::clicked, this, [this] {
|
||||
const QList<QTreeWidgetItem *> selected = m_view.selectedItems();
|
||||
@@ -486,12 +485,11 @@ void EnvironmentWidget::unsetEnvironmentButtonClicked()
|
||||
void EnvironmentWidget::amendPathList(Utils::NameValueItem::Operation op)
|
||||
{
|
||||
const QString varName = d->m_model->indexToVariable(d->m_environmentView->currentIndex());
|
||||
const QString dir = QDir::toNativeSeparators(
|
||||
QFileDialog::getExistingDirectory(this, tr("Choose Directory")));
|
||||
const FilePath dir = FileUtils::getExistingDirectory(this, tr("Choose Directory"));
|
||||
if (dir.isEmpty())
|
||||
return;
|
||||
Utils::NameValueItems changes = d->m_model->userChanges();
|
||||
changes.append({varName, dir, op});
|
||||
changes.append({varName, dir.toUserOutput(), op});
|
||||
d->m_model->setUserChanges(changes);
|
||||
}
|
||||
|
||||
|
@@ -308,17 +308,17 @@ void KitManagerConfigWidget::setIcon()
|
||||
action->setIconVisibleInMenu(true);
|
||||
}
|
||||
iconMenu.addSeparator();
|
||||
iconMenu.addAction(Utils::PathChooser::browseButtonLabel(), [this] {
|
||||
const QString path = QFileDialog::getOpenFileName(this, tr("Select Icon"),
|
||||
m_modifiedKit->iconPath().toString(),
|
||||
iconMenu.addAction(PathChooser::browseButtonLabel(), [this] {
|
||||
const FilePath path = FileUtils::getOpenFilePath(this, tr("Select Icon"),
|
||||
m_modifiedKit->iconPath(),
|
||||
tr("Images (*.png *.xpm *.jpg)"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
const QIcon icon(path);
|
||||
const QIcon icon(path.toString());
|
||||
if (icon.isNull())
|
||||
return;
|
||||
m_iconButton->setIcon(icon);
|
||||
m_modifiedKit->setIconPath(Utils::FilePath::fromString(path));
|
||||
m_modifiedKit->setIconPath(path);
|
||||
emit dirty();
|
||||
});
|
||||
iconMenu.exec(mapToGlobal(m_iconButton->pos()));
|
||||
|
@@ -49,6 +49,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
@@ -73,14 +75,14 @@ ParseIssuesDialog::ParseIssuesDialog(QWidget *parent) : QDialog(parent), d(new P
|
||||
|
||||
const auto loadFileButton = new QPushButton(tr("Load from File..."));
|
||||
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())
|
||||
return;
|
||||
QFile file(filePath);
|
||||
QFile file(filePath.toString());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::critical(this, tr("Could Not Open File"),
|
||||
tr("Could not open file: \"%1\": %2")
|
||||
.arg(filePath, file.errorString()));
|
||||
.arg(filePath.toUserOutput(), file.errorString()));
|
||||
return;
|
||||
}
|
||||
d->compileOutputEdit.setPlainText(QString::fromLocal8Bit(file.readAll()));
|
||||
|
@@ -586,11 +586,11 @@ void QmlProfilerTool::showErrorDialog(const QString &error)
|
||||
errorDialog->show();
|
||||
}
|
||||
|
||||
void saveLastTraceFile(const QString &filename)
|
||||
static void saveLastTraceFile(const FilePath &filePath)
|
||||
{
|
||||
QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings();
|
||||
if (filename != settings->lastTraceFile.value()) {
|
||||
settings->lastTraceFile.setValue(filename);
|
||||
if (filePath != settings->lastTraceFile.filePath()) {
|
||||
settings->lastTraceFile.setFilePath(filePath);
|
||||
settings->writeGlobalSettings();
|
||||
}
|
||||
}
|
||||
@@ -599,16 +599,16 @@ void QmlProfilerTool::showSaveDialog()
|
||||
{
|
||||
QLatin1String tFile(QtdFileExtension);
|
||||
QLatin1String zFile(QztFileExtension);
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
ICore::dialogParent(), tr("Save QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile.value(),
|
||||
FilePath filePath = FileUtils::getSaveFilePath(
|
||||
nullptr, tr("Save QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile.filePath(),
|
||||
tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
|
||||
if (!filename.isEmpty()) {
|
||||
if (!filename.endsWith(zFile) && !filename.endsWith(tFile))
|
||||
filename += zFile;
|
||||
saveLastTraceFile(filename);
|
||||
if (!filePath.isEmpty()) {
|
||||
if (!filePath.endsWith(zFile) && !filePath.endsWith(tFile))
|
||||
filePath = filePath + zFile;
|
||||
saveLastTraceFile(filePath);
|
||||
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,
|
||||
Core::ProgressManager::ShowInApplicationIcon);
|
||||
}
|
||||
@@ -623,18 +623,18 @@ void QmlProfilerTool::showLoadDialog()
|
||||
|
||||
QLatin1String tFile(QtdFileExtension);
|
||||
QLatin1String zFile(QztFileExtension);
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
ICore::dialogParent(), tr("Load QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile.value(),
|
||||
FilePath filePath = FileUtils::getOpenFilePath(
|
||||
nullptr, tr("Load QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile.filePath(),
|
||||
tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile));
|
||||
|
||||
if (!filename.isEmpty()) {
|
||||
saveLastTraceFile(filename);
|
||||
if (!filePath.isEmpty()) {
|
||||
saveLastTraceFile(filePath);
|
||||
Debugger::enableMainWindow(false);
|
||||
connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged,
|
||||
this, &QmlProfilerTool::setRecordedFeatures);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -35,9 +35,10 @@
|
||||
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
@@ -107,16 +108,16 @@ void QnxSettingsWidget::addConfiguration()
|
||||
{
|
||||
QString filter;
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
filter = QLatin1String("*.bat file");
|
||||
filter = "*.bat file";
|
||||
else
|
||||
filter = QLatin1String("*.sh file");
|
||||
filter = "*.sh file";
|
||||
|
||||
const QString envFile = QFileDialog::getOpenFileName(this, tr("Select QNX Environment File"),
|
||||
QString(), filter);
|
||||
const FilePath envFile = FileUtils::getOpenFilePath(this, tr("Select QNX Environment File"),
|
||||
{}, filter);
|
||||
if (envFile.isEmpty())
|
||||
return;
|
||||
|
||||
QnxConfiguration *config = new QnxConfiguration(Utils::FilePath::fromString(envFile));
|
||||
QnxConfiguration *config = new QnxConfiguration(envFile);
|
||||
if (m_qnxConfigManager->configurations().contains(config)
|
||||
|| !config->isValid()) {
|
||||
QMessageBox::warning(Core::ICore::dialogParent(),
|
||||
|
@@ -58,7 +58,6 @@
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QTextBrowser>
|
||||
@@ -602,13 +601,12 @@ QtOptionsPageWidget::~QtOptionsPageWidget()
|
||||
|
||||
void QtOptionsPageWidget::addQtDir()
|
||||
{
|
||||
FilePath qtVersion = FilePath::fromString(
|
||||
QFileDialog::getOpenFileName(this,
|
||||
FilePath qtVersion = FileUtils::getOpenFilePath(this,
|
||||
tr("Select a qmake Executable"),
|
||||
QString(),
|
||||
{},
|
||||
BuildableHelperLibrary::filterForQmakeFileDialog(),
|
||||
0,
|
||||
QFileDialog::DontResolveSymlinks));
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
if (qtVersion.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -672,14 +670,13 @@ void QtOptionsPageWidget::removeQtDir()
|
||||
void QtOptionsPageWidget::editPath()
|
||||
{
|
||||
BaseQtVersion *current = currentVersion();
|
||||
QString dir = currentVersion()->qmakeFilePath().toFileInfo().absolutePath();
|
||||
FilePath qtVersion = FilePath::fromString(
|
||||
QFileDialog::getOpenFileName(this,
|
||||
FilePath qtVersion =
|
||||
FileUtils::getOpenFilePath(this,
|
||||
tr("Select a qmake Executable"),
|
||||
dir,
|
||||
current->qmakeFilePath().absolutePath(),
|
||||
BuildableHelperLibrary::filterForQmakeFileDialog(),
|
||||
nullptr,
|
||||
QFileDialog::DontResolveSymlinks));
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
if (qtVersion.isEmpty())
|
||||
return;
|
||||
BaseQtVersion *version = QtVersionFactory::createQtVersionFromQMakePath(qtVersion);
|
||||
|
@@ -31,9 +31,8 @@
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
@@ -50,14 +49,13 @@ using namespace Internal;
|
||||
PublicKeyDeploymentDialog *PublicKeyDeploymentDialog::createDialog(
|
||||
const IDevice::ConstPtr &deviceConfig, QWidget *parent)
|
||||
{
|
||||
const QString &dir = QFileInfo(deviceConfig->sshParameters().privateKeyFile).path();
|
||||
const QString publicKeyFileName = QFileDialog::getOpenFileName(parent
|
||||
? parent : Core::ICore::dialogParent(),
|
||||
const FilePath dir = FilePath::fromString(deviceConfig->sshParameters().privateKeyFile).parentDir();
|
||||
const FilePath publicKeyFileName = FileUtils::getOpenFilePath(nullptr,
|
||||
tr("Choose Public Key File"), dir,
|
||||
tr("Public Key Files (*.pub);;All Files (*)"));
|
||||
if (publicKeyFileName.isEmpty())
|
||||
return nullptr;
|
||||
return new PublicKeyDeploymentDialog(deviceConfig, publicKeyFileName, parent);
|
||||
return new PublicKeyDeploymentDialog(deviceConfig, publicKeyFileName.toString(), parent);
|
||||
}
|
||||
|
||||
PublicKeyDeploymentDialog::PublicKeyDeploymentDialog(const IDevice::ConstPtr &deviceConfig,
|
||||
|
@@ -426,11 +426,11 @@ void MainWidget::exportToImage()
|
||||
.arg(lastFolder)
|
||||
.arg(suggestedFileName)
|
||||
.arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"));
|
||||
const QString selectedFileName = QFileDialog::getSaveFileName(this,
|
||||
const FilePath filePath = FileUtils::getSaveFilePath(this,
|
||||
tr("Export Canvas to Image"),
|
||||
suggestedFileName,
|
||||
FilePath::fromString(suggestedFileName),
|
||||
saveImageFileFilter());
|
||||
if (!selectedFileName.isEmpty()) {
|
||||
if (!filePath.isEmpty()) {
|
||||
const QRectF r = view->scene()->itemsBoundingRect();
|
||||
QImage image(r.size().toSize(), QImage::Format_ARGB32);
|
||||
image.fill(QColor(0xef, 0xef, 0xef));
|
||||
@@ -438,9 +438,8 @@ void MainWidget::exportToImage()
|
||||
QPainter painter(&image);
|
||||
view->scene()->render(&painter, QRectF(), r);
|
||||
|
||||
if (image.save(selectedFileName)) {
|
||||
s->setValue(Constants::C_SETTINGS_LASTEXPORTFOLDER,
|
||||
QFileInfo(selectedFileName).absolutePath());
|
||||
if (image.save(filePath.toString())) {
|
||||
s->setValue(Constants::C_SETTINGS_LASTEXPORTFOLDER, filePath.parentDir().toString());
|
||||
} else {
|
||||
QMessageBox::warning(this, tr("Export Failed"), tr("Could not export to image."));
|
||||
}
|
||||
@@ -455,18 +454,17 @@ void MainWidget::saveScreenShot()
|
||||
|
||||
QSettings *s = Core::ICore::settings();
|
||||
const QString documentsLocation = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||
const QString lastFolder =
|
||||
s->value(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER, documentsLocation).toString();
|
||||
const QString filename = QFileDialog::getSaveFileName(this,
|
||||
const FilePath lastFolder = FilePath::fromVariant(
|
||||
s->value(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER, documentsLocation));
|
||||
const FilePath filePath = FileUtils::getSaveFilePath(this,
|
||||
tr("Save Screenshot"),
|
||||
lastFolder + "/scxml_screenshot.png",
|
||||
lastFolder / "scxml_screenshot.png",
|
||||
saveImageFileFilter());
|
||||
if (!filename.isEmpty()) {
|
||||
if (!filePath.isEmpty()) {
|
||||
const QImage image = view->view()->grabView();
|
||||
|
||||
if (image.save(filename)) {
|
||||
s->setValue(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER,
|
||||
QFileInfo(filename).absolutePath());
|
||||
if (image.save(filePath.toString())) {
|
||||
s->setValue(Constants::C_SETTINGS_LASTSAVESCREENSHOTFOLDER, filePath.parentDir().toVariant());
|
||||
} else {
|
||||
QMessageBox::warning(this, tr("Saving Failed"), tr("Could not save the screenshot."));
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
using namespace ScxmlEditor::OutputPane;
|
||||
using namespace Utils;
|
||||
|
||||
ErrorWidget::ErrorWidget(QWidget *parent)
|
||||
: OutputPane(parent)
|
||||
@@ -203,13 +204,13 @@ QString ErrorWidget::modifyExportedValue(const QString &val)
|
||||
|
||||
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())
|
||||
return;
|
||||
|
||||
QFile file(fileName);
|
||||
QFile file(fileName.toString());
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
using namespace TextEditor;
|
||||
using namespace Utils;
|
||||
|
||||
namespace TextEditor {
|
||||
namespace Internal {
|
||||
@@ -150,8 +151,7 @@ CodeStyleDialog::~CodeStyleDialog()
|
||||
delete m_codeStyle;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // Internal
|
||||
|
||||
CodeStyleSelectorWidget::CodeStyleSelectorWidget(ICodeStylePreferencesFactory *factory, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -326,9 +326,9 @@ void CodeStyleSelectorWidget::slotRemoveClicked()
|
||||
|
||||
void CodeStyleSelectorWidget::slotImportClicked()
|
||||
{
|
||||
const Utils::FilePath fileName =
|
||||
Utils::FilePath::fromString(QFileDialog::getOpenFileName(this, tr("Import Code Style"), QString(),
|
||||
tr("Code styles (*.xml);;All files (*)")));
|
||||
const FilePath fileName =
|
||||
FileUtils::getOpenFilePath(this, tr("Import Code Style"), {},
|
||||
tr("Code styles (*.xml);;All files (*)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
CodeStylePool *codeStylePool = m_codeStyle->delegatingPool();
|
||||
ICodeStylePreferences *importedStyle = codeStylePool->importCodeStyle(fileName);
|
||||
@@ -343,12 +343,12 @@ void CodeStyleSelectorWidget::slotImportClicked()
|
||||
void CodeStyleSelectorWidget::slotExportClicked()
|
||||
{
|
||||
ICodeStylePreferences *currentPreferences = m_codeStyle->currentPreferences();
|
||||
const QString fileName = QFileDialog::getSaveFileName(this, tr("Export Code Style"),
|
||||
QString::fromUtf8(currentPreferences->id() + ".xml"),
|
||||
const FilePath filePath = FileUtils::getSaveFilePath(this, tr("Export Code Style"),
|
||||
FilePath::fromString(QString::fromUtf8(currentPreferences->id() + ".xml")),
|
||||
tr("Code styles (*.xml);;All files (*)"));
|
||||
if (!fileName.isEmpty()) {
|
||||
if (!filePath.isEmpty()) {
|
||||
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;
|
||||
}
|
||||
|
||||
} // TextEditor
|
||||
|
||||
#include "codestyleselectorwidget.moc"
|
||||
|
@@ -874,17 +874,18 @@ void CallgrindToolPrivate::slotRequestDump()
|
||||
|
||||
void CallgrindToolPrivate::loadExternalLogFile()
|
||||
{
|
||||
const QString filePath = QFileDialog::getOpenFileName(
|
||||
ICore::dialogParent(),
|
||||
const FilePath filePath = FileUtils::getOpenFilePath(
|
||||
nullptr,
|
||||
CallgrindTool::tr("Open Callgrind Log File"),
|
||||
QString(),
|
||||
{},
|
||||
CallgrindTool::tr("Callgrind Output (callgrind.out*);;All Files (*)"));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
QFile logFile(filePath);
|
||||
QFile logFile(filePath.toString());
|
||||
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::requestPopup();
|
||||
return;
|
||||
|
@@ -1017,16 +1017,16 @@ void MemcheckToolPrivate::loadShowXmlLogFile(const QString &filePath, const QStr
|
||||
|
||||
void MemcheckToolPrivate::loadExternalXmlLogFile()
|
||||
{
|
||||
const QString filePath = QFileDialog::getOpenFileName(
|
||||
ICore::dialogParent(),
|
||||
const FilePath filePath = FileUtils::getOpenFilePath(
|
||||
nullptr,
|
||||
MemcheckTool::tr("Open Memcheck XML Log File"),
|
||||
QString(),
|
||||
{},
|
||||
MemcheckTool::tr("XML Files (*.xml);;All Files (*)"));
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
m_exitMsg.clear();
|
||||
loadXmlLogFile(filePath);
|
||||
loadXmlLogFile(filePath.toString());
|
||||
}
|
||||
|
||||
void MemcheckToolPrivate::loadXmlLogFile(const QString &filePath)
|
||||
|
@@ -38,7 +38,6 @@
|
||||
#include <valgrind/xmlprotocol/error.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QListView>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
@@ -104,16 +103,16 @@ void SuppressionAspectPrivate::slotAddSuppression()
|
||||
{
|
||||
ValgrindGlobalSettings *conf = ValgrindGlobalSettings::instance();
|
||||
QTC_ASSERT(conf, return);
|
||||
const QStringList files =
|
||||
QFileDialog::getOpenFileNames(Core::ICore::dialogParent(),
|
||||
const FilePaths files =
|
||||
FileUtils::getOpenFilePaths(nullptr,
|
||||
tr("Valgrind Suppression Files"),
|
||||
conf->lastSuppressionDirectory.value(),
|
||||
conf->lastSuppressionDirectory.filePath(),
|
||||
tr("Valgrind Suppression File (*.supp);;All Files (*)"));
|
||||
//dialog.setHistory(conf->lastSuppressionDialogHistory());
|
||||
if (!files.isEmpty()) {
|
||||
for (const QString &file : files)
|
||||
m_model.appendRow(new QStandardItem(file));
|
||||
conf->lastSuppressionDirectory.setValue(QFileInfo(files.at(0)).absolutePath());
|
||||
for (const FilePath &file : files)
|
||||
m_model.appendRow(new QStandardItem(file.toString()));
|
||||
conf->lastSuppressionDirectory.setFilePath(files.at(0).absolutePath());
|
||||
//conf->setLastSuppressionDialogHistory(dialog.history());
|
||||
if (!isGlobal)
|
||||
q->apply();
|
||||
|
Reference in New Issue
Block a user