diff options
author | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-01 17:13:40 (GMT) |
---|---|---|
committer | Mateusz Piekos <mateuszpiekos@gmail.com> | 2012-06-01 17:13:40 (GMT) |
commit | e8ab1af885ff61715ab0350c3cb22ed6988a082a (patch) | |
tree | abfd1f18bf6bda8865c1269c1ecb4a1b4ff802d0 /Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp | |
parent | 4f9ad66f222d4bf1cb740a9e1b4b4496cfbc0910 (diff) | |
download | swift-contrib-e8ab1af885ff61715ab0350c3cb22ed6988a082a.zip swift-contrib-e8ab1af885ff61715ab0350c3cb22ed6988a082a.tar.bz2 |
Added simple whiteboard payload and it's parser and serializer
Diffstat (limited to 'Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp')
-rw-r--r-- | Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.cpp new file mode 100644 index 0000000..4423d17 --- /dev/null +++ b/Swift/QtUI/Whiteboard/QtWhiteboardWindow.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); + } +} |