2009-06-19 09:18:07 +00:00
|
|
|
/********************************************************************
|
2012-01-07 16:05:22 +00:00
|
|
|
Copyright (C) 2009, 2010, 2012 Martin Gräßlin <mgraesslin@kde.org>
|
2009-06-19 09:18:07 +00:00
|
|
|
|
|
|
|
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 AURORAE_H
|
|
|
|
#define AURORAE_H
|
|
|
|
|
|
|
|
#include "themeconfig.h"
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
#include <kdecoration.h>
|
2009-06-19 09:18:07 +00:00
|
|
|
#include <kdecorationfactory.h>
|
|
|
|
|
2013-11-14 08:01:42 +00:00
|
|
|
class QMutex;
|
2013-10-02 12:54:43 +00:00
|
|
|
class QOpenGLFramebufferObject;
|
2013-10-02 08:04:10 +00:00
|
|
|
class QQmlComponent;
|
|
|
|
class QQmlEngine;
|
|
|
|
class QQuickItem;
|
|
|
|
class QQuickWindow;
|
2012-07-22 15:35:18 +00:00
|
|
|
class KConfig;
|
|
|
|
class KConfigGroup;
|
2009-06-19 09:18:07 +00:00
|
|
|
|
|
|
|
namespace Aurorae
|
|
|
|
{
|
2010-04-12 19:28:58 +00:00
|
|
|
class AuroraeTheme;
|
2012-01-11 20:14:29 +00:00
|
|
|
class AuroraeClient;
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2013-08-23 07:05:59 +00:00
|
|
|
class AuroraeFactory : public KDecorationFactory
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2012-01-13 10:48:04 +00:00
|
|
|
Q_OBJECT
|
2009-06-19 09:18:07 +00:00
|
|
|
public:
|
|
|
|
~AuroraeFactory();
|
|
|
|
|
|
|
|
static AuroraeFactory* instance();
|
2014-02-21 09:48:24 +00:00
|
|
|
static QObject *createInstance(QWidget *, QObject *, const QList<QVariant> &);
|
2009-06-19 09:18:07 +00:00
|
|
|
KDecoration *createDecoration(KDecorationBridge*);
|
|
|
|
bool supports(Ability ability) const;
|
2009-11-08 20:35:34 +00:00
|
|
|
virtual QList< BorderSize > borderSizes() const;
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
AuroraeTheme *theme() const {
|
|
|
|
return m_theme;
|
2010-01-01 12:47:48 +00:00
|
|
|
}
|
2013-10-02 08:04:10 +00:00
|
|
|
QQuickItem *createQmlDecoration(AuroraeClient *client);
|
2012-07-29 09:20:48 +00:00
|
|
|
const QString ¤tThemeName() const {
|
|
|
|
return m_themeName;
|
|
|
|
}
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2014-03-27 13:17:07 +00:00
|
|
|
QMutex *mutex() {
|
|
|
|
return m_mutex.data();
|
|
|
|
}
|
|
|
|
|
2009-06-19 09:18:07 +00:00
|
|
|
private:
|
2012-07-22 15:35:18 +00:00
|
|
|
enum EngineType {
|
|
|
|
AuroraeEngine,
|
|
|
|
QMLEngine
|
|
|
|
};
|
2013-08-23 07:05:59 +00:00
|
|
|
explicit AuroraeFactory(QObject *parent = nullptr);
|
2009-06-19 09:18:07 +00:00
|
|
|
void init();
|
2012-07-22 15:35:18 +00:00
|
|
|
void initAurorae(KConfig &conf, KConfigGroup &group);
|
|
|
|
void initQML(const KConfigGroup& group);
|
2009-06-19 09:18:07 +00:00
|
|
|
|
2012-01-13 10:48:04 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void buttonsChanged();
|
2012-08-09 07:44:40 +00:00
|
|
|
void titleFontChanged();
|
2012-07-29 09:20:48 +00:00
|
|
|
void configChanged();
|
2012-01-13 10:48:04 +00:00
|
|
|
|
2013-08-23 11:36:40 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void updateConfiguration();
|
|
|
|
|
2009-06-19 09:18:07 +00:00
|
|
|
private:
|
|
|
|
static AuroraeFactory *s_instance;
|
|
|
|
|
2010-04-12 19:28:58 +00:00
|
|
|
AuroraeTheme *m_theme;
|
2013-10-02 08:04:10 +00:00
|
|
|
QQmlEngine *m_engine;
|
|
|
|
QQmlComponent *m_component;
|
2012-07-22 15:35:18 +00:00
|
|
|
EngineType m_engineType;
|
2012-07-29 09:20:48 +00:00
|
|
|
QString m_themeName;
|
2014-03-27 13:17:07 +00:00
|
|
|
QScopedPointer<QMutex> m_mutex;
|
2009-06-19 09:18:07 +00:00
|
|
|
};
|
|
|
|
|
2013-08-20 09:58:02 +00:00
|
|
|
class AuroraeClient : public KDecoration
|
2009-06-19 09:18:07 +00:00
|
|
|
{
|
2009-07-27 21:30:26 +00:00
|
|
|
Q_OBJECT
|
2012-01-04 18:51:51 +00:00
|
|
|
Q_PROPERTY(QRect geometry READ geometry)
|
|
|
|
Q_PROPERTY(int height READ height)
|
2012-01-07 16:05:22 +00:00
|
|
|
Q_PROPERTY(bool closeable READ isCloseable CONSTANT)
|
|
|
|
Q_PROPERTY(bool maximizeable READ isMaximizable CONSTANT)
|
|
|
|
Q_PROPERTY(bool minimizeable READ isMinimizable CONSTANT)
|
2012-01-04 18:51:51 +00:00
|
|
|
Q_PROPERTY(bool modal READ isModal)
|
2012-01-07 16:05:22 +00:00
|
|
|
Q_PROPERTY(bool moveable READ isMovable CONSTANT)
|
2012-01-04 18:51:51 +00:00
|
|
|
Q_PROPERTY(bool preview READ isPreview CONSTANT)
|
2012-01-07 16:05:22 +00:00
|
|
|
Q_PROPERTY(bool resizeable READ isResizable CONSTANT)
|
2012-01-04 18:51:51 +00:00
|
|
|
Q_PROPERTY(bool shadeable READ isShadeable)
|
|
|
|
Q_PROPERTY(bool providesContextHelp READ providesContextHelp)
|
2012-12-27 09:29:13 +00:00
|
|
|
Q_PROPERTY(bool appMenu READ menuAvailable NOTIFY appMenuAvailableChanged)
|
2012-01-04 18:51:51 +00:00
|
|
|
Q_PROPERTY(QRect transparentRect READ transparentRect)
|
|
|
|
Q_PROPERTY(int width READ width)
|
|
|
|
Q_PROPERTY(qulonglong windowId READ windowId CONSTANT)
|
2012-02-16 10:30:28 +00:00
|
|
|
Q_PROPERTY(int doubleClickInterval READ doubleClickInterval)
|
2013-03-12 17:36:21 +00:00
|
|
|
Q_PROPERTY(bool animationsSupported READ animationsSupported CONSTANT)
|
2012-01-04 18:51:51 +00:00
|
|
|
// TODO: window tabs - they suck for dynamic features
|
2009-06-19 09:18:07 +00:00
|
|
|
public:
|
2010-04-12 19:28:58 +00:00
|
|
|
AuroraeClient(KDecorationBridge* bridge, KDecorationFactory* factory);
|
2010-06-19 15:23:48 +00:00
|
|
|
virtual ~AuroraeClient();
|
2012-07-30 18:00:25 +00:00
|
|
|
virtual bool eventFilter(QObject *object, QEvent *event);
|
2010-04-12 19:28:58 +00:00
|
|
|
virtual void borders(int& left, int& right, int& top, int& bottom) const;
|
|
|
|
virtual void init();
|
|
|
|
virtual QSize minimumSize() const;
|
|
|
|
virtual Position mousePosition(const QPoint& p) const;
|
2009-11-01 12:12:30 +00:00
|
|
|
virtual void resize(const QSize& s);
|
2010-04-12 19:28:58 +00:00
|
|
|
// optional overrides
|
|
|
|
virtual void padding(int &left, int &right, int &top, int &bottom) const;
|
2012-02-16 10:30:28 +00:00
|
|
|
int doubleClickInterval() const;
|
2010-04-12 19:28:58 +00:00
|
|
|
|
2013-03-12 17:36:21 +00:00
|
|
|
bool animationsSupported() const;
|
|
|
|
|
2012-07-29 09:20:48 +00:00
|
|
|
Q_INVOKABLE QVariant readConfig(const QString &key, const QVariant &defaultValue = QVariant());
|
|
|
|
|
2013-10-07 12:40:12 +00:00
|
|
|
virtual void render(QPaintDevice *device, const QRegion &sourceRegion);
|
|
|
|
|
2012-01-04 18:51:51 +00:00
|
|
|
Q_SIGNALS:
|
2012-07-27 08:03:22 +00:00
|
|
|
void buttonsChanged();
|
2012-07-29 09:20:48 +00:00
|
|
|
/**
|
|
|
|
* Signal emitted when the decoration's configuration might have changed.
|
|
|
|
* A decoration could reload it's configuration when this signal is emitted.
|
|
|
|
**/
|
|
|
|
void configChanged();
|
2012-08-24 09:40:02 +00:00
|
|
|
void fontChanged();
|
2012-12-27 09:29:13 +00:00
|
|
|
void appMenuAvailableChanged();
|
2012-01-04 18:51:51 +00:00
|
|
|
|
2013-07-25 15:59:30 +00:00
|
|
|
public Q_SLOTS:
|
2010-04-12 19:28:58 +00:00
|
|
|
void menuClicked();
|
2012-12-27 09:29:13 +00:00
|
|
|
void appMenuClicked();
|
2010-04-12 19:28:58 +00:00
|
|
|
void toggleShade();
|
|
|
|
void toggleKeepAbove();
|
|
|
|
void toggleKeepBelow();
|
2012-01-07 16:05:22 +00:00
|
|
|
void titlePressed(int button, int buttons);
|
2010-04-12 19:28:58 +00:00
|
|
|
void titlePressed(Qt::MouseButton button, Qt::MouseButtons buttons);
|
2012-07-14 09:11:02 +00:00
|
|
|
void closeWindow();
|
2012-08-10 06:52:11 +00:00
|
|
|
void titlebarDblClickOperation();
|
|
|
|
void maximize(int button);
|
2009-07-27 21:30:26 +00:00
|
|
|
|
2012-12-27 07:51:15 +00:00
|
|
|
QRegion region(KDecorationDefines::Region r);
|
|
|
|
|
2013-07-25 15:59:30 +00:00
|
|
|
private Q_SLOTS:
|
2012-01-11 20:14:29 +00:00
|
|
|
void themeChanged();
|
2012-07-14 09:11:02 +00:00
|
|
|
void doCloseWindow();
|
2012-08-10 06:52:11 +00:00
|
|
|
void doTitlebarDblClickOperation();
|
|
|
|
void doMaximzie(int button);
|
2012-10-12 09:34:05 +00:00
|
|
|
void slotAlphaChanged();
|
2012-01-11 20:14:29 +00:00
|
|
|
|
2009-11-01 12:12:30 +00:00
|
|
|
private:
|
2013-01-16 07:43:53 +00:00
|
|
|
void sizesFromBorders(const QObject *borders, int &left, int &right, int &top, int &bottom) const;
|
2013-10-02 08:04:10 +00:00
|
|
|
QQuickWindow *m_view;
|
2013-10-09 09:19:03 +00:00
|
|
|
QScopedPointer<QQuickItem> m_item;
|
2013-10-02 12:54:43 +00:00
|
|
|
QScopedPointer<QOpenGLFramebufferObject> m_fbo;
|
|
|
|
QImage m_buffer;
|
2009-06-19 09:18:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|