Commit 9706b58b authored by Alexander A. Maly's avatar Alexander A. Maly

Astyling Vodoley

parent a850ff9a
Pipeline #2532 failed with stages
in 2 minutes and 12 seconds
......@@ -7,6 +7,7 @@ kumir2_use_qt(Core Gui)
set(SOURCES
vodoleymodule.cpp
vodoley.cpp
vial.cpp
pult.cpp
dialog.cpp
)
......@@ -14,6 +15,7 @@ set(SOURCES
set(MOC_HEADERS
vodoleymodule.h
vodoley.h
vial.h
pult.h
dialog.h
)
......
//
// C++ Implementation: VodoleyDialog
//
// Description:
// Description:
//
//
// Author: Denis Khachko <mordol@mail.ru>, (C) 2008
......@@ -9,31 +9,52 @@
// Copyright: See COPYING file that comes with this distribution
//
//
#include "dialog.h"
#include <QDebug>
#include <QAbstractButton>
Dialog::Dialog(QWidget *parent, Qt::WindowFlags fl):
QDialog(parent, fl),
Ui::Dialog()
{
setupUi(this);
translateButtons();
setMax();
connect(BaseA, SIGNAL(valueChanged(int)), this, SLOT(setMax()));
connect(BaseB, SIGNAL(valueChanged(int)), this, SLOT(setMax()));
connect(BaseC, SIGNAL(valueChanged(int)), this, SLOT(setMax()));
}
Dialog::Dialog(QWidget* parent, Qt::WindowFlags fl ): QDialog ( parent, fl ), Ui::Dialog()
{
setupUi(this);
connect(BaseA,SIGNAL(valueChanged ( int )),this,SLOT(setMax()));
connect(BaseB,SIGNAL(valueChanged ( int )),this,SLOT(setMax()));
connect(BaseC,SIGNAL(valueChanged ( int )),this,SLOT(setMax()));
translateButtons();
setMax();
};
void Dialog::setMax()
{
{
ValueA->setMaximum(BaseA->value());
ValueB->setMaximum(BaseB->value());
ValueC->setMaximum(BaseC->value());
ValueB->setMaximum(BaseB->value());
ValueC->setMaximum(BaseC->value());
int max = 0;
if (BaseA->value() > max) {
max = BaseA->value();
}
if (BaseB->value() > max) {
max = BaseB->value();
}
if (BaseC->value() > max) {
max = BaseC->value();
}
int max=BaseA->value();
if(BaseB->value()>max)max=BaseB->value();
if(BaseC->value()>max)max=BaseC->value();
NeedA->setMaximum(max);
//NeedB->setMaximum(BaseB->value());
//NeedC->setMaximum(BaseC->value());
};
}
void Dialog::translateButtons()
{
QList<QAbstractButton *>btns = buttonBox->buttons();
for (int i = 0; i < btns.count(); i++) {
if (buttonBox->buttonRole(btns[i]) == QDialogButtonBox::RejectRole) {
btns[i]->setText(trUtf8("Отмена"));
}
}
}
......@@ -13,68 +13,78 @@
//** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//**
//****************************************************************************/
#ifndef NDIALOG_H
#define NDIALOG_H
#include "ui_dialog.h"
#include <QtCore>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
class Dialog : public QDialog, Ui::Dialog
{
Q_OBJECT
public:
Dialog ( QWidget* parent = 0, Qt::WindowFlags fl = 0 );
~Dialog(){};
int ASize(){return BaseA->value();};
int BSize(){return BaseB->value();};
int CSize(){return BaseC->value();};
int AFill(){return ValueA->value();};
int BFill(){return ValueB->value();};
int CFill(){return ValueC->value();};
int ANeed(){return NeedA->value();};
// int BNeed(){return NeedB->value();};
// int CNeed(){return NeedC->value();};
void setSizes(int A,int B,int C)
{
BaseA->setValue(A);
BaseB->setValue(B);
BaseC->setValue(C);
};
void setFill(int A,int B,int C)
{
qDebug()<<A<<B<<C;
ValueA->setValue(A);
ValueB->setValue(B);
ValueC->setValue(C);
};
void setNeed(int A)
{
NeedA->setValue(A);
//NeedB->setValue(B);
//NeedC->setValue(C);
};
void setMaximum()
{
};
void translateButtons()
{
QList<QAbstractButton *>btns = buttonBox->buttons();
for(int i=0;i<btns.count();i++)
{
if(buttonBox->buttonRole(btns[i])==QDialogButtonBox::RejectRole)btns[i]->setText(trUtf8("Отмена"));
}
}
public:
Dialog(QWidget *parent = 0, Qt::WindowFlags fl = 0);
~Dialog() {};
int ASize() const
{
return BaseA->value();
}
int BSize() const
{
return BaseB->value();
}
int CSize() const
{
return BaseC->value();
}
int AFill() const
{
return ValueA->value();
}
int BFill() const
{
return ValueB->value();
}
int CFill() const
{
return ValueC->value();
}
int getNeed() const
{
return NeedA->value();
}
void setSizes(int a, int b, int c)
{
BaseA->setValue(a);
BaseB->setValue(b);
BaseC->setValue(c);
}
void setFill(int a, int b, int c)
{
ValueA->setValue(a);
ValueB->setValue(b);
ValueC->setValue(c);
}
void setNeed(int a)
{
NeedA->setValue(a);
}
public slots:
void setMax();
void setMax();
private:
void translateButtons();
};
#endif // NDIALOG_H
This diff is collapsed.
......@@ -13,104 +13,105 @@
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include <QWidget>
#ifndef VPULT_H
#define VPULT_H
#include "ui_pult.h"
#include "vodoley.h"
#include <kumir2-libs/widgets/pultlogger.h>
//#include "network.h"
#include <QtCore>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
class Vodoley;
class pultLogger;
class linkLight;
class MainButton;
#include <QWidget>
#if 0
#define SCROLL_STEP 10
#define RESP_PANEL 40
#define LOGGER_BUTTONS 140
#define TEXT_STEP 14
#undef TEXT
#define UP 1
#define DOWN 2
#define LEFT 3
#define RIGHT 4
#define TEXT 5
#endif
#if 0
class OvenTimer : public QWidget
{
Q_OBJECT
Q_OBJECT
public:
OvenTimer(QWidget *parent = 0);
OvenTimer(QWidget *parent = 0);
void setDuration(int secs);
int duration() const;
void draw(QPainter *painter);
void setDuration(int secs);
int duration() const;
void draw(QPainter *painter);
signals:
void angChange(int value);
void angChange(int value);
public slots:
void setValue(int value);
void setValue(int value);
protected:
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent ( QMouseEvent * event );
void mouseReleaseEvent ( QMouseEvent * event );
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
private:
// QDateTime finishTime;
// QTimer *updateTimer;
// QTimer *finishTimer;
bool mouseFlag;
QPointF old_mouse_pos;
int gradValue;
int oldValue;
// QDateTime finishTime;
// QTimer *updateTimer;
// QTimer *finishTimer;
bool mouseFlag;
QPointF old_mouse_pos;
int gradValue;
int oldValue;
};
#endif
class VodoleyPult : public QWidget, public Ui::VodoleyPult
class VodoleyPult : public QWidget, public Ui::VodoleyPult
{
Q_OBJECT
public:
/**
* Конструктор
* @param parent ссыка на объект-владелец
* @param fl флаги окна
*/
VodoleyPult ( QWidget* parent = 0, Qt::WindowFlags fl = 0 );
inline QSize minimumSizeHint() const { return QSize(250, 450); }
/**
* Деструктор
*/
~VodoleyPult(){};
bool Link(){return link;};
pultLogger * Logger;
pultLogger * pltLogger(){return Logger;};
Vodoley* VodoleyObj;
//KNPServer* form_kumir;
// void Connect(KNPServer* server);
bool libMode;
void AutoClose(){autoClose=true;};
public
slots:
public:
/**
* Конструктор
* @param parent ссыка на объект-владелец
* @param fl флаги окна
*/
VodoleyPult(QWidget *parent, Qt::WindowFlags fl, Vodoley *vodoley);
/**
* Деструктор
*/
~VodoleyPult() {}
QSize minimumSizeHint() const
{
return QSize(250, 450);
}
bool Link()
{
return link;
}
pultLogger *pltLogger()
{
return Logger;
}
void AutoClose()
{
autoClose = true;
}
public
slots:
void noLink();
void LinkOK();
void newClient(QString);
void clientDisconnect();
void LinkOK();
void newClient(QString);
void clientDisconnect();
void Up();
......@@ -118,8 +119,6 @@ public
void BOutS();
void COutS();
void TempS();
void AtoBS();
......@@ -128,21 +127,25 @@ public
void CtoAS();
void resetVodoley();
void showMessage(QString message){label->setText(message);};
void logToKumir();
void FillAs();
void FillBs();
void FillCs();
void showMessage(QString message)
{
label->setText(message);
}
void logToKumir();
void FillAs();
void FillBs();
void FillCs();
void lockCButtons();
void UnLockCButtons();
signals:
signals:
void goUp();
void goDown();
void goLeft();
void goRight();
void hasLeftWall();
void hasRightWall();
......@@ -152,24 +155,25 @@ public
void noRightWall();
void Color();
void Clean();
void Rad();
void Temp();
void logToK();
void PultCmd(QString text);
void sendText(QString text);
protected:
// virtual void closeEvent ( QCloseEvent * event );
virtual void paintEvent(QPaintEvent *);
private:
bool link;
bool autoClose;
linkLight * greenLight;
MainButton* BtoC,*buttBack,*AtoC,*turnRight;
MainButton* Coutb,*askFree,*AtoB,*buttTemp,*aFill,*bFill,*cFill,*CtoB,*CtoA;
OvenTimer * GradInput;
protected:
virtual void paintEvent(QPaintEvent *);
private:
pultLogger *Logger;
Vodoley *VodoleyObj;
bool link;
bool autoClose;
linkLight *greenLight;
MainButton *BtoC, *buttBack, *AtoC, *turnRight;
MainButton *Coutb, *askFree, *AtoB, *buttTemp, *aFill, *bFill, *cFill, *CtoB, *CtoA;
};
#endif // VPULT_H
#include "vial.h"
#include <QPainter>
#include <QMutex>
#include <QDebug>
#define X_SIZE 30
Vial::Vial(int x, int y, uint size, float lsize, QMutex *mutex)
{
SizeInLiters = size;
literSize = lsize;
offsetX = x + 5;
offsetY = y;
curFil = 1;
needFill = -1;
M = mutex;
}
void Vial::paint(
QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget
) {
Q_UNUSED(option);
Q_UNUSED(widget);
M->lock();
//qDebug()<<"Repaint menzurka "<<Gp<<" curFil"<<curFil;
QBrush black(Qt::black);
float size = (literSize * SizeInLiters);
// qDebug()<<"Repaint menzurka "<<Gp<<" gpy"<<GpY <<" size"<<size;
QPointF points[4] = {
QPointF(offsetX, offsetY + size - 3),
QPointF(offsetX - 3, offsetY + size + 2),
QPointF(offsetX + X_SIZE + 3, offsetY + size + 2),
QPointF(offsetX + X_SIZE, offsetY + size - 3)
};
painter->setBrush(black);
painter->drawConvexPolygon(points, 4);
QLinearGradient glassGradient(offsetX, offsetY, offsetX + X_SIZE, offsetY + size);
QColor niceBlue(142, 140 + 26, 180 + 25);
QColor semiWhite(230, 230, 250);
glassGradient.setColorAt(0.0, Qt::white);
glassGradient.setColorAt(23 / 20, niceBlue);
glassGradient.setColorAt(4 / 20, semiWhite);
// glassGradient.setColorAt(0.4, Qt::white);
//Menzurka
painter->setBrush(glassGradient);
painter->drawRoundedRect(offsetX, offsetY - 5, X_SIZE, size + 5, 5, 5);
//Birka
QString text = QString::number(curFil);
QPointF birka[5] = {
QPointF(offsetX + X_SIZE + 3, offsetY + size - literSize * curFil),
QPointF(offsetX + X_SIZE + 11, offsetY + size - literSize * curFil + 8),
QPointF(offsetX + X_SIZE + 17 + text.length() * 10, offsetY + size - literSize * curFil + 8),
QPointF(offsetX + X_SIZE + 17 + text.length() * 10, offsetY + size - literSize * curFil - 8),
QPointF(offsetX + X_SIZE + 11, offsetY + size - literSize * curFil - 8)
};
painter->drawConvexPolygon(birka, 5);
painter->drawText(offsetX + X_SIZE + 13, offsetY + size - literSize * curFil + 7, text); //Birka text
QString sizeT = QString::number(SizeInLiters);
painter->drawText(offsetX + X_SIZE / 2 - sizeT.length() * 3, offsetY + size + 20, sizeT);
//Metki
if (((uint)needFill > 0) && ((uint)needFill <= SizeInLiters)) {
painter->setPen(QColor(20, 237, 17));
painter->drawLine(offsetX + 1, offsetY + size - literSize * needFill, offsetX + X_SIZE / 3, offsetY + size - literSize * needFill);
//QString sizeN=QString::number(needFill);
//painter->drawText(offsetX-sizeN.length()*10,offsetY+size-literSize*needFill+7,sizeN);
//QBrush gold(QColor(2,237,17));
painter->setPen(QColor(150, 150, 150));
painter->drawLine(offsetX + X_SIZE * 3 / 4, offsetY + size - literSize * SizeInLiters, offsetX + X_SIZE - 1, offsetY + size - literSize * SizeInLiters);
};
painter->setPen(QColor(0, 0, 0));
//VODA
if (curFil > 0) {
QLinearGradient waterGradient(offsetX + 1, offsetY + size - literSize * curFil, offsetX + X_SIZE - 2, offsetY + size);
QColor W1(78, 127, 248);
QColor W2(18, 173, 253);
qDebug() << "cur" << curFil << " need" << needFill;
if (curFil == (uint)needFill) {
qDebug() << "OK!!!!!!";
W1.setRgb(250, 250, 35);
W1.setRgb(210, 230, 10);
}
//waterGradient.setColorAt(0.0, Qt::);
waterGradient.setColorAt(0.0, W1);
// waterGradient.setColorAt(0.3, W2);
if (curFil == (uint)needFill) {
waterGradient.setColorAt(1, W2);
} else {
waterGradient.setColorAt(0.3, W2);
}
painter->setBrush(waterGradient);
painter->setOpacity(0.5);
painter->drawRoundedRect(offsetX, offsetY + size - literSize * curFil, X_SIZE, literSize * curFil, 2, 2);
}
M->unlock();
}
#ifndef VIAL_H
#define VIAL_H
#include <QGraphicsItem>
class QMutex;
class Vial: public QGraphicsItem
{
public:
Vial(int x, int y, uint size, float lsize, QMutex *mutex);
~Vial() {};
QRectF boundingRect() const
{
qreal penWidth = 1;
return QRectF(
-10 - penWidth / 2, -10 - penWidth / 2,
20 + penWidth / 2, 20 + penWidth / 2
);