i2pd/qt/i2pd_qt/widgetlock.h

36 lines
970 B
C
Raw Normal View History

#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 10:59:19 +03: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 10:59:19 +03:00
virtual ~widgetlock() {}
void deleteListener() {
QObject::disconnect(lockButton,SIGNAL(clicked(bool)), this, SLOT(lockButtonClicked(bool)));
}
};
#endif // WIDGETLOCK_H