]> git.zarvox.org Git - shareboard.git/commitdiff
Make the slider change the present view of where we are in time.
authorDrew Fisher <drew.m.fisher@gmail.com>
Fri, 8 Oct 2010 15:39:04 +0000 (08:39 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Fri, 8 Oct 2010 15:39:04 +0000 (08:39 -0700)
mainwindow.cpp
mainwindow.h
shareboard.cpp
shareboard.h

index fb8669ebafc43a5074a11a82ce268abfe2650776..5caf77a2ab448bff665ceafecde379e0d38cff5f 100644 (file)
@@ -39,6 +39,11 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) {
        QObject::connect(colorAction, SIGNAL(triggered()), this, SLOT(chooseColor()));
        QObject::connect(clearAction, SIGNAL(triggered()), this, SLOT(clearBoard()));
 
+       QObject::connect(board, SIGNAL(rangeChanged(int)), this, SLOT(updateSliderRange(int)));
+       QObject::connect(board, SIGNAL(indexChanged(int)), sliderWidget, SLOT(setValue(int)));
+       QObject::connect(sliderWidget, SIGNAL(valueChanged(int)), board, SLOT(jumpToIndex(int)));
+
+
        statusBar()->showMessage("Ready");
 }
 
@@ -46,6 +51,10 @@ MainWindow::~MainWindow() {
 
 }
 
+void MainWindow::updateSliderRange(int newmax) {
+       sliderWidget->setRange(0, newmax);
+}
+
 void MainWindow::chooseColor() {
        lineColor = QColorDialog::getColor(lineColor, this, "Choose drawing color");
        // update pixmap
@@ -166,7 +175,7 @@ void MainWindow::createToolBars() {
        // Create the history UI elements.
        QAction* restartAction = new QAction(QIcon("icons/rewind.png"), "Replay History", this);
        QAction* playAction = new QAction(QIcon("icons/play.png"), "Play", this);
-       QSlider* sliderWidget = new QSlider(Qt::Horizontal, this);
+       sliderWidget = new QSlider(Qt::Horizontal, this);
 
        toolBar = addToolBar("Test");
        toolBar->setMovable(false);
index 9437980687fa108a964dbc40d6f949f3436dc794..cb82b6a2561ad080745e2d50215e5d0637092b3f 100644 (file)
@@ -11,6 +11,7 @@ class ConnectionManager;
 class Shareboard;
 class Action;
 class QSpinBox;
+class QSlider;
 
 class MainWindow : public QMainWindow {
        Q_OBJECT
@@ -28,6 +29,7 @@ public slots:
        void chooseColor();
        void clearBoard();
        void marshallAction(Action* action);
+       void updateSliderRange(int newmax);
 private:
        void createActions();
        void createMenus();
@@ -41,6 +43,7 @@ private:
        QAction* colorAction;
        QAction* clearAction;
        QSpinBox* spinboxWidget;
+       QSlider* sliderWidget;
        ConnectionManager* connMan;
 //     HistoryManager* historyManager;
        Shareboard* board;
index 9240ea3ca6d58d8de2151ff52868d60fc2736c4d..5ecc3243d0479fe8032a4bdf2f2bbe217a5fef37 100644 (file)
@@ -69,6 +69,7 @@ void Shareboard::postAction(Action* action) {
                localHistory.removeFirst();
        }
        history.append(action);
+       emit rangeChanged(history.size());
        jumpToIndex(history.size()); // Jump to the most recent state
 }
 
@@ -153,4 +154,5 @@ void Shareboard::jumpToIndex(int index) {
        }
        p.end();
        canvas->update();
+       emit indexChanged(viewIndex);
 }
index 67db295e94c4bb29c9a1bc69b33e2c5cd38e5cc2..28ab2589d26112c907f84b66069555c3059cba4e 100644 (file)
@@ -32,6 +32,8 @@ class Shareboard : public QWidget {
                //void jumpToTime(QDateTime time);
 
        signals:
+               void rangeChanged(int max);
+               void indexChanged(int index);
                void connectToServer(QString, QString);
                void actionHappened(Action* action);