2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-12-08 14:30:47 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-12-08 14:30:47 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-12-08 14:30:47 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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 Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2009-12-08 14:30:47 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-12-08 14:30:47 +01:00
|
|
|
|
|
|
|
|
#include "vcsplugin.h"
|
2010-04-12 16:34:21 +02:00
|
|
|
#include "commonsettingspage.h"
|
2009-12-08 14:30:47 +01:00
|
|
|
#include "nicknamedialog.h"
|
|
|
|
|
#include "vcsbaseoutputwindow.h"
|
|
|
|
|
#include "corelistener.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/mimedatabase.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QDebug>
|
2009-12-08 14:30:47 +01:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2009-12-08 14:30:47 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsPlugin *VcsPlugin::m_instance = 0;
|
2009-12-08 14:30:47 +01:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsPlugin::VcsPlugin() :
|
2009-12-08 14:30:47 +01:00
|
|
|
m_settingsPage(0),
|
|
|
|
|
m_nickNameModel(0),
|
|
|
|
|
m_coreListener(0)
|
|
|
|
|
{
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsPlugin::~VcsPlugin()
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
|
2013-08-30 16:38:57 +02:00
|
|
|
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":/vcsbase/VcsBase.mimetypes.xml"), errorMessage))
|
2009-12-08 14:30:47 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
m_coreListener = new CoreListener;
|
|
|
|
|
addAutoReleasedObject(m_coreListener);
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
m_settingsPage = new CommonOptionsPage;
|
2009-12-08 14:30:47 +01:00
|
|
|
addAutoReleasedObject(m_settingsPage);
|
2012-01-07 12:31:48 +01:00
|
|
|
addAutoReleasedObject(VcsBaseOutputWindow::instance());
|
|
|
|
|
connect(m_settingsPage, SIGNAL(settingsChanged(VcsBase::Internal::CommonVcsSettings)),
|
|
|
|
|
this, SIGNAL(settingsChanged(VcsBase::Internal::CommonVcsSettings)));
|
|
|
|
|
connect(m_settingsPage, SIGNAL(settingsChanged(VcsBase::Internal::CommonVcsSettings)),
|
2009-12-08 14:30:47 +01:00
|
|
|
this, SLOT(slotSettingsChanged()));
|
|
|
|
|
slotSettingsChanged();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsPlugin::extensionsInitialized()
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
VcsPlugin *VcsPlugin::instance()
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
CoreListener *VcsPlugin::coreListener() const
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
return m_coreListener;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
CommonVcsSettings VcsPlugin::settings() const
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
return m_settingsPage->settings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Delayed creation/update of the nick name model. */
|
2012-01-07 12:31:48 +01:00
|
|
|
QStandardItemModel *VcsPlugin::nickNameModel()
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
if (!m_nickNameModel) {
|
|
|
|
|
m_nickNameModel = NickNameDialog::createModel(this);
|
|
|
|
|
populateNickNameModel();
|
|
|
|
|
}
|
|
|
|
|
return m_nickNameModel;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsPlugin::populateNickNameModel()
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
QString errorMessage;
|
|
|
|
|
if (!NickNameDialog::populateModelFromMailCapFile(settings().nickNameMailMap,
|
|
|
|
|
m_nickNameModel,
|
|
|
|
|
&errorMessage)) {
|
2010-04-12 16:34:21 +02:00
|
|
|
qWarning("%s", qPrintable(errorMessage));
|
|
|
|
|
}
|
2009-12-08 14:30:47 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
void VcsPlugin::slotSettingsChanged()
|
2009-12-08 14:30:47 +01:00
|
|
|
{
|
|
|
|
|
if (m_nickNameModel)
|
|
|
|
|
populateNickNameModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|
2009-12-08 14:30:47 +01:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
Q_EXPORT_PLUGIN(VcsBase::Internal::VcsPlugin)
|