--- /dev/null
+#include "LargeView.h"
+
+#include <QDebug>
+#include <QDragEnterEvent>
+#include <QDragMoveEvent>
+
+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();
+}
--- /dev/null
+#ifndef LARGEVIEW_H
+#define LARGEVIEW_H
+
+#include <QGraphicsView>
+
+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
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 \
#include <Tidy.h>
#include <Force.h>
#include <GestureOutput.h>
+#include <Peephole.h>
MenuPrincipal::MenuPrincipal(QWidget *parent) :
QMainWindow(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();
GestureOutput * g= new GestureOutput(this);
g->show();
}
+
+void MenuPrincipal::openPeephole()
+{
+ Peephole * p= new Peephole(this);
+ p->show();
+}
void openTidy();
void openForce();
void openGestureOutput();
+ void openPeephole();
private:
Ui::MenuPrincipal *ui;
--- /dev/null
+#include "Peephole.h"
+
+#include <QDebug>
+#include <MenuPrincipal.h>
+#include <QScrollBar>
+
+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<MenuPrincipal *>(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<MenuPrincipal *>(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()));
+ }
+}
--- /dev/null
+#ifndef PEEPHOLE_H
+#define PEEPHOLE_H
+
+#include <QMainWindow>
+#include <QGraphicsScene>
+
+#include <ui_fullscreen.h>
+
+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
_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()));
<number>0</number>
</property>
<item>
- <widget class="QGraphicsView" name="image"/>
+ <widget class="LargeView" name="image"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
</layout>
</widget>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>LargeView</class>
+ <extends>QGraphicsView</extends>
+ <header location="global">LargeView.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
</widget>
</item>
<item row="2" column="1">
- <widget class="QPushButton" name="pushButton_4">
+ <widget class="QPushButton" name="peephole">
<property name="minimumSize">
<size>
<width>0</width>
</font>
</property>
<property name="text">
- <string>Demo 4</string>
+ <string>Peephole</string>
</property>
</widget>
</item>
<tabstop>tidy</tabstop>
<tabstop>force</tabstop>
<tabstop>gestureoutput</tabstop>
- <tabstop>pushButton_4</tabstop>
+ <tabstop>peephole</tabstop>
<tabstop>options</tabstop>
</tabstops>
<resources/>