QmakeProjectManager: Proliferate FilePath use

Change-Id: Ife92980a179a2872e4dd5083b60bbd0561be55bc
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2021-09-30 13:09:18 +02:00
parent 9e38e710d3
commit 2373c69e47
5 changed files with 93 additions and 89 deletions

View File

@@ -38,8 +38,8 @@
#include <QTextStream>
#include <QVBoxLayout>
using namespace QmakeProjectManager;
using namespace QmakeProjectManager::Internal;
namespace QmakeProjectManager {
namespace Internal {
const char qt_file_dialog_filter_reg_exp[] =
"^(.*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$";
@@ -79,8 +79,8 @@ static bool validateLibraryPath(const Utils::FilePath &filePath,
return false;
}
AddLibraryWizard::AddLibraryWizard(const QString &fileName, QWidget *parent) :
Utils::Wizard(parent), m_proFile(fileName)
AddLibraryWizard::AddLibraryWizard(const Utils::FilePath &proFile, QWidget *parent) :
Utils::Wizard(parent), m_proFile(proFile)
{
setWindowTitle(tr("Add Library"));
m_libraryTypePage = new LibraryTypePage(this);
@@ -93,7 +93,7 @@ AddLibraryWizard::AddLibraryWizard(const QString &fileName, QWidget *parent) :
AddLibraryWizard::~AddLibraryWizard() = default;
QString AddLibraryWizard::proFile() const
Utils::FilePath AddLibraryWizard::proFile() const
{
return m_proFile;
}
@@ -294,10 +294,9 @@ SummaryPage::SummaryPage(AddLibraryWizard *parent)
void SummaryPage::initializePage()
{
m_snippet = m_libraryWizard->snippet();
QFileInfo fi(m_libraryWizard->proFile());
m_summaryLabel->setText(
tr("The following snippet will be added to the<br><b>%1</b> file:")
.arg(fi.fileName()));
.arg(m_libraryWizard->proFile().fileName()));
QString richSnippet;
{
QTextStream str(&richSnippet);
@@ -316,3 +315,6 @@ QString SummaryPage::snippet() const
{
return m_snippet;
}
} // Internal
} // QmakeProjectManager

View File

@@ -76,20 +76,18 @@ public:
Q_DECLARE_FLAGS(Platforms, Platform)
explicit AddLibraryWizard(const QString &fileName, QWidget *parent = nullptr);
explicit AddLibraryWizard(const Utils::FilePath &proFile, QWidget *parent = nullptr);
~AddLibraryWizard() override;
LibraryKind libraryKind() const;
QString proFile() const;
Utils::FilePath proFile() const;
QString snippet() const;
signals:
private:
LibraryTypePage *m_libraryTypePage = nullptr;
DetailsPage *m_detailsPage = nullptr;
SummaryPage *m_summaryPage = nullptr;
QString m_proFile;
Utils::FilePath m_proFile;
};
class LibraryTypePage : public QWizardPage

View File

@@ -40,22 +40,24 @@
#include <QTextStream>
using namespace ProjectExplorer;
using namespace QmakeProjectManager;
using namespace QmakeProjectManager::Internal;
using namespace Utils;
namespace QmakeProjectManager {
namespace Internal {
static void fillLibraryPlatformTypes(QComboBox *comboBox)
{
comboBox->clear();
comboBox->addItem("Windows (*.lib lib*.a)", int(Utils::OsTypeWindows));
comboBox->addItem("Linux (lib*.so lib*.a)", int(Utils::OsTypeLinux));
comboBox->addItem("macOS (*.dylib *.a *.framework)", int(Utils::OsTypeMac));
const int currentIndex = comboBox->findData(int(Utils::HostOsInfo::hostOs()));
comboBox->addItem("Windows (*.lib lib*.a)", int(OsTypeWindows));
comboBox->addItem("Linux (lib*.so lib*.a)", int(OsTypeLinux));
comboBox->addItem("macOS (*.dylib *.a *.framework)", int(OsTypeMac));
const int currentIndex = comboBox->findData(int(HostOsInfo::hostOs()));
comboBox->setCurrentIndex(std::max(0, currentIndex));
}
LibraryDetailsController::LibraryDetailsController(
Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile, QObject *parent) :
const FilePath &proFile, QObject *parent) :
QObject(parent),
m_proFile(proFile),
m_libraryDetailsWidget(libraryDetails)
@@ -65,12 +67,12 @@ LibraryDetailsController::LibraryDetailsController(
setLinkageGroupVisible(true);
setMacLibraryGroupVisible(true);
setPackageLineEditVisible(false);
const bool isMacOs = libraryPlatformType() == Utils::OsTypeMac;
const bool isWindows = libraryPlatformType() == Utils::OsTypeWindows;
const bool isMacOs = libraryPlatformType() == OsTypeMac;
const bool isWindows = libraryPlatformType() == OsTypeWindows;
setMacLibraryRadiosVisible(!isMacOs);
setLinkageRadiosVisible(isWindows);
connect(m_libraryDetailsWidget->includePathChooser, &Utils::PathChooser::rawPathChanged,
connect(m_libraryDetailsWidget->includePathChooser, &PathChooser::rawPathChanged,
this, &LibraryDetailsController::slotIncludePathChanged);
connect(m_libraryDetailsWidget->frameworkRadio, &QAbstractButton::clicked,
this, &LibraryDetailsController::slotMacLibraryTypeChanged);
@@ -108,9 +110,9 @@ AddLibraryWizard::MacLibraryType LibraryDetailsController::macLibraryType() cons
return m_macLibraryType;
}
Utils::OsType LibraryDetailsController::libraryPlatformType() const
OsType LibraryDetailsController::libraryPlatformType() const
{
return Utils::OsType(m_libraryDetailsWidget->libraryTypeComboBox->currentData().value<int>());
return OsType(m_libraryDetailsWidget->libraryTypeComboBox->currentData().value<int>());
}
QString LibraryDetailsController::libraryPlatformFilter() const
@@ -198,7 +200,7 @@ void LibraryDetailsController::updateGui()
// UGLY HACK END
}
QString LibraryDetailsController::proFile() const
FilePath LibraryDetailsController::proFile() const
{
return m_proFile;
}
@@ -397,7 +399,7 @@ static QString smartQuote(const QString &aString)
{
// The OS type is not important in that case, but use always the same
// in order not to generate different quoting depending on host platform
return Utils::ProcessArgs::quoteArg(aString, Utils::OsTypeLinux);
return ProcessArgs::quoteArg(aString, OsTypeLinux);
}
static QString appendSeparator(const QString &aString)
@@ -622,15 +624,15 @@ static QString generatePreTargetDepsSnippet(AddLibraryWizard::Platforms platform
NonInternalLibraryDetailsController::NonInternalLibraryDetailsController(
Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile, QObject *parent) :
const FilePath &proFile, QObject *parent) :
LibraryDetailsController(libraryDetails, proFile, parent)
{
setLibraryComboBoxVisible(false);
setLibraryPathChooserVisible(true);
connect(libraryDetailsWidget()->libraryPathChooser, &Utils::PathChooser::validChanged,
connect(libraryDetailsWidget()->libraryPathChooser, &PathChooser::validChanged,
this, &LibraryDetailsController::completeChanged);
connect(libraryDetailsWidget()->libraryPathChooser, &Utils::PathChooser::rawPathChanged,
connect(libraryDetailsWidget()->libraryPathChooser, &PathChooser::rawPathChanged,
this, &NonInternalLibraryDetailsController::slotLibraryPathChanged);
connect(libraryDetailsWidget()->removeSuffixCheckBox, &QAbstractButton::toggled,
this, &NonInternalLibraryDetailsController::slotRemoveSuffixChanged);
@@ -646,7 +648,7 @@ NonInternalLibraryDetailsController::NonInternalLibraryDetailsController(
AddLibraryWizard::LinkageType NonInternalLibraryDetailsController::suggestedLinkageType() const
{
AddLibraryWizard::LinkageType type = AddLibraryWizard::NoLinkage;
if (libraryPlatformType() != Utils::OsTypeWindows) {
if (libraryPlatformType() != OsTypeWindows) {
if (libraryDetailsWidget()->libraryPathChooser->isValid()) {
QFileInfo fi(libraryDetailsWidget()->libraryPathChooser->filePath().toString());
if (fi.suffix() == QLatin1String("a"))
@@ -661,7 +663,7 @@ AddLibraryWizard::LinkageType NonInternalLibraryDetailsController::suggestedLink
AddLibraryWizard::MacLibraryType NonInternalLibraryDetailsController::suggestedMacLibraryType() const
{
AddLibraryWizard::MacLibraryType type = AddLibraryWizard::NoLibraryType;
if (libraryPlatformType() == Utils::OsTypeMac) {
if (libraryPlatformType() == OsTypeMac) {
if (libraryDetailsWidget()->libraryPathChooser->isValid()) {
QFileInfo fi(libraryDetailsWidget()->libraryPathChooser->filePath().toString());
if (fi.suffix() == QLatin1String("framework"))
@@ -695,7 +697,7 @@ QString NonInternalLibraryDetailsController::suggestedIncludePath() const
void NonInternalLibraryDetailsController::updateWindowsOptionsEnablement()
{
bool ena = platforms() & (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform);
if (libraryPlatformType() == Utils::OsTypeWindows) {
if (libraryPlatformType() == OsTypeWindows) {
libraryDetailsWidget()->addSuffixCheckBox->setEnabled(ena);
ena = true;
}
@@ -732,10 +734,10 @@ void NonInternalLibraryDetailsController::slotRemoveSuffixChanged(bool ena)
void NonInternalLibraryDetailsController::handleLibraryTypeChange()
{
libraryDetailsWidget()->libraryPathChooser->setPromptDialogFilter(libraryPlatformFilter());
const bool isMacOs = libraryPlatformType() == Utils::OsTypeMac;
const bool isWindows = libraryPlatformType() == Utils::OsTypeWindows;
libraryDetailsWidget()->libraryPathChooser->setExpectedKind(isMacOs ? Utils::PathChooser::Any
: Utils::PathChooser::File);
const bool isMacOs = libraryPlatformType() == OsTypeMac;
const bool isWindows = libraryPlatformType() == OsTypeWindows;
libraryDetailsWidget()->libraryPathChooser->setExpectedKind(isMacOs ? PathChooser::Any
: PathChooser::File);
setMacLibraryRadiosVisible(!isMacOs);
setLinkageRadiosVisible(isWindows);
setRemoveSuffixVisible(isWindows);
@@ -752,7 +754,7 @@ void NonInternalLibraryDetailsController::slotLibraryTypeChanged()
void NonInternalLibraryDetailsController::handleLibraryPathChange()
{
if (libraryPlatformType() == Utils::OsTypeWindows) {
if (libraryPlatformType() == OsTypeWindows) {
bool subfoldersEnabled = true;
bool removeSuffixEnabled = true;
if (libraryDetailsWidget()->libraryPathChooser->isValid()) {
@@ -797,13 +799,13 @@ QString NonInternalLibraryDetailsController::snippet() const
QString libName;
const bool removeSuffix = isWindowsGroupVisible()
&& libraryDetailsWidget()->removeSuffixCheckBox->isChecked();
if (libraryPlatformType() == Utils::OsTypeWindows) {
if (libraryPlatformType() == OsTypeWindows) {
libName = fi.completeBaseName();
if (removeSuffix && !libName.isEmpty()) // remove last letter which needs to be "d"
libName = libName.left(libName.size() - 1);
if (fi.completeSuffix() == QLatin1String("a")) // the mingw lib case
libName = libName.mid(3); // cut the "lib" prefix
} else if (libraryPlatformType() == Utils::OsTypeMac) {
} else if (libraryPlatformType() == OsTypeMac) {
if (macLibraryType() == AddLibraryWizard::FrameworkType)
libName = fi.completeBaseName();
else
@@ -817,7 +819,7 @@ QString NonInternalLibraryDetailsController::snippet() const
if (isWindowsGroupVisible()) {
// when we are on Win but we don't generate the code for Win
// we still need to remove "debug" or "release" subfolder
const bool useSubfoldersCondition = (libraryPlatformType() == Utils::OsTypeWindows)
const bool useSubfoldersCondition = (libraryPlatformType() == OsTypeWindows)
? true : platforms() & (AddLibraryWizard::WindowsMinGWPlatform
| AddLibraryWizard::WindowsMSVCPlatform);
if (useSubfoldersCondition)
@@ -829,10 +831,10 @@ QString NonInternalLibraryDetailsController::snippet() const
QString targetRelativePath;
QString includeRelativePath;
if (isIncludePathVisible()) { // generate also the path to lib
QFileInfo pfi(proFile());
QFileInfo pfi = proFile().toFileInfo();
QDir pdir = pfi.absoluteDir();
QString absoluteLibraryPath = fi.absolutePath();
if (libraryPlatformType() == Utils::OsTypeWindows && useSubfolders) { // drop last subfolder which needs to be "debug" or "release"
if (libraryPlatformType() == OsTypeWindows && useSubfolders) { // drop last subfolder which needs to be "debug" or "release"
QFileInfo libfi(absoluteLibraryPath);
absoluteLibraryPath = libfi.absolutePath();
}
@@ -862,7 +864,7 @@ QString NonInternalLibraryDetailsController::snippet() const
PackageLibraryDetailsController::PackageLibraryDetailsController(
Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile, QObject *parent)
const FilePath &proFile, QObject *parent)
: NonInternalLibraryDetailsController(libraryDetails, proFile, parent)
{
setPlatformsVisible(false);
@@ -897,11 +899,11 @@ QString PackageLibraryDetailsController::snippet() const
bool PackageLibraryDetailsController::isLinkPackageGenerated() const
{
const Project *project = SessionManager::projectForFile(Utils::FilePath::fromString(proFile()));
const Project *project = SessionManager::projectForFile(proFile());
if (!project)
return false;
const ProjectNode *projectNode = project->findNodeForBuildKey(proFile());
const ProjectNode *projectNode = project->findNodeForBuildKey(proFile().toString());
if (!projectNode)
return false;
@@ -921,7 +923,7 @@ bool PackageLibraryDetailsController::isLinkPackageGenerated() const
SystemLibraryDetailsController::SystemLibraryDetailsController(
Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile, QObject *parent)
const FilePath &proFile, QObject *parent)
: NonInternalLibraryDetailsController(libraryDetails, proFile, parent)
{
setIncludePathVisible(false);
@@ -934,7 +936,7 @@ SystemLibraryDetailsController::SystemLibraryDetailsController(
ExternalLibraryDetailsController::ExternalLibraryDetailsController(
Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile, QObject *parent)
const FilePath &proFile, QObject *parent)
: NonInternalLibraryDetailsController(libraryDetails, proFile, parent)
{
setIncludePathVisible(true);
@@ -949,7 +951,7 @@ void ExternalLibraryDetailsController::updateWindowsOptionsEnablement()
bool subfoldersEnabled = true;
bool removeSuffixEnabled = true;
if (libraryPlatformType() == Utils::OsTypeWindows
if (libraryPlatformType() == OsTypeWindows
&& libraryDetailsWidget()->libraryPathChooser->isValid()) {
QFileInfo fi(libraryDetailsWidget()->libraryPathChooser->filePath().toString());
QFileInfo dfi(fi.absolutePath());
@@ -968,9 +970,8 @@ void ExternalLibraryDetailsController::updateWindowsOptionsEnablement()
/////////////
InternalLibraryDetailsController::InternalLibraryDetailsController(
Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile, QObject *parent)
InternalLibraryDetailsController::InternalLibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
const FilePath &proFile, QObject *parent)
: LibraryDetailsController(libraryDetails, proFile, parent)
{
setLinkageRadiosVisible(false);
@@ -980,7 +981,7 @@ InternalLibraryDetailsController::InternalLibraryDetailsController(
setWindowsGroupVisible(true);
setRemoveSuffixVisible(false);
if (Utils::HostOsInfo::isWindowsHost())
if (HostOsInfo::isWindowsHost())
libraryDetailsWidget()->useSubfoldersCheckBox->setEnabled(true);
connect(libraryDetailsWidget()->libraryComboBox,
@@ -1034,7 +1035,7 @@ QString InternalLibraryDetailsController::suggestedIncludePath() const
void InternalLibraryDetailsController::updateWindowsOptionsEnablement()
{
if (Utils::HostOsInfo::isWindowsHost())
if (HostOsInfo::isWindowsHost())
libraryDetailsWidget()->addSuffixCheckBox->setEnabled(true);
libraryDetailsWidget()->winGroupBox->setEnabled(platforms()
& (AddLibraryWizard::WindowsMinGWPlatform | AddLibraryWizard::WindowsMSVCPlatform));
@@ -1047,7 +1048,7 @@ void InternalLibraryDetailsController::updateProFile()
libraryDetailsWidget()->libraryComboBox->clear();
const QmakeProject *project
= dynamic_cast<QmakeProject *>(SessionManager::projectForFile(Utils::FilePath::fromString(proFile())));
= dynamic_cast<QmakeProject *>(SessionManager::projectForFile(proFile()));
if (!project)
return;
@@ -1091,7 +1092,7 @@ void InternalLibraryDetailsController::slotCurrentLibraryChanged()
currentIndex, Qt::ToolTipRole).toString());
QmakeProFile *proFile = m_proFiles.at(currentIndex);
const QStringList configVar = proFile->variableValue(Variable::Config);
if (Utils::HostOsInfo::isWindowsHost()) {
if (HostOsInfo::isWindowsHost()) {
bool useSubfolders = false;
if (configVar.contains(QLatin1String("debug_and_release"))
&& configVar.contains(QLatin1String("debug_and_release_target")))
@@ -1130,10 +1131,10 @@ QString InternalLibraryDetailsController::snippet() const
// relative path for the project for which we insert the snippet,
// it's relative to the root project
const QString proRelavitePath = rootDir.relativeFilePath(proFile());
const QString proRelavitePath = rootDir.relativeFilePath(proFile().toString());
// project for which we insert the snippet
const Project *project = SessionManager::projectForFile(Utils::FilePath::fromString(proFile()));
const Project *project = SessionManager::projectForFile(proFile());
// the build directory of the active build configuration
QDir rootBuildDir = rootDir; // If the project is unconfigured use the project dir
@@ -1147,7 +1148,7 @@ QString InternalLibraryDetailsController::snippet() const
QDir projectBuildDir(pfi.absolutePath());
// current project node from combobox
QFileInfo fi(proFile());
QFileInfo fi = proFile().toFileInfo();
QDir projectSrcDir(fi.absolutePath());
// project node which we want to link against
@@ -1175,3 +1176,6 @@ QString InternalLibraryDetailsController::snippet() const
useSubfolders, addSuffix);
return snippetMessage;
}
} // Internal
} // QmakeProjectManager

View File

@@ -38,7 +38,7 @@ class LibraryDetailsController : public QObject
Q_OBJECT
public:
explicit LibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile,
const Utils::FilePath &proFile,
QObject *parent = nullptr);
virtual bool isComplete() const = 0;
virtual QString snippet() const = 0;
@@ -54,7 +54,7 @@ protected:
AddLibraryWizard::MacLibraryType macLibraryType() const;
Utils::OsType libraryPlatformType() const;
QString libraryPlatformFilter() const;
QString proFile() const;
Utils::FilePath proFile() const;
bool isIncludePathChanged() const;
bool guiSignalsIgnored() const;
@@ -99,7 +99,7 @@ private:
AddLibraryWizard::LinkageType m_linkageType = AddLibraryWizard::NoLinkage;
AddLibraryWizard::MacLibraryType m_macLibraryType = AddLibraryWizard::NoLibraryType;
QString m_proFile;
Utils::FilePath m_proFile;
bool m_ignoreGuiSignals = false;
bool m_includePathChanged = false;
@@ -118,7 +118,7 @@ class NonInternalLibraryDetailsController : public LibraryDetailsController
Q_OBJECT
public:
explicit NonInternalLibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile,
const Utils::FilePath &proFile,
QObject *parent = nullptr);
bool isComplete() const override;
QString snippet() const override;
@@ -143,7 +143,7 @@ class PackageLibraryDetailsController : public NonInternalLibraryDetailsControll
Q_OBJECT
public:
explicit PackageLibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile,
const Utils::FilePath &proFile,
QObject *parent = nullptr);
bool isComplete() const override;
QString snippet() const override;
@@ -160,7 +160,7 @@ class SystemLibraryDetailsController : public NonInternalLibraryDetailsControlle
Q_OBJECT
public:
explicit SystemLibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile,
const Utils::FilePath &proFile,
QObject *parent = nullptr);
protected:
void updateWindowsOptionsEnablement() override final {
@@ -173,7 +173,7 @@ class ExternalLibraryDetailsController : public NonInternalLibraryDetailsControl
Q_OBJECT
public:
explicit ExternalLibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile,
const Utils::FilePath &proFile,
QObject *parent = nullptr);
protected:
void updateWindowsOptionsEnablement() override final;
@@ -184,7 +184,7 @@ class InternalLibraryDetailsController : public LibraryDetailsController
Q_OBJECT
public:
explicit InternalLibraryDetailsController(Ui::LibraryDetailsWidget *libraryDetails,
const QString &proFile,
const Utils::FilePath &proFile,
QObject *parent = nullptr);
bool isComplete() const override;
QString snippet() const override;

View File

@@ -73,6 +73,7 @@
using namespace Core;
using namespace ProjectExplorer;
using namespace TextEditor;
using namespace Utils;
namespace QmakeProjectManager {
namespace Internal {
@@ -90,7 +91,7 @@ public:
void buildStateChanged(Project *pro);
void updateBuildFileAction();
void disableBuildFileMenus();
void enableBuildFileMenus(const Utils::FilePath &file);
void enableBuildFileMenus(const FilePath &file);
Core::Context projectContext;
@@ -114,15 +115,15 @@ public:
QAction *m_runQMakeAction = nullptr;
QAction *m_runQMakeActionContextMenu = nullptr;
Utils::ParameterAction *m_buildSubProjectContextMenu = nullptr;
ParameterAction *m_buildSubProjectContextMenu = nullptr;
QAction *m_subProjectRebuildSeparator = nullptr;
QAction *m_rebuildSubProjectContextMenu = nullptr;
QAction *m_cleanSubProjectContextMenu = nullptr;
QAction *m_buildFileContextMenu = nullptr;
Utils::ParameterAction *m_buildSubProjectAction = nullptr;
ParameterAction *m_buildSubProjectAction = nullptr;
QAction *m_rebuildSubProjectAction = nullptr;
QAction *m_cleanSubProjectAction = nullptr;
Utils::ParameterAction *m_buildFileAction = nullptr;
ParameterAction *m_buildFileAction = nullptr;
QAction *m_addLibraryAction = nullptr;
QAction *m_addLibraryActionContextMenu = nullptr;
@@ -140,7 +141,7 @@ public:
void buildFile();
void handleSubDirContextMenu(QmakeBuildSystem::Action action, bool isFileBuild);
void addLibraryImpl(const QString &fileName, TextEditor::BaseTextEditor *editor);
void addLibraryImpl(const FilePath &filePath, TextEditor::BaseTextEditor *editor);
void runQMakeImpl(Project *p, ProjectExplorer::Node *node);
};
@@ -181,8 +182,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
//register actions
Command *command = nullptr;
d->m_buildSubProjectContextMenu = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
d->m_buildSubProjectContextMenu = new ParameterAction(tr("Build"), tr("Build \"%1\""),
ParameterAction::AlwaysEnabled/*handled manually*/,
this);
command = ActionManager::registerAction(d->m_buildSubProjectContextMenu, Constants::BUILDSUBDIRCONTEXTMENU, projectContext);
command->setAttribute(Command::CA_Hide);
@@ -227,8 +228,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
connect(d->m_buildFileContextMenu, &QAction::triggered,
d, &QmakeProjectManagerPluginPrivate::buildFileContextMenu);
d->m_buildSubProjectAction = new Utils::ParameterAction(tr("Build &Subproject"), tr("Build &Subproject \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this);
d->m_buildSubProjectAction = new ParameterAction(tr("Build &Subproject"), tr("Build &Subproject \"%1\""),
ParameterAction::AlwaysEnabled, this);
command = ActionManager::registerAction(d->m_buildSubProjectAction, Constants::BUILDSUBDIR, projectContext);
command->setAttribute(Command::CA_Hide);
command->setAttribute(Command::CA_UpdateText);
@@ -244,8 +245,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
connect(d->m_runQMakeAction, &QAction::triggered,
d, &QmakeProjectManagerPluginPrivate::runQMake);
d->m_rebuildSubProjectAction = new QAction(Icons::REBUILD.icon(), tr("Rebuild"),
this);
d->m_rebuildSubProjectAction = new QAction(ProjectExplorer::Icons::REBUILD.icon(), tr("Rebuild"), this);
d->m_rebuildSubProjectAction->setWhatsThis(tr("Rebuild Subproject"));
command = ActionManager::registerAction(d->m_rebuildSubProjectAction, Constants::REBUILDSUBDIR, projectContext);
command->setAttribute(Command::CA_Hide);
@@ -265,8 +265,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
connect(d->m_cleanSubProjectAction, &QAction::triggered,
d, &QmakeProjectManagerPluginPrivate::cleanSubDirContextMenu);
d->m_buildFileAction = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""),
Utils::ParameterAction::AlwaysEnabled, this);
d->m_buildFileAction = new ParameterAction(tr("Build File"), tr("Build File \"%1\""),
ParameterAction::AlwaysEnabled, this);
command = ActionManager::registerAction(d->m_buildFileAction, Constants::BUILDFILE, projectContext);
command->setAttribute(Command::CA_Hide);
command->setAttribute(Command::CA_UpdateText);
@@ -361,33 +361,33 @@ static QmakeProFileNode *buildableFileProFile(Node *node)
void QmakeProjectManagerPluginPrivate::addLibrary()
{
if (auto editor = qobject_cast<BaseTextEditor *>(Core::EditorManager::currentEditor()))
addLibraryImpl(editor->document()->filePath().toString(), editor);
addLibraryImpl(editor->document()->filePath(), editor);
}
void QmakeProjectManagerPluginPrivate::addLibraryContextMenu()
{
QString projectPath;
FilePath projectPath;
Node *node = ProjectTree::currentNode();
if (ContainerNode *cn = node->asContainerNode())
projectPath = cn->project()->projectFilePath().toString();
projectPath = cn->project()->projectFilePath();
else if (dynamic_cast<QmakeProFileNode *>(node))
projectPath = node->filePath().toString();
projectPath = node->filePath();
addLibraryImpl(projectPath, nullptr);
}
void QmakeProjectManagerPluginPrivate::addLibraryImpl(const QString &fileName, BaseTextEditor *editor)
void QmakeProjectManagerPluginPrivate::addLibraryImpl(const FilePath &filePath, BaseTextEditor *editor)
{
if (fileName.isEmpty())
if (filePath.isEmpty())
return;
Internal::AddLibraryWizard wizard(fileName, Core::ICore::dialogParent());
Internal::AddLibraryWizard wizard(filePath, Core::ICore::dialogParent());
if (wizard.exec() != QDialog::Accepted)
return;
if (!editor)
editor = qobject_cast<BaseTextEditor *>(Core::EditorManager::openEditor(fileName,
editor = qobject_cast<BaseTextEditor *>(Core::EditorManager::openEditor(filePath,
Constants::PROFILE_EDITOR_ID, Core::EditorManager::DoNotMakeVisible));
if (!editor)
return;
@@ -448,7 +448,7 @@ void QmakeProjectManagerPluginPrivate::buildFile()
if (!currentDocument)
return;
const Utils::FilePath file = currentDocument->filePath();
const FilePath file = currentDocument->filePath();
Node *n = ProjectTree::nodeForFile(file);
FileNode *node = n ? n->asFileNode() : nullptr;
if (!node)
@@ -599,7 +599,7 @@ void QmakeProjectManagerPluginPrivate::disableBuildFileMenus()
m_buildFileContextMenu->setEnabled(false);
}
void QmakeProjectManagerPluginPrivate::enableBuildFileMenus(const Utils::FilePath &file)
void QmakeProjectManagerPluginPrivate::enableBuildFileMenus(const FilePath &file)
{
bool visible = false;
bool enabled = false;