mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
147 lines
4.4 KiB
C++
147 lines
4.4 KiB
C++
/* Copyright (C) 2014
|
|
* swift project Community / Contributors
|
|
*
|
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
* contained in the LICENSE file.
|
|
*/
|
|
|
|
//! \file
|
|
|
|
#ifndef BLACKGUI_STYLESHEETUTILITY_H
|
|
#define BLACKGUI_STYLESHEETUTILITY_H
|
|
|
|
#include "blackgui/blackguiexport.h"
|
|
#include <QMap>
|
|
#include <QObject>
|
|
#include <QFont>
|
|
#include <QStringList>
|
|
#include <QStyle>
|
|
#include <QScopedPointer>
|
|
#include <QSettings>
|
|
|
|
namespace BlackGui
|
|
{
|
|
//! Reads and provides style sheets
|
|
class BLACKGUI_EXPORT CStyleSheetUtility : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
//! Read the *.qss files
|
|
bool read();
|
|
|
|
//! Style for given file name
|
|
QString style(const QString &fileName) const;
|
|
|
|
//! Multiple styles concatenated
|
|
QString styles(const QStringList &fileNames) const;
|
|
|
|
//! Contains style for name
|
|
bool containsStyle(const QString &fileName) const;
|
|
|
|
//! Update the fonts
|
|
bool updateFonts(const QFont &font);
|
|
|
|
//! Update the fonts
|
|
bool updateFonts(const QString &fontFamily, const QString &fontSize, const QString &fontStyle, const QString &fontWeight, const QString &fontColor);
|
|
|
|
//! Current font color from style sheet
|
|
QString fontColor();
|
|
|
|
//! GUI ini file data
|
|
const QSettings *iniFile() const { return m_iniFile.data(); }
|
|
|
|
//! Get the font style
|
|
static QString fontStyle(const QString &combinedStyleAndWeight);
|
|
|
|
//! Get the font weight
|
|
static QString fontWeight(const QString &combinedStyleAndWeight);
|
|
|
|
//! Central reader
|
|
static CStyleSheetUtility &instance();
|
|
|
|
//! File name fonts.qss
|
|
static const QString &fileNameFonts();
|
|
|
|
//! File name infobar.qss
|
|
static const QString &fileNameInfoBar();
|
|
|
|
//! File name navigator.qss
|
|
static const QString &fileNameNavigator();
|
|
|
|
//! File name dockwidgettab.qss
|
|
static const QString &fileNameDockWidgetTab();
|
|
|
|
//! File name for standard widgets
|
|
static const QString &fileNameStandardWidget();
|
|
|
|
//! File name maininfoarea.qss
|
|
static const QString &fileNameInfoWindow();
|
|
|
|
//! File name textmessage.qss
|
|
static const QString &fileNameTextMessage();
|
|
|
|
//! File name maininfoarea.qss
|
|
static const QString &fileNameFilterDialog();
|
|
|
|
//! File name swift standard GUI
|
|
static const QString &fileNameSwiftStandardGui();
|
|
|
|
//! File name swiftcore.qss
|
|
static const QString &fileNameSwiftCore();
|
|
|
|
//! File name swiftcore.qss
|
|
static const QString &fileNameSwiftData();
|
|
|
|
//! File name ini file
|
|
static const QString &fileNameIniFile();
|
|
|
|
//! Font weights
|
|
static const QStringList &fontWeights();
|
|
|
|
//! Font styles
|
|
static const QStringList &fontStyles();
|
|
|
|
//! Transparent background color
|
|
static const QString &transparentBackgroundColor();
|
|
|
|
//! qss directory
|
|
static QString qssDirectory();
|
|
|
|
//! Font style as string
|
|
static const QString &fontStyleAsString(const QFont &font);
|
|
|
|
//! Font weight as string
|
|
static const QString &fontWeightAsString(const QFont &font);
|
|
|
|
//! Font as combined weight and style
|
|
static QString fontAsCombinedWeightStyle(const QFont &font);
|
|
|
|
//! Use style sheets in derived widgets
|
|
//! \sa QWidget::paintEvent
|
|
static bool useStyleSheetInDerivedWidget(QWidget *derivedWidget, QStyle::PrimitiveElement element = QStyle::PE_Widget);
|
|
|
|
//! Stylesheet string for a checkbox displayed as 2 icons
|
|
static QString styleForIconCheckBox(const QString &checkedIcon, const QString &uncheckedIcon, const QString &width = "16px", const QString &height = "16px");
|
|
|
|
//! Concatenate 2 styles
|
|
static QString concatStyles(const QString &style1, const QString &style2);
|
|
|
|
signals:
|
|
//! Sheets have been changed
|
|
void styleSheetsChanged();
|
|
|
|
private:
|
|
QMap<QString, QString> m_styleSheets; //!< filename, stylesheet
|
|
QScopedPointer<QSettings> m_iniFile;
|
|
|
|
//! Constructor
|
|
explicit CStyleSheetUtility(QObject *parent = nullptr);
|
|
};
|
|
|
|
}
|
|
#endif // guard
|