diff options
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/SConscript | 4 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/FreehandLineItem.cpp | 88 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/FreehandLineItem.h | 32 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/GView.cpp | 259 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/GView.h | 49 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/TextDialog.cpp | 47 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/TextDialog.h | 41 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/Window.cpp | 182 | ||||
-rw-r--r-- | Swift/QtUI/Whiteboard/Window.h | 67 |
9 files changed, 769 insertions, 0 deletions
diff --git a/Swift/QtUI/SConscript b/Swift/QtUI/SConscript index 4c53313..d687203 100644 --- a/Swift/QtUI/SConscript +++ b/Swift/QtUI/SConscript @@ -139,6 +139,10 @@ sources = [ "UserSearch/QtUserSearchWindow.cpp", "UserSearch/UserSearchModel.cpp", "UserSearch/UserSearchDelegate.cpp", + "Whiteboard/FreehandLineItem.cpp", + "Whiteboard/GView.cpp", + "Whiteboard/TextDialog.cpp", + "Whiteboard/Window.cpp", "QtSubscriptionRequestWindow.cpp", "QtRosterHeader.cpp", "QtWebView.cpp", diff --git a/Swift/QtUI/Whiteboard/FreehandLineItem.cpp b/Swift/QtUI/Whiteboard/FreehandLineItem.cpp new file mode 100644 index 0000000..3dc42a7 --- /dev/null +++ b/Swift/QtUI/Whiteboard/FreehandLineItem.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include "FreehandLineItem.h" + + +namespace Swift { + FreehandLineItem::FreehandLineItem(QGraphicsItem* parent) : QGraphicsItem(parent) { + } + + QRectF FreehandLineItem::boundingRect() const + { + return boundRect; + } + + void FreehandLineItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) + { + painter->setPen(_pen); + if (points.size() > 0) { + QVector<QPointF>::const_iterator it = points.begin(); + QPointF previous = *it; + ++it; + for (; it != points.end(); ++it) { + painter->drawLine(previous, *it); + previous = *it; + } + } + } + + void FreehandLineItem::setStartPoint(QPointF point) + { + points.clear(); + points.append(point); + QRectF rect(point, point); + boundRect = rect; + update(rect); + } + + void FreehandLineItem::lineTo(QPointF point) + { + qreal x1, x2, y1, y2; + x1 = points.last().x(); + x2 = point.x(); + y1 = points.last().y(); + y2 = point.y(); + if (x1 > x2) { + qreal temp = x1; + x1 = x2; + x2 = temp; + } + if (y1 > y2) { + qreal temp = y1; + y1 = y2; + y2 = temp; + } + QRectF rect(x1-1, y1-1, x2+1-x1, y2+1-y1); + + points.append(point); + + boundRect |= rect; + update(rect); + } + + bool FreehandLineItem::collidesWithPath(const QPainterPath& path, Qt::ItemSelectionMode mode) const + { + QVector<QPointF>::const_iterator it; + QSizeF size(1,1); + for (it = points.begin(); it != points.end(); ++it) { + if (path.intersects(QRectF(*it, size))) { + return true; + } + } + return false; + } + + void FreehandLineItem::setPen(const QPen& pen) + { + _pen = pen; + } + + QPen FreehandLineItem::pen() const + { + return _pen; + } +} diff --git a/Swift/QtUI/Whiteboard/FreehandLineItem.h b/Swift/QtUI/Whiteboard/FreehandLineItem.h new file mode 100644 index 0000000..aa9fdff --- /dev/null +++ b/Swift/QtUI/Whiteboard/FreehandLineItem.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <QGraphicsItem> +#include <QPainter> +#include <iostream> + +using namespace std; + +namespace Swift { + class FreehandLineItem : public QGraphicsItem { + public: + FreehandLineItem(QGraphicsItem* parent = 0); + QRectF boundingRect() const; + void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); + void setStartPoint(QPointF point); + void lineTo(QPointF point); + bool collidesWithPath(const QPainterPath& path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; + void setPen(const QPen& pen); + QPen pen() const; + + private: + QPen _pen; + QVector<QPointF> points; + QRectF boundRect; + }; +} diff --git a/Swift/QtUI/Whiteboard/GView.cpp b/Swift/QtUI/Whiteboard/GView.cpp new file mode 100644 index 0000000..c3782db --- /dev/null +++ b/Swift/QtUI/Whiteboard/GView.cpp @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include "GView.h" +#include "FreehandLineItem.h" + +namespace Swift { + GView::GView(QGraphicsScene* scene, QWidget* parent) : QGraphicsView(scene, parent), brush(QColor(Qt::white)) + { + selectionRect = 0; + zValue = 0; + } + + void GView::setLineWidth(int i) + { + pen.setWidth(i); + } + + void GView::setLineColor(QColor color) + { + pen.setColor(color); + } + + QColor GView::getLineColor() + { + return pen.color(); + } + + void GView::setBrushColor(QColor color) + { + brush.setColor(color); +// brush.setStyle(Qt::SolidPattern); + } + + QColor GView::getBrushColor() + { + return brush.color(); + } + + void GView::setMode(Mode mode) + { + this->mode = mode; + lastItem = 0; + } + + void GView::mouseMoveEvent(QMouseEvent* event) + { + if (!mousePressed) { + return; + } + + if (mode == Line) { + QGraphicsLineItem* item = qgraphicsitem_cast<QGraphicsLineItem*>(lastItem); + if(item != 0) { + QLineF line = item->line(); + line.setP1(this->mapToScene(event->pos())); + item->setLine(line); + } + } + else if (mode == Rect) { + QGraphicsRectItem* item = qgraphicsitem_cast<QGraphicsRectItem*>(lastItem); + if (item != 0) { + QPointF beginPoint = item->data(0).toPointF(); + QPointF newPoint = this->mapToScene(event->pos()); + QRectF rect = item->rect(); + if (beginPoint.x() <= newPoint.x() && beginPoint.y() <= newPoint.y()) { + rect.setTopLeft(beginPoint); + rect.setBottomRight(newPoint); + } + else if (beginPoint.x() > newPoint.x() && beginPoint.y() <= newPoint.y()) { + rect.setTopRight(beginPoint); + rect.setBottomLeft(newPoint); + } + else if (beginPoint.x() <= newPoint.x() && beginPoint.y() > newPoint.y()) { + rect.setBottomLeft(beginPoint); + rect.setTopRight(newPoint); + } + else if (beginPoint.x() > newPoint.x() && beginPoint.y() > newPoint.y()) { + rect.setBottomRight(beginPoint); + rect.setTopLeft(newPoint); + } + item->setRect(rect); + } + } + else if (mode == Circle) { + QGraphicsPathItem* item = qgraphicsitem_cast<QGraphicsPathItem*>(lastItem); + QPainterPath path; + QPointF beginPoint = item->data(0).toPointF(); + QPointF newPoint = this->mapToScene(event->pos()); + path.moveTo((newPoint.x()+beginPoint.x())/2, beginPoint.y()); + path.cubicTo(beginPoint.x(), beginPoint.y(), beginPoint.x(), newPoint.y(), (newPoint.x()+beginPoint.x())/2, newPoint.y()); + path.cubicTo(newPoint.x(), newPoint.y(), newPoint.x(), beginPoint.y(), (newPoint.x()+beginPoint.x())/2, beginPoint.y()); + item->setPath(path); + } + else if (mode == HandLine) { + FreehandLineItem* item = qgraphicsitem_cast<FreehandLineItem*>(lastItem); + if (item != 0) { + QPointF newPoint = this->mapToScene(event->pos()); + item->lineTo(newPoint); + } + } + else if (mode == FilledHandLine) { + QGraphicsPathItem* item = qgraphicsitem_cast<QGraphicsPathItem*>(lastItem); + QPainterPath path; + path = item->path(); + if (path.isEmpty()) + path.moveTo(item->data(0).toPointF()); + QPointF newPoint = this->mapToScene(event->pos()); + path.lineTo(newPoint); + item->setPath(path); + } + else if (mode == Polygon) { + QGraphicsPolygonItem* item = qgraphicsitem_cast<QGraphicsPolygonItem*>(lastItem); + QPointF newPoint = this->mapToScene(event->pos()); + QPolygonF polygon = item->polygon(); + polygon.erase(polygon.end()-1); + polygon.append(newPoint); + item->setPolygon(polygon); + } + else if (mode == Select) { + QGraphicsItem* item = selectionRect->data(1).value<QGraphicsItem*>(); + if (item != 0) { + QPainterPath path; + QPointF beginPoint = selectionRect->data(0).toPointF(); + QPointF newPoint = this->mapToScene(event->pos()); + item->setPos(beginPoint + newPoint); + selectionRect->setPos(beginPoint + newPoint); + } + } + } + + void GView::mousePressEvent(QMouseEvent *event) + { + mousePressed = true; + if (selectionRect != 0) { + scene()->removeItem(selectionRect); + delete selectionRect; + selectionRect = 0; + } + if (mode == Line) { + QPointF point = this->mapToScene(event->pos()); + QGraphicsItem* item = scene()->addLine(point.x(), point.y(), point.x(), point.y(), pen); + item->setZValue(zValue++); + lastItem = item; + + } + else if (mode == Rect) { + QPointF point = this->mapToScene(event->pos()); + QGraphicsRectItem* item = scene()->addRect(point.x(), point.y(), 0, 0, pen, brush); + item->setZValue(zValue++); + item->setData(0, point); + lastItem = item; + } + else if (mode == Rubber) { + QPointF point = this->mapToScene(event->pos()); + int w = pen.width(); + QRectF rect(point.x()-w, point.y()-w, w*2, w*2); + QList<QGraphicsItem*> list = scene()->items(rect); + if (!list.isEmpty()) + { + QGraphicsItem* item = scene()->items(rect).first(); + scene()->removeItem(item); + delete item; + } + } + else if (mode == Circle) { + QPointF point = this->mapToScene(event->pos()); + QGraphicsPathItem* item = scene()->addPath(QPainterPath(), pen, brush); + item->setZValue(zValue++); + item->setData(0, point); + lastItem = item; + } + else if (mode == HandLine) { + QPointF point = this->mapToScene(event->pos()); + FreehandLineItem* item = new FreehandLineItem; + item->setPen(pen); + item->setStartPoint(point); + item->setZValue(zValue++); + scene()->addItem(item); + lastItem = item; + } + else if (mode == FilledHandLine) { + QPointF point = this->mapToScene(event->pos()); + QPainterPath path; + QGraphicsPathItem* item = scene()->addPath(path, pen, brush); + item->setZValue(zValue++); + item->setData(0, point); + lastItem = item; + } + else if (mode == Text) { + QPointF point = this->mapToScene(event->pos()); + QGraphicsTextItem* item = scene()->addText(""); + item->setZValue(zValue++); + item->setDefaultTextColor(pen.color()); + textDialog = new TextDialog(item, this); + textDialog->setAttribute(Qt::WA_DeleteOnClose); + textDialog->show(); + item->setPos(point); + } + else if (mode == Polygon) { + QPointF point = this->mapToScene(event->pos()); + QGraphicsPolygonItem* item = dynamic_cast<QGraphicsPolygonItem*>(lastItem); + if (item == 0) { + QPolygonF polygon; + polygon.append(point); + polygon.append(point); + item = scene()->addPolygon(polygon, pen, brush); + item->setZValue(zValue++); + lastItem = item; + } + else { + QPolygonF polygon; + polygon = item->polygon(); + polygon.append(point); + item->setPolygon(polygon); + } + } + else if (mode == Select) { + QPointF point = this->mapToScene(event->pos()); + int w = pen.width(); + QRectF rect(point.x()-w, point.y()-w, w*2, w*2); + QList<QGraphicsItem*> list = scene()->items(rect); + if (!list.isEmpty()) { + QPen pen; + pen.setColor(QColor(Qt::gray)); + pen.setStyle(Qt::DashLine); + QGraphicsItem *item = scene()->items(rect).first(); + selectionRect = scene()->addRect(item->boundingRect(), pen); + selectionRect->setZValue(1000000); + selectionRect->setData(0, item->pos()-point); + selectionRect->setPos(item->pos()); + QVariant var(QVariant::UserType); + var.setValue(item); + selectionRect->setData(1, var); + } + } + } + + void GView::mouseReleaseEvent(QMouseEvent *event) + { + mousePressed = false; + } + + + void GView::moveUpSelectedItem() + { + QGraphicsItem* item = selectionRect->data(1).value<QGraphicsItem*>(); + item->setZValue(item->zValue()+1); + } + + void GView::moveDownSelectedItem() + { + QGraphicsItem* item = selectionRect->data(1).value<QGraphicsItem*>(); + item->setZValue(item->zValue()-1); + } +} diff --git a/Swift/QtUI/Whiteboard/GView.h b/Swift/QtUI/Whiteboard/GView.h new file mode 100644 index 0000000..dd620e8 --- /dev/null +++ b/Swift/QtUI/Whiteboard/GView.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <QGraphicsView> +#include <QGraphicsLineItem> +#include <QMouseEvent> +#include <QPen> +#include <iostream> + +#include "TextDialog.h" + +using namespace std; + +namespace Swift { + class GView : public QGraphicsView { + Q_OBJECT; + public: + enum Mode { Rubber, Line, Rect, Circle, HandLine, FilledHandLine, Text, Polygon, Select }; + GView(QGraphicsScene* scene, QWidget* parent = 0); + void setLineWidth(int i); + void setLineColor(QColor color); + QColor getLineColor(); + void setBrushColor(QColor color); + QColor getBrushColor(); + void setMode(Mode mode); + void mouseMoveEvent(QMouseEvent* event); + void mousePressEvent(QMouseEvent* event); + void mouseReleaseEvent(QMouseEvent* event); + + public slots: + void moveUpSelectedItem(); + void moveDownSelectedItem(); + + private: + int zValue; + bool mousePressed; + QPen pen; + QBrush brush; + Mode mode; + QGraphicsItem* lastItem; + QGraphicsRectItem* selectionRect; + TextDialog* textDialog; + }; +} diff --git a/Swift/QtUI/Whiteboard/TextDialog.cpp b/Swift/QtUI/Whiteboard/TextDialog.cpp new file mode 100644 index 0000000..caa78ce --- /dev/null +++ b/Swift/QtUI/Whiteboard/TextDialog.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include "TextDialog.h" + +namespace Swift { + TextDialog::TextDialog(QGraphicsTextItem* item, QWidget* parent) : QDialog(parent) + { + this->item = item; + + layout = new QVBoxLayout(this); + hLayout = new QHBoxLayout; + + editor = new QLineEdit(this); + connect(editor, SIGNAL(textChanged(const QString&)), this, SLOT(changeItemText(const QString&))); + + fontSizeBox = new QSpinBox(this); + fontSizeBox->setMinimum(1); + connect(fontSizeBox, SIGNAL(valueChanged(int)), this, SLOT(changeItemFontSize(int))); + fontSizeBox->setValue(13); + + + buttonBox = new QDialogButtonBox(this); + buttonBox->setStandardButtons(QDialogButtonBox::Ok); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + + hLayout->addWidget(editor); + hLayout->addWidget(fontSizeBox); + layout->addLayout(hLayout); + layout->addWidget(buttonBox); + } + + void TextDialog::changeItemText(const QString &text) + { + item->setPlainText(text); + } + + void TextDialog::changeItemFontSize(int i) + { + QFont font = item->font(); + font.setPointSize(i); + item->setFont(font); + } +} diff --git a/Swift/QtUI/Whiteboard/TextDialog.h b/Swift/QtUI/Whiteboard/TextDialog.h new file mode 100644 index 0000000..8b31d5b --- /dev/null +++ b/Swift/QtUI/Whiteboard/TextDialog.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <QDialog> +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QDialogButtonBox> +#include <QLineEdit> +#include <QGraphicsTextItem> +#include <QSpinBox> + +#include <iostream> + +using namespace std; + +namespace Swift { + class TextDialog : public QDialog + { + Q_OBJECT; + public: + TextDialog(QGraphicsTextItem* item, QWidget* parent = 0); + + private: + QGraphicsTextItem* item; + QLineEdit* editor; + QDialogButtonBox* buttonBox; + QVBoxLayout* layout; + QHBoxLayout* hLayout; + QSpinBox* fontSizeBox; + + private slots: + void changeItemText(const QString &text); + void changeItemFontSize(int i); + }; +} + diff --git a/Swift/QtUI/Whiteboard/Window.cpp b/Swift/QtUI/Whiteboard/Window.cpp new file mode 100644 index 0000000..4423d17 --- /dev/null +++ b/Swift/QtUI/Whiteboard/Window.cpp @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#include "Window.h" + +#include<iostream> + +using namespace std; + +namespace Swift { + Window::Window() : QWidget() { + layout = new QVBoxLayout(this); + hLayout = new QHBoxLayout; + sidebarLayout = new QVBoxLayout; + toolboxLayout = new QGridLayout; + + scene = new QGraphicsScene(this); + scene->setSceneRect(0, 0, 400, 400); +// scene->setItemIndexMethod(QGraphicsScene::NoIndex); + + graphicsView = new GView(scene, this); + graphicsView->setMode(GView::Line); + + widthBox = new QSpinBox(this); + connect(widthBox, SIGNAL(valueChanged(int)), this, SLOT(changeLineWidth(int))); + widthBox->setValue(1); + + moveUpButton = new QPushButton("Move Up", this); + connect(moveUpButton, SIGNAL(clicked()), graphicsView, SLOT(moveUpSelectedItem())); + + moveDownButton = new QPushButton("Move Down", this); + connect(moveDownButton, SIGNAL(clicked()), graphicsView, SLOT(moveDownSelectedItem())); + + colorDialogButton = new QPushButton("Color", this); + connect(colorDialogButton, SIGNAL(clicked()), this, SLOT(showColorDialog())); + + brushColorDialogButton = new QPushButton("Brush", this); + connect(brushColorDialogButton, SIGNAL(clicked()), this, SLOT(showBrushColorDialog())); + + rubberButton = new QToolButton(this); + rubberButton->setCheckable(true); + rubberButton->setAutoExclusive(true); + connect(rubberButton, SIGNAL(clicked()), this, SLOT(setRubberMode())); + + lineButton = new QToolButton(this); + lineButton->setIcon(QIcon(":/icons/line.png")); + lineButton->setCheckable(true); + lineButton->setAutoExclusive(true); + lineButton->setChecked(true); + connect(lineButton, SIGNAL(clicked()), this, SLOT(setLineMode())); + + rectButton = new QToolButton(this); + rectButton->setIcon(QIcon(":/icons/rect.png")); + rectButton->setCheckable(true); + rectButton->setAutoExclusive(true); + connect(rectButton, SIGNAL(clicked()), this, SLOT(setRectMode())); + + circleButton = new QToolButton(this); + circleButton->setIcon(QIcon(":/icons/circle.png")); + circleButton->setCheckable(true); + circleButton->setAutoExclusive(true); + connect(circleButton, SIGNAL(clicked()), this, SLOT(setCircleMode())); + + handLineButton = new QToolButton(this); + handLineButton->setIcon(QIcon(":/icons/handline.png")); + handLineButton->setCheckable(true); + handLineButton->setAutoExclusive(true); + connect(handLineButton, SIGNAL(clicked()), this, SLOT(setHandLineMode())); + + filledHandLineButton = new QToolButton(this); + filledHandLineButton->setIcon(QIcon(":/icons/filledHandline.png")); + filledHandLineButton->setCheckable(true); + filledHandLineButton->setAutoExclusive(true); + connect(filledHandLineButton, SIGNAL(clicked()), this, SLOT(setFilledHandLineMode())); + + textButton = new QToolButton(this); + textButton->setIcon(QIcon(":/icons/text.png")); + textButton->setCheckable(true); + textButton->setAutoExclusive(true); + connect(textButton, SIGNAL(clicked()), this, SLOT(setTextMode())); + + polygonButton = new QToolButton(this); + polygonButton->setIcon(QIcon(":/icons/polygon.png")); + polygonButton->setCheckable(true); + polygonButton->setAutoExclusive(true); + connect(polygonButton, SIGNAL(clicked()), this, SLOT(setPolygonMode())); + + selectButton = new QToolButton(this); + selectButton->setIcon(QIcon(":/icons/cursor.png")); + selectButton->setCheckable(true); + selectButton->setAutoExclusive(true); + connect(selectButton, SIGNAL(clicked()), this, SLOT(setSelectMode())); + + toolboxLayout->addWidget(rubberButton, 0, 0); + toolboxLayout->addWidget(lineButton, 0, 1); + toolboxLayout->addWidget(rectButton, 0, 2); + toolboxLayout->addWidget(circleButton, 1, 0); + toolboxLayout->addWidget(handLineButton, 1, 1); + toolboxLayout->addWidget(filledHandLineButton, 1, 2); + toolboxLayout->addWidget(textButton, 2, 0); + toolboxLayout->addWidget(polygonButton, 2, 1); + toolboxLayout->addWidget(selectButton, 2, 2); + + sidebarLayout->addLayout(toolboxLayout); + sidebarLayout->addWidget(moveUpButton); + sidebarLayout->addWidget(moveDownButton); + sidebarLayout->addWidget(widthBox); + sidebarLayout->addWidget(colorDialogButton); + sidebarLayout->addWidget(brushColorDialogButton); + hLayout->addWidget(graphicsView); + hLayout->addLayout(sidebarLayout); + layout->addLayout(hLayout); + this->setLayout(layout); + } + + void Window::changeLineWidth(int i) + { + graphicsView->setLineWidth(i); + } + + void Window::showColorDialog() + { + QColor color = QColorDialog::getColor(graphicsView->getLineColor(), 0, "Select pen color", QColorDialog::ShowAlphaChannel); + if(color.isValid()) + graphicsView->setLineColor(color); + } + + void Window::showBrushColorDialog() + { + QColor color = QColorDialog::getColor(graphicsView->getBrushColor(), 0, "Select brush color", QColorDialog::ShowAlphaChannel); + if(color.isValid()) + graphicsView->setBrushColor(color); + } + + void Window::setRubberMode() + { + graphicsView->setMode(GView::Rubber); + } + + void Window::setLineMode() + { + graphicsView->setMode(GView::Line); + } + + void Window::setRectMode() + { + graphicsView->setMode(GView::Rect); + } + + void Window::setCircleMode() + { + graphicsView->setMode(GView::Circle); + } + + void Window::setHandLineMode() + { + graphicsView->setMode(GView::HandLine); + } + + void Window::setFilledHandLineMode() + { + graphicsView->setMode(GView::FilledHandLine); + } + + void Window::setTextMode() + { + graphicsView->setMode(GView::Text); + } + + void Window::setPolygonMode() + { + graphicsView->setMode(GView::Polygon); + } + + void Window::setSelectMode() + { + graphicsView->setMode(GView::Select); + } +} diff --git a/Swift/QtUI/Whiteboard/Window.h b/Swift/QtUI/Whiteboard/Window.h new file mode 100644 index 0000000..4423f7c --- /dev/null +++ b/Swift/QtUI/Whiteboard/Window.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012 Mateusz Piękos + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +#pragma once + +#include <QWidget> +#include <QGraphicsView> +#include <QGraphicsScene> +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QGridLayout> +#include <QPainter> +#include <QPushButton> +#include <QSpinBox> +#include <QColorDialog> +#include <QToolButton> + +#include "GView.h" + +namespace Swift { + class Window : public QWidget + { + Q_OBJECT; + public: + Window(); + + private slots: + void changeLineWidth(int i); + void showColorDialog(); + void showBrushColorDialog(); + void setRubberMode(); + void setLineMode(); + void setRectMode(); + void setCircleMode(); + void setHandLineMode(); + void setFilledHandLineMode(); + void setTextMode(); + void setPolygonMode(); + void setSelectMode(); + + private: + QGraphicsScene* scene; + GView* graphicsView; + QVBoxLayout* layout; + QVBoxLayout* sidebarLayout; + QHBoxLayout* hLayout; + QGridLayout* toolboxLayout; + QWidget* widget; + QPushButton* moveUpButton; + QPushButton* moveDownButton; + QPushButton* colorDialogButton; + QPushButton* brushColorDialogButton; + QSpinBox* widthBox; + QToolButton* rubberButton; + QToolButton* lineButton; + QToolButton* rectButton; + QToolButton* circleButton; + QToolButton* handLineButton; + QToolButton* filledHandLineButton; + QToolButton* textButton; + QToolButton* polygonButton; + QToolButton* selectButton; + }; +} |