From: Mjolnir Date: Fri, 4 Sep 2015 14:21:47 +0000 (+0200) Subject: PeepHole X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=39ee87319e5782199d8c279b8d3b79db167f6e6e;p=livingdesktop.git PeepHole --- diff --git a/LivingDemos/LargeView.cpp b/LivingDemos/LargeView.cpp new file mode 100644 index 0000000..aeb0bc9 --- /dev/null +++ b/LivingDemos/LargeView.cpp @@ -0,0 +1,34 @@ +#include "LargeView.h" + +#include +#include +#include + +LargeView::LargeView(QWidget *parent) : + QGraphicsView(parent) +{ + setInteractive(true); +} + +void LargeView::resizeEvent(QResizeEvent *event) +{ + fit(); +} + +void LargeView::fit() +{ + //QRectF content = scene().sceneRect(); + //qreal ratio = width() / height(); + fitInView(sceneRect(), Qt::KeepAspectRatioByExpanding); +} + +void LargeView::dragEnterEvent(QDragEnterEvent *event) +{ + event->accept(); + qDebug() << "start drag"; +} + +void LargeView::dragMoveEvent(QDragMoveEvent *event) +{ + qDebug() << "move " << event->pos().x(); +} diff --git a/LivingDemos/LargeView.h b/LivingDemos/LargeView.h new file mode 100644 index 0000000..e7a15e2 --- /dev/null +++ b/LivingDemos/LargeView.h @@ -0,0 +1,25 @@ +#ifndef LARGEVIEW_H +#define LARGEVIEW_H + +#include + +class LargeView : public QGraphicsView +{ + Q_OBJECT + public: + explicit LargeView(QWidget *parent = 0); + + private: + void resizeEvent(QResizeEvent * event); + void fit(); + + void dragEnterEvent(QDragEnterEvent * event); + void dragMoveEvent(QDragMoveEvent * event); + + signals: + + public slots: + +}; + +#endif // LARGEVIEW_H diff --git a/LivingDemos/LivingDemos.pro b/LivingDemos/LivingDemos.pro index 73d9e2f..d63a129 100644 --- a/LivingDemos/LivingDemos.pro +++ b/LivingDemos/LivingDemos.pro @@ -27,13 +27,17 @@ SOURCES += main.cpp\ Options.cpp \ Tidy.cpp \ Force.cpp \ - GestureOutput.cpp + GestureOutput.cpp \ + Peephole.cpp \ + LargeView.cpp HEADERS += MenuPrincipal.h \ Options.h \ Tidy.h \ Force.h \ - GestureOutput.h + GestureOutput.h \ + Peephole.h \ + LargeView.h FORMS += menuprincipal.ui \ options.ui \ diff --git a/LivingDemos/MenuPrincipal.cpp b/LivingDemos/MenuPrincipal.cpp index a2edcd3..4b77dd2 100644 --- a/LivingDemos/MenuPrincipal.cpp +++ b/LivingDemos/MenuPrincipal.cpp @@ -6,6 +6,7 @@ #include #include #include +#include MenuPrincipal::MenuPrincipal(QWidget *parent) : QMainWindow(parent), @@ -23,6 +24,8 @@ MenuPrincipal::MenuPrincipal(QWidget *parent) : connect(ui->tidy, SIGNAL(clicked()), this, SLOT(openTidy())); connect(ui->force, SIGNAL(clicked()), this, SLOT(openForce())); connect(ui->gestureoutput, SIGNAL(clicked()), this, SLOT(openGestureOutput())); + connect(ui->peephole, SIGNAL(clicked()), this, SLOT(openPeephole())); + connectKeyboard(); connectScreen(); @@ -179,3 +182,9 @@ void MenuPrincipal::openGestureOutput() GestureOutput * g= new GestureOutput(this); g->show(); } + +void MenuPrincipal::openPeephole() +{ + Peephole * p= new Peephole(this); + p->show(); +} diff --git a/LivingDemos/MenuPrincipal.h b/LivingDemos/MenuPrincipal.h index ba2bbca..2a00699 100644 --- a/LivingDemos/MenuPrincipal.h +++ b/LivingDemos/MenuPrincipal.h @@ -49,6 +49,7 @@ class MenuPrincipal : public QMainWindow void openTidy(); void openForce(); void openGestureOutput(); + void openPeephole(); private: Ui::MenuPrincipal *ui; diff --git a/LivingDemos/Peephole.cpp b/LivingDemos/Peephole.cpp new file mode 100644 index 0000000..6977d3d --- /dev/null +++ b/LivingDemos/Peephole.cpp @@ -0,0 +1,51 @@ +#include "Peephole.h" + +#include +#include +#include + +const int Peephole::length = 660; + +Peephole::Peephole(QWidget *parent) : + QMainWindow(parent), + screenpos(330), + viewpos(0), + ui(new Ui::Fullscreen) +{ + ui->setupUi(this); + setWindowState(Qt::WindowMaximized); + setAttribute(Qt::WA_DeleteOnClose); + + ui->image->setScene(&_background); + _background.addPixmap(QPixmap("../../images/panorama.jpg")); + ui->image->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + ui->image->setDragMode(QGraphicsView::ScrollHandDrag); + ui->image->setResizeAnchor(QGraphicsView::AnchorViewCenter); + + connect(ui->start, SIGNAL(clicked()), this, SLOT(moveDevices())); + connect(ui->image->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scroll(int))); + + MenuPrincipal * menu = dynamic_cast(parent); + if (!menu->getScreen()) + qDebug() << "Warning: screen not connected"; +} + +Peephole::~Peephole() +{ + delete ui; +} + +void Peephole::scroll(int pos) +{ + qDebug() << "Pos: " << pos; + MenuPrincipal * menu = dynamic_cast(this->parent()); + if (menu->getScreen()) + { + int delta = pos - viewpos; + viewpos = pos; + if (delta < 0) + menu->getScreen()->translation(LivingScreen::LEFT, -delta * length / (_background.width() - ui->image->width())); + else + menu->getScreen()->translation(LivingScreen::RIGHT, delta * length / (_background.width() - ui->image->width())); + } +} diff --git a/LivingDemos/Peephole.h b/LivingDemos/Peephole.h new file mode 100644 index 0000000..6e99adf --- /dev/null +++ b/LivingDemos/Peephole.h @@ -0,0 +1,31 @@ +#ifndef PEEPHOLE_H +#define PEEPHOLE_H + +#include +#include + +#include + +namespace Ui { + class Fullscreen; +} + +class Peephole : public QMainWindow +{ + Q_OBJECT + + public: + explicit Peephole(QWidget *parent = 0); + ~Peephole(); + + public slots: + void scroll(int pos); + + private: + int screenpos, viewpos; + static const int length; + Ui::Fullscreen *ui; + QGraphicsScene _background; +}; + +#endif // PEEPHOLE_H diff --git a/LivingDemos/Tidy.cpp b/LivingDemos/Tidy.cpp index 2685990..3ce9220 100644 --- a/LivingDemos/Tidy.cpp +++ b/LivingDemos/Tidy.cpp @@ -16,8 +16,6 @@ Tidy::Tidy(QWidget *parent) : _background.addPixmap(QPixmap("../../images/desktop.jpg")); ui->image->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui->image->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - //ui->image->ensureVisible(_background.itemsBoundingRect()); - //sceneRect()); connect(ui->start, SIGNAL(clicked()), this, SLOT(moveDevices())); diff --git a/LivingDemos/fullscreen.ui b/LivingDemos/fullscreen.ui index ca23847..1b36056 100644 --- a/LivingDemos/fullscreen.ui +++ b/LivingDemos/fullscreen.ui @@ -34,7 +34,7 @@ 0 - + @@ -63,6 +63,13 @@ + + + LargeView + QGraphicsView +
LargeView.h
+
+
diff --git a/LivingDemos/menuprincipal.ui b/LivingDemos/menuprincipal.ui index ca9aaa0..bb1689f 100644 --- a/LivingDemos/menuprincipal.ui +++ b/LivingDemos/menuprincipal.ui @@ -88,7 +88,7 @@
- + 0 @@ -101,7 +101,7 @@ - Demo 4 + Peephole @@ -179,7 +179,7 @@ tidy force gestureoutput - pushButton_4 + peephole options diff --git a/images/panorama.jpg b/images/panorama.jpg new file mode 100644 index 0000000..7cd6d4f Binary files /dev/null and b/images/panorama.jpg differ