forked from qt-creator/qt-creator
Fixes: coreplugin: small fixes
Details: comments & codestyle
This commit is contained in:
@@ -42,23 +42,25 @@ namespace Core {
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Core::ICoreListener
|
\class Core::ICoreListener
|
||||||
\brief Provides a hook for plugins to veto on certain events emitted from the core plugin.
|
|
||||||
|
|
||||||
You implement this interface if you want to prevent certain events from occurring, e.g.
|
\brief Provides a hook for plugins to veto on certain events emitted from
|
||||||
if you want to prevent the closing of the whole application or to prevent the closing
|
the core plugin.
|
||||||
of an editor window under certain conditions.
|
|
||||||
|
You implement this interface if you want to prevent certain events from
|
||||||
|
occurring, e.g. if you want to prevent the closing of the whole application
|
||||||
|
or to prevent the closing of an editor window under certain conditions.
|
||||||
|
|
||||||
If e.g. the application window requests a close, then first
|
If e.g. the application window requests a close, then first
|
||||||
ICoreListener::coreAboutToClose() is called (in arbitrary order)
|
ICoreListener::coreAboutToClose() is called (in arbitrary order) on all
|
||||||
on all registered objects implementing this interface. If one if these calls returns
|
registered objects implementing this interface. If one if these calls returns
|
||||||
false, the process is aborted and the event is ignored.
|
false, the process is aborted and the event is ignored. If all calls return
|
||||||
If all calls return true, the corresponding signal is emitted and the event is accepted/performed.
|
true, the corresponding signal is emitted and the event is accepted/performed.
|
||||||
|
|
||||||
Guidelines for implementing:
|
Guidelines for implementing:
|
||||||
\list
|
\list
|
||||||
\o Return false from the implemented method if you want to prevent the event.
|
\o Return false from the implemented method if you want to prevent the event.
|
||||||
\o You need to add your implementing object to the plugin managers objects:
|
\o You need to add your implementing object to the plugin managers objects:
|
||||||
ICore::pluginManager()->addObject(yourImplementingObject);
|
ExtensionSystem::PluginManager::instance()->addObject(yourImplementingObject);
|
||||||
\o Don't forget to remove the object again at deconstruction (e.g. in the destructor of
|
\o Don't forget to remove the object again at deconstruction (e.g. in the destructor of
|
||||||
your plugin).
|
your plugin).
|
||||||
*/
|
*/
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "inavigationwidgetfactory.h"
|
#include "inavigationwidgetfactory.h"
|
||||||
|
|
||||||
|
#include <QtGui/QKeySequence>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
INavigationWidgetFactory::INavigationWidgetFactory()
|
INavigationWidgetFactory::INavigationWidgetFactory()
|
||||||
|
@@ -37,16 +37,17 @@
|
|||||||
#include <coreplugin/core_global.h>
|
#include <coreplugin/core_global.h>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtGui/QKeySequence>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
|
class QKeySequence;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
struct NavigationView {
|
struct NavigationView
|
||||||
|
{
|
||||||
QWidget *widget;
|
QWidget *widget;
|
||||||
QList<QToolButton *> doockToolBarWidgets;
|
QList<QToolButton *> doockToolBarWidgets;
|
||||||
};
|
};
|
||||||
|
@@ -36,14 +36,11 @@
|
|||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtGui/QKeySequence>
|
|
||||||
|
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class CORE_EXPORT IView
|
class CORE_EXPORT IView : public IContext
|
||||||
: public IContext
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@@ -120,7 +120,8 @@ private:
|
|||||||
* Extensions:
|
* Extensions:
|
||||||
* - List of suffixes and preferred suffix (derived from glob patterns).
|
* - List of suffixes and preferred suffix (derived from glob patterns).
|
||||||
*/
|
*/
|
||||||
class CORE_EXPORT MimeType {
|
class CORE_EXPORT MimeType
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
/* Return value of a glob match, which is higher than magic */
|
/* Return value of a glob match, which is higher than magic */
|
||||||
enum { GlobMatchPriority = 101 };
|
enum { GlobMatchPriority = 101 };
|
||||||
|
@@ -44,41 +44,51 @@ namespace Core {
|
|||||||
class IMode;
|
class IMode;
|
||||||
class RightPaneWidget;
|
class RightPaneWidget;
|
||||||
|
|
||||||
// TODO: The right pane works only for the help plugin atm.
|
// TODO: The right pane works only for the help plugin atm. It can't cope
|
||||||
// It can't cope with more than one plugin publishing objects they want in the right pane
|
// with more than one plugin publishing objects they want in the right pane
|
||||||
// For that the API would need to be different. (Might be that instead of adding objects
|
// For that the API would need to be different. (Might be that instead of
|
||||||
// to the pool, there should be a method RightPaneWidget::setWidget(QWidget *w)
|
// adding objects to the pool, there should be a method
|
||||||
// Anyway if a second plugin wants to show something there, redesign this API
|
// RightPaneWidget::setWidget(QWidget *w) Anyway if a second plugin wants to
|
||||||
|
// show something there, redesign this API
|
||||||
|
|
||||||
class CORE_EXPORT RightPanePlaceHolder : public QWidget
|
class CORE_EXPORT RightPanePlaceHolder : public QWidget
|
||||||
{
|
{
|
||||||
friend class Core::RightPaneWidget;
|
friend class Core::RightPaneWidget;
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RightPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
RightPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
||||||
~RightPanePlaceHolder();
|
~RightPanePlaceHolder();
|
||||||
static RightPanePlaceHolder *current();
|
static RightPanePlaceHolder *current();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void currentModeChanged(Core::IMode *);
|
void currentModeChanged(Core::IMode *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applyStoredSize(int width);
|
void applyStoredSize(int width);
|
||||||
Core::IMode *m_mode;
|
Core::IMode *m_mode;
|
||||||
static RightPanePlaceHolder* m_current;
|
static RightPanePlaceHolder* m_current;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CORE_EXPORT BaseRightPaneWidget : public QObject
|
class CORE_EXPORT BaseRightPaneWidget : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseRightPaneWidget(QWidget *widget);
|
BaseRightPaneWidget(QWidget *widget);
|
||||||
~BaseRightPaneWidget();
|
~BaseRightPaneWidget();
|
||||||
QWidget *widget() const;
|
QWidget *widget() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_widget;
|
QWidget *m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CORE_EXPORT RightPaneWidget : public QWidget
|
class CORE_EXPORT RightPaneWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RightPaneWidget();
|
RightPaneWidget();
|
||||||
~RightPaneWidget();
|
~RightPaneWidget();
|
||||||
@@ -92,8 +102,10 @@ public:
|
|||||||
static RightPaneWidget *instance();
|
static RightPaneWidget *instance();
|
||||||
|
|
||||||
int storedWidth();
|
int storedWidth();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void objectAdded(QObject *obj);
|
void objectAdded(QObject *obj);
|
||||||
void aboutToRemoveObject(QObject *obj);
|
void aboutToRemoveObject(QObject *obj);
|
||||||
|
@@ -54,23 +54,23 @@ void Animation::paint(QPainter *painter, const QStyleOption *option)
|
|||||||
|
|
||||||
void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
|
void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
|
||||||
{
|
{
|
||||||
if (_secondaryImage.isNull() || _primaryImage.isNull())
|
if (m_secondaryImage.isNull() || m_primaryImage.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_tempImage.isNull())
|
if (m_tempImage.isNull())
|
||||||
_tempImage = _secondaryImage;
|
m_tempImage = m_secondaryImage;
|
||||||
|
|
||||||
const int a = qRound(alpha*256);
|
const int a = qRound(alpha*256);
|
||||||
const int ia = 256 - a;
|
const int ia = 256 - a;
|
||||||
const int sw = _primaryImage.width();
|
const int sw = m_primaryImage.width();
|
||||||
const int sh = _primaryImage.height();
|
const int sh = m_primaryImage.height();
|
||||||
const int bpl = _primaryImage.bytesPerLine();
|
const int bpl = m_primaryImage.bytesPerLine();
|
||||||
switch (_primaryImage.depth()) {
|
switch (m_primaryImage.depth()) {
|
||||||
case 32:
|
case 32:
|
||||||
{
|
{
|
||||||
uchar *mixed_data = _tempImage.bits();
|
uchar *mixed_data = m_tempImage.bits();
|
||||||
const uchar *back_data = _primaryImage.bits();
|
const uchar *back_data = m_primaryImage.bits();
|
||||||
const uchar *front_data = _secondaryImage.bits();
|
const uchar *front_data = m_secondaryImage.bits();
|
||||||
for (int sy = 0; sy < sh; sy++) {
|
for (int sy = 0; sy < sh; sy++) {
|
||||||
quint32 *mixed = (quint32*)mixed_data;
|
quint32 *mixed = (quint32*)mixed_data;
|
||||||
const quint32* back = (const quint32*)back_data;
|
const quint32* back = (const quint32*)back_data;
|
||||||
@@ -91,27 +91,28 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
painter->drawImage(rect, _tempImage);
|
painter->drawImage(rect, m_tempImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transition::paint(QPainter *painter, const QStyleOption *option)
|
void Transition::paint(QPainter *painter, const QStyleOption *option)
|
||||||
{
|
{
|
||||||
float alpha = 1.0;
|
float alpha = 1.0;
|
||||||
if (_duration > 0) {
|
if (m_duration > 0) {
|
||||||
QTime current = QTime::currentTime();
|
QTime current = QTime::currentTime();
|
||||||
|
|
||||||
if (_startTime > current)
|
if (m_startTime > current)
|
||||||
_startTime = current;
|
m_startTime = current;
|
||||||
|
|
||||||
int timeDiff = _startTime.msecsTo(current);
|
int timeDiff = m_startTime.msecsTo(current);
|
||||||
alpha = timeDiff/(float)_duration;
|
alpha = timeDiff/(float)m_duration;
|
||||||
if (timeDiff > _duration) {
|
if (timeDiff > m_duration) {
|
||||||
_running = false;
|
m_running = false;
|
||||||
alpha = 1.0;
|
alpha = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_running = false; }
|
m_running = false;
|
||||||
|
}
|
||||||
drawBlendedImage(painter, option->rect, alpha);
|
drawBlendedImage(painter, option->rect, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,24 +51,24 @@
|
|||||||
class Animation
|
class Animation
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
Animation() : _running(true) { }
|
Animation() : m_running(true) { }
|
||||||
virtual ~Animation() { }
|
virtual ~Animation() { }
|
||||||
QWidget * widget() const { return _widget; }
|
QWidget * widget() const { return m_widget; }
|
||||||
bool running() const { return _running; }
|
bool running() const { return m_running; }
|
||||||
const QTime &startTime() const { return _startTime; }
|
const QTime &startTime() const { return m_startTime; }
|
||||||
void setRunning(bool val) { _running = val; }
|
void setRunning(bool val) { m_running = val; }
|
||||||
void setWidget(QWidget *widget) { _widget = widget; }
|
void setWidget(QWidget *widget) { m_widget = widget; }
|
||||||
void setStartTime(const QTime &startTime) { _startTime = startTime; }
|
void setStartTime(const QTime &startTime) { m_startTime = startTime; }
|
||||||
virtual void paint(QPainter *painter, const QStyleOption *option);
|
virtual void paint(QPainter *painter, const QStyleOption *option);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void drawBlendedImage(QPainter *painter, QRect rect, float value);
|
void drawBlendedImage(QPainter *painter, QRect rect, float value);
|
||||||
QTime _startTime;
|
QTime m_startTime;
|
||||||
QPointer<QWidget> _widget;
|
QPointer<QWidget> m_widget;
|
||||||
QImage _primaryImage;
|
QImage m_primaryImage;
|
||||||
QImage _secondaryImage;
|
QImage m_secondaryImage;
|
||||||
QImage _tempImage;
|
QImage m_tempImage;
|
||||||
bool _running;
|
bool m_running;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles state transition animations
|
// Handles state transition animations
|
||||||
@@ -77,12 +77,12 @@ class Transition : public Animation
|
|||||||
public :
|
public :
|
||||||
Transition() : Animation() {}
|
Transition() : Animation() {}
|
||||||
virtual ~Transition() {}
|
virtual ~Transition() {}
|
||||||
void setDuration(int duration) { _duration = duration; }
|
void setDuration(int duration) { m_duration = duration; }
|
||||||
void setStartImage(const QImage &image) { _primaryImage = image; }
|
void setStartImage(const QImage &image) { m_primaryImage = image; }
|
||||||
void setEndImage(const QImage &image) { _secondaryImage = image; }
|
void setEndImage(const QImage &image) { m_secondaryImage = image; }
|
||||||
virtual void paint(QPainter *painter, const QStyleOption *option);
|
virtual void paint(QPainter *painter, const QStyleOption *option);
|
||||||
int duration() const { return _duration; }
|
int duration() const { return m_duration; }
|
||||||
int _duration; //set time in ms to complete a state transition
|
int m_duration; //set time in ms to complete a state transition
|
||||||
};
|
};
|
||||||
|
|
||||||
class StyleAnimator : public QObject
|
class StyleAnimator : public QObject
|
||||||
|
@@ -69,9 +69,7 @@ public:
|
|||||||
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
|
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
|
||||||
|
|
||||||
// Pixmap cache should only be enabled for X11 due to slow gradients
|
// Pixmap cache should only be enabled for X11 due to slow gradients
|
||||||
static bool usePixmapCache() {
|
static bool usePixmapCache() { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QColor m_baseColor;
|
static QColor m_baseColor;
|
||||||
|
@@ -36,8 +36,6 @@
|
|||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
#define TABPOSITIONINDICATOR_WIDTH 2
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -46,6 +44,8 @@ class TabPositionIndicator : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum { TABPOSITIONINDICATOR_WIDTH = 2 };
|
||||||
|
|
||||||
TabPositionIndicator();
|
TabPositionIndicator();
|
||||||
int indicatorWidth() { return TABPOSITIONINDICATOR_WIDTH; }
|
int indicatorWidth() { return TABPOSITIONINDICATOR_WIDTH; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user