get rid of the old sizehint mechanism

This commit is contained in:
Marco Martin 2014-01-29 11:11:43 +01:00
parent 075d55c842
commit 012554d8d9
5 changed files with 0 additions and 373 deletions

View File

@ -458,92 +458,6 @@ int AppletInterface::apiVersion() const
return offers.first()->property("X-KDE-PluginInfo-Version", QVariant::Int).toInt();
}
bool AppletInterface::fillWidth() const
{
if (!m_qmlObject->rootObject()) {
return false;
}
QVariant prop;
if (m_compactUiObject) {
prop = m_compactUiObject.data()->property("fillWidth");
} else {
prop = m_qmlObject->rootObject()->property("fillWidth");
}
if (prop.isValid() && prop.canConvert<bool>()) {
return prop.toBool();
} else {
return false;
}
}
bool AppletInterface::fillHeight() const
{
if (!m_qmlObject->rootObject()) {
return false;
}
QVariant prop;
if (m_compactUiObject) {
prop = m_compactUiObject.data()->property("fillHeight");
} else {
prop = m_qmlObject->rootObject()->property("fillHeight");
}
if (prop.isValid() && prop.canConvert<bool>()) {
return prop.toBool();
} else {
return false;
}
}
//private api, just an helper
qreal AppletInterface::readGraphicsObjectSizeHint(const char *hint) const
{
if (!m_qmlObject->rootObject()) {
return -1;
}
QVariant prop;
if (m_compactUiObject) {
prop = m_compactUiObject.data()->property(hint);
} else {
prop = m_qmlObject->rootObject()->property(hint);
}
if (prop.isValid() && prop.canConvert<qreal>()) {
return prop.toReal();
} else {
return -1;
}
}
qreal AppletInterface::minimumWidth() const
{
return readGraphicsObjectSizeHint("minimumWidth");
}
qreal AppletInterface::minimumHeight() const
{
return readGraphicsObjectSizeHint("minimumHeight");
}
qreal AppletInterface::maximumWidth() const
{
return readGraphicsObjectSizeHint("maximumWidth");
}
qreal AppletInterface::maximumHeight() const
{
return readGraphicsObjectSizeHint("maximumHeight");
}
void AppletInterface::setAssociatedApplication(const QString &string)
{
@ -615,215 +529,6 @@ void AppletInterface::geometryChanged(const QRectF &newGeometry, const QRectF &o
m_collapseTimer->start(100);
}
void AppletInterface::_compactRepresentationCheck()
{
if (width() <= 0 || height() <= 0 || !m_qmlObject->rootObject() ||
qobject_cast<ContainmentInterface *>(this)) {
return;
}
//Read the minimum width of the full representation, not our own, since we could be in collapsed mode
QSizeF minHint(-1, -1);
if (m_qmlObject->rootObject()->property("minimumWidth").canConvert<qreal>()) {
minHint.setWidth(m_qmlObject->rootObject()->property("minimumWidth").toReal());
}
if (m_qmlObject->rootObject()->property("minimumHeight").canConvert<qreal>()) {
minHint.setHeight(m_qmlObject->rootObject()->property("minimumHeight").toReal());
}
//Make it an icon
if (width() < minHint.width() || height() < minHint.height()) {
m_expanded = false;
//we are already an icon: nothing to do
if (m_compactUiObject) {
return;
}
m_compactUiObject = m_qmlObject->createObjectFromSource(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("compactapplet")));
QObject *compactRepresentation = 0;
//build the icon representation
if (m_compactUiObject) {
QQmlComponent *compactComponent = m_qmlObject->rootObject()->property("compactRepresentation").value<QQmlComponent *>();
if (compactComponent) {
compactRepresentation = compactComponent->create(compactComponent->creationContext());
} else {
compactRepresentation = m_qmlObject->createObjectFromSource(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("defaultcompactrepresentation")));
}
if (compactRepresentation && compactComponent) {
compactComponent->setParent(compactRepresentation);
} else {
delete compactComponent;
}
}
if (m_compactUiObject && compactRepresentation) {
//put compactRepresentation in the icon place
compactRepresentation->setProperty("parent", QVariant::fromValue(m_compactUiObject.data()));
m_compactUiObject.data()->setProperty("compactRepresentation", QVariant::fromValue(compactRepresentation));
//replace the full applet with the collapsed view
m_compactUiObject.data()->setProperty("visible", true);
m_compactUiObject.data()->setProperty("parent", QVariant::fromValue(this));
{
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_compactUiObject.data(), "parent");
QQmlProperty prop(m_compactUiObject.data(), "anchors.fill");
prop.write(expr.evaluate());
}
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(m_compactUiObject.data()));
{
//reset all the anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "anchors.fill=undefined;anchors.left=undefined;anchors.right=undefined;anchors.top=undefined;anchors.bottom=undefined;");
expr.evaluate();
}
KConfigGroup cg = applet()->config();
cg = KConfigGroup(&cg, "PopupApplet");
int width = cg.readEntry("DialogWidth", 0);
int height = cg.readEntry("DialogHeight", 0);
m_qmlObject->rootObject()->setProperty("width", width);
m_qmlObject->rootObject()->setProperty("height", height);
m_compactUiObject.data()->setProperty("applet", QVariant::fromValue(m_qmlObject->rootObject()));
//hook m_compactUiObject size hints to this size hint
//Here we have to use the old connect syntax, because we don't have access to the class type
if (m_qmlObject->rootObject()) {
disconnect(m_qmlObject->rootObject(), 0, this, 0);
}
//resize of the root object means popup resize when iconified
connect(m_qmlObject->rootObject(), SIGNAL(widthChanged()),
this, SLOT(updatePopupSize()));
connect(m_qmlObject->rootObject(), SIGNAL(heightChanged()),
this, SLOT(updatePopupSize()));
if (m_compactUiObject.data()->property("minimumWidth").isValid()) {
connect(m_compactUiObject.data(), SIGNAL(minimumWidthChanged()),
this, SIGNAL(minimumWidthChanged()));
}
if (m_compactUiObject.data()->property("minimumHeight").isValid()) {
connect(m_compactUiObject.data(), SIGNAL(minimumHeightChanged()),
this, SIGNAL(minimumHeightChanged()));
}
if (m_compactUiObject.data()->property("maximumWidth").isValid()) {
connect(m_compactUiObject.data(), SIGNAL(maximumWidthChanged()),
this, SIGNAL(maximumWidthChanged()));
}
if (m_compactUiObject.data()->property("maximumHeight").isValid()) {
connect(m_compactUiObject.data(), SIGNAL(maximumHeightChanged()),
this, SIGNAL(maximumHeightChanged()));
}
if (m_compactUiObject.data()->property("implicitWidth").isValid()) {
connect(m_compactUiObject.data(), SIGNAL(implicitWidthChanged()),
this, SIGNAL(implicitWidthChanged()));
}
if (m_compactUiObject.data()->property("implicitHeight").isValid()) {
connect(m_compactUiObject.data(), SIGNAL(implicitHeightChanged()),
this, SIGNAL(implicitHeightChanged()));
}
emit fillWidthChanged();
emit fillHeightChanged();
emit minimumWidthChanged();
emit minimumHeightChanged();
emit implicitWidthChanged();
emit implicitHeightChanged();
emit maximumWidthChanged();
emit maximumHeightChanged();
//failed to create UI, don't do anything, return in expanded status
} else {
m_expanded = true;
}
emit expandedChanged();
//show the full UI
} else {
m_expanded = true;
emit expandedChanged();
//we are already expanded: nothing to do
if (m_compactUiObject) {
disconnect(m_compactUiObject.data(), 0, this, 0);
}
disconnect(m_qmlObject->rootObject(), SIGNAL(widthChanged()),
this, SLOT(updatePopupSize()));
disconnect(m_qmlObject->rootObject(), SIGNAL(heightChanged()),
this, SLOT(updatePopupSize()));
//Here we have to use the old connect syntax, because we don't have access to the class type
if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()),
this, SIGNAL(minimumWidthChanged()));
}
if (m_qmlObject->rootObject()->property("minimumHeight").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(minimumHeightChanged()),
this, SIGNAL(minimumHeightChanged()));
}
if (m_qmlObject->rootObject()->property("maximumWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(maximumWidthChanged()),
this, SIGNAL(maximumWidthChanged()));
}
if (m_qmlObject->rootObject()->property("maximumHeight").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(maximumHeightChanged()),
this, SIGNAL(maximumHeightChanged()));
}
if (m_qmlObject->rootObject()->property("implicitWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(implicitWidthChanged()),
this, SLOT(updateImplicitWidth()));
}
if (m_qmlObject->rootObject()->property("implicitHeight").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(implicitHeightChanged()),
this, SLOT(updateImplicitHeight()));
}
emit fillWidthChanged();
emit fillHeightChanged();
emit minimumWidthChanged();
emit minimumHeightChanged();
emit maximumWidthChanged();
emit maximumHeightChanged();
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this));
if (m_compactUiObject) {
m_compactUiObject.data()->deleteLater();
}
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "parent");
QQmlProperty prop(m_qmlObject->rootObject(), "anchors.fill");
prop.write(expr.evaluate());
}
}
void AppletInterface::updateImplicitWidth()
{
setImplicitWidth(readGraphicsObjectSizeHint("implicitWidth"));
}
void AppletInterface::updateImplicitHeight()
{
setImplicitHeight(readGraphicsObjectSizeHint("implicitHeight"));
}
void AppletInterface::updatePopupSize()
{
KConfigGroup cg = applet()->config();

View File

@ -146,22 +146,6 @@ class AppletInterface : public AppletLoader
// would be preferrable if found.
Q_PROPERTY(int screen READ screen NOTIFY screenChanged)
//Size hints. Note that the containments may chose to not respect them.
Q_PROPERTY(qreal minimumWidth READ minimumWidth NOTIFY minimumWidthChanged)
Q_PROPERTY(qreal minimumHeight READ minimumHeight NOTIFY minimumHeightChanged)
Q_PROPERTY(qreal maximumWidth READ maximumWidth NOTIFY maximumWidthChanged)
Q_PROPERTY(qreal maximumHeight READ maximumHeight NOTIFY maximumHeightChanged)
/**
* If the plasmoid is in a linear layout, such as a panel, it indicates to take as much horizontal space as possible
*/
Q_PROPERTY(bool fillWidth READ fillWidth NOTIFY fillWidthChanged)
/**
* If the plasmoid is in a linear layout, such as a panel, it indicates to take as much vertical space as possible
*/
Q_PROPERTY(bool fillHeight READ fillHeight NOTIFY fillHeightChanged)
/**
* Whether the dialog should be hidden when the dialog loses focus.
*
@ -292,13 +276,6 @@ public:
bool hideOnWindowDeactivate() const;
void setHideOnWindowDeactivate(bool hide);
bool fillWidth() const;
bool fillHeight() const;
qreal minimumWidth() const;
qreal minimumHeight() const;
qreal maximumWidth() const;
qreal maximumHeight() const;
Q_SIGNALS:
/**
* somebody else, usually the containment sent some data to the applet
@ -324,12 +301,6 @@ Q_SIGNALS:
void screenChanged();
void hideOnWindowDeactivateChanged();
void minimumWidthChanged();
void minimumHeightChanged();
void maximumWidthChanged();
void maximumHeightChanged();
void fillWidthChanged();
void fillHeightChanged();
void userConfiguringChanged();
protected:
@ -342,14 +313,9 @@ protected Q_SLOTS:
virtual void init();
private Q_SLOTS:
void _compactRepresentationCheck();
void updatePopupSize();
void updateImplicitWidth();
void updateImplicitHeight();
private:
//Helper for minimumWidth etc.
qreal readGraphicsObjectSizeHint(const char *hint) const;
QStringList m_actions;
QSignalMapper *m_actionSignals;

View File

@ -171,13 +171,6 @@ void AppletLoader::setPreferredRepresentation(QQmlComponent *component)
////////////Internals
void AppletLoader::classBegin()
{
Q_ASSERT(m_qmlObject->engine());
m_qmlObject->engine()->rootContext()->setContextProperty("plasmoid", this);
}
void AppletLoader::init()
{
//m_appletScriptEngine = property("_plasma_appletscript").value<Plasma::AppletScript *>();

View File

@ -93,7 +93,6 @@ public:
QObject *compactRepresentationExpanderItem();
//Reimplemented
virtual void classBegin();
virtual void init();
Q_SIGNALS:

View File

@ -152,42 +152,6 @@ void ContainmentInterface::init()
QQmlProperty prop(m_qmlObject->rootObject(), "anchors.fill");
prop.write(expr.evaluate());
}
if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()),
this, SIGNAL(minimumWidthChanged()));
}
if (m_qmlObject->rootObject()->property("minimumHeight").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(minimumHeightChanged()),
this, SIGNAL(minimumHeightChanged()));
}
if (m_qmlObject->rootObject()->property("maximumWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(maximumWidthChanged()),
this, SIGNAL(maximumWidthChanged()));
}
if (m_qmlObject->rootObject()->property("maximumHeight").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(maximumHeightChanged()),
this, SIGNAL(maximumHeightChanged()));
}
if (m_qmlObject->rootObject()->property("implicitWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(implicitWidthChanged()),
this, SIGNAL(implicitWidthChanged()));
}
if (m_qmlObject->rootObject()->property("implicitHeight").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(implicitHeightChanged()),
this, SIGNAL(implicitHeightChanged()));
}
emit fillWidthChanged();
emit fillHeightChanged();
emit minimumWidthChanged();
emit minimumHeightChanged();
emit implicitWidthChanged();
emit implicitHeightChanged();
emit maximumWidthChanged();
emit maximumHeightChanged();
}
QList <QObject *> ContainmentInterface::applets()