#include <QApplication>
#include <QFile>
#include <QFileDialog>
+#include <QColorDialog>
#include <QLabel>
#include <QMenuBar>
#include <QStatusBar>
createActions();
createMenus();
+ lineColor = Qt::blue;
createToolBars();
board = new Shareboard(this);
QObject::connect(connMan, SIGNAL(error(QString)), this, SLOT(showError(QString)));
QObject::connect(board, SIGNAL(actionHappened(Action*)), this, SLOT(marshallAction(Action*)));
+ QObject::connect(colorAction, SIGNAL(triggered()), this, SLOT(chooseColor()));
+
statusBar()->showMessage("Ready");
}
}
+void MainWindow::chooseColor() {
+ lineColor = QColorDialog::getColor(lineColor, this, "Choose drawing color");
+ // update pixmap
+ QPixmap pixmap(16, 16);
+ pixmap.fill(lineColor);
+ colorAction->setIcon(QIcon(pixmap));
+}
+
void MainWindow::load() {
QString fileName = QFileDialog::getOpenFileName(this, "Load saved board:", ".", "Shareboards (*.board)");
if(fileName.isEmpty()) {
case Action::DrawLine: // set the action's thickness, color
{
DrawLineAction* a = static_cast<DrawLineAction*>(action);
- a->color = Qt::blue;
- a->width = 3;
+ a->color = lineColor;
+ a->width = spinboxWidget->value();
}
break;
default: break;
QAction* clearAction = new QAction(QIcon("icons/clear.png"), "Clear", this);
// Style
- QSpinBox* spinboxWidget = new QSpinBox(this);
+ spinboxWidget = new QSpinBox(this);
spinboxWidget->setMinimum(4);
spinboxWidget->setMaximum(40);
QPixmap pixmap(16, 16);
- pixmap.fill(QColor(0, 0, 255));
- QAction* colorAction = new QAction(QIcon(pixmap), "Select Color", this);
+ pixmap.fill(lineColor);
+ colorAction = new QAction(QIcon(pixmap), "Select Color", this);
// Create the history UI elements.
QAction* restartAction = new QAction(QIcon("icons/rewind.png"), "Replay History", this);
#define __MAINWINDOW_H__
#include <QMainWindow>
+#include <QColor>
class QMenu;
class QAction;
class ConnectionManager;
class Shareboard;
class Action;
+class QSpinBox;
class MainWindow : public QMainWindow {
Q_OBJECT
void switchToBoard();
void switchToConnect();
void showError(QString error);
+ void chooseColor();
void marshallAction(Action* action);
private:
void createActions();
QAction* loadPastAction;
QAction* saveAction;
QAction* quitAction;
+ QAction* colorAction;
+ QSpinBox* spinboxWidget;
ConnectionManager* connMan;
// HistoryManager* historyManager;
Shareboard* board;
ConnectWidget* prompt;
+ QColor lineColor;
};
#endif // __MAINWINDOW_H__
userID = -1;
viewIndex = 0;
viewImage = QImage(1024,768,QImage::Format_ARGB32_Premultiplied);
- viewImage.fill(Qt::white);
+ viewImage.fill(QColor(Qt::white).rgb());
QObject::connect(prompt, SIGNAL(connectToServer(QString, QString)), this, SIGNAL(connectToServer(QString, QString)));
QObject::connect(canvas, SIGNAL(mouseMovedTo(QPointF)), this, SLOT(handleMouseMoved(QPointF)));
int i = 0;
if(index < viewIndex) {
viewImage = QImage(1024,768,QImage::Format_ARGB32_Premultiplied);
- viewImage.fill(Qt::white);
+ viewImage.fill(QColor(Qt::white).rgb());
viewCursors.clear();
viewUsers.clear();
} else {
p.end();
canvas->update();
}
-/*
-void Shareboard::jumpToTime(QDateTime time) {
- int i = 0;
- if(time < viewTime) {
- // Start from a blank pixmap, trace through all changes up until time
- viewImage = QImage(1024,768,QImage::Format_ARGB32_Premultiplied);
- viewImage.fill(Qt::white);
- viewCursors.clear();
- } else {
- while(i < history.size() && history[i]->timestamp <= viewTime)
- i++;
- }
- QPainter p;
- p.begin(&viewImage);
- // Now, i matches either the beginning of time or the entry for the currently-rendered pixmap,
- // whichever is more useful
- // Now, apply all actions from i until time
- while(i < history.size() && history[i]->timestamp <= time) {
- }
- qDebug() << "i is at" << i << "of" << history.size();
- p.end();
- qDebug() << "cursors:" << viewCursors;
-}
-*/
-
-/*
-QPixmap renderAtTime(QDateTime time) {
- QPixmap pixmap;
- return pixmap;
-}
-
-QPixmap renderOneChange() {
-
-}
-*/
// Now paint the set of mouse cursors on top of that
QMap<int, QPointF>::const_iterator i;
for (i = board->viewCursors.constBegin(); i!=board->viewCursors.constEnd(); ++i) {
- p.setPen(QPen(QColor(255,0,0,50)));
+ QPen pen(QColor(255,0,0,50));
+ pen.setCapStyle(Qt::RoundCap);
+ p.setPen(pen);
p.setBrush(QBrush(QColor(255,0,0,50)));
p.drawEllipse(i.value(),4,4);
p.setPen(Qt::black);