Skip to content
Permalink
Browse files

Pass on the theme style data directly instead of a file:///...

Benefit: remove requirement to have write permission for the
theme directory.
  • Loading branch information
nirvn committed Dec 20, 2018
1 parent c339c36 commit d7aa980889083620fe2071389afb8e3fc88e33a2
Showing with 19 additions and 25 deletions.
  1. +9 −9 resources/themes/Night Mapping/style.qss
  2. +10 −16 src/core/qgsapplication.cpp
@@ -60,15 +60,15 @@ QAbstractSpinBox {
subcontrol-position: top right;

width: 16px;
image: url(icons/up_arrow.png) 1;
image: url(@theme_path/icons/up_arrow.png) 1;
}

QAbstractSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right;

width: 16px;
image: url(icons/down_arrow.png);
image: url(@theme_path/icons/down_arrow.png);
}


@@ -159,7 +159,7 @@ QToolButton::hover, QToolButton::menu-button::hover
}
QToolButton::menu-arrow
{
image: url(icons/down_arrow.png);
image: url(@theme_path/icons/down_arrow.png);
}
QToolBar QToolButton, QToolButton::menu-button
{
@@ -219,7 +219,7 @@ QComboBox::drop-down {

QComboBox::down-arrow
{
image: url(icons/down_arrow.png);
image: url(@theme_path/icons/down_arrow.png);
}


@@ -298,7 +298,7 @@ QHeaderView::section
}
QDockWidget
{
titlebar-close-icon: url(icons/cross.svg);
titlebar-close-icon: url(@theme_path/icons/cross.svg);
}

QDockWidget::separator
@@ -566,13 +566,13 @@ QTreeView::item:selected, QTreeView::branch:selected {
QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings {
border-image: none;
image: url(icons/caret-right_ffffff_14.png);
image: url(@theme_path/icons/caret-right_ffffff_14.png);
}

QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings {
border-image: none;
image: url(icons/caret-down_ffffff_14.png);
image: url(@theme_path/icons/caret-down_ffffff_14.png);
}

QgsLayerTreeView
@@ -594,15 +594,15 @@ QTreeView#viewGraduated::indicator:unchecked,
QTreeView#viewCategories::indicator:unchecked,
QTreeView#viewRules::indicator:unchecked
{
image: url(icons/eye-blocked.svg);
image: url(@theme_path/icons/eye-blocked.svg);
}

QgsLayerTreeView::indicator:checked,
QTreeView#viewGraduated::indicator:checked,
QTreeView#viewCategories::indicator:checked,
QTreeView#viewRules::indicator:checked
{
image: url(icons/eye.svg);
image: url(@theme_path/icons/eye.svg);
}

/* ==================================================================================== */
@@ -724,22 +724,22 @@ void QgsApplication::setUITheme( const QString &themeName )

QString path = themes.value( themeName );
QString stylesheetname = path + "/style.qss";
QString autostylesheet = stylesheetname + ".auto";

QFile file( stylesheetname );
QFile variablesfile( path + "/variables.qss" );
QFile fileout( autostylesheet );

QFileInfo variableInfo( variablesfile );

if ( variableInfo.exists() && variablesfile.open( QIODevice::ReadOnly ) )
if ( !file.open( QIODevice::ReadOnly ) || ( variableInfo.exists() && !variablesfile.open( QIODevice::ReadOnly ) ) )
{
if ( !file.open( QIODevice::ReadOnly ) || !fileout.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
{
return;
}
return;
}

QString styledata = file.readAll();
styledata.replace( QStringLiteral( "@theme_path" ), path );

QString styledata = file.readAll();
if ( variableInfo.exists() )
{
QTextStream in( &variablesfile );
while ( !in.atEnd() )
{
@@ -754,16 +754,10 @@ void QgsApplication::setUITheme( const QString &themeName )
}
}
variablesfile.close();
QTextStream out( &fileout );
out << styledata;
fileout.close();
file.close();
stylesheetname = autostylesheet;
}
file.close();

QString styleSheet = QStringLiteral( "file:///" );
styleSheet.append( stylesheetname );
qApp->setStyleSheet( styleSheet );
qApp->setStyleSheet( styledata );
setThemeName( themeName );
}

0 comments on commit d7aa980

Please sign in to comment.
You can’t perform that action at this time.