mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Currently when the general font of KDE has been changed, the used fonts for the view in Dolphin have not been changed.
This has been fixed by differing between a "Use system font" setting (= default) or a "Use custom font" setting. TODO: if the general font of KDE is changed during Dolphin is open, no update is done yet CCMAIL: ereslibre@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=775487
This commit is contained in:
parent
8f975fec46
commit
d38de66f4b
12 changed files with 247 additions and 34 deletions
|
@ -85,6 +85,7 @@ set(dolphin_SRCS
|
|||
columnviewsettingspage.cpp
|
||||
detailsviewsettingspage.cpp
|
||||
dolphinapplication.cpp
|
||||
dolphinfontrequester.cpp
|
||||
dolphinmainwindow.cpp
|
||||
dolphinnewmenu.cpp
|
||||
dolphinviewcontainer.cpp
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
#include "columnviewsettingspage.h"
|
||||
|
||||
#include "dolphinfontrequester.h"
|
||||
#include "dolphinsettings.h"
|
||||
#include "dolphin_columnmodesettings.h"
|
||||
|
||||
#include <kdialog.h>
|
||||
#include <kfontrequester.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include <QButtonGroup>
|
||||
|
@ -92,7 +92,7 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
|
|||
textBox->setSizePolicy(sizePolicy);
|
||||
|
||||
QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textBox);
|
||||
m_fontRequester = new KFontRequester(textBox);
|
||||
m_fontRequester = new DolphinFontRequester(textBox);
|
||||
|
||||
QHBoxLayout* textLayout = new QHBoxLayout(textBox);
|
||||
textLayout->addWidget(fontLabel);
|
||||
|
@ -123,6 +123,7 @@ void ColumnViewSettingsPage::applySettings()
|
|||
settings->setIconSize(iconSize);
|
||||
|
||||
const QFont font = m_fontRequester->font();
|
||||
settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
settings->setFontFamily(font.family());
|
||||
settings->setFontSize(font.pointSize());
|
||||
settings->setItalicFont(font.italic());
|
||||
|
@ -157,11 +158,16 @@ void ColumnViewSettingsPage::loadSettings()
|
|||
m_smallIconSize->setChecked(true);
|
||||
}
|
||||
|
||||
QFont font(settings->fontFamily(),
|
||||
settings->fontSize());
|
||||
font.setItalic(settings->italicFont());
|
||||
font.setBold(settings->boldFont());
|
||||
m_fontRequester->setFont(font);
|
||||
if (settings->useSystemFont()) {
|
||||
m_fontRequester->setMode(DolphinFontRequester::SystemFont);
|
||||
} else {
|
||||
QFont font(settings->fontFamily(),
|
||||
settings->fontSize());
|
||||
font.setItalic(settings->italicFont());
|
||||
font.setBold(settings->boldFont());
|
||||
m_fontRequester->setMode(DolphinFontRequester::CustomFont);
|
||||
m_fontRequester->setCustomFont(font);
|
||||
}
|
||||
|
||||
m_columnWidthSlider->setValue((settings->columnWidth() - 150) / 50);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <kvbox.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class KFontRequester;
|
||||
class DolphinFontRequester;
|
||||
class QSlider;
|
||||
class QRadioButton;
|
||||
|
||||
|
@ -57,7 +57,7 @@ private:
|
|||
QRadioButton* m_smallIconSize;
|
||||
QRadioButton* m_mediumIconSize;
|
||||
QRadioButton* m_largeIconSize;
|
||||
KFontRequester* m_fontRequester;
|
||||
DolphinFontRequester* m_fontRequester;
|
||||
QSlider* m_columnWidthSlider;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,16 +23,16 @@
|
|||
#include "dolphin_detailsmodesettings.h"
|
||||
|
||||
#include <kdialog.h>
|
||||
#include <kfontrequester.h>
|
||||
#include <dolphinfontrequester.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include <QtGui/QButtonGroup>
|
||||
#include <QtGui/QCheckBox>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QGroupBox>
|
||||
#include <QtGui/QGridLayout>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QRadioButton>
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGroupBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QRadioButton>
|
||||
#include <QtGui/QSpinBox>
|
||||
|
||||
DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
|
||||
|
@ -74,7 +74,7 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
|
|||
textBox->setSizePolicy(sizePolicy);
|
||||
|
||||
QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textBox);
|
||||
m_fontRequester = new KFontRequester(textBox);
|
||||
m_fontRequester = new DolphinFontRequester(textBox);
|
||||
|
||||
QHBoxLayout* textLayout = new QHBoxLayout(textBox);
|
||||
textLayout->addWidget(fontLabel);
|
||||
|
@ -105,6 +105,7 @@ void DetailsViewSettingsPage::applySettings()
|
|||
settings->setIconSize(iconSize);
|
||||
|
||||
const QFont font = m_fontRequester->font();
|
||||
settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
settings->setFontFamily(font.family());
|
||||
settings->setFontSize(font.pointSize());
|
||||
settings->setItalicFont(font.italic());
|
||||
|
@ -136,11 +137,16 @@ void DetailsViewSettingsPage::loadSettings()
|
|||
m_smallIconSize->setChecked(true);
|
||||
}
|
||||
|
||||
QFont font(settings->fontFamily(),
|
||||
settings->fontSize());
|
||||
font.setItalic(settings->italicFont());
|
||||
font.setBold(settings->boldFont());
|
||||
m_fontRequester->setFont(font);
|
||||
if (settings->useSystemFont()) {
|
||||
m_fontRequester->setMode(DolphinFontRequester::SystemFont);
|
||||
} else {
|
||||
QFont font(settings->fontFamily(),
|
||||
settings->fontSize());
|
||||
font.setItalic(settings->italicFont());
|
||||
font.setBold(settings->boldFont());
|
||||
m_fontRequester->setMode(DolphinFontRequester::CustomFont);
|
||||
m_fontRequester->setCustomFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
#include "detailsviewsettingspage.moc"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <kvbox.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class KFontRequester;
|
||||
class DolphinFontRequester;
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
|
||||
|
@ -57,7 +57,7 @@ private:
|
|||
QRadioButton* m_smallIconSize;
|
||||
QRadioButton* m_mediumIconSize;
|
||||
QRadioButton* m_largeIconSize;
|
||||
KFontRequester* m_fontRequester;
|
||||
DolphinFontRequester* m_fontRequester;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<label context="@label">Font family</label>
|
||||
<default code="true">KGlobalSettings::generalFont().family()</default>
|
||||
</entry>
|
||||
<entry name="UseSystemFont" type="Bool">
|
||||
<label context="@label">Use system font</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="FontSize" type="Int">
|
||||
<label context="@label">Font size</label>
|
||||
<default code="true">KGlobalSettings::generalFont().pointSize()</default>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<label context="@label">Font family</label>
|
||||
<default code="true">KGlobalSettings::generalFont().family()</default>
|
||||
</entry>
|
||||
<entry name="UseSystemFont" type="Bool">
|
||||
<label context="@label">Use system font</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="FontSize" type="Int">
|
||||
<label context="@label">Font size</label>
|
||||
<default code="true">KGlobalSettings::generalFont().pointSize()</default>
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
<label context="@label">Arrangement</label>
|
||||
<default code="true">QListView::TopToBottom</default>
|
||||
</entry>
|
||||
<entry name="UseSystemFont" type="Bool">
|
||||
<label context="@label">Use system font</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="FontFamily" type="String">
|
||||
<label context="@label">Font family</label>
|
||||
<default code="true">KGlobalSettings::generalFont().family()</default>
|
||||
|
|
107
src/dolphinfontrequester.cpp
Normal file
107
src/dolphinfontrequester.cpp
Normal file
|
@ -0,0 +1,107 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "dolphinfontrequester.h"
|
||||
|
||||
#include <kfontdialog.h>
|
||||
#include <kglobalsettings.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QEvent>
|
||||
#include <QPushButton>
|
||||
|
||||
DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
|
||||
KHBox(parent),
|
||||
m_modeCombo(0),
|
||||
m_chooseFontButton(0),
|
||||
m_mode(SystemFont),
|
||||
m_customFont()
|
||||
{
|
||||
m_modeCombo = new QComboBox(this);
|
||||
m_modeCombo->addItem(i18nc("@item:inlistbox Font", "System Font"));
|
||||
m_modeCombo->addItem(i18nc("@item:inlistbox Font", "Custom Font"));
|
||||
connect(m_modeCombo, SIGNAL(activated(int)),
|
||||
this, SLOT(changeMode(int)));
|
||||
|
||||
m_chooseFontButton = new QPushButton(i18n("Choose..."), this);
|
||||
connect(m_chooseFontButton, SIGNAL(clicked()),
|
||||
this, SLOT(openFontDialog()));
|
||||
|
||||
changeMode(m_modeCombo->currentIndex());
|
||||
}
|
||||
|
||||
DolphinFontRequester::~DolphinFontRequester()
|
||||
{
|
||||
}
|
||||
|
||||
void DolphinFontRequester::setMode(Mode mode)
|
||||
{
|
||||
m_mode = mode;
|
||||
m_modeCombo->setCurrentIndex(m_mode);
|
||||
m_modeCombo->setFont(font());
|
||||
m_chooseFontButton->setEnabled(m_mode == CustomFont);
|
||||
}
|
||||
|
||||
DolphinFontRequester::Mode DolphinFontRequester::mode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
QFont DolphinFontRequester::font() const
|
||||
{
|
||||
return (m_mode == CustomFont) ? m_customFont : KGlobalSettings::generalFont();
|
||||
}
|
||||
|
||||
void DolphinFontRequester::setCustomFont(const QFont& font)
|
||||
{
|
||||
m_customFont = font;
|
||||
}
|
||||
|
||||
QFont DolphinFontRequester::customFont() const
|
||||
{
|
||||
return m_customFont;
|
||||
}
|
||||
|
||||
bool DolphinFontRequester::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Polish) {
|
||||
m_modeCombo->setFont(font());
|
||||
}
|
||||
return KHBox::event(event);
|
||||
}
|
||||
|
||||
void DolphinFontRequester::openFontDialog()
|
||||
{
|
||||
QFont font;
|
||||
const int result = KFontDialog::getFont(font,
|
||||
KFontChooser::NoDisplayFlags,
|
||||
this);
|
||||
if (result == KFontDialog::Accepted) {
|
||||
m_customFont = font;
|
||||
m_modeCombo->setFont(m_customFont);
|
||||
}
|
||||
}
|
||||
|
||||
void DolphinFontRequester::changeMode(int index)
|
||||
{
|
||||
setMode((index == CustomFont) ? CustomFont : SystemFont);
|
||||
}
|
||||
|
||||
#include "dolphinfontrequester.moc"
|
75
src/dolphinfontrequester.h
Normal file
75
src/dolphinfontrequester.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef DOLPHINFONTREQUESTER_H
|
||||
#define DOLPHINFONTREQUESTER_H
|
||||
|
||||
#include <khbox.h>
|
||||
|
||||
#include <QFont>
|
||||
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
|
||||
/**
|
||||
* @brief Allows to select between using the system font or a custom font.
|
||||
*/
|
||||
class DolphinFontRequester : public KHBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Mode
|
||||
{
|
||||
SystemFont = 0,
|
||||
CustomFont = 1
|
||||
};
|
||||
|
||||
DolphinFontRequester(QWidget* parent);
|
||||
virtual ~DolphinFontRequester();
|
||||
|
||||
void setMode(Mode mode);
|
||||
Mode mode() const;
|
||||
|
||||
/**
|
||||
* Returns the custom font (see DolphinFontRequester::customFont()),
|
||||
* if the mode is \a CustomFont, otherwise the system font is
|
||||
* returned.
|
||||
*/
|
||||
QFont font() const;
|
||||
|
||||
void setCustomFont(const QFont& font);
|
||||
QFont customFont() const;
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event);
|
||||
|
||||
private slots:
|
||||
void openFontDialog();
|
||||
void changeMode(int index);
|
||||
|
||||
private:
|
||||
QComboBox* m_modeCombo;
|
||||
QPushButton* m_chooseFontButton;
|
||||
|
||||
Mode m_mode;
|
||||
QFont m_customFont;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
#include "iconsviewsettingspage.h"
|
||||
|
||||
#include "dolphinfontrequester.h"
|
||||
#include "dolphinsettings.h"
|
||||
#include "iconsizedialog.h"
|
||||
|
||||
#include "dolphin_iconsmodesettings.h"
|
||||
|
||||
#include <kdialog.h>
|
||||
#include <kfontrequester.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kglobalsettings.h>
|
||||
#include <klocale.h>
|
||||
|
@ -70,7 +70,7 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
|
|||
textGroup->setSizePolicy(sizePolicy);
|
||||
|
||||
QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
|
||||
m_fontRequester = new KFontRequester(textGroup);
|
||||
m_fontRequester = new DolphinFontRequester(textGroup);
|
||||
|
||||
QLabel* textlinesCountLabel = new QLabel(i18nc("@label:textbox", "Number of lines:"), textGroup);
|
||||
m_textlinesCountBox = new QSpinBox(textGroup);
|
||||
|
@ -155,6 +155,7 @@ void IconsViewSettingsPage::applySettings()
|
|||
settings->setItemWidth(itemWidth);
|
||||
settings->setItemHeight(itemHeight);
|
||||
|
||||
settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
settings->setFontFamily(font.family());
|
||||
settings->setFontSize(font.pointSize());
|
||||
settings->setItalicFont(font.italic());
|
||||
|
@ -189,11 +190,16 @@ void IconsViewSettingsPage::loadSettings()
|
|||
m_iconSize = settings->iconSize();
|
||||
m_previewSize = settings->previewSize();
|
||||
|
||||
QFont font(settings->fontFamily(),
|
||||
settings->fontSize());
|
||||
font.setItalic(settings->italicFont());
|
||||
font.setBold(settings->boldFont());
|
||||
m_fontRequester->setFont(font);
|
||||
if (settings->useSystemFont()) {
|
||||
m_fontRequester->setMode(DolphinFontRequester::SystemFont);
|
||||
} else {
|
||||
QFont font(settings->fontFamily(),
|
||||
settings->fontSize());
|
||||
font.setItalic(settings->italicFont());
|
||||
font.setBold(settings->boldFont());
|
||||
m_fontRequester->setMode(DolphinFontRequester::CustomFont);
|
||||
m_fontRequester->setCustomFont(font);
|
||||
}
|
||||
|
||||
m_textlinesCountBox->setValue(settings->numberOfTextlines());
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <kvbox.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class KFontRequester;
|
||||
class DolphinFontRequester;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
|
||||
QPushButton* m_iconSizeButton;
|
||||
QComboBox* m_textWidthBox;
|
||||
KFontRequester* m_fontRequester;
|
||||
DolphinFontRequester* m_fontRequester;
|
||||
QSpinBox* m_textlinesCountBox;
|
||||
|
||||
QComboBox* m_arrangementBox;
|
||||
|
|
Loading…
Reference in a new issue