a simple way to enable/disable background
This commit is contained in:
parent
93052bf263
commit
38bcec95b0
@ -61,7 +61,8 @@ public:
|
|||||||
hideOnWindowDeactivate(false),
|
hideOnWindowDeactivate(false),
|
||||||
outputOnly(false),
|
outputOnly(false),
|
||||||
componentComplete(dialog->parent() == 0),
|
componentComplete(dialog->parent() == 0),
|
||||||
resizeOrigin(Undefined)
|
resizeOrigin(Undefined),
|
||||||
|
backgroundHints(Dialog::StandardBackground)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +102,7 @@ public:
|
|||||||
Plasma::Theme theme;
|
Plasma::Theme theme;
|
||||||
bool componentComplete;
|
bool componentComplete;
|
||||||
ResizeOrigin resizeOrigin;
|
ResizeOrigin resizeOrigin;
|
||||||
|
Dialog::BackgroundHints backgroundHints;
|
||||||
|
|
||||||
//Attached Layout property of mainItem, if any
|
//Attached Layout property of mainItem, if any
|
||||||
QWeakPointer <QObject> mainItemLayout;
|
QWeakPointer <QObject> mainItemLayout;
|
||||||
@ -460,7 +462,7 @@ Dialog::Dialog(QQuickItem *parent)
|
|||||||
property("data");
|
property("data");
|
||||||
//Create the FrameSvg background.
|
//Create the FrameSvg background.
|
||||||
d->frameSvgItem = new Plasma::FrameSvgItem(contentItem());
|
d->frameSvgItem = new Plasma::FrameSvgItem(contentItem());
|
||||||
d->frameSvgItem->setImagePath("dialogs/background");
|
//d->frameSvgItem->setImagePath("dialogs/background");
|
||||||
|
|
||||||
connect(&d->theme, SIGNAL(themeChanged()),
|
connect(&d->theme, SIGNAL(themeChanged()),
|
||||||
this, SLOT(updateTheme()));
|
this, SLOT(updateTheme()));
|
||||||
@ -761,11 +763,15 @@ void Dialog::setType(WindowType type)
|
|||||||
setFlags(Qt::FramelessWindowHint | flags());
|
setFlags(Qt::FramelessWindowHint | flags());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == Tooltip) {
|
if (d->backgroundHints == Dialog::NoBackground) {
|
||||||
|
d->frameSvgItem->setImagePath(QString());
|
||||||
|
} else {
|
||||||
|
if (d->type == Tooltip) {
|
||||||
d->frameSvgItem->setImagePath("widgets/tooltip");
|
d->frameSvgItem->setImagePath("widgets/tooltip");
|
||||||
} else {
|
} else {
|
||||||
d->frameSvgItem->setImagePath("dialogs/background");
|
d->frameSvgItem->setImagePath("dialogs/background");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (type == Dock) {
|
if (type == Dock) {
|
||||||
KWindowSystem::setOnAllDesktops(winId(), true);
|
KWindowSystem::setOnAllDesktops(winId(), true);
|
||||||
@ -850,6 +856,15 @@ void Dialog::classBegin()
|
|||||||
|
|
||||||
void Dialog::componentComplete()
|
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->componentComplete = true;
|
||||||
d->syncToMainItemSize();
|
d->syncToMainItemSize();
|
||||||
}
|
}
|
||||||
@ -882,6 +897,30 @@ void Dialog::setOutputOnly(bool outputOnly)
|
|||||||
emit outputOnlyChanged();
|
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"
|
#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)
|
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")
|
Q_CLASSINFO("DefaultProperty", "mainItem")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -129,6 +136,12 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUMS(WindowType)
|
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(QQuickItem *parent = 0);
|
||||||
~Dialog();
|
~Dialog();
|
||||||
|
|
||||||
@ -155,6 +168,9 @@ public:
|
|||||||
void setOutputOnly(bool outputOnly);
|
void setOutputOnly(bool outputOnly);
|
||||||
bool isOutputOnly() const;
|
bool isOutputOnly() const;
|
||||||
|
|
||||||
|
BackgroundHints backgroundHints() const;
|
||||||
|
void setBackgroundHints(BackgroundHints hints);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns The suggested screen position for the popup
|
* @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
|
* @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 hideOnWindowDeactivateChanged();
|
||||||
void outputOnlyChanged();
|
void outputOnlyChanged();
|
||||||
void flagsChanged();
|
void flagsChanged();
|
||||||
|
void backgroundHintsChanged();
|
||||||
/**
|
/**
|
||||||
* Emitted when the @see hideOnWindowDeactivate property is @c true and this dialog lost focus to a
|
* 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.
|
* window that is neither a parent dialog to nor a child dialog of this dialog.
|
||||||
|
Loading…
Reference in New Issue
Block a user