Commit 2d72e364 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

StyleSheet automatically created.

parent 20cde100
......@@ -11,6 +11,136 @@
void UILoadApplicationStyle( QApplication &app, QSettings *userSettings )
{
app.setFont( QFont("Calibri",9) );
QPalette palette = app.palette();
for( int i=0; i<3; i+=2 )
{
palette.setColor( (QPalette::ColorGroup)i, QPalette::Window , QColor( 64, 64, 72) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::WindowText , QColor(160,192,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Text , QColor(160,192,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::BrightText , QColor(200,230,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::ButtonText , QColor(200,230,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Button , QColor( 48, 48, 64) );
//palette.setColor( (QPalette::ColorGroup)i, QPalette::ToolTipText, QColor(220,220,255) );
//palette.setColor( (QPalette::ColorGroup)i, QPalette::HighlightedText, QColor(220,220,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Shadow , QColor( 0, 0, 0) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Base , QColor( 48, 48, 64) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Dark , QColor( 32, 32, 48) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Mid , QColor( 56, 56, 80) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Light , QColor( 96, 96,112) );
}
app.setPalette( palette );
//if( !userSettings->contains("uiStyle") )
{
qDebug() << "Generating default UI style sheet...";
// Create the directory where to store the new style generated files.
QString styleBasePath = QFileInfo(userSettings->fileName()).absolutePath() + "/styles/iron/";
QDir().mkpath( styleBasePath );
// Load the template CSS file from resources.
QFile cssTemplate( ":/style/Default.css" );
cssTemplate.open( QIODevice::ReadOnly | QIODevice::Text );
QString styleSheetTemplate = QTextStream(&cssTemplate).readAll();
// Parse the template file to collect every occurrence of pattern "[IconImageName:PaletteColorName]".
QMap<QString, QSet<QString>> foundIcons;
QRegExp expIconId( "\\[([^\\]\\:]+)\\:([^\\]\\:]+)\\]" );
int found = 0;
while( (found = expIconId.indexIn( styleSheetTemplate, found )) > -1 )
{
foundIcons[ expIconId.cap(1) ].insert( expIconId.cap(2) );
found += expIconId.matchedLength();
}
// Create a dictionary to map every palette color name to the corresponding QColor.
QMap<QString,QColor> colorDict;
colorDict["window" ] = palette.color( QPalette::Active, QPalette::Window );
colorDict["window-text"] = palette.color( QPalette::Active, QPalette::WindowText );
colorDict["text" ] = palette.color( QPalette::Active, QPalette::Text );
colorDict["bright-text"] = palette.color( QPalette::Active, QPalette::BrightText );
colorDict["button-text"] = palette.color( QPalette::Active, QPalette::ButtonText );
colorDict["button" ] = palette.color( QPalette::Active, QPalette::Button );
colorDict["shadow" ] = palette.color( QPalette::Active, QPalette::Shadow );
colorDict["base" ] = palette.color( QPalette::Active, QPalette::Base );
colorDict["dark" ] = palette.color( QPalette::Active, QPalette::Dark );
colorDict["mid" ] = palette.color( QPalette::Active, QPalette::Mid );
colorDict["light" ] = palette.color( QPalette::Active, QPalette::Light );
//Midlight
//Highlight, HighlightedText,
//Link, LinkVisited,
//AlternateBase,
//ToolTipBase, ToolTipText,
// For each pair [IconImageName:PaletteColorName] found in the template, generate the corresponding icon image.
for( auto iconDesc=foundIcons.begin(); iconDesc!=foundIcons.end(); ++iconDesc )
{
// Load the template alpha mask image from resources.
QImage alphaMask( ":/style/"+iconDesc.key()+".png" );
// Create a new image corresponding to this mask for each of the required colors.
QImage icon( alphaMask.width(), alphaMask.height(), QImage::Format_RGBA8888 );
for( auto colorName=iconDesc.value().begin(); colorName!=iconDesc.value().end(); ++colorName )
{
// Update pixel color values.
QColor c = colorDict[ *colorName ];
for( int y=0; y<alphaMask.height(); ++y )
for( int x=0; x<alphaMask.width(); ++x )
{
c.setAlpha( alphaMask.pixelColor(x,y).alpha() );
icon.setPixelColor( x,y, c );
}
// Save the icon to the style destination directory.
QString iconFilePath = styleBasePath + iconDesc.key() + "_" + *colorName + ".png";
icon.save( iconFilePath );
// Replace pattern occurrences in the template CSS by the icon file path.
styleSheetTemplate.replace( "["+iconDesc.key()+":"+*colorName+"]", iconFilePath );
}
}
// Store the modified CSS template to the style destination directory.
QString cssFileName = styleBasePath + "Style.css";
QFile cssFile( cssFileName );
cssFile.open( QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text );
QTextStream(&cssFile) << styleSheetTemplate;
cssFile.close();
// Update the settings file to set the new created style as the current one.
userSettings->setValue( "uiStyle", QVariant(cssFileName) );
}
QFile cssFile( userSettings->value("uiStyle").toString() );
if( cssFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
app.setStyleSheet( QTextStream(&cssFile).readAll() );
cssFile.close();
}
}
#ifdef _WIN32
/*
......
......@@ -16,6 +16,9 @@
#include "UIMainWindow.h"
GUIMAIN_API void UILoadApplicationStyle( QApplication &app, QSettings *userSettings );
template <typename UIMainWindowT>
int UILaunch( int argc, char **argv )
{
......@@ -43,40 +46,13 @@ int UILaunch( int argc, char **argv )
QApplication::setAttribute( Qt::AA_ShareOpenGLContexts, true );
QApplication app( argc, argv );
app.setFont( QFont("Calibri",9) );
QPalette palette = app.palette();
for( int i=0; i<3; i+=2 )
{
palette.setColor( (QPalette::ColorGroup)i, QPalette::Window , QColor( 64, 64, 72) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::WindowText , QColor(160,192,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Text , QColor(160,192,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::BrightText , QColor(200,230,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::ButtonText , QColor(200,230,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Button , QColor( 48, 48, 64) );
//palette.setColor( (QPalette::ColorGroup)i, QPalette::ToolTipText, QColor(220,220,255) );
//palette.setColor( (QPalette::ColorGroup)i, QPalette::HighlightedText, QColor(220,220,255) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Shadow , QColor( 0, 0, 0) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Base , QColor( 48, 48, 64) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Dark , QColor( 32, 32, 48) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Mid , QColor( 56, 56, 80) );
palette.setColor( (QPalette::ColorGroup)i, QPalette::Light , QColor( 96, 96,112) );
}
app.setPalette( palette );
QFile cssFile( ":/style/Default.css" );
if( cssFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
app.setStyleSheet( QTextStream(&cssFile).readAll() );
cssFile.close();
}
UIMainWindow *mainWin = new UIMainWindowT(); // Use default GUI main window.
mainWin->onInitializingApp();
mainWin->init();
UILoadApplicationStyle( app, mainWin->getUserSettings() );
mainWin->show();
int appRetVal = app.exec();
......
......@@ -80,8 +80,7 @@ bool UIMainWindow::loadUISettings()
// Load geometry and state of the main window and the dock widgets.
if( settings->value("geometry" ).toByteArray().isEmpty() ||
settings->value("windowState").toByteArray().isEmpty() )
if( !settings->contains("geometry") || !settings->contains("windowState") )
return false;
restoreGeometry( settings->value("geometry" ).toByteArray() );
......
......@@ -101,6 +101,7 @@ public:
virtual void applicationInfo( QString &compagnyName, QString &applicationName, QString &shortDescription ) const = 0;
virtual QString projectFileExtension() const = 0;
inline QSettings* getUserSettings() const { return m_UserSettings; }
inline QString getUserSettingsPath() const { return QFileInfo(m_UserSettings->fileName()).absolutePath(); }
virtual void onInitializingApp() {}
virtual void onReleasingApp() {}
......
......@@ -28,7 +28,10 @@
</qresource>
<qresource prefix="/style">
<file alias="Default.css">resources/style/Default.css</file>
<file>resources/style/QCheckBox.png</file>
<file>resources/style/QRadioButton.png</file>
<file alias="QCheckBox.png">resources/style/QCheckBox.png</file>
<file alias="QRadioButton.png">resources/style/QRadioButton.png</file>
<file alias="QHeaderViewUpArrow.png">resources/style/QHeaderViewUpArrow.png</file>
<file alias="QHeaderViewDownArrow.png">resources/style/QHeaderViewDownArrow.png</file>
<file alias="QTreeViewIndicatorEye.png">resources/style/QTreeViewIndicatorEye.png</file>
</qresource>
</RCC>
......@@ -4,19 +4,20 @@ QPushButton[flat="false"], QScrollBar::handle, QToolTip, QHeaderView::section
border-right : 1px solid palette(shadow);
border-bottom: 1px solid palette(shadow);
border-left : 1px solid palette(light);
border-radius: 3px;
}
QPushButton[flat="false"]:pressed, QComboBox, QLineEdit, QSpinBox, QDoubleSpinBox, QCheckBox::indicator, QRadioButton::indicator, QSlider::groove:horizontal, QHeaderView::section:pressed, QTreeView::indicator
QPushButton[flat="false"]:pressed, QComboBox, QLineEdit, QSpinBox, QDoubleSpinBox, QCheckBox::indicator, QRadioButton::indicator, QSlider::groove:horizontal, QHeaderView::section:pressed, QTreeView, QTreeView::indicator, QTableView, QTableView::indicator, QListView, QListView::indicator
{
border-top : 1px solid palette(shadow);
border-right : 1px solid palette(light);
border-bottom: 1px solid palette(light);
border-left : 1px solid palette(shadow);
border-radius: 3px;
}
QPushButton[flat="false"]
{
color: palette(text);
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 palette(window), stop: 0.35 palette(light), stop: 0.75 palette(base));
border-radius: 3px;
padding: 4 20 4 20;
}
QPushButton[flat="false"]:hover
......@@ -49,9 +50,8 @@ QGroupBox#UIParamChoice
QComboBox, QLineEdit, QSpinBox, QDoubleSpinBox
{
color: palette(bright-text);
border-radius: 3px;
}
QComboBox:disabled, QLineEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled, QCheckBox::indicator:disabled, QRadioButton::indicator:disabled, QGroupBox:disabled, QGroupBox#UIParamChoice:disabled
QComboBox:disabled, QLineEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled, QCheckBox::indicator:disabled, QRadioButton::indicator:disabled, QGroupBox:disabled, QGroupBox#UIParamChoice:disabled, QSlider::groove:horizontal:disabled
{
color: palette(base);
border-color: palette(dark);
......@@ -61,7 +61,7 @@ QComboBox, QLineEdit
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 palette(dark), stop:0.3 palette(base));
}
QComboBox::hover, QLineEdit::hover
QComboBox:hover, QLineEdit:hover
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 palette(dark), stop:0.3 palette(mid));
}
......@@ -71,26 +71,29 @@ QSpinBox, QDoubleSpinBox
{
background-color: palette(base);
}
QSpinBox::hover, QDoubleSpinBox::hover
QSpinBox:hover, QDoubleSpinBox:hover
{
background-color: palette(mid);
}
QCheckBox::indicator, QTreeView::indicator
QCheckBox::indicator, QTreeView::indicator, QTableView::indicator, QListView::indicator
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 palette(dark), stop:0.3 palette(base));
border-radius: 3px;
width: 20px;
height: 20px;
}
QCheckBox::indicator::hover
QCheckBox::indicator:hover, QTreeView::indicator:hover, QTableView::indicator:hover, QListView::indicator:hover
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 palette(dark), stop:0.3 palette(mid));
}
QCheckBox::indicator:checked, QTreeView::indicator:checked
QCheckBox::indicator:checked, QTreeView::indicator:checked, QTableView::indicator:checked, QListView::indicator:checked
{
image: url(D:/Development/ExRealis/ExRealisGUI-build/Release/themes/QCheckBox.png);
image: url([QCheckBox:bright-text]);
}
QCheckBox::indicator:checked:disabled, QTreeView::indicator:checked:disabled, QTableView::indicator:checked:disabled, QListView::indicator:checked:disabled
{
image: url([QCheckBox:base]);
}
......@@ -98,33 +101,37 @@ QRadioButton
{
height: 23px;
}
QRadioButton:hover
{
color: palette(bright-text);
}
QRadioButton::indicator
{
background-color: qradialgradient(cx:0.75, cy:1, radius:1, fx:0.5, fy:0.5 stop:0 palette(base), stop:0.85 palette(dark));
border-radius: 10px;
border-radius: 9px;
width: 18px;
height: 18px;
}
QRadioButton::indicator::hover
QRadioButton::indicator:hover
{
background-color: qradialgradient(cx:0.75, cy:1, radius:1, fx:0.5, fy:0.5 stop:0 palette(mid), stop:0.85 palette(dark));
}
QRadioButton::indicator:checked
QRadioButton::indicator:checked, QSlider::handle:horizontal, QSlider::handle:vertical
{
image: url([QRadioButton:bright-text]);
}
QRadioButton::indicator:checked:disabled, QSlider::handle:horizontal:disabled, QSlider::handle:vertical:disabled
{
image: url(D:/Development/ExRealis/ExRealisGUI-build/Release/themes/QRadioButton.png);
image: url([QRadioButton:base]);
}
QSlider::groove:horizontal
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 palette(dark), stop:0.3 palette(mid));
border-radius: 10px;
border-radius: 9px;
height: 18px;
}
QSlider::handle:horizontal, QSlider::handle:vertical
{
image: url(D:/Development/ExRealis/ExRealisGUI-build/Release/themes/QRadioButton.png);
}
QScrollBar
......@@ -150,11 +157,19 @@ QScrollBar::handle:horizontal
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 palette(window), stop: 0.35 palette(light), stop: 0.75 palette(base));
min-height: 20px;
}
QScrollBar::handle:horizontal:hover
{
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 palette(window), stop: 0.35 palette(light), stop: 0.75 palette(mid));
}
QScrollBar::handle:vertical
{
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 palette(window), stop: 0.35 palette(light), stop: 0.75 palette(base));
min-width: 20px;
}
QScrollBar::handle:vertical:hover
{
background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 palette(window), stop: 0.35 palette(light), stop: 0.75 palette(mid));
}
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal, QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical
{
background:none;
......@@ -184,8 +199,13 @@ QToolBar
QMenu
{
border: 1px solid black;
background-color: palette(base);
border: 1px solid black;
border-top: 0;
border-top-right-radius : 0;
border-top-left-radius : 0;
border-bottom-right-radius: 3;
border-bottom-left-radius : 3;
}
QMenu::item
{
......@@ -202,17 +222,34 @@ QToolTip
{
color: palette(text);
background-color: palette(base);
border-radius: 3px;
}
QTreeWidget
QTreeView
{
color: palette(text);
background-color: palette(base);
selection-color: palette(bright-text);
}
QTreeView::item:selected
{
background-color: palette(light);
}
QTreeView#tableCurrentProjContent::indicator
{
border: 0;
background-color: rgba(0,0,0,0);
width : 20px;
height: 20px;
image: url([QTreeViewIndicatorEye:bright-text]);
}
QTreeView#tableCurrentProjContent::indicator:unchecked
{
image: url([QTreeViewIndicatorEye:dark]);
}
QHeaderView::section
{
padding-left: 10px;
color: palette(text);
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 palette(window), stop: 0.35 palette(light), stop: 0.75 palette(base));
}
......@@ -223,7 +260,15 @@ QHeaderView::section:hover
}
QHeaderView::up-arrow, QHeaderView::down-arrow
{
image: url(D:/Development/ExRealis/ExRealisGUI-build/Release/themes/QRadioButton.png);
subcontrol-origin: margin;
subcontrol-position: right center;
right: 10px;
}
QHeaderView::up-arrow
{
image: url([QHeaderViewUpArrow:bright-text]);
}
QHeaderView::down-arrow
{
image: url([QHeaderViewDownArrow:bright-text]);
}
GUI_main/resources/style/QCheckBox.png

1.06 KB | W: | H:

GUI_main/resources/style/QCheckBox.png

272 Bytes | W: | H:

GUI_main/resources/style/QCheckBox.png
GUI_main/resources/style/QCheckBox.png
GUI_main/resources/style/QCheckBox.png
GUI_main/resources/style/QCheckBox.png
  • 2-up
  • Swipe
  • Onion skin
GUI_main/resources/style/QRadioButton.png

2.25 KB | W: | H:

GUI_main/resources/style/QRadioButton.png

288 Bytes | W: | H:

GUI_main/resources/style/QRadioButton.png
GUI_main/resources/style/QRadioButton.png
GUI_main/resources/style/QRadioButton.png
GUI_main/resources/style/QRadioButton.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -19,7 +19,8 @@ UIParamChoice::UIParamChoice( const QString& id,
: UIParam(id,name,description)
{
QGridLayout *l = new QGridLayout();
l->setSpacing( 0 );
l->setHorizontalSpacing( 6 );
l->setVerticalSpacing ( 0 );
if( name.isNull() || name.isEmpty() )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment