2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2009-06-29 14:47:04 +02:00
|
|
|
|
|
|
|
|
#include "customwidgetpluginwizardpage.h"
|
|
|
|
|
#include "customwidgetwidgetswizardpage.h"
|
|
|
|
|
|
2022-08-12 14:36:45 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2014-05-30 11:38:08 +02:00
|
|
|
#include <utils/wizard.h>
|
|
|
|
|
|
2022-08-12 14:36:45 +02:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
|
2013-10-16 11:02:37 +02:00
|
|
|
namespace QmakeProjectManager {
|
2009-06-29 14:47:04 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2017-03-18 23:56:13 +02:00
|
|
|
// Determine name for Q_EXPORT_PLUGIN
|
|
|
|
|
static inline QString createPluginName(const QString &prefix)
|
|
|
|
|
{
|
|
|
|
|
return prefix.toLower() + QLatin1String("plugin");
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-29 14:47:04 +02:00
|
|
|
CustomWidgetPluginWizardPage::CustomWidgetPluginWizardPage(QWidget *parent) :
|
|
|
|
|
QWizardPage(parent),
|
|
|
|
|
m_classCount(-1),
|
|
|
|
|
m_complete(false)
|
|
|
|
|
{
|
2022-08-12 14:36:45 +02:00
|
|
|
m_collectionClassLabel = new QLabel(tr("Collection class:"));
|
|
|
|
|
m_collectionClassEdit = new QLineEdit;
|
|
|
|
|
m_collectionHeaderLabel = new QLabel(tr("Collection header file:"));
|
|
|
|
|
m_collectionHeaderEdit = new QLineEdit;
|
|
|
|
|
m_collectionSourceLabel = new QLabel(tr("Collection source file:"));
|
|
|
|
|
m_collectionSourceEdit = new QLineEdit;
|
|
|
|
|
m_pluginNameEdit = new QLineEdit;
|
|
|
|
|
m_resourceFileEdit = new QLineEdit(tr("icons.qrc"));
|
|
|
|
|
|
|
|
|
|
using namespace Utils::Layouting;
|
|
|
|
|
Column {
|
|
|
|
|
tr("Specify the properties of the plugin library and the collection class."),
|
|
|
|
|
Space(10),
|
|
|
|
|
Form {
|
|
|
|
|
m_collectionClassLabel, m_collectionClassEdit, br,
|
|
|
|
|
m_collectionHeaderLabel, m_collectionHeaderEdit, br,
|
|
|
|
|
m_collectionSourceLabel, m_collectionSourceEdit, br,
|
|
|
|
|
tr("Plugin name:"), m_pluginNameEdit, br,
|
|
|
|
|
tr("Resource file:"), m_resourceFileEdit, br,
|
|
|
|
|
}
|
|
|
|
|
}.attachTo(this);
|
|
|
|
|
|
|
|
|
|
connect(m_collectionClassEdit, &QLineEdit::textEdited,
|
2017-03-18 23:56:13 +02:00
|
|
|
this, &CustomWidgetPluginWizardPage::slotCheckCompleteness);
|
2022-08-12 14:36:45 +02:00
|
|
|
connect(m_collectionClassEdit, &QLineEdit::textChanged,
|
2017-03-18 23:56:13 +02:00
|
|
|
this, [this](const QString &collectionClass) {
|
2022-08-12 14:36:45 +02:00
|
|
|
m_collectionHeaderEdit->setText(m_fileNamingParameters.headerFileName(collectionClass));
|
|
|
|
|
m_pluginNameEdit->setText(createPluginName(collectionClass));
|
2017-03-18 23:56:13 +02:00
|
|
|
});
|
2022-08-12 14:36:45 +02:00
|
|
|
connect(m_pluginNameEdit, &QLineEdit::textEdited,
|
2017-03-18 23:56:13 +02:00
|
|
|
this, &CustomWidgetPluginWizardPage::slotCheckCompleteness);
|
2022-08-12 14:36:45 +02:00
|
|
|
connect(m_collectionHeaderEdit, &QLineEdit::textChanged,
|
2017-03-18 23:56:13 +02:00
|
|
|
this, [this](const QString &text) {
|
2022-08-12 14:36:45 +02:00
|
|
|
m_collectionSourceEdit->setText(m_fileNamingParameters.headerToSourceFileName(text));
|
2017-03-18 23:56:13 +02:00
|
|
|
});
|
2014-05-30 11:38:08 +02:00
|
|
|
|
|
|
|
|
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Plugin Details"));
|
2009-06-29 14:47:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CustomWidgetPluginWizardPage::collectionClassName() const
|
|
|
|
|
{
|
2022-08-12 14:36:45 +02:00
|
|
|
return m_collectionClassEdit->text();
|
2009-06-29 14:47:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString CustomWidgetPluginWizardPage::pluginName() const
|
|
|
|
|
{
|
2022-08-12 14:36:45 +02:00
|
|
|
return m_pluginNameEdit->text();
|
2009-06-29 14:47:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomWidgetPluginWizardPage::init(const CustomWidgetWidgetsWizardPage *widgetsPage)
|
|
|
|
|
{
|
|
|
|
|
m_classCount = widgetsPage->classCount();
|
|
|
|
|
const QString empty;
|
|
|
|
|
if (m_classCount == 1) {
|
2022-08-12 14:36:45 +02:00
|
|
|
m_pluginNameEdit->setText(createPluginName(widgetsPage->classNameAt(0)));
|
2009-06-29 14:47:04 +02:00
|
|
|
setCollectionEnabled(false);
|
|
|
|
|
} else {
|
2022-08-12 14:36:45 +02:00
|
|
|
m_pluginNameEdit->setText(empty);
|
2009-06-29 14:47:04 +02:00
|
|
|
setCollectionEnabled(true);
|
|
|
|
|
}
|
2022-08-12 14:36:45 +02:00
|
|
|
m_collectionClassEdit->setText(empty);
|
|
|
|
|
m_collectionHeaderEdit->setText(empty);
|
|
|
|
|
m_collectionSourceEdit->setText(empty);
|
2009-06-29 14:47:04 +02:00
|
|
|
|
|
|
|
|
slotCheckCompleteness();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomWidgetPluginWizardPage::setCollectionEnabled(bool enColl)
|
|
|
|
|
{
|
2022-08-12 14:36:45 +02:00
|
|
|
m_collectionClassLabel->setEnabled(enColl);
|
|
|
|
|
m_collectionClassEdit->setEnabled(enColl);
|
|
|
|
|
m_collectionHeaderLabel->setEnabled(enColl);
|
|
|
|
|
m_collectionHeaderEdit->setEnabled(enColl);
|
|
|
|
|
m_collectionSourceLabel->setEnabled(enColl);
|
|
|
|
|
m_collectionSourceEdit->setEnabled(enColl);
|
2009-06-29 14:47:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSharedPointer<PluginOptions> CustomWidgetPluginWizardPage::basicPluginOptions() const
|
|
|
|
|
{
|
|
|
|
|
QSharedPointer<PluginOptions> po(new PluginOptions);
|
|
|
|
|
po->pluginName = pluginName();
|
2022-08-12 14:36:45 +02:00
|
|
|
po->resourceFile = m_resourceFileEdit->text();
|
2009-06-29 14:47:04 +02:00
|
|
|
po->collectionClassName = collectionClassName();
|
2022-08-12 14:36:45 +02:00
|
|
|
po->collectionHeaderFile = m_collectionHeaderEdit->text();
|
|
|
|
|
po->collectionSourceFile = m_collectionSourceEdit->text();
|
2009-06-29 14:47:04 +02:00
|
|
|
return po;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CustomWidgetPluginWizardPage::slotCheckCompleteness()
|
|
|
|
|
{
|
|
|
|
|
// A collection is complete only with class name
|
|
|
|
|
bool completeNow = false;
|
|
|
|
|
if (!pluginName().isEmpty()) {
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_classCount > 1)
|
2009-06-29 14:47:04 +02:00
|
|
|
completeNow = !collectionClassName().isEmpty();
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2009-06-29 14:47:04 +02:00
|
|
|
completeNow = true;
|
|
|
|
|
}
|
|
|
|
|
if (completeNow != m_complete) {
|
|
|
|
|
m_complete = completeNow;
|
|
|
|
|
emit completeChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CustomWidgetPluginWizardPage::isComplete() const
|
|
|
|
|
{
|
|
|
|
|
return m_complete;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2013-10-16 11:02:37 +02:00
|
|
|
} // namespace QmakeProjectManager
|