a simple way to enable/disable background
This commit is contained in:
parent
93052bf263
commit
38bcec95b0
@ -61,7 +61,8 @@ public:
|
||||
hideOnWindowDeactivate(false),
|
||||
outputOnly(false),
|
||||
componentComplete(dialog->parent() == 0),
|
||||
resizeOrigin(Undefined)
|
||||
resizeOrigin(Undefined),
|
||||
backgroundHints(Dialog::StandardBackground)
|
||||
{
|
||||
}
|
||||
|
||||
@ -101,6 +102,7 @@ public:
|
||||
Plasma::Theme theme;
|
||||
bool componentComplete;
|
||||
ResizeOrigin resizeOrigin;
|
||||
Dialog::BackgroundHints backgroundHints;
|
||||
|
||||
//Attached Layout property of mainItem, if any
|
||||
QWeakPointer <QObject> mainItemLayout;
|
||||
@ -460,7 +462,7 @@ Dialog::Dialog(QQuickItem *parent)
|
||||
property("data");
|
||||
//Create the FrameSvg background.
|
||||
d->frameSvgItem = new Plasma::FrameSvgItem(contentItem());
|
||||
d->frameSvgItem->setImagePath("dialogs/background");
|
||||
//d->frameSvgItem->setImagePath("dialogs/background");
|
||||
|
||||
connect(&d->theme, SIGNAL(themeChanged()),
|
||||
this, SLOT(updateTheme()));
|
||||
@ -761,10 +763,14 @@ void Dialog::setType(WindowType type)
|
||||
setFlags(Qt::FramelessWindowHint | flags());
|
||||
}
|
||||
|
||||
if (type == Tooltip) {
|
||||
d->frameSvgItem->setImagePath("widgets/tooltip");
|
||||
if (d->backgroundHints == Dialog::NoBackground) {
|
||||
d->frameSvgItem->setImagePath(QString());
|
||||
} else {
|
||||
d->frameSvgItem->setImagePath("dialogs/background");
|
||||
if (d->type == Tooltip) {
|
||||
d->frameSvgItem->setImagePath("widgets/tooltip");
|
||||
} else {
|
||||
d->frameSvgItem->setImagePath("dialogs/background");
|
||||
}
|
||||
}
|
||||
|
||||
if (type == Dock) {
|
||||
@ -850,6 +856,15 @@ void Dialog::classBegin()
|
||||
|
||||
void Dialog::componentComplete()
|
||||
{
|
||||
if (d->backgroundHints == NoBackground) {
|
||||
d->frameSvgItem->setImagePath(QString());
|
||||
} else {
|
||||
if (d->type == Tooltip) {
|
||||
d->frameSvgItem->setImagePath("widgets/tooltip");
|
||||
} else {
|
||||
d->frameSvgItem->setImagePath("dialogs/background");
|
||||
}
|
||||
}
|
||||
d->componentComplete = true;
|
||||
d->syncToMainItemSize();
|
||||
}
|
||||
@ -882,6 +897,30 @@ void Dialog::setOutputOnly(bool outputOnly)
|
||||
emit outputOnlyChanged();
|
||||
}
|
||||
|
||||
Dialog::BackgroundHints Dialog::backgroundHints() const
|
||||
{
|
||||
return d->backgroundHints;
|
||||
}
|
||||
|
||||
void Dialog::setBackgroundHints(Dialog::BackgroundHints hints)
|
||||
{
|
||||
if (d->backgroundHints == hints) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->backgroundHints = hints;
|
||||
if (hints == NoBackground) {
|
||||
d->frameSvgItem->setImagePath(QString());
|
||||
} else {
|
||||
if (d->type == Tooltip) {
|
||||
d->frameSvgItem->setImagePath("widgets/tooltip");
|
||||
} else {
|
||||
d->frameSvgItem->setImagePath("dialogs/background");
|
||||
}
|
||||
}
|
||||
emit backgroundHintsChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_dialog.cpp"
|
||||
|
@ -116,6 +116,13 @@ class PLASMAQUICK_EXPORT Dialog : public QQuickWindow, public QQmlParserStatus
|
||||
*/
|
||||
Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFramelessFlags NOTIFY flagsChanged)
|
||||
|
||||
/**
|
||||
* This property holds how (and if at all) the dialog should draw its own background
|
||||
* or if it complete responsibility of the content to render a background.
|
||||
* Note that in this case it loses kwin side shadows and blur
|
||||
*/
|
||||
Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints NOTIFY backgroundHintsChanged)
|
||||
|
||||
Q_CLASSINFO("DefaultProperty", "mainItem")
|
||||
|
||||
public:
|
||||
@ -129,6 +136,12 @@ public:
|
||||
};
|
||||
Q_ENUMS(WindowType)
|
||||
|
||||
enum BackgroundHints {
|
||||
NoBackground = 0, /**< Not drawing a background under the applet, the dialog has its own implementation */
|
||||
StandardBackground = 1 /**< The standard background from the theme is drawn */
|
||||
};
|
||||
Q_ENUMS(BackgroundHints)
|
||||
|
||||
Dialog(QQuickItem *parent = 0);
|
||||
~Dialog();
|
||||
|
||||
@ -155,6 +168,9 @@ public:
|
||||
void setOutputOnly(bool outputOnly);
|
||||
bool isOutputOnly() const;
|
||||
|
||||
BackgroundHints backgroundHints() const;
|
||||
void setBackgroundHints(BackgroundHints hints);
|
||||
|
||||
/**
|
||||
* @returns The suggested screen position for the popup
|
||||
* @arg item the item the popup has to be positioned relatively to. if null, the popup will be positioned in the center of the window
|
||||
@ -170,6 +186,7 @@ Q_SIGNALS:
|
||||
void hideOnWindowDeactivateChanged();
|
||||
void outputOnlyChanged();
|
||||
void flagsChanged();
|
||||
void backgroundHintsChanged();
|
||||
/**
|
||||
* Emitted when the @see hideOnWindowDeactivate property is @c true and this dialog lost focus to a
|
||||
* window that is neither a parent dialog to nor a child dialog of this dialog.
|
||||
|
Loading…
Reference in New Issue
Block a user