various UI reimplementations from 0.1.x
This commit is contained in:
@@ -123,7 +123,7 @@ QIcon olive::icon::Create(const QString& theme, const QString &name)
|
||||
QIcon icon;
|
||||
|
||||
for (int i=0;i<ICON_SIZE_COUNT;i++) {
|
||||
icon.addFile(QString(":/style/%1/png/%2.%3.png").arg(theme, name, QString::number(ICON_SIZES[i])),
|
||||
icon.addFile(QString("%1/png/%2.%3.png").arg(theme, name, QString::number(ICON_SIZES[i])),
|
||||
QSize(ICON_SIZES[i], ICON_SIZES[i]));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/style/olive-dark">
|
||||
<file>palette.ini</file>
|
||||
<file>style.css</file>
|
||||
<file>png/add-button.16.png</file>
|
||||
<file>png/add-button.32.png</file>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
[All]
|
||||
AlternateBase=#353535
|
||||
Base=#191919
|
||||
BrightText=#FF0000
|
||||
Button=#353535
|
||||
ButtonText=#FFFFFF
|
||||
Disabled-ButtonText=#808080
|
||||
Highlight=#2A82DA
|
||||
HighlightedText=#FFFFFF
|
||||
Link=#2A82DA
|
||||
Text=#FFFFFF
|
||||
ToolTipBase=#191919
|
||||
ToolTipText=#FFFFFF
|
||||
Window=#353535
|
||||
WindowText=#FFFFFF
|
||||
|
||||
[Disabled]
|
||||
ButtonText=#808080
|
||||
@@ -18,56 +18,6 @@
|
||||
|
||||
***/
|
||||
|
||||
/***
|
||||
|
||||
Olive Dark - Qt CSS Theme
|
||||
|
||||
A fairly basic CSS style for the Olive Video Editor/Qt Fusion.
|
||||
|
||||
The primary colors are:
|
||||
|
||||
Main: #353535
|
||||
Text: #ffffff
|
||||
Disabled Text: #808080
|
||||
Highlight: #2a82da
|
||||
Highlight Text: #ffffff
|
||||
Dark: #191919
|
||||
|
||||
**/
|
||||
|
||||
/* Default widget colors */
|
||||
QWidget, QMenu::separator {
|
||||
/* Main */
|
||||
background: #353535;
|
||||
|
||||
/* Text */
|
||||
color: #ffffff;
|
||||
|
||||
/* Highlight */
|
||||
selection-background-color: #2a82da;
|
||||
|
||||
/* Highlight Text */
|
||||
selection-color: #ffffff;
|
||||
}
|
||||
|
||||
/* Default disabled colors */
|
||||
QWidget::disabled {
|
||||
/* Disabled Text */
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
/* Default link color */
|
||||
a {
|
||||
/* Highlight */
|
||||
color: #2a82da;
|
||||
}
|
||||
|
||||
/* All of these widgets' backgrounds are dark */
|
||||
QTreeView, QListView, QLineEdit, QMenu, QProgressBar, QPushButton::checked, NodeView, QComboBox, QSpinBox {
|
||||
/* Dark */
|
||||
background: #191919;
|
||||
}
|
||||
|
||||
/* Node styling */
|
||||
NodeViewItemWidget {
|
||||
qproperty-titlebarColor: #4040a0;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/style/olive-light">
|
||||
<file>palette.ini</file>
|
||||
<file>style.css</file>
|
||||
<file>png/add-button.16.png</file>
|
||||
<file>png/add-button.32.png</file>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
[All]
|
||||
AlternateBase=#D0D0D0
|
||||
Base=#F0F0F0
|
||||
BrightText=#FF0000
|
||||
Button=#D0D0D0
|
||||
ButtonText=#000000
|
||||
Highlight=#2A82DA
|
||||
HighlightedText=#FFFFFF
|
||||
Link=#2A82DA
|
||||
Text=#000000
|
||||
ToolTipBase=#FFFFFF
|
||||
ToolTipText=#000000
|
||||
Window=#D0D0D0
|
||||
WindowText=#000000
|
||||
|
||||
[Disabled]
|
||||
ButtonText=#D0D0D0
|
||||
@@ -18,56 +18,6 @@
|
||||
|
||||
***/
|
||||
|
||||
/***
|
||||
|
||||
Olive Light - Qt CSS Theme
|
||||
|
||||
A fairly basic CSS style for the Olive Video Editor/Qt Fusion.
|
||||
|
||||
The primary colors are:
|
||||
|
||||
Main: #d0d0d0
|
||||
Text: #000000
|
||||
Disabled Text: #808080
|
||||
Highlight: #2a82da
|
||||
Highlight Text: #ffffff
|
||||
Dark: #ffffff
|
||||
|
||||
**/
|
||||
|
||||
/* Default widget colors */
|
||||
QWidget, QMenu::separator {
|
||||
/* Main */
|
||||
background: #d0d0d0;
|
||||
|
||||
/* Text */
|
||||
color: #000000;
|
||||
|
||||
/* Highlight */
|
||||
selection-background-color: #2a82da;
|
||||
|
||||
/* Highlight Text */
|
||||
selection-color: #ffffff;
|
||||
}
|
||||
|
||||
/* Default disabled colors */
|
||||
QWidget::disabled {
|
||||
/* Disabled Text */
|
||||
color: #808080;
|
||||
}
|
||||
|
||||
/* Default link color */
|
||||
a {
|
||||
/* Highlight */
|
||||
color: #2a82da;
|
||||
}
|
||||
|
||||
/* All of these widgets' backgrounds are dark */
|
||||
QTreeView, QListView, QLineEdit, QMenu, QProgressBar, QPushButton::checked, NodeView, QComboBox, QSpinBox {
|
||||
/* Dark */
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
/* Node styling */
|
||||
NodeViewItemWidget {
|
||||
qproperty-titlebarColor: #a0a0ff;
|
||||
|
||||
+133
-9
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QPalette>
|
||||
#include <QStyle>
|
||||
#include <QStyleFactory>
|
||||
@@ -29,28 +30,151 @@
|
||||
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
void olive::style::AppSetDefault()
|
||||
QList<StyleDescriptor> StyleManager::ListInternal()
|
||||
{
|
||||
// FIXME: Fixed theme, allow the user to set this in-app
|
||||
SetOliveStyle("olive-dark");
|
||||
QList<StyleDescriptor> style_list;
|
||||
|
||||
style_list.append(StyleDescriptor(tr("Olive Dark"), ":/style/olive-dark"));
|
||||
style_list.append(StyleDescriptor(tr("Olive Light"), ":/style/olive-light"));
|
||||
|
||||
return style_list;
|
||||
}
|
||||
|
||||
void olive::style::SetOliveStyle(const QString &style_name)
|
||||
QPalette StyleManager::ParsePalette(const QString& ini_path)
|
||||
{
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
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);
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
void StyleManager::ParsePaletteGroup(QSettings *ini, QPalette *palette, QPalette::ColorGroup group)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
ini->beginGroup(group_name);
|
||||
|
||||
QStringList keys = ini->childKeys();
|
||||
foreach (QString k, keys) {
|
||||
ParsePaletteColor(ini, palette, group, k);
|
||||
}
|
||||
|
||||
ini->endGroup();
|
||||
}
|
||||
|
||||
void StyleManager::ParsePaletteColor(QSettings *ini, QPalette *palette, QPalette::ColorGroup group, const QString &role_name)
|
||||
{
|
||||
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;
|
||||
} else if (!QString::compare(role_name, "PlaceholderText", Qt::CaseInsensitive)) {
|
||||
role = QPalette::PlaceholderText;
|
||||
} 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()));
|
||||
}
|
||||
|
||||
StyleDescriptor StyleManager::DefaultStyle()
|
||||
{
|
||||
return ListInternal().first();
|
||||
}
|
||||
|
||||
void StyleManager::SetStyle(const StyleDescriptor &style)
|
||||
{
|
||||
SetStyle(style.path());
|
||||
}
|
||||
|
||||
void StyleManager::SetStyle(const QString &style_path)
|
||||
{
|
||||
// Load all icons for this style (icons must be loaded first because the style change below triggers the icon change)
|
||||
olive::icon::LoadAll(style_path);
|
||||
|
||||
// Set palette for this
|
||||
QString palette_file = QString("%1/palette.ini").arg(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(QString(":/style/%1/style.css").arg(style_name));
|
||||
QFile css_file(QString("%1/style.css").arg(style_path));
|
||||
|
||||
if (css_file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
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());
|
||||
|
||||
css_file.close();
|
||||
} else {
|
||||
qApp->setStyleSheet(QString());
|
||||
}
|
||||
}
|
||||
|
||||
// Load all icons for this style
|
||||
olive::icon::LoadAll(style_name);
|
||||
StyleDescriptor::StyleDescriptor(const QString &name, const QString &path) :
|
||||
name_(name),
|
||||
path_(path)
|
||||
{
|
||||
}
|
||||
|
||||
const QString &StyleDescriptor::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
const QString &StyleDescriptor::path() const
|
||||
{
|
||||
return path_;
|
||||
}
|
||||
|
||||
+29
-13
@@ -21,23 +21,39 @@
|
||||
#ifndef STYLEMANAGER_H
|
||||
#define STYLEMANAGER_H
|
||||
|
||||
#include <QSettings>
|
||||
#include <QWidget>
|
||||
|
||||
namespace olive {
|
||||
namespace style {
|
||||
class StyleDescriptor {
|
||||
public:
|
||||
StyleDescriptor(const QString& name, const QString& path);
|
||||
|
||||
/**
|
||||
* @brief Sets the application style to "Olive Default"
|
||||
*
|
||||
* This function should probably be replaced (or at least renamed) later as alternative styles are reimplemented.
|
||||
* At the moment, this is a convenience function for setting to "Olive Default" which is a cross-platform default
|
||||
* style used in Olive.
|
||||
*/
|
||||
void AppSetDefault();
|
||||
const QString& name() const;
|
||||
const QString& path() const;
|
||||
|
||||
void SetOliveStyle(const QString& style_name);
|
||||
private:
|
||||
QString name_;
|
||||
QString path_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
class StyleManager : public QObject {
|
||||
public:
|
||||
StyleManager();
|
||||
|
||||
static StyleDescriptor DefaultStyle();
|
||||
|
||||
static void SetStyle(const StyleDescriptor& style);
|
||||
|
||||
static void SetStyle(const QString& style_path);
|
||||
|
||||
static QList<StyleDescriptor> ListInternal();
|
||||
|
||||
private:
|
||||
static QPalette ParsePalette(const QString& ini_path);
|
||||
|
||||
static void ParsePaletteGroup(QSettings* ini, QPalette* palette, QPalette::ColorGroup group);
|
||||
|
||||
static void ParsePaletteColor(QSettings* ini, QPalette* palette, QPalette::ColorGroup group, const QString& role_name);
|
||||
};
|
||||
|
||||
#endif // STYLEMANAGER_H
|
||||
|
||||
Reference in New Issue
Block a user