Add UI theme support.

- Add dark theme (Night Mapping)
- Themes loaded from resources\themes and ~\.qgis2\themes
- Themes need folder + style.qss
This commit is contained in:
Nathan Woodrow 2015-08-28 11:41:57 +10:00
parent 4ad6168989
commit da3f7beeb0
17 changed files with 869 additions and 262 deletions

View File

@ -189,6 +189,12 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
//! default theme if the active theme does not have the required icon.
static QPixmap getThemePixmap( const QString &theName );
static const QHash<QString, QString> uiThemes();
static void setUITheme( const QString &themeName );
static const QString uiThemeName();
//! Returns the path to user's style.
static const QString userStyleV2Path();

View File

@ -1,6 +1,7 @@
INSTALL(FILES srs.db qgis.db symbology-ng-style.db spatialite.db customization.xml
DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY cpt-city-qgis-min DESTINATION ${QGIS_DATA_DIR}/resources)
INSTALL(DIRECTORY themes DESTINATION ${QGIS_DATA_DIR}/resources)
ADD_SUBDIRECTORY(context_help)
ADD_SUBDIRECTORY(function_help)

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generated by IcoMoon.io -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
viewBox="0 0 32 32"
id="svg2"
inkscape:version="0.48.5 r10040"
sodipodi:docname="cross.svg">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#000000"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1166"
inkscape:window-height="781"
id="namedview6"
showgrid="false"
inkscape:zoom="7.375"
inkscape:cx="16"
inkscape:cy="16"
inkscape:window-x="2297"
inkscape:window-y="104"
inkscape:window-maximized="0"
inkscape:current-layer="svg2"
inkscape:showpageshadow="true"
showborder="true" />
<path
d="M31.708 25.708c-0-0-0-0-0-0l-9.708-9.708 9.708-9.708c0-0 0-0 0-0 0.105-0.105 0.18-0.227 0.229-0.357 0.133-0.356 0.057-0.771-0.229-1.057l-4.586-4.586c-0.286-0.286-0.702-0.361-1.057-0.229-0.13 0.048-0.252 0.124-0.357 0.228 0 0-0 0-0 0l-9.708 9.708-9.708-9.708c-0-0-0-0-0-0-0.105-0.104-0.227-0.18-0.357-0.228-0.356-0.133-0.771-0.057-1.057 0.229l-4.586 4.586c-0.286 0.286-0.361 0.702-0.229 1.057 0.049 0.13 0.124 0.252 0.229 0.357 0 0 0 0 0 0l9.708 9.708-9.708 9.708c-0 0-0 0-0 0-0.104 0.105-0.18 0.227-0.229 0.357-0.133 0.355-0.057 0.771 0.229 1.057l4.586 4.586c0.286 0.286 0.702 0.361 1.057 0.229 0.13-0.049 0.252-0.124 0.357-0.229 0-0 0-0 0-0l9.708-9.708 9.708 9.708c0 0 0 0 0 0 0.105 0.105 0.227 0.18 0.357 0.229 0.356 0.133 0.771 0.057 1.057-0.229l4.586-4.586c0.286-0.286 0.362-0.702 0.229-1.057-0.049-0.13-0.124-0.252-0.229-0.357z"
id="path4"
style="fill:#ffffff"
/>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generated by IcoMoon.io -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
viewBox="0 0 32 32"
id="svg2"
inkscape:version="0.48.5 r10040"
sodipodi:docname="eye-blocked.svg">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1017"
id="namedview10"
showgrid="false"
inkscape:zoom="7.375"
inkscape:cx="-5.1525424"
inkscape:cy="16"
inkscape:window-x="1912"
inkscape:window-y="1"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<path
fill="#444444"
d="M29.561 0.439c-0.586-0.586-1.535-0.586-2.121 0l-6.318 6.318c-1.623-0.492-3.342-0.757-5.122-0.757-6.979 0-13.028 4.064-16 10 1.285 2.566 3.145 4.782 5.407 6.472l-4.968 4.968c-0.586 0.586-0.586 1.535 0 2.121 0.293 0.293 0.677 0.439 1.061 0.439s0.768-0.146 1.061-0.439l27-27c0.586-0.586 0.586-1.536 0-2.121zM13 10c1.32 0 2.44 0.853 2.841 2.037l-3.804 3.804c-1.184-0.401-2.037-1.521-2.037-2.841 0-1.657 1.343-3 3-3zM3.441 16c1.197-1.891 2.79-3.498 4.67-4.697 0.122-0.078 0.246-0.154 0.371-0.228-0.311 0.854-0.482 1.776-0.482 2.737 0 1.715 0.54 3.304 1.459 4.607l-1.904 1.904c-1.639-1.151-3.038-2.621-4.114-4.323z"
id="path4"
style="stroke:#000000;stroke-opacity:1;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none;fill:#f2f2f2" />
<path
fill="#444444"
d="M24 13.813c0-0.849-0.133-1.667-0.378-2.434l-10.056 10.056c0.768 0.245 1.586 0.378 2.435 0.378 4.418 0 8-3.582 8-8z"
id="path6"
style="fill:#f2f2f2;stroke:#000000;stroke-opacity:1;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none" />
<path
fill="#444444"
d="M25.938 9.062l-2.168 2.168c0.040 0.025 0.079 0.049 0.118 0.074 1.88 1.199 3.473 2.805 4.67 4.697-1.197 1.891-2.79 3.498-4.67 4.697-2.362 1.507-5.090 2.303-7.889 2.303-1.208 0-2.403-0.149-3.561-0.439l-2.403 2.403c1.866 0.671 3.873 1.036 5.964 1.036 6.978 0 13.027-4.064 16-10-1.407-2.81-3.504-5.2-6.062-6.938z"
id="path8"
style="stroke:#000000;stroke-opacity:1;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none;fill:#f2f2f2" />
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generated by IcoMoon.io -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
viewBox="0 0 32 32"
id="svg2"
inkscape:version="0.48.5 r10040"
sodipodi:docname="eye.svg">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1017"
id="namedview6"
showgrid="false"
inkscape:zoom="10.429825"
inkscape:cx="-3.6723737"
inkscape:cy="6.897807"
inkscape:window-x="1912"
inkscape:window-y="1"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<path
d="M16 6c-6.979 0-13.028 4.064-16 10 2.972 5.936 9.021 10 16 10s13.027-4.064 16-10c-2.972-5.936-9.021-10-16-10zM23.889 11.303c1.88 1.199 3.473 2.805 4.67 4.697-1.197 1.891-2.79 3.498-4.67 4.697-2.362 1.507-5.090 2.303-7.889 2.303s-5.527-0.796-7.889-2.303c-1.88-1.199-3.473-2.805-4.67-4.697 1.197-1.891 2.79-3.498 4.67-4.697 0.122-0.078 0.246-0.154 0.371-0.228-0.311 0.854-0.482 1.776-0.482 2.737 0 4.418 3.582 8 8 8s8-3.582 8-8c0-0.962-0.17-1.883-0.482-2.737 0.124 0.074 0.248 0.15 0.371 0.228v0zM16 13c0 1.657-1.343 3-3 3s-3-1.343-3-3 1.343-3 3-3 3 1.343 3 3z"
id="path4"
style="stroke:#000000;stroke-opacity:1;opacity:1;stroke-width:0.20000000000000001;stroke-miterlimit:4;stroke-dasharray:none;fill:#f9f9f9" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,515 @@
QToolTip
{
border: 1px solid #222;
background-color: #333;
color: #aaa;
}
QWidget
{
color: #aaa;
background-color: #323232;
}
QWidget:item:hover
{
background-color: #507098;
color: #aaa;
}
QWidget:item:selected
{
background-color: #507098;
}
QMenuBar {
background-color: #323232;
}
QMenuBar::item
{
background: transparent;
}
QMenuBar::item:selected
{
/*
background: transparent;
border: 1px solid #ffaa00;
*/
background: #444;
}
QMenuBar::item:pressed
{
border: 1px solid #000;
background-color: #444;
margin-bottom:-1px;
padding-bottom:1px;
}
/* ==================================================================================== */
/* MENU */
/* ==================================================================================== */
QMenu
{
background: #444;
border: 1px solid #222;
padding: 4px;
padding-right: 0px;
}
QMenu::item
{
background: transparent;
padding: 2px 20px 2px 20px;
}
QMenu::item:disabled
{
color: #555;
background: transparent;
padding: 2px 20px 2px 20px;
}
QMenu::item:selected
{
background-color: #507098;
color: #aaa;
}
QWidget:disabled
{
color: #404040;
background-color: #323232;
}
QLineEdit
{
padding: 1px;
border: 1px solid #111;
background-color: #888;
color: #111;
}
QPushButton
{
color: #b1b1b1;
/* background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);*/
border-width: 1px;
border-color: #1e1e1e;
border-style: solid;
padding: 3px;
font-size: 12px;
padding-left: 5px;
padding-right: 5px;
}
QPushButton:pressed
{
/* background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #2d2d2d, stop: 0.1 #2b2b2b, stop: 0.5 #292929, stop: 0.9 #282828, stop: 1 #252525);*/
}
/* ==================================================================================== */
/* COMBO BOX */
/* ==================================================================================== */
QComboBox {
selection-background-color: #ffaa00;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #565656, stop: 0.1 #525252, stop: 0.5 #4e4e4e, stop: 0.9 #4a4a4a, stop: 1 #464646);
border-style: solid;
border: 1px solid #1e1e1e;
padding: 1px 0px 1px 3px; /*This makes text colour work*/
}
QComboBox:hover,QPushButton:hover {
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #565656,
stop: 0.1 #525252,
stop: 0.5 #4e4e4e,
stop: 0.9 #4a4a4a,
stop: 1 #464646);
}
QComboBox:on {
padding-top: 1px;
padding-left: 3px;
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #555,
stop: 0.1 #4C4C4C,
stop: 0.5 #464646,
stop: 0.9 #414141,
stop: 1 #444);
selection-background-color: #ffaa00;
}
QComboBox QAbstractItemView {
border: 1px solid #222;
selection-background-color: #507098;
}
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top right;
width: 15px;
border: 0px;
}
QComboBox::down-arrow
{
image: url(icons/down_arrow.png);
}
QLineEdit:focus
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
QTextEdit:focus
{
border: 2px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffa02f, stop: 1 #d7801a);
}
/* ==================================================================================== */
/* SCROLL BAR */
/* ==================================================================================== */
QScrollBar:horizontal {
background-color: #333;
height: 8px;
margin: 0px;
padding: 0px;
}
QScrollBar::handle:horizontal {
border: 1px solid #111;
background: #535353;
}
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal,
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
width: 0px;
background: transparent;
}
QScrollBar:vertical {
background-color: #333;
width: 8px;
margin: 0;
}
QScrollBar::handle:vertical {
border: 1px solid #111;
background: #535353;
}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical,
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
height: 0px;
background: transparent;
}
QTextEdit
{
background-color: #242424;
}
QPlainTextEdit
{
background-color: #242424;
}
QSizeGrip
{
width: 1px;
}
QHeaderView::section
{
/*background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565);*/
color: white;
padding-left: 4px;
border: 1px solid #6c6c6c;
}
QDockWidget
{
titlebar-close-icon: url(icons/cross.svg);
}
QDockWidget::separator
{
border: 1px solid red;
}
QDockWidget::title
{
text-align: center;
spacing: 3px; /* spacing between items in the tool bar */
background-color: #323232;
font-weight: bold;
}
QDockWidget::close-button, QDockWidget::float-button
{
text-align: center;
spacing: 1px; /* spacing between items in the tool bar */
}
QDockWidget::close-button:hover, QDockWidget::float-button:hover
{
background: #242424;
}
QDockWidget::close-button:pressed, QDockWidget::float-button:pressed
{
padding: 1px -1px -1px 1px;
}
QMainWindow::separator
{
/*background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);*/
color: white;
padding-left: 4px;
border: 0px solid #4c4c4c;
spacing: 3px; /* spacing between items in the tool bar */
}
QMainWindow::separator:hover
{
/*background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #d7801a, stop:0.5 #b56c17 stop:1 #ffa02f);*/
color: white;
padding-left: 4px;
border: 1px solid #6c6c6c;
spacing: 3px; /* spacing between items in the tool bar */
}
QToolBar {
background: #323232;
border: 1px solid #323232;
font-weight: bold;
}
QToolBar::handle:horizontal
{
image: url(:/qss_icons/rc/Hmovetoolbar.png);
}
QToolBar::handle:vertical
{
image: url(:/qss_icons/rc/Vmovetoolbar.png);
}
QToolBar::separator:horizontal
{
image: url(:/qss_icons/rc/Hsepartoolbar.png);
}
QToolBar::separator:vertical
{
image: url(:/qss_icons/rc/Vsepartoolbars.png);
}
QMenu::separator
{
height: 2px;
/*
background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #161616, stop: 0.5 #151515, stop: 0.6 #212121, stop:1 #343434);
*/
color: white;
padding-left: 4px;
margin-left: 10px;
margin-right: 5px;
}
QProgressBar
{
border: 2px solid grey;
text-align: center;
}
QProgressBar::chunk
{
background-color: #d7801a;
width: 2.15px;
margin: 0.5px;
}
QTabBar::tab {
color: #b1b1b1;
border: 1px solid #444;
border-bottom-style: none;
background-color: #323232;
padding-left: 10px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 2px;
margin-right: -1px;
}
QTabWidget::pane {
border: 1px solid #444;
top: 1px;
}
QTabBar::tab:last
{
margin-right: 0; /* the last selected tab has nothing to overlap with on the right */
}
QTabBar::tab:first:!selected
{
margin-left: 0px; /* the last selected tab has nothing to overlap with on the right */
}
QTabBar::tab:!selected
{
color: #b1b1b1;
border-bottom-style: solid;
margin-top: 3px;
/*background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:.4 #343434);*/
}
QTabBar::tab:selected
{
margin-bottom: 0px;
}
QTabBar::tab:!selected:hover
{
/*border-top: 2px solid #ffaa00;
padding-bottom: 3px;*/
/*background-color: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:1 #212121, stop:0.4 #343434, stop:0.2 #343434, stop:0.1 #ffaa00);*/
}
/* ==================================================================================== */
/* RADIO BUTTON */
/* ==================================================================================== */
QGroupBox::indicator:unchecked,
QGroupBox::indicator:checked,
QCheckBox::indicator:checked,
QCheckBox::indicator:unchecked,
QRadioButton::indicator:checked,
QRadioButton::indicator:unchecked{
color: #b1b1b1;
background-color: #323232;
border: 1px solid #b1b1b1;
}
QGroupBox::indicator:checked,
QCheckBox::indicator:checked,
QRadioButton::indicator:checked {
background-color: qradialgradient(
cx: 0.5, cy: 0.5,
fx: 0.5, fy: 0.5,
radius: 1.0,
stop: 0.25 #ffaa00,
stop: 0.3 #323232
);
}
QRadioButton::indicator
{
}
QGroupBox::indicator:hover,
QCheckBox::indicator:hover,
QRadioButton::indicator:hover
{
border: 1px solid #ffaa00;
}
/* ==================================================================================== */
/* CHECKBOX */
/* ==================================================================================== */
QAbstractItemView
{
background-color: #222;
alternate-background-color: #323232;
color: silver;
border: none;
border-radius: 3px;
padding: 1px;
}
QAbstractItemView::selected {
border: 0px;
outline: none;
}
/* ==================================================================================== */
/* TREE VIEW */
/* ==================================================================================== */
QTreeView {
border: 0.5px solid rgba(108,108,108,75);
}
QTreeView::item, QTreeView::branch {
background: transparent;
color: #DDD;
}
QTreeView::item:hover, QTreeView::branch:hover {
background-color: #507098;
color: #DDD;
}
QTreeView::item:selected, QTreeView::branch:selected {
background-color: #507098;
color: #DDD;
}
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);
}
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);
}
QgsLayerTreeView
{
}
QgsLayerTreeView::item
{
border-top: 0.5px solid rgba(108,108,108,50);
border-bottom: 0.5px solid rgba(108,108,108,50);
padding: 3px;
}
QgsLayerTreeView::indicator:unchecked{
image: url(icons/eye-blocked.svg);
}
QgsLayerTreeView::indicator:checked {
image: url(icons/eye.svg);
}
/* ==================================================================================== */
/* TABLE VIEW */
/* ==================================================================================== */
QHeaderView {
}
QHeaderView::section {
background: transparent;
background-color: #323232;
color: #777;
border-right: 0px solid #777;
border-top: 0px solid #777;
padding: 0 0 2px 3px
}

View File

@ -788,6 +788,7 @@ APP_EXPORT int main( int argc, char *argv[] )
#endif
#endif
QgsApplication::setUITheme( QgsApplication::uiThemeName() );
/* Translation file for QGIS.
*/
QString i18nPath = QgsApplication::i18nPath();

View File

@ -848,6 +848,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mMapCanvas->clearExtentHistory(); // reset zoomnext/zoomlast
mLastComposerId = 0;
// Show a nice tip of the day
if ( settings.value( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), true ).toBool() )
{
@ -883,6 +884,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
// should come after fileNewBlank to ensure project is properly set up to receive any data source files
QgsApplication::setFileOpenEventReceiver( this );
#ifdef ANDROID
toggleFullScreen();
#endif

View File

@ -99,6 +99,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
cmbStyle->addItem( style );
}
QStringList themes = QgsApplication::uiThemes().keys();
cmbUITheme->addItems( themes );
connect( cmbUITheme, SIGNAL( currentIndexChanged(const QString& ) ), this, SLOT( uiThemeChanged( const QString& ) ) );
mIdentifyHighlightColorButton->setColorDialogTitle( tr( "Identify highlight color" ) );
mIdentifyHighlightColorButton->setAllowAlpha( true );
mIdentifyHighlightColorButton->setContext( "gui" );
@ -520,6 +525,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl ) :
QString name = QApplication::style()->objectName();
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
QString theme = QgsApplication::uiThemeName();
cmbUITheme->setCurrentIndex( cmbUITheme->findText( theme, Qt::MatchFixedString ) );
mNativeColorDialogsChkBx->setChecked( settings.value( "/qgis/native_color_dialogs", false ).toBool() );
mLiveColorDialogsChkBx->setChecked( settings.value( "/qgis/live_color_dialogs", false ).toBool() );
@ -928,6 +936,11 @@ void QgsOptions::iconSizeChanged( const QString &iconSize )
QgisApp::instance()->setIconSizes( iconSize.toInt() );
}
void QgsOptions::uiThemeChanged( const QString &theme )
{
QgsApplication::setUITheme( theme );
}
void QgsOptions::on_mProjectOnLaunchCmbBx_currentIndexChanged( int indx )
{
bool specific = ( indx == 2 );

View File

@ -76,6 +76,8 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
void iconSizeChanged( const QString &iconSize );
void uiThemeChanged(const QString &theme );
/** Slot to handle when type of project to open after launch is changed
*/
void on_mProjectOnLaunchCmbBx_currentIndexChanged( int indx );

View File

@ -56,6 +56,7 @@ QString ABISYM( QgsApplication::mPkgDataPath );
QString ABISYM( QgsApplication::mLibraryPath );
QString ABISYM( QgsApplication::mLibexecPath );
QString ABISYM( QgsApplication::mThemeName );
QString ABISYM( QgsApplication::mUIThemeName );
QStringList ABISYM( QgsApplication::mDefaultSvgPaths );
QMap<QString, QString> ABISYM( QgsApplication::mSystemEnvVars );
QString ABISYM( QgsApplication::mConfigPath );
@ -430,6 +431,50 @@ const QString QgsApplication::themeName()
{
return ABISYM( mThemeName );
}
void QgsApplication::setUITheme( const QString &themeName )
{
// Loop all style sheets, find matching name, load it.
QHash<QString, QString> themes = QgsApplication::uiThemes();
QString path = themes[themeName];
QString styleSheet = QLatin1String( "file:///" );
styleSheet.append( path + "/style.qss" );
qApp->setStyleSheet( styleSheet );
QSettings settings;
return settings.setValue( "UI/UITheme", themeName );
}
const QHash<QString, QString> QgsApplication::uiThemes()
{
QString themepath = ABISYM( mPkgDataPath ) + QString( "/resources/themes" );
QString userthemes = qgisSettingsDirPath() + QString( "/themes" );
QStringList paths = QStringList() << themepath << userthemes;
QHash<QString, QString> mapping;
mapping.insert( "default", "" );
foreach( const QString path, paths )
{
QDir folder( path );
QFileInfoList styleFiles = folder.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot );
foreach ( QFileInfo info, styleFiles )
{
QFileInfo styleFile( info.absoluteFilePath() + "/style.qss" );
if ( !styleFile.exists() )
continue;
QString name = info.baseName();
QString path = info.absoluteFilePath();
mapping.insert( name, path );
}
}
return mapping;
}
const QString QgsApplication::uiThemeName()
{
QSettings settings;
return settings.value( "UI/UITheme", "default" ).toString();
}
/*!
Returns the path to the authors file.
*/

View File

@ -76,6 +76,22 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
static const QString themeName();
static void setUITheme( const QString &themeName );
/**
* @brief Return the active UI theme set in the settings.
* @return The name of the current UI theme.
*/
static const QString uiThemeName();
/**
* @brief All themes found in the application resources folder
* and ~\.qgis2\themes folder. The path is to the root folder for the theme
* @note Valid theme folders must contain a style.qss file.
* @return A hash of theme name and theme path. Valid theme folders contain style.qss
*/
static const QHash<QString, QString> uiThemes();
//! Returns the path to the authors file.
static const QString authorsFilePath();
@ -307,6 +323,7 @@ class CORE_EXPORT QgsApplication : public QApplication
static QObject* ABISYM( mFileOpenEventReceiver );
static QStringList ABISYM( mFileOpenEventList );
static QString ABISYM( mUIThemeName );
static QString ABISYM( mPrefixPath );
static QString ABISYM( mPluginPath );
static QString ABISYM( mPkgDataPath );

View File

@ -45,16 +45,7 @@
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -275,35 +266,17 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -320,7 +293,7 @@
<x>0</x>
<y>0</y>
<width>610</width>
<height>635</height>
<height>670</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
@ -360,6 +333,36 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_37">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_42">
<property name="text">
<string>UI Theme</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_47">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="cmbUITheme"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
@ -911,16 +914,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageSystem">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -936,7 +930,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>663</width>
<width>655</width>
<height>862</height>
</rect>
</property>
@ -1132,10 +1126,10 @@
<property name="title">
<string>Current environment variables (read-only - bold indicates modified at startup)</string>
</property>
<property name="collapsed" stdset="0">
<property name="collapsed">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<property name="saveCollapsedState">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
@ -1295,16 +1289,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageDataSources">
<layout class="QVBoxLayout" name="verticalLayout_26">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -1320,8 +1305,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>440</height>
<width>626</width>
<height>549</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
@ -1621,16 +1606,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageRendering">
<layout class="QVBoxLayout" name="verticalLayout_12">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -1646,7 +1622,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>747</width>
<width>728</width>
<height>802</height>
</rect>
</property>
@ -1865,16 +1841,7 @@
<string>Rendering quality</string>
</property>
<layout class="QVBoxLayout" name="_5">
<property name="leftMargin">
<number>11</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<property name="rightMargin">
<number>11</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>11</number>
</property>
<item>
@ -1896,16 +1863,7 @@
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_19">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -1989,16 +1947,7 @@
<item>
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_22">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2030,16 +1979,7 @@
<item>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_23">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2071,16 +2011,7 @@
<item>
<widget class="QWidget" name="widget_5" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_24">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2119,16 +2050,7 @@
<item>
<widget class="QWidget" name="widget_6" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_25">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2160,16 +2082,7 @@
<item>
<widget class="QWidget" name="widget_7" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_18">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2226,16 +2139,7 @@
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_20">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2341,16 +2245,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageColors">
<layout class="QVBoxLayout" name="verticalLayout_38">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2446,16 +2341,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageMapCanvas">
<layout class="QVBoxLayout" name="verticalLayout_16">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2471,8 +2357,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>528</width>
<height>327</height>
<width>526</width>
<height>331</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
@ -2784,16 +2670,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageMapTools">
<layout class="QVBoxLayout" name="verticalLayout_14">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -2809,8 +2686,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>692</width>
<height>625</height>
<width>684</width>
<height>607</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
@ -3279,16 +3156,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageComposer">
<layout class="QVBoxLayout" name="verticalLayout_36">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -3304,8 +3172,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<height>307</height>
<width>504</width>
<height>308</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_39">
@ -3484,16 +3352,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageDigitizing">
<layout class="QVBoxLayout" name="verticalLayout_17">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -3509,8 +3368,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>640</height>
<width>501</width>
<height>641</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
@ -3984,16 +3843,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageGDAL">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -4009,7 +3859,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<width>462</width>
<height>372</height>
</rect>
</property>
@ -4123,16 +3973,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageCRS">
<layout class="QVBoxLayout" name="verticalLayout_18">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -4148,8 +3989,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>574</width>
<height>647</height>
<width>565</width>
<height>679</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
@ -4210,7 +4051,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QgsProjectionSelectionWidget" name="leLayerGlobalCrs" native="true">
<widget class="QgsProjectionSelectionWidget" name="leLayerGlobalCrs">
<property name="enabled">
<bool>false</bool>
</property>
@ -4273,7 +4114,7 @@
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QgsProjectionSelectionWidget" name="leProjectGlobalCrs" native="true">
<widget class="QgsProjectionSelectionWidget" name="leProjectGlobalCrs">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
@ -4369,16 +4210,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageLocale">
<layout class="QVBoxLayout" name="verticalLayout_19">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -4394,7 +4226,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>305</width>
<width>300</width>
<height>226</height>
</rect>
</property>
@ -4468,16 +4300,7 @@
</widget>
<widget class="QWidget" name="mOptionsPageNetwork">
<layout class="QVBoxLayout" name="verticalLayout_20">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@ -4493,7 +4316,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<width>610</width>
<height>705</height>
</rect>
</property>
@ -4643,10 +4466,10 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="collapsed" stdset="0">
<property name="collapsed">
<bool>false</bool>
</property>
<property name="saveCollapsedState" stdset="0">
<property name="saveCollapsedState">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_1">
@ -4844,7 +4667,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_41">
<item>
<widget class="QgsVariableEditorWidget" name="mVariableEditor">
<widget class="QgsVariableEditorWidget" name="mVariableEditor" native="true">
<property name="settingGroup" stdset="0">
<string notr="true">globalOptions</string>
</property>
@ -4923,6 +4746,12 @@
<header>qgscolorbuttonv2.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsProjectionSelectionWidget</class>
<extends>QWidget</extends>
<header>qgsprojectionselectionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorSchemeList</class>
<extends>QWidget</extends>
@ -4934,12 +4763,6 @@
<extends>QComboBox</extends>
<header>qgsscalecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsProjectionSelectionWidget</class>
<extends>QWidget</extends>
<header location="global">qgsprojectionselectionwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsVariableEditorWidget</class>
<extends>QWidget</extends>