File indexing completed on 2024-04-28 04:33:05

0001 /*
0002     SPDX-FileCopyrightText: 2006-2007 Pino Toscano <pino@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef OKULAR_GUIUTILS_H
0008 #define OKULAR_GUIUTILS_H
0009 
0010 #include <QColor>
0011 #include <QIcon>
0012 #include <QString>
0013 
0014 class QImage;
0015 class QPixmap;
0016 class QSize;
0017 class QWidget;
0018 class QFile;
0019 
0020 namespace Okular
0021 {
0022 class Annotation;
0023 class EmbeddedFile;
0024 class Movie;
0025 class ScreenAnnotation;
0026 }
0027 
0028 namespace GuiUtils
0029 {
0030 /**
0031  * Returns the translated string with the type of the given @p annotation.
0032  */
0033 QString captionForAnnotation(const Okular::Annotation *annotation);
0034 QString authorForAnnotation(const Okular::Annotation *annotation);
0035 
0036 QString contentsHtml(const Okular::Annotation *annotation);
0037 
0038 QString prettyToolTip(const Okular::Annotation *annotation);
0039 
0040 void saveEmbeddedFile(Okular::EmbeddedFile *ef, QWidget *parent);
0041 void writeEmbeddedFile(Okular::EmbeddedFile *ef, QWidget *parent, QFile &targetFile);
0042 
0043 /**
0044  * Returns the movie object that is referenced by a rendition action of the passed screen @p annotation
0045  * or @c 0 if the screen annotation has no rendition action set or the rendition action does not contain
0046  * a media rendition.
0047  */
0048 Okular::Movie *renditionMovieFromScreenAnnotation(const Okular::ScreenAnnotation *annotation);
0049 
0050 // colorize a gray image to the given color
0051 void colorizeImage(QImage &image, const QColor &color, unsigned int alpha = 255);
0052 
0053 enum ColorIconFlags {
0054     NoFlags = 0x0,
0055     VisualizeTransparent = 0x1 ///< Visualizes Qt::transparent with a cross.
0056 };
0057 
0058 /**
0059  * Paints color rectangles on the lower 25% of an icon.
0060  *
0061  * If no icon is given, the whole icon square is filled, and a 1px border is added.
0062  *
0063  * Examples:
0064  *  * Different icons for different kinds of color selection, like fill and outline.
0065  *  * Selection of a color scheme preset, where each scheme has a different icon and ~1..3 specific colors.
0066  *
0067  * @param colors Which color rectangles to paint, from left to right (even on RTL). Colors may be transparent. Invalid colors are skipped.
0068  * @param background Which icon to use as background.
0069  * @param flags Special wishes.
0070  *
0071  * @returns A newly created QIcon.
0072  */
0073 QIcon createColorIcon(const QList<QColor> &colors, const QIcon &background = QIcon(), ColorIconFlags flags = NoFlags);
0074 
0075 /**
0076  * Creates an opacity icon, using QPalette foreground color
0077  * painted on top of a checkerboard pattern using @p opacity.
0078  *
0079  * @param opacity 0 = invisible, 1 = opaque.
0080  */
0081 QIcon createOpacityIcon(qreal opacity);
0082 
0083 }
0084 
0085 #endif