Version: 1.3.0_devel (using KDE 3.4.0, compiled sources) Compiler: gcc version 3.4.3 OS: SunOS (sun4u) release 5.8 Regardless of the outcome of the discussion attached to bug #129281 regarding the edition of multiple view objects a posteriori (i.e. after creation) and as discussed there already, I think it would be nice to make it easier to create a series of objects with common settings. We should therefore implement *optional* sticky settings for each type of view objects, which would make it easy to create e.g. a series of boxes with the same line color, roundedness and fill. The default should be as it is now (don't remember the settings) but an extra "Temporary defaults" button could be added to the dialogs, with possibly a second button "Cancel temp. defaults" to revert to factory defaults (the naming may need to be improved, but I think you get the idea).
I would suggest the labels be "Set defaults" and "Restore defaults". These would both be regular buttons (i.e. not check or radio) and would be disabled when in edit multiple mode.
I like the idea of a "set current values as defaults" and "restore defaults to default values" buttons, but can we come up with a more compact way of labeling these? Icons?
Icons seem difficult to create for such a case. But maybe if we find some icons that are not too bad, and add a tooltip on the buttons, then it might be OK ?
SVN commit 705936 by arwalker: BUG:130278 Add set defaults and restore defaults button to the edit view object dialog. This allows the user to create session defaults for each of the view objects. M +49 -3 editviewobjectdialog.ui M +27 -16 ksteditviewobjectdialog_i.cpp M +2 -0 ksteditviewobjectdialog_i.h M +1 -0 kstgfxellipsemousehandler.cpp M +2 -0 kstgfxmousehandler.h M +8 -0 ksttoplevelview.cpp M +6 -5 ksttoplevelview.h M +1 -1 kstviewellipse.cpp --- branches/work/kst/1.5/kst/src/libkstapp/editviewobjectdialog.ui #705935:705936 @@ -19,7 +19,7 @@ <property name="name"> <cstring>unnamed</cstring> </property> - <widget class="EditMultipleWidget" row="0" column="1" rowspan="3" colspan="1"> + <widget class="EditMultipleWidget" row="0" column="1" rowspan="4" colspan="1"> <property name="name"> <cstring>_editMultipleWidget</cstring> </property> @@ -76,7 +76,7 @@ </widget> </hbox> </widget> - <widget class="QLayoutWidget" row="3" column="0" rowspan="1" colspan="2"> + <widget class="QLayoutWidget" row="4" column="0" rowspan="1" colspan="2"> <property name="name"> <cstring>layout6</cstring> </property> @@ -167,10 +167,56 @@ <property name="sizeHint"> <size> <width>41</width> - <height>241</height> + <height>210</height> </size> </property> </spacer> + <widget class="QButtonGroup" row="3" column="0"> + <property name="name"> + <cstring>buttonGroup2</cstring> + </property> + <property name="title"> + <string>Object defaults:</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>_pushButtonSetDefaults</cstring> + </property> + <property name="text"> + <string>Set</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>_pushButtonRestoreDefaults</cstring> + </property> + <property name="text"> + <string>Restore</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer4_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>181</width> + <height>21</height> + </size> + </property> + </spacer> + </hbox> + </widget> </grid> </widget> <customwidgets> --- branches/work/kst/1.5/kst/src/libkstapp/ksteditviewobjectdialog_i.cpp #705935:705936 @@ -47,6 +47,8 @@ connect(_apply, SIGNAL(clicked()), this, SLOT(applyClicked())); connect(_OK, SIGNAL(clicked()), this, SLOT(okClicked())); connect(_editMultiple, SIGNAL(clicked()), this, SLOT(toggleEditMultiple())); + connect(_pushButtonSetDefaults, SIGNAL(clicked()), this, SLOT(setDefaults())); + connect(_pushButtonRestoreDefaults, SIGNAL(clicked()), this, SLOT(restoreDefaults())); _grid = 0L; _viewObject = 0L; @@ -103,11 +105,14 @@ if (_editMultipleMode) { _editMultipleWidget->hide(); _editMultiple->setText(i18n("Edit Multiple >>")); - + _pushButtonSetDefaults->setEnabled(true); + _pushButtonRestoreDefaults->setEnabled(true); updateWidgets(); } else { _editMultipleWidget->show(); _editMultiple->setText(i18n("Edit Multiple <<")); + _pushButtonSetDefaults->setEnabled(false); + _pushButtonRestoreDefaults->setEnabled(false); if (_customWidget) { if (_viewObject) { @@ -467,20 +472,6 @@ viewObject->setProperty(propertyName.latin1(), (*iter)->property(widgetPropertyName.latin1())); } } - -#if 0 - // Removed by George. This is very strange. Some dialogs have 10+ - // properties, and when I change 8 of them, the next "new" object of the - // same type has all of these modified on me. I have to go through and - // change them all back to what they were before. I think this is too - // confusing and annoying. We could add a sticky flag or something like - // that if this feature is really demanded. - - // and then save this viewObject's properties as the default - if (_top) { - _top->saveDefaults(_viewObject); - } -#endif } } @@ -531,6 +522,26 @@ } +void KstEditViewObjectDialogI::setDefaults() { + if (_top) { + KstViewObjectPtr viewObject = _viewObject->copyObjectQuietly(*_top, QString("")); + _top->removeChild(viewObject); + + if (viewObject) { + applySettings(viewObject); + _top->saveDefaults(viewObject); + } + } +} + + +void KstEditViewObjectDialogI::restoreDefaults() { + if (_top) { + _top->restoreDefaults(_viewObject); + } +} + + void KstEditViewObjectDialogI::applyClicked() { apply(); } @@ -544,4 +555,4 @@ #include "ksteditviewobjectdialog_i.moc" -// vim: ts=2 sw=2 et + --- branches/work/kst/1.5/kst/src/libkstapp/ksteditviewobjectdialog_i.h #705935:705936 @@ -42,6 +42,8 @@ void showEditViewObjectDialog(KstViewObjectPtr viewObject, KstTopLevelViewPtr top); void setNew(); void toggleEditMultiple(); + void setDefaults(); + void restoreDefaults(); private: void updateWidgets(); --- branches/work/kst/1.5/kst/src/libkstapp/kstgfxellipsemousehandler.cpp #705935:705936 @@ -34,6 +34,7 @@ defaultEllipse->setBorderColor(Qt::black); defaultEllipse->setForegroundColor(Qt::white); _defaultObject = KstViewObjectPtr(defaultEllipse); + _currentDefaultObject = KstViewObjectPtr(defaultEllipse); } --- branches/work/kst/1.5/kst/src/libkstapp/kstgfxmousehandler.h #705935:705936 @@ -39,12 +39,14 @@ virtual void cancelMouseOperations(KstTopLevelViewPtr view); void saveDefaults(KstViewObjectPtr obj); + void restoreDefaults(); protected: // copy defaults to newObj void copyDefaults(KstViewObjectPtr newObj); KstViewObjectPtr _defaultObject; + KstViewObjectPtr _currentDefaultObject; QPoint _mouseOrigin; QRect _prevBand; bool _mouseMoved; --- branches/work/kst/1.5/kst/src/libkstapp/ksttoplevelview.cpp #705935:705936 @@ -1847,6 +1847,14 @@ } +void KstTopLevelView::restoreDefaults(KstViewObjectPtr object) { + KstGfxMouseHandler *handler = handlerForObject(object->type()); + if (handler) { + handler->restoreDefaults(); + } +} + + bool KstTopLevelView::handleDoubleClick(const QPoint& pos, bool shift) { handlePress(pos, shift); if (_pressTarget) { --- branches/work/kst/1.5/kst/src/libkstapp/ksttoplevelview.h #705935:705936 @@ -60,25 +60,26 @@ KstViewObjectList& selectionList() { return _selectionList; } KstViewObjectPtr pressTarget() const { return _pressTarget; } void clearPressTarget() { _pressTarget = 0L; } - + template<class T> KstSharedPtr<T> createObject(const QString& name, bool doCleanup = true); bool mouseGrabbed() const { return _mouseGrabbed; } KstViewObjectPtr mouseGrabber() const { return _mouseGrabber; } bool grabMouse(KstViewObjectPtr me); void releaseMouse(KstViewObjectPtr me); - + // save defaults for mouse mode from a given object void saveDefaults(KstViewObjectPtr object); - + void restoreDefaults(KstViewObjectPtr object); + bool tiedZoomPrev(const QString& plotName); bool tiedZoomMode(int zoom, bool flag, double center, int mode, int modeExtra, const QString& plotName); bool tiedZoom(bool x, double xmin, double xmax, bool y, double ymin, double ymax, const QString& plotName); public slots: void cleanupDefault(); - void cleanupCustom(); - + void cleanupCustom(); + private slots: void menuClosed(); void condenseXAxis(); --- branches/work/kst/1.5/kst/src/libkstapp/kstviewellipse.cpp #705935:705936 @@ -44,7 +44,7 @@ if (!el.isNull()) { if (metaObject()->findProperty(el.tagName().latin1(), true) > -1) { setProperty(el.tagName().latin1(), QVariant(el.text())); - } + } } n = n.nextSibling(); }
SVN commit 705937 by arwalker: CCBUG:130278 Add set defaults and restore defaults button to the edit view object dialog. This allows the user to create session defaults for each of the view objects. M +10 -4 kstgfxmousehandler.cpp --- branches/work/kst/1.5/kst/src/libkstapp/kstgfxmousehandler.cpp #705936:705937 @@ -36,6 +36,7 @@ void KstGfxMouseHandler::handlePress(KstTopLevelViewPtr view, const QPoint& pos, bool shift) { Q_UNUSED(view) Q_UNUSED(shift) + _mouseOrigin = pos; _mouseMoved = false; _cancelled = false; @@ -44,16 +45,21 @@ void KstGfxMouseHandler::saveDefaults(KstViewObjectPtr obj) { - _defaultObject = obj; + _currentDefaultObject = obj; } +void KstGfxMouseHandler::restoreDefaults() { + _currentDefaultObject = _defaultObject; +} + + void KstGfxMouseHandler::copyDefaults(KstViewObjectPtr newObj) { if (_defaultObject) { - int numProperties = _defaultObject->metaObject()->numProperties(true); + int numProperties = _currentDefaultObject->metaObject()->numProperties(true); for (int i = 0; i < numProperties; i++) { - const QMetaProperty* property = _defaultObject->metaObject()->property(i, true); - newObj->setProperty(property->name(), _defaultObject->property(property->name())); + const QMetaProperty* property = _currentDefaultObject->metaObject()->property(i, true); + newObj->setProperty(property->name(), _currentDefaultObject->property(property->name())); } } }