#include <QDebug>
#include <MenuPrincipal.h>
#include <QScrollBar>
-
-const int Peephole::length = 660;
+#include <QThread>
Peephole::Peephole(QWidget *parent) :
QMainWindow(parent),
setAttribute(Qt::WA_DeleteOnClose);
ui->image->setScene(&_background);
- _background.addPixmap(QPixmap("../../images/panorama.jpg"));
+ QPixmap back("../../images/panorama.jpg");
+ _background.addPixmap(back);
+ bgwidth = back.width();
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";
+ else
+ rackwidth = menu->getScreen()->getWidth();
}
Peephole::~Peephole()
MenuPrincipal * menu = dynamic_cast<MenuPrincipal *>(this->parent());
if (menu->getScreen())
{
- int delta = pos - viewpos;
+ unsigned int min = ui->image->horizontalScrollBar()->minimum();
+ unsigned int range = ui->image->horizontalScrollBar()->maximum() - min;
+ if (range == 0)
+ return;
+ unsigned int dest = rackwidth * pos / range - min;
+ qDebug() << "Move to" << dest;
+ menu->getScreen()->moveto(dest);//(bgwidth - ui->image->width()));
+ QThread::msleep(20);
+/* int delta = pos - viewpos;
viewpos = pos;
if (delta < 0)
- menu->getScreen()->translation(LivingScreen::LEFT, -delta * length / (_background.width() - ui->image->width()));
+ menu->getScreen()->translation(LivingScreen::LEFT, -delta * rackwidth / (bgwidth - ui->image->width()));
else
- menu->getScreen()->translation(LivingScreen::RIGHT, delta * length / (_background.width() - ui->image->width()));
+ menu->getScreen()->translation(LivingScreen::RIGHT, delta * rackwidth / (bgwidth - ui->image->width()));*/
}
}