[Kst] branches/work/kst/portto4/kst/src/libkstapp
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Aug 3 16:48:37 UTC 2011
SVN commit 1244679 by netterfield:
Add optional transparency durring drags.
Draw children when dragging.
M +10 -3 applicationsettings.cpp
M +4 -0 applicationsettings.h
M +2 -0 applicationsettingsdialog.cpp
M +7 -0 generaltab.cpp
M +3 -0 generaltab.h
M +10 -3 generaltab.ui
M +22 -7 viewitem.cpp
M +2 -0 viewitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.cpp #1244678:1244679
@@ -48,9 +48,7 @@
_settings = new QSettings("kst", "application");
- //FIXME Not sure if this is the best test for hardware acceleration
- // but right now opening with QGV with QGLWidget as viewport takes
- // several seconds delay when opening application on my system.
+ _transparentDrag = _settings->value("general/transparentdrag", false).toBool();
_useOpenGL = _settings->value("general/opengl", false).toBool(); //QVariant(QGLPixelBuffer::hasOpenGLPbuffers())).toBool();
_maxUpdate = _settings->value("general/minimumupdateperiod", QVariant(200)).toInt();
@@ -92,7 +90,16 @@
delete _settings;
}
+bool ApplicationSettings::transparentDrag() const {
+ return _transparentDrag;
+}
+void ApplicationSettings::setTransparentDrag(bool transparent_drag) {
+ _transparentDrag = transparent_drag;
+ _settings->setValue("general/transparentdrag",transparent_drag);
+ emit modified();
+}
+
bool ApplicationSettings::useOpenGL() const {
return _useOpenGL;
}
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.h #1244678:1244679
@@ -29,6 +29,9 @@
public:
static ApplicationSettings *self();
+ bool transparentDrag() const;
+ void setTransparentDrag(bool transparent_drag);
+
bool useOpenGL() const;
void setUseOpenGL(bool useOpenGL);
@@ -77,6 +80,7 @@
private:
QSettings *_settings;
+ bool _transparentDrag;
bool _useOpenGL;
double _refViewWidth;
double _refViewHeight;
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettingsdialog.cpp #1244678:1244679
@@ -74,6 +74,7 @@
void ApplicationSettingsDialog::setupGeneral() {
_generalTab->setUseOpenGL(ApplicationSettings::self()->useOpenGL());
+ _generalTab->setTransparentDrag(ApplicationSettings::self()->transparentDrag());
_generalTab->setMinimumUpdatePeriod(ApplicationSettings::self()->minimumUpdatePeriod());
}
@@ -104,6 +105,7 @@
void ApplicationSettingsDialog::generalChanged() {
//Need to block the signals so that the modified signal only goes out once...
ApplicationSettings::self()->blockSignals(true);
+ ApplicationSettings::self()->setTransparentDrag(_generalTab->transparentDrag());
ApplicationSettings::self()->setUseOpenGL(_generalTab->useOpenGL());
ApplicationSettings::self()->setMinimumUpdatePeriod(_generalTab->minimumUpdatePeriod());
ApplicationSettings::self()->blockSignals(false);
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.cpp #1244678:1244679
@@ -38,7 +38,14 @@
_useOpenGL->setChecked(useOpenGL);
}
+bool GeneralTab::transparentDrag() const {
+ return _transparentDrag->isChecked();
+}
+void GeneralTab::setTransparentDrag(const bool transparent_drag) {
+ _transparentDrag->setChecked(transparent_drag);
+}
+
int GeneralTab::minimumUpdatePeriod() const {
return _maxUpdate->value();
}
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.h #1244678:1244679
@@ -29,6 +29,9 @@
bool useOpenGL() const;
void setUseOpenGL(const bool useOpenGL);
+ bool transparentDrag() const;
+ void setTransparentDrag(const bool transparent_drag);
+
int minimumUpdatePeriod() const;
void setMinimumUpdatePeriod(const int Period);
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.ui #1244678:1244679
@@ -14,7 +14,7 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&Period between updates (ms):</string>
@@ -27,7 +27,7 @@
</property>
</widget>
</item>
- <item row="1" column="1" colspan="2">
+ <item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="_maxUpdate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -55,7 +55,7 @@
</property>
</widget>
</item>
- <item row="2" column="0">
+ <item row="3" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -81,6 +81,13 @@
</property>
</widget>
</item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="_transparentDrag">
+ <property name="text">
+ <string>Use transparency when dragging</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1244678:1244679
@@ -993,7 +993,11 @@
//pixmap.fill(brush().color());
// Qt::transparent is maybe too expensive, and when
// not moving a plot it also has no transparent background
+ if (ApplicationSettings::self()->transparentDrag()) {
pixmap.fill(Qt::transparent);
+ } else {
+ pixmap.fill(brush().color());
+ }
QPainter painter(&pixmap);
qreal x1 = -rect().height()*sin(theta);
@@ -1027,13 +1031,7 @@
setBrush(brush_hold);
// TODO also paint annotations
- QList<QGraphicsItem*> children = childItems();
- foreach(QGraphicsItem* child, children) {
- ViewItem* item = qgraphicsitem_cast<ViewItem*>(child);
- if (item) {
- //item->paint(&painter);
- }
- }
+ paintChildItems(painter);
painter.end();
drag->setPixmap(pixmap);
@@ -1054,6 +1052,23 @@
}
}
+void ViewItem::paintChildItems(QPainter &painter) {
+ QList<QGraphicsItem*> children = childItems();
+ foreach(QGraphicsItem* child, children) {
+ ViewItem* item = qgraphicsitem_cast<ViewItem*>(child);
+ if (item) {
+ painter.save();
+ painter.translate(item->pos().x(),
+ item->pos().y());
+ painter.rotate(item->rotationAngle());
+ item->paint(&painter);
+ item->paintChildItems(painter);
+ painter.restore();
+ }
+ }
+
+}
+
void ViewItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if (view()->viewMode() == View::Data) {
event->ignore();
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #1244678:1244679
@@ -170,6 +170,8 @@
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual void paint(QPainter *painter);
+ virtual void paintChildItems(QPainter &painter);
+
virtual QList<DialogPage*> dialogPages() const { return QList<DialogPage*>(); }
virtual QPointF centerOfRotation() const { return rect().center(); }
More information about the Kst
mailing list