calamares/src/libcalamaresui/utils/CalamaresUtilsGui.h

134 lines
3.9 KiB
C
Raw Normal View History

/* === This file is part of Calamares - <https://github.com/calamares> ===
2014-07-01 11:48:10 +02:00
*
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
* SPDX-FileCopyrightText: 2017-2018 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
2014-07-01 11:48:10 +02:00
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CALAMARESUTILSGUI_H
#define CALAMARESUTILSGUI_H
#include "DllMacro.h"
2014-07-01 11:48:10 +02:00
#include <QObject>
#include <QPixmap>
#include <QSize>
2014-07-01 11:48:10 +02:00
class QLayout;
namespace CalamaresUtils
{
2017-03-01 13:34:48 +01:00
/**
* @brief The ImageType enum lists all common Calamares icons.
* Icons are loaded from SVGs and cached. Each icon has an enum value, through which
* it can be accessed.
* You can forward-declare this as:
* enum ImageType : int;
*/
2014-12-16 15:22:33 +01:00
enum ImageType : int
{
Yes,
No,
Information,
2014-09-03 18:00:47 +02:00
Fail,
Bugs,
Help,
Release,
Donate,
PartitionDisk,
PartitionPartition,
PartitionAlongside,
PartitionEraseAuto,
PartitionManual,
PartitionReplaceOs,
2015-11-27 17:25:16 +01:00
PartitionTable,
BootEnvironment,
Squid,
StatusOk, // Icons for the requirements checker
StatusWarning,
StatusError
};
2017-03-01 13:34:48 +01:00
/**
* @brief The ImageMode enum contains different transformations that can be applied.
* Most of these are currently unused.
*/
enum ImageMode
{
Original,
CoverInCase,
Grid,
DropShadow,
RoundedCorners
};
2017-03-01 13:34:48 +01:00
/**
* @brief defaultPixmap returns a resized and/or transformed pixmap for a given
* ImageType.
* @param type the ImageType i.e. the enum value for an SVG.
* @param mode the transformation to apply (default: no transformation).
* @param size the target pixmap size (default: original SVG size).
* @return the new pixmap.
*/
UIDLLEXPORT QPixmap defaultPixmap( ImageType type,
2017-03-01 13:34:48 +01:00
ImageMode mode = CalamaresUtils::Original,
const QSize& size = QSize( 0, 0 ) );
2014-07-01 11:48:10 +02:00
// TODO:3.3:This has only one consumer, move to ImageRegistry, make static
2017-03-01 13:34:48 +01:00
/**
* @brief createRoundedImage returns a rounded version of a pixmap.
* @param avatar the input pixmap.
* @param size the new size.
* @param frameWidthPct the frame size, as percentage of width.
* @return the transformed pixmap.
* This one is currently unused.
*/
UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size, float frameWidthPct = 0.20f );
2017-03-01 13:34:48 +01:00
/**
* @brief unmarginLayout recursively walks the QLayout tree and removes all margins.
* @param layout the layout to unmargin.
*/
UIDLLEXPORT void unmarginLayout( QLayout* layout );
2017-03-01 13:34:48 +01:00
// TODO:3.3:This has only one consumer, move to LicensePage, make static
2017-03-01 13:34:48 +01:00
/**
* @brief clearLayout recursively walks the QLayout tree and deletes all the child
* widgets and layouts.
* @param layout the layout to clear.
*/
UIDLLEXPORT void clearLayout( QLayout* layout );
2014-07-01 11:48:10 +02:00
UIDLLEXPORT void setDefaultFontSize( int points );
UIDLLEXPORT int defaultFontSize(); // in points
UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific
UIDLLEXPORT QFont defaultFont(); // TODO:3.3:This has one consumer, move to BlankViewStep
UIDLLEXPORT QFont largeFont();
UIDLLEXPORT QSize defaultIconSize();
/**
* @brief Size constants for the main Calamares window.
*/
constexpr int windowMinimumWidth = 800;
constexpr int windowMinimumHeight = 520;
constexpr int windowPreferredWidth = 1024;
constexpr int windowPreferredHeight = 520;
} // namespace CalamaresUtils
2014-07-01 11:48:10 +02:00
#endif // CALAMARESUTILSGUI_H