Commit 5d89cc07 authored by Peter Penz's avatar Peter Penz
Browse files

Use KFontRequester for dialogs as suggested by Ellen at...

Use KFontRequester for dialogs as suggested by Ellen at http://wiki.openusability.org/guidelines/index.php/Practical_Examples:Configuration_Dialogs. TODO: get rid of Qt3 classes in these dialogs and use a more sensible spacing/margin

svn path=/trunk/KDE/kdebase/apps/; revision=642269
parent 8e861085
......@@ -19,20 +19,22 @@
***************************************************************************/
#include "detailsviewsettingspage.h"
#include <qcheckbox.h>
#include <kfontrequester.h>
#include <klocale.h>
#include <kdialog.h>
#include <qfontcombobox.h>
#include <qspinbox.h>
#include <qlabel.h>
#include <q3grid.h>
#include <assert.h>
#include <q3buttongroup.h>
#include <qradiobutton.h>
#include <qcombobox.h>
#include <q3groupbox.h>
#include <q3groupbox.h>
#include <kvbox.h>
#include "dolphinsettings.h"
#include "dolphin_detailsmodesettings.h"
#include "dolphindetailsview.h"
......@@ -47,7 +49,8 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
m_groupBox(0),
m_smallIconSize(0),
m_mediumIconSize(0),
m_largeIconSize(0)
m_largeIconSize(0),
m_fontRequester(0)
{
const int spacing = KDialog::spacingHint();
const int margin = KDialog::marginHint();
......@@ -57,7 +60,7 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
setMargin(margin);
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
assert(settings != 0);
Q_ASSERT(settings != 0);
// create "Columns" properties
Q3GroupBox* columnsGroup = new Q3GroupBox(4, Qt::Vertical, i18n("Columns"), this);
......@@ -98,24 +101,18 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
m_smallIconSize->setChecked(true);
}
//new QLabel(i18n("Icon size:"), iconGroup);
//m_iconSizeBox = new QComboBox(iconGroup);
//m_iconSizeBox->insertItem(i18n("Small"));
//m_iconSizeBox->insertItem(i18n("Medium"));
//m_iconSizeBox->insertItem(i18n("Large"));
// create "Text" properties
Q3GroupBox* textGroup = new Q3GroupBox(2, Qt::Horizontal, i18n("Text"), this);
textGroup->setSizePolicy(sizePolicy);
textGroup->setMargin(margin);
new QLabel(i18n("Font family:"), textGroup);
m_fontFamilyBox = new QFontComboBox(textGroup);
m_fontFamilyBox->setCurrentFont(settings->fontFamily());
new QLabel(i18n("Font size:"), textGroup);
m_fontSizeBox = new QSpinBox(6, 99, 1, textGroup);
m_fontSizeBox->setValue(settings->fontSize());
new QLabel(i18n("Font:"), textGroup);
m_fontRequester = new KFontRequester(textGroup);
QFont font(settings->fontFamily(),
settings->fontSize());
font.setItalic(settings->italicFont());
font.setBold(settings->boldFont());
m_fontRequester->setFont(font);
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
......@@ -123,7 +120,6 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
new QWidget(this);
}
DetailsViewSettingsPage::~DetailsViewSettingsPage()
{
}
......@@ -131,7 +127,7 @@ DetailsViewSettingsPage::~DetailsViewSettingsPage()
void DetailsViewSettingsPage::applySettings()
{
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
assert(settings != 0);
Q_ASSERT(settings != 0);
settings->setShowDate(m_dateBox->isChecked());
settings->setShowPermissions(m_permissionsBox->isChecked());
......@@ -147,8 +143,11 @@ void DetailsViewSettingsPage::applySettings()
}
settings->setIconSize(iconSize);
settings->setFontFamily(m_fontFamilyBox->currentFont().family());
settings->setFontSize(m_fontSizeBox->value());
const QFont font = m_fontRequester->font();
settings->setFontFamily(font.family());
settings->setFontSize(font.pointSize());
settings->setItalicFont(font.italic());
settings->setBoldFont(font.bold());
}
#include "detailsviewsettingspage.moc"
......@@ -24,15 +24,15 @@
#include <kvbox.h>
class DolphinMainWindow;
class KFontRequester;
class QCheckBox;
class QFontComboBox;
class QSpinBox;
class QComboBox;
class QRadioButton;
/**
* @brief Represents the page from the Dolphin Settings which allows
* to modify the settings for the details view.
* to modify the settings for the details view.
*/
class DetailsViewSettingsPage : public KVBox
{
......@@ -58,9 +58,7 @@ private:
QRadioButton* m_smallIconSize;
QRadioButton* m_mediumIconSize;
QRadioButton* m_largeIconSize;
QFontComboBox* m_fontFamilyBox;
QSpinBox* m_fontSizeBox;
KFontRequester* m_fontRequester;
};
#endif
......@@ -13,6 +13,14 @@
<label>Font size</label>
<default code="true">KGlobalSettings::generalFont().pointSize()</default>
</entry>
<entry name="ItalicFont" type="Bool">
<label>Italic</label>
<default>false</default>
</entry>
<entry name="BoldFont" type="Bool">
<label>Bold</label>
<default>false</default>
</entry>
<entry name="IconSize" type="Int">
<label>Icon size</label>
<default code="true">K3Icon::SizeSmall</default>
......
......@@ -18,7 +18,15 @@
<label>Font size</label>
<default code="true">KGlobalSettings::generalFont().pointSize()</default>
</entry>
<entry name="GridHeight" type="Int">
<entry name="ItalicFont" type="Bool">
<label>Italic</label>
<default>false</default>
</entry>
<entry name="BoldFont" type="Bool">
<label>Bold</label>
<default>false</default>
</entry>
<entry name="GridHeight" type="Int">
<label>Grid height</label>
<default code="true">96</default>
</entry>
......
......@@ -75,7 +75,12 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
Q_ASSERT(settings != 0);
m_viewOptions = QTreeView::viewOptions();
m_viewOptions.font = QFont(settings->fontFamily(), settings->fontSize());
QFont font(settings->fontFamily(), settings->fontSize());
font.setItalic(settings->italicFont());
font.setBold(settings->boldFont());
m_viewOptions.font = font;
updateDecorationSize();
}
......
......@@ -57,7 +57,11 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
Q_ASSERT(settings != 0);
m_viewOptions = QListView::viewOptions();
m_viewOptions.font = QFont(settings->fontFamily(), settings->fontSize());
QFont font(settings->fontFamily(), settings->fontSize());
font.setItalic(settings->italicFont());
font.setBold(settings->boldFont());
m_viewOptions.font = font;
updateGridSize(controller->showPreview());
......
......@@ -32,6 +32,7 @@
#include <qspinbox.h>
#include <qfontcombobox.h>
#include <kfontrequester.h>
#include <kiconloader.h>
#include <kdialog.h>
#include <kglobalsettings.h>
......@@ -52,8 +53,7 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
m_previewSize(0),
m_iconSizeButton(0),
m_textWidthBox(0),
m_fontFamilyBox(0),
m_fontSizeBox(0),
m_fontRequester(0),
m_textlinesCountBox(0),
m_arrangementBox(0),
m_gridSpacingBox(0)
......@@ -82,13 +82,13 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
textGroup->setSizePolicy(sizePolicy);
textGroup->setMargin(margin);
new QLabel(i18n("Font family:"), textGroup);
m_fontFamilyBox = new QFontComboBox(textGroup);
m_fontFamilyBox->setCurrentFont(settings->fontFamily());
new QLabel(i18n("Font size:"), textGroup);
m_fontSizeBox = new QSpinBox(6, 99, 1, textGroup);
m_fontSizeBox->setValue(settings->fontSize());
new QLabel(i18n("Font:"), textGroup);
m_fontRequester = new KFontRequester(textGroup);
QFont font(settings->fontFamily(),
settings->fontSize());
font.setItalic(settings->italicFont());
font.setBold(settings->boldFont());
m_fontRequester->setFont(font);
new QLabel(i18n("Number of lines:"), textGroup);
m_textlinesCountBox = new QSpinBox(1, 5, 1, textGroup);
......@@ -138,7 +138,8 @@ void IconsViewSettingsPage::applySettings()
settings->setIconSize(m_iconSize);
settings->setPreviewSize(m_previewSize);
const int fontSize = m_fontSizeBox->value();
const QFont font = m_fontRequester->font();
const int fontSize = font.pointSize();
const int arrangement = (m_arrangementBox->currentIndex() == 0) ?
QListView::LeftToRight :
......@@ -163,8 +164,11 @@ void IconsViewSettingsPage::applySettings()
settings->setGridWidth(gridWidth);
settings->setGridHeight(gridHeight);
settings->setFontFamily(m_fontFamilyBox->currentFont().family());
settings->setFontFamily(font.family());
settings->setFontSize(fontSize);
settings->setItalicFont(font.italic());
settings->setBoldFont(font.bold());
settings->setNumberOfTextlines(m_textlinesCountBox->value());
settings->setGridSpacing(GRID_SPACING_BASE +
......
......@@ -24,12 +24,12 @@
#include <kvbox.h>
class DolphinMainWindow;
class KFontRequester;
class QSlider;
class QComboBox;
class QCheckBox;
class QPushButton;
class QSpinBox;
class QFontComboBox;
/**
* @brief Tab page for the 'Icons Mode' and 'Previews Mode' settings
......@@ -40,8 +40,7 @@ class QFontComboBox;
* - preview size
* - text width
* - grid spacing
* - font family
* - font size
* - font
* - number of text lines
* - arrangement
*
......@@ -79,8 +78,7 @@ private:
QPushButton* m_iconSizeButton;
QComboBox* m_textWidthBox;
QFontComboBox* m_fontFamilyBox;
QSpinBox* m_fontSizeBox;
KFontRequester* m_fontRequester;
QSpinBox* m_textlinesCountBox;
QComboBox* m_arrangementBox;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment