Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

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

New template CSS processing.

- Allow palette color from "Inactive" and "Disabled" color groups.
- Allow shadowed icons.
parent aaab065c
......@@ -12,10 +12,11 @@ file( GLOB LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h )
file( GLOB LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp )
file( GLOB LIB_UI_FORMS ${CMAKE_CURRENT_SOURCE_DIR}/*.ui )
file( GLOB LIB_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.qrc )
generate_resource_solution_folders( ${LIB_RESOURCES} ALL_RESOURCE_FILES )
qt5_wrap_ui( LIB_FORM_HEADERS ${LIB_UI_FORMS} )
add_library( ${CURRENT_TARGET} SHARED ${LIB_HEADERS} ${LIB_SOURCES} ${LIB_UI_FORMS} ${LIB_FORM_HEADERS} ${LIB_RESOURCES} )
add_library( ${CURRENT_TARGET} SHARED ${LIB_HEADERS} ${LIB_SOURCES} ${LIB_UI_FORMS} ${LIB_FORM_HEADERS} ${LIB_RESOURCES} ${ALL_RESOURCE_FILES} )
include_directories( ${CMAKE_BINARY_DIR}/GUI_main )
......
......@@ -35,6 +35,9 @@ void UILoadApplicationStyle( QApplication &app, QSettings *userSettings )
}
app.setPalette( palette );
palette.setColor( QPalette::Disabled, QPalette::Base , QColor( 48, 48, 64) );
palette.setColor( QPalette::Disabled, QPalette::Shadow , QColor( 48, 48, 64) );
//if( !userSettings->contains("uiStyle") )
{
......@@ -52,37 +55,56 @@ QString styleBasePath = QFileInfo(QApplication::applicationFilePath()).absoluteP
cssTemplate.open( QIODevice::ReadOnly | QIODevice::Text );
QString styleSheetTemplate = QTextStream(&cssTemplate).readAll();
// Create a dictionary to map every palette color name to the corresponding QColor.
QPalette::ColorGroup colorGroup[] = { QPalette::Active, QPalette::Disabled, QPalette::Inactive };
QString colorGroupPrefix[] = { "active_", "disabled_", "inactive_" };
QMap<QString,QColor> colorDict;
for( int i=0; i<3; ++i )
{
colorDict[ colorGroupPrefix[i]+"window" ] = palette.color( colorGroup[i], QPalette::Window );
colorDict[ colorGroupPrefix[i]+"window-text" ] = palette.color( colorGroup[i], QPalette::WindowText );
colorDict[ colorGroupPrefix[i]+"text" ] = palette.color( colorGroup[i], QPalette::Text );
colorDict[ colorGroupPrefix[i]+"bright-text" ] = palette.color( colorGroup[i], QPalette::BrightText );
colorDict[ colorGroupPrefix[i]+"button" ] = palette.color( colorGroup[i], QPalette::Button );
colorDict[ colorGroupPrefix[i]+"button-text" ] = palette.color( colorGroup[i], QPalette::ButtonText );
colorDict[ colorGroupPrefix[i]+"shadow" ] = palette.color( colorGroup[i], QPalette::Shadow );
colorDict[ colorGroupPrefix[i]+"base" ] = palette.color( colorGroup[i], QPalette::Base );
colorDict[ colorGroupPrefix[i]+"alternate-base" ] = palette.color( colorGroup[i], QPalette::AlternateBase );
colorDict[ colorGroupPrefix[i]+"dark" ] = palette.color( colorGroup[i], QPalette::Dark );
colorDict[ colorGroupPrefix[i]+"mid" ] = palette.color( colorGroup[i], QPalette::Mid );
colorDict[ colorGroupPrefix[i]+"midlight" ] = palette.color( colorGroup[i], QPalette::Midlight );
colorDict[ colorGroupPrefix[i]+"light" ] = palette.color( colorGroup[i], QPalette::Light );
colorDict[ colorGroupPrefix[i]+"highlight" ] = palette.color( colorGroup[i], QPalette::Highlight );
colorDict[ colorGroupPrefix[i]+"highlighted-text" ] = palette.color( colorGroup[i], QPalette::HighlightedText );
colorDict[ colorGroupPrefix[i]+"link" ] = palette.color( colorGroup[i], QPalette::Link );
colorDict[ colorGroupPrefix[i]+"link-visited" ] = palette.color( colorGroup[i], QPalette::LinkVisited );
}
// Parse the template file to collect every occurrence of pattern "[IconImageName:PaletteColorName]".
QMap<QString, QSet<QString>> foundIcons;
QRegExp expIconId( "\\[([^\\]\\:]+)\\:([^\\]\\:]+)\\]" );
QRegExp expIconId( "\\[([^\\]\\:]+)\\:([^\\]\\:]+)(\\:([^\\]\\:]+))?\\]" );
int found = 0;
while( (found = expIconId.indexIn( styleSheetTemplate, found )) > -1 )
{
foundIcons[ expIconId.cap(1) ].insert( expIconId.cap(2) );
found += expIconId.matchedLength();
}
QString colorDesc;
if( expIconId.cap(4).isEmpty() )
colorDesc = colorGroupPrefix[0] + expIconId.cap(2);
else
colorDesc = expIconId.cap(2) + "_" + expIconId.cap(4);
// Create a dictionary to map every palette color name to the corresponding QColor.
if( !colorDict.contains(colorDesc) )
{
qDebug() << __FUNCTION__ << ": Parse error.";
return;
}
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" ] = palette.color( QPalette::Active, QPalette::Button );
colorDict["button-text" ] = palette.color( QPalette::Active, QPalette::ButtonText );
colorDict["shadow" ] = palette.color( QPalette::Active, QPalette::Shadow );
colorDict["base" ] = palette.color( QPalette::Active, QPalette::Base );
colorDict["alternate-base" ] = palette.color( QPalette::Active, QPalette::AlternateBase );
colorDict["dark" ] = palette.color( QPalette::Active, QPalette::Dark );
colorDict["mid" ] = palette.color( QPalette::Active, QPalette::Mid );
colorDict["midlight" ] = palette.color( QPalette::Active, QPalette::Midlight );
colorDict["light" ] = palette.color( QPalette::Active, QPalette::Light );
colorDict["highlight" ] = palette.color( QPalette::Active, QPalette::Highlight );
colorDict["highlighted-text"] = palette.color( QPalette::Active, QPalette::HighlightedText );
colorDict["link" ] = palette.color( QPalette::Active, QPalette::Link );
colorDict["link-visited" ] = palette.color( QPalette::Active, QPalette::LinkVisited );
foundIcons[ expIconId.cap(1) ].insert( colorDesc );
found += expIconId.matchedLength();
}
// For each pair [IconImageName:PaletteColorName] found in the template, generate the corresponding icon image.
......@@ -101,11 +123,17 @@ QString styleBasePath = QFileInfo(QApplication::applicationFilePath()).absoluteP
// Update pixel color values.
QColor c = colorDict[ *colorName ];
QColor s = colorDict[ colorName->split('_').first() + "_shadow" ];
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 );
float l = alphaMask.pixelColor(x,y).redF();
int a = alphaMask.pixelColor(x,y).alpha();
QColor color( l*c.red () + (1.0f-l)*s.red (),
l*c.green() + (1.0f-l)*s.green(),
l*c.blue () + (1.0f-l)*s.blue (),
a );
icon.setPixelColor( x,y, color );
}
// Save the icon to the style destination directory.
......@@ -115,7 +143,11 @@ QString styleBasePath = QFileInfo(QApplication::applicationFilePath()).absoluteP
// Replace pattern occurrences in the template CSS by the icon file path.
styleSheetTemplate.replace( "["+iconDesc.key()+":"+*colorName+"]", iconFilePath );
QString colorDesc = *colorName;
colorDesc.replace( "_", ":" );
styleSheetTemplate.replace( "["+iconDesc.key()+":"+colorDesc+"]", iconFilePath );
styleSheetTemplate.replace( "["+iconDesc.key()+":"+colorDesc.split(':').last()+"]", iconFilePath );
}
}
......
......@@ -93,7 +93,7 @@ QCheckBox::indicator:checked, QTreeView::indicator:checked, QTableView::indicato
}
QCheckBox::indicator:checked:disabled, QTreeView::indicator:checked:disabled, QTableView::indicator:checked:disabled, QListView::indicator:checked:disabled
{
image: url([QCheckBox:base]);
image: url([QCheckBox:disabled:base]);
}
......@@ -254,6 +254,10 @@ QTreeView#tableCurrentProjContent::indicator:unchecked
{
image: url([QTreeViewIndicatorEye:dark]);
}
QTreeView#tableCurrentProjContent::indicator:unchecked:hover
{
image: url([QTreeViewIndicatorEye:light]);
}
QHeaderView::section
{
padding: 0 10px 0 10px;
......
GUI_main/resources/style/QCheckBox.png

272 Bytes | W: | H:

GUI_main/resources/style/QCheckBox.png

7.46 KB | 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
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