mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
156 lines
4.8 KiB
C++
156 lines
4.8 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 "blackmisc/restricted.h"
|
|
#include "blackmisc/digestsignal.h"
|
|
|
|
#include <QFileSystemWatcher>
|
|
#include <QMap>
|
|
#include <QObject>
|
|
#include <QScopedPointer>
|
|
#include <QSettings>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QStyle>
|
|
|
|
class QFont;
|
|
class QWidget;
|
|
|
|
namespace BlackGui
|
|
{
|
|
class CGuiApplication;
|
|
|
|
//! Reads and provides style sheets
|
|
class BLACKGUI_EXPORT CStyleSheetUtility : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
//! Constructor
|
|
explicit CStyleSheetUtility(BlackMisc::Restricted<CGuiApplication>, QObject *parent = nullptr);
|
|
|
|
//! 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 updateFont(const QFont &font);
|
|
|
|
//! Update the fonts
|
|
bool updateFont(const QString &fontFamily, const QString &fontSize, const QString &fontStyle, const QString &fontWeight, const QString &fontColor);
|
|
|
|
//! Reset font
|
|
bool resetFont();
|
|
|
|
//! Current font color from style sheet
|
|
QString fontColor() const;
|
|
|
|
//! Read the *.qss files
|
|
bool read();
|
|
|
|
//! Get the font style
|
|
static QString fontStyle(const QString &combinedStyleAndWeight);
|
|
|
|
//! Get the font weight
|
|
static QString fontWeight(const QString &combinedStyleAndWeight);
|
|
|
|
//! File name fonts.qss
|
|
static const QString &fileNameFonts();
|
|
|
|
//! Name for user modified file
|
|
static const QString &fileNameFontsModified();
|
|
|
|
//! Delete the modified file for fonts
|
|
bool deleteModifiedFontFile();
|
|
|
|
//! 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 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 swiftlauncher.qss
|
|
static const QString &fileNameSwiftLauncher();
|
|
|
|
//! Font weights
|
|
static const QStringList &fontWeights();
|
|
|
|
//! Font styles
|
|
static const QStringList &fontStyles();
|
|
|
|
//! Transparent background color
|
|
static const QString &transparentBackgroundColor();
|
|
|
|
//! 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
|
|
//! \deprecated use BlackGui::CGuiApplication::styleSheetsChanged
|
|
void styleSheetsChanged();
|
|
|
|
private slots:
|
|
//! File changed
|
|
void ps_qssDirectoryChanged(const QString &file);
|
|
|
|
private:
|
|
QMap<QString, QString> m_styleSheets; //!< filename, stylesheet
|
|
QFileSystemWatcher m_fileWatcher {this}; //!< Monitor my qss files
|
|
};
|
|
}
|
|
#endif // guard
|