LeechCraft  0.6.70-13729-g7046a9d2a7
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 class QStyleOptionViewItem;
44 
45 namespace LC
46 {
47 namespace Util
48 {
66  UTIL_GUI_API QLabel* ShowPixmapLabel (const QPixmap& pixmap, const QPoint& pos = QPoint ());
67 
83  UTIL_GUI_API QColor TintColors (const QColor& c1, const QColor& c2, double alpha = 0.5);
84 
85  UTIL_GUI_API QString ElideProgressBarText (const QString& text, const QStyleOptionViewItem& option);
86 
106  UTIL_GUI_API void TintPalette (QWidget *widget,
107  const QColor& color,
108  double alpha = 0.5,
109  const QList<QPalette::ColorRole>& roles = { QPalette::ColorRole::Text, QPalette::ColorRole::WindowText });
110 
122  UTIL_GUI_API QString FormatName (const QString& name);
123 
124  template<typename T>
125  void Save2MimeData (QMimeData *mimeData, const QString& name, const T& t)
126  {
127  QByteArray infosData;
128  QDataStream ostr { &infosData, QIODevice::WriteOnly };
129  ostr << t;
130 
131  mimeData->setData (name, infosData);
132  }
133 }
134 }
QString FormatName(const QString &name)
HTML-formats the name to let the user know it is not a part of the fixed dialog text.
Definition: util.cpp:126
QString ElideProgressBarText(const QString &text, const QStyleOptionViewItem &option)
Definition: util.cpp:113
#define UTIL_GUI_API
Definition: guiconfig.h:37
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:118
QColor TintColors(const QColor &c1, const QColor &c2, double alpha)
Mixes two colors with the given weights.
Definition: util.cpp:104
QLabel * ShowPixmapLabel(const QPixmap &srcPx, const QPoint &pos)
Shows a pixmap at the given pos.
Definition: util.cpp:83
Definition: constants.h:35
void Save2MimeData(QMimeData *mimeData, const QString &name, const T &t)
Definition: util.h:125