Skip to content
Snippets Groups Projects
Commit 64f2d9f3 authored by hjk's avatar hjk
Browse files

Fixes: coreplugin: small fixes

    Details:  comments & codestyle
parent a438a853
No related branches found
No related tags found
No related merge requests found
......@@ -42,23 +42,25 @@ namespace Core {
/*!
\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.
if you want to prevent the closing of the whole application or to prevent the closing
of an editor window under certain conditions.
\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. 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
ICoreListener::coreAboutToClose() is called (in arbitrary order)
on all registered objects implementing this interface. If one if these calls returns
false, the process is aborted and the event is ignored.
If all calls return true, the corresponding signal is emitted and the event is accepted/performed.
ICoreListener::coreAboutToClose() is called (in arbitrary order) on all
registered objects implementing this interface. If one if these calls returns
false, the process is aborted and the event is ignored. If all calls return
true, the corresponding signal is emitted and the event is accepted/performed.
Guidelines for implementing:
\list
\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:
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
your plugin).
*/
......
......@@ -33,6 +33,8 @@
#include "inavigationwidgetfactory.h"
#include <QtGui/QKeySequence>
using namespace Core;
INavigationWidgetFactory::INavigationWidgetFactory()
......
......@@ -37,18 +37,19 @@
#include <coreplugin/core_global.h>
#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtGui/QKeySequence>
QT_BEGIN_NAMESPACE
class QToolButton;
class QKeySequence;
class QWidget;
QT_END_NAMESPACE
namespace Core {
struct NavigationView {
QWidget *widget;
QList<QToolButton *> doockToolBarWidgets;
struct NavigationView
{
QWidget *widget;
QList<QToolButton *> doockToolBarWidgets;
};
class CORE_EXPORT INavigationWidgetFactory : public QObject
......
......@@ -36,14 +36,11 @@
#include "core_global.h"
#include <QtGui/QKeySequence>
#include <coreplugin/icontext.h>
namespace Core {
class CORE_EXPORT IView
: public IContext
class CORE_EXPORT IView : public IContext
{
Q_OBJECT
public:
......
......@@ -120,7 +120,8 @@ private:
* Extensions:
* - List of suffixes and preferred suffix (derived from glob patterns).
*/
class CORE_EXPORT MimeType {
class CORE_EXPORT MimeType
{
public:
/* Return value of a glob match, which is higher than magic */
enum { GlobMatchPriority = 101 };
......
......@@ -44,41 +44,51 @@ namespace Core {
class IMode;
class RightPaneWidget;
// TODO: The right pane works only for the help plugin atm.
// It can't cope 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
// to the pool, there should be a method RightPaneWidget::setWidget(QWidget *w)
// Anyway if a second plugin wants to show something there, redesign this API
// TODO: The right pane works only for the help plugin atm. It can't cope
// 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 to the pool, there should be a method
// RightPaneWidget::setWidget(QWidget *w) Anyway if a second plugin wants to
// show something there, redesign this API
class CORE_EXPORT RightPanePlaceHolder : public QWidget
{
friend class Core::RightPaneWidget;
Q_OBJECT
public:
RightPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
~RightPanePlaceHolder();
static RightPanePlaceHolder *current();
private slots:
void currentModeChanged(Core::IMode *);
private:
void applyStoredSize(int width);
Core::IMode *m_mode;
static RightPanePlaceHolder* m_current;
};
class CORE_EXPORT BaseRightPaneWidget : public QObject
{
Q_OBJECT
public:
BaseRightPaneWidget(QWidget *widget);
~BaseRightPaneWidget();
QWidget *widget() const;
private:
QWidget *m_widget;
};
class CORE_EXPORT RightPaneWidget : public QWidget
{
Q_OBJECT
public:
RightPaneWidget();
~RightPaneWidget();
......@@ -89,11 +99,13 @@ public:
bool isShown();
void setShown(bool b);
static RightPaneWidget* instance();
static RightPaneWidget *instance();
int storedWidth();
protected:
void resizeEvent(QResizeEvent *);
private slots:
void objectAdded(QObject *obj);
void aboutToRemoveObject(QObject *obj);
......
......@@ -54,25 +54,25 @@ void Animation::paint(QPainter *painter, const QStyleOption *option)
void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
{
if (_secondaryImage.isNull() || _primaryImage.isNull())
if (m_secondaryImage.isNull() || m_primaryImage.isNull())
return;
if (_tempImage.isNull())
_tempImage = _secondaryImage;
if (m_tempImage.isNull())
m_tempImage = m_secondaryImage;
const int a = qRound(alpha*256);
const int ia = 256 - a;
const int sw = _primaryImage.width();
const int sh = _primaryImage.height();
const int bpl = _primaryImage.bytesPerLine();
switch (_primaryImage.depth()) {
const int sw = m_primaryImage.width();
const int sh = m_primaryImage.height();
const int bpl = m_primaryImage.bytesPerLine();
switch (m_primaryImage.depth()) {
case 32:
{
uchar *mixed_data = _tempImage.bits();
const uchar *back_data = _primaryImage.bits();
const uchar *front_data = _secondaryImage.bits();
uchar *mixed_data = m_tempImage.bits();
const uchar *back_data = m_primaryImage.bits();
const uchar *front_data = m_secondaryImage.bits();
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* front = (const quint32*)front_data;
for (int sx = 0; sx < sw; sx++) {
......@@ -91,27 +91,28 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
default:
break;
}
painter->drawImage(rect, _tempImage);
painter->drawImage(rect, m_tempImage);
}
void Transition::paint(QPainter *painter, const QStyleOption *option)
{
float alpha = 1.0;
if (_duration > 0) {
if (m_duration > 0) {
QTime current = QTime::currentTime();
if (_startTime > current)
_startTime = current;
if (m_startTime > current)
m_startTime = current;
int timeDiff = _startTime.msecsTo(current);
alpha = timeDiff/(float)_duration;
if (timeDiff > _duration) {
_running = false;
int timeDiff = m_startTime.msecsTo(current);
alpha = timeDiff/(float)m_duration;
if (timeDiff > m_duration) {
m_running = false;
alpha = 1.0;
}
}
else {
_running = false; }
m_running = false;
}
drawBlendedImage(painter, option->rect, alpha);
}
......
......@@ -51,24 +51,24 @@
class Animation
{
public :
Animation() : _running(true) { }
Animation() : m_running(true) { }
virtual ~Animation() { }
QWidget * widget() const { return _widget; }
bool running() const { return _running; }
const QTime &startTime() const { return _startTime; }
void setRunning(bool val) { _running = val; }
void setWidget(QWidget *widget) { _widget = widget; }
void setStartTime(const QTime &startTime) { _startTime = startTime; }
QWidget * widget() const { return m_widget; }
bool running() const { return m_running; }
const QTime &startTime() const { return m_startTime; }
void setRunning(bool val) { m_running = val; }
void setWidget(QWidget *widget) { m_widget = widget; }
void setStartTime(const QTime &startTime) { m_startTime = startTime; }
virtual void paint(QPainter *painter, const QStyleOption *option);
protected:
void drawBlendedImage(QPainter *painter, QRect rect, float value);
QTime _startTime;
QPointer<QWidget> _widget;
QImage _primaryImage;
QImage _secondaryImage;
QImage _tempImage;
bool _running;
QTime m_startTime;
QPointer<QWidget> m_widget;
QImage m_primaryImage;
QImage m_secondaryImage;
QImage m_tempImage;
bool m_running;
};
// Handles state transition animations
......@@ -76,13 +76,13 @@ class Transition : public Animation
{
public :
Transition() : Animation() {}
virtual ~Transition() { }
void setDuration(int duration) { _duration = duration; }
void setStartImage(const QImage &image) { _primaryImage = image; }
void setEndImage(const QImage &image) { _secondaryImage = image; }
virtual ~Transition() {}
void setDuration(int duration) { m_duration = duration; }
void setStartImage(const QImage &image) { m_primaryImage = image; }
void setEndImage(const QImage &image) { m_secondaryImage = image; }
virtual void paint(QPainter *painter, const QStyleOption *option);
int duration() const { return _duration; }
int _duration; //set time in ms to complete a state transition
int duration() const { return m_duration; }
int m_duration; //set time in ms to complete a state transition
};
class StyleAnimator : public QObject
......
......@@ -69,9 +69,7 @@ public:
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
// Pixmap cache should only be enabled for X11 due to slow gradients
static bool usePixmapCache() {
return true;
}
static bool usePixmapCache() { return true; }
private:
static QColor m_baseColor;
......
......@@ -36,8 +36,6 @@
#include <QtGui/QWidget>
#define TABPOSITIONINDICATOR_WIDTH 2
namespace Core {
namespace Internal {
......@@ -46,6 +44,8 @@ class TabPositionIndicator : public QWidget
Q_OBJECT
public:
enum { TABPOSITIONINDICATOR_WIDTH = 2 };
TabPositionIndicator();
int indicatorWidth() { return TABPOSITIONINDICATOR_WIDTH; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment