cutter/src/widgets/CutterDockWidget.h

49 lines
1.3 KiB
C
Raw Normal View History

#ifndef CUTTERWIDGET_H
#define CUTTERWIDGET_H
#include <QDockWidget>
#include "common/RefreshDeferrer.h"
class MainWindow;
class CutterDockWidget : public QDockWidget
{
Q_OBJECT
public:
explicit CutterDockWidget(MainWindow *main, QAction *action = nullptr);
~CutterDockWidget() override;
bool eventFilter(QObject *object, QEvent *event) override;
2019-01-12 19:25:43 +00:00
bool isVisibleToUser() { return isVisibleToUserCurrent; }
public slots:
void toggleDockWidget(bool show);
signals:
void becameVisibleToUser();
private:
QAction *action;
bool isVisibleToUserCurrent;
void updateIsVisibleToUser();
protected:
2018-03-21 20:32:32 +00:00
void closeEvent(QCloseEvent *event) override;
template<class ParamResult, typename Func>
2019-01-13 13:59:08 +00:00
RefreshDeferrer *createReplacingRefreshDeferrer(bool replaceIfNull, Func refreshNowFunc)
{
2019-01-13 13:59:08 +00:00
auto *deferrer = new RefreshDeferrer(new ReplacingRefreshDeferrerAccumulator<ParamResult>(replaceIfNull), this);
deferrer->registerFor(this);
connect(deferrer, &RefreshDeferrer::refreshNow, this, [refreshNowFunc](const RefreshDeferrerParamsResult paramsResult) {
2019-01-13 13:59:08 +00:00
auto *result = static_cast<const ParamResult *>(paramsResult);
refreshNowFunc(result);
});
return deferrer;
}
};
#endif // CUTTERWIDGET_H