Commit be9455bc authored by hjk's avatar hjk

mode: make displayname, icon, priority, id, type data members

parent 5b7b39cb
......@@ -148,6 +148,11 @@ public:
Core::Constants::C_EDITORMANAGER,
Constants::C_ANALYZEMODE,
Core::Constants::C_NAVIGATION_PANE));
setDisplayName(tr("Analyze"));
setIcon(QIcon(":/images/analyzer_mode.png"));
setPriority(Constants::P_MODE_ANALYZE);
setId(QLatin1String(Constants::MODE_ANALYZE));
setType(Core::Constants::MODE_EDIT_TYPE);
}
~AnalyzerMode()
......@@ -159,13 +164,6 @@ public:
}
Core::EditorManager::instance()->setParent(0);
}
QString displayName() const { return tr("Analyze"); }
QIcon icon() const { return QIcon(":/images/analyzer_mode.png"); }
int priority() const { return Constants::P_MODE_ANALYZE; }
QString id() const { return QLatin1String(Constants::MODE_ANALYZE); }
QString type() const { return Core::Constants::MODE_EDIT_TYPE; }
QString contextHelpId() const { return QString(); }
};
} // namespace Internal
......
......@@ -122,6 +122,11 @@ DesignMode::DesignMode(EditorManager *editorManager) :
setEnabled(false);
setContext(Context(Constants::C_DESIGN_MODE));
setWidget(d->m_stackWidget);
setDisplayName(tr("Design"));
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Design.png")));
setPriority(Constants::P_MODE_DESIGN);
setId(Constants::MODE_DESIGN);
setType(Constants::MODE_DESIGN_TYPE);
ExtensionSystem::PluginManager::instance()->addObject(d->m_coreListener);
......@@ -141,31 +146,6 @@ DesignMode::~DesignMode()
delete d;
}
QString DesignMode::displayName() const
{
return tr("Design");
}
QIcon DesignMode::icon() const
{
return QIcon(QLatin1String(":/fancyactionbar/images/mode_Design.png"));
}
int DesignMode::priority() const
{
return Constants::P_MODE_DESIGN;
}
QString DesignMode::id() const
{
return QLatin1String(Constants::MODE_DESIGN);
}
QString DesignMode::type() const
{
return QLatin1String(Constants::MODE_DESIGN_TYPE);
}
QStringList DesignMode::registeredMimeTypes() const
{
QStringList rc;
......
......@@ -68,13 +68,6 @@ public:
QStringList registeredMimeTypes() const;
// IMode
QString displayName() const;
QIcon icon() const;
int priority() const;
QString id() const;
QString type() const;
signals:
void actionsUpdated(Core::IEditor *editor);
......
......@@ -58,6 +58,12 @@ EditMode::EditMode(EditorManager *editorManager) :
m_rightSplitWidgetLayout(new QVBoxLayout)
{
setObjectName(QLatin1String("EditMode"));
setDisplayName(tr("Edit"));
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Edit.png")));
setPriority(Constants::P_MODE_EDIT);
setId(QLatin1String(Constants::MODE_EDIT));
setType(QLatin1String(Constants::MODE_EDIT_TYPE));
m_rightSplitWidgetLayout->setSpacing(0);
m_rightSplitWidgetLayout->setMargin(0);
QWidget *rightSplitWidget = new QWidget;
......@@ -102,31 +108,6 @@ EditMode::~EditMode()
delete m_splitter;
}
QString EditMode::displayName() const
{
return tr("Edit");
}
QIcon EditMode::icon() const
{
return QIcon(QLatin1String(":/fancyactionbar/images/mode_Edit.png"));
}
int EditMode::priority() const
{
return Constants::P_MODE_EDIT;
}
QString EditMode::id() const
{
return QLatin1String(Constants::MODE_EDIT);
}
QString EditMode::type() const
{
return QLatin1String(Constants::MODE_EDIT_TYPE);
}
void EditMode::grabEditorManager(Core::IMode *mode)
{
if (mode != this)
......
......@@ -56,13 +56,6 @@ public:
EditMode(EditorManager *editorManager);
~EditMode();
// IMode
QString displayName() const;
QIcon icon() const;
int priority() const;
QString id() const;
QString type() const;
private slots:
void grabEditorManager(Core::IMode *mode);
......
......@@ -37,12 +37,10 @@
#include <QtGui/QToolButton>
QT_BEGIN_NAMESPACE
class QMenu;
class QVBoxLayout;
QT_END_NAMESPACE
namespace Core {
class IMode;
namespace Internal {
class FancyToolButton : public QToolButton
......
......@@ -82,13 +82,16 @@ public:
virtual Context context() const { return m_context; }
virtual QWidget *widget() const { return m_widget; }
virtual QString contextHelpId() const { return QString(); }
virtual QString contextHelpId() const { return m_contextHelpId; }
virtual void setContext(const Context &context) { m_context = context; }
virtual void setWidget(QWidget *widget) { m_widget = widget; }
virtual void setContextHelpId(const QString &id) { m_contextHelpId = id; }
protected:
Context m_context;
QPointer<QWidget> m_widget;
QString m_contextHelpId;
};
} // namespace Core
......
......@@ -36,11 +36,7 @@
#include "icontext.h"
#include <coreplugin/core_global.h>
QT_BEGIN_NAMESPACE
class QIcon;
QT_END_NAMESPACE
#include <QtGui/QIcon>
namespace Core {
......@@ -48,23 +44,33 @@ class CORE_EXPORT IMode : public IContext
{
Q_OBJECT
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
public:
IMode(QObject *parent = 0);
virtual ~IMode() {}
virtual QString displayName() const = 0;
virtual QIcon icon() const = 0;
virtual int priority() const = 0;
virtual QString id() const = 0;
virtual QString type() const = 0;
QString displayName() const { return m_displayName; }
QIcon icon() const { return m_icon; }
int priority() const { return m_priority; }
QString id() const { return m_id; }
QString type() const { return m_type; }
bool isEnabled() const;
void setEnabled(bool enabled);
bool isEnabled() const;
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
void setIcon(const QIcon &icon) { m_icon = icon; }
void setPriority(int priority) { m_priority = priority; }
void setId(const QString &id) { m_id = id; }
void setType(const QString &type) { m_type = type; }
signals:
void enabledStateChanged(bool enabled);
private:
QString m_displayName;
QIcon m_icon;
int m_priority;
QString m_id;
QString m_type;
bool m_isEnabled;
};
......
......@@ -63,8 +63,8 @@ public:
void init();
static ModeManager *instance();
IMode* currentMode() const;
IMode* mode(const QString &id) const;
IMode *currentMode() const;
IMode *mode(const QString &id) const;
void addAction(QAction *action, int priority);
void addProjectSelector(QAction *action);
......
......@@ -48,7 +48,6 @@ class StyledBar;
namespace Core {
class INavigationWidgetFactory;
class IMode;
class Command;
class NavigationWidget;
......
......@@ -47,7 +47,6 @@ QT_END_NAMESPACE
namespace Core {
class IMode;
class IOutputPane;
namespace Internal {
......
......@@ -499,6 +499,11 @@ public:
{
setObjectName(QLatin1String("DebugMode"));
setContext(Context(CC::C_EDITORMANAGER, C_DEBUGMODE, CC::C_NAVIGATION_PANE));
setDisplayName(DebuggerPlugin::tr("Debug"));
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Debug.png")));
setPriority(P_MODE_DEBUG);
setId(MODE_DEBUG);
setType(CC::MODE_EDIT_TYPE);
}
~DebugMode()
......@@ -507,19 +512,6 @@ public:
//EditorManager::instance()->setParent(0);
delete m_widget;
}
void setWidget(QWidget *widget)
{
m_widget = widget;
}
// IMode
QString displayName() const { return DebuggerPlugin::tr("Debug"); }
QIcon icon() const { return QIcon(__(":/fancyactionbar/images/mode_Debug.png")); }
int priority() const { return P_MODE_DEBUG; }
QString id() const { return MODE_DEBUG; }
QString type() const { return CC::MODE_EDIT_TYPE; }
QString contextHelpId() const { return QString(); }
};
......
......@@ -41,10 +41,6 @@ QT_BEGIN_NAMESPACE
class QDesignerFormWindowInterface;
QT_END_NAMESPACE
namespace Core {
class IMode;
}
namespace TextEditor {
class BaseTextDocument;
class PlainTextEditor;
......
......@@ -60,14 +60,13 @@ public:
{
setWidget(new QPushButton(tr("Hello World PushButton!")));
setContext(Core::Context("HelloWorld.MainView"));
setDisplayName(tr("Hello world!"));
setIcon(QIcon());
setPriority(0);
setId(QLatin1String("HelloWorld.HelloWorldMode"));
setType(QLatin1String("HelloWorld.HelloWorldMode"));
setContextHelpId(QString());
}
QString displayName() const { return tr("Hello world!"); }
QIcon icon() const { return QIcon(); }
int priority() const { return 0; }
QString id() const { return QLatin1String("HelloWorld.HelloWorldMode"); }
QString type() const { return QLatin1String("HelloWorld.HelloWorldMode"); }
QString contextHelpId() const { return QString(); }
};
......
......@@ -40,24 +40,12 @@ using namespace Help;
using namespace Help::Internal;
HelpMode::HelpMode(QObject *parent)
: Core::IMode(parent),
m_icon(QLatin1String(":/fancyactionbar/images/mode_Reference.png"))
: Core::IMode(parent)
{
setObjectName(QLatin1String("HelpMode"));
setContext(Core::Context(Constants::C_MODE_HELP));
}
QString HelpMode::displayName() const
{
return QCoreApplication::translate("Help::Internal::HelpMode", "Help");
}
int HelpMode::priority() const
{
return Constants::P_MODE_HELP;
}
QString HelpMode::id() const
{
return QLatin1String(Constants::ID_MODE_HELP);
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Reference.png")));
setDisplayName(QCoreApplication::translate("Help::Internal::HelpMode", "Help"));
setPriority(Constants::P_MODE_HELP);
setId(Constants::ID_MODE_HELP);
}
......@@ -46,17 +46,6 @@ class HelpMode : public Core::IMode
{
public:
explicit HelpMode(QObject *parent = 0);
QString displayName() const;
QIcon icon() const { return m_icon; }
int priority() const;
QString id() const;
QString type() const { return QString(); }
QString contextHelpId() const { return QString(); }
private:
QWidget *m_widget;
QIcon m_icon;
};
} // namespace Internal
......
......@@ -579,10 +579,11 @@ void HelpPlugin::createRightPaneContextViewer()
agg->add(m_helpViewerForSideBar);
agg->add(new HelpViewerFindSupport(m_helpViewerForSideBar));
Core::IContext *context = new Core::IContext(this);
context->setContext(Core::Context(Constants::C_HELP_SIDEBAR));
context->setWidget(m_helpViewerForSideBar);
m_core->addContextObject(context);
Core::Context context(Constants::C_HELP_SIDEBAR);
Core::IContext *icontext = new Core::IContext(this);
icontext->setContext(context);
icontext->setWidget(m_helpViewerForSideBar);
m_core->addContextObject(icontext);
QAction *copy = new QAction(this);
Core::Command *cmd = m_core->actionManager()->registerAction(copy,
......
......@@ -238,17 +238,13 @@ public:
{
setWidget(proWindow);
setContext(Core::Context(Constants::C_PROJECTEXPLORER));
setDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectsMode", "Projects"));
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Project.png")));
setPriority(Constants::P_MODE_SESSION);
setId(QLatin1String(Constants::MODE_SESSION));
setType(QString());
setContextHelpId(QLatin1String("Managing Projects"));
}
QString displayName() const { return QCoreApplication::translate("ProjectExplorer::ProjectsMode", "Projects"); }
QIcon icon() const { return QIcon(QLatin1String(":/fancyactionbar/images/mode_Project.png")); }
int priority() const { return Constants::P_MODE_SESSION; }
QString id() const { return QLatin1String(Constants::MODE_SESSION); }
QString type() const { return QString(); }
QString contextHelpId() const { return QLatin1String("Managing Projects"); }
private:
QIcon m_icon;
};
} // namespace ProjectExplorer
......
......@@ -48,11 +48,7 @@ QT_END_NAMESPACE
namespace Core {
class Context;
class IContext;
class IWizard;
class ICore;
class IEditorFactory;
class IEditor;
class IMode;
class DesignMode;
class EditorManager;
}
......
......@@ -100,6 +100,13 @@ struct WelcomeModePrivate
WelcomeMode::WelcomeMode() :
m_d(new WelcomeModePrivate)
{
setDisplayName(tr("Welcome"));
setIcon(QIcon(QLatin1String(Core::Constants::ICON_QTLOGO_32)));
setPriority(Core::Constants::P_MODE_WELCOME);
setId(QLatin1String(Core::Constants::MODE_WELCOME));
setType(QLatin1String(Core::Constants::MODE_WELCOME_TYPE));
setContextHelpId(QLatin1String("Qt Creator Manual"));
m_d->m_widget = new QWidget;
QVBoxLayout *l = new QVBoxLayout(m_d->m_widget);
l->setMargin(0);
......@@ -133,32 +140,7 @@ WelcomeMode::~WelcomeMode()
delete m_d;
}
QString WelcomeMode::displayName() const
{
return tr("Welcome");
}
QIcon WelcomeMode::icon() const
{
return QIcon(QLatin1String(Core::Constants::ICON_QTLOGO_32));
}
int WelcomeMode::priority() const
{
return Core::Constants::P_MODE_WELCOME;
}
QString WelcomeMode::id() const
{
return QLatin1String(Core::Constants::MODE_WELCOME);
}
QString WelcomeMode::type() const
{
return QLatin1String(Core::Constants::MODE_WELCOME_TYPE);
}
bool sortFunction(Utils::IWelcomePage * a, Utils::IWelcomePage *b)
bool sortFunction(Utils::IWelcomePage *a, Utils::IWelcomePage *b)
{
return a->priority() < b->priority();
}
......@@ -181,11 +163,6 @@ QToolButton *WelcomeMode::addPageToolButton(Utils::IWelcomePage *plugin, int pos
return btn;
}
QString WelcomeMode::contextHelpId() const
{
return QLatin1String("Qt Creator Manual");
}
void WelcomeMode::initPlugins()
{
m_d->buttonLayout = new QHBoxLayout(m_d->ui.navFrame);
......
......@@ -57,14 +57,7 @@ public:
WelcomeMode();
~WelcomeMode();
// IMode
QString displayName() const;
QIcon icon() const;
int priority() const;
QString id() const;
QString type() const;
void activated();
QString contextHelpId() const;
void initPlugins();
private slots:
......
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