2017-08-27 08:10:09 +00:00
|
|
|
#ifndef WIDGETLOCK_H
|
|
|
|
#define WIDGETLOCK_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QApplication>
|
|
|
|
|
|
|
|
class widgetlock : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QWidget* widget;
|
|
|
|
QPushButton* lockButton;
|
2017-09-08 07:59:19 +00:00
|
|
|
|
2017-08-27 08:10:09 +00:00
|
|
|
public slots:
|
|
|
|
void lockButtonClicked(bool) {
|
|
|
|
bool wasEnabled = widget->isEnabled();
|
|
|
|
widget->setEnabled(!wasEnabled);
|
|
|
|
lockButton->setText(widget->isEnabled()?lockButton->tr("Lock"):lockButton->tr("Edit"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
widgetlock(QWidget* widget_, QPushButton* lockButton_): widget(widget_),lockButton(lockButton_) {
|
|
|
|
widget->setEnabled(false);
|
|
|
|
lockButton->setText(lockButton->tr("Edit"));
|
|
|
|
QObject::connect(lockButton,SIGNAL(clicked(bool)), this, SLOT(lockButtonClicked(bool)));
|
|
|
|
}
|
2017-09-08 07:59:19 +00:00
|
|
|
virtual ~widgetlock() {}
|
|
|
|
void deleteListener() {
|
2017-08-27 08:10:09 +00:00
|
|
|
QObject::disconnect(lockButton,SIGNAL(clicked(bool)), this, SLOT(lockButtonClicked(bool)));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WIDGETLOCK_H
|