diff options
Diffstat (limited to 'src/plugins/qmakeprojectmanager/wizards')
12 files changed, 13 insertions, 1408 deletions
diff --git a/src/plugins/qmakeprojectmanager/wizards/guiappwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/guiappwizard.cpp deleted file mode 100644 index 08b7514a8e..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/guiappwizard.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "guiappwizard.h" - -#include "guiappwizarddialog.h" - -#include <projectexplorer/projectexplorerconstants.h> -#include <cpptools/abstracteditorsupport.h> -#include <designer/cpp/formclasswizardparameters.h> -#include <extensionsystem/pluginmanager.h> -#include <extensionsystem/invoker.h> -#include <qtsupport/qtsupportconstants.h> - -#include <utils/fileutils.h> - -#include <QCoreApplication> -#include <QDir> -#include <QTextStream> -#include <QSharedPointer> - -static const char mainSourceFileC[] = "main"; -static const char mainSourceShowC[] = " w.show();\n"; -static const char mainSourceMobilityShowC[] = " w.show();\n"; - -static const char mainWindowUiContentsC[] = -"\n <widget class=\"QMenuBar\" name=\"menuBar\" />" -"\n <widget class=\"QToolBar\" name=\"mainToolBar\" />" -"\n <widget class=\"QWidget\" name=\"centralWidget\" />" -"\n <widget class=\"QStatusBar\" name=\"statusBar\" />"; -static const char mainWindowMobileUiContentsC[] = -"\n <widget class=\"QWidget\" name=\"centralWidget\" />"; - -static const char *baseClassesC[] = {"QMainWindow", "QWidget", "QDialog"}; - -static inline QStringList baseClasses() -{ - QStringList rc; - for (auto baseClass : baseClassesC) - rc.push_back(QLatin1String(baseClass)); - return rc; -} - -namespace QmakeProjectManager { -namespace Internal { - -GuiAppWizard::GuiAppWizard() -{ - setId("C.Qt4Gui"); - setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY)); - setDisplayCategory(QCoreApplication::translate("ProjectExplorer", - ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY)); - setDisplayName(tr("Qt Widgets Application")); - setDescription(tr("Creates a Qt application for the desktop. " - "Includes a Qt Designer-based main window.\n\n" - "Preselects a desktop Qt for building the application if available.")); - setIcon(QIcon(QLatin1String(":/wizards/images/gui.png"))); - setRequiredFeatures({QtSupport::Constants::FEATURE_QWIDGETS}); -} - -Core::BaseFileWizard *GuiAppWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const -{ - GuiAppWizardDialog *dialog = new GuiAppWizardDialog(this, displayName(), icon(), parent, parameters); - dialog->setProjectName(GuiAppWizardDialog::uniqueProjectName(parameters.defaultPath())); - // Order! suffixes first to generate files correctly - dialog->setLowerCaseFiles(QtWizard::lowerCaseFiles()); - dialog->setSuffixes(headerSuffix(), sourceSuffix(), formSuffix()); - dialog->setBaseClasses(baseClasses()); - return dialog; -} - -// Use the class generation utils provided by the designer plugin -static inline bool generateFormClass(const GuiAppParameters ¶ms, - const Core::GeneratedFile &uiFile, - Core::GeneratedFile *formSource, - Core::GeneratedFile *formHeader, - QString *errorMessage) -{ - // Retrieve parameters from settings - Designer::FormClassWizardParameters fp; - fp.uiTemplate = uiFile.contents(); - fp.uiFile = uiFile.path(); - fp.className = params.className; - fp.sourceFile = params.sourceFileName; - fp.headerFile = params.headerFileName; - fp.usePragmaOnce = CppTools::AbstractEditorSupport::usePragmaOnce(); - QString headerContents; - QString sourceContents; - // Invoke code generation service of Qt Designer plugin. - if (QObject *codeGenerator = ExtensionSystem::PluginManager::getObjectByName("QtDesignerFormClassCodeGenerator")) { - const QVariant code = ExtensionSystem::invoke<QVariant>(codeGenerator, "generateFormClassCode", fp); - if (code.type() == QVariant::List) { - const QVariantList vl = code.toList(); - if (vl.size() == 2) { - headerContents = vl.front().toString(); - sourceContents = vl.back().toString(); - } - } - } - if (headerContents.isEmpty() || sourceContents.isEmpty()) { - *errorMessage = QString::fromLatin1("Failed to obtain Designer plugin code generation service."); - return false; - } - - formHeader->setContents(headerContents); - formSource->setContents(sourceContents); - return true; -} - -Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w, - QString *errorMessage) const -{ - const auto *dialog = qobject_cast<const GuiAppWizardDialog *>(w); - const QtProjectParameters projectParams = dialog->projectParameters(); - const QString projectPath = projectParams.projectPath(); - const GuiAppParameters params = dialog->parameters(); - - // Generate file names. Note that the path for the project files is the - // newly generated project directory. - const QString templatePath = templateDir(); - // Create files: main source - QString contents; - const QString mainSourceFileName = buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix()); - Core::GeneratedFile mainSource(mainSourceFileName); - if (!parametrizeTemplate(templatePath, QLatin1String("main.cpp"), params, &contents, errorMessage)) - return Core::GeneratedFiles(); - mainSource.setContents(CppTools::AbstractEditorSupport::licenseTemplate(mainSourceFileName) - + contents); - // Create files: form source with or without form - const QString formSourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix()); - const QString formHeaderName = buildFileName(projectPath, params.headerFileName, headerSuffix()); - Core::GeneratedFile formSource(formSourceFileName); - Core::GeneratedFile formHeader(formHeaderName); - formSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute); - - QSharedPointer<Core::GeneratedFile> form; - if (params.designerForm) { - // Create files: form - const QString formName = buildFileName(projectPath, params.formFileName, formSuffix()); - form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName)); - if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage)) - return Core::GeneratedFiles(); - form->setContents(contents); - if (!generateFormClass(params, *form, &formSource, &formHeader, errorMessage)) - return Core::GeneratedFiles(); - } else { - const QString formSourceTemplate = QLatin1String("mywidget.cpp"); - if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage)) - return Core::GeneratedFiles(); - formSource.setContents(CppTools::AbstractEditorSupport::licenseTemplate(formSourceFileName) - + contents); - // Create files: form header - const QString formHeaderTemplate = QLatin1String("mywidget.h"); - if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage)) - return Core::GeneratedFiles(); - formHeader.setContents(CppTools::AbstractEditorSupport::licenseTemplate(formHeaderName) - + contents); - } - // Create files: profile - const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix()); - Core::GeneratedFile profile(profileName); - profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); - contents.clear(); - { - QTextStream proStr(&contents); - QtProjectParameters::writeProFileHeader(proStr); - projectParams.writeProFile(proStr); - proStr << "\nCONFIG += c++11"; // ensure all Qt5 versions can handle the source - proStr << "\n\nSOURCES +=" - << " \\\n " << Utils::FileName::fromString(mainSourceFileName).fileName() - << " \\\n " << Utils::FileName::fromString(formSource.path()).fileName() - << "\n\nHEADERS +=" - << " \\\n " << Utils::FileName::fromString(formHeader.path()).fileName(); - if (params.designerForm) - proStr << "\n\nFORMS +=" - << " \\\n " << Utils::FileName::fromString(form->path()).fileName(); - if (params.isMobileApplication) { - proStr << "\n\nCONFIG += mobility" - << "\nMOBILITY = " - << "\n"; - } - proStr << "\n\n# Default rules for deployment.\n" - "qnx: target.path = /tmp/$${TARGET}/bin\n" - "else: unix:!android: target.path = /opt/$${TARGET}/bin\n" - "!isEmpty(target.path): INSTALLS += target\n"; - } - profile.setContents(contents); - // List - Core::GeneratedFiles rc; - rc << mainSource << formSource << formHeader; - if (params.designerForm) - rc << *form; - rc << profile; - return rc; -} - -bool GuiAppWizard::parametrizeTemplate(const QString &templatePath, const QString &templateName, - const GuiAppParameters ¶ms, - QString *target, QString *errorMessage) -{ - const QString fileName = templatePath + QLatin1Char('/') + templateName; - Utils::FileReader reader; - if (!reader.fetch(fileName, QIODevice::Text, errorMessage)) - return false; - QString contents = QString::fromUtf8(reader.data()); - contents.replace(QLatin1String("%QAPP_INCLUDE%"), QLatin1String("QApplication")); - contents.replace(QLatin1String("%INCLUDE%"), params.headerFileName); - contents.replace(QLatin1String("%CLASS%"), params.className); - contents.replace(QLatin1String("%BASECLASS%"), params.baseClassName); - contents.replace(QLatin1String("%WIDGET_HEIGHT%"), QString::number(params.widgetHeight)); - contents.replace(QLatin1String("%WIDGET_WIDTH%"), QString::number(params.widgetWidth)); - if (params.isMobileApplication) - contents.replace(QLatin1String("%SHOWMETHOD%"), QString::fromLatin1(mainSourceMobilityShowC)); - else - contents.replace(QLatin1String("%SHOWMETHOD%"), QString::fromLatin1(mainSourceShowC)); - - // Replace include guards with pragma once - if (CppTools::AbstractEditorSupport::usePragmaOnce()) { - contents.replace(QLatin1String("#ifndef %PRE_DEF%\n#define %PRE_DEF%"), "#pragma once"); - contents.replace(QLatin1String("#endif // %PRE_DEF%\n"), QString()); - } - - const QChar dot = QLatin1Char('.'); - - QString preDef = params.headerFileName.toUpper(); - preDef.replace(dot, QLatin1Char('_')); - contents.replace(QLatin1String("%PRE_DEF%"), preDef); - - const QString uiFileName = params.formFileName; - QString uiHdr = QLatin1String("ui_"); - uiHdr += uiFileName.left(uiFileName.indexOf(dot)); - uiHdr += QLatin1String(".h"); - - contents.replace(QLatin1String("%UI_HDR%"), uiHdr); - if (params.baseClassName == QLatin1String("QMainWindow")) { - if (params.isMobileApplication) - contents.replace(QLatin1String("%CENTRAL_WIDGET%"), QLatin1String(mainWindowMobileUiContentsC)); - else - contents.replace(QLatin1String("%CENTRAL_WIDGET%"), QLatin1String(mainWindowUiContentsC)); - } else { - contents.remove(QLatin1String("%CENTRAL_WIDGET%")); - } - *target = contents; - return true; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/guiappwizard.h b/src/plugins/qmakeprojectmanager/wizards/guiappwizard.h deleted file mode 100644 index 31eb5b7ce9..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/guiappwizard.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtwizard.h" - -namespace QmakeProjectManager { -namespace Internal { - -struct GuiAppParameters; - -class GuiAppWizard : public QtWizard -{ - Q_OBJECT - -public: - GuiAppWizard(); - -private: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const override; - - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; - -private: - static bool parametrizeTemplate(const QString &templatePath, const QString &templateName, - const GuiAppParameters ¶ms, - QString *target, QString *errorMessage); -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/guiappwizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/guiappwizarddialog.cpp deleted file mode 100644 index 5f12fdc41a..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/guiappwizarddialog.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "guiappwizarddialog.h" - -#include "filespage.h" - -#include <projectexplorer/projectexplorerconstants.h> - -namespace QmakeProjectManager { -namespace Internal { - -GuiAppWizardDialog::GuiAppWizardDialog(const Core::BaseFileWizardFactory *factory, - const QString &templateName, - const QIcon &icon, QWidget *parent, - const Core::WizardDialogParameters ¶meters) : - BaseQmakeProjectWizardDialog(factory, false, parent, parameters), - m_filesPage(new FilesPage) -{ - setWindowIcon(icon); - setWindowTitle(templateName); - setSelectedModules(QLatin1String("core gui"), true); - - setIntroDescription(tr("This wizard generates a Qt Widgets Application " - "project. The application derives by default from QApplication " - "and includes an empty widget.")); - - addModulesPage(); - if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) - addTargetSetupPage(); - - m_filesPage->setFormInputCheckable(true); - m_filesPage->setClassTypeComboVisible(false); - addPage(m_filesPage); - - addExtensionPages(extensionPages()); -} - -void GuiAppWizardDialog::setBaseClasses(const QStringList &baseClasses) -{ - m_filesPage->setBaseClassChoices(baseClasses); - if (!baseClasses.empty()) - m_filesPage->setBaseClassName(baseClasses.front()); -} - -void GuiAppWizardDialog::setSuffixes(const QString &header, const QString &source, const QString &form) -{ - m_filesPage->setSuffixes(header, source, form); -} - -void GuiAppWizardDialog::setLowerCaseFiles(bool l) -{ - m_filesPage->setLowerCaseFiles(l); -} - -QtProjectParameters GuiAppWizardDialog::projectParameters() const -{ - QtProjectParameters rc; - rc.type = QtProjectParameters::GuiApp; - rc.flags |= QtProjectParameters::WidgetsRequiredFlag; - rc.fileName = projectName(); - rc.path = path(); - rc.selectedModules = selectedModulesList(); - rc.deselectedModules = deselectedModulesList(); - return rc; -} - -GuiAppParameters GuiAppWizardDialog::parameters() const -{ - GuiAppParameters rc; - rc.className = m_filesPage->className(); - rc.baseClassName = m_filesPage->baseClassName(); - rc.sourceFileName = m_filesPage->sourceFileName(); - rc.headerFileName = m_filesPage->headerFileName(); - rc.formFileName = m_filesPage->formFileName(); - rc.designerForm = m_filesPage->formInputChecked(); - if (isQtPlatformSelected("Android.Device.Type")) { // FIXME: Is this really necessary? - rc.isMobileApplication = true; - rc.widgetWidth = 800; - rc.widgetHeight = 480; - } - return rc; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/guiappwizarddialog.h b/src/plugins/qmakeprojectmanager/wizards/guiappwizarddialog.h deleted file mode 100644 index b12644e123..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/guiappwizarddialog.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtwizard.h" - -namespace QmakeProjectManager { -namespace Internal { - -struct QtProjectParameters; -class FilesPage; - -// Additional parameters required besides QtProjectParameters -struct GuiAppParameters -{ - QString className; - QString baseClassName; - QString sourceFileName; - QString headerFileName; - QString formFileName; - int widgetWidth = 400; - int widgetHeight = 300; - bool designerForm = true; - bool isMobileApplication = false; -}; - -class GuiAppWizardDialog : public BaseQmakeProjectWizardDialog -{ - Q_OBJECT - -public: - explicit GuiAppWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, - const QIcon &icon, - QWidget *parent, - const Core::WizardDialogParameters ¶meters); - - void setBaseClasses(const QStringList &baseClasses); - void setSuffixes(const QString &header, const QString &source, const QString &form); - void setLowerCaseFiles(bool l); - - QtProjectParameters projectParameters() const; - GuiAppParameters parameters() const; - -private: - FilesPage *m_filesPage; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/libraryparameters.cpp b/src/plugins/qmakeprojectmanager/wizards/libraryparameters.cpp deleted file mode 100644 index 83217ce2bf..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/libraryparameters.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "libraryparameters.h" -#include "librarywizarddialog.h" - -#include <utils/codegeneration.h> -#include <utils/qtcassert.h> - -#include <QTextStream> -#include <QStringList> - -#include <cstring> - -namespace QmakeProjectManager { -namespace Internal { - -void LibraryParameters::generateCode(QtProjectParameters:: Type t, - const QString &headerName, - const QString &sharedHeader, - const QString &exportMacro, - const QString &pluginJsonFileName, - int indentation, - bool usePragmaOnce, - QString *header, - QString *source) const -{ - QTextStream headerStr(header); - - const QString indent = QString(indentation, QLatin1Char(' ')); - - // Do we have namespaces? - QStringList namespaceList = className.split(QLatin1String("::")); - if (namespaceList.empty()) // Paranoia! - return; - - const QString unqualifiedClassName = namespaceList.takeLast(); - - // 1) Header - const QString guard = Utils::headerGuard(headerFileName, namespaceList); - if (usePragmaOnce) - headerStr << "#pragma once\n\n"; - else - headerStr << "#ifndef " << guard << "\n#define " << guard << "\n\n"; - - if (!sharedHeader.isEmpty()) - Utils::writeIncludeFileDirective(sharedHeader, false, headerStr); - - // include base class header - if (!baseClassName.isEmpty()) { - Utils::writeIncludeFileDirective(baseClassName, true, headerStr); - headerStr << '\n'; - } - - const QString namespaceIndent = Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr); - - // Class declaraction - if (!namespaceIndent.isEmpty()) - headerStr << '\n'; - headerStr << namespaceIndent << "class "; - if (t == QtProjectParameters::SharedLibrary && !exportMacro.isEmpty()) - headerStr << exportMacro << ' '; - - headerStr << unqualifiedClassName; - if (!baseClassName.isEmpty()) - headerStr << " : public " << baseClassName; - headerStr << "\n{\n"; - - // Is this a QObject (plugin) - const bool inheritsQObject = t == QtProjectParameters::QtPlugin; - if (inheritsQObject) - headerStr << namespaceIndent << indent << "Q_OBJECT\n"; - if (t == QtProjectParameters::QtPlugin) { // Write Qt plugin meta data. - const QString qt5InterfaceName = LibraryWizardDialog::pluginInterface(baseClassName); - QTC_CHECK(!qt5InterfaceName.isEmpty()); - headerStr << namespaceIndent << indent << "Q_PLUGIN_METADATA(IID \"" - << qt5InterfaceName << '"'; - QTC_CHECK(!pluginJsonFileName.isEmpty()); - headerStr << " FILE \"" << pluginJsonFileName << '"'; - headerStr << ")\n"; - } - - headerStr << namespaceIndent << "\npublic:\n"; - if (inheritsQObject) { - headerStr << namespaceIndent << indent << "explicit " << unqualifiedClassName - << "(QObject *parent = nullptr);\n"; - } else { - headerStr << namespaceIndent << indent << unqualifiedClassName << "();\n"; - } - if (!pureVirtualSignatures.empty()) { - headerStr << "\nprivate:\n"; - for (const QString &signature : pureVirtualSignatures) - headerStr << namespaceIndent << indent << signature << " override;\n"; - } - headerStr << namespaceIndent << "};\n"; - if (!namespaceIndent.isEmpty()) - headerStr << '\n'; - Utils::writeClosingNameSpaces(namespaceList, indent, headerStr); - if (!usePragmaOnce) - headerStr << "\n#endif // " << guard << '\n'; - - /// 2) Source - QTextStream sourceStr(source); - - Utils::writeIncludeFileDirective(headerName, false, sourceStr); - sourceStr << '\n'; - - Utils::writeOpeningNameSpaces(namespaceList, indent, sourceStr); - if (!namespaceIndent.isEmpty()) - sourceStr << '\n'; - - // Constructor - sourceStr << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName; - if (inheritsQObject) { - sourceStr << "(QObject *parent) :\n" - << namespaceIndent << indent << baseClassName << "(parent)\n"; - } else { - sourceStr << "()\n"; - } - sourceStr << namespaceIndent << "{\n" << namespaceIndent << "}\n"; - for (const QString &signature : pureVirtualSignatures) { - const int parenIndex = signature.indexOf('('); - QTC_ASSERT(parenIndex != -1, continue); - int nameIndex = -1; - for (int i = parenIndex - 1; i > 0; --i) { - if (!signature.at(i).isLetterOrNumber()) { - nameIndex = i + 1; - break; - } - } - QTC_ASSERT(nameIndex != -1, continue); - sourceStr << '\n' << namespaceIndent << signature.left(nameIndex); - if (!std::strchr("&* ", signature.at(nameIndex - 1).toLatin1())) - sourceStr << ' '; - sourceStr << unqualifiedClassName << "::" << signature.mid(nameIndex) << '\n'; - sourceStr << namespaceIndent << "{\n" << indent - << "static_assert(false, \"You need to implement this function\");\n}\n"; - } - - Utils::writeClosingNameSpaces(namespaceList, indent, sourceStr); -} - -QString LibraryParameters::generateSharedHeader(const QString &globalHeaderFileName, - const QString &projectTarget, - const QString &exportMacro, - bool usePragmaOnce) -{ - QString contents; - if (usePragmaOnce) { - contents += "#pragma once\n"; - } else { - contents += "#ifndef " + Utils::headerGuard(globalHeaderFileName) + "\n"; - contents += "#define " + Utils::headerGuard(globalHeaderFileName) + "\n"; - } - contents += "\n"; - contents += "#include <QtCore/qglobal.h>\n"; - contents += "\n"; - contents += "#if defined(" + QtProjectParameters::libraryMacro(projectTarget) + ")\n"; - contents += "# define " + exportMacro + " Q_DECL_EXPORT\n"; - contents += "#else\n"; - contents += "# define " + exportMacro + " Q_DECL_IMPORT\n"; - contents += "#endif\n"; - contents += "\n"; - if (!usePragmaOnce) - contents += "#endif // " + Utils::headerGuard(globalHeaderFileName) + '\n'; - - return contents; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/libraryparameters.h b/src/plugins/qmakeprojectmanager/wizards/libraryparameters.h deleted file mode 100644 index 4fe7d00dc1..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/libraryparameters.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtprojectparameters.h" - -#include <QStringList> - -namespace QmakeProjectManager { -namespace Internal { - -// Additional parameters required besides QtProjectParameters for creating -// libraries -struct LibraryParameters { - - // generate class - void generateCode(QtProjectParameters:: Type t, - const QString &headerName, - const QString &sharedHeader, - const QString &exportMacro, - const QString &pluginJsonFileName, - int indentation, - bool usePragmaOnce, - QString *header, - QString *source) const; - - // Generate the code of the shared header containing the export macro - static QString generateSharedHeader(const QString &globalHeaderFileName, - const QString &projectTarget, - const QString &exportMacro, - bool usePragmaOnce); - - QString className; - QString baseClassName; - QString sourceFileName; - QString headerFileName; - QStringList pureVirtualSignatures; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/librarywizard.cpp b/src/plugins/qmakeprojectmanager/wizards/librarywizard.cpp deleted file mode 100644 index 239fec9c3f..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/librarywizard.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "librarywizard.h" -#include "librarywizarddialog.h" - -#include <cpptools/abstracteditorsupport.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <qtsupport/qtsupportconstants.h> - -#include <utils/fileutils.h> - -#include <QTextStream> -#include <QCoreApplication> - -static const char sharedHeaderPostfixC[] = "_global"; - -namespace QmakeProjectManager { -namespace Internal { - -LibraryWizard::LibraryWizard() -{ - setId("H.Qt4Library"); - setCategory(QLatin1String(ProjectExplorer::Constants::LIBRARIES_WIZARD_CATEGORY)); - setDisplayCategory(QCoreApplication::translate("ProjectExplorer", - ProjectExplorer::Constants::LIBRARIES_WIZARD_CATEGORY_DISPLAY)); - setDisplayName(tr("C++ Library")); - setDescription(tr("Creates a C++ library based on qmake. This can be used to create:<ul>" - "<li>a shared C++ library for use with <tt>QPluginLoader</tt> and runtime (Plugins)</li>" - "<li>a shared or static C++ library for use with another project at linktime</li></ul>")); - setIcon(QIcon(QLatin1String(":/wizards/images/lib.png"))); - setRequiredFeatures({QtSupport::Constants::FEATURE_QT_PREFIX}); -} - -Core::BaseFileWizard *LibraryWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const -{ - LibraryWizardDialog *dialog = new LibraryWizardDialog(this, displayName(), icon(), parent, parameters); - dialog->setLowerCaseFiles(QtWizard::lowerCaseFiles()); - dialog->setProjectName(LibraryWizardDialog::uniqueProjectName(parameters.defaultPath())); - dialog->setSuffixes(headerSuffix(), sourceSuffix(), formSuffix()); - return dialog; -} - -static void writeLinuxProFile(QTextStream &str, const QtProjectParameters ¶ms) -{ - str << "\n" - "unix {\n"; - if (!params.targetDirectory.isEmpty()) - str << " target.path = " << params.targetDirectory << '\n'; - else - str << " target.path = /usr/lib\n"; - str << " INSTALLS += target\n" - "}\n"; -} - -Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w, - QString *errorMessage) const -{ - Q_UNUSED(errorMessage) - const auto *dialog = qobject_cast<const LibraryWizardDialog *>(w); - const QtProjectParameters projectParams = dialog->parameters(); - const QString projectPath = projectParams.projectPath(); - const LibraryParameters params = dialog->libraryParameters(); - const bool usePragmaOnce = CppTools::AbstractEditorSupport::usePragmaOnce(); - - const QString sharedLibExportMacro = QtProjectParameters::exportMacro(projectParams.fileName); - - Core::GeneratedFiles rc; - // Class header + source - const QString sourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix()); - Core::GeneratedFile source(sourceFileName); - source.setAttributes(Core::GeneratedFile::OpenEditorAttribute); - - const QString headerFileFullName = buildFileName(projectPath, params.headerFileName, headerSuffix()); - const QString headerFileName = Utils::FileName::fromString(headerFileFullName).fileName(); - QString pluginJsonFileFullName; - QString pluginJsonFileName; - if (projectParams.type == QtProjectParameters::QtPlugin) { - pluginJsonFileFullName = buildFileName(projectPath, projectParams.fileName, QLatin1String("json")); - pluginJsonFileName = Utils::FileName::fromString(pluginJsonFileFullName).fileName(); - } - - Core::GeneratedFile header(headerFileFullName); - - // Create files: global header for shared libs - QString globalHeaderFileName; - if (projectParams.type == QtProjectParameters::SharedLibrary) { - const QString globalHeaderName = buildFileName(projectPath, projectParams.fileName.toLower() + QLatin1String(sharedHeaderPostfixC), headerSuffix()); - Core::GeneratedFile globalHeader(globalHeaderName); - globalHeaderFileName = Utils::FileName::fromString(globalHeader.path()).fileName(); - globalHeader.setContents(CppTools::AbstractEditorSupport::licenseTemplate(globalHeaderFileName) - + LibraryParameters::generateSharedHeader(globalHeaderFileName, projectParams.fileName, sharedLibExportMacro, usePragmaOnce)); - rc.push_back(globalHeader); - } - - // Generate code - QString headerContents, sourceContents; - params.generateCode(projectParams.type, headerFileName, - globalHeaderFileName, sharedLibExportMacro, pluginJsonFileName, - /* indentation*/ 4, usePragmaOnce, &headerContents, &sourceContents); - - source.setContents(CppTools::AbstractEditorSupport::licenseTemplate(sourceFileName, params.className) - + sourceContents); - header.setContents(CppTools::AbstractEditorSupport::licenseTemplate(headerFileFullName, params.className) - + headerContents); - rc.push_back(source); - rc.push_back(header); - // Create files: profile - const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix()); - Core::GeneratedFile profile(profileName); - profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); - QString profileContents; - { - QTextStream proStr(&profileContents); - QtProjectParameters::writeProFileHeader(proStr); - projectParams.writeProFile(proStr); - proStr << "\nSOURCES +=" - << " \\\n " << Utils::FileName::fromString(source.path()).fileName() - << "\n\nHEADERS +=" - << " \\\n " << headerFileName; - if (!globalHeaderFileName.isEmpty()) - proStr << " \\\n " << globalHeaderFileName << " \n"; - if (!pluginJsonFileName.isEmpty()) - proStr << "\nDISTFILES += " << pluginJsonFileName << " \n"; - writeLinuxProFile(proStr, projectParams); - } - profile.setContents(profileContents); - rc.push_back(profile); - - if (!pluginJsonFileName.isEmpty()) { - Core::GeneratedFile jsonFile(pluginJsonFileFullName); - jsonFile.setContents(QLatin1String("{\n \"Keys\" : [ ]\n}\n")); - rc.push_back(jsonFile); - } - return rc; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/librarywizard.h b/src/plugins/qmakeprojectmanager/wizards/librarywizard.h deleted file mode 100644 index f7edeb5330..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/librarywizard.h +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtwizard.h" -#include "libraryparameters.h" - -namespace QmakeProjectManager { -namespace Internal { - -class LibraryWizard : public QtWizard -{ - Q_OBJECT - -public: - LibraryWizard(); - -protected: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const override; - - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const override; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp deleted file mode 100644 index 2aed6d43cd..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.cpp +++ /dev/null @@ -1,347 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "librarywizarddialog.h" -#include "filespage.h" -#include "libraryparameters.h" -#include "modulespage.h" - -#include <utils/projectintropage.h> -#include <projectexplorer/projectexplorerconstants.h> - -#include <QDebug> - -#include <QComboBox> -#include <QLabel> - -enum { debugLibWizard = 0 }; - -namespace QmakeProjectManager { -namespace Internal { - -struct PluginBaseClasses { - const char *name; - const char *module; - QStringList pureVirtuals; - - // blank separated list or 0 - const char *dependentModules; - const char *targetDirectory; - const char *pluginInterface; -}; -using QSL = QStringList; - -static const PluginBaseClasses pluginBaseClasses[] = -{ - {"QAccessiblePlugin", "QtGui", - QSL{"QAccessibleInterface *create(const QString &key, QObject *object)"}, - "QtCore", "accessible", "QAccessibleFactoryInterface"}, - {"QGenericPlugin", "QtGui", QSL{"QObject *create(const QString &name, const QString &spec)"}, - "QtCore", "generic", "QGenericPluginFactoryInterface"}, - {"QIconEnginePlugin", "QtGui", QSL{"QIconEngine *create(const QString &filename)"}, - "QtCore", "imageformats", "QIconEngineFactoryInterface"}, - {"QImageIOPlugin", "QtGui", - QSL{"QImageIOPlugin::Capabilities capabilities(QIODevice *device, const QByteArray &format) const", - "QImageIOHandler *create(QIODevice *device, const QByteArray &format) const"}, - "QtCore", "imageformats", "QImageIOHandlerFactoryInterface"}, - {"QScriptExtensionPlugin", "QtScript", - QSL{"void initialize(const QString &key, QScriptEngine *engine)", "QStringList keys() const"}, - "QtCore", nullptr, "QScriptExtensionInterface"}, - {"QSqlDriverPlugin", "QtSql", QSL{"QSqlDriver *create(const QString &key)"}, - "QtCore", "sqldrivers", "QSqlDriverFactoryInterface"}, - {"QStylePlugin", "QtWidgets", QSL{"QStyle *create(const QString &key)"}, - "QtCore", "styles", "QStyleFactoryInterface"}, -}; - -enum { defaultPluginBaseClass = 1 }; - -static const PluginBaseClasses *findPluginBaseClass(const QString &name) -{ - const int pluginBaseClassCount = sizeof(pluginBaseClasses)/sizeof(PluginBaseClasses); - for (int i = 0; i < pluginBaseClassCount; i++) - if (name == QLatin1String(pluginBaseClasses[i].name)) - return pluginBaseClasses + i; - return nullptr; -} - -// return dependencies of a plugin as a line ready for the 'QT=' line in a pro -// file -static QStringList pluginDependencies(const PluginBaseClasses *plb) -{ - QStringList dependencies; - const QChar blank = QLatin1Char(' '); - // Find the module names and convert to ids - QStringList pluginModules= plb->dependentModules ? - QString::fromLatin1(plb->dependentModules).split(blank) : - QStringList(); - pluginModules.push_back(QLatin1String(plb->module)); - foreach (const QString &module, pluginModules) { - dependencies.append(ModulesPage::idOfModule(module)); - } - return dependencies; -} - -// A Project intro page with an additional type chooser. -class LibraryIntroPage : public Utils::ProjectIntroPage -{ -public: - explicit LibraryIntroPage(QWidget *parent = nullptr); - - QtProjectParameters::Type type() const; - -private: - QComboBox *m_typeCombo; -}; - -LibraryIntroPage::LibraryIntroPage(QWidget *parent) : - Utils::ProjectIntroPage(parent), - m_typeCombo(new QComboBox) -{ - m_typeCombo->setEditable(false); - m_typeCombo->addItem(LibraryWizardDialog::tr("Shared Library"), - QVariant(QtProjectParameters::SharedLibrary)); - m_typeCombo->addItem(LibraryWizardDialog::tr("Statically Linked Library"), - QVariant(QtProjectParameters::StaticLibrary)); - m_typeCombo->addItem(LibraryWizardDialog::tr("Qt Plugin"), - QVariant(QtProjectParameters::QtPlugin)); - insertControl(0, new QLabel(LibraryWizardDialog::tr("Type")), m_typeCombo); -} - -QtProjectParameters::Type LibraryIntroPage::type() const -{ - return static_cast<QtProjectParameters::Type>(m_typeCombo->itemData(m_typeCombo->currentIndex()).toInt()); -} - -// ------------------- LibraryWizardDialog -LibraryWizardDialog::LibraryWizardDialog(const Core::BaseFileWizardFactory *factory, - const QString &templateName, - const QIcon &icon, - QWidget *parent, - const Core::WizardDialogParameters ¶meters) : - BaseQmakeProjectWizardDialog(factory, true, new LibraryIntroPage, -1, parent, parameters), - m_filesPage(new FilesPage), - m_pluginBaseClassesInitialized(false), - m_filesPageId(-1), m_modulesPageId(-1), m_targetPageId(-1) -{ - setWindowIcon(icon); - setWindowTitle(templateName); - setSelectedModules(QLatin1String("core")); - - // Note that QWizard::currentIdChanged() is emitted at strange times. - // Use the intro page instead, set up initially - setIntroDescription(tr("This wizard generates a C++ Library project.")); - - if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) - m_targetPageId = addTargetSetupPage(); - - m_modulesPageId = addModulesPage(); - - m_filesPage->setNamespacesEnabled(true); - m_filesPage->setFormFileInputVisible(false); - m_filesPage->setClassTypeComboVisible(false); - - m_filesPageId = addPage(m_filesPage); - - Utils::WizardProgressItem *introItem = wizardProgress()->item(startId()); - Utils::WizardProgressItem *targetItem = nullptr; - if (m_targetPageId != -1) - targetItem = wizardProgress()->item(m_targetPageId); - Utils::WizardProgressItem *modulesItem = wizardProgress()->item(m_modulesPageId); - Utils::WizardProgressItem *filesItem = wizardProgress()->item(m_filesPageId); - filesItem->setTitle(tr("Details")); - - if (targetItem) { - if (m_targetPageId != -1) { - targetItem->setNextItems(QList<Utils::WizardProgressItem *>() - << modulesItem << filesItem); - targetItem->setNextShownItem(nullptr); - } else { - introItem->setNextItems(QList<Utils::WizardProgressItem *>() - << modulesItem << filesItem); - introItem->setNextShownItem(nullptr); - } - } - - connect(this, &QWizard::currentIdChanged, this, &LibraryWizardDialog::slotCurrentIdChanged); - - addExtensionPages(extensionPages()); -} - -void LibraryWizardDialog::setSuffixes(const QString &header, const QString &source, const QString &form) -{ - m_filesPage->setSuffixes(header, source, form); -} - -void LibraryWizardDialog::setLowerCaseFiles(bool l) -{ - m_filesPage->setLowerCaseFiles(l); -} - -QtProjectParameters::Type LibraryWizardDialog::type() const -{ - return static_cast<const LibraryIntroPage*>(introPage())->type(); -} - -bool LibraryWizardDialog::isModulesPageSkipped() const -{ - // When leaving the intro or target page, the modules page is skipped - // in the case of a plugin since it knows its dependencies by itself. - return type() == QtProjectParameters::QtPlugin; -} - -int LibraryWizardDialog::skipModulesPageIfNeeded() const -{ - if (isModulesPageSkipped()) - return m_filesPageId; - return m_modulesPageId; -} - -int LibraryWizardDialog::nextId() const -{ - if (m_targetPageId != -1) { - if (currentId() == m_targetPageId) - return skipModulesPageIfNeeded(); - } else if (currentId() == startId()) { - return skipModulesPageIfNeeded(); - } - - return BaseQmakeProjectWizardDialog::nextId(); -} - -void LibraryWizardDialog::initializePage(int id) -{ - if (m_targetPageId != -1 && id == m_targetPageId) { - Utils::WizardProgressItem *targetsItem = wizardProgress()->item(m_targetPageId); - Utils::WizardProgressItem *modulesItem = wizardProgress()->item(m_modulesPageId); - Utils::WizardProgressItem *filesItem = wizardProgress()->item(m_filesPageId); - if (isModulesPageSkipped()) - targetsItem->setNextShownItem(filesItem); - else - targetsItem->setNextShownItem(modulesItem); - - } - BaseQmakeProjectWizardDialog::initializePage(id); -} - -void LibraryWizardDialog::cleanupPage(int id) -{ - if (m_targetPageId != -1 && id == m_targetPageId) { - Utils::WizardProgressItem *targetsItem = wizardProgress()->item(m_targetPageId); - targetsItem->setNextShownItem(nullptr); - } - BaseQmakeProjectWizardDialog::cleanupPage(id); -} - -QtProjectParameters LibraryWizardDialog::parameters() const -{ - QtProjectParameters rc; - rc.type = type(); - rc.fileName = projectName(); - rc.path = path(); - if (rc.type == QtProjectParameters::QtPlugin) { - // Plugin: Dependencies & Target directory - if (const PluginBaseClasses *plb = findPluginBaseClass(m_filesPage->baseClassName())) { - rc.selectedModules = pluginDependencies(plb); - if (plb->targetDirectory) { - rc.targetDirectory = QLatin1String("$$[QT_INSTALL_PLUGINS]/"); - rc.targetDirectory += QLatin1String(plb->targetDirectory); - } - } - } else { - // Modules from modules page - rc.selectedModules = selectedModulesList(); - rc.deselectedModules = deselectedModulesList(); - } - return rc; -} - -void LibraryWizardDialog::slotCurrentIdChanged(int id) -{ - if (debugLibWizard) - qDebug() << Q_FUNC_INFO << id; - if (id == m_filesPageId) - setupFilesPage();// Switching to files page: Set up base class accordingly (plugin) -} - -void LibraryWizardDialog::setupFilesPage() -{ - switch (type()) { - case QtProjectParameters::QtPlugin: - if (!m_pluginBaseClassesInitialized) { - if (debugLibWizard) - qDebug("initializing for plugins"); - QStringList baseClasses; - const int pluginBaseClassCount = sizeof(pluginBaseClasses)/sizeof(PluginBaseClasses); - Q_ASSERT(defaultPluginBaseClass < pluginBaseClassCount); - for (const PluginBaseClasses &pluginBaseClasse : pluginBaseClasses) - baseClasses.push_back(QLatin1String(pluginBaseClasse.name)); - m_filesPage->setBaseClassChoices(baseClasses); - m_filesPage->setBaseClassName(baseClasses.at(defaultPluginBaseClass)); - m_pluginBaseClassesInitialized = true; - } - m_filesPage->setBaseClassInputVisible(true); - break; - default: - if (!m_filesPage->isComplete()) { - // Urrm, figure out a good class name. Use project name this time - QString className = projectName(); - if (!className.isEmpty()) - className[0] = className.at(0).toUpper(); - m_filesPage->setClassName(className); - m_filesPage->setBaseClassInputVisible(false); - } - break; - } -} - -LibraryParameters LibraryWizardDialog::libraryParameters() const -{ - LibraryParameters rc; - rc.className = m_filesPage->className(); - if (type() == QtProjectParameters::QtPlugin) { - rc.baseClassName = m_filesPage->baseClassName(); - for (const PluginBaseClasses &c : pluginBaseClasses) { - if (QLatin1String(c.name) == rc.baseClassName) { - rc.pureVirtualSignatures = c.pureVirtuals; - break; - } - } - } - rc.sourceFileName = m_filesPage->sourceFileName(); - rc.headerFileName = m_filesPage->headerFileName(); - return rc; -} - -QString LibraryWizardDialog::pluginInterface(const QString &baseClass) -{ - if (const PluginBaseClasses *plb = findPluginBaseClass(baseClass)) - if (plb->pluginInterface) - return QLatin1String("org.qt-project.Qt.") + QLatin1String(plb->pluginInterface); - return QString(); -} - - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.h b/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.h deleted file mode 100644 index 620ffe7cca..0000000000 --- a/src/plugins/qmakeprojectmanager/wizards/librarywizarddialog.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtwizard.h" - -namespace QmakeProjectManager { -namespace Internal { - -struct QtProjectParameters; -class FilesPage; -struct LibraryParameters; - -// Library wizard dialog. -class LibraryWizardDialog : public BaseQmakeProjectWizardDialog -{ - Q_OBJECT - -public: - LibraryWizardDialog(const Core::BaseFileWizardFactory *factory, const QString &templateName, - const QIcon &icon, - QWidget *parent, - const Core::WizardDialogParameters ¶meters); - - void setSuffixes(const QString &header, const QString &source, const QString &form= QString()); - void setLowerCaseFiles(bool); - - QtProjectParameters parameters() const; - LibraryParameters libraryParameters() const; - - static QString pluginInterface(const QString &baseClass); - - int nextId() const override; - -protected: - void initializePage(int id) override; - void cleanupPage(int id) override; - -private: - void slotCurrentIdChanged(int); - - QtProjectParameters::Type type() const; - void setupFilesPage(); - bool isModulesPageSkipped() const; - int skipModulesPageIfNeeded() const; - - FilesPage *m_filesPage; - bool m_pluginBaseClassesInitialized; - int m_filesPageId; - int m_modulesPageId; - int m_targetPageId; -}; - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp index 9a4b97a0b7..0e9cd877a5 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp @@ -205,11 +205,11 @@ int BaseQmakeProjectWizardDialog::addTargetSetupPage(int id) const Core::Id platform = selectedPlatform(); QSet<Core::Id> features = {QtSupport::Constants::FEATURE_DESKTOP}; if (!platform.isValid()) - m_targetSetupPage->setPreferredKitPredicate(QtKitInformation::qtVersionPredicate(features)); + m_targetSetupPage->setPreferredKitPredicate(QtKitAspect::qtVersionPredicate(features)); else - m_targetSetupPage->setPreferredKitPredicate(QtKitInformation::platformPredicate(platform)); + m_targetSetupPage->setPreferredKitPredicate(QtKitAspect::platformPredicate(platform)); - m_targetSetupPage->setRequiredKitPredicate(QtKitInformation::qtVersionPredicate(requiredFeatures())); + m_targetSetupPage->setRequiredKitPredicate(QtKitAspect::qtVersionPredicate(requiredFeatures())); resize(900, 450); if (id >= 0) @@ -259,7 +259,7 @@ bool BaseQmakeProjectWizardDialog::writeUserFile(const QString &proFileName) con if (!m_targetSetupPage) return false; - QmakeProject *pro = new QmakeProject(Utils::FileName::fromString(proFileName)); + QmakeProject *pro = new QmakeProject(Utils::FilePath::fromString(proFileName)); bool success = m_targetSetupPage->setupProject(pro); if (success) pro->saveSettings(); @@ -271,7 +271,7 @@ bool BaseQmakeProjectWizardDialog::isQtPlatformSelected(Core::Id platform) const { QList<Core::Id> selectedKitList = selectedKits(); - return Utils::contains(KitManager::kits(QtKitInformation::platformPredicate(platform)), + return Utils::contains(KitManager::kits(QtKitAspect::platformPredicate(platform)), [selectedKitList](const Kit *k) { return selectedKitList.contains(k->id()); }); } diff --git a/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp index 2c1621fcb0..77c6fdd10f 100644 --- a/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/simpleprojectwizard.cpp @@ -70,8 +70,8 @@ public: bool isComplete() const override { return m_filesWidget->hasFilesSelected(); } void initializePage() override; void cleanupPage() override { m_filesWidget->cancelParsing(); } - FileNameList selectedFiles() const { return m_filesWidget->selectedFiles(); } - FileNameList selectedPaths() const { return m_filesWidget->selectedPaths(); } + FilePathList selectedFiles() const { return m_filesWidget->selectedFiles(); } + FilePathList selectedPaths() const { return m_filesWidget->selectedPaths(); } private: SimpleProjectWizardDialog *m_simpleProjectWizardDialog; @@ -117,8 +117,8 @@ public: QString path() const { return m_firstPage->path(); } void setPath(const QString &path) { m_firstPage->setPath(path); } - FileNameList selectedFiles() const { return m_secondPage->selectedFiles(); } - FileNameList selectedPaths() const { return m_secondPage->selectedPaths(); } + FilePathList selectedFiles() const { return m_secondPage->selectedFiles(); } + FilePathList selectedPaths() const { return m_secondPage->selectedPaths(); } QString projectName() const { return m_firstPage->fileName(); } FileWizardPage *m_firstPage; @@ -127,8 +127,8 @@ public: void FilesSelectionWizardPage::initializePage() { - m_filesWidget->resetModel(FileName::fromString(m_simpleProjectWizardDialog->path()), - FileNameList()); + m_filesWidget->resetModel(FilePath::fromString(m_simpleProjectWizardDialog->path()), + FilePathList()); } SimpleProjectWizard::SimpleProjectWizard() @@ -169,7 +169,7 @@ GeneratedFiles SimpleProjectWizard::generateFiles(const QWizard *w, const QDir dir(projectPath); const QString projectName = wizard->projectName(); const QString proFileName = QFileInfo(dir, projectName + ".pro").absoluteFilePath(); - const QStringList paths = Utils::transform(wizard->selectedPaths(), &FileName::toString); + const QStringList paths = Utils::transform(wizard->selectedPaths(), &FilePath::toString); MimeType headerType = Utils::mimeTypeForName("text/x-chdr"); @@ -189,7 +189,7 @@ GeneratedFiles SimpleProjectWizard::generateFiles(const QWizard *w, QString proSources = "SOURCES = \\\n"; QString proHeaders = "HEADERS = \\\n"; - for (const FileName &fileName : wizard->selectedFiles()) { + for (const FilePath &fileName : wizard->selectedFiles()) { QString source = dir.relativeFilePath(fileName.toString()); MimeType mimeType = Utils::mimeTypeForFile(fileName.toFileInfo()); if (mimeType.matchesName("text/x-chdr") || mimeType.matchesName("text/x-c++hdr")) |