[Kst] branches/work/kst/1.5/kst/src/libkstapp
Andrew Walker
arwalker at sumusltd.com
Wed Aug 29 22:41:06 CEST 2007
SVN commit 706275 by arwalker:
allow default settings for labels
M +7 -2 kstgfxtextmousehandler.cpp
M +15 -37 kstviewlabel.cpp
M +1 -1 kstviewlabel.h
M +1 -1 viewlabelwidget.ui
--- branches/work/kst/1.5/kst/src/libkstapp/kstgfxtextmousehandler.cpp #706274:706275
@@ -21,6 +21,7 @@
#include "kstgfxtextmousehandler.h"
#include "kstgfxmousehandlerutils.h"
+#include "kstsettings.h"
#include "kst.h"
#include "ksdebug.h"
#include "kstdoc.h"
@@ -31,10 +32,14 @@
: KstGfxMouseHandler() {
// initial default settings before any sticky settings
KstViewLabelPtr defaultLabel = new KstViewLabel;
- defaultLabel->setForegroundColor(Qt::black);
- defaultLabel->setBackgroundColor(Qt::white);
+ defaultLabel->setForegroundColor(KstSettings::globalSettings()->foregroundColor);
+ defaultLabel->setBackgroundColor(KstSettings::globalSettings()->backgroundColor);
defaultLabel->setTransparent(false);
+ defaultLabel->setFontName(KstApp::inst()->defaultFont());
defaultLabel->setBorderWidth(2);
+ defaultLabel->setLabelMargin(5);
+ defaultLabel->setRotation(0.0);
+ defaultLabel->setFontSize(0);
_defaultObject = KstViewObjectPtr(defaultLabel);
_currentDefaultObject = KstViewObjectPtr(defaultLabel);
}
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewlabel.cpp #706274:706275
@@ -616,47 +616,29 @@
return _rotation;
}
+
bool KstViewLabel::fillConfigWidget(QWidget *w, bool isNew) const {
ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
if (!widget) {
return false;
}
- if (isNew) { // probably a new label: set widget to defaults
- widget->_precision->setValue(8);
- widget->_rotation->setValue(0);
- widget->_fontSize->setValue(0);
- widget->_horizontal->setCurrentItem(0);
- widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor);
- widget->_font->setCurrentFont(KstApp::inst()->defaultFont());
- widget->_margin->setValue(5);
-
- widget->_boxColors->setForeground(KstSettings::globalSettings()->foregroundColor);
- widget->_boxColors->setBackground(KstSettings::globalSettings()->backgroundColor);
-
- if (size().width() * size().height() < 25) { // assume a click, and default to just text
- widget->_transparent->setChecked(true);
- widget->_border->setValue(0);
- } else { // someone drew a box, so assume that is what they wanted
- widget->_transparent->setChecked(false);
- widget->_border->setValue(2);
- }
- } else {
+ if (!isNew) {
widget->_text->setText(text());
+ }
- widget->_precision->setValue(int(dataPrecision()));
- widget->_rotation->setValue(double(rotation()));
- widget->_fontSize->setValue(int(fontSize()));
- widget->_horizontal->setCurrentItem(horizJustifyWrap());
- widget->_fontColor->setColor(foregroundColor());
- widget->_font->setCurrentFont(fontName());
+ widget->_precision->setValue(int(dataPrecision()));
+ widget->_rotation->setValue(double(rotation()));
+ widget->_fontSize->setValue(int(fontSize()));
+ widget->_horizontal->setCurrentItem(horizJustifyWrap());
+ widget->_fontColor->setColor(foregroundColor());
+ widget->_font->setCurrentFont(fontName());
- widget->_transparent->setChecked(transparent());
- widget->_border->setValue(borderWidth());
- widget->_boxColors->setForeground(borderColor());
- widget->_boxColors->setBackground(backgroundColor());
- widget->_margin->setValue(_labelMargin);
- }
+ widget->_transparent->setChecked(transparent());
+ widget->_border->setValue(borderWidth());
+ widget->_boxColors->setForeground(borderColor());
+ widget->_boxColors->setBackground(backgroundColor());
+ widget->_margin->setValue(labelMargin());
widget->_text->setFocus();
@@ -799,11 +781,6 @@
}
-bool KstViewLabel::supportsDefaults() {
- return false;
-}
-
-
void KstViewLabel::setDataPrecision(int prec) {
int n;
@@ -877,6 +854,7 @@
void KstViewLabel::setLabelMargin(int margin) {
int mm = kMax(0, margin);
+
if (mm != _labelMargin) {
_labelMargin = mm;
setDirty();
--- branches/work/kst/1.5/kst/src/libkstapp/kstviewlabel.h #706274:706275
@@ -38,6 +38,7 @@
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize)
Q_PROPERTY(bool transparent READ transparent WRITE setTransparent)
Q_PROPERTY(int horizontalJustification READ horizJustifyWrap WRITE setHorizJustifyWrap)
+ Q_PROPERTY(int labelMargin READ labelMargin WRITE setLabelMargin)
public:
KstViewLabel(const QString& txt = QString::null, KstLJustifyType justify = 0L, float rotation = 0.0);
KstViewLabel(const QDomElement& e);
@@ -100,7 +101,6 @@
bool readConfigWidget(QWidget *w, bool editMultipleMode);
void connectConfigWidget(QWidget *parent, QWidget *w) const;
void populateEditMultiple(QWidget *w);
- bool supportsDefaults();
KstObject::UpdateType update(int counter);
void adjustSizeForText(const QRect& w);
--- branches/work/kst/1.5/kst/src/libkstapp/viewlabelwidget.ui #706274:706275
@@ -323,7 +323,7 @@
<cstring>_margin</cstring>
</property>
<property name="minValue">
- <number>-99</number>
+ <number>0</number>
</property>
</widget>
<widget class="QLabel">
More information about the Kst
mailing list