Set the widget enabled false and emit an error if we cannot connect to the service
This commit is contained in:
parent
70194457a9
commit
dec6018464
2 changed files with 16 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -68,6 +69,14 @@ DeviceWidget::DeviceWidget(QWidget *parent) :
|
|||
buttonLayout->addStretch();
|
||||
|
||||
layout->addLayout( buttonLayout );
|
||||
|
||||
if (model.haveError()) {
|
||||
//We emit the signal in the next "event loop".
|
||||
//This to allow the signals to be connected from our parent object
|
||||
QTimer::singleShot(0, this, SLOT(emitError()));
|
||||
this->setEnabled( false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DeviceWidget::~DeviceWidget()
|
||||
|
@ -85,6 +94,10 @@ void DeviceWidget::changeEvent(QEvent *e)
|
|||
}
|
||||
}
|
||||
|
||||
void DeviceWidget::emitError() {
|
||||
emit showMessage("", model.errorString(), "");
|
||||
}
|
||||
|
||||
void DeviceWidget::addDevice() {
|
||||
Device device(0, 0);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ private slots:
|
|||
void addGroup();
|
||||
void deleteDevice();
|
||||
void editDevice();
|
||||
void emitError();
|
||||
|
||||
private:
|
||||
DeviceModel model;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue