2009-04-06 16:09:34 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef DESKTOPCHANGEOSD_H
|
|
|
|
#define DESKTOPCHANGEOSD_H
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <KDE/Plasma/FrameSvg>
|
2010-06-01 18:23:14 +00:00
|
|
|
#include <KDE/Plasma/Theme>
|
|
|
|
#include <KDE/Plasma/WindowEffects>
|
2010-02-06 22:41:34 +00:00
|
|
|
#include <QWeakPointer>
|
2009-04-06 16:09:34 +00:00
|
|
|
|
|
|
|
class QGraphicsScene;
|
2010-02-06 22:41:34 +00:00
|
|
|
class QPropertyAnimation;
|
2009-04-06 16:09:34 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
class Workspace;
|
|
|
|
|
|
|
|
class DesktopChangeText : public QGraphicsItem
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DesktopChangeText(Workspace* ws);
|
|
|
|
~DesktopChangeText();
|
2009-04-06 16:09:34 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
enum { Type = UserType + 2 };
|
2009-04-06 16:09:34 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
inline void setWidth(float width) {
|
|
|
|
m_width = width;
|
|
|
|
};
|
|
|
|
inline void setHeight(float height) {
|
|
|
|
m_height = height;
|
|
|
|
};
|
2009-04-06 16:09:34 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
virtual QRectF boundingRect() const;
|
|
|
|
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
|
|
|
|
inline virtual int type() const {
|
|
|
|
return Type;
|
2009-04-06 16:09:34 +00:00
|
|
|
};
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
|
|
|
Workspace* m_wspace;
|
|
|
|
float m_width;
|
|
|
|
float m_height;
|
|
|
|
};
|
|
|
|
|
2009-04-06 16:09:34 +00:00
|
|
|
class DesktopChangeOSD : public QGraphicsView
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-06-27 15:45:49 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
DesktopChangeOSD(Workspace* ws);
|
|
|
|
~DesktopChangeOSD();
|
|
|
|
|
|
|
|
void reconfigure();
|
|
|
|
void numberDesktopsChanged();
|
|
|
|
|
|
|
|
inline Plasma::FrameSvg* itemFrame() {
|
|
|
|
return &m_item_frame;
|
|
|
|
};
|
|
|
|
inline int& getDelayTime() {
|
|
|
|
return m_delayTime;
|
2009-04-06 16:09:34 +00:00
|
|
|
};
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
protected:
|
|
|
|
virtual void hideEvent(QHideEvent*);
|
|
|
|
virtual void drawBackground(QPainter* painter, const QRectF& rect);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void resize();
|
|
|
|
Workspace* m_wspace;
|
|
|
|
Plasma::FrameSvg m_frame;
|
|
|
|
Plasma::FrameSvg m_item_frame;
|
|
|
|
QGraphicsScene* m_scene;
|
|
|
|
bool m_active;
|
|
|
|
QTimer m_delayedHideTimer;
|
|
|
|
bool m_show;
|
|
|
|
int m_delayTime;
|
|
|
|
bool m_textOnly;
|
2011-06-27 15:45:49 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void desktopChanged(int old);
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
|
|
|
|
2009-04-06 16:09:34 +00:00
|
|
|
class DesktopChangeItem : public QObject, public QGraphicsItem
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-04-06 16:09:34 +00:00
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
Q_PROPERTY(qreal arrowValue READ arrowValue WRITE setArrowValue)
|
|
|
|
Q_PROPERTY(qreal highLightValue READ highLightValue WRITE setHighLightValue)
|
2010-02-06 22:41:34 +00:00
|
|
|
|
2009-10-05 07:58:12 +00:00
|
|
|
Q_INTERFACES(QGraphicsItem)
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
DesktopChangeItem(Workspace* ws, DesktopChangeOSD* parent, int desktop);
|
|
|
|
~DesktopChangeItem();
|
|
|
|
enum { Type = UserType + 1 };
|
|
|
|
void startDesktopHighLightAnimation(int time);
|
|
|
|
void stopDesktopHighLightAnimation();
|
|
|
|
|
|
|
|
inline void setWidth(float width) {
|
|
|
|
m_width = width;
|
|
|
|
};
|
|
|
|
inline void setHeight(float height) {
|
|
|
|
m_height = height;
|
|
|
|
};
|
|
|
|
inline int desktop() const {
|
|
|
|
return m_desktop;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual QRectF boundingRect() const;
|
|
|
|
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
|
|
|
|
inline virtual int type() const {
|
|
|
|
return Type;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Arrow {
|
|
|
|
NONE,
|
|
|
|
LEFT,
|
|
|
|
RIGHT,
|
|
|
|
UP,
|
|
|
|
DOWN
|
2009-04-06 16:09:34 +00:00
|
|
|
};
|
2011-01-30 14:34:42 +00:00
|
|
|
void setArrow(Arrow arrow, int start_delay, int hide_delay);
|
|
|
|
|
|
|
|
qreal arrowValue() const;
|
|
|
|
qreal highLightValue() const;
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void setArrowValue(qreal value);
|
|
|
|
void setHighLightValue(qreal value);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void showArrow();
|
|
|
|
void hideArrow();
|
|
|
|
void arrowAnimationFinished();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Workspace* m_wspace;
|
|
|
|
DesktopChangeOSD* m_parent;
|
|
|
|
int m_desktop;
|
|
|
|
float m_width;
|
|
|
|
float m_height;
|
|
|
|
QTimer m_delayed_show_arrow_timer;
|
|
|
|
QTimer m_delayed_hide_arrow_timer;
|
|
|
|
|
|
|
|
Arrow m_arrow;
|
|
|
|
bool m_arrowShown;
|
|
|
|
bool m_fadeInArrow;
|
|
|
|
bool m_fadeInHighLight;
|
|
|
|
|
|
|
|
qreal m_arrowValue;
|
|
|
|
qreal m_highLightValue;
|
|
|
|
|
|
|
|
QWeakPointer<QPropertyAnimation> m_arrowAnimation;
|
|
|
|
QWeakPointer<QPropertyAnimation> m_highLightAnimation;
|
|
|
|
};
|
2009-04-06 16:09:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // DESKTOPCHANGEOSD_H
|