change: change code style to Linux style except indent.
This commit is contained in:
+52
-59
@@ -20,80 +20,73 @@
|
||||
|
||||
#include "colorcoding.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
QVector<Color> ColorCoding::colors_ = {
|
||||
Color(0.545f, 0.255f, 0.255f),
|
||||
Color(0.412f, 0.188f, 0.259f),
|
||||
Color(0.561f, 0.427f, 0.239f),
|
||||
Color(0.486f, 0.306f, 0.235f),
|
||||
Color(0.631f, 0.612f, 0.212f),
|
||||
Color(0.404f, 0.478f, 0.243f),
|
||||
Color(0.349f, 0.576f, 0.275f),
|
||||
Color(0.224f, 0.459f, 0.251f),
|
||||
Color(0.259f, 0.471f, 0.541f),
|
||||
Color(0.184f, 0.376f, 0.329f),
|
||||
Color(0.259f, 0.365f, 0.541f),
|
||||
Color(0.196f, 0.216f, 0.412f),
|
||||
Color(0.612f, 0.294f, 0.502f),
|
||||
Color(0.404f, 0.220f, 0.459f),
|
||||
Color(0.800f, 0.800f, 0.800f),
|
||||
Color(0.502f, 0.502f, 0.502f)
|
||||
Color(0.545f, 0.255f, 0.255f), Color(0.412f, 0.188f, 0.259f),
|
||||
Color(0.561f, 0.427f, 0.239f), Color(0.486f, 0.306f, 0.235f),
|
||||
Color(0.631f, 0.612f, 0.212f), Color(0.404f, 0.478f, 0.243f),
|
||||
Color(0.349f, 0.576f, 0.275f), Color(0.224f, 0.459f, 0.251f),
|
||||
Color(0.259f, 0.471f, 0.541f), Color(0.184f, 0.376f, 0.329f),
|
||||
Color(0.259f, 0.365f, 0.541f), Color(0.196f, 0.216f, 0.412f),
|
||||
Color(0.612f, 0.294f, 0.502f), Color(0.404f, 0.220f, 0.459f),
|
||||
Color(0.800f, 0.800f, 0.800f), Color(0.502f, 0.502f, 0.502f)
|
||||
};
|
||||
|
||||
QString ColorCoding::GetColorName(int c)
|
||||
{
|
||||
// FIXME: I'm sure we could come up with more creative names for these colors
|
||||
switch (c) {
|
||||
case kRed:
|
||||
return tr("Red");
|
||||
case kMaroon:
|
||||
return tr("Maroon");
|
||||
case kOrange:
|
||||
return tr("Orange");
|
||||
case kBrown:
|
||||
return tr("Brown");
|
||||
case kYellow:
|
||||
return tr("Yellow");
|
||||
case kOlive:
|
||||
return tr("Olive");
|
||||
case kLime:
|
||||
return tr("Lime");
|
||||
case kGreen:
|
||||
return tr("Green");
|
||||
case kCyan:
|
||||
return tr("Cyan");
|
||||
case kTeal:
|
||||
return tr("Teal");
|
||||
case kBlue:
|
||||
return tr("Blue");
|
||||
case kNavy:
|
||||
return tr("Navy");
|
||||
case kPink:
|
||||
return tr("Pink");
|
||||
case kPurple:
|
||||
return tr("Purple");
|
||||
case kSilver:
|
||||
return tr("Silver");
|
||||
case kGray:
|
||||
return tr("Gray");
|
||||
}
|
||||
// FIXME: I'm sure we could come up with more creative names for these colors
|
||||
switch (c) {
|
||||
case kRed:
|
||||
return tr("Red");
|
||||
case kMaroon:
|
||||
return tr("Maroon");
|
||||
case kOrange:
|
||||
return tr("Orange");
|
||||
case kBrown:
|
||||
return tr("Brown");
|
||||
case kYellow:
|
||||
return tr("Yellow");
|
||||
case kOlive:
|
||||
return tr("Olive");
|
||||
case kLime:
|
||||
return tr("Lime");
|
||||
case kGreen:
|
||||
return tr("Green");
|
||||
case kCyan:
|
||||
return tr("Cyan");
|
||||
case kTeal:
|
||||
return tr("Teal");
|
||||
case kBlue:
|
||||
return tr("Blue");
|
||||
case kNavy:
|
||||
return tr("Navy");
|
||||
case kPink:
|
||||
return tr("Pink");
|
||||
case kPurple:
|
||||
return tr("Purple");
|
||||
case kSilver:
|
||||
return tr("Silver");
|
||||
case kGray:
|
||||
return tr("Gray");
|
||||
}
|
||||
|
||||
return QString();
|
||||
return QString();
|
||||
}
|
||||
|
||||
Color ColorCoding::GetColor(int c)
|
||||
{
|
||||
return colors_.at(c);
|
||||
return colors_.at(c);
|
||||
}
|
||||
|
||||
Qt::GlobalColor ColorCoding::GetUISelectorColor(const Color &c)
|
||||
{
|
||||
if (c.GetRoughLuminance() > 0.40f) {
|
||||
return Qt::black;
|
||||
} else {
|
||||
return Qt::white;
|
||||
}
|
||||
if (c.GetRoughLuminance() > 0.40f) {
|
||||
return Qt::black;
|
||||
} else {
|
||||
return Qt::white;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+30
-31
@@ -24,47 +24,46 @@
|
||||
#include <olive/core/core.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
using namespace core;
|
||||
|
||||
class ColorCoding : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class ColorCoding : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Code {
|
||||
kRed,
|
||||
kMaroon,
|
||||
kOrange,
|
||||
kBrown,
|
||||
kYellow,
|
||||
kOlive,
|
||||
kLime,
|
||||
kGreen,
|
||||
kCyan,
|
||||
kTeal,
|
||||
kBlue,
|
||||
kNavy,
|
||||
kPink,
|
||||
kPurple,
|
||||
kSilver,
|
||||
kGray
|
||||
};
|
||||
enum Code {
|
||||
kRed,
|
||||
kMaroon,
|
||||
kOrange,
|
||||
kBrown,
|
||||
kYellow,
|
||||
kOlive,
|
||||
kLime,
|
||||
kGreen,
|
||||
kCyan,
|
||||
kTeal,
|
||||
kBlue,
|
||||
kNavy,
|
||||
kPink,
|
||||
kPurple,
|
||||
kSilver,
|
||||
kGray
|
||||
};
|
||||
|
||||
static QString GetColorName(int c);
|
||||
static QString GetColorName(int c);
|
||||
|
||||
static Color GetColor(int c);
|
||||
static Color GetColor(int c);
|
||||
|
||||
static Qt::GlobalColor GetUISelectorColor(const Color& c);
|
||||
static Qt::GlobalColor GetUISelectorColor(const Color &c);
|
||||
|
||||
static const QVector<Color>& standard_colors()
|
||||
{
|
||||
return colors_;
|
||||
}
|
||||
static const QVector<Color> &standard_colors()
|
||||
{
|
||||
return colors_;
|
||||
}
|
||||
|
||||
private:
|
||||
static QVector<Color> colors_;
|
||||
|
||||
static QVector<Color> colors_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+61
-46
@@ -2,65 +2,80 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
QString HumanStrings::SampleRateToString(const int &sample_rate)
|
||||
{
|
||||
return QCoreApplication::translate("AudioParams", "%1 Hz").arg(sample_rate);
|
||||
return QCoreApplication::translate("AudioParams", "%1 Hz").arg(sample_rate);
|
||||
}
|
||||
|
||||
QString HumanStrings::ChannelLayoutToString(const uint64_t &layout)
|
||||
{
|
||||
switch (layout) {
|
||||
case AV_CH_LAYOUT_MONO:
|
||||
return QCoreApplication::translate("AudioParams", "Mono");
|
||||
case AV_CH_LAYOUT_STEREO:
|
||||
return QCoreApplication::translate("AudioParams", "Stereo");
|
||||
case AV_CH_LAYOUT_2_1:
|
||||
return QCoreApplication::translate("AudioParams", "2.1");
|
||||
case AV_CH_LAYOUT_5POINT1:
|
||||
return QCoreApplication::translate("AudioParams", "5.1");
|
||||
case AV_CH_LAYOUT_7POINT1:
|
||||
return QCoreApplication::translate("AudioParams", "7.1");
|
||||
default:
|
||||
return QCoreApplication::translate("AudioParams", "Unknown (0x%1)").arg(layout, 1, 16);
|
||||
}
|
||||
switch (layout) {
|
||||
case AV_CH_LAYOUT_MONO:
|
||||
return QCoreApplication::translate("AudioParams", "Mono");
|
||||
case AV_CH_LAYOUT_STEREO:
|
||||
return QCoreApplication::translate("AudioParams", "Stereo");
|
||||
case AV_CH_LAYOUT_2_1:
|
||||
return QCoreApplication::translate("AudioParams", "2.1");
|
||||
case AV_CH_LAYOUT_5POINT1:
|
||||
return QCoreApplication::translate("AudioParams", "5.1");
|
||||
case AV_CH_LAYOUT_7POINT1:
|
||||
return QCoreApplication::translate("AudioParams", "7.1");
|
||||
default:
|
||||
return QCoreApplication::translate("AudioParams", "Unknown (0x%1)")
|
||||
.arg(layout, 1, 16);
|
||||
}
|
||||
}
|
||||
|
||||
QString HumanStrings::FormatToString(const SampleFormat &f)
|
||||
{
|
||||
switch (f) {
|
||||
case SampleFormat::U8:
|
||||
return QCoreApplication::translate("AudioParams", "Unsigned 8-bit (Packed)");
|
||||
case SampleFormat::S16:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 16-bit (Packed)");
|
||||
case SampleFormat::S32:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 32-bit (Packed)");
|
||||
case SampleFormat::S64:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 64-bit (Packed)");
|
||||
case SampleFormat::F32:
|
||||
return QCoreApplication::translate("AudioParams", "Float 32-bit (Packed)");
|
||||
case SampleFormat::F64:
|
||||
return QCoreApplication::translate("AudioParams", "Float 64-bit (Packed)");
|
||||
case SampleFormat::U8P:
|
||||
return QCoreApplication::translate("AudioParams", "Unsigned 8-bit (Planar)");
|
||||
case SampleFormat::S16P:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 16-bit (Planar)");
|
||||
case SampleFormat::S32P:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 32-bit (Planar)");
|
||||
case SampleFormat::S64P:
|
||||
return QCoreApplication::translate("AudioParams", "Signed 64-bit (Planar)");
|
||||
case SampleFormat::F32P:
|
||||
return QCoreApplication::translate("AudioParams", "Float 32-bit (Planar)");
|
||||
case SampleFormat::F64P:
|
||||
return QCoreApplication::translate("AudioParams", "Float 64-bit (Planar)");
|
||||
switch (f) {
|
||||
case SampleFormat::U8:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Unsigned 8-bit (Packed)");
|
||||
case SampleFormat::S16:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Signed 16-bit (Packed)");
|
||||
case SampleFormat::S32:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Signed 32-bit (Packed)");
|
||||
case SampleFormat::S64:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Signed 64-bit (Packed)");
|
||||
case SampleFormat::F32:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Float 32-bit (Packed)");
|
||||
case SampleFormat::F64:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Float 64-bit (Packed)");
|
||||
case SampleFormat::U8P:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Unsigned 8-bit (Planar)");
|
||||
case SampleFormat::S16P:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Signed 16-bit (Planar)");
|
||||
case SampleFormat::S32P:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Signed 32-bit (Planar)");
|
||||
case SampleFormat::S64P:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Signed 64-bit (Planar)");
|
||||
case SampleFormat::F32P:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Float 32-bit (Planar)");
|
||||
case SampleFormat::F64P:
|
||||
return QCoreApplication::translate("AudioParams",
|
||||
"Float 64-bit (Planar)");
|
||||
|
||||
case SampleFormat::INVALID:
|
||||
case SampleFormat::COUNT:
|
||||
break;
|
||||
}
|
||||
case SampleFormat::INVALID:
|
||||
case SampleFormat::COUNT:
|
||||
break;
|
||||
}
|
||||
|
||||
return QCoreApplication::translate("AudioParams", "Unknown (0x%1)").arg(f, 1, 16);
|
||||
return QCoreApplication::translate("AudioParams", "Unknown (0x%1)")
|
||||
.arg(f, 1, 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,22 +4,21 @@
|
||||
#include <olive/core/core.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
using namespace core;
|
||||
|
||||
class HumanStrings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
class HumanStrings : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
HumanStrings() = default;
|
||||
HumanStrings() = default;
|
||||
|
||||
static QString SampleRateToString(const int &sample_rate);
|
||||
static QString SampleRateToString(const int &sample_rate);
|
||||
|
||||
static QString ChannelLayoutToString(const uint64_t &layout);
|
||||
|
||||
static QString FormatToString(const SampleFormat &f);
|
||||
static QString ChannelLayoutToString(const uint64_t &layout);
|
||||
|
||||
static QString FormatToString(const SampleFormat &f);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+80
-82
@@ -20,16 +20,12 @@
|
||||
|
||||
#include "icons.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
/// Works in conjunction with `genicons.sh` to generate and utilize icons of specific sizes
|
||||
const int ICON_SIZE_COUNT = 4;
|
||||
const int ICON_SIZES[] = {
|
||||
16,
|
||||
32,
|
||||
64,
|
||||
128
|
||||
};
|
||||
const int ICON_SIZES[] = { 16, 32, 64, 128 };
|
||||
|
||||
/// Internal icon library for use throughout Olive without having to regenerate constantly
|
||||
QIcon icon::GoToStart;
|
||||
@@ -98,96 +94,98 @@ QIcon icon::Pencil;
|
||||
QIcon icon::Subtitles;
|
||||
QIcon icon::ColorPicker;
|
||||
|
||||
void icon::LoadAll(const QString& theme)
|
||||
void icon::LoadAll(const QString &theme)
|
||||
{
|
||||
GoToStart = Create(theme, "prev");
|
||||
PrevFrame = Create(theme, "rew");
|
||||
Play = Create(theme, "play");
|
||||
Pause = Create(theme, "pause");
|
||||
NextFrame = Create(theme, "ff");
|
||||
GoToEnd = Create(theme, "next");
|
||||
GoToStart = Create(theme, "prev");
|
||||
PrevFrame = Create(theme, "rew");
|
||||
Play = Create(theme, "play");
|
||||
Pause = Create(theme, "pause");
|
||||
NextFrame = Create(theme, "ff");
|
||||
GoToEnd = Create(theme, "next");
|
||||
|
||||
New = Create(theme, "new");
|
||||
Open = Create(theme, "open");
|
||||
Save = Create(theme, "save");
|
||||
Undo = Create(theme, "undo");
|
||||
Redo = Create(theme, "redo");
|
||||
TreeView = Create(theme, "treeview");
|
||||
ListView = Create(theme, "listview");
|
||||
IconView = Create(theme, "iconview");
|
||||
New = Create(theme, "new");
|
||||
Open = Create(theme, "open");
|
||||
Save = Create(theme, "save");
|
||||
Undo = Create(theme, "undo");
|
||||
Redo = Create(theme, "redo");
|
||||
TreeView = Create(theme, "treeview");
|
||||
ListView = Create(theme, "listview");
|
||||
IconView = Create(theme, "iconview");
|
||||
|
||||
ToolPointer = Create(theme, "arrow");
|
||||
ToolEdit = Create(theme, "beam");
|
||||
ToolRipple = Create(theme, "ripple");
|
||||
ToolRolling = Create(theme, "rolling");
|
||||
ToolRazor = Create(theme, "razor");
|
||||
ToolSlip = Create(theme, "slip");
|
||||
ToolSlide = Create(theme, "slide");
|
||||
ToolHand = Create(theme, "hand");
|
||||
ToolTransition = Create(theme, "transition-tool");
|
||||
ToolTrackSelect = Create(theme, "track-tool");
|
||||
ToolPointer = Create(theme, "arrow");
|
||||
ToolEdit = Create(theme, "beam");
|
||||
ToolRipple = Create(theme, "ripple");
|
||||
ToolRolling = Create(theme, "rolling");
|
||||
ToolRazor = Create(theme, "razor");
|
||||
ToolSlip = Create(theme, "slip");
|
||||
ToolSlide = Create(theme, "slide");
|
||||
ToolHand = Create(theme, "hand");
|
||||
ToolTransition = Create(theme, "transition-tool");
|
||||
ToolTrackSelect = Create(theme, "track-tool");
|
||||
|
||||
Folder = Create(theme, "folder");
|
||||
Sequence = Create(theme, "sequence");
|
||||
Video = Create(theme, "videosource");
|
||||
Audio = Create(theme, "audiosource");
|
||||
Image = Create(theme, "imagesource");
|
||||
Folder = Create(theme, "folder");
|
||||
Sequence = Create(theme, "sequence");
|
||||
Video = Create(theme, "videosource");
|
||||
Audio = Create(theme, "audiosource");
|
||||
Image = Create(theme, "imagesource");
|
||||
|
||||
MiniMap = Create(theme, "map");
|
||||
MiniMap = Create(theme, "map");
|
||||
|
||||
TriUp = Create(theme, "tri-up");
|
||||
TriLeft = Create(theme, "tri-left");
|
||||
TriDown = Create(theme, "tri-down");
|
||||
TriRight = Create(theme, "tri-right");
|
||||
TriUp = Create(theme, "tri-up");
|
||||
TriLeft = Create(theme, "tri-left");
|
||||
TriDown = Create(theme, "tri-down");
|
||||
TriRight = Create(theme, "tri-right");
|
||||
|
||||
TextBold = Create(theme, "text-bold");
|
||||
TextItalic = Create(theme, "text-italic");
|
||||
TextUnderline = Create(theme, "text-underline");
|
||||
TextStrikethrough = Create(theme, "text-strikethrough");
|
||||
TextSmallCaps = Create(theme, "text-small-caps");
|
||||
TextAlignLeft = Create(theme, "align-left");
|
||||
TextAlignRight = Create(theme, "align-right");
|
||||
TextAlignCenter = Create(theme, "align-center");
|
||||
TextAlignJustify = Create(theme, "align-justify-all");
|
||||
TextAlignTop = Create(theme, "align-v-top");
|
||||
TextAlignBottom = Create(theme, "align-v-bottom");
|
||||
TextAlignMiddle = Create(theme, "align-v-middle");
|
||||
TextBold = Create(theme, "text-bold");
|
||||
TextItalic = Create(theme, "text-italic");
|
||||
TextUnderline = Create(theme, "text-underline");
|
||||
TextStrikethrough = Create(theme, "text-strikethrough");
|
||||
TextSmallCaps = Create(theme, "text-small-caps");
|
||||
TextAlignLeft = Create(theme, "align-left");
|
||||
TextAlignRight = Create(theme, "align-right");
|
||||
TextAlignCenter = Create(theme, "align-center");
|
||||
TextAlignJustify = Create(theme, "align-justify-all");
|
||||
TextAlignTop = Create(theme, "align-v-top");
|
||||
TextAlignBottom = Create(theme, "align-v-bottom");
|
||||
TextAlignMiddle = Create(theme, "align-v-middle");
|
||||
|
||||
Snapping = Create(theme, "magnet");
|
||||
ZoomIn = Create(theme, "zoomin");
|
||||
ZoomOut = Create(theme, "zoomout");
|
||||
Record = Create(theme, "record");
|
||||
Add = Create(theme, "add-button");
|
||||
Error = Create(theme, "error");
|
||||
DirUp = Create(theme, "dirup");
|
||||
Clock = Create(theme, "clock");
|
||||
Diamond = Create(theme, "diamond");
|
||||
Plus = Create(theme, "plus");
|
||||
Minus = Create(theme, "minus");
|
||||
AddEffect = Create(theme, "add-effect");
|
||||
ColorPicker = Create(theme, "color-picker");
|
||||
Snapping = Create(theme, "magnet");
|
||||
ZoomIn = Create(theme, "zoomin");
|
||||
ZoomOut = Create(theme, "zoomout");
|
||||
Record = Create(theme, "record");
|
||||
Add = Create(theme, "add-button");
|
||||
Error = Create(theme, "error");
|
||||
DirUp = Create(theme, "dirup");
|
||||
Clock = Create(theme, "clock");
|
||||
Diamond = Create(theme, "diamond");
|
||||
Plus = Create(theme, "plus");
|
||||
Minus = Create(theme, "minus");
|
||||
AddEffect = Create(theme, "add-effect");
|
||||
ColorPicker = Create(theme, "color-picker");
|
||||
|
||||
EyeOpened = Create(theme, "eye-opened");
|
||||
EyeClosed = Create(theme, "eye-closed");
|
||||
LockOpened = Create(theme, "lock-opened");
|
||||
LockClosed = Create(theme, "lock-closed");
|
||||
EyeOpened = Create(theme, "eye-opened");
|
||||
EyeClosed = Create(theme, "eye-closed");
|
||||
LockOpened = Create(theme, "lock-opened");
|
||||
LockClosed = Create(theme, "lock-closed");
|
||||
|
||||
Pencil = Create(theme, "text-edit");
|
||||
Subtitles = Create(theme, "subtitles");
|
||||
Pencil = Create(theme, "text-edit");
|
||||
Subtitles = Create(theme, "subtitles");
|
||||
}
|
||||
|
||||
QIcon icon::Create(const QString& theme, const QString &name)
|
||||
QIcon icon::Create(const QString &theme, const QString &name)
|
||||
{
|
||||
QIcon icon;
|
||||
QIcon icon;
|
||||
|
||||
for (int i=0;i<ICON_SIZE_COUNT;i++) {
|
||||
icon.addFile(QStringLiteral("%1/png/%2.%3.png").arg(theme, name, QString::number(ICON_SIZES[i])),
|
||||
QSize(ICON_SIZES[i], ICON_SIZES[i]), QIcon::Normal);
|
||||
icon.addFile(QStringLiteral("%1/png/%2.%3.disabled.png").arg(theme, name, QString::number(ICON_SIZES[i])),
|
||||
QSize(ICON_SIZES[i], ICON_SIZES[i]), QIcon::Disabled);
|
||||
}
|
||||
for (int i = 0; i < ICON_SIZE_COUNT; i++) {
|
||||
icon.addFile(QStringLiteral("%1/png/%2.%3.png")
|
||||
.arg(theme, name, QString::number(ICON_SIZES[i])),
|
||||
QSize(ICON_SIZES[i], ICON_SIZES[i]), QIcon::Normal);
|
||||
icon.addFile(QStringLiteral("%1/png/%2.%3.disabled.png")
|
||||
.arg(theme, name, QString::number(ICON_SIZES[i])),
|
||||
QSize(ICON_SIZES[i], ICON_SIZES[i]), QIcon::Disabled);
|
||||
}
|
||||
|
||||
return icon;
|
||||
return icon;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,9 +25,11 @@
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
namespace icon {
|
||||
namespace icon
|
||||
{
|
||||
|
||||
// Playback Icons
|
||||
extern QIcon GoToStart;
|
||||
@@ -139,7 +141,7 @@ extern QIcon ColorPicker;
|
||||
*
|
||||
* A QIcon object containing the various icon sizes loaded from resource
|
||||
*/
|
||||
QIcon Create(const QString &theme, const QString& name);
|
||||
QIcon Create(const QString &theme, const QString &name);
|
||||
|
||||
/**
|
||||
* @brief Methodically load all Olive icons into global variables that can be accessed throughout the application
|
||||
|
||||
+116
-101
@@ -31,150 +31,165 @@
|
||||
#include "config/config.h"
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const char* StyleManager::kDefaultStyle = "olive-dark";
|
||||
const char *StyleManager::kDefaultStyle = "olive-dark";
|
||||
QString StyleManager::current_style_;
|
||||
QMap<QString, QString> StyleManager::available_themes_;
|
||||
|
||||
QPalette StyleManager::ParsePalette(const QString& ini_path)
|
||||
QPalette StyleManager::ParsePalette(const QString &ini_path)
|
||||
{
|
||||
QSettings ini(ini_path, QSettings::IniFormat);
|
||||
QPalette palette;
|
||||
QSettings ini(ini_path, QSettings::IniFormat);
|
||||
QPalette palette;
|
||||
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::All);
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::Active);
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::Inactive);
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::Disabled);
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::All);
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::Active);
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::Inactive);
|
||||
ParsePaletteGroup(&ini, &palette, QPalette::Disabled);
|
||||
|
||||
return palette;
|
||||
return palette;
|
||||
}
|
||||
|
||||
void StyleManager::ParsePaletteGroup(QSettings *ini, QPalette *palette, QPalette::ColorGroup group)
|
||||
void StyleManager::ParsePaletteGroup(QSettings *ini, QPalette *palette,
|
||||
QPalette::ColorGroup group)
|
||||
{
|
||||
QString group_name;
|
||||
QString group_name;
|
||||
|
||||
switch (group) {
|
||||
case QPalette::All:
|
||||
group_name = "All";
|
||||
break;
|
||||
case QPalette::Active:
|
||||
group_name = "Active";
|
||||
break;
|
||||
case QPalette::Inactive:
|
||||
group_name = "Inactive";
|
||||
break;
|
||||
case QPalette::Disabled:
|
||||
group_name = "Disabled";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
switch (group) {
|
||||
case QPalette::All:
|
||||
group_name = "All";
|
||||
break;
|
||||
case QPalette::Active:
|
||||
group_name = "Active";
|
||||
break;
|
||||
case QPalette::Inactive:
|
||||
group_name = "Inactive";
|
||||
break;
|
||||
case QPalette::Disabled:
|
||||
group_name = "Disabled";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
ini->beginGroup(group_name);
|
||||
ini->beginGroup(group_name);
|
||||
|
||||
QStringList keys = ini->childKeys();
|
||||
foreach (QString k, keys) {
|
||||
ParsePaletteColor(ini, palette, group, k);
|
||||
}
|
||||
QStringList keys = ini->childKeys();
|
||||
foreach (QString k, keys) {
|
||||
ParsePaletteColor(ini, palette, group, k);
|
||||
}
|
||||
|
||||
ini->endGroup();
|
||||
ini->endGroup();
|
||||
}
|
||||
|
||||
void StyleManager::ParsePaletteColor(QSettings *ini, QPalette *palette, QPalette::ColorGroup group, const QString &role_name)
|
||||
void StyleManager::ParsePaletteColor(QSettings *ini, QPalette *palette,
|
||||
QPalette::ColorGroup group,
|
||||
const QString &role_name)
|
||||
{
|
||||
QPalette::ColorRole role;
|
||||
QPalette::ColorRole role;
|
||||
|
||||
if (!QString::compare(role_name, "Window", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Window;
|
||||
} else if (!QString::compare(role_name, "WindowText", Qt::CaseInsensitive)) {
|
||||
role = QPalette::WindowText;
|
||||
} else if (!QString::compare(role_name, "Base", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Base;
|
||||
} else if (!QString::compare(role_name, "AlternateBase", Qt::CaseInsensitive)) {
|
||||
role = QPalette::AlternateBase;
|
||||
} else if (!QString::compare(role_name, "ToolTipBase", Qt::CaseInsensitive)) {
|
||||
role = QPalette::ToolTipBase;
|
||||
} else if (!QString::compare(role_name, "ToolTipText", Qt::CaseInsensitive)) {
|
||||
role = QPalette::ToolTipText;
|
||||
if (!QString::compare(role_name, "Window", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Window;
|
||||
} else if (!QString::compare(role_name, "WindowText",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::WindowText;
|
||||
} else if (!QString::compare(role_name, "Base", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Base;
|
||||
} else if (!QString::compare(role_name, "AlternateBase",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::AlternateBase;
|
||||
} else if (!QString::compare(role_name, "ToolTipBase",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::ToolTipBase;
|
||||
} else if (!QString::compare(role_name, "ToolTipText",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::ToolTipText;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
|
||||
} else if (!QString::compare(role_name, "PlaceholderText", Qt::CaseInsensitive)) {
|
||||
role = QPalette::PlaceholderText;
|
||||
} else if (!QString::compare(role_name, "PlaceholderText",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::PlaceholderText;
|
||||
#endif
|
||||
} else if (!QString::compare(role_name, "Text", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Text;
|
||||
} else if (!QString::compare(role_name, "Button", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Button;
|
||||
} else if (!QString::compare(role_name, "ButtonText", Qt::CaseInsensitive)) {
|
||||
role = QPalette::ButtonText;
|
||||
} else if (!QString::compare(role_name, "BrightText", Qt::CaseInsensitive)) {
|
||||
role = QPalette::BrightText;
|
||||
} else if (!QString::compare(role_name, "Highlight", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Highlight;
|
||||
} else if (!QString::compare(role_name, "HighlightedText", Qt::CaseInsensitive)) {
|
||||
role = QPalette::HighlightedText;
|
||||
} else if (!QString::compare(role_name, "Link", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Link;
|
||||
} else if (!QString::compare(role_name, "LinkVisited", Qt::CaseInsensitive)) {
|
||||
role = QPalette::LinkVisited;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else if (!QString::compare(role_name, "Text", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Text;
|
||||
} else if (!QString::compare(role_name, "Button", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Button;
|
||||
} else if (!QString::compare(role_name, "ButtonText",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::ButtonText;
|
||||
} else if (!QString::compare(role_name, "BrightText",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::BrightText;
|
||||
} else if (!QString::compare(role_name, "Highlight", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Highlight;
|
||||
} else if (!QString::compare(role_name, "HighlightedText",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::HighlightedText;
|
||||
} else if (!QString::compare(role_name, "Link", Qt::CaseInsensitive)) {
|
||||
role = QPalette::Link;
|
||||
} else if (!QString::compare(role_name, "LinkVisited",
|
||||
Qt::CaseInsensitive)) {
|
||||
role = QPalette::LinkVisited;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
palette->setColor(group, role, QColor(ini->value(role_name).toString()));
|
||||
palette->setColor(group, role, QColor(ini->value(role_name).toString()));
|
||||
}
|
||||
|
||||
void StyleManager::Init()
|
||||
{
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
|
||||
available_themes_.insert(QStringLiteral("olive-dark"), QStringLiteral("Olive Dark"));
|
||||
available_themes_.insert(QStringLiteral("olive-light"), QStringLiteral("Olive Light"));
|
||||
available_themes_.insert(QStringLiteral("olive-dark"),
|
||||
QStringLiteral("Olive Dark"));
|
||||
available_themes_.insert(QStringLiteral("olive-light"),
|
||||
QStringLiteral("Olive Light"));
|
||||
|
||||
QString config_style = OLIVE_CONFIG("Style").toString();
|
||||
QString config_style = OLIVE_CONFIG("Style").toString();
|
||||
|
||||
if (config_style.isEmpty() || !available_themes_.contains(config_style)) {
|
||||
SetStyle(kDefaultStyle);
|
||||
} else {
|
||||
SetStyle(config_style);
|
||||
}
|
||||
if (config_style.isEmpty() || !available_themes_.contains(config_style)) {
|
||||
SetStyle(kDefaultStyle);
|
||||
} else {
|
||||
SetStyle(config_style);
|
||||
}
|
||||
}
|
||||
|
||||
const QString &StyleManager::GetStyle()
|
||||
{
|
||||
return current_style_;
|
||||
return current_style_;
|
||||
}
|
||||
|
||||
void StyleManager::SetStyle(const QString &style_path)
|
||||
{
|
||||
current_style_ = style_path;
|
||||
current_style_ = style_path;
|
||||
|
||||
QString abs_style_path = QStringLiteral(":/style/%1").arg(style_path);
|
||||
QString abs_style_path = QStringLiteral(":/style/%1").arg(style_path);
|
||||
|
||||
// Load all icons for this style (icons must be loaded first because the style change below triggers the icon change)
|
||||
icon::LoadAll(abs_style_path);
|
||||
// Load all icons for this style (icons must be loaded first because the style change below triggers the icon change)
|
||||
icon::LoadAll(abs_style_path);
|
||||
|
||||
// Set palette for this
|
||||
QString palette_file = QStringLiteral("%1/palette.ini").arg(abs_style_path);
|
||||
if (QFileInfo::exists(palette_file)) {
|
||||
qApp->setPalette(ParsePalette(palette_file));
|
||||
} else {
|
||||
qApp->setPalette(qApp->style()->standardPalette());
|
||||
}
|
||||
// Set palette for this
|
||||
QString palette_file = QStringLiteral("%1/palette.ini").arg(abs_style_path);
|
||||
if (QFileInfo::exists(palette_file)) {
|
||||
qApp->setPalette(ParsePalette(palette_file));
|
||||
} else {
|
||||
qApp->setPalette(qApp->style()->standardPalette());
|
||||
}
|
||||
|
||||
// Set CSS style for this
|
||||
QFile css_file(QStringLiteral("%1/style.css").arg(abs_style_path));
|
||||
// Set CSS style for this
|
||||
QFile css_file(QStringLiteral("%1/style.css").arg(abs_style_path));
|
||||
|
||||
if (css_file.exists() && css_file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
// Read in entire CSS from file and set as the application stylesheet
|
||||
QTextStream css_ts(&css_file);
|
||||
if (css_file.exists() && css_file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
// Read in entire CSS from file and set as the application stylesheet
|
||||
QTextStream css_ts(&css_file);
|
||||
|
||||
qApp->setStyleSheet(css_ts.readAll());
|
||||
qApp->setStyleSheet(css_ts.readAll());
|
||||
|
||||
css_file.close();
|
||||
} else {
|
||||
qApp->setStyleSheet(QString());
|
||||
}
|
||||
css_file.close();
|
||||
} else {
|
||||
qApp->setStyleSheet(QString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+18
-15
@@ -26,34 +26,37 @@
|
||||
|
||||
#include "common/define.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
class StyleManager : public QObject {
|
||||
public:
|
||||
static void Init();
|
||||
static void Init();
|
||||
|
||||
static const QString& GetStyle();
|
||||
static const QString &GetStyle();
|
||||
|
||||
static void SetStyle(const QString& style_path);
|
||||
static void SetStyle(const QString &style_path);
|
||||
|
||||
static const char* kDefaultStyle;
|
||||
static const char *kDefaultStyle;
|
||||
|
||||
static const QMap<QString, QString>& available_themes()
|
||||
{
|
||||
return available_themes_;
|
||||
}
|
||||
static const QMap<QString, QString> &available_themes()
|
||||
{
|
||||
return available_themes_;
|
||||
}
|
||||
|
||||
private:
|
||||
static QPalette ParsePalette(const QString& ini_path);
|
||||
static QPalette ParsePalette(const QString &ini_path);
|
||||
|
||||
static void ParsePaletteGroup(QSettings* ini, QPalette* palette, QPalette::ColorGroup group);
|
||||
static void ParsePaletteGroup(QSettings *ini, QPalette *palette,
|
||||
QPalette::ColorGroup group);
|
||||
|
||||
static void ParsePaletteColor(QSettings* ini, QPalette* palette, QPalette::ColorGroup group, const QString& role_name);
|
||||
static void ParsePaletteColor(QSettings *ini, QPalette *palette,
|
||||
QPalette::ColorGroup group,
|
||||
const QString &role_name);
|
||||
|
||||
static QString current_style_;
|
||||
|
||||
static QMap<QString, QString> available_themes_;
|
||||
static QString current_style_;
|
||||
|
||||
static QMap<QString, QString> available_themes_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user