LeechCraft  0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
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 
17 class QWidget;
18 class QWindow;
19 
20 namespace LC::Util
21 {
44  class AutoResizeMixin : public QObject
45  {
46  const QPoint OrigPoint_;
47 
48  const std::function<void (QPoint)> Mover_;
49  public:
52  using RectGetter_f = std::function<QRect ()>;
53  private:
54  const RectGetter_f Rect_;
55  public:
68  UTIL_GUI_API AutoResizeMixin (const QPoint& point, RectGetter_f rect, QWidget *widget);
69 
82  UTIL_GUI_API AutoResizeMixin (const QPoint& point, RectGetter_f rect, QWindow *window);
83 
86  bool eventFilter (QObject*, QEvent*) override;
87  private:
88  void Refit (const QSize&);
89  };
90 }
bool eventFilter(QObject *, QEvent *) override
Listens for resize events and refits the widget.
#define UTIL_GUI_API
Definition: guiconfig.h:16
Automatically moves a widget to fit a rectangle on resize.
UTIL_GUI_API AutoResizeMixin(const QPoint &point, RectGetter_f rect, QWidget *widget)
Constructs the resize mixin.
std::function< QRect()> RectGetter_f
A function type used to get the rect to fit widget in.