Make the use of system's theme icons configurable

A lyxrc variable is added and a checkbox is added to the LyX->preferences
dialog.
This commit is contained in:
Vincent van Ravesteijn 2012-05-08 17:55:59 +02:00
parent b1f6ab69f2
commit 147dcb4cb9
6 changed files with 61 additions and 8 deletions

View File

@ -53,6 +53,10 @@
# Incremented to format 11, by gb
# Split pdf format into pdf and pdf6
# Incremented to format 12, by vfr
# Add option to use the system's theme icons
# No conversion necessary.
import re
###########################################################
@ -308,5 +312,6 @@ conversions = [
[ 8, []],
[ 9, [ remove_default_language ]],
[ 10, []],
[ 11, [split_pdf_format]]
[ 11, [split_pdf_format]],
[ 12, []]
]

View File

@ -55,7 +55,7 @@ namespace os = support::os;
namespace {
static unsigned int const LYXRC_FILEFORMAT = 11; // gb: Split pdf format into pdf and pdf6
static unsigned int const LYXRC_FILEFORMAT = 12; // vfr: System theme's icons
// when adding something to this array keep it sorted!
LexerKeyword lyxrcTags[] = {
@ -203,6 +203,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\use_qimage", LyXRC::RC_USE_QIMAGE },
// compatibility with versions older than 1.4.0 only
{ "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS },
{ "\\use_system_theme_icons", LyXRC::RC_USE_SYSTEM_THEME_ICONS },
{ "\\use_tooltip", LyXRC::RC_USE_TOOLTIP },
{ "\\user_email", LyXRC::RC_USER_EMAIL },
{ "\\user_name", LyXRC::RC_USER_NAME },
@ -228,6 +229,7 @@ LyXRC::LyXRC()
void LyXRC::setDefaults()
{
icon_set = string();
use_system_theme_icons = false;
bind_file = "cua";
def_file = "default";
ui_file = "default";
@ -833,6 +835,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
lexrc >> icon_set;
break;
case RC_USE_SYSTEM_THEME_ICONS:
lexrc >> use_system_theme_icons;
break;
case RC_SCREEN_FONT_ROMAN:
if (lexrc.next()) {
roman_font_name = lexrc.getString();
@ -1701,6 +1707,16 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
if (tag != RC_LAST)
break;
case RC_USE_SYSTEM_THEME_ICONS:
if (ignore_system_lyxrc ||
use_system_theme_icons != system_lyxrc.use_system_theme_icons) {
os << "\\use_system_theme_icons "
<< convert<string>(use_system_theme_icons)
<< "\n";
}
if (tag != RC_LAST)
break;
case RC_SCREEN_DPI:
if (ignore_system_lyxrc ||
dpi != system_lyxrc.dpi) {
@ -3023,6 +3039,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
case LyXRC::RC_USE_TOOLTIP:
case LyXRC::RC_USE_PIXMAP_CACHE:
case LyXRC::RC_USE_QIMAGE:
case LyXRC::RC_USE_SYSTEM_THEME_ICONS:
case LyXRC::RC_VIEWDVI_PAPEROPTION:
case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
case LyXRC::RC_SINGLE_INSTANCE:

View File

@ -185,6 +185,7 @@ public:
RC_USE_TOOLTIP,
RC_USE_PIXMAP_CACHE,
RC_USE_QIMAGE,
RC_USE_SYSTEM_THEME_ICONS,
RC_VIEWDVI_PAPEROPTION,
RC_VIEWER,
RC_VIEWER_ALTERNATIVES,
@ -465,6 +466,8 @@ public:
std::string user_email;
/// icon set name
std::string icon_set;
/// whether to use the icons from the theme
bool use_system_theme_icons;
/// True if the TeX engine cannot handle posix paths
bool windows_style_tex_paths;
/// True if the TeX engine can handle file names containing spaces

View File

@ -549,12 +549,14 @@ QPixmap getPixmap(QString const & path, QString const & name, QString const & ex
QIcon getIcon(FuncRequest const & f, bool unknown)
{
#if (QT_VERSION >= 0x040600)
QString action = toqstr(lyxaction.getActionName(f.action()));
if (!f.argument().empty())
action += " " + toqstr(f.argument());
QString const theme_icon = themeIconName(action);
if (QIcon::hasThemeIcon(theme_icon))
return QIcon::fromTheme(theme_icon);
if (lyxrc.use_system_theme_icons) {
QString action = toqstr(lyxaction.getActionName(f.action()));
if (!f.argument().empty())
action += " " + toqstr(f.argument());
QString const theme_icon = themeIconName(action);
if (QIcon::hasThemeIcon(theme_icon))
return QIcon::fromTheme(theme_icon);
}
#endif
QString icon = iconName(f, unknown);

View File

@ -2513,6 +2513,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form)
this, SIGNAL(changed()));
connect(iconSetCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
connect(useSystemThemeIconsCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
connect(lastfilesSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed()));
connect(tooltipCB, SIGNAL(toggled(bool)),
@ -2531,6 +2533,7 @@ void PrefUserInterface::apply(LyXRC & rc) const
iconSetCO->currentIndex()).toString());
rc.ui_file = internal_path(fromqstr(uiFileED->text()));
rc.use_system_theme_icons = useSystemThemeIconsCB->isChecked();
rc.num_lastfiles = lastfilesSB->value();
rc.use_tooltip = tooltipCB->isChecked();
}
@ -2542,6 +2545,11 @@ void PrefUserInterface::update(LyXRC const & rc)
if (iconset < 0)
iconset = 0;
iconSetCO->setCurrentIndex(iconset);
#if (QT_VERSION < 0x040600)
useSystemThemeIconsCB->hide();
themeIconsLA->hide();
#endif
useSystemThemeIconsCB->setChecked(rc.use_system_theme_icons);
uiFileED->setText(toqstr(external_path(rc.ui_file)));
lastfilesSB->setValue(rc.num_lastfiles);
tooltipCB->setChecked(rc.use_tooltip);

View File

@ -100,6 +100,23 @@
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="themeIconsLA">
<property name="text" >
<string>Use icons from system's &amp;theme:</string>
</property>
<property name="buddy" >
<cstring>useSystemThemeIconsCB</cstring>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useSystemThemeIconsCB"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@ -200,6 +217,7 @@
<tabstop>uiFileED</tabstop>
<tabstop>uiFilePB</tabstop>
<tabstop>iconSetCO</tabstop>
<tabstop>useSystemThemeIconsCB</tabstop>
<tabstop>tooltipCB</tabstop>
</tabstops>
<includes>