forked from qt-creator/qt-creator
IMode: Create private class
Change-Id: I64bafc4b8f73b78b7c775192c247ed635a367a39 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -11,6 +11,21 @@
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class IModePrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QString m_displayName;
|
||||||
|
QIcon m_icon;
|
||||||
|
QMenu *m_menu = nullptr;
|
||||||
|
int m_priority = -1;
|
||||||
|
Utils::Id m_id;
|
||||||
|
bool m_isEnabled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Core::IMode
|
\class Core::IMode
|
||||||
\inheaderfile coreplugin/imode.h
|
\inheaderfile coreplugin/imode.h
|
||||||
@@ -102,17 +117,66 @@ namespace Core {
|
|||||||
|
|
||||||
Registers the mode in \QC.
|
Registers the mode in \QC.
|
||||||
*/
|
*/
|
||||||
IMode::IMode(QObject *parent) : IContext(parent)
|
IMode::IMode(QObject *parent)
|
||||||
|
: IContext(parent)
|
||||||
|
, m_d(new Internal::IModePrivate)
|
||||||
{
|
{
|
||||||
ModeManager::addMode(this);
|
ModeManager::addMode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IMode::~IMode() = default;
|
||||||
|
|
||||||
|
QString IMode::displayName() const
|
||||||
|
{
|
||||||
|
return m_d->m_displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon IMode::icon() const
|
||||||
|
{
|
||||||
|
return m_d->m_icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IMode::priority() const
|
||||||
|
{
|
||||||
|
return m_d->m_priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::Id IMode::id() const
|
||||||
|
{
|
||||||
|
return m_d->m_id;
|
||||||
|
}
|
||||||
|
|
||||||
void IMode::setEnabled(bool enabled)
|
void IMode::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
if (m_isEnabled == enabled)
|
if (m_d->m_isEnabled == enabled)
|
||||||
return;
|
return;
|
||||||
m_isEnabled = enabled;
|
m_d->m_isEnabled = enabled;
|
||||||
emit enabledStateChanged(m_isEnabled);
|
emit enabledStateChanged(m_d->m_isEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMode::setDisplayName(const QString &displayName)
|
||||||
|
{
|
||||||
|
m_d->m_displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMode::setIcon(const QIcon &icon)
|
||||||
|
{
|
||||||
|
m_d->m_icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMode::setPriority(int priority)
|
||||||
|
{
|
||||||
|
m_d->m_priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMode::setId(Utils::Id id)
|
||||||
|
{
|
||||||
|
m_d->m_id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMode::setMenu(QMenu *menu)
|
||||||
|
{
|
||||||
|
m_d->m_menu = menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FancyMainWindow *IMode::mainWindow()
|
Utils::FancyMainWindow *IMode::mainWindow()
|
||||||
@@ -122,7 +186,12 @@ Utils::FancyMainWindow *IMode::mainWindow()
|
|||||||
|
|
||||||
bool IMode::isEnabled() const
|
bool IMode::isEnabled() const
|
||||||
{
|
{
|
||||||
return m_isEnabled;
|
return m_d->m_isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu *IMode::menu() const
|
||||||
|
{
|
||||||
|
return m_d->m_menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -10,12 +10,18 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class FancyMainWindow;
|
class FancyMainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
class IModePrivate;
|
||||||
|
}
|
||||||
|
|
||||||
class CORE_EXPORT IMode : public IContext
|
class CORE_EXPORT IMode : public IContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -28,20 +34,21 @@ class CORE_EXPORT IMode : public IContext
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
IMode(QObject *parent = nullptr);
|
IMode(QObject *parent = nullptr);
|
||||||
|
~IMode();
|
||||||
|
|
||||||
QString displayName() const { return m_displayName; }
|
QString displayName() const;
|
||||||
QIcon icon() const { return m_icon; }
|
QIcon icon() const;
|
||||||
int priority() const { return m_priority; }
|
int priority() const;
|
||||||
Utils::Id id() const { return m_id; }
|
Utils::Id id() const;
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
QMenu *menu() const { return m_menu; }
|
QMenu *menu() const;
|
||||||
|
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
void setDisplayName(const QString &displayName);
|
||||||
void setIcon(const QIcon &icon) { m_icon = icon; }
|
void setIcon(const QIcon &icon);
|
||||||
void setPriority(int priority) { m_priority = priority; }
|
void setPriority(int priority);
|
||||||
void setId(Utils::Id id) { m_id = id; }
|
void setId(Utils::Id id);
|
||||||
void setMenu(QMenu *menu) { m_menu = menu; }
|
void setMenu(QMenu *menu);
|
||||||
|
|
||||||
virtual Utils::FancyMainWindow *mainWindow();
|
virtual Utils::FancyMainWindow *mainWindow();
|
||||||
|
|
||||||
@@ -49,12 +56,7 @@ signals:
|
|||||||
void enabledStateChanged(bool enabled);
|
void enabledStateChanged(bool enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_displayName;
|
std::unique_ptr<Internal::IModePrivate> m_d;
|
||||||
QIcon m_icon;
|
|
||||||
QMenu *m_menu = nullptr;
|
|
||||||
int m_priority = -1;
|
|
||||||
Utils::Id m_id;
|
|
||||||
bool m_isEnabled = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
Reference in New Issue
Block a user