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