111 lines
2.7 KiB
C++
111 lines
2.7 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
#include <QPainter>
|
|
#include "sensor.h"
|
|
#include "hallsensor.h"
|
|
#include "schuifdeur.h"
|
|
#include "draaideur.h"
|
|
#include <stdio.h>
|
|
#include <iostream>
|
|
#include <QLineEdit>
|
|
#include <sleutelslot.h>
|
|
#include <codeslot.h>
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
QMainWindow(parent),
|
|
ui(new Ui::MainWindow){
|
|
ui->setupUi(this);
|
|
s1=new Hallsensor(515,160);
|
|
//sleutelSlot0 = new SleutelSlot("cisco");
|
|
//sleutelSlot1 = new SleutelSlot("cisco");
|
|
deuren.emplace_back(std::shared_ptr<Deur> (new Schuifdeur(503,250,80,s1)));
|
|
deuren[0]->addSlot(new SleutelSlot("cisco"));
|
|
deuren[0]->addSlot(new SleutelSlot("cisco2"));
|
|
deuren.emplace_back(std::shared_ptr<Deur> (new draaideur(248,140,40,false)));
|
|
deuren[1]->addSlot(new CodeSlot(1234));
|
|
deuren[1]->addSlot(new CodeSlot(5678));
|
|
deuren.emplace_back(std::shared_ptr<Deur> (new draaideur(295,290,30,true)));
|
|
deuren[2]->addSlot(new CodeSlot(0000));
|
|
}
|
|
|
|
MainWindow::~MainWindow(){
|
|
delete ui;
|
|
delete s1;
|
|
}
|
|
|
|
void MainWindow::paintEvent(QPaintEvent *event){
|
|
|
|
QPainter painter(this);
|
|
QPen pen;
|
|
QImage image("/home/shaquilles/Downloads/gebouw/Gebouw.png");
|
|
|
|
pen.setColor(Qt::green);
|
|
pen.setWidth(4);
|
|
painter.setPen(pen);
|
|
painter.drawImage(10,10,image);
|
|
|
|
s1->teken(this);
|
|
deuren.at(0)->teken(this);
|
|
deuren.at(1)->teken(this);
|
|
deuren.at(2)->teken(this);
|
|
}
|
|
|
|
void MainWindow::on_schuifdeurSensorKnop_clicked(){
|
|
if(s1->isGeactiveerd())
|
|
s1->deactiveer();
|
|
else
|
|
s1->activeer();
|
|
update();
|
|
}
|
|
|
|
void MainWindow::on_vd_clicked(){
|
|
if(deuren.at(0)->isDeurOpen()){
|
|
deuren[0]->sluit();
|
|
}
|
|
else{
|
|
deuren.at(0)->open();
|
|
s1->deactiveer();
|
|
}
|
|
update();
|
|
}
|
|
|
|
void MainWindow::on_d1_clicked(){
|
|
if(deuren.at(1)->isDeurOpen()){
|
|
deuren.at(1)->sluit();
|
|
}
|
|
else{
|
|
deuren.at(1)->open();
|
|
}
|
|
update();
|
|
}
|
|
|
|
void MainWindow::on_d2_clicked(){
|
|
if(deuren.at(2)->isDeurOpen()){
|
|
deuren.at(2)->sluit();
|
|
}
|
|
else{
|
|
deuren.at(2)->open();
|
|
}
|
|
update();
|
|
}
|
|
|
|
void MainWindow::on_lineEdit_returnPressed(){
|
|
string eenSleutel = ui->lineEdit->text().toStdString();
|
|
Slot* sleutelSlot0 = deuren[0]->geefSleutel(0);
|
|
Slot* sleutelSlot1 = deuren[0]->geefSleutel(1);
|
|
Slot* codeSlot0 = deuren[1]->geefSleutel(0);
|
|
Slot* codeSlot1 = deuren[1]->geefSleutel(1);
|
|
Slot* codeSlot2 = deuren[2]->geefSleutel(0);
|
|
sleutelSlot0->ontgrendel(eenSleutel);
|
|
sleutelSlot1->ontgrendel(eenSleutel);
|
|
codeSlot0->ontgrendel(eenSleutel);
|
|
codeSlot1->ontgrendel(eenSleutel);
|
|
codeSlot2->ontgrendel(eenSleutel);
|
|
|
|
}
|
|
|
|
void MainWindow::on_textBrowser_textChanged(){
|
|
update();
|
|
}
|
|
|