[Kst] extragear/graphics/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Thu Dec 1 06:37:16 CET 2005


SVN commit 484515 by netterfield:

Apply defaults to new view label dialog.
Click in text mode pops up a text dialog in transparent, no box mode
Box in label mode pops up a label dialog in !tranparent, w/ box mode.



 M  +20 -4     kstgfxtextmousehandler.cpp  
 M  +24 -57    kstviewlabel.cpp  


--- trunk/extragear/graphics/kst/kst/kstgfxtextmousehandler.cpp #484514:484515
@@ -34,7 +34,8 @@
   defaultLabel->setAutoResize(true);
   defaultLabel->setForegroundColor(Qt::black);
   defaultLabel->setBackgroundColor(Qt::white);
-  defaultLabel->setTransparent(true);
+  defaultLabel->setTransparent(false);
+  defaultLabel->setBorderWidth(2);
   _defaultObject = KstViewObjectPtr(defaultLabel); 
 }  
 
@@ -78,12 +79,27 @@
   _mouseDown = false;
   
   // once released, create a new text object and popup the edit dialog
-  if (!_cancelled && _mouseOrigin != pos) {
+  if (!_cancelled) {
     KstViewLabelPtr label = new KstViewLabel(QString::null);
     copyDefaults(KstViewObjectPtr(label));
     _top->appendChild(KstViewObjectPtr(label));
-    label->move(_prevBand.topLeft());
-    label->resize(_prevBand.size());
+    
+    QSize size(0,0);
+    if (_mouseOrigin != pos) {
+      label->move(_prevBand.topLeft());
+      size = _prevBand.size();
+    } else {
+      label->move(pos);
+    }
+
+    if (size.width()<3) {
+      size.setWidth(3);
+    }
+    if (size.height()<3) {
+      size.setHeight(3);
+    }
+    label->resize(size);
+
     label->showDialog(KstTopLevelViewPtr(_top));
     KstApp::inst()->document()->setModified();
   }
--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #484514:484515
@@ -105,9 +105,9 @@
         }
       }  
     }
-    n = n.nextSibling();      
+    n = n.nextSibling();
   }
-  
+
   _autoResize = in_autoResize;
 }
 
@@ -217,9 +217,6 @@
   _backBuffer.buffer().resize(size());
   _backBuffer.buffer().fill(backgroundColor());
   QPainter p(&_backBuffer.buffer());
-/*  QPen pen;
-  pen.setColor(foregroundColor());
-  p.setPen(pen);*/
   drawToPainter(lp, p);
 }
 
@@ -530,58 +527,6 @@
   return _rotation; 
 }
 
-
-// QMap<QString, QVariant> KstViewLabel::widgetHints(const QString& propertyName) const {
-//   QMap<QString, QVariant> map = KstBorderedViewObject::widgetHints(propertyName);
-//   if (!map.empty()) {
-//     return map;  
-//   }
-//   
-//   if (propertyName == "text") {
-//     map.insert(QString("_kst_widgetType"), QString("QLineEdit"));
-//     map.insert(QString("_kst_label"), i18n("Text"));  
-//   } else if (propertyName == "rotation") {
-//     map.insert(QString("_kst_widgetType"), QString("KDoubleSpinBox"));
-//     map.insert(QString("_kst_label"), i18n("Rotation")); 
-//     map.insert(QString("minValue"), -90.0);
-//     map.insert(QString("maxValue"), 90.0);
-//     map.insert(QString("lineStep"), 1.0);
-//   } else if (propertyName == "font") {
-//     map.insert(QString("_kst_widgetType"), QString("KFontCombo"));
-//     map.insert(QString("_kst_label"), i18n("Font"));
-//   } else if (propertyName == "foregroundColor") {
-//     map.insert(QString("_kst_widgetType"), QString("KColorButton"));
-//     map.insert(QString("_kst_label"), i18n("Font color"));   
-//   } else if (propertyName == "backgroundColor") {
-//     map.insert(QString("_kst_widgetType"), QString("KColorButton"));
-//     map.insert(QString("_kst_label"), i18n("Background color"));   
-//   } else if (propertyName == "dataPrecision") {
-//     map.insert(QString("_kst_widgetType"), QString("QSpinBox"));
-//     map.insert(QString("_kst_label"), i18n("Data precision"));   
-//     map.insert(QString("minValue"), 0);
-//     map.insert(QString("maxValue"), 16);
-//   } else if (propertyName == "fontSize") {
-//     map.insert(QString("_kst_widgetType"), QString("QSpinBox"));
-//     map.insert(QString("_kst_label"), i18n("Font size"));
-//     map.insert(QString("minValue"), MIN_FONT_SIZE - (double)KstSettings::globalSettings()->plotFontSize);   
-//   } else if (propertyName == "transparent") {
-//     map.insert(QString("_kst_widgetType"), QString("QCheckBox"));
-//     map.insert(QString("_kst_label"), QString::null);
-//     map.insert(QString("text"), i18n("Transparent fill"));   
-//   } else if (propertyName == "horizontalJustification") {
-//     map.insert(QString("_kst_widgetType"), QString("HJustifyCombo"));
-//     map.insert(QString("_kst_label"), i18n("Horizontal Justification"));
-//   } else if (propertyName == "verticalJustification") {
-//     map.insert(QString("_kst_widgetType"), QString("VJustifyCombo"));
-//     map.insert(QString("_kst_label"), i18n("Vertical Justification"));
-//   } else if (propertyName == "autoResize") {
-//     map.insert(QString("_kst_widgetType"), QString("QCheckBox"));
-//     map.insert(QString("_kst_label"), QString::null);
-//     map.insert(QString("text"), i18n("Resize label for text"));   
-//   }
-//   return map;
-// }
-
 bool KstViewLabel::fillConfigWidget(QWidget *w) const {
   ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
   if (!w) {
@@ -589,6 +534,28 @@
   }
   
   if (text().isEmpty()) { // probably a new label: set widget to defaults
+    widget->_precision->setValue(8);
+    widget->_rotation->setValue(0);
+    widget->_fontSize->setValue(0);
+    widget->_horizontal->setCurrentItem(2);
+    widget->_vertical->setCurrentItem(2);
+    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->_autoResize->setChecked(true);
+      widget->_border->setValue(0);
+    } else { // someone drew a box, so assume that is what they wanted
+      widget->_transparent->setChecked(false);
+      widget->_autoResize->setChecked(false);
+      widget->_border->setValue(2);
+    }
+
   } else { 
     // replace \n & \t with tabs and newlines for the text edit box
     QString tmpstr = text();


More information about the Kst mailing list