[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Fri Jan 30 19:44:00 CET 2009
SVN commit 918778 by fenton:
Add Layout Settings at application and viewItem levels that provide seed values for ViewGridLayout.
M +31 -0 applicationsettings.cpp
M +8 -0 applicationsettings.h
M +28 -0 applicationsettingsdialog.cpp
M +4 -0 applicationsettingsdialog.h
M +0 -23 layouttab.cpp
M +0 -6 layouttab.h
M +0 -7 layouttab.ui
M +3 -5 viewgridlayout.cpp
M +3 -0 viewitem.cpp
M +8 -0 viewitem.h
M +6 -25 viewitemdialog.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.cpp #918777:918778
@@ -84,6 +84,11 @@
_defaultFontColor = QColor(_settings->value("defaultlabelproperties/defaultfontcolor", "black").toString());
_shareAxis = _settings->value("childviewoptions/shareaxis", QVariant(true)).toBool();
+
+ _layoutMargins.setHeight(_settings->value("layout/marginheight", QVariant(5.0)).toDouble());
+ _layoutMargins.setWidth(_settings->value("layout/marginwidth", QVariant(5.0)).toDouble());
+ _layoutSpacing.setHeight(_settings->value("layout/spacingheight", QVariant(0.0)).toDouble());
+ _layoutSpacing.setWidth(_settings->value("layout/spacingwidth", QVariant(0.0)).toDouble());
}
@@ -313,7 +318,33 @@
emit modified();
}
+
+QSizeF ApplicationSettings::layoutMargins() const {
+ return _layoutMargins;
}
+void ApplicationSettings::setLayoutMargins(QSizeF margins) {
+ _layoutMargins = margins;
+ _settings->setValue("layout/marginheight", margins.height());
+ _settings->setValue("layout/marginwidth", margins.width());
+ emit modified();
+}
+
+
+QSizeF ApplicationSettings::layoutSpacing() const {
+ return _layoutSpacing;
+}
+
+
+void ApplicationSettings::setLayoutSpacing(QSizeF spacing) {
+ _layoutSpacing = spacing;
+ _settings->setValue("layout/spacingheight", spacing.height());
+ _settings->setValue("layout/spacingwidth", spacing.width());
+ emit modified();
+}
+
+}
+
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.h #918777:918778
@@ -78,6 +78,12 @@
bool shareAxis() const;
void setShareAxis(bool shareAxis);
+ QSizeF layoutMargins() const;
+ void setLayoutMargins(QSizeF margins);
+
+ QSizeF layoutSpacing() const;
+ void setLayoutSpacing(QSizeF spacing);
+
Q_SIGNALS:
void modified();
@@ -105,6 +111,8 @@
QBrush _backgroundBrush;
QGradientStops _gradientStops;
bool _shareAxis;
+ QSizeF _layoutMargins;
+ QSizeF _layoutSpacing;
friend class ApplicationSettingsDialog;
};
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettingsdialog.cpp #918777:918778
@@ -18,6 +18,7 @@
#include "dialogpage.h"
#include "childviewoptionstab.h"
#include "defaultlabelpropertiestab.h"
+#include "layouttab.h"
#include <QDebug>
@@ -32,6 +33,7 @@
_gridTab = new GridTab(this);
_fillTab = new FillTab(this);
_defaultLabelPropertiesTab = new DefaultLabelPropertiesTab(this);
+ _layoutTab = new LayoutTab(this);
// _childViewOptionsTab = new ChildViewOptionsTab(this);
connect(_generalTab, SIGNAL(apply()), this, SLOT(generalChanged()));
@@ -39,6 +41,7 @@
connect(_fillTab, SIGNAL(apply()), this, SLOT(fillChanged()));
// connect(_childViewOptionsTab, SIGNAL(apply()), this, SLOT(childViewOptionsChanged()));
connect(_defaultLabelPropertiesTab, SIGNAL(apply()), this, SLOT(defaultLabelPropertiesChanged()));
+ connect(_layoutTab, SIGNAL(apply()), this, SLOT(layoutChanged()));
DialogPage *general = new DialogPage(this);
general->setPageTitle(tr("General"));
@@ -55,6 +58,11 @@
fill->addDialogTab(_fillTab);
addDialogPage(fill);
+ DialogPage *layout = new DialogPage(this);
+ layout->setPageTitle(tr("Default Layout Properties"));
+ layout->addDialogTab(_layoutTab);
+ addDialogPage(layout);
+
DialogPage *defaultLabelProperties = new DialogPage(this);
defaultLabelProperties->setPageTitle(tr("Default Label Properties"));
defaultLabelProperties->addDialogTab(_defaultLabelPropertiesTab);
@@ -69,6 +77,7 @@
setupGrid();
setupFill();
setupDefaultLabelProperties();
+ setupLayout();
// setupChildViewOptions();
selectDialogPage(general);
@@ -121,6 +130,14 @@
}
+void ApplicationSettingsDialog::setupLayout() {
+ _layoutTab->setHorizontalMargin(ApplicationSettings::self()->layoutMargins().width());
+ _layoutTab->setVerticalMargin(ApplicationSettings::self()->layoutMargins().height());
+ _layoutTab->setHorizontalSpacing(ApplicationSettings::self()->layoutSpacing().width());
+ _layoutTab->setVerticalSpacing(ApplicationSettings::self()->layoutSpacing().height());
+}
+
+
void ApplicationSettingsDialog::generalChanged() {
//Need to block the signals so that the modified signal only goes out once...
ApplicationSettings::self()->blockSignals(true);
@@ -180,6 +197,17 @@
}
+void ApplicationSettingsDialog::layoutChanged() {
+ //Need to block the signals so that the modified signal only goes out once...
+ ApplicationSettings::self()->blockSignals(true);
+ ApplicationSettings::self()->setLayoutMargins(QSizeF(_layoutTab->horizontalMargin(), _layoutTab->verticalMargin()));
+ ApplicationSettings::self()->setLayoutSpacing(QSizeF(_layoutTab->horizontalSpacing(), _layoutTab->verticalSpacing()));
+ ApplicationSettings::self()->blockSignals(false);
+
+ emit ApplicationSettings::self()->modified();
+}
+
+
void ApplicationSettingsDialog::setupChildViewOptions() {
_childViewOptionsTab->setShareAxis(ApplicationSettings::self()->shareAxis());
}
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettingsdialog.h #918777:918778
@@ -25,6 +25,7 @@
class FillTab;
class ChildViewOptionsTab;
class DefaultLabelPropertiesTab;
+class LayoutTab;
class KST_EXPORT ApplicationSettingsDialog : public Dialog
{
@@ -39,6 +40,7 @@
void fillChanged();
void childViewOptionsChanged();
void defaultLabelPropertiesChanged();
+ void layoutChanged();
private:
void setupGeneral();
@@ -46,6 +48,7 @@
void setupFill();
void setupChildViewOptions();
void setupDefaultLabelProperties();
+ void setupLayout();
private:
GeneralTab *_generalTab;
@@ -53,6 +56,7 @@
FillTab *_fillTab;
ChildViewOptionsTab *_childViewOptionsTab;
DefaultLabelPropertiesTab *_defaultLabelPropertiesTab;
+ LayoutTab *_layoutTab;
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/layouttab.cpp #918777:918778
@@ -23,7 +23,6 @@
connect(_verMargin, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
connect(_horSpacing, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
connect(_verSpacing, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
- connect(_lockAspectRatio, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
}
@@ -31,14 +30,6 @@
}
-void LayoutTab::setLayoutEnabled(bool layoutEnabled) {
- _horMargin->setEnabled(layoutEnabled);
- _verMargin->setEnabled(layoutEnabled);
- _horSpacing->setEnabled(layoutEnabled);
- _verSpacing->setEnabled(layoutEnabled);
-}
-
-
double LayoutTab::horizontalMargin() const {
return _horMargin->value();
}
@@ -79,20 +70,6 @@
}
-bool LayoutTab::lockAspectRatio() const {
- return _lockAspectRatio->isChecked();
}
-
-void LayoutTab::setLockAspectRatio(const bool lock) {
- _lockAspectRatio->setChecked(lock);
-}
-
-
-void LayoutTab::enableLockAspectRatio(const bool enable) {
- _lockAspectRatio->setEnabled(enable);
-}
-
-}
-
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/layouttab.h #918777:918778
@@ -25,8 +25,6 @@
LayoutTab(QWidget *parent = 0);
virtual ~LayoutTab();
- void setLayoutEnabled(bool layoutEnabled);
-
double horizontalMargin() const;
void setHorizontalMargin(double horizontalMargin);
@@ -38,10 +36,6 @@
double verticalSpacing() const;
void setVerticalSpacing(double verticalSpacing);
-
- bool lockAspectRatio() const;
- void setLockAspectRatio(const bool lock);
- void enableLockAspectRatio(const bool enable);
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/layouttab.ui #918777:918778
@@ -95,13 +95,6 @@
</property>
</widget>
</item>
- <item row="4" column="0" colspan="2" >
- <widget class="QCheckBox" name="_lockAspectRatio" >
- <property name="text" >
- <string>Lock Aspect Ratio</string>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
--- branches/work/kst/portto4/kst/src/libkstapp/viewgridlayout.cpp #918777:918778
@@ -24,8 +24,6 @@
#define DEBUG_PLOT_STANDARDIZATION 0
#define DEBUG_SHAREDAXIS 0
-static qreal DEFAULT_STRUT = 5.0;
-
namespace Kst {
ViewGridLayout::ViewGridLayout(ViewItem *parent)
@@ -34,9 +32,9 @@
_rowCount(0),
_columnCount(0),
_shareX(false),
- _shareY(false),
- _spacing(QSizeF(0.0, 0.0)),
- _margin(QSizeF(DEFAULT_STRUT,DEFAULT_STRUT)) {
+ _shareY(false) {
+ _spacing = parent->layoutSpacing();
+ _margin = parent->layoutMargins();
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #918777:918778
@@ -76,6 +76,9 @@
setShareAxis(ApplicationSettings::self()->shareAxis());
+ setLayoutMargins(ApplicationSettings::self()->layoutMargins());
+ setLayoutSpacing(ApplicationSettings::self()->layoutSpacing());
+
// Add actions common to all view objects
// create them here in the constructor so we
// can register shortcuts.
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #918777:918778
@@ -138,6 +138,12 @@
bool shareAxis() const { return _shareAxis; }
void setShareAxis(bool shareAxis);
+ QSizeF layoutMargins() const { return _layoutMargins; }
+ void setLayoutMargins(const QSizeF margins) { _layoutMargins = margins; }
+
+ QSizeF layoutSpacing() const { return _layoutSpacing; }
+ void setLayoutSpacing(const QSizeF spacing) { _layoutSpacing = spacing; }
+
//This is a workaround for context menu bug in Qt4.3 graphicsview
bool acceptsContextMenuEvents() const
{ return _acceptsContextMenuEvents; }
@@ -252,6 +258,8 @@
QHash<QString, QAction*> _shortcutMap;
qreal _parentRelativeHeight, _parentRelativeWidth;
+ QSizeF _layoutMargins, _layoutSpacing;
+
friend class View;
friend class Scene;
};
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.cpp #918777:918778
@@ -110,20 +110,10 @@
void ViewItemDialog::setupLayout() {
Q_ASSERT(_item);
-/* ViewGridLayout *layout = _item->layout();
-
- _layoutTab->setLockAspectRatio(_item->lockAspectRatio());
- _layoutTab->enableLockAspectRatio(!_item->lockAspectRatioFixed());
-
- if (!layout) {
- _layoutTab->setLayoutEnabled(false);
- return;
- }
-
- _layoutTab->setHorizontalMargin(layout->margin().width());
- _layoutTab->setVerticalMargin(layout->margin().height());
- _layoutTab->setHorizontalSpacing(layout->spacing().width());
- _layoutTab->setVerticalSpacing(layout->spacing().height());*/
+ _layoutTab->setHorizontalMargin(_item->layoutMargins().width());
+ _layoutTab->setVerticalMargin(_item->layoutMargins().height());
+ _layoutTab->setHorizontalSpacing(_item->layoutSpacing().width());
+ _layoutTab->setVerticalSpacing(_item->layoutSpacing().height());
}
@@ -169,19 +159,10 @@
void ViewItemDialog::layoutChanged() {
Q_ASSERT(_item);
-/* ViewGridLayout *layout = _item->layout();
-
- _item->setLockAspectRatio(_layoutTab->lockAspectRatio());
- if (!layout) {
- _layoutTab->setLayoutEnabled(false);
- return;
- }
-
- layout->setMargin(QSizeF(_layoutTab->horizontalMargin(),
+ _item->setLayoutMargins(QSizeF(_layoutTab->horizontalMargin(),
_layoutTab->verticalMargin()));
- layout->setSpacing(QSizeF(_layoutTab->horizontalSpacing(),
+ _item->setLayoutSpacing(QSizeF(_layoutTab->horizontalSpacing(),
_layoutTab->verticalSpacing()));
- layout->update();*/
}
void ViewItemDialog::dimensionsChanged() {
More information about the Kst
mailing list