diff --git a/Plugins/org.blueberry.ui.qt/resources/fonts/FiraSans/FiraSans.ttc b/Plugins/org.blueberry.ui.qt/resources/fonts/FiraSans/FiraSans.ttc
new file mode 100644
index 0000000000..12318fc1c2
Binary files /dev/null and b/Plugins/org.blueberry.ui.qt/resources/fonts/FiraSans/FiraSans.ttc differ
diff --git a/Plugins/org.blueberry.ui.qt/resources/fonts/LightFiraSans/LightFiraSans.ttc b/Plugins/org.blueberry.ui.qt/resources/fonts/LightFiraSans/LightFiraSans.ttc
new file mode 100644
index 0000000000..6c03afcc8a
Binary files /dev/null and b/Plugins/org.blueberry.ui.qt/resources/fonts/LightFiraSans/LightFiraSans.ttc differ
diff --git a/Plugins/org.blueberry.ui.qt/resources/fonts/LightFiraSans/OFL.txt b/Plugins/org.blueberry.ui.qt/resources/fonts/LightFiraSans/OFL.txt
new file mode 100644
index 0000000000..4f9e17ed29
--- /dev/null
+++ b/Plugins/org.blueberry.ui.qt/resources/fonts/LightFiraSans/OFL.txt
@@ -0,0 +1,92 @@
+Copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A.
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto.ttf b/Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto.ttf
index b0d268840f..8c082c8de0 100644
Binary files a/Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto.ttf and b/Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto.ttf differ
diff --git a/Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto.ttf b/Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto2.ttf
similarity index 100%
copy from Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto.ttf
copy to Plugins/org.blueberry.ui.qt/resources/fonts/Roboto/Roboto2.ttf
diff --git a/Plugins/org.blueberry.ui.qt/resources/org_blueberry_ui_qt.qrc b/Plugins/org.blueberry.ui.qt/resources/org_blueberry_ui_qt.qrc
index f43407e69f..8b9a9bd9e8 100755
--- a/Plugins/org.blueberry.ui.qt/resources/org_blueberry_ui_qt.qrc
+++ b/Plugins/org.blueberry.ui.qt/resources/org_blueberry_ui_qt.qrc
@@ -1,66 +1,67 @@
cursor_bottom.xpm
cursor_center.xpm
cursor_left.xpm
cursor_offscreen.xpm
cursor_right.xpm
cursor_top.xpm
dialog-error.svg
icon_missing.png
tab_close_icon.png
tab_close_icon-active.png
defaultstyle.qss
defaultstyle-activetab.qss
defaultstyle-tab.qss
dark/up_arrow_disabled.png
dark/Hmovetoolbar.png
dark/stylesheet-branch-end.png
dark/branch_closed-on.png
dark/stylesheet-vline.png
dark/branch_closed.png
dark/branch_open-on.png
dark/transparent.png
dark/right_arrow_disabled.png
dark/sizegrip.png
dark/close.png
dark/close-hover.png
dark/close-pressed.png
dark/down_arrow.png
dark/Vmovetoolbar.png
dark/left_arrow.png
dark/stylesheet-branch-more.png
dark/up_arrow.png
dark/right_arrow.png
dark/left_arrow_disabled.png
dark/Hsepartoolbar.png
dark/branch_open.png
dark/Vsepartoolbar.png
dark/down_arrow_disabled.png
dark/undock.png
dark/checkbox_checked_disabled.png
dark/checkbox_checked_focus.png
dark/checkbox_checked.png
dark/checkbox_indeterminate.png
dark/checkbox_indeterminate_focus.png
dark/checkbox_unchecked_disabled.png
dark/checkbox_unchecked_focus.png
dark/checkbox_unchecked.png
dark/radio_checked_disabled.png
dark/radio_checked_focus.png
dark/radio_checked.png
dark/radio_unchecked_disabled.png
dark/radio_unchecked_focus.png
dark/radio_unchecked.png
darkstyle.qss
darkstyle-tab.qss
darkstyle-activetab.qss
- fonts/FiraSans/FiraSans.ttf
+ fonts/FiraSans/FiraSans.ttc
+ fonts/LightFiraSans/LightFiraSans.ttc
fonts/Roboto/Roboto.ttf
fonts/xkcd/xkcd.ttf
diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp b/Plugins/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp
index d9e1cec233..f695ef9495 100644
--- a/Plugins/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp
+++ b/Plugins/org.blueberry.ui.qt/src/internal/berryQtStyleManager.cpp
@@ -1,391 +1,392 @@
/*===================================================================
BlueBerry Platform
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "berryQtStyleManager.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "berryQtPreferences.h"
#include "berryWorkbenchPlugin.h"
namespace berry
{
QtStyleManager::QtStyleManager()
{
AddDefaultStyle();
AddDefaultFonts();
ReadPreferences();
}
void QtStyleManager::ReadPreferences()
{
IPreferencesService* prefService = WorkbenchPlugin::GetDefault()->GetPreferencesService();
IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(QtPreferences::QT_STYLES_NODE);
QString paths = stylePref->Get(QtPreferences::QT_STYLE_SEARCHPATHS, "");
QStringList pathList = paths.split(";", QString::SkipEmptyParts);
QStringListIterator it(pathList);
while (it.hasNext())
{
AddStyles(it.next());
}
QString styleName = stylePref->Get(QtPreferences::QT_STYLE_NAME, "");
// if a style is contributed via the Qt resource mechanism, it may not be
// registered yet.
if (Contains(styleName))
// do not update the style in the QApplication instance,
// since it might not be created yet
SetStyle(styleName, false);
else
SetDefaultStyle(false);
}
QtStyleManager::~QtStyleManager()
{
for (FileNameToStyleMap::const_iterator i = styles.begin(); i != styles.end(); ++i)
{
delete i.value();
}
}
void QtStyleManager::AddDefaultStyle()
{
#ifndef _APPLE_
AddStyle(":/org.blueberry.ui.qt/defaultstyle.qss", "Default");
AddStyle(":/org.blueberry.ui.qt/darkstyle.qss", "Dark");
defaultStyle = styles[":/org.blueberry.ui.qt/defaultstyle.qss"];
#endif
}
void QtStyleManager::AddDefaultFonts()
{
m_customFontNames.append(QString("<>"));
- AddFont(QString(":/org.blueberry.ui.qt/fonts/FiraSans/FiraSans.ttf"), QString("Fira Sans"));
+ AddFont(QString(":/org.blueberry.ui.qt/fonts/FiraSans/FiraSans.ttc"), QString("Fira Sans"));
+ AddFont(QString(":/org.blueberry.ui.qt/fonts/LightFiraSans/LightFiraSans.ttc"), QString("Light Fira Sans"));
AddFont(QString(":/org.blueberry.ui.qt/fonts/Roboto/Roboto.ttf"), QString("Roboto"));
AddFont(QString(":/org.blueberry.ui.qt/fonts/xkcd/xkcd.ttf"), QString("xkcd"));
}
void QtStyleManager::ClearStyles()
{
for (FileNameToStyleMap::iterator i = styles.begin(); i != styles.end(); )
{
if (!i.value()->fileName.startsWith(':'))
{
delete i.value();
i = styles.erase(i);
}
else ++i;
}
SetDefaultStyle();
}
QtStyleManager::Style QtStyleManager::GetStyle() const
{
return Style(currentStyle->name, currentStyle->fileName);
}
QString QtStyleManager::GetStylesheet() const
{
return currentStyle->stylesheet;
}
QString QtStyleManager::GetActiveTabStylesheet() const
{
return currentStyle->activeTabStylesheet;
}
QString QtStyleManager::GetTabStylesheet() const
{
return currentStyle->tabStylesheet;
}
void QtStyleManager::AddStyle(const QString& styleFileName,
const QString& styleName)
{
auto newStyle = new ExtStyle();
if (styleName.isEmpty())
{
QFileInfo info(styleFileName);
newStyle->name = info.completeBaseName();
}
else
{
newStyle->name = styleName;
}
newStyle->fileName = styleFileName;
styles.insert(newStyle->fileName, newStyle);
}
void QtStyleManager::AddFont(const QString& fontFilePath,
const QString& fontName)
{
QFontDatabase::addApplicationFont(fontFilePath);
m_customFontNames.push_back(fontName);
}
void QtStyleManager::GetFonts(QStringList& fontNames) const
{
fontNames = m_customFontNames;
}
QString QtStyleManager::GetFont() const
{
return currentFont;
}
void QtStyleManager::AddStyles(const QString& path)
{
QDirIterator dirIt(path);
while (dirIt.hasNext())
{
QString current = dirIt.next();
QFileInfo info = dirIt.fileInfo();
if (info.isFile() && info.isReadable())
{
QString fileName = info.fileName();
if (fileName.endsWith("-tab.qss") || fileName.endsWith("-activetab.qss"))
continue;
if (fileName.endsWith(".qss"))
AddStyle(current);
}
}
}
void QtStyleManager::ReadStyleData(ExtStyle* style)
{
QString tabStyleFileName(style->fileName);
QString activeTabStyleFileName(style->fileName);
int index = style->fileName.lastIndexOf(".qss");
tabStyleFileName.replace(index, 4, "-tab.qss");
activeTabStyleFileName.replace(index, 4, "-activetab.qss");
QFile styleFile(style->fileName);
if (styleFile.open(QIODevice::ReadOnly))
{
QTextStream in(&styleFile);
style->stylesheet = in.readAll();
}
else
{
BERRY_WARN << "Could not read " << style->fileName.toStdString();
}
QFile tabStyleFile(tabStyleFileName);
if (tabStyleFile.open(QIODevice::ReadOnly))
{
QTextStream in(&tabStyleFile);
style->tabStylesheet = in.readAll();
}
else
{
BERRY_WARN << "Could not read " << tabStyleFileName.toStdString();
}
QFile activeTabStyleFile(activeTabStyleFileName);
if (activeTabStyleFile.open(QIODevice::ReadOnly))
{
QTextStream in(&activeTabStyleFile);
style->activeTabStylesheet = in.readAll();
}
else
{
BERRY_WARN << "Could not read " << activeTabStyleFileName.toStdString();
}
}
void QtStyleManager::RemoveStyle(const QString& styleFileName)
{
if (currentStyle->fileName == styleFileName)
{
SetDefaultStyle();
}
delete styles.take(styleFileName);
}
void QtStyleManager::RemoveStyles(const QString& repo)
{
if (repo.isEmpty())
{
ClearStyles();
return;
}
for (FileNameToStyleMap::iterator i = styles.begin(); i != styles.end();)
{
ExtStyle* style = i.value();
QFileInfo info(style->fileName);
if (info.absolutePath() == repo)
{
if (style->name == currentStyle->name)
{
SetDefaultStyle();
}
i = styles.erase(i);
delete style;
}
else
{
++i;
}
}
}
void QtStyleManager::GetStyles(StyleList& styleNames) const
{
for (FileNameToStyleMap::const_iterator i = styles.begin(); i != styles.end(); ++i)
styleNames.push_back(Style(i.value()->name, i.value()->fileName));
}
void QtStyleManager::GetIconThemes(IconThemeList& iconThemes) const
{
iconThemes.clear();
iconThemes.push_back(IconTheme(QString( "<>" )));
QStringList iconSearchPaths = QIcon::themeSearchPaths();
for(QStringList::Iterator pathIt = iconSearchPaths.begin(); pathIt != iconSearchPaths.end(); ++pathIt)
{
QDirIterator dirIt(*pathIt);
while (dirIt.hasNext())
{
QString current = dirIt.next();
QFileInfo info = dirIt.fileInfo();
if (info.isDir() && info.isReadable())
{
QFileInfo themeFile( info.filePath() + QString("/index.theme") );
if( themeFile.exists() && themeFile.isFile() && themeFile.isReadable() )
{
QString fileName = info.fileName();
iconThemes.push_back( IconTheme(fileName) );
}
}
}
}
}
void QtStyleManager::SetStyle(const QString& fileName)
{
SetStyle(fileName, true);
}
void QtStyleManager::SetStyle(const QString& fileName, bool update)
{
if (fileName.isEmpty())
{
SetDefaultStyle();
return;
}
FileNameToStyleMap::const_iterator i = styles.find(fileName);
ExtStyle* style = nullptr;
if (i == styles.end())
{
BERRY_WARN << "Style " + fileName.toStdString() << " does not exist";
style = defaultStyle;
}
else
{
style = i.value();
}
currentStyle = style;
ReadStyleData(style);
if (update)
{
qApp->setStyleSheet(currentStyle->stylesheet);
PlatformUI::GetWorkbench()->UpdateTheme();
}
}
void QtStyleManager::SetFont(const QString& fontName)
{
if( fontName == QString( "<>" ) || fontName == QString( "" ))
{
qApp->setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
}
else
{
- QFont font(fontName, 11);
+ QFont font(fontName);
qApp->setFont(font);
}
currentFont = fontName;
qApp->setStyleSheet(currentStyle->stylesheet);
PlatformUI::GetWorkbench()->UpdateTheme();
}
void QtStyleManager::SetIconTheme(const QString& themeName)
{
if( themeName == QString( "<>" ) )
{
SetIconTheme( QString("tango"), true);
}
else
{
SetIconTheme(themeName, true);
}
}
void QtStyleManager::SetIconTheme(const QString& themeName, bool /*update*/)
{
QIcon::setThemeName( themeName );
}
QtStyleManager::Style QtStyleManager::GetDefaultStyle() const
{
return Style(defaultStyle->name, defaultStyle->fileName);
}
void QtStyleManager::SetDefaultStyle()
{
SetDefaultStyle(true);
}
void QtStyleManager::SetDefaultStyle(bool update)
{
SetStyle(defaultStyle->fileName, update);
}
bool QtStyleManager::Contains(const QString& fileName) const
{
return styles.contains(fileName);
}
}