[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Thu Sep 20 23:18:21 CEST 2007
SVN commit 714905 by treat:
* Switch between layout modes in different tabs.
M +6 -1 mainwindow.cpp
M +26 -0 viewgridlayout.cpp
M +45 -0 viewgridlayout.h
M +2 -0 viewitem.cpp
M +2 -2 viewitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #714904:714905
@@ -251,6 +251,7 @@
void MainWindow::currentViewChanged() {
_undoGroup->setActiveStack(_tabWidget->currentView()->undoStack());
+ _layoutModeAct->setChecked(_tabWidget->currentView()->viewMode() == View::Layout);
}
@@ -524,9 +525,13 @@
_viewMenu = menuBar()->addMenu(tr("&View"));
_viewMenu->addAction(_viewManagerAct);
- _viewMenu->addAction(_layoutModeAct);
_layoutMenu = _viewMenu->addMenu(tr("&Layout"));
+
+ _layoutMenu->setIcon(QPixmap(":kst_layoutmode.png"));
+
+ _layoutMenu->addAction(_layoutModeAct);
+ _layoutMenu->addSeparator();
_layoutMenu->addAction(_createLabelAct);
_layoutMenu->addAction(_createBoxAct);
_layoutMenu->addAction(_createEllipseAct);
--- branches/work/kst/portto4/kst/src/libkstapp/viewgridlayout.cpp #714904:714905
@@ -201,6 +201,32 @@
}
}
+
+#if 0
+void LayoutMarginCommand::undo() {
+ Q_ASSERT(_layout);
+ _layout->setMargin(_originalMargin);
}
+
+void LayoutMarginCommand::redo() {
+ Q_ASSERT(_layout);
+ _layout->setMargin(_newMargin);
+}
+
+
+void LayoutSpacingCommand::undo() {
+ Q_ASSERT(_layout);
+ _layout->setSpacing(_originalSpacing);
+}
+
+
+void LayoutSpacingCommand::redo() {
+ Q_ASSERT(_layout);
+ _layout->setSpacing(_newSpacing);
+}
+#endif
+
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/viewgridlayout.h #714904:714905
@@ -86,6 +86,51 @@
QHash<const ViewItem*, LayoutItem> _itemInfos;
};
+//FIXME How far should we go with the command pattern?
+//Should we provide undo support for layout margins?
+//How about for setting the pens/brushes of a viewitem??
+#if 0
+class KST_EXPORT LayoutMarginCommand : public ViewItemCommand
+{
+ public:
+ LayoutMarginCommand(ViewItem *item, const QPointF &originalMargin, const QPointF &newMargin)
+ : ViewItemCommand(item, QObject::tr("Margin"))
+ _originalMargin(originalMargin),
+ _newMargin(newMargin),
+ _layout(item->layout) {}
+
+ virtual ~LayoutMarginCommand() {}
+
+ virtual void undo();
+ virtual void redo();
+
+ private:
+ QSizeF _originalMargin;
+ QSizeF _newMargin;
+ QPointer<ViewGridLayout> _layout;
+};
+
+class KST_EXPORT LayoutSpacingCommand : public ViewItemCommand
+{
+ public:
+ LayoutSpacingCommand(ViewItem *item, const QPointF &originalSpacing, const QPointF &newSpacing)
+ : ViewItemCommand(item, QObject::tr("Spacing"))
+ _originalSpacing(originalSpacing),
+ _newSpacing(newSpacing),
+ _layout(item->layout) {}
+
+ virtual ~LayoutSpacingCommand() {}
+
+ virtual void undo();
+ virtual void redo();
+
+ private:
+ QSizeF _originalSpacing;
+ QSizeF _newSpacing;
+ QPointer<ViewGridLayout> _layout;
+};
+#endif
+
}
#endif
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #714904:714905
@@ -1523,6 +1523,8 @@
}
if (qobject_cast<LayoutBoxItem*>(_item)) {
+ _layout->setMargin(QSizeF());
+ _layout->setSpacing(QSizeF());
QObject::connect(_layout, SIGNAL(enabledChanged(bool)),
_item, SLOT(setEnabled(bool)));
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #714904:714905
@@ -233,7 +233,7 @@
{
public:
LayoutCommand(ViewItem *item)
- : ViewItemCommand(item, QObject::tr("Layout"), false) {}
+ : ViewItemCommand(item, QObject::tr("Create layout"), false) {}
virtual ~LayoutCommand() {}
@@ -249,7 +249,7 @@
{
public:
BreakLayoutCommand(ViewItem *item)
- : ViewItemCommand(item, QObject::tr("Break Layout")) {}
+ : ViewItemCommand(item, QObject::tr("Break layout")) {}
virtual ~BreakLayoutCommand() {}
More information about the Kst
mailing list