forked from qt-creator/qt-creator
Replace BaseMode convenience class by individual implementation.
Using the convienience class does not really save code and adds another needless level in the hierarchy. This affects the three remaining BaseMode users: Help, ProjectExplorer and HelloWorld.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#define HELPCONSTANTS_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
#include <QtCore/QLatin1String>
|
||||
|
||||
namespace Help {
|
||||
namespace Constants {
|
||||
|
||||
@@ -30,20 +30,16 @@
|
||||
#include "helpmode.h"
|
||||
#include "helpconstants.h"
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
using namespace Help;
|
||||
using namespace Help::Internal;
|
||||
|
||||
HelpMode::HelpMode(QWidget *widget, QObject *parent)
|
||||
: BaseMode(parent)
|
||||
HelpMode::HelpMode(QObject *parent)
|
||||
: Core::IMode(parent),
|
||||
m_widget(0),
|
||||
m_icon(QLatin1String(":/fancyactionbar/images/mode_Reference.png"))
|
||||
{
|
||||
setObjectName(QLatin1String("HelpMode"));
|
||||
setDisplayName(tr("Help"));
|
||||
setId(QLatin1String(Constants::ID_MODE_HELP));
|
||||
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Reference.png")));
|
||||
setPriority(Constants::P_MODE_HELP);
|
||||
setWidget(widget);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,19 +30,35 @@
|
||||
#ifndef HELPMODE_H
|
||||
#define HELPMODE_H
|
||||
|
||||
#include <coreplugin/basemode.h>
|
||||
#include "helpmode.h"
|
||||
#include "helpconstants.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
#include <coreplugin/imode.h>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
namespace Help {
|
||||
namespace Internal {
|
||||
|
||||
class HelpMode : public Core::BaseMode
|
||||
class HelpMode : public Core::IMode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit HelpMode(QWidget *widget, QObject *parent = 0);
|
||||
HelpMode(QObject *parent = 0);
|
||||
|
||||
QString displayName() const { return tr("Help"); }
|
||||
QIcon icon() const { return m_icon; }
|
||||
int priority() const { return Constants::P_MODE_HELP; }
|
||||
QWidget *widget() { return m_widget; }
|
||||
QString id() const { return QLatin1String(Constants::ID_MODE_HELP); }
|
||||
QString type() const { return QString(); }
|
||||
Core::Context context() const { return Core::Context(Constants::C_MODE_HELP); }
|
||||
QString contextHelpId() const { return QString(); }
|
||||
void setWidget(QWidget *widget) { m_widget = widget; }
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
QIcon m_icon;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -342,18 +342,18 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
Core::IMode*)), this, SLOT(modeChanged(Core::IMode*, Core::IMode*)));
|
||||
|
||||
m_externalWindow = new ExternalHelpWindow;
|
||||
m_mode = new HelpMode;
|
||||
if (contextHelpOption() == Help::Constants::ExternalHelpAlways) {
|
||||
m_mode = new HelpMode(new QWidget);
|
||||
m_mode->setWidget(new QWidget);
|
||||
m_mode->setEnabled(false);
|
||||
m_externalHelpBar->setVisible(true);
|
||||
m_externalWindow->setCentralWidget(m_splitter);
|
||||
QTimer::singleShot(0, this, SLOT(showExternalWindow()));
|
||||
} else {
|
||||
m_mode = new HelpMode(m_splitter);
|
||||
m_mode->setWidget(m_splitter);
|
||||
m_internalHelpBar->setVisible(true);
|
||||
}
|
||||
addAutoReleasedObject(m_mode);
|
||||
m_mode->setContext(modecontext);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user