2010-01-19 13:44:22 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2013-03-12 12:17:53 +00:00
|
|
|
Copyright (C) 2009 Martin Gräßlin <mgraesslin@kde.org>
|
2010-01-19 13:44:22 +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/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
2010-05-02 10:07:24 +00:00
|
|
|
#ifndef KWIN_DECORATIONMODEL_H
|
|
|
|
#define KWIN_DECORATIONMODEL_H
|
2010-01-19 13:44:22 +00:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <KConfig>
|
|
|
|
#include <kdecoration.h>
|
|
|
|
|
2010-04-23 19:20:01 +00:00
|
|
|
class QWidget;
|
2010-01-19 13:44:22 +00:00
|
|
|
class KDesktopFile;
|
|
|
|
class KDecorationPlugins;
|
|
|
|
class KDecorationPreview;
|
2013-10-09 06:57:00 +00:00
|
|
|
class KDecorationPreviewOptions;
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2010-04-16 21:03:34 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2010-01-19 13:44:22 +00:00
|
|
|
|
2012-01-13 10:48:04 +00:00
|
|
|
class DecorationButtons;
|
|
|
|
|
2010-01-19 13:44:22 +00:00
|
|
|
class DecorationModelData
|
|
|
|
{
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
enum DecorationType {
|
|
|
|
NativeDecoration = 0,
|
2012-07-27 08:10:28 +00:00
|
|
|
AuroraeDecoration = 1,
|
|
|
|
QmlDecoration = 2
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
|
|
|
QString name;
|
|
|
|
QString libraryName;
|
|
|
|
DecorationType type;
|
|
|
|
QString comment;
|
|
|
|
QString author;
|
|
|
|
QString email;
|
|
|
|
QString website;
|
|
|
|
QString version;
|
|
|
|
QString license;
|
|
|
|
QString auroraeName;
|
2012-07-27 08:10:28 +00:00
|
|
|
QString qmlPath;
|
2011-01-30 14:34:42 +00:00
|
|
|
KDecorationDefines::BorderSize borderSize;
|
|
|
|
KDecorationDefines::BorderSize buttonSize;
|
2012-08-24 13:16:30 +00:00
|
|
|
/**
|
|
|
|
* Whether the window gets closed on double clicking the Menu Button.
|
|
|
|
* Only applies for Aurorae and QML Decoration.
|
|
|
|
**/
|
|
|
|
bool closeDblClick;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
static bool less(const DecorationModelData& a, const DecorationModelData& b) {
|
|
|
|
return a.name < b.name;
|
|
|
|
}
|
2010-01-19 13:44:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DecorationModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
NameRole = Qt::UserRole,
|
|
|
|
LibraryNameRole = Qt::UserRole + 1,
|
|
|
|
TypeRole = Qt::UserRole + 3,
|
|
|
|
AuroraeNameRole = Qt::UserRole + 4,
|
|
|
|
PackageDescriptionRole = Qt::UserRole + 5,
|
|
|
|
PackageAuthorRole = Qt::UserRole + 6,
|
|
|
|
PackageEmailRole = Qt::UserRole + 7,
|
|
|
|
PackageWebsiteRole = Qt::UserRole + 8,
|
|
|
|
PackageVersionRole = Qt::UserRole + 9,
|
|
|
|
PackageLicenseRole = Qt::UserRole + 10,
|
|
|
|
BorderSizeRole = Qt::UserRole + 11,
|
|
|
|
BorderSizesRole = Qt::UserRole + 12,
|
2012-07-27 08:10:28 +00:00
|
|
|
ButtonSizeRole = Qt::UserRole + 13,
|
2012-08-24 13:16:30 +00:00
|
|
|
QmlMainScriptRole = Qt::UserRole + 14,
|
|
|
|
CloseOnDblClickRole = Qt::UserRole + 15
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
2012-12-29 06:34:38 +00:00
|
|
|
explicit DecorationModel(KSharedConfigPtr config, QObject* parent = 0);
|
2011-01-30 14:34:42 +00:00
|
|
|
~DecorationModel();
|
|
|
|
|
|
|
|
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
|
|
|
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
|
|
|
|
|
|
|
|
void reload();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes the button state and regenerates the preview.
|
|
|
|
*/
|
2012-01-13 10:48:04 +00:00
|
|
|
void changeButtons(const DecorationButtons *buttons);
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Changes the button state without regenerating the preview.
|
|
|
|
*/
|
2013-10-10 11:53:10 +00:00
|
|
|
void setButtons(bool custom, const QList<KDecorationDefines::DecorationButton>& left, const QList<KDecorationDefines::DecorationButton>& right);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
void setBorderSize(const QModelIndex& index, KDecorationDefines::BorderSize size);
|
|
|
|
|
|
|
|
QModelIndex indexOfLibrary(const QString& libraryName) const;
|
|
|
|
QModelIndex indexOfName(const QString& decoName) const;
|
2012-07-27 08:10:28 +00:00
|
|
|
QModelIndex indexOfAuroraeName(const QString& auroraeName, const QString& type) const;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2012-07-29 09:20:48 +00:00
|
|
|
Q_INVOKABLE QVariant readConfig(const QString &themeName, const QString &key, const QVariant &defaultValue = QVariant());
|
|
|
|
|
2012-08-25 07:54:20 +00:00
|
|
|
void notifyConfigChanged(const QModelIndex &index);
|
|
|
|
|
2012-07-29 09:20:48 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
void configChanged(QString themeName);
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
|
|
|
void findDecorations();
|
|
|
|
void findAuroraeThemes();
|
|
|
|
void metaData(DecorationModelData& data, const KDesktopFile& df);
|
|
|
|
QList<DecorationModelData> m_decorations;
|
|
|
|
KDecorationPlugins* m_plugins;
|
|
|
|
KDecorationPreview* m_preview;
|
|
|
|
bool m_customButtons;
|
|
|
|
KSharedConfigPtr m_config;
|
2013-10-09 06:57:00 +00:00
|
|
|
QScopedPointer<KDecorationPreviewOptions> m_options;
|
2010-01-19 13:44:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace KWin
|
|
|
|
|
2010-05-02 10:07:24 +00:00
|
|
|
#endif // KWIN_DECORATIONMODEL_H
|