1
/****************************************************************************
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of Qt Creator.
8
** Commercial License Usage
9
** Licensees holding valid commercial Qt licenses may use this file in
10
** accordance with the commercial license agreement provided with the
11
** Software or, alternatively, in accordance with the terms contained in
12
** a written agreement between you and Digia. For licensing terms and
13
** conditions see http://qt.digia.com/licensing. For further information
14
** use the contact form at http://qt.digia.com/contact-us.
16
** GNU Lesser General Public License Usage
17
** Alternatively, this file may be used under the terms of the GNU Lesser
18
** General Public License version 2.1 as published by the Free Software
19
** Foundation and appearing in the file LICENSE.LGPL included in the
20
** packaging of this file. Please review the following information to
21
** ensure the GNU Lesser General Public License version 2.1 requirements
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
** In addition, as a special exception, Digia gives you certain additional
25
** rights. These rights are described in the Digia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
****************************************************************************/
30
#include "customwidgetpluginwizardpage.h"
31
#include "customwidgetwidgetswizardpage.h"
32
#include "ui_customwidgetpluginwizardpage.h"
34
namespace QmakeProjectManager {
37
CustomWidgetPluginWizardPage::CustomWidgetPluginWizardPage(QWidget *parent) :
39
m_ui(new Ui::CustomWidgetPluginWizardPage),
44
connect(m_ui->collectionClassEdit, SIGNAL(textEdited(QString)), this, SLOT(slotCheckCompleteness()));
45
connect(m_ui->pluginNameEdit, SIGNAL(textEdited(QString)), this, SLOT(slotCheckCompleteness()));
48
CustomWidgetPluginWizardPage::~CustomWidgetPluginWizardPage()
53
QString CustomWidgetPluginWizardPage::collectionClassName() const
55
return m_ui->collectionClassEdit->text();
58
QString CustomWidgetPluginWizardPage::pluginName() const
60
return m_ui->pluginNameEdit->text();
63
// Determine name for Q_EXPORT_PLUGIN
64
static inline QString createPluginName(const QString &prefix)
66
return prefix.toLower() + QLatin1String("plugin");
69
void CustomWidgetPluginWizardPage::init(const CustomWidgetWidgetsWizardPage *widgetsPage)
71
m_classCount = widgetsPage->classCount();
73
if (m_classCount == 1) {
74
m_ui->pluginNameEdit->setText(createPluginName(widgetsPage->classNameAt(0)));
75
setCollectionEnabled(false);
77
m_ui->pluginNameEdit->setText(empty);
78
setCollectionEnabled(true);
80
m_ui->collectionClassEdit->setText(empty);
81
m_ui->collectionHeaderEdit->setText(empty);
82
m_ui->collectionSourceEdit->setText(empty);
84
slotCheckCompleteness();
87
void CustomWidgetPluginWizardPage::setCollectionEnabled(bool enColl)
89
m_ui->collectionClassLabel->setEnabled(enColl);
90
m_ui->collectionClassEdit->setEnabled(enColl);
91
m_ui->collectionHeaderLabel->setEnabled(enColl);
92
m_ui->collectionHeaderEdit->setEnabled(enColl);
93
m_ui->collectionSourceLabel->setEnabled(enColl);
94
m_ui->collectionSourceEdit->setEnabled(enColl);
97
void CustomWidgetPluginWizardPage::on_collectionClassEdit_textChanged()
99
const QString collectionClass = collectionClassName();
100
m_ui->collectionHeaderEdit->setText(m_fileNamingParameters.headerFileName(collectionClass));
101
m_ui->pluginNameEdit->setText(createPluginName(collectionClass));
104
void CustomWidgetPluginWizardPage::on_collectionHeaderEdit_textChanged()
106
m_ui->collectionSourceEdit->setText(m_fileNamingParameters.headerToSourceFileName(m_ui->collectionHeaderEdit->text()));
109
QSharedPointer<PluginOptions> CustomWidgetPluginWizardPage::basicPluginOptions() const
111
QSharedPointer<PluginOptions> po(new PluginOptions);
112
po->pluginName = pluginName();
113
po->resourceFile = m_ui->resourceFileEdit->text();
114
po->collectionClassName = collectionClassName();
115
po->collectionHeaderFile = m_ui->collectionHeaderEdit->text();
116
po->collectionSourceFile = m_ui->collectionSourceEdit->text();
120
void CustomWidgetPluginWizardPage::slotCheckCompleteness()
122
// A collection is complete only with class name
123
bool completeNow = false;
124
if (!pluginName().isEmpty()) {
125
if (m_classCount > 1)
126
completeNow = !collectionClassName().isEmpty();
130
if (completeNow != m_complete) {
131
m_complete = completeNow;
132
emit completeChanged();
136
bool CustomWidgetPluginWizardPage::isComplete() const
141
} // namespace Internal
142
} // namespace QmakeProjectManager