Skip to content

Commit

Permalink
libhawaiishell: Move configuring property from QuickView to Containment
Browse files Browse the repository at this point in the history
The configuration logic does really belong here.

Issue: #151
  • Loading branch information
plfiorini committed Mar 24, 2014
1 parent e8b9b13 commit 41015a6
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 44 deletions.
18 changes: 18 additions & 0 deletions src/libhawaiishell/containment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ContainmentPrivate
Types::FormFactor formFactor;
Types::Location location;
bool immutable;
bool configuring;
Package package;
};

Expand All @@ -63,6 +64,7 @@ ContainmentPrivate::ContainmentPrivate()
, formFactor(Types::Plane)
, location(Types::Desktop)
, immutable(false)
, configuring(false)
{
}

Expand Down Expand Up @@ -168,6 +170,22 @@ void Containment::setImmutable(bool value)
}
}

bool Containment::isConfiguring() const
{
Q_D(const Containment);
return d->configuring;
}

void Containment::setConfiguring(bool value)
{
Q_D(Containment);

if (d->configuring != value) {
d->configuring = value;
Q_EMIT configuringChanged(value);
}
}

Package Containment::package() const
{
Q_D(const Containment);
Expand Down
18 changes: 18 additions & 0 deletions src/libhawaiishell/containment.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class HAWAIISHELL_EXPORT Containment : public QObject
Q_PROPERTY(Hawaii::Shell::Types::FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
Q_PROPERTY(Hawaii::Shell::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
Q_PROPERTY(bool immutable READ isImmutable WRITE setImmutable NOTIFY immutableChanged)
Q_PROPERTY(bool configuring READ isConfiguring WRITE setConfiguring NOTIFY configuringChanged)
public:
explicit Containment(Mantle *mantle, QObject *parent = 0);
~Containment();
Expand Down Expand Up @@ -93,6 +94,17 @@ class HAWAIISHELL_EXPORT Containment : public QObject
*/
void setImmutable(bool value);

/*!
* \return whether this containment is in configuration mode.
*/
bool isConfiguring() const;

/*!
* Enable or disable the configuration mode.
* \param value whether configuration mode is enabled or not.
*/
void setConfiguring(bool value);

/*!
* \return the package loaded for this containment.
*/
Expand Down Expand Up @@ -134,6 +146,12 @@ class HAWAIISHELL_EXPORT Containment : public QObject
*/
void immutableChanged(bool newValue);

/*!
* Emitted when the configuration mode is enabled or disabled.
* \param newValue whether the containment is now in configuration mode or not.
*/
void configuringChanged(bool newValue);

/*!
* Emitted when the package for this containment is changed.
* \param package the new package.
Expand Down
14 changes: 14 additions & 0 deletions src/libhawaiishell/containmentitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ ContainmentItem::ContainmentItem(Containment *containment, QQuickItem *parent)
this, &ContainmentItem::locationChanged);
connect(containment, &Containment::immutableChanged,
this, &ContainmentItem::immutableChanged);
connect(containment, &Containment::configuringChanged,
this, &ContainmentItem::configuringChanged);

// Reinizialize this item when the package is changed
connect(containment, SIGNAL(packageChanged(Package)),
Expand Down Expand Up @@ -170,6 +172,18 @@ void ContainmentItem::setImmutable(bool value)
d->containment->setImmutable(value);
}

bool ContainmentItem::isConfiguring() const
{
Q_D(const ContainmentItem);
return d->containment->isConfiguring();
}

void ContainmentItem::setConfiguring(bool value)
{
Q_D(ContainmentItem);
d->containment->setConfiguring(value);
}

void ContainmentItem::initialize()
{
Q_D(ContainmentItem);
Expand Down
18 changes: 18 additions & 0 deletions src/libhawaiishell/containmentitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class HAWAIISHELL_EXPORT ContainmentItem : public QQuickItem
Q_PROPERTY(Hawaii::Shell::Types::FormFactor formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
Q_PROPERTY(Hawaii::Shell::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
Q_PROPERTY(bool immutable READ isImmutable WRITE setImmutable NOTIFY immutableChanged)
Q_PROPERTY(bool configuring READ isConfiguring WRITE setConfiguring NOTIFY configuringChanged)
public:
/*!
* \brief Constructor.
Expand Down Expand Up @@ -104,6 +105,17 @@ class HAWAIISHELL_EXPORT ContainmentItem : public QQuickItem
*/
void setImmutable(bool value);

/*!
* \return whether this containment is in configuration mode.
*/
bool isConfiguring() const;

/*!
* Enable or disable the configuration mode.
* \param value whether configuration mode is enabled or not.
*/
void setConfiguring(bool value);

/*!
* Initializes the containment item.
*/
Expand Down Expand Up @@ -131,6 +143,12 @@ class HAWAIISHELL_EXPORT ContainmentItem : public QQuickItem
*/
void immutableChanged(bool newValue);

/*!
* Emitted when the configuration mode is enabled or disabled.
* \param newValue whether the containment is now in configuration mode or not.
*/
void configuringChanged(bool newValue);

private:
Q_DECLARE_PRIVATE(ContainmentItem)
ContainmentItemPrivate *const d_ptr;
Expand Down
61 changes: 34 additions & 27 deletions src/libhawaiishell/quickview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ class QuickViewPrivate

Mantle *mantle;
QPointer<Containment> containment;
bool configuring;

void initialize();

void _q_configuringChanged(bool value);

protected:
QuickView *const q_ptr;
};

QuickViewPrivate::QuickViewPrivate(QuickView *view)
: configuring(false)
, q_ptr(view)
: q_ptr(view)
{
}

Expand All @@ -84,6 +84,18 @@ void QuickViewPrivate::initialize()
q->setResizeMode(QQuickView::SizeViewToRootObject);
}

void QuickViewPrivate::_q_configuringChanged(bool value)
{
Q_Q(QuickView);

// Views inheriting QuickView will have to override these methods
// implementing their window setup code
if (value)
q->showConfigurationWindow();
else
q->hideConfigurationWindow();
}

/*
* QuickView
*/
Expand Down Expand Up @@ -148,6 +160,8 @@ void QuickView::setContainment(Containment *containment)
this, &QuickView::formFactorChanged);
connect(containment, &Containment::immutableChanged,
this, &QuickView::immutableChanged);
connect(containment, SIGNAL(configuringChanged(bool)),
this, SLOT(_q_configuringChanged(bool)));

QQuickItem *item = qobject_cast<QQuickItem *>(d->containment.data()->property("_graphicObject").value<QObject *>());
if (item) {
Expand All @@ -161,30 +175,6 @@ void QuickView::setContainment(Containment *containment)
}
}

bool QuickView::isConfiguring() const
{
Q_D(const QuickView);
return d->configuring;
}

void QuickView::setConfiguring(bool value)
{
Q_D(QuickView);

if (d->configuring != value) {
// Views inheriting QuickView will have to override these methods
// implementing their window setup code
if (value)
showConfigurationWindow();
else
hideConfigurationWindow();

// Now we can actually change the property
d->configuring = value;
Q_EMIT configuringChanged(value);
}
}

Hawaii::Shell::Types::FormFactor QuickView::formFactor() const
{
Q_D(const QuickView);
Expand Down Expand Up @@ -236,6 +226,23 @@ void QuickView::setImmutable(bool value)
d->containment.data()->setImmutable(value);
}

bool QuickView::isConfiguring() const
{
Q_D(const QuickView);

if (!d->containment)
return false;
return d->containment.data()->isConfiguring();
}

void QuickView::setConfiguring(bool value)
{
Q_D(QuickView);

if (isConfiguring() != value)
d->containment.data()->setConfiguring(value);
}

QRectF QuickView::screenGeometry() const
{
return screen()->geometry();
Expand Down
36 changes: 19 additions & 17 deletions src/libhawaiishell/quickview.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ class HAWAIISHELL_EXPORT QuickView : public QQuickView
*/
void setContainment(Containment *containment);

/*!
* \return whether this view is in configuration mode.
*/
bool isConfiguring() const;

/*!
* Enable or disable the configuration mode.
* \param value whether configuration mode is enabled or not.
*/
void setConfiguring(bool value);

/*!
* \return the form factor of this view.
*/
Expand Down Expand Up @@ -127,6 +116,17 @@ class HAWAIISHELL_EXPORT QuickView : public QQuickView
*/
void setImmutable(bool value);

/*!
* \return whether this view is in configuration mode.
*/
bool isConfiguring() const;

/*!
* Enable or disable the configuration mode.
* \param value whether configuration mode is enabled or not.
*/
void setConfiguring(bool value);

/*!
* \return the geometry of the screen where this view is located.
*/
Expand All @@ -153,12 +153,6 @@ class HAWAIISHELL_EXPORT QuickView : public QQuickView
*/
void containmentChanged();

/*!
* Emitted when the configuration mode is enabled or disabled.
* \param newValue whether the view is now in configuration mode or not.
*/
void configuringChanged(bool newValue);

/*!
* Emitted when the form factor is changed.
* \param formFactor the new form factorof the view
Expand All @@ -178,6 +172,12 @@ class HAWAIISHELL_EXPORT QuickView : public QQuickView
*/
void immutableChanged(bool newValue);

/*!
* Emitted when the configuration mode is enabled or disabled.
* \param newValue whether the view is now in configuration mode or not.
*/
void configuringChanged(bool newValue);

/*!
* Emitted when the screen geometry is changed.
* \param geometry the new screen geometry
Expand All @@ -187,6 +187,8 @@ class HAWAIISHELL_EXPORT QuickView : public QQuickView
private:
Q_DECLARE_PRIVATE(QuickView)
QuickViewPrivate *const d_ptr;

Q_PRIVATE_SLOT(d_func(), void _q_configuringChanged(bool value))
};

} // namespace Shell
Expand Down

0 comments on commit 41015a6

Please sign in to comment.