class JDialog : public QDialog{Q_OBJECTpublic: JDialog(QWidget *parent = 0, JDeviceDispatcher * _device = 0 ,QString msg = 0, const QStringList & list = QStringList() << "Продолжить"); ~JDialog(); uint getCurrentButton(); void setTextMessage( QString ); QString getTextMessage(); private: QListWidget * listButton; QLabel * message; QLabel * icon; _dialogDelegate * delegate; JDeviceDispatcher * _deviceDispatcher;public slots: void pressMainButton();};
#ifndef JPROGRESSDIALOG_H#define JPROGRESSDIALOG_H#include <QTimer>#include <JDialog.h>class JProgressDialog : public JDialog{Q_OBJECTpublic: JProgressDialog(QWidget *parent = 0, JDeviceDispatcher * _device = 0 ,QString msg = 0, const QStringList & list = QStringList() << "Повторить" << "Отмена"); ~JProgressDialog();private : JDeviceDispatcher * _deviceDispatcher; QTimer progressTimer; QLabel progressText; bool activate; QString message; QTimer * activateProcessTimer;public slots: void pressMainButton(); void response( QByteArray ); void errorResponse( QString ); void cancel(); void retrive();private slots: void activateInProgress();};JProgressDialog::JProgressDialog(QWidget *parent, JDeviceDispatcher * device, QString msg, const QStringList & buttons) : JDialog(parent, device, msg, buttons), _deviceDispatcher (device) , message(msg){ activateProcessTimer = new QTimer(this); connect( activateProcessTimer, SIGNAL( timeout() ), this, SLOT( activateInProgress() ) ); }
JDialog::JDialog(QWidget *parent, JDeviceDispatcher * device, QString msg, const QStringList & buttons) : QDialog(parent), _deviceDispatcher(device){ setAttribute(Qt::WA_DeleteOnClose); _deviceDispatcher->setObject(this); setGeometry(0,0,800,600); QFont fontMessage = QFont("Elektra Medium Pro", 0, QFont::Bold); fontMessage.setStyleStrategy(QFont::PreferAntialias); fontMessage.setPixelSize(20); message = new QLabel(this); QPalette messagePalette = message->palette(); messagePalette.setColor( QPalette::WindowText, Qt::white ); message->setGeometry(200,170,400,100); message->setAlignment( Qt::AlignCenter ); message->setWordWrap(true); message->setPalette(messagePalette); message->setFont(fontMessage); message->setText(msg); listButton = new QListWidget(this); foreach(QString text, buttons ){ QListWidgetItem * _item = new QListWidgetItem(text, listButton); _item->setSizeHint(QSize(450,40)); } listButton->setGeometry(175, 300, 450, 100); listButton->setCurrentRow( 0 ); delegate = new _dialogDelegate(); QPalette _palete = listButton->palette(); _palete.setBrush(QPalette::Base, Qt::transparent); listButton->setPalette( _palete ); listButton->setFrameStyle(QFrame::NoFrame); listButton->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); listButton->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); listButton->setItemDelegate(delegate);}
JProgressDialog::JProgressDialog(QWidget *parent, JDeviceDispatcher * device, QString msg, const QStringList & buttons) : JDialog(parent, device, msg, buttons), _deviceDispatcher (device) , message(msg){ qDebug() << "конструктор"; activateProcessTimer = new QTimer(this); connect( activateProcessTimer, SIGNAL( timeout() ), this, SLOT( activateInProgress() ) ); activateProcessTimer->start(500);}