LeechCraft  0.6.70-15082-g543737046d
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 {
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 }
LC::Util::AutoResizeMixin
Automatically moves a widget to fit a rectangle on resize.
Definition: autoresizemixin.h:46
LC::Util
Definition: icoreproxy.h:33
LC::Util::AutoResizeMixin::AutoResizeMixin
UTIL_GUI_API AutoResizeMixin(const QPoint &point, RectGetter_f rect, QWidget *widget)
Constructs the resize mixin.
Definition: autoresizemixin.cpp:23
UTIL_GUI_API
#define UTIL_GUI_API
Definition: guiconfig.h:16
LC::Util::AutoResizeMixin::eventFilter
bool eventFilter(QObject *, QEvent *) override
Listens for resize events and refits the widget.
Definition: autoresizemixin.cpp:43
LC::Util::AutoResizeMixin::RectGetter_f
std::function< QRect()> RectGetter_f
A function type used to get the rect to fit widget in.
Definition: autoresizemixin.h:54
guiconfig.h