Commit 5e68c2af authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Don't create Welcome mode pages when there is no Welcome mode

Fixes creating these pages unnecessarily when the Welcome plugin is not
loaded, as well as "leaking" them in that case.

Reviewed-by: con
parent 66e02011
......@@ -184,8 +184,7 @@ struct ProjectExplorerPluginPrivate {
QString m_projectFilterString;
Internal::MiniProjectTargetSelector * m_targetSelector;
Internal::ProjectExplorerSettings m_projectExplorerSettings;
Internal::ProjectWelcomePage *m_welcomePlugin;
Internal::ProjectWelcomePageWidget *m_welcomePage;
Internal::ProjectWelcomePage *m_welcomePage;
Core::BaseMode * m_projectsMode;
};
......@@ -217,8 +216,8 @@ ProjectExplorerPlugin::ProjectExplorerPlugin()
ProjectExplorerPlugin::~ProjectExplorerPlugin()
{
removeObject(d->m_welcomePlugin);
delete d->m_welcomePlugin;
removeObject(d->m_welcomePage);
delete d->m_welcomePage;
removeObject(this);
delete d;
}
......@@ -242,11 +241,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
Core::ICore *core = Core::ICore::instance();
Core::ActionManager *am = core->actionManager();
d->m_welcomePlugin = new ProjectWelcomePage;
d->m_welcomePage = qobject_cast<Internal::ProjectWelcomePageWidget*>(d->m_welcomePlugin->page());
Q_ASSERT(d->m_welcomePage);
d->m_welcomePage = new ProjectWelcomePage;
connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
addObject(d->m_welcomePlugin);
addObject(d->m_welcomePage);
addObject(this);
connect(core->fileManager(), SIGNAL(currentFileChanged(QString)),
......@@ -1127,7 +1124,6 @@ Project *ProjectExplorerPlugin::startupProject() const
return pro;
}
// update welcome page
void ProjectExplorerPlugin::updateWelcomePage()
{
ProjectWelcomePageWidget::WelcomePageData welcomePageData;
......@@ -1135,16 +1131,15 @@ void ProjectExplorerPlugin::updateWelcomePage()
welcomePageData.activeSession = d->m_session->activeSession();
welcomePageData.previousSession = d->m_session->lastSession();
welcomePageData.projectList = d->m_recentProjects;
d->m_welcomePage->updateWelcomePage(welcomePageData);
d->m_welcomePage->setWelcomePageData(welcomePageData);
}
void ProjectExplorerPlugin::currentModeChanged(Core::IMode *mode, Core::IMode *oldMode)
{
if (mode && mode->id() == QLatin1String(Core::Constants::MODE_WELCOME))
updateWelcomePage();
if (oldMode == d->m_projectsMode) {
if (oldMode == d->m_projectsMode)
savePersistentSettings();
}
}
void ProjectExplorerPlugin::determineSessionToRestoreAtStartup()
......
......@@ -34,19 +34,31 @@ namespace ProjectExplorer {
namespace Internal {
ProjectWelcomePage::ProjectWelcomePage()
: m_page(new ProjectWelcomePageWidget)
: m_page(0)
{
}
ProjectWelcomePage::~ProjectWelcomePage()
QWidget *ProjectWelcomePage::page()
{
if (!m_page) {
m_page = new ProjectWelcomePageWidget;
// Forward signals
connect(m_page, SIGNAL(requestProject(QString)), this, SIGNAL(requestProject(QString)));
connect(m_page, SIGNAL(requestSession(QString)), this, SIGNAL(requestSession(QString)));
connect(m_page, SIGNAL(manageSessions()), this, SIGNAL(manageSessions()));
m_page->updateWelcomePage(m_welcomePageData);
}
return m_page;
}
QWidget* ProjectWelcomePage::page()
void ProjectWelcomePage::setWelcomePageData(const ProjectWelcomePageWidget::WelcomePageData &welcomePageData)
{
return m_page;
m_welcomePageData = welcomePageData;
if (m_page)
m_page->updateWelcomePage(welcomePageData);
}
} // namespace Internal
......
......@@ -32,25 +32,31 @@
#include <utils/iwelcomepage.h>
#include "projectwelcomepagewidget.h"
namespace ProjectExplorer {
namespace Internal {
class ProjectWelcomePageWidget;
class ProjectWelcomePage : public Utils::IWelcomePage
{
Q_OBJECT
public:
ProjectWelcomePage();
~ProjectWelcomePage();
QWidget *page();
QString title() const { return tr("Develop"); }
int priority() const { return 20; }
private:
ProjectWelcomePageWidget *m_page;
void setWelcomePageData(const ProjectWelcomePageWidget::WelcomePageData &welcomePageData);
signals:
void requestProject(const QString &project);
void requestSession(const QString &session);
void manageSessions();
private:
ProjectWelcomePageWidget *m_page;
ProjectWelcomePageWidget::WelcomePageData m_welcomePageData;
};
} // namespace Internal
......
......@@ -84,7 +84,6 @@ ProjectWelcomePageWidget::ProjectWelcomePageWidget(QWidget *parent) :
connect(ui->projTreeWidget, SIGNAL(activated(QString)), SLOT(slotProjectClicked(QString)));
connect(ui->createNewProjectButton, SIGNAL(clicked()), SLOT(slotCreateNewProject()));
connect(ui->manageSessionsButton, SIGNAL(clicked()), SIGNAL(manageSessions()));
}
ProjectWelcomePageWidget::~ProjectWelcomePageWidget()
......
......@@ -34,20 +34,21 @@
namespace ProjectExplorer {
namespace Internal {
namespace Internal {
namespace Ui {
class ProjectWelcomePageWidget;
}
class ProjectWelcomePageWidget : public QWidget {
class ProjectWelcomePageWidget : public QWidget
{
Q_OBJECT
public:
ProjectWelcomePageWidget(QWidget *parent = 0);
~ProjectWelcomePageWidget();
struct WelcomePageData{
struct WelcomePageData {
bool operator==(const WelcomePageData &rhs) const;
bool operator!=(const WelcomePageData &rhs) const;
......@@ -75,7 +76,7 @@ private:
WelcomePageData lastData;
};
}
}
} // namespace Internal
} // namespace ProjectExplorer
#endif // PROJECTWELCOMEPAGEWIDGET_H
......@@ -34,14 +34,24 @@ namespace Qt4ProjectManager {
namespace Internal {
GettingStartedWelcomePage::GettingStartedWelcomePage()
: m_page(new GettingStartedWelcomePageWidget)
: m_page(0)
{
}
QWidget* GettingStartedWelcomePage::page()
QWidget *GettingStartedWelcomePage::page()
{
if (!m_page)
m_page = new GettingStartedWelcomePageWidget;
return m_page;
}
void GettingStartedWelcomePage::updateExamples(const QString &examplePath,
const QString &demosPath,
const QString &sourcePath)
{
if (m_page)
m_page->updateExamples(examplePath, demosPath, sourcePath);
}
} // namespace Internal
} // namespace Qt4ProjectManager
......@@ -47,6 +47,11 @@ public:
QString title() const { return tr("Getting Started");}
int priority() const { return 10; }
public slots:
void updateExamples(const QString &examplePath,
const QString &demosPath,
const QString &sourcePath);
private:
GettingStartedWelcomePageWidget *m_page;
};
......
......@@ -99,7 +99,9 @@ GettingStartedWelcomePageWidget::~GettingStartedWelcomePageWidget()
delete ui;
}
void GettingStartedWelcomePageWidget::updateExamples(const QString& examplePath, const QString& demosPath, const QString &sourcePath)
void GettingStartedWelcomePageWidget::updateExamples(const QString &examplePath,
const QString &demosPath,
const QString &sourcePath)
{
QString demoxml = demosPath + "/qtdemo/xml/examples.xml";
if (!QFile::exists(demoxml)) {
......
......@@ -39,18 +39,21 @@ namespace Ui {
class GettingStartedWelcomePageWidget;
}
class GettingStartedWelcomePageWidget : public QWidget {
class GettingStartedWelcomePageWidget : public QWidget
{
Q_OBJECT
public:
GettingStartedWelcomePageWidget(QWidget *parent = 0);
~GettingStartedWelcomePageWidget();
public slots:
void updateExamples(const QString& examplePath, const QString& demosPath, const QString &sourcePath);
public slots:
void updateExamples(const QString &examplePath,
const QString &demosPath,
const QString &sourcePath);
private slots:
void slotOpenHelpPage(const QString& url);
void slotOpenContextHelpPage(const QString& url);
void slotOpenHelpPage(const QString &url);
void slotOpenContextHelpPage(const QString &url);
void slotEnableExampleButton(int);
void slotOpenExample();
void slotNextTip();
......@@ -63,7 +66,7 @@ private:
int m_currentTip;
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif // GETTINGSTARTEDWELCOMEPAGEWIDGET_H
......@@ -47,7 +47,6 @@
#include "qtoptionspage.h"
#include "externaleditors.h"
#include "gettingstartedwelcomepage.h"
#include "gettingstartedwelcomepagewidget.h"
#include "qt-maemo/maemomanager.h"
#include "qt-s60/s60manager.h"
......@@ -103,16 +102,14 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
m_projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
Core::ActionManager *am = core->actionManager();
QtVersionManager *mgr = new QtVersionManager();
QtVersionManager *mgr = new QtVersionManager;
addAutoReleasedObject(mgr);
addAutoReleasedObject(new QtOptionsPage());
addAutoReleasedObject(new QtOptionsPage);
m_welcomePage = new GettingStartedWelcomePage;
addObject(m_welcomePage);
GettingStartedWelcomePageWidget *gswp =
static_cast<GettingStartedWelcomePageWidget*>(m_welcomePage->page());
connect(mgr, SIGNAL(updateExamples(QString,QString,QString)),
gswp, SLOT(updateExamples(QString,QString,QString)));
m_welcomePage, SLOT(updateExamples(QString,QString,QString)));
//create and register objects
m_qt4ProjectManager = new Qt4Manager(this);
......
......@@ -227,7 +227,6 @@ void QtVersionManager::updateExamples()
versions.append(m_versions);
QString examplesPath;
QString docPath;
QString demosPath;
QtVersion *version = 0;
// try to find a version which has both, demos and examples
......
......@@ -35,12 +35,14 @@ namespace Welcome {
namespace Internal {
CommunityWelcomePage::CommunityWelcomePage()
: m_page(new CommunityWelcomePageWidget)
: m_page(0)
{
}
QWidget* CommunityWelcomePage::page()
QWidget *CommunityWelcomePage::page()
{
if (!m_page)
m_page = new CommunityWelcomePageWidget;
return m_page;
}
......
......@@ -51,7 +51,6 @@ public:
private:
CommunityWelcomePageWidget *m_page;
};
} // namespace Internal
......
......@@ -156,8 +156,8 @@ void WelcomeMode::initPlugins()
delete m_d->ui.stackedWidget->currentWidget();
QList<IWelcomePage*> plugins = PluginManager::instance()->getObjects<IWelcomePage>();
qSort(plugins.begin(), plugins.end(), &sortFunction);
foreach (IWelcomePage* plugin, plugins) {
QToolButton * btn = new QToolButton;
foreach (IWelcomePage *plugin, plugins) {
QToolButton *btn = new QToolButton;
btn->setCheckable(true);
btn->setText(plugin->title());
btn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment