kwin/src/kcmkwin/kwinrules/ruleitem.h
Vlad Zahorodnii 93e0265e4e Move source code to src/ directory
Once in a while, we receive complaints from other fellow KDE developers
about the file organization of kwin. This change addresses some of those
complaints by moving all of source code in a separate directory, src/,
thus making the project structure more traditional. Things such as tests
are kept in their own toplevel directories.

This change may wreak havoc on merge requests that add new files to kwin,
but if a patch modifies an already existing file, git should be smart
enough to figure out that the file has been relocated.

We may potentially split the src/ directory further to make navigating
the source code easier, but hopefully this is good enough already.
2021-02-10 15:31:43 +00:00

116 lines
2.5 KiB
C++

/*
SPDX-FileCopyrightText: 2020 Ismael Asensio <isma.af@gmail.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef KWIN_RULEITEM_H
#define KWIN_RULEITEM_H
#include "optionsmodel.h"
#include <QFlag>
#include <QIcon>
namespace KWin
{
class RuleItem : public QObject
{
Q_OBJECT
public:
enum Type {
Undefined,
Boolean,
String,
Integer,
Option,
NetTypes,
Percentage,
Point,
Size,
Shortcut,
OptionList,
};
Q_ENUM(Type)
enum Flags {
NoFlags = 0,
AlwaysEnabled = 1u << 0,
StartEnabled = 1u << 1,
AffectsWarning = 1u << 2,
AffectsDescription = 1u << 3,
SuggestionOnly = 1u << 4,
AllFlags = 0b11111
};
public:
RuleItem() {};
RuleItem(const QString &key,
const RulePolicy::Type policyType,
const Type type,
const QString &name,
const QString &section,
const QIcon &icon = QIcon::fromTheme("window"),
const QString &description = QString("")
);
~RuleItem();
QString key() const;
QString name() const;
QString section() const;
QIcon icon() const;
QString iconName() const;
QString description() const;
bool isEnabled() const;
void setEnabled(bool enabled);
bool hasFlag(RuleItem::Flags flag) const;
void setFlag(RuleItem::Flags flag, bool active=true);
Type type() const;
QVariant value() const;
void setValue(QVariant value);
QVariant suggestedValue() const;
void setSuggestedValue(QVariant value);
QVariant options() const;
void setOptionsData(const QList<OptionsModel::Data> &data);
uint optionsMask() const;
RulePolicy::Type policyType() const;
int policy() const; // int belongs to anonymous enum in Rules::
void setPolicy(int policy); // int belongs to anonymous enum in Rules::
QVariant policyModel() const;
QString policyKey() const;
void reset();
private:
QVariant typedValue(const QVariant &value) const;
private:
QString m_key;
RuleItem::Type m_type;
QString m_name;
QString m_section;
QIcon m_icon;
QString m_description;
QFlags<Flags> m_flags;
bool m_enabled;
QVariant m_value;
QVariant m_suggestedValue;
RulePolicy *m_policy;
OptionsModel *m_options;
uint m_optionsMask;
};
} //namespace
#endif //KWIN_RULEITEM_H