forked from qt-creator/qt-creator
CppEditor: Introduce QuickFix settings and unify getter/setter generation
Introduces a QuickFix settings page where the generation of getters and setters can be customized. The settings can be saved into a file that can go into a VCS. All QuickFixes that generate getter/setter/signals/ Q_PROPERTIES now use the same backend. QuickFixes that generate getters/ setters are now extended to also generate signals and Q_PROPERTIES. Fixes: QTCREATORBUG-1532 Fixes: QTCREATORBUG-17941 Fixes: QTCREATORBUG-12678 Fixes: QTCREATORBUG-15779 Fixes: QTCREATORBUG-11620 Fixes: QTCREATORBUG-22707 Fixes: QTCREATORBUG-20157 Fixes: QTCREATORBUG-21804 Fixes: QTCREATORBUG-19814 Fixes: QTCREATORBUG-14622 Fixes: QTCREATORBUG-19803 Change-Id: I50ed2dad9b4a637fbd87b3e1f2856060ad0ad920 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -75,6 +75,8 @@ void NamePrettyPrinter::visit(const TemplateNameId *name)
|
||||
_name = QString::fromUtf8(id->chars(), id->size());
|
||||
else
|
||||
_name = QLatin1String("anonymous");
|
||||
if (!_overview->showTemplateParameters)
|
||||
return;
|
||||
_name += QLatin1Char('<');
|
||||
for (int index = 0; index < name->templateArgumentCount(); ++index) {
|
||||
if (index != 0)
|
||||
|
@@ -25,10 +25,19 @@ add_qtc_plugin(CppEditor
|
||||
cppquickfix.cpp cppquickfix.h
|
||||
cppquickfixassistant.cpp cppquickfixassistant.h
|
||||
cppquickfixes.cpp cppquickfixes.h
|
||||
cppquickfixprojectsettings.cpp cppquickfixprojectsettings.h
|
||||
cppquickfixprojectsettingswidget.cpp cppquickfixprojectsettingswidget.h
|
||||
cppquickfixprojectsettingswidget.ui
|
||||
cppquickfixsettings.cpp cppquickfixsettings.h
|
||||
cppquickfixsettingspage.cpp cppquickfixsettingspage.h
|
||||
cppquickfixsettingswidget.cpp cppquickfixsettingswidget.h cppquickfixsettingswidget.ui
|
||||
cpptypehierarchy.cpp cpptypehierarchy.h
|
||||
cppuseselectionsupdater.cpp cppuseselectionsupdater.h
|
||||
resourcepreviewhoverhandler.cpp resourcepreviewhoverhandler.h
|
||||
EXPLICIT_MOC cppeditor.h
|
||||
EXPLICIT_MOC
|
||||
cppeditor.h
|
||||
cppquickfixsettingswidget.h
|
||||
cppquickfixprojectsettingswidget.h
|
||||
)
|
||||
|
||||
extend_qtc_plugin(CppEditor
|
||||
|
@@ -24,6 +24,11 @@ HEADERS += \
|
||||
cppquickfix.h \
|
||||
cppquickfixassistant.h \
|
||||
cppquickfixes.h \
|
||||
cppquickfixprojectsettings.h \
|
||||
cppquickfixprojectsettingswidget.h \
|
||||
cppquickfixsettings.h \
|
||||
cppquickfixsettingspage.h \
|
||||
cppquickfixsettingswidget.h \
|
||||
cpptypehierarchy.h \
|
||||
cppuseselectionsupdater.h \
|
||||
resourcepreviewhoverhandler.h
|
||||
@@ -48,13 +53,20 @@ SOURCES += \
|
||||
cppquickfix.cpp \
|
||||
cppquickfixassistant.cpp \
|
||||
cppquickfixes.cpp \
|
||||
cppquickfixprojectsettings.cpp \
|
||||
cppquickfixprojectsettingswidget.cpp \
|
||||
cppquickfixsettings.cpp \
|
||||
cppquickfixsettingspage.cpp \
|
||||
cppquickfixsettingswidget.cpp \
|
||||
cpptypehierarchy.cpp \
|
||||
cppuseselectionsupdater.cpp \
|
||||
resourcepreviewhoverhandler.cpp
|
||||
|
||||
FORMS += \
|
||||
cpppreprocessordialog.ui \
|
||||
cppcodemodelinspectordialog.ui
|
||||
cppcodemodelinspectordialog.ui \
|
||||
cppquickfixprojectsettingswidget.ui \
|
||||
cppquickfixsettingswidget.ui
|
||||
|
||||
RESOURCES += \
|
||||
cppeditor.qrc
|
||||
|
@@ -64,6 +64,18 @@ QtcPlugin {
|
||||
"cppquickfixassistant.h",
|
||||
"cppquickfixes.cpp",
|
||||
"cppquickfixes.h",
|
||||
"cppquickfixprojectsettings.cpp",
|
||||
"cppquickfixprojectsettings.h",
|
||||
"cppquickfixprojectsettingswidget.cpp",
|
||||
"cppquickfixprojectsettingswidget.h",
|
||||
"cppquickfixprojectsettingswidget.ui",
|
||||
"cppquickfixsettings.cpp",
|
||||
"cppquickfixsettings.h",
|
||||
"cppquickfixsettingspage.cpp",
|
||||
"cppquickfixsettingspage.h",
|
||||
"cppquickfixsettingswidget.cpp",
|
||||
"cppquickfixsettingswidget.h",
|
||||
"cppquickfixsettingswidget.ui",
|
||||
"cpptypehierarchy.cpp",
|
||||
"cpptypehierarchy.h",
|
||||
"cppuseselectionsupdater.cpp",
|
||||
|
@@ -53,5 +53,30 @@ const char CPP_SNIPPETS_GROUP_ID[] = "C++";
|
||||
const char EXTRA_PREPROCESSOR_DIRECTIVES[] = "CppEditor.ExtraPreprocessorDirectives-";
|
||||
const char PREFERRED_PARSE_CONTEXT[] = "CppEditor.PreferredParseContext-";
|
||||
|
||||
const char QUICK_FIX_PROJECT_PANEL_ID[] = "CppEditor.QuickFix";
|
||||
const char QUICK_FIX_SETTINGS_ID[] = "CppEditor.QuickFix";
|
||||
const char QUICK_FIX_SETTINGS_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "Quick Fixes");
|
||||
const char QUICK_FIX_SETTING_GETTER_OUTSIDE_CLASS_FROM[] = "GettersOutsideClassFrom";
|
||||
const char QUICK_FIX_SETTING_GETTER_IN_CPP_FILE_FROM[] = "GettersInCppFileFrom";
|
||||
const char QUICK_FIX_SETTING_SETTER_OUTSIDE_CLASS_FROM[] = "SettersOutsideClassFrom";
|
||||
const char QUICK_FIX_SETTING_SETTER_IN_CPP_FILE_FROM[] = "SettersInCppFileFrom";
|
||||
const char QUICK_FIX_SETTING_GETTER_ATTRIBUTES[] = "GetterAttributes";
|
||||
const char QUICK_FIX_SETTING_GETTER_NAME_TEMPLATE[] = "GetterNameTemplate";
|
||||
const char QUICK_FIX_SETTING_SETTER_NAME_TEMPLATE[] = "SetterNameTemplate";
|
||||
const char QUICK_FIX_SETTING_SIGNAL_NAME_TEMPLATE[] = "SignalNameTemplate";
|
||||
const char QUICK_FIX_SETTING_RESET_NAME_TEMPLATE[] = "ResetNameTemplate";
|
||||
const char QUICK_FIX_SETTING_SIGNAL_WITH_NEW_VALUE[] = "SignalWithNewValue";
|
||||
const char QUICK_FIX_SETTING_SETTER_AS_SLOT[] = "SetterAsSlot";
|
||||
const char QUICK_FIX_SETTING_SETTER_PARAMETER_NAME[] = "SetterParameterName";
|
||||
const char QUICK_FIX_SETTING_CPP_FILE_NAMESPACE_HANDLING[] = "CppFileNamespaceHandling";
|
||||
const char QUICK_FIX_SETTING_MEMBER_VARIABEL_NAME_TEMPLATE[] = "MemberVariableNameTemplate";
|
||||
const char QUICK_FIX_SETTING_VALUE_TYPES[] = "ValueTypes";
|
||||
const char QUICK_FIX_SETTING_CUSTOM_TEMPLATES[] = "CustomTemplate";
|
||||
const char QUICK_FIX_SETTING_CUSTOM_TEMPLATE_TYPES[] = "Types";
|
||||
const char QUICK_FIX_SETTING_CUSTOM_TEMPLATE_COMPARISON[] = "Comparison";
|
||||
const char QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_TYPE[] = "ReturnType";
|
||||
const char QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_EXPRESSION[] = "ReturnExpression";
|
||||
const char QUICK_FIX_SETTING_CUSTOM_TEMPLATE_ASSIGNMENT[] = "Assignment";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace CppEditor
|
||||
|
@@ -29,13 +29,15 @@
|
||||
#include "cppcodemodelinspectordialog.h"
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditordocument.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cpphighlighter.h"
|
||||
#include "cppincludehierarchy.h"
|
||||
#include "cppoutline.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
#include "cppquickfixes.h"
|
||||
#include "cppquickfixprojectsettingswidget.h"
|
||||
#include "cppquickfixsettingspage.h"
|
||||
#include "cpptypehierarchy.h"
|
||||
#include "resourcepreviewhoverhandler.h"
|
||||
|
||||
@@ -56,10 +58,11 @@
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <cpptools/cpphoverhandler.h>
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
#include <texteditor/texteditoractionhandler.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <texteditor/colorpreviewhoverhandler.h>
|
||||
#include <texteditor/snippets/snippetprovider.h>
|
||||
#include <texteditor/texteditoractionhandler.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
@@ -124,6 +127,7 @@ public:
|
||||
QAction *m_openIncludeHierarchyAction = nullptr;
|
||||
|
||||
CppQuickFixAssistProvider m_quickFixProvider;
|
||||
CppQuickFixSettingsPage m_quickFixSettingsPage;
|
||||
|
||||
QPointer<CppCodeModelInspectorDialog> m_cppCodeModelInspectorDialog;
|
||||
|
||||
@@ -164,6 +168,16 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
auto panelFactory = new ProjectExplorer::ProjectPanelFactory;
|
||||
panelFactory->setPriority(100);
|
||||
panelFactory->setId(Constants::QUICK_FIX_PROJECT_PANEL_ID);
|
||||
panelFactory->setDisplayName(
|
||||
QCoreApplication::translate("CppTools", Constants::QUICK_FIX_SETTINGS_DISPLAY_NAME));
|
||||
panelFactory->setCreateWidgetFunction([](ProjectExplorer::Project *project) {
|
||||
return new CppQuickFixProjectSettingsWidget(project);
|
||||
});
|
||||
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
||||
|
||||
d = new CppEditorPluginPrivate;
|
||||
|
||||
SnippetProvider::registerGroup(Constants::CPP_SNIPPETS_GROUP_ID, tr("C++", "SnippetProvider"),
|
||||
|
@@ -103,19 +103,32 @@ private slots:
|
||||
void test_quickfix_data();
|
||||
void test_quickfix();
|
||||
|
||||
void test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAndNamespaceToCpp();
|
||||
void test_quickfix_GenerateGetterSetter_createNamespaceInCpp_data();
|
||||
void test_quickfix_GenerateGetterSetter_createNamespaceInCpp();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingCreate_data();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingCreate();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingAddUsing_data();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingAddUsing();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingFullyQualify_data();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingFullyQualify();
|
||||
void test_quickfix_GenerateGetterSetter_customNames_data();
|
||||
void test_quickfix_GenerateGetterSetter_customNames();
|
||||
void test_quickfix_GenerateGetterSetter_valueTypes_data();
|
||||
void test_quickfix_GenerateGetterSetter_valueTypes();
|
||||
void test_quickfix_GenerateGetterSetter_customTemplate();
|
||||
void test_quickfix_GenerateGetterSetter_needThis();
|
||||
void test_quickfix_GenerateGetterSetter_offeredFixes_data();
|
||||
void test_quickfix_GenerateGetterSetter_offeredFixes();
|
||||
void test_quickfix_GenerateGetterSetter_generalTests_data();
|
||||
void test_quickfix_GenerateGetterSetter_generalTests();
|
||||
void test_quickfix_GenerateGetterSetter_onlyGetter();
|
||||
void test_quickfix_GenerateGetterSetter_onlyGetter_DontPreferGetterWithGet();
|
||||
void test_quickfix_GenerateGetterSetter_onlySetter();
|
||||
void test_quickfix_GenerateGetterSetter_onlySetterHeaderFile();
|
||||
void test_quickfix_GenerateGetterSetter_inlineInHeaderFile();
|
||||
void test_quickfix_GenerateGetterSetter_onlySetterHeaderFileWithIncludeGuard();
|
||||
void test_quickfix_GenerateGetterSetter_offerGetterWhenSetterPresent();
|
||||
void test_quickfix_GenerateGetterSetter_offerSetterWhenGetterPresent();
|
||||
void test_quickfix_GenerateGettersSetters_data();
|
||||
void test_quickfix_GenerateGettersSetters();
|
||||
|
||||
void test_quickfix_InsertQtPropertyMembers_data();
|
||||
void test_quickfix_InsertQtPropertyMembers();
|
||||
|
||||
void test_quickfix_InsertMemberFromInitialization_data();
|
||||
void test_quickfix_InsertMemberFromInitialization();
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
187
src/plugins/cppeditor/cppquickfixprojectsettings.cpp
Normal file
187
src/plugins/cppeditor/cppquickfixprojectsettings.cpp
Normal file
@@ -0,0 +1,187 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "cppquickfixprojectsettings.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include <coreplugin/icore.h>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QtDebug>
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
using namespace Constants;
|
||||
|
||||
static const char SETTINGS_FILE_NAME[] = ".cppQuickFix";
|
||||
static const char USE_GLOBAL_SETTINGS[] = "UseGlobalSettings";
|
||||
|
||||
CppQuickFixProjectsSettings::CppQuickFixProjectsSettings(ProjectExplorer::Project *project)
|
||||
{
|
||||
m_project = project;
|
||||
const auto settings = m_project->namedSettings(QUICK_FIX_SETTINGS_ID).toMap();
|
||||
// if no option is saved try to load settings from a file
|
||||
m_useGlobalSettings = settings.value(USE_GLOBAL_SETTINGS, false).toBool();
|
||||
if (!m_useGlobalSettings) {
|
||||
m_settingsFile = searchForCppQuickFixSettingsFile();
|
||||
if (!m_settingsFile.isEmpty()) {
|
||||
loadOwnSettingsFromFile();
|
||||
m_useGlobalSettings = false;
|
||||
} else {
|
||||
m_useGlobalSettings = true;
|
||||
}
|
||||
}
|
||||
connect(project, &ProjectExplorer::Project::aboutToSaveSettings, [this] {
|
||||
auto settings = m_project->namedSettings(QUICK_FIX_SETTINGS_ID).toMap();
|
||||
settings.insert(USE_GLOBAL_SETTINGS, m_useGlobalSettings);
|
||||
m_project->setNamedSettings(QUICK_FIX_SETTINGS_ID, settings);
|
||||
});
|
||||
}
|
||||
|
||||
CppQuickFixSettings *CppQuickFixProjectsSettings::getSettings()
|
||||
{
|
||||
if (m_useGlobalSettings)
|
||||
return CppQuickFixSettings::instance();
|
||||
|
||||
return &m_ownSettings;
|
||||
}
|
||||
|
||||
bool CppQuickFixProjectsSettings::isUsingGlobalSettings() const
|
||||
{
|
||||
return m_useGlobalSettings;
|
||||
}
|
||||
|
||||
const Utils::FilePath &CppQuickFixProjectsSettings::filePathOfSettingsFile() const
|
||||
{
|
||||
return m_settingsFile;
|
||||
}
|
||||
|
||||
CppQuickFixProjectsSettings::CppQuickFixProjectsSettingsPtr CppQuickFixProjectsSettings::getSettings(
|
||||
ProjectExplorer::Project *project)
|
||||
{
|
||||
const QString key = "CppQuickFixProjectsSettings";
|
||||
QVariant v = project->extraData(key);
|
||||
if (v.isNull()) {
|
||||
v = QVariant::fromValue(
|
||||
CppQuickFixProjectsSettingsPtr{new CppQuickFixProjectsSettings(project)});
|
||||
project->setExtraData(key, v);
|
||||
}
|
||||
return v.value<QSharedPointer<CppQuickFixProjectsSettings>>();
|
||||
}
|
||||
|
||||
CppQuickFixSettings *CppQuickFixProjectsSettings::getQuickFixSettings(ProjectExplorer::Project *project)
|
||||
{
|
||||
if (project)
|
||||
return getSettings(project)->getSettings();
|
||||
return CppQuickFixSettings::instance();
|
||||
}
|
||||
|
||||
Utils::FilePath CppQuickFixProjectsSettings::searchForCppQuickFixSettingsFile()
|
||||
{
|
||||
auto cur = m_project->projectDirectory();
|
||||
while (!cur.isEmpty()) {
|
||||
const auto path = cur / SETTINGS_FILE_NAME;
|
||||
if (path.exists())
|
||||
return path;
|
||||
|
||||
cur = cur.parentDir();
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
|
||||
void CppQuickFixProjectsSettings::useGlobalSettings()
|
||||
{
|
||||
m_useGlobalSettings = true;
|
||||
}
|
||||
|
||||
bool CppQuickFixProjectsSettings::useCustomSettings()
|
||||
{
|
||||
if (m_settingsFile.isEmpty()) {
|
||||
m_settingsFile = searchForCppQuickFixSettingsFile();
|
||||
const Utils::FilePath defaultLocation = m_project->projectDirectory() / SETTINGS_FILE_NAME;
|
||||
if (m_settingsFile.isEmpty()) {
|
||||
m_settingsFile = defaultLocation;
|
||||
} else if (m_settingsFile != defaultLocation) {
|
||||
QMessageBox msgBox(Core::ICore::dialogParent());
|
||||
msgBox.setText(tr("Quick Fix settings are saved in a file. Existing settings file "
|
||||
"'%1' found. Should this file be used or a "
|
||||
"new one be created?")
|
||||
.arg(m_settingsFile.toString()));
|
||||
QPushButton *cancel = msgBox.addButton(QMessageBox::Cancel);
|
||||
cancel->setToolTip(tr("Switch Back to Global Settings"));
|
||||
QPushButton *useExisting = msgBox.addButton(tr("Use Existing"), QMessageBox::AcceptRole);
|
||||
useExisting->setToolTip(m_settingsFile.toString());
|
||||
QPushButton *createNew = msgBox.addButton(tr("Create New"), QMessageBox::ActionRole);
|
||||
createNew->setToolTip(defaultLocation.toString());
|
||||
msgBox.exec();
|
||||
if (msgBox.clickedButton() == createNew) {
|
||||
m_settingsFile = defaultLocation;
|
||||
} else if (msgBox.clickedButton() != useExisting) {
|
||||
m_settingsFile.clear();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
resetOwnSettingsToGlobal();
|
||||
}
|
||||
if (m_settingsFile.exists())
|
||||
loadOwnSettingsFromFile();
|
||||
|
||||
m_useGlobalSettings = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CppQuickFixProjectsSettings::resetOwnSettingsToGlobal()
|
||||
{
|
||||
m_ownSettings = *CppQuickFixSettings::instance();
|
||||
}
|
||||
|
||||
bool CppQuickFixProjectsSettings::saveOwnSettings()
|
||||
{
|
||||
if (m_settingsFile.isEmpty())
|
||||
return false;
|
||||
|
||||
QSettings settings(m_settingsFile.toString(), QSettings::IniFormat);
|
||||
if (settings.status() == QSettings::NoError) {
|
||||
m_ownSettings.saveSettingsTo(&settings);
|
||||
settings.sync();
|
||||
return settings.status() == QSettings::NoError;
|
||||
}
|
||||
m_settingsFile.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
void CppQuickFixProjectsSettings::loadOwnSettingsFromFile()
|
||||
{
|
||||
QSettings settings(m_settingsFile.toString(), QSettings::IniFormat);
|
||||
if (settings.status() == QSettings::NoError) {
|
||||
m_ownSettings.loadSettingsFrom(&settings);
|
||||
return;
|
||||
}
|
||||
m_settingsFile.clear();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
67
src/plugins/cppeditor/cppquickfixprojectsettings.h
Normal file
67
src/plugins/cppeditor/cppquickfixprojectsettings.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "cppquickfixsettings.h"
|
||||
#include <projectexplorer/project.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
class CppQuickFixProjectsSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CppQuickFixProjectsSettings(ProjectExplorer::Project *project);
|
||||
CppQuickFixSettings *getSettings();
|
||||
bool isUsingGlobalSettings() const;
|
||||
const Utils::FilePath &filePathOfSettingsFile() const;
|
||||
|
||||
using CppQuickFixProjectsSettingsPtr = QSharedPointer<CppQuickFixProjectsSettings>;
|
||||
static CppQuickFixProjectsSettingsPtr getSettings(ProjectExplorer::Project *project);
|
||||
static CppQuickFixSettings *getQuickFixSettings(ProjectExplorer::Project *project);
|
||||
|
||||
Utils::FilePath searchForCppQuickFixSettingsFile();
|
||||
|
||||
void useGlobalSettings();
|
||||
[[nodiscard]] bool useCustomSettings();
|
||||
void resetOwnSettingsToGlobal();
|
||||
bool saveOwnSettings();
|
||||
|
||||
private:
|
||||
void loadOwnSettingsFromFile();
|
||||
|
||||
ProjectExplorer::Project *m_project;
|
||||
Utils::FilePath m_settingsFile;
|
||||
CppQuickFixSettings m_ownSettings;
|
||||
bool m_useGlobalSettings;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
||||
Q_DECLARE_METATYPE(QSharedPointer<CppEditor::Internal::CppQuickFixProjectsSettings>)
|
104
src/plugins/cppeditor/cppquickfixprojectsettingswidget.cpp
Normal file
104
src/plugins/cppeditor/cppquickfixprojectsettingswidget.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "cppquickfixprojectsettingswidget.h"
|
||||
#include "cppquickfixsettingswidget.h"
|
||||
#include "ui_cppquickfixprojectsettingswidget.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
using namespace CppEditor::Internal;
|
||||
|
||||
CppQuickFixProjectSettingsWidget::CppQuickFixProjectSettingsWidget(ProjectExplorer::Project *project,
|
||||
QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::CppQuickFixProjectSettingsWidget)
|
||||
{
|
||||
m_projectSettings = CppQuickFixProjectsSettings::getSettings(project);
|
||||
ui->setupUi(this);
|
||||
m_settingsWidget = new CppEditor::Internal::CppQuickFixSettingsWidget(this);
|
||||
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
||||
ui->layout->addWidget(m_settingsWidget);
|
||||
connect(ui->comboBox,
|
||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
this,
|
||||
&CppQuickFixProjectSettingsWidget::currentItemChanged);
|
||||
connect(ui->pushButton_custom,
|
||||
&QAbstractButton::clicked,
|
||||
this,
|
||||
&CppQuickFixProjectSettingsWidget::buttonCustomClicked);
|
||||
connect(m_settingsWidget, &CppEditor::Internal::CppQuickFixSettingsWidget::settingsChanged, [this] {
|
||||
m_settingsWidget->saveSettings(m_projectSettings->getSettings());
|
||||
if (!useGlobalSettings())
|
||||
m_projectSettings->saveOwnSettings();
|
||||
});
|
||||
ui->comboBox->setCurrentIndex(m_projectSettings->isUsingGlobalSettings() ? 0 : 1);
|
||||
}
|
||||
|
||||
CppQuickFixProjectSettingsWidget::~CppQuickFixProjectSettingsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CppQuickFixProjectSettingsWidget::currentItemChanged()
|
||||
{
|
||||
if (useGlobalSettings()) {
|
||||
const auto &path = m_projectSettings->filePathOfSettingsFile();
|
||||
ui->pushButton_custom->setToolTip(tr("Custom settings are saved in a file. If you use the "
|
||||
"global settings, you can delete that file."));
|
||||
ui->pushButton_custom->setText(tr("Delete Custom Settings File"));
|
||||
ui->pushButton_custom->setVisible(!path.isEmpty() && path.exists());
|
||||
m_projectSettings->useGlobalSettings();
|
||||
} else /*Custom*/ {
|
||||
if (!m_projectSettings->useCustomSettings()) {
|
||||
ui->comboBox->setCurrentIndex(0);
|
||||
return;
|
||||
}
|
||||
ui->pushButton_custom->setToolTip(tr("Resets all settings to the global settings."));
|
||||
ui->pushButton_custom->setText(tr("Reset to Global"));
|
||||
ui->pushButton_custom->setVisible(true);
|
||||
// otherwise you change the comboBox and exit and have no custom settings:
|
||||
m_projectSettings->saveOwnSettings();
|
||||
}
|
||||
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
||||
}
|
||||
|
||||
void CppQuickFixProjectSettingsWidget::buttonCustomClicked()
|
||||
{
|
||||
if (useGlobalSettings()) {
|
||||
// delete file
|
||||
QFile::remove(m_projectSettings->filePathOfSettingsFile().toString());
|
||||
ui->pushButton_custom->setVisible(false);
|
||||
} else /*Custom*/ {
|
||||
m_projectSettings->resetOwnSettingsToGlobal();
|
||||
m_projectSettings->saveOwnSettings();
|
||||
m_settingsWidget->loadSettings(m_projectSettings->getSettings());
|
||||
}
|
||||
}
|
||||
|
||||
bool CppQuickFixProjectSettingsWidget::useGlobalSettings()
|
||||
{
|
||||
return ui->comboBox->currentIndex() == 0;
|
||||
}
|
63
src/plugins/cppeditor/cppquickfixprojectsettingswidget.h
Normal file
63
src/plugins/cppeditor/cppquickfixprojectsettingswidget.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "cppquickfixprojectsettings.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class CppQuickFixProjectSettingsWidget; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer { class Project; }
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
class CppQuickFixSettingsWidget;
|
||||
class CppQuickFixProjectSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CppQuickFixProjectSettingsWidget(ProjectExplorer::Project *project,
|
||||
QWidget *parent = nullptr);
|
||||
~CppQuickFixProjectSettingsWidget();
|
||||
|
||||
private slots:
|
||||
void currentItemChanged();
|
||||
void buttonCustomClicked();
|
||||
|
||||
private:
|
||||
bool useGlobalSettings();
|
||||
|
||||
Ui::CppQuickFixProjectSettingsWidget *ui;
|
||||
CppQuickFixSettingsWidget *m_settingsWidget;
|
||||
CppQuickFixProjectsSettings::CppQuickFixProjectsSettingsPtr m_projectSettings;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
48
src/plugins/cppeditor/cppquickfixprojectsettingswidget.ui
Normal file
48
src/plugins/cppeditor/cppquickfixprojectsettingswidget.ui
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CppQuickFixProjectSettingsWidget</class>
|
||||
<widget class="QWidget" name="CppQuickFixProjectSettingsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>532</width>
|
||||
<height>345</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_custom">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="layout"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Global Settings</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Custom Settings</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
446
src/plugins/cppeditor/cppquickfixsettings.cpp
Normal file
446
src/plugins/cppeditor/cppquickfixsettings.cpp
Normal file
@@ -0,0 +1,446 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "cppquickfixsettings.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cpptools/cppcodestylesettings.h>
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace CppEditor {
|
||||
CppQuickFixSettings::CppQuickFixSettings(bool loadGlobalSettings)
|
||||
{
|
||||
setDefaultSettings();
|
||||
if (loadGlobalSettings)
|
||||
this->loadGlobalSettings();
|
||||
}
|
||||
|
||||
void CppQuickFixSettings::loadGlobalSettings()
|
||||
{
|
||||
// TODO remove the conversion of the old setting preferGetterNameWithoutGetPrefix of the
|
||||
// CppCodeStyleSettings in 4.16 (also remove the member preferGetterNameWithoutGetPrefix)
|
||||
getterNameTemplate = "__dummy";
|
||||
loadSettingsFrom(Core::ICore::settings());
|
||||
if (getterNameTemplate == "__dummy") {
|
||||
// there was no saved property for getterNameTemplate
|
||||
if (CppTools::CppCodeStyleSettings::currentGlobalCodeStyle().preferGetterNameWithoutGetPrefix)
|
||||
getterNameTemplate = "<name>";
|
||||
else
|
||||
getterNameTemplate = "get<Name>";
|
||||
}
|
||||
}
|
||||
|
||||
void CppQuickFixSettings::loadSettingsFrom(QSettings *s)
|
||||
{
|
||||
s->beginGroup(QLatin1String(Constants::QUICK_FIX_SETTINGS_ID));
|
||||
getterOutsideClassFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_GETTER_OUTSIDE_CLASS_FROM),
|
||||
getterOutsideClassFrom)
|
||||
.toInt();
|
||||
getterInCppFileFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_GETTER_IN_CPP_FILE_FROM),
|
||||
getterInCppFileFrom)
|
||||
.toInt();
|
||||
setterOutsideClassFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_SETTER_OUTSIDE_CLASS_FROM),
|
||||
setterOutsideClassFrom)
|
||||
.toInt();
|
||||
setterInCppFileFrom = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_SETTER_IN_CPP_FILE_FROM),
|
||||
setterInCppFileFrom)
|
||||
.toInt();
|
||||
getterAttributes = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_ATTRIBUTES),
|
||||
getterAttributes)
|
||||
.toString();
|
||||
getterNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_NAME_TEMPLATE),
|
||||
getterNameTemplate)
|
||||
.toString();
|
||||
setterNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_NAME_TEMPLATE),
|
||||
setterNameTemplate)
|
||||
.toString();
|
||||
setterParameterNameTemplate = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_SETTER_PARAMETER_NAME),
|
||||
setterParameterNameTemplate)
|
||||
.toString();
|
||||
resetNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_RESET_NAME_TEMPLATE),
|
||||
resetNameTemplate)
|
||||
.toString();
|
||||
signalNameTemplate = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_NAME_TEMPLATE),
|
||||
signalNameTemplate)
|
||||
.toString();
|
||||
signalWithNewValue = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_WITH_NEW_VALUE),
|
||||
signalWithNewValue)
|
||||
.toBool();
|
||||
setterAsSlot = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_AS_SLOT), setterAsSlot)
|
||||
.toBool();
|
||||
cppFileNamespaceHandling = static_cast<MissingNamespaceHandling>(
|
||||
s->value(QLatin1String(Constants::QUICK_FIX_SETTING_CPP_FILE_NAMESPACE_HANDLING),
|
||||
static_cast<int>(cppFileNamespaceHandling))
|
||||
.toInt());
|
||||
memberVariableNameTemplate
|
||||
= s->value(QLatin1String(Constants::QUICK_FIX_SETTING_MEMBER_VARIABEL_NAME_TEMPLATE),
|
||||
memberVariableNameTemplate)
|
||||
.toString();
|
||||
valueTypes = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_VALUE_TYPES), valueTypes)
|
||||
.toStringList();
|
||||
int size = s->beginReadArray(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATES));
|
||||
if (size > 0)
|
||||
customTemplates.clear();
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
s->setArrayIndex(i);
|
||||
CustomTemplate c;
|
||||
c.types = s->value(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_TYPES))
|
||||
.toStringList();
|
||||
if (c.types.isEmpty())
|
||||
continue;
|
||||
c.equalComparison = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_COMPARISON))
|
||||
.toString();
|
||||
c.returnType = s->value(QLatin1String(
|
||||
Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_TYPE))
|
||||
.toString();
|
||||
c.returnExpression
|
||||
= s->value(
|
||||
QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_EXPRESSION))
|
||||
.toString();
|
||||
c.assignment = s->value(
|
||||
QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_ASSIGNMENT))
|
||||
.toString();
|
||||
if (c.assignment.isEmpty() && c.returnType.isEmpty() && c.equalComparison.isEmpty())
|
||||
continue; // nothing custom here
|
||||
|
||||
customTemplates.push_back(c);
|
||||
}
|
||||
s->endArray();
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void CppQuickFixSettings::saveSettingsTo(QSettings *s)
|
||||
{
|
||||
s->beginGroup(QLatin1String(Constants::QUICK_FIX_SETTINGS_ID));
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_OUTSIDE_CLASS_FROM),
|
||||
getterOutsideClassFrom);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_IN_CPP_FILE_FROM),
|
||||
getterInCppFileFrom);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_OUTSIDE_CLASS_FROM),
|
||||
setterOutsideClassFrom);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_IN_CPP_FILE_FROM),
|
||||
setterInCppFileFrom);
|
||||
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_ATTRIBUTES), getterAttributes);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_GETTER_NAME_TEMPLATE), getterNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_NAME_TEMPLATE), setterNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_RESET_NAME_TEMPLATE), resetNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_NAME_TEMPLATE), signalNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SIGNAL_WITH_NEW_VALUE), signalWithNewValue);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CPP_FILE_NAMESPACE_HANDLING),
|
||||
static_cast<int>(cppFileNamespaceHandling));
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_MEMBER_VARIABEL_NAME_TEMPLATE),
|
||||
memberVariableNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_PARAMETER_NAME),
|
||||
setterParameterNameTemplate);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_SETTER_AS_SLOT), setterAsSlot);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_VALUE_TYPES), valueTypes);
|
||||
s->beginWriteArray(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATES));
|
||||
for (int i = 0; i < static_cast<int>(customTemplates.size()); ++i) {
|
||||
const auto &c = customTemplates[i];
|
||||
s->setArrayIndex(i);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_TYPES), c.types);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_COMPARISON),
|
||||
c.equalComparison);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_TYPE),
|
||||
c.returnType);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_RETURN_EXPRESSION),
|
||||
c.returnExpression);
|
||||
s->setValue(QLatin1String(Constants::QUICK_FIX_SETTING_CUSTOM_TEMPLATE_ASSIGNMENT),
|
||||
c.assignment);
|
||||
}
|
||||
s->endArray();
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void CppQuickFixSettings::saveAsGlobalSettings()
|
||||
{
|
||||
saveSettingsTo(Core::ICore::settings());
|
||||
}
|
||||
|
||||
void CppQuickFixSettings::setDefaultSettings()
|
||||
{
|
||||
valueTypes << "Pointer" // for Q...Pointer
|
||||
<< "optional" // for ...::optional
|
||||
<< "unique_ptr"; // for std::unique_ptr and boost::movelib::unique_ptr
|
||||
valueTypes << "int"
|
||||
<< "long"
|
||||
<< "char"
|
||||
<< "real"
|
||||
<< "short"
|
||||
<< "unsigned"
|
||||
<< "size"
|
||||
<< "float"
|
||||
<< "double"
|
||||
<< "bool";
|
||||
CustomTemplate floatingPoint;
|
||||
floatingPoint.types << "float"
|
||||
<< "double"
|
||||
<< "qreal"
|
||||
<< "long double";
|
||||
floatingPoint.equalComparison = "qFuzzyCompare(<cur>, <new>)";
|
||||
customTemplates.push_back(floatingPoint);
|
||||
|
||||
CustomTemplate unique_ptr;
|
||||
unique_ptr.types << "unique_ptr";
|
||||
unique_ptr.assignment = "<cur> = std::move(<new>)";
|
||||
unique_ptr.returnType = "<T>*";
|
||||
unique_ptr.returnExpression = "<cur>.get()";
|
||||
customTemplates.push_back(unique_ptr);
|
||||
}
|
||||
|
||||
QString toUpperCamelCase(const QString &s)
|
||||
{
|
||||
auto parts = s.split('_');
|
||||
if (parts.size() == 1)
|
||||
return s;
|
||||
|
||||
QString camel;
|
||||
camel.reserve(s.length() - parts.size() + 1);
|
||||
for (const auto &part : parts) {
|
||||
camel += part[0].toUpper();
|
||||
camel += part.mid(1);
|
||||
}
|
||||
return camel;
|
||||
}
|
||||
|
||||
QString toSnakeCase(const QString &s, bool upperSnakeCase)
|
||||
{
|
||||
QString snake;
|
||||
snake.reserve(s.length() + 5);
|
||||
if (upperSnakeCase)
|
||||
snake += s[0].toUpper();
|
||||
else
|
||||
snake += s[0].toLower();
|
||||
|
||||
for (int i = 1; i < s.length(); ++i) {
|
||||
if (s[i].isUpper() && s[i - 1].isLower()) {
|
||||
snake += '_';
|
||||
if (upperSnakeCase)
|
||||
snake += s[i].toUpper();
|
||||
else
|
||||
snake += s[i].toLower();
|
||||
|
||||
} else {
|
||||
if (s[i - 1] == '_') {
|
||||
if (upperSnakeCase)
|
||||
snake += s[i].toUpper();
|
||||
else
|
||||
snake += s[i].toLower();
|
||||
} else {
|
||||
snake += s[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return snake;
|
||||
}
|
||||
|
||||
QString CppQuickFixSettings::replaceNamePlaceholders(const QString &nameTemplate,
|
||||
const QString &name)
|
||||
{
|
||||
const int start = nameTemplate.indexOf("<");
|
||||
const int end = nameTemplate.indexOf(">");
|
||||
if (start < 0 || end < 0)
|
||||
return nameTemplate;
|
||||
|
||||
const auto before = nameTemplate.left(start);
|
||||
const auto after = nameTemplate.right(nameTemplate.length() - end - 1);
|
||||
if (name.isEmpty())
|
||||
return before + after;
|
||||
|
||||
// const auto charBefore = start >= 1 ? nameTemplate.at(start - 1) : QChar{};
|
||||
const auto nameType = nameTemplate.mid(start + 1, end - start - 1);
|
||||
if (nameType == "name") {
|
||||
return before + name + after;
|
||||
} else if (nameType == "Name") {
|
||||
return before + name.at(0).toUpper() + name.mid(1) + after;
|
||||
} else if (nameType == "camel") {
|
||||
auto camel = toUpperCamelCase(name);
|
||||
camel.data()[0] = camel.data()[0].toLower();
|
||||
return before + camel + after;
|
||||
} else if (nameType == "Camel") {
|
||||
return before + toUpperCamelCase(name) + after;
|
||||
} else if (nameType == "snake") {
|
||||
return before + toSnakeCase(name, false) + after;
|
||||
} else if (nameType == "Snake") {
|
||||
return before + toSnakeCase(name, true) + after;
|
||||
} else {
|
||||
return "templateHasErrors";
|
||||
}
|
||||
}
|
||||
|
||||
auto removeAndExtractTemplate(QString type)
|
||||
{
|
||||
// maybe we have somethink like: myName::test<std::byte>::fancy<std::optional<int>>, then we want fancy
|
||||
QString realType;
|
||||
QString templateParameter;
|
||||
int counter = 0;
|
||||
int start = 0;
|
||||
int templateStart;
|
||||
for (int i = 0; i < type.length(); ++i) {
|
||||
auto c = type[i];
|
||||
if (c == '<') {
|
||||
if (counter == 0) {
|
||||
// template start
|
||||
realType += type.mid(start, i - start);
|
||||
templateStart = i + 1;
|
||||
}
|
||||
++counter;
|
||||
} else if (c == '>') {
|
||||
--counter;
|
||||
if (counter == 0) {
|
||||
// template ends
|
||||
start = i + 1;
|
||||
templateParameter = type.mid(templateStart, i - templateStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start < type.length()) // add last block if there is one
|
||||
realType += type.mid(start);
|
||||
|
||||
struct _
|
||||
{
|
||||
QString type;
|
||||
QString templateParameter;
|
||||
};
|
||||
return _{realType, templateParameter};
|
||||
}
|
||||
|
||||
auto withoutNamespace(QString type)
|
||||
{
|
||||
const auto namespaceIndex = type.lastIndexOf("::");
|
||||
if (namespaceIndex >= 0)
|
||||
return type.mid(namespaceIndex + 2);
|
||||
return type;
|
||||
}
|
||||
|
||||
bool CppQuickFixSettings::isValueType(QString type) const
|
||||
{
|
||||
// first remove template stuff
|
||||
auto realType = removeAndExtractTemplate(type).type;
|
||||
// remove namespaces: namespace_int::complex should not be matched by int
|
||||
realType = withoutNamespace(realType);
|
||||
for (const auto &valueType : valueTypes) {
|
||||
if (realType.contains(valueType))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CppQuickFixSettings::GetterSetterTemplate::replacePlaceholders(QString currentValueVariableName,
|
||||
QString newValueVariableName)
|
||||
{
|
||||
equalComparison = equalComparison.replace("<new>", newValueVariableName)
|
||||
.replace("<cur>", currentValueVariableName);
|
||||
assignment = assignment.replace("<new>", newValueVariableName)
|
||||
.replace("<cur>", currentValueVariableName);
|
||||
returnExpression = returnExpression.replace("<new>", newValueVariableName)
|
||||
.replace("<cur>", currentValueVariableName);
|
||||
}
|
||||
|
||||
CppQuickFixSettings::GetterSetterTemplate CppQuickFixSettings::findGetterSetterTemplate(
|
||||
QString fullyQualifiedType) const
|
||||
{
|
||||
const int index = fullyQualifiedType.lastIndexOf("::");
|
||||
const QString namespaces = index >= 0 ? fullyQualifiedType.left(index) : "";
|
||||
const QString typeOnly = index >= 0 ? fullyQualifiedType.mid(index + 2) : fullyQualifiedType;
|
||||
CustomTemplate bestMatch;
|
||||
enum MatchType { FullyExact, FullyContains, Exact, Contains, None } currentMatch = None;
|
||||
QRegularExpression regex;
|
||||
for (const auto &cTemplate : customTemplates) {
|
||||
for (const auto &t : cTemplate.types) {
|
||||
QString type = t;
|
||||
bool fully = false;
|
||||
if (t.contains("::")) {
|
||||
const int index = t.lastIndexOf("::");
|
||||
if (t.left(index) != namespaces)
|
||||
continue;
|
||||
|
||||
type = t.mid(index + 2);
|
||||
fully = true;
|
||||
} else if (currentMatch <= FullyContains) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MatchType match = None;
|
||||
if (t.contains("*")) {
|
||||
regex.setPattern('^' + QString(t).replace('*', ".*") + '$');
|
||||
if (regex.match(typeOnly).isValid() != QRegularExpression::NormalMatch)
|
||||
match = fully ? FullyContains : Contains;
|
||||
} else if (t == typeOnly) {
|
||||
match = fully ? FullyExact : Exact;
|
||||
}
|
||||
if (match < currentMatch) {
|
||||
currentMatch = match;
|
||||
bestMatch = cTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMatch != None) {
|
||||
GetterSetterTemplate t;
|
||||
if (!bestMatch.equalComparison.isEmpty())
|
||||
t.equalComparison = bestMatch.equalComparison;
|
||||
if (!bestMatch.returnExpression.isEmpty())
|
||||
t.returnExpression = bestMatch.returnExpression;
|
||||
if (!bestMatch.assignment.isEmpty())
|
||||
t.assignment = bestMatch.assignment;
|
||||
if (!bestMatch.returnType.isEmpty())
|
||||
t.returnTypeTemplate = bestMatch.returnType;
|
||||
return t;
|
||||
}
|
||||
return GetterSetterTemplate{};
|
||||
}
|
||||
|
||||
CppQuickFixSettings::FunctionLocation CppQuickFixSettings::determineGetterLocation(int lineCount) const
|
||||
{
|
||||
int outsideDiff = getterOutsideClassFrom > 0 ? lineCount - getterOutsideClassFrom : -1;
|
||||
int cppDiff = getterInCppFileFrom > 0 ? lineCount - getterInCppFileFrom : -1;
|
||||
if (outsideDiff > cppDiff) {
|
||||
if (outsideDiff >= 0)
|
||||
return FunctionLocation::OutsideClass;
|
||||
}
|
||||
return cppDiff >= 0 ? FunctionLocation::CppFile : FunctionLocation::InsideClass;
|
||||
}
|
||||
|
||||
CppQuickFixSettings::FunctionLocation CppQuickFixSettings::determineSetterLocation(int lineCount) const
|
||||
{
|
||||
int outsideDiff = setterOutsideClassFrom > 0 ? lineCount - setterOutsideClassFrom : -1;
|
||||
int cppDiff = setterInCppFileFrom > 0 ? lineCount - setterInCppFileFrom : -1;
|
||||
if (outsideDiff > cppDiff) {
|
||||
if (outsideDiff >= 0)
|
||||
return FunctionLocation::OutsideClass;
|
||||
}
|
||||
return cppDiff >= 0 ? FunctionLocation::CppFile : FunctionLocation::InsideClass;
|
||||
}
|
||||
|
||||
} // namespace CppEditor
|
149
src/plugins/cppeditor/cppquickfixsettings.h
Normal file
149
src/plugins/cppeditor/cppquickfixsettings.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 <utils/optional.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <vector>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CppEditor {
|
||||
|
||||
class CppQuickFixSettings
|
||||
{
|
||||
public:
|
||||
static CppQuickFixSettings *instance()
|
||||
{
|
||||
static CppQuickFixSettings settings(true);
|
||||
return &settings;
|
||||
}
|
||||
struct CustomTemplate
|
||||
{
|
||||
QStringList types;
|
||||
QString equalComparison;
|
||||
QString returnExpression;
|
||||
QString returnType;
|
||||
QString assignment;
|
||||
};
|
||||
|
||||
struct GetterSetterTemplate
|
||||
{
|
||||
QString equalComparison = "<cur> == <new>";
|
||||
QString returnExpression = "<cur>";
|
||||
QString assignment = "<cur> = <new>";
|
||||
const static inline QString TYPE_PATTERN = "<type>";
|
||||
const static inline QString TEMPLATE_PARAMETER_PATTERN = "<T>";
|
||||
Utils::optional<QString> returnTypeTemplate;
|
||||
void replacePlaceholders(QString currentValueVariableName, QString newValueVariableName);
|
||||
};
|
||||
|
||||
enum class FunctionLocation {
|
||||
InsideClass,
|
||||
OutsideClass,
|
||||
CppFile,
|
||||
};
|
||||
enum class MissingNamespaceHandling {
|
||||
CreateMissing,
|
||||
AddUsingDirective,
|
||||
RewriteType, // e.g. change classname to namespacename::classname in cpp file
|
||||
};
|
||||
|
||||
explicit CppQuickFixSettings(bool loadGlobalSettings = false);
|
||||
|
||||
void loadGlobalSettings();
|
||||
void loadSettingsFrom(QSettings *);
|
||||
void saveSettingsTo(QSettings *);
|
||||
void saveAsGlobalSettings();
|
||||
void setDefaultSettings();
|
||||
|
||||
static QString replaceNamePlaceholders(const QString &nameTemplate, const QString &name);
|
||||
bool isValueType(QString type) const;
|
||||
GetterSetterTemplate findGetterSetterTemplate(QString fullyQualifiedType) const;
|
||||
|
||||
QString getGetterName(const QString &variableName) const
|
||||
{
|
||||
return replaceNamePlaceholders(getterNameTemplate, variableName);
|
||||
}
|
||||
QString getSetterName(const QString &variableName) const
|
||||
{
|
||||
return replaceNamePlaceholders(setterNameTemplate, variableName);
|
||||
}
|
||||
QString getSignalName(const QString &variableName) const
|
||||
{
|
||||
return replaceNamePlaceholders(signalNameTemplate, variableName);
|
||||
}
|
||||
QString getResetName(const QString &variableName) const
|
||||
{
|
||||
return replaceNamePlaceholders(resetNameTemplate, variableName);
|
||||
}
|
||||
QString getSetterParameterName(const QString &variableName) const
|
||||
{
|
||||
return replaceNamePlaceholders(setterParameterNameTemplate, variableName);
|
||||
}
|
||||
QString getMemberVariableName(const QString &variableName) const
|
||||
{
|
||||
return replaceNamePlaceholders(memberVariableNameTemplate, variableName);
|
||||
}
|
||||
FunctionLocation determineGetterLocation(int lineCount) const;
|
||||
FunctionLocation determineSetterLocation(int lineCount) const;
|
||||
bool createMissingNamespacesinCppFile() const
|
||||
{
|
||||
return cppFileNamespaceHandling == MissingNamespaceHandling::CreateMissing;
|
||||
}
|
||||
bool addUsingNamespaceinCppFile() const
|
||||
{
|
||||
return cppFileNamespaceHandling == MissingNamespaceHandling::AddUsingDirective;
|
||||
}
|
||||
bool rewriteTypesinCppFile() const
|
||||
{
|
||||
return cppFileNamespaceHandling == MissingNamespaceHandling::RewriteType;
|
||||
}
|
||||
|
||||
public:
|
||||
int getterOutsideClassFrom = 0;
|
||||
int getterInCppFileFrom = 2;
|
||||
int setterOutsideClassFrom = 0;
|
||||
int setterInCppFileFrom = 2;
|
||||
QString getterAttributes; // e.g. [[nodiscard]]
|
||||
QString getterNameTemplate = "<name>"; // or get<Name>
|
||||
QString setterNameTemplate = "set<Name>"; // or set_<name> or Set<Name>
|
||||
QString setterParameterNameTemplate = "new<Name>";
|
||||
QString signalNameTemplate = "<name>Changed";
|
||||
QString resetNameTemplate = "reset<Name>";
|
||||
bool signalWithNewValue = false;
|
||||
bool setterAsSlot = false;
|
||||
MissingNamespaceHandling cppFileNamespaceHandling = MissingNamespaceHandling::CreateMissing;
|
||||
QString memberVariableNameTemplate = "m_<name>";
|
||||
QStringList valueTypes; // if contains use value. Ignores namespaces and template parameters
|
||||
std::vector<CustomTemplate> customTemplates;
|
||||
};
|
||||
} // namespace CppEditor
|
62
src/plugins/cppeditor/cppquickfixsettingspage.cpp
Normal file
62
src/plugins/cppeditor/cppquickfixsettingspage.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "cppquickfixsettingspage.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppquickfixsettings.h"
|
||||
#include "cppquickfixsettingswidget.h"
|
||||
#include "cpptools/cpptoolsconstants.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QtDebug>
|
||||
|
||||
using namespace CppEditor::Internal;
|
||||
|
||||
CppQuickFixSettingsPage::CppQuickFixSettingsPage()
|
||||
{
|
||||
setId(Constants::QUICK_FIX_SETTINGS_ID);
|
||||
setDisplayName(QCoreApplication::translate("CppTools", Constants::QUICK_FIX_SETTINGS_DISPLAY_NAME));
|
||||
setCategory(CppTools::Constants::CPP_SETTINGS_CATEGORY);
|
||||
}
|
||||
|
||||
QWidget *CppQuickFixSettingsPage::widget()
|
||||
{
|
||||
if (!m_widget) {
|
||||
m_widget = new CppQuickFixSettingsWidget;
|
||||
m_widget->loadSettings(CppQuickFixSettings::instance());
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
void CppQuickFixSettingsPage::apply()
|
||||
{
|
||||
const auto s = CppQuickFixSettings::instance();
|
||||
m_widget->saveSettings(s);
|
||||
s->saveAsGlobalSettings();
|
||||
}
|
||||
|
||||
void CppEditor::Internal::CppQuickFixSettingsPage::finish()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
48
src/plugins/cppeditor/cppquickfixsettingspage.h
Normal file
48
src/plugins/cppeditor/cppquickfixsettingspage.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "coreplugin/dialogs/ioptionspage.h"
|
||||
#include <QPointer>
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
class CppQuickFixSettingsWidget;
|
||||
|
||||
class CppQuickFixSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CppQuickFixSettingsPage();
|
||||
|
||||
QWidget *widget() override;
|
||||
void apply() override;
|
||||
void finish() override;
|
||||
|
||||
private:
|
||||
QPointer<CppQuickFixSettingsWidget> m_widget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
272
src/plugins/cppeditor/cppquickfixsettingswidget.cpp
Normal file
272
src/plugins/cppeditor/cppquickfixsettingswidget.cpp
Normal file
@@ -0,0 +1,272 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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 "cppquickfixsettingswidget.h"
|
||||
#include "cppquickfixsettings.h"
|
||||
#include "ui_cppquickfixsettingswidget.h"
|
||||
#include <QtDebug>
|
||||
|
||||
using namespace CppEditor;
|
||||
using namespace CppEditor::Internal;
|
||||
|
||||
CppQuickFixSettingsWidget::CppQuickFixSettingsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new ::Ui::CppQuickFixSettingsWidget)
|
||||
, typeSplitter("\\s*,\\s*")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QObject::connect(ui->listWidget_customTemplates,
|
||||
&QListWidget::currentItemChanged,
|
||||
this,
|
||||
&CppQuickFixSettingsWidget::currentCustomItemChanged);
|
||||
QObject::connect(ui->pushButton_addValueType, &QPushButton::clicked, [this] {
|
||||
auto item = new QListWidgetItem("<type>", ui->valueTypes);
|
||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled
|
||||
| Qt::ItemNeverHasChildren);
|
||||
ui->valueTypes->scrollToItem(item);
|
||||
item->setSelected(true);
|
||||
});
|
||||
QObject::connect(ui->pushButton_addCustomTemplate, &QPushButton::clicked, [this] {
|
||||
auto item = new QListWidgetItem("<type>", ui->listWidget_customTemplates);
|
||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
|
||||
ui->listWidget_customTemplates->scrollToItem(item);
|
||||
ui->listWidget_customTemplates->setCurrentItem(item);
|
||||
ui->lineEdit_customTemplateTypes->setText("<type>");
|
||||
});
|
||||
QObject::connect(ui->pushButton_removeCustomTemplate, &QPushButton::clicked, [this] {
|
||||
delete ui->listWidget_customTemplates->currentItem();
|
||||
});
|
||||
QObject::connect(ui->pushButton_removeValueType, &QPushButton::clicked, [this] {
|
||||
delete ui->valueTypes->currentItem();
|
||||
});
|
||||
this->setEnabled(false);
|
||||
this->ui->pushButton_removeCustomTemplate->setEnabled(false);
|
||||
this->ui->groupBox_customTemplate->setEnabled(false);
|
||||
this->ui->widget_getterCpp->setEnabled(false);
|
||||
this->ui->widget_setterCpp->setEnabled(false);
|
||||
this->ui->widget_getterOutside->setEnabled(false);
|
||||
this->ui->widget_setterOutside->setEnabled(false);
|
||||
|
||||
const QString toolTip = QCoreApplication::translate("CppQuickFixSettingsWidget",
|
||||
R"==(Use <name> for the variable
|
||||
Use <camel> for camel case
|
||||
Use <snake> for snake case
|
||||
Use <Name>, <Camel> and <Snake> for upper case
|
||||
e.g. name = "m_test_foo_":
|
||||
"set_<name> => "set_test_foo"
|
||||
"set<Name> => "setTest_foo"
|
||||
"set<Camel> => "setTestFoo")==");
|
||||
this->ui->lineEdit_resetName->setToolTip(toolTip);
|
||||
this->ui->lineEdit_setterName->setToolTip(toolTip);
|
||||
this->ui->lineEdit_setterParameter->setToolTip(toolTip);
|
||||
this->ui->lineEdit_signalName->setToolTip(toolTip);
|
||||
this->ui->lineEdit_getterName->setToolTip(toolTip);
|
||||
this->ui->lineEdit_memberVariableName->setToolTip(toolTip);
|
||||
|
||||
// connect controls to settingsChanged signal
|
||||
auto then = [this] {
|
||||
if (!isLoadingSettings)
|
||||
emit settingsChanged();
|
||||
};
|
||||
QObject::connect(this->ui->checkBox_getterCpp, &QCheckBox::clicked, then);
|
||||
QObject::connect(this->ui->checkBox_getterOutside, &QCheckBox::clicked, then);
|
||||
QObject::connect(this->ui->checkBox_setterCpp, &QCheckBox::clicked, then);
|
||||
QObject::connect(this->ui->checkBox_setterOutside, &QCheckBox::clicked, then);
|
||||
QObject::connect(this->ui->checkBox_setterSlots, &QCheckBox::clicked, then);
|
||||
QObject::connect(this->ui->checkBox_signalWithNewValue, &QCheckBox::clicked, then);
|
||||
QObject::connect(this->ui->pushButton_addCustomTemplate, &QPushButton::clicked, then);
|
||||
QObject::connect(this->ui->pushButton_removeCustomTemplate, &QPushButton::clicked, then);
|
||||
QObject::connect(this->ui->pushButton_addValueType, &QPushButton::clicked, then);
|
||||
QObject::connect(this->ui->pushButton_removeValueType, &QPushButton::clicked, then);
|
||||
QObject::connect(this->ui->valueTypes, &QListWidget::itemChanged, then);
|
||||
QObject::connect(this->ui->lineEdit_customTemplateAssignment, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_customTemplateComparison, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_customTemplateReturnExpression, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_customTemplateReturnType, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_customTemplateTypes, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_getterAttribute, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_getterName, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_memberVariableName, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_resetName, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_setterName, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_setterParameter, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->lineEdit_signalName, &QLineEdit::textEdited, then);
|
||||
QObject::connect(this->ui->spinBox_getterCpp, &QSpinBox::editingFinished, then);
|
||||
QObject::connect(this->ui->spinBox_getterOutside, &QSpinBox::editingFinished, then);
|
||||
QObject::connect(this->ui->spinBox_setterCpp, &QSpinBox::editingFinished, then);
|
||||
QObject::connect(this->ui->spinBox_setterOutside, &QSpinBox::editingFinished, then);
|
||||
QObject::connect(this->ui->radioButton_addUsingnamespace, &QRadioButton::clicked, then);
|
||||
QObject::connect(this->ui->radioButton_generateMissingNamespace, &QRadioButton::clicked, then);
|
||||
QObject::connect(this->ui->radioButton_rewriteTypes, &QRadioButton::clicked, then);
|
||||
}
|
||||
|
||||
CppQuickFixSettingsWidget::~CppQuickFixSettingsWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CppQuickFixSettingsWidget::loadSettings(CppQuickFixSettings *settings)
|
||||
{
|
||||
isLoadingSettings = true;
|
||||
ui->checkBox_getterCpp->setChecked(settings->getterInCppFileFrom > 0);
|
||||
ui->spinBox_getterCpp->setValue(std::abs(settings->getterInCppFileFrom));
|
||||
ui->checkBox_setterCpp->setChecked(settings->setterInCppFileFrom > 0);
|
||||
ui->spinBox_setterCpp->setValue(std::abs(settings->setterInCppFileFrom));
|
||||
ui->checkBox_getterOutside->setChecked(settings->getterOutsideClassFrom > 0);
|
||||
ui->spinBox_getterOutside->setValue(std::abs(settings->getterOutsideClassFrom));
|
||||
ui->checkBox_setterOutside->setChecked(settings->setterOutsideClassFrom > 0);
|
||||
ui->spinBox_setterOutside->setValue(std::abs(settings->setterOutsideClassFrom));
|
||||
ui->lineEdit_getterAttribute->setText(settings->getterAttributes);
|
||||
ui->lineEdit_getterName->setText(settings->getterNameTemplate);
|
||||
ui->lineEdit_setterName->setText(settings->setterNameTemplate);
|
||||
ui->lineEdit_setterParameter->setText(settings->setterParameterNameTemplate);
|
||||
switch (settings->cppFileNamespaceHandling) {
|
||||
case CppQuickFixSettings::MissingNamespaceHandling::RewriteType:
|
||||
ui->radioButton_rewriteTypes->setChecked(true);
|
||||
break;
|
||||
case CppQuickFixSettings::MissingNamespaceHandling::CreateMissing:
|
||||
ui->radioButton_generateMissingNamespace->setChecked(true);
|
||||
break;
|
||||
case CppQuickFixSettings::MissingNamespaceHandling::AddUsingDirective:
|
||||
ui->radioButton_addUsingnamespace->setChecked(true);
|
||||
break;
|
||||
}
|
||||
ui->lineEdit_resetName->setText(settings->resetNameTemplate);
|
||||
ui->lineEdit_signalName->setText(settings->signalNameTemplate);
|
||||
ui->lineEdit_memberVariableName->setText(settings->memberVariableNameTemplate);
|
||||
ui->checkBox_setterSlots->setChecked(settings->setterAsSlot);
|
||||
ui->checkBox_signalWithNewValue->setChecked(settings->signalWithNewValue);
|
||||
ui->valueTypes->clear();
|
||||
for (const auto &valueType : settings->valueTypes) {
|
||||
auto item = new QListWidgetItem(valueType, ui->valueTypes);
|
||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled
|
||||
| Qt::ItemNeverHasChildren);
|
||||
}
|
||||
ui->listWidget_customTemplates->clear();
|
||||
for (const auto &customTemplate : settings->customTemplates) {
|
||||
auto item = new QListWidgetItem(customTemplate.types.join(", "),
|
||||
ui->listWidget_customTemplates);
|
||||
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren);
|
||||
item->setData(CustomDataRoles::Types, customTemplate.types.join(", "));
|
||||
item->setData(CustomDataRoles::Comparison, customTemplate.equalComparison);
|
||||
item->setData(CustomDataRoles::Assignment, customTemplate.assignment);
|
||||
item->setData(CustomDataRoles::ReturnType, customTemplate.returnType);
|
||||
item->setData(CustomDataRoles::ReturnExpression, customTemplate.returnExpression);
|
||||
}
|
||||
if (ui->listWidget_customTemplates->count() > 0) {
|
||||
ui->listWidget_customTemplates->setCurrentItem(ui->listWidget_customTemplates->item(0));
|
||||
}
|
||||
this->setEnabled(true);
|
||||
isLoadingSettings = false;
|
||||
}
|
||||
|
||||
void CppQuickFixSettingsWidget::saveSettings(CppQuickFixSettings *settings)
|
||||
{
|
||||
// first write the current selected custom template back to the model
|
||||
if (ui->listWidget_customTemplates->currentItem() != nullptr) {
|
||||
auto item = ui->listWidget_customTemplates->currentItem();
|
||||
auto list = ui->lineEdit_customTemplateTypes->text().split(typeSplitter, Qt::SkipEmptyParts);
|
||||
item->setData(CustomDataRoles::Types, list);
|
||||
item->setData(CustomDataRoles::Comparison, ui->lineEdit_customTemplateComparison->text());
|
||||
item->setData(CustomDataRoles::Assignment, ui->lineEdit_customTemplateAssignment->text());
|
||||
item->setData(CustomDataRoles::ReturnType, ui->lineEdit_customTemplateReturnType->text());
|
||||
item->setData(CustomDataRoles::ReturnExpression,
|
||||
ui->lineEdit_customTemplateReturnExpression->text());
|
||||
}
|
||||
const auto preGetOut = ui->checkBox_getterOutside->isChecked() ? 1 : -1;
|
||||
settings->getterOutsideClassFrom = preGetOut * ui->spinBox_getterOutside->value();
|
||||
const auto preSetOut = ui->checkBox_setterOutside->isChecked() ? 1 : -1;
|
||||
settings->setterOutsideClassFrom = preSetOut * ui->spinBox_setterOutside->value();
|
||||
const auto preGetCpp = ui->checkBox_getterCpp->isChecked() ? 1 : -1;
|
||||
settings->getterInCppFileFrom = preGetCpp * ui->spinBox_getterCpp->value();
|
||||
const auto preSetCpp = ui->checkBox_setterCpp->isChecked() ? 1 : -1;
|
||||
settings->setterInCppFileFrom = preSetCpp * ui->spinBox_setterCpp->value();
|
||||
settings->setterParameterNameTemplate = ui->lineEdit_setterParameter->text();
|
||||
settings->setterAsSlot = ui->checkBox_setterSlots->isChecked();
|
||||
settings->signalWithNewValue = ui->checkBox_signalWithNewValue->isChecked();
|
||||
settings->getterAttributes = ui->lineEdit_getterAttribute->text();
|
||||
settings->getterNameTemplate = ui->lineEdit_getterName->text();
|
||||
settings->setterNameTemplate = ui->lineEdit_setterName->text();
|
||||
settings->resetNameTemplate = ui->lineEdit_resetName->text();
|
||||
settings->signalNameTemplate = ui->lineEdit_signalName->text();
|
||||
settings->memberVariableNameTemplate = ui->lineEdit_memberVariableName->text();
|
||||
if (ui->radioButton_rewriteTypes->isChecked()) {
|
||||
settings->cppFileNamespaceHandling = CppQuickFixSettings::MissingNamespaceHandling::RewriteType;
|
||||
} else if (ui->radioButton_addUsingnamespace->isChecked()) {
|
||||
settings->cppFileNamespaceHandling = CppQuickFixSettings::MissingNamespaceHandling::AddUsingDirective;
|
||||
} else if (ui->radioButton_generateMissingNamespace->isChecked()) {
|
||||
settings->cppFileNamespaceHandling = CppQuickFixSettings::MissingNamespaceHandling::CreateMissing;
|
||||
}
|
||||
settings->valueTypes.clear();
|
||||
for (int i = 0; i < ui->valueTypes->count(); ++i) {
|
||||
settings->valueTypes << ui->valueTypes->item(i)->text();
|
||||
}
|
||||
settings->customTemplates.clear();
|
||||
for (int i = 0; i < ui->listWidget_customTemplates->count(); ++i) {
|
||||
auto item = ui->listWidget_customTemplates->item(i);
|
||||
CppQuickFixSettings::CustomTemplate t;
|
||||
t.types = item->data(CustomDataRoles::Types).toStringList();
|
||||
t.equalComparison = item->data(CustomDataRoles::Comparison).toString();
|
||||
t.assignment = item->data(CustomDataRoles::Assignment).toString();
|
||||
t.returnExpression = item->data(CustomDataRoles::ReturnExpression).toString();
|
||||
t.returnType = item->data(CustomDataRoles::ReturnType).toString();
|
||||
settings->customTemplates.push_back(t);
|
||||
}
|
||||
}
|
||||
|
||||
void CppQuickFixSettingsWidget::currentCustomItemChanged(QListWidgetItem *newItem,
|
||||
QListWidgetItem *oldItem)
|
||||
{
|
||||
if (oldItem) {
|
||||
auto list = ui->lineEdit_customTemplateTypes->text().split(typeSplitter, Qt::SkipEmptyParts);
|
||||
oldItem->setData(CustomDataRoles::Types, list);
|
||||
oldItem->setData(Qt::DisplayRole, list.join(", "));
|
||||
oldItem->setData(CustomDataRoles::Comparison, ui->lineEdit_customTemplateComparison->text());
|
||||
oldItem->setData(CustomDataRoles::Assignment, ui->lineEdit_customTemplateAssignment->text());
|
||||
oldItem->setData(CustomDataRoles::ReturnType, ui->lineEdit_customTemplateReturnType->text());
|
||||
oldItem->setData(CustomDataRoles::ReturnExpression,
|
||||
ui->lineEdit_customTemplateReturnExpression->text());
|
||||
}
|
||||
this->ui->pushButton_removeCustomTemplate->setEnabled(newItem != nullptr);
|
||||
this->ui->groupBox_customTemplate->setEnabled(newItem != nullptr);
|
||||
if (newItem) {
|
||||
this->ui->lineEdit_customTemplateTypes->setText(
|
||||
newItem->data(CustomDataRoles::Types).toStringList().join(", "));
|
||||
this->ui->lineEdit_customTemplateComparison->setText(
|
||||
newItem->data(CustomDataRoles::Comparison).toString());
|
||||
this->ui->lineEdit_customTemplateAssignment->setText(
|
||||
newItem->data(CustomDataRoles::Assignment).toString());
|
||||
this->ui->lineEdit_customTemplateReturnType->setText(
|
||||
newItem->data(CustomDataRoles::ReturnType).toString());
|
||||
this->ui->lineEdit_customTemplateReturnExpression->setText(
|
||||
newItem->data(CustomDataRoles::ReturnExpression).toString());
|
||||
} else {
|
||||
this->ui->lineEdit_customTemplateTypes->setText("");
|
||||
this->ui->lineEdit_customTemplateComparison->setText("");
|
||||
this->ui->lineEdit_customTemplateAssignment->setText("");
|
||||
this->ui->lineEdit_customTemplateReturnType->setText("");
|
||||
this->ui->lineEdit_customTemplateReturnExpression->setText("");
|
||||
}
|
||||
}
|
72
src/plugins/cppeditor/cppquickfixsettingswidget.h
Normal file
72
src/plugins/cppeditor/cppquickfixsettingswidget.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2020 Leander Schulten <Leander.Schulten@rwth-aachen.de>
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CppQuickFixSettingsWidget_H
|
||||
#define CppQuickFixSettingsWidget_H
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QListWidgetItem;
|
||||
namespace Ui { class CppQuickFixSettingsWidget; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CppEditor {
|
||||
class CppQuickFixSettings;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class CppQuickFixSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
enum CustomDataRoles {
|
||||
Types = Qt::UserRole,
|
||||
Comparison,
|
||||
Assignment,
|
||||
ReturnExpression,
|
||||
ReturnType,
|
||||
};
|
||||
|
||||
public:
|
||||
explicit CppQuickFixSettingsWidget(QWidget *parent = nullptr);
|
||||
~CppQuickFixSettingsWidget();
|
||||
void loadSettings(CppQuickFixSettings *settings);
|
||||
void saveSettings(CppQuickFixSettings *settings);
|
||||
private slots:
|
||||
void currentCustomItemChanged(QListWidgetItem *newItem, QListWidgetItem *oldItem);
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
bool isLoadingSettings = false;
|
||||
Ui::CppQuickFixSettingsWidget *ui;
|
||||
const QRegularExpression typeSplitter;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
||||
#endif // CppQuickFixSettingsWidget_H
|
961
src/plugins/cppeditor/cppquickfixsettingswidget.ui
Normal file
961
src/plugins/cppeditor/cppquickfixsettingswidget.ui
Normal file
@@ -0,0 +1,961 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CppQuickFixSettingsWidget</class>
|
||||
<widget class="QWidget" name="CppQuickFixSettingsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>641</width>
|
||||
<height>1074</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Generated Function Locations</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="horizontalSpacing">
|
||||
<number>48</number>
|
||||
</property>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" alignment="Qt::AlignHCenter">
|
||||
<widget class="QWidget" name="widget2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="checkBox_setterOutside">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_setterOutside" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>≥</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_setterOutside">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" alignment="Qt::AlignHCenter">
|
||||
<widget class="QWidget" name="widget3" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="checkBox_setterCpp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_setterCpp" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="group1">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>≥</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_setterCpp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2" alignment="Qt::AlignHCenter">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="checkBox_getterOutside">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_getterOutside" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>≥</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_getterOutside">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<underline>true</underline>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate Getters</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<underline>true</underline>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate Setters</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="text">
|
||||
<string>In .cpp file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2" alignment="Qt::AlignHCenter">
|
||||
<widget class="QWidget" name="widget4" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="checkBox_getterCpp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_getterCpp" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>≥</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_getterCpp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Outside class:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Inside class:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>Getter Setter Generation Properties</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Getter name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_setterParameter">
|
||||
<property name="placeholderText">
|
||||
<string>For example, new<Name></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
<string>Setter name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_setterSlots">
|
||||
<property name="text">
|
||||
<string>Setters should be slots</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBox_signalWithNewValue">
|
||||
<property name="text">
|
||||
<string>Generate signals with the new value as parameter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Getter attributes:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_28">
|
||||
<property name="text">
|
||||
<string>Setter parameter name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_30">
|
||||
<property name="text">
|
||||
<string>Reset name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="text">
|
||||
<string>Signal name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_getterName">
|
||||
<property name="placeholderText">
|
||||
<string>See tool tip for more information</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_resetName">
|
||||
<property name="placeholderText">
|
||||
<string>Normally reset<Name></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_getterAttribute">
|
||||
<property name="placeholderText">
|
||||
<string>For example, [[nodiscard]]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_setterName">
|
||||
<property name="placeholderText">
|
||||
<string>See tool tip for more information</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_signalName">
|
||||
<property name="placeholderText">
|
||||
<string>Normally <name>Changed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_31">
|
||||
<property name="text">
|
||||
<string>Member variable name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_memberVariableName">
|
||||
<property name="placeholderText">
|
||||
<string>For example, m_<name></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Missing Namespace Handling</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_generateMissingNamespace">
|
||||
<property name="text">
|
||||
<string>Generate missing namespaces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_addUsingnamespace">
|
||||
<property name="text">
|
||||
<string>Add "using namespace ..."</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_rewriteTypes">
|
||||
<property name="text">
|
||||
<string>Rewrite types to match the existing namespaces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Custom Getter Setter Templates</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,5">
|
||||
<item row="1" column="1" rowspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_customTemplate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Template</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="text">
|
||||
<string>Types:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_customTemplateTypes">
|
||||
<property name="toolTip">
|
||||
<string>Separate the types by comma.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="text">
|
||||
<string>Comparison:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_customTemplateComparison"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="text">
|
||||
<string>Assignment:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_customTemplateAssignment"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_25">
|
||||
<property name="text">
|
||||
<string>Return expression:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_customTemplateReturnExpression"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="text">
|
||||
<string>Return type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_customTemplateReturnType"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use <new> and <cur> to access the parameter and current value. Use <type> to access the type and <T> for the template parameter.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2">
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_customTemplates">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_addCustomTemplate">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_removeCustomTemplate">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QListWidget" name="valueTypes">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Normally arguments get passed by const reference. If the Type is one of the following ones, the argument gets passed by value. Namespaces and template arguments are removed. The real Type must contain the given Type. For example, "int" matches "int32_t" but not "vector<int>". "vector" matches "std::pmr::vector<int>" but not "std::optional<vector<int>>"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>212</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Value types:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_addValueType">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_removeValueType">
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>checkBox_getterCpp</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widget_getterCpp</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>509</x>
|
||||
<y>125</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>570</x>
|
||||
<y>125</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_getterOutside</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widget_getterOutside</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>509</x>
|
||||
<y>91</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>570</x>
|
||||
<y>91</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_setterOutside</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widget_setterOutside</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>312</x>
|
||||
<y>91</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>373</x>
|
||||
<y>91</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkBox_setterCpp</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widget_setterCpp</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>312</x>
|
||||
<y>125</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>373</x>
|
||||
<y>125</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -83,6 +83,8 @@ public:
|
||||
// b
|
||||
bool alignAssignments = false;
|
||||
|
||||
// TODO only kept to allow conversion to the new setting getterNameTemplate in
|
||||
// CppEditor/QuickFixSetting. Remove in 4.16
|
||||
bool preferGetterNameWithoutGetPrefix = true;
|
||||
|
||||
void toSettings(const QString &category, QSettings *s) const;
|
||||
|
@@ -157,8 +157,6 @@ CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
|
||||
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
|
||||
connect(m_ui->bindStarToRightSpecifier, &QCheckBox::toggled,
|
||||
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
|
||||
connect(m_ui->preferGetterNamesWithoutGet, &QCheckBox::toggled,
|
||||
this, &CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged);
|
||||
|
||||
m_ui->categoryTab->setCurrentIndex(0);
|
||||
}
|
||||
@@ -216,7 +214,6 @@ CppCodeStyleSettings CppCodeStylePreferencesWidget::cppCodeStyleSettings() const
|
||||
set.bindStarToRightSpecifier = m_ui->bindStarToRightSpecifier->isChecked();
|
||||
set.extraPaddingForConditionsIfConfusingAlign = m_ui->extraPaddingConditions->isChecked();
|
||||
set.alignAssignments = m_ui->alignAssignments->isChecked();
|
||||
set.preferGetterNameWithoutGetPrefix = m_ui->preferGetterNamesWithoutGet->isChecked();
|
||||
|
||||
return set;
|
||||
}
|
||||
@@ -250,7 +247,6 @@ void CppCodeStylePreferencesWidget::setCodeStyleSettings(const CppCodeStyleSetti
|
||||
m_ui->bindStarToRightSpecifier->setChecked(s.bindStarToRightSpecifier);
|
||||
m_ui->extraPaddingConditions->setChecked(s.extraPaddingForConditionsIfConfusingAlign);
|
||||
m_ui->alignAssignments->setChecked(s.alignAssignments);
|
||||
m_ui->preferGetterNamesWithoutGet->setChecked(s.preferGetterNameWithoutGetPrefix);
|
||||
m_blockUpdates = wasBlocked;
|
||||
if (preview)
|
||||
updatePreview();
|
||||
|
@@ -433,33 +433,6 @@ if they would align to the next line</string>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="getterSetterTab">
|
||||
<attribute name="title">
|
||||
<string>Getter and Setter</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="preferGetterNamesWithoutGet">
|
||||
<property name="text">
|
||||
<string>Prefer getter names without "get"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Reference in New Issue
Block a user