[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Wed Jul 22 21:54:37 CEST 2009
SVN commit 1001282 by fenton:
Add view based plot font default settings.
M +2 -7 plotitem.cpp
M +47 -1 view.cpp
M +3 -0 view.h
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1001281:1001282
@@ -94,7 +94,6 @@
_plotPixmapDirty(true),
_i_per(0)
{
-
setTypeName("Plot");
setBrush(Qt::white);
@@ -107,14 +106,14 @@
connect(this, SIGNAL(geometryChanged()), _yAxis, SLOT(setTicksUpdated()));
connect(this, SIGNAL(geometryChanged()), this, SLOT(setPlotRectsDirty()));
- _globalFont = parentView()->defaultFont();
-
_leftLabelDetails = new PlotLabel(this);
_rightLabelDetails = new PlotLabel(this);
_topLabelDetails = new PlotLabel(this);
_bottomLabelDetails = new PlotLabel(this);
_numberLabelDetails = new PlotLabel(this);
+ parentView()->configurePlotFontDefaults(this);
+
connect(_leftLabelDetails, SIGNAL(labelChanged()), this, SLOT(setPlotBordersDirty()));
connect(_leftLabelDetails, SIGNAL(labelChanged()), this, SLOT(setLeftLabelDirty()));
connect(_rightLabelDetails, SIGNAL(labelChanged()), this, SLOT(setPlotBordersDirty()));
@@ -126,10 +125,6 @@
connect(_numberLabelDetails, SIGNAL(labelChanged()), this, SLOT(setPlotBordersDirty()));
connect(_numberLabelDetails, SIGNAL(labelChanged()), this, SLOT(setAxisLabelsDirty()));
- _globalFont = parentView()->defaultFont();
- _globalFontColor = ApplicationSettings::self()->defaultFontColor();
- _globalFontScale = ApplicationSettings::self()->defaultFontScale();
-
_undoStack = new QUndoStack(this);
createActions();
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #1001281:1001282
@@ -20,6 +20,7 @@
#include "viewgridlayout.h"
#include "document.h"
#include "plotitemmanager.h"
+#include "plotitem.h"
#include <math.h>
@@ -138,7 +139,6 @@
}
-
View::ViewMode View::viewMode() const {
return _viewMode;
}
@@ -518,6 +518,52 @@
}
+void View::configurePlotFontDefaults(PlotItem *plot) {
+ if (plot) {
+ bool configured = false;
+ foreach(PlotItem* plotItem, PlotItemManager::self()->plotsForView(this)) {
+ if (plot != plotItem) {
+ configured = true;
+ plot->setGlobalFont(plotItem->globalFont());
+ plot->setGlobalFontScale(plotItem->globalFontScale());
+ plot->setGlobalFontColor(plotItem->globalFontColor());
+
+ plot->leftLabelDetails()->setFontUseGlobal(plotItem->leftLabelDetails()->fontUseGlobal());
+ plot->leftLabelDetails()->setFont(plotItem->leftLabelDetails()->font());
+ plot->leftLabelDetails()->setFontScale(plotItem->leftLabelDetails()->fontScale());
+ plot->leftLabelDetails()->setFontColor(plotItem->leftLabelDetails()->fontColor());
+
+ plot->rightLabelDetails()->setFontUseGlobal(plotItem->rightLabelDetails()->fontUseGlobal());
+ plot->rightLabelDetails()->setFont(plotItem->rightLabelDetails()->font());
+ plot->rightLabelDetails()->setFontScale(plotItem->rightLabelDetails()->fontScale());
+ plot->rightLabelDetails()->setFontColor(plotItem->rightLabelDetails()->fontColor());
+
+ plot->topLabelDetails()->setFontUseGlobal(plotItem->topLabelDetails()->fontUseGlobal());
+ plot->topLabelDetails()->setFont(plotItem->topLabelDetails()->font());
+ plot->topLabelDetails()->setFontScale(plotItem->topLabelDetails()->fontScale());
+ plot->topLabelDetails()->setFontColor(plotItem->topLabelDetails()->fontColor());
+
+ plot->bottomLabelDetails()->setFontUseGlobal(plotItem->bottomLabelDetails()->fontUseGlobal());
+ plot->bottomLabelDetails()->setFont(plotItem->bottomLabelDetails()->font());
+ plot->bottomLabelDetails()->setFontScale(plotItem->bottomLabelDetails()->fontScale());
+ plot->bottomLabelDetails()->setFontColor(plotItem->bottomLabelDetails()->fontColor());
+
+ plot->numberLabelDetails()->setFontUseGlobal(plotItem->numberLabelDetails()->fontUseGlobal());
+ plot->numberLabelDetails()->setFont(plotItem->numberLabelDetails()->font());
+ plot->numberLabelDetails()->setFontScale(plotItem->numberLabelDetails()->fontScale());
+ plot->numberLabelDetails()->setFontColor(plotItem->numberLabelDetails()->fontColor());
+ break;
+ }
+ }
+ if (!configured) {
+ plot->setGlobalFont(defaultFont());
+ plot->setGlobalFontScale(ApplicationSettings::self()->defaultFontScale());
+ plot->setGlobalFontColor(ApplicationSettings::self()->defaultFontColor());
+ }
+ }
+}
+
+
void View::contextMenuEvent() {
QMenu menu;
--- branches/work/kst/portto4/kst/src/libkstapp/view.h #1001281:1001282
@@ -25,6 +25,7 @@
class ViewItem;
class LayoutBoxItem;
+class PlotItem;
class KST_EXPORT View : public QGraphicsView
{
@@ -99,6 +100,8 @@
bool plotBordersDirty() const {return _plotBordersDirty;}
void setPlotBordersDirty(bool dirty) {_plotBordersDirty = dirty;}
+ void configurePlotFontDefaults(PlotItem *plot);
+
Q_SIGNALS:
void viewModeChanged(View::ViewMode oldMode);
void mouseModeChanged(View::MouseMode oldMode);
More information about the Kst
mailing list