/***************************************************************************
* Copyright (C) 2007-2021 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* Based on Promoe, an XMMS2 Client *
* Copyright (C) 2005-2006 by XMMS2 Team *
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
* This program 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 this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef SKIN_H
#define SKIN_H
#include <QObject>
#include <QMap>
#include <QPixmap>
#include <QDir>
#include <QRegion>
#include <QCursor>
class Skin : public QObject
{
Q_OBJECT
public:
Skin(QObject *parent = nullptr);
~Skin();
static Skin *instance();
static QPixmap getPixmap(const QString &name, QDir dir);
int ratio() const;
const QPixmap &getMain() const;
const QPixmap getButton(uint bt) const;
const QCursor getCursor(uint cu) const;
const QPixmap getTitleBar(uint tb) const;
const QPixmap &getPosBar() const;
const QPixmap &getNumber(uint n) const;
/*!
* Returns count of numbers in number list.
* We need this to check if we have "-" in pixmaps.
* if no we should draw it manually.
*/
uint getNumCount(void) const;
const QPixmap getPlPart(uint p) const;
const QPixmap getEqPart(uint p) const;
const QPixmap &getEqSlider(uint n) const;
const QPixmap &getEqSpline(uint n) const;
const QPixmap getMSPart(uint n) const;
const QPixmap getLetter(const QChar& ch) const;
const QPixmap getItem(uint n) const;
const QPixmap &getVolumeBar(int n) const;
const QPixmap &getBalanceBar(int n) const;
const QByteArray getPLValue (QByteArray c) const;
const QColor getMainColor(int n) const;
const QColor &getVisColor(int n) const;
const QRegion getRegion(uint r) const;
enum Button
{
BT_PREVIOUS_N = 0,
BT_PREVIOUS_P,
BT_PLAY_N,
BT_PLAY_P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ume.* */
BT_VOL_N,
BT_VOL_P,
/* balance.* */
BT_BAL_N,
BT_BAL_P,
};
enum TitleBarPart
{
TITLEBAR_A = 0,
TITLEBAR_I,
TITLEBAR_SHADED_A,
TITLEBAR_SHADED_I
};
enum PlayListPart
{
PL_CORNER_UL_A = 0,
PL_CORNER_UL_I,
PL_CORNER_UR_A,
PL_CORNER_UR_I,
PL_TITLEBAR_A,
PL_TITLEBAR_I,
PL_TFILL1_A,
PL_TFILL1_I,
PL_TFILL2_A,
PL_TFILL2_I,
PL_LFILL,
PL_RFILL,
PL_LSBAR,
PL_RSBAR,
PL_SFILL1,
PL_SFILL2,
PL_CONTROL,
PL_TITLEBAR_SHADED1_A,
PL_TITLEBAR_SHADED1_I,
PL_TITLEBAR_SHADED2,
PL_TFILL_SHADED
};
enum EqualizerPart
{
EQ_MAIN = 0,
EQ_TITLEBAR_A,
EQ_TITLEBAR_I,
EQ_GRAPH,
EQ_TITLEBAR_SHADED_A,
EQ_TITLEBAR_SHADED_I,
EQ_VOLUME1,
EQ_VOLUME2,
EQ_VOLUME3,
EQ_BALANCE1,
EQ_BALANCE2,
EQ_BALANCE3
};
enum MonoSterPart
{
MONO_A = 0,
MONO_I,
STEREO_A,
STEREO_I
};
enum OtherPart
{
PLAY = 0,
PAUSE,
STOP
};
enum Regions
{
NORMAL = 0,
EQUALIZER,
WINDOW_SHADE,
EQUALIZER_WS
};
enum Cursor
{
CUR_NORMAL = 0,
CUR_CLOSE,
CUR_MAINMENU,
CUR_MIN,
CUR_POSBAR,
CUR_SONGNAME,
CUR_TITLEBAR,
CUR_VOLBAL,
CUR_WINBUT,
CUR_WSNORMAL,
CUR_WSPOSBAR,
CUR_EQCLOSE,
CUR_EQNORMAL,
CUR_EQSLID,
CUR_EQTITLE,
CUR_PCLOSE,
CUR_PNORMAL,
CUR_PSIZE,
CUR_PTBAR,
CUR_PVSCROLL,
CUR_PWINBUT,
CUR_PWSNORM,
CUR_PWSSIZE,
CUR_VOLBAR,
CUR_WSCLOSE,
CUR_WSMIN,
CUR_WSWINBUT
};
enum Color
{
MW_BACKGROUND = 0,
MW_FOREGROUND
};
public slots:
void setSkin(const QString& path);
void reloadSkin();
signals:
void skinChanged();
private:
QPixmap *getPixmap(const QString &name, const QString &fallback = QString());
QString getPath(const QString&);
const QString findFile(const QString &name);
/*!
* As far as there is no standard in skin making we cannot be sure
* that all needful images we can find in skin :( This will cause
* segfaults and asserts. So to prevent this we need such method
* to load pixmap from default skin.
*/
QPixmap *getDummyPixmap(const QString &name, const QString &fallback);
QPixmap scalePixmap(const QPixmap &pix, int ratio = 2);
static Skin *m_instance;
QDir m_skin_dir;
QMap<uint, QPixmap> m_buttons;
QMap<uint, QCursor> m_cursors;
QMap<uint, QPixmap> m_titlebar;
QMap<uint, QPixmap> m_pl_parts;
QMap<uint, QPixmap> m_eq_parts;
QMap<uint, QPixmap> m_ms_parts;
QMap<uint, QPixmap> m_parts;
QMap<QChar, QPixmap> m_letters;
QMap<QByteArray, QByteArray> m_pledit_txt;
QMap<uint, QRegion> m_regions;
QPixmap m_main;
QPixmap posbar;
QList<QPixmap> m_numbers;
QList<QPixmap> m_eq_bar;
QList<QPixmap> m_eq_spline;
QList<QPixmap> m_volume;
QList<QPixmap> m_balance;
QList<QColor> m_vis_colors;
QMap<uint, QColor> m_main_colors;
bool m_use_cursors;
bool m_double_size;
bool m_antialiasing;
void loadMain();
void loadButtons();
void loadCursors();
void loadColors();
void loadTitleBar();
void loadPosBar();
void loadNumbers();
void loadPlayList();
void loadPLEdit();
void loadEqMain();
void loadEq_ex();
void loadVisColor();
void loadShufRep();
void loadLetters();
void loadMonoSter();
void loadVolume();
void loadBalance();
void loadRegion();
QRegion createRegion(const QString &path, const QString &group);
QPixmap *correctSize(QPixmap *pixmap, int w, int h);
};
#endif