LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
autoresizemixin.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <functional>
12#include <QObject>
13#include <QPoint>
14#include <QRect>
15#include "guiconfig.h"
16
17class QWidget;
18class QWindow;
19
20namespace LC::Util
21{
46 class AutoResizeMixin : public QObject
47 {
48 const QPoint OrigPoint_;
49
50 const std::function<void (QPoint)> Mover_;
51 public:
54 using RectGetter_f = std::function<QRect ()>;
55 private:
56 const RectGetter_f Rect_;
57 public:
70 UTIL_GUI_API AutoResizeMixin (const QPoint& point, RectGetter_f rect, QWidget *widget);
71
84 UTIL_GUI_API AutoResizeMixin (const QPoint& point, RectGetter_f rect, QWindow *window);
85
88 bool eventFilter (QObject*, QEvent*) override;
89 private:
90 void Refit (const QSize&);
91 };
92}
Automatically moves a widget to fit a rectangle on resize.
std::function< QRect()> RectGetter_f
A function type used to get the rect to fit widget in.
UTIL_GUI_API AutoResizeMixin(const QPoint &point, RectGetter_f rect, QWidget *widget)
Constructs the resize mixin.
bool eventFilter(QObject *, QEvent *) override
Listens for resize events and refits the widget.
#define UTIL_GUI_API
Definition guiconfig.h:16