[Kst] extragear/graphics/kst/kst
Rick Chern
rchern at interchange.ubc.ca
Fri Aug 19 20:58:44 CEST 2005
SVN commit 451034 by rchern:
- make object groups have transparent background as default
- allow selection of transparent background and selection of background color for object groups
- fix saving/loading plotgroup properties
M +67 -12 kstplotgroup.cpp
M +6 -0 kstplotgroup.h
--- trunk/extragear/graphics/kst/kst/kstplotgroup.cpp #451033:451034
@@ -37,10 +37,23 @@
setTagName(i18n("Plot Group %1").arg(++pgcount));
_type = "plotgroup";
setBorderColor(Qt::blue);
+ setTransparent(true);
}
KstPlotGroup::KstPlotGroup(const QDomElement& e) : KstMetaPlot(e) {
+ QDomNode n = e.firstChild();
+ while (!n.isNull()) {
+ QDomElement el = n.toElement();
+ if (!el.isNull()) {
+ if (metaObject()->findProperty(el.tagName().latin1(), true) > -1) {
+ setProperty(el.tagName().latin1(), QVariant(el.text()));
+ }
+ }
+ n = n.nextSibling();
+ }
+
+ // always have these values
_standardActions |= Delete | Raise | Zoom | Lower | RaiseToTop | LowerToBottom;
_layoutActions |= Delete | Copy | Raise | Lower | RaiseToTop | LowerToBottom | Rename | MoveTo;
setTagName(i18n("Plot Group %1").arg(++pgcount));
@@ -134,26 +147,39 @@
void KstPlotGroup::paint(KstPaintType type, QPainter& p) {
- QRegion clipRegion(geometry());
- QBrush brush(_backgroundColor);
- bool hadClipping = p.hasClipping();
- QRegion oldRegion = p.clipRegion();
-
+
if (KstApp::inst()->getZoomRadio() == KstApp::LAYOUT) {
setBorderWidth(0);
} else {
setBorderWidth(0);
}
- for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
- clipRegion -= (*i)->clipRegion();
+ QRegion clipRegion;
+
+ if (transparent()) {
+ // make the clipregion just the children
+ for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+ clipRegion += (*i)->clipRegion();
+ }
+ QRegion oldRegion = p.clipRegion();
+ p.setClipRegion(clipRegion + oldRegion);
+ } else {
+ // fill non-children areas with color
+ clipRegion = QRegion(geometry());
+ QBrush brush(_backgroundColor);
+ bool hadClipping = p.hasClipping();
+ QRegion oldRegion = p.clipRegion();
+ for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+ clipRegion -= (*i)->clipRegion();
+ }
+ p.setClipRegion(clipRegion);
+ p.fillRect(geometry(), brush);
+
+ p.setClipRegion(oldRegion);
+ p.setClipping(hadClipping);
}
- p.setClipRegion(clipRegion);
- p.fillRect(geometry(), brush);
+
- p.setClipRegion(oldRegion);
- p.setClipping(hadClipping);
-
#ifdef BENCHMARK
QTime t;
t.start();
@@ -207,5 +233,34 @@
return &create_KstPlotGroup;
}
+
+void KstPlotGroup::setTransparent(bool transparent) {
+ KstViewObject::setTransparent(transparent);
+}
+
+
+bool KstPlotGroup::transparent() const {
+ return KstViewObject::transparent();
+}
+
+
+QMap<QString, QVariant> KstPlotGroup::widgetHints(const QString& propertyName) const {
+ // don't ask for borderedviewobject hints because we don't want to set border color
+ QMap<QString, QVariant> map = KstViewObject::widgetHints(propertyName);
+ if (!map.empty()) {
+ return map;
+ }
+
+ if (propertyName == "transparent") {
+ map.insert(QString("_kst_widgetType"), QString("QCheckBox"));
+ map.insert(QString("_kst_label"), i18n(""));
+ map.insert(QString("text"), i18n("Transparent background"));
+ } else if (propertyName == "backColor") {
+ map.insert(QString("_kst_widgetType"), QString("KColorButton"));
+ map.insert(QString("_kst_label"), i18n("Background color"));
+ }
+ return map;
+}
+
#include "kstplotgroup.moc"
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstplotgroup.h #451033:451034
@@ -21,6 +21,7 @@
class KstPlotGroup : public KstMetaPlot {
Q_OBJECT
+ Q_PROPERTY(bool transparent READ transparent WRITE setTransparent)
public:
KstPlotGroup();
KstPlotGroup(const QDomElement& e);
@@ -34,6 +35,11 @@
virtual bool layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
virtual void setHasFocus(bool hasFocus);
virtual void removeFocus(QPainter& p);
+
+ void setTransparent(bool transparent);
+ bool transparent() const;
+
+ virtual QMap<QString, QVariant> widgetHints(const QString& propertyName) const;
public slots:
virtual void paint(KstPaintType type, QPainter& p);
More information about the Kst
mailing list