Use a hint instead of a bool

This commit is contained in:
Niccolò Venerandi 2020-08-22 16:54:52 +02:00
parent a2500223b5
commit db2126cea1
3 changed files with 19 additions and 9 deletions

View File

@ -62,7 +62,17 @@ public:
ImmutableConstraint
};
Q_ENUM(Constraint)
Q_DECLARE_FLAGS(Constraints, Constraint)
/**
* This enumeration lists the various hints that an applet can pass to its
* constraint regarding the way that it is represented
*/
enum ConstraintHints {
NoHint = 0,
CanFillArea = 1 /**< The applet can fill the area and ignore constraint margins*/
};
Q_ENUM(ConstraintHints)
/**
* The FormFactor enumeration describes how a Plasma::Applet should arrange

View File

@ -618,14 +618,14 @@ bool AppletInterface::hideOnWindowDeactivate() const
return m_hideOnDeactivate;
}
void AppletInterface::setApplyMarginsProperty(bool margins)
void AppletInterface::setConstraintHints(Plasma::Types::ConstraintHints hints)
{
m_apply_margins = margins;
m_constraintHints = hints;
}
bool AppletInterface::applyMargins() const
Plasma::Types::ConstraintHints AppletInterface::constraintHints() const
{
return m_apply_margins;
return m_constraintHints;
}
QKeySequence AppletInterface::globalShortcut() const

View File

@ -253,7 +253,7 @@ class AppletInterface : public PlasmaQuick::AppletQuickItem
/**
* When false the plasmoid will ignore the margins when contained in a panel
*/
Q_PROPERTY(bool applyMargins READ applyMargins WRITE setApplyMarginsProperty NOTIFY applyMarginsChanged)
Q_PROPERTY(Plasma::Types::ConstraintHints constraintHints READ constraintHints WRITE setConstraintHints NOTIFY constraintHintsChanged)
public:
AppletInterface(DeclarativeAppletScript *script, const QVariantList &args = QVariantList(), QQuickItem *parent = nullptr);
@ -420,8 +420,8 @@ public:
QString configurationRequiredReason() const;
void setConfigurationRequiredReason(const QString &reason);
bool applyMargins() const;
void setApplyMarginsProperty(bool applyMargins);
Plasma::Types::ConstraintHints constraintHints() const;
void setConstraintHints(Plasma::Types::ConstraintHints constraintHints);
Q_SIGNALS:
/**
@ -468,7 +468,7 @@ Q_SIGNALS:
void associatedApplicationUrlsChanged();
void availableScreenRegionChanged();
void availableScreenRectChanged();
void applyMarginsChanged();
void constraintHintsChanged();
void userConfiguringChanged();
void globalShortcutChanged();
@ -519,7 +519,7 @@ private:
friend class ContainmentInterface;
//This is used by ContainmentInterface
QPointF m_positionBeforeRemoval;
bool m_apply_margins = true;
Plasma::Types::ConstraintHints m_constraintHints = Plasma::Types::ConstraintHints::NoHint;
};
QML_DECLARE_TYPEINFO(AppletInterface, QML_HAS_ATTACHED_PROPERTIES)