LeechCraft  0.6.70-6645-gcd10d7e
Modular cross-platform feature rich live environment.
util.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  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #pragma once
31 
32 #include <QPoint>
33 #include <QPalette>
34 #include <QMimeData>
35 #include "guiconfig.h"
36 
37 class QSize;
38 class QRect;
39 class QPixmap;
40 class QLabel;
41 class QColor;
42 class QWidget;
43 
44 namespace LeechCraft
45 {
46 namespace Util
47 {
52  enum FitFlag
53  {
57 
65  NoOverlap = 0x01
66  };
67 
68  Q_DECLARE_FLAGS (FitFlags, FitFlag);
69 
94  UTIL_GUI_API QPoint FitRectScreen (QPoint pos, const QSize& size,
95  FitFlags flags = NoFlags, const QPoint& shiftAdd = QPoint (0, 0));
96 
123  UTIL_GUI_API QPoint FitRect (QPoint pos, const QSize& size, const QRect& geometry,
124  FitFlags flags = NoFlags, const QPoint& shiftAdd = QPoint (0, 0));
125 
143  UTIL_GUI_API QLabel* ShowPixmapLabel (const QPixmap& pixmap, const QPoint& pos = QPoint ());
144 
160  UTIL_GUI_API QColor TintColors (const QColor& c1, const QColor& c2, double alpha = 0.5);
161 
181  UTIL_GUI_API void TintPalette (QWidget *widget,
182  const QColor& color,
183  double alpha = 0.5,
184  const QList<QPalette::ColorRole>& roles = { QPalette::ColorRole::Text, QPalette::ColorRole::WindowText });
185 
186  template<typename T>
187  void Save2MimeData (QMimeData *mimeData, const QString& name, const T& t)
188  {
189  QByteArray infosData;
190  QDataStream ostr { &infosData, QIODevice::WriteOnly };
191  ostr << t;
192 
193  mimeData->setData (name, infosData);
194  }
195 }
196 }
197 
198 Q_DECLARE_OPERATORS_FOR_FLAGS (LeechCraft::Util::FitFlags);
QLabel * ShowPixmapLabel(const QPixmap &srcPx, const QPoint &pos)
Shows a pixmap at the given pos.
Definition: util.cpp:119
Q_DECLARE_OPERATORS_FOR_FLAGS(LeechCraft::Util::FitFlags)
detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, boost::mpl::int_< Idx >> pos
Definition: oral.h:917
QPoint FitRectScreen(QPoint pos, const QSize &size, FitFlags flags, const QPoint &shiftAdd)
Tries to fit a rectangle (like a dialog or popup) into screen.
Definition: util.cpp:44
void Save2MimeData(QMimeData *mimeData, const QString &name, const T &t)
Definition: util.h:187
#define UTIL_GUI_API
Definition: guiconfig.h:37
QColor TintColors(const QColor &c1, const QColor &c2, double alpha)
Mixes two colors with the given weights.
Definition: util.cpp:140
void TintPalette(QWidget *widget, const QColor &color, double alpha, const QList< QPalette::ColorRole > &roles)
Mixes some of the widget&#39;s palette roles with the given color.
Definition: util.cpp:149
QPoint FitRect(QPoint pos, const QSize &size, const QRect &geometry, FitFlags flags, const QPoint &shiftAdd)
Tries to fit a rectangle (like a dialog or popup) into geometry.
Definition: util.cpp:49
Q_DECLARE_FLAGS(FitFlags, FitFlag)