mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
Simplified code for the viewmode settings
This commit is contained in:
parent
d2a3510cc3
commit
8266e456a1
|
@ -140,12 +140,9 @@ set(dolphin_SRCS
|
|||
settings/servicemodel.cpp
|
||||
settings/startup/startupsettingspage.cpp
|
||||
settings/trash/trashsettingspage.cpp
|
||||
settings/viewmodes/detailsviewsettingspage.cpp
|
||||
settings/viewmodes/dolphinfontrequester.cpp
|
||||
settings/viewmodes/iconsizegroupbox.cpp
|
||||
settings/viewmodes/iconsviewsettingspage.cpp
|
||||
settings/viewmodes/viewsettingspage.cpp
|
||||
settings/viewmodes/viewsettingspagebase.cpp
|
||||
settings/viewmodes/viewsettingstab.cpp
|
||||
statusbar/dolphinstatusbar.cpp
|
||||
statusbar/statusbarspaceinfo.cpp
|
||||
views/zoomlevelinfo.cpp
|
||||
|
@ -204,11 +201,8 @@ install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
|
|||
|
||||
set(kcm_dolphinviewmodes_PART_SRCS
|
||||
settings/kcm/kcmdolphinviewmodes.cpp
|
||||
settings/viewmodes/detailsviewsettingspage.cpp
|
||||
settings/viewmodes/dolphinfontrequester.cpp
|
||||
settings/viewmodes/iconsizegroupbox.cpp
|
||||
settings/viewmodes/iconsviewsettingspage.cpp
|
||||
settings/viewmodes/viewsettingspagebase.cpp
|
||||
settings/viewmodes/viewsettingstab.cpp
|
||||
views/zoomlevelinfo.cpp)
|
||||
|
||||
set(kcm_dolphinnavigation_PART_SRCS
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#endif
|
||||
|
||||
#include "dolphin_generalsettings.h"
|
||||
#include "dolphin_iconsmodesettings.h"
|
||||
#include "dolphin_searchsettings.h"
|
||||
|
||||
#include <KAcceleratorManager>
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
#include <KPluginFactory>
|
||||
#include <KPluginLoader>
|
||||
|
||||
#include <settings/viewmodes/detailsviewsettingspage.h>
|
||||
#include <settings/viewmodes/iconsviewsettingspage.h>
|
||||
#include <settings/viewmodes/viewsettingstab.h>
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
|
@ -39,7 +38,7 @@ K_EXPORT_PLUGIN(KCMDolphinViewModesConfigFactory("kcmdolphinviewmodes"))
|
|||
|
||||
DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args) :
|
||||
KCModule(KCMDolphinViewModesConfigFactory::componentData(), parent),
|
||||
m_pages()
|
||||
m_tabs()
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
|
||||
|
@ -53,20 +52,24 @@ DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, cons
|
|||
|
||||
KTabWidget* tabWidget = new KTabWidget(this);
|
||||
|
||||
// initialize 'Icons' tab
|
||||
IconsViewSettingsPage* iconsPage = new IconsViewSettingsPage(tabWidget);
|
||||
tabWidget->addTab(iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
|
||||
connect(iconsPage, SIGNAL(changed()), this, SLOT(changed()));
|
||||
// Initialize 'Icons' tab
|
||||
ViewSettingsTab* iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
|
||||
tabWidget->addTab(iconsTab, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
|
||||
connect(iconsTab, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
|
||||
// TODO: initialize 'Compact' tab
|
||||
// Initialize 'Compact' tab
|
||||
ViewSettingsTab* compactTab = new ViewSettingsTab(ViewSettingsTab::CompactMode, tabWidget);
|
||||
tabWidget->addTab(compactTab, KIcon("view-list-details"), i18nc("@title:tab", "Compact"));
|
||||
connect(compactTab, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
|
||||
// initialize 'Details' tab
|
||||
DetailsViewSettingsPage* detailsPage = new DetailsViewSettingsPage(tabWidget);
|
||||
tabWidget->addTab(detailsPage, KIcon("view-list-text"), i18nc("@title:tab", "Details"));
|
||||
connect(detailsPage, SIGNAL(changed()), this, SLOT(changed()));
|
||||
// Initialize 'Details' tab
|
||||
ViewSettingsTab* detailsTab = new ViewSettingsTab(ViewSettingsTab::DetailsMode, tabWidget);
|
||||
tabWidget->addTab(detailsTab, KIcon("view-list-tree"), i18nc("@title:tab", "Details"));
|
||||
connect(detailsTab, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
|
||||
m_pages.append(iconsPage);
|
||||
m_pages.append(detailsPage);
|
||||
m_tabs.append(iconsTab);
|
||||
m_tabs.append(compactTab);
|
||||
m_tabs.append(detailsTab);
|
||||
|
||||
topLayout->addWidget(tabWidget, 0, 0);
|
||||
}
|
||||
|
@ -77,16 +80,16 @@ DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
|
|||
|
||||
void DolphinViewModesConfigModule::save()
|
||||
{
|
||||
foreach (ViewSettingsPageBase* page, m_pages) {
|
||||
page->applySettings();
|
||||
foreach (ViewSettingsTab* tab, m_tabs) {
|
||||
tab->applySettings();
|
||||
}
|
||||
reparseConfiguration();
|
||||
}
|
||||
|
||||
void DolphinViewModesConfigModule::defaults()
|
||||
{
|
||||
foreach (ViewSettingsPageBase* page, m_pages) {
|
||||
page->restoreDefaults();
|
||||
foreach (ViewSettingsTab* tab, m_tabs) {
|
||||
tab->restoreDefaultSettings();
|
||||
}
|
||||
reparseConfiguration();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <kcmodule.h>
|
||||
|
||||
class ViewSettingsPageBase;
|
||||
class ViewSettingsTab;
|
||||
|
||||
/**
|
||||
* @brief Allow to configure the Dolphin views.
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
void reparseConfiguration();
|
||||
|
||||
private:
|
||||
QList<ViewSettingsPageBase*> m_pages;
|
||||
QList<ViewSettingsTab*> m_tabs;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 "detailsviewsettingspage.h"
|
||||
|
||||
#include "iconsizegroupbox.h"
|
||||
#include "dolphinfontrequester.h"
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
|
||||
#include <KDialog>
|
||||
#include <KLocale>
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QGroupBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QRadioButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
#include <views/zoomlevelinfo.h>
|
||||
|
||||
DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget* parent) :
|
||||
ViewSettingsPageBase(parent),
|
||||
m_iconSizeGroupBox(0),
|
||||
m_fontRequester(0)
|
||||
{
|
||||
const int spacing = KDialog::spacingHint();
|
||||
const int margin = KDialog::marginHint();
|
||||
const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
|
||||
setSpacing(spacing);
|
||||
setMargin(margin);
|
||||
|
||||
// Create "Icon" properties
|
||||
m_iconSizeGroupBox = new IconSizeGroupBox(this);
|
||||
m_iconSizeGroupBox->setSizePolicy(sizePolicy);
|
||||
|
||||
const int min = ZoomLevelInfo::minimumLevel();
|
||||
const int max = ZoomLevelInfo::maximumLevel();
|
||||
m_iconSizeGroupBox->setDefaultSizeRange(min, max);
|
||||
m_iconSizeGroupBox->setPreviewSizeRange(min, max);
|
||||
|
||||
// create "Text" properties
|
||||
QWidget* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
|
||||
textGroup->setSizePolicy(sizePolicy);
|
||||
|
||||
QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
|
||||
m_fontRequester = new DolphinFontRequester(textGroup);
|
||||
|
||||
QHBoxLayout* textLayout = new QHBoxLayout(textGroup);
|
||||
textLayout->addWidget(fontLabel, 0, Qt::AlignRight);
|
||||
textLayout->addWidget(m_fontRequester);
|
||||
|
||||
// Add a dummy widget with no restriction regarding
|
||||
// a vertical resizing. This assures that the dialog layout
|
||||
// is not stretched vertically.
|
||||
new QWidget(this);
|
||||
|
||||
loadSettings();
|
||||
|
||||
connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)), this, SIGNAL(changed()));
|
||||
connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)), this, SIGNAL(changed()));
|
||||
connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
DetailsViewSettingsPage::~DetailsViewSettingsPage()
|
||||
{
|
||||
}
|
||||
|
||||
void DetailsViewSettingsPage::applySettings()
|
||||
{
|
||||
const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
|
||||
const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
|
||||
DetailsModeSettings::setIconSize(iconSize);
|
||||
DetailsModeSettings::setPreviewSize(previewSize);
|
||||
|
||||
const QFont font = m_fontRequester->font();
|
||||
DetailsModeSettings::setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
DetailsModeSettings::setFontFamily(font.family());
|
||||
DetailsModeSettings::setFontSize(font.pointSizeF());
|
||||
DetailsModeSettings::setItalicFont(font.italic());
|
||||
DetailsModeSettings::setFontWeight(font.weight());
|
||||
|
||||
DetailsModeSettings::self()->writeConfig();
|
||||
}
|
||||
|
||||
void DetailsViewSettingsPage::restoreDefaults()
|
||||
{
|
||||
DetailsModeSettings::self()->useDefaults(true);
|
||||
loadSettings();
|
||||
DetailsModeSettings::self()->useDefaults(false);
|
||||
}
|
||||
|
||||
void DetailsViewSettingsPage::loadSettings()
|
||||
{
|
||||
const QSize iconSize(DetailsModeSettings::iconSize(), DetailsModeSettings::iconSize());
|
||||
const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
|
||||
m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
|
||||
|
||||
const QSize previewSize(DetailsModeSettings::previewSize(), DetailsModeSettings::previewSize());
|
||||
const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
|
||||
m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
|
||||
|
||||
if (DetailsModeSettings::useSystemFont()) {
|
||||
m_fontRequester->setMode(DolphinFontRequester::SystemFont);
|
||||
} else {
|
||||
QFont font(DetailsModeSettings::fontFamily(),
|
||||
qRound(DetailsModeSettings::fontSize()));
|
||||
font.setItalic(DetailsModeSettings::italicFont());
|
||||
font.setWeight(DetailsModeSettings::fontWeight());
|
||||
font.setPointSizeF(DetailsModeSettings::fontSize());
|
||||
m_fontRequester->setMode(DolphinFontRequester::CustomFont);
|
||||
m_fontRequester->setCustomFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
#include "detailsviewsettingspage.moc"
|
|
@ -25,16 +25,18 @@
|
|||
#include <KComboBox>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
|
||||
KHBox(parent),
|
||||
QWidget(parent),
|
||||
m_modeCombo(0),
|
||||
m_chooseFontButton(0),
|
||||
m_mode(SystemFont),
|
||||
m_customFont()
|
||||
{
|
||||
setSpacing(KDialog::spacingHint());
|
||||
QHBoxLayout* topLayout = new QHBoxLayout(this);
|
||||
topLayout->setMargin(0);
|
||||
|
||||
m_modeCombo = new KComboBox(this);
|
||||
m_modeCombo->addItem(i18nc("@item:inlistbox Font", "System Font"));
|
||||
|
@ -47,6 +49,9 @@ DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
|
|||
this, SLOT(openFontDialog()));
|
||||
|
||||
changeMode(m_modeCombo->currentIndex());
|
||||
|
||||
topLayout->addWidget(m_modeCombo);
|
||||
topLayout->addWidget(m_chooseFontButton);
|
||||
}
|
||||
|
||||
DolphinFontRequester::~DolphinFontRequester()
|
||||
|
@ -57,7 +62,7 @@ void DolphinFontRequester::setMode(Mode mode)
|
|||
{
|
||||
m_mode = mode;
|
||||
m_modeCombo->setCurrentIndex(m_mode);
|
||||
m_modeCombo->setFont(font());
|
||||
m_modeCombo->setFont(customFont());
|
||||
m_chooseFontButton->setEnabled(m_mode == CustomFont);
|
||||
}
|
||||
|
||||
|
@ -66,7 +71,7 @@ DolphinFontRequester::Mode DolphinFontRequester::mode() const
|
|||
return m_mode;
|
||||
}
|
||||
|
||||
QFont DolphinFontRequester::font() const
|
||||
QFont DolphinFontRequester::currentFont() const
|
||||
{
|
||||
return (m_mode == CustomFont) ? m_customFont : KGlobalSettings::generalFont();
|
||||
}
|
||||
|
@ -84,9 +89,9 @@ QFont DolphinFontRequester::customFont() const
|
|||
bool DolphinFontRequester::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Polish) {
|
||||
m_modeCombo->setFont(font());
|
||||
m_modeCombo->setFont(customFont());
|
||||
}
|
||||
return KHBox::event(event);
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void DolphinFontRequester::openFontDialog()
|
||||
|
|
|
@ -20,9 +20,8 @@
|
|||
#ifndef DOLPHINFONTREQUESTER_H
|
||||
#define DOLPHINFONTREQUESTER_H
|
||||
|
||||
#include <khbox.h>
|
||||
|
||||
#include <QFont>
|
||||
#include <QWidget>
|
||||
|
||||
class KComboBox;
|
||||
class QPushButton;
|
||||
|
@ -30,7 +29,7 @@ class QPushButton;
|
|||
/**
|
||||
* @brief Allows to select between using the system font or a custom font.
|
||||
*/
|
||||
class DolphinFontRequester : public KHBox
|
||||
class DolphinFontRequester : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -52,7 +51,7 @@ public:
|
|||
* if the mode is \a CustomFont, otherwise the system font is
|
||||
* returned.
|
||||
*/
|
||||
QFont font() const;
|
||||
QFont currentFont() const;
|
||||
|
||||
void setCustomFont(const QFont& font);
|
||||
QFont customFont() const;
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 "iconsizegroupbox.h"
|
||||
|
||||
#include <KLocale>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGridLayout>
|
||||
#include <QHelpEvent>
|
||||
#include <QLabel>
|
||||
#include <QPoint>
|
||||
#include <QRect>
|
||||
#include <QSlider>
|
||||
|
||||
#include <views/zoomlevelinfo.h>
|
||||
|
||||
IconSizeGroupBox::IconSizeGroupBox(QWidget* parent) :
|
||||
QGroupBox(i18nc("@title:group", "Icon Size"), parent),
|
||||
m_defaultSizeSlider(0),
|
||||
m_previewSizeSlider(0)
|
||||
{
|
||||
QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this);
|
||||
m_defaultSizeSlider = new QSlider(Qt::Horizontal, this);
|
||||
m_defaultSizeSlider->setPageStep(1);
|
||||
m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
|
||||
connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(slotDefaultSliderMoved(int)));
|
||||
|
||||
QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
|
||||
m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
|
||||
m_previewSizeSlider->setPageStep(1);
|
||||
m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
|
||||
connect(m_previewSizeSlider, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(slotPreviewSliderMoved(int)));
|
||||
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
|
||||
layout->addWidget(m_defaultSizeSlider, 0, 1);
|
||||
layout->addWidget(previewLabel, 1, 0, Qt::AlignRight);
|
||||
layout->addWidget(m_previewSizeSlider, 1, 1);
|
||||
}
|
||||
|
||||
IconSizeGroupBox::~IconSizeGroupBox()
|
||||
{
|
||||
}
|
||||
|
||||
void IconSizeGroupBox::setDefaultSizeRange(int min, int max)
|
||||
{
|
||||
m_defaultSizeSlider->setRange(min, max);
|
||||
}
|
||||
|
||||
void IconSizeGroupBox::setPreviewSizeRange(int min, int max)
|
||||
{
|
||||
m_previewSizeSlider->setRange(min, max);
|
||||
}
|
||||
|
||||
void IconSizeGroupBox::setDefaultSizeValue(int value)
|
||||
{
|
||||
m_defaultSizeSlider->setValue(value);
|
||||
}
|
||||
|
||||
int IconSizeGroupBox::defaultSizeValue() const
|
||||
{
|
||||
return m_defaultSizeSlider->value();
|
||||
}
|
||||
|
||||
void IconSizeGroupBox::setPreviewSizeValue(int value)
|
||||
{
|
||||
m_previewSizeSlider->setValue(value);
|
||||
}
|
||||
|
||||
int IconSizeGroupBox::previewSizeValue() const
|
||||
{
|
||||
return m_previewSizeSlider->value();
|
||||
}
|
||||
|
||||
void IconSizeGroupBox::slotDefaultSliderMoved(int value)
|
||||
{
|
||||
showToolTip(m_defaultSizeSlider, value);
|
||||
emit defaultSizeChanged(value);
|
||||
}
|
||||
|
||||
void IconSizeGroupBox::slotPreviewSliderMoved(int value)
|
||||
{
|
||||
showToolTip(m_previewSizeSlider, value);
|
||||
emit previewSizeChanged(value);
|
||||
}
|
||||
|
||||
void IconSizeGroupBox::showToolTip(QSlider* slider, int value)
|
||||
{
|
||||
const int size = ZoomLevelInfo::iconSizeForZoomLevel(value);
|
||||
slider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size));
|
||||
if (!slider->isVisible()) {
|
||||
return;
|
||||
}
|
||||
QPoint global = slider->rect().topLeft();
|
||||
global.ry() += slider->height() / 2;
|
||||
QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global));
|
||||
QApplication::sendEvent(slider, &toolTipEvent);
|
||||
}
|
||||
|
||||
#include "iconsizegroupbox.moc"
|
|
@ -1,66 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 ICONSIZEGROUPBOX_H
|
||||
#define ICONSIZEGROUPBOX_H
|
||||
|
||||
#include <QGroupBox>
|
||||
|
||||
class QSlider;
|
||||
|
||||
/**
|
||||
* @short Provides a group box for adjusting the icon sizes.
|
||||
*
|
||||
* It is possible to adjust the default icon size and the icon
|
||||
* size when previews are used.
|
||||
*/
|
||||
class IconSizeGroupBox : public QGroupBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IconSizeGroupBox(QWidget* parent);
|
||||
virtual ~IconSizeGroupBox();
|
||||
|
||||
void setDefaultSizeRange(int min, int max);
|
||||
void setPreviewSizeRange(int min, int max);
|
||||
|
||||
void setDefaultSizeValue(int value);
|
||||
int defaultSizeValue() const;
|
||||
|
||||
void setPreviewSizeValue(int value);
|
||||
int previewSizeValue() const;
|
||||
|
||||
signals:
|
||||
void defaultSizeChanged(int value);
|
||||
void previewSizeChanged(int value);
|
||||
|
||||
private slots:
|
||||
void slotDefaultSliderMoved(int value);
|
||||
void slotPreviewSliderMoved(int value);
|
||||
|
||||
private:
|
||||
void showToolTip(QSlider* slider, int value);
|
||||
|
||||
private:
|
||||
QSlider* m_defaultSizeSlider;
|
||||
QSlider* m_previewSizeSlider;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,153 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 "iconsviewsettingspage.h"
|
||||
|
||||
#include "dolphinfontrequester.h"
|
||||
#include "iconsizegroupbox.h"
|
||||
|
||||
#include "dolphin_iconsmodesettings.h"
|
||||
|
||||
#include <KDialog>
|
||||
#include <KIconLoader>
|
||||
#include <KGlobalSettings>
|
||||
#include <KLocale>
|
||||
#include <KComboBox>
|
||||
#include <KNumInput>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include <views/zoomlevelinfo.h>
|
||||
|
||||
IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) :
|
||||
ViewSettingsPageBase(parent),
|
||||
m_iconSizeGroupBox(0),
|
||||
m_textWidthBox(0),
|
||||
m_fontRequester(0)
|
||||
{
|
||||
const int spacing = KDialog::spacingHint();
|
||||
const int margin = KDialog::marginHint();
|
||||
const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
|
||||
setSpacing(spacing);
|
||||
setMargin(margin);
|
||||
|
||||
// Create "Icon" properties
|
||||
m_iconSizeGroupBox = new IconSizeGroupBox(this);
|
||||
m_iconSizeGroupBox->setSizePolicy(sizePolicy);
|
||||
|
||||
const int min = ZoomLevelInfo::minimumLevel();
|
||||
const int max = ZoomLevelInfo::maximumLevel();
|
||||
m_iconSizeGroupBox->setDefaultSizeRange(min, max);
|
||||
m_iconSizeGroupBox->setPreviewSizeRange(min, max);
|
||||
|
||||
// Create 'Text' group for selecting the font, the number of lines
|
||||
// and the text width
|
||||
QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
|
||||
textGroup->setSizePolicy(sizePolicy);
|
||||
|
||||
QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
|
||||
m_fontRequester = new DolphinFontRequester(textGroup);
|
||||
|
||||
QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
|
||||
m_textWidthBox = new KComboBox(textGroup);
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Huge"));
|
||||
|
||||
QGridLayout* textGroupLayout = new QGridLayout(textGroup);
|
||||
textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
|
||||
textGroupLayout->addWidget(m_fontRequester, 0, 1);
|
||||
textGroupLayout->addWidget(textWidthLabel, 2, 0, Qt::AlignRight);
|
||||
textGroupLayout->addWidget(m_textWidthBox, 2, 1);
|
||||
|
||||
// Add a dummy widget with no restriction regarding
|
||||
// a vertical resizing. This assures that the dialog layout
|
||||
// is not stretched vertically.
|
||||
new QWidget(this);
|
||||
|
||||
loadSettings();
|
||||
|
||||
connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)), this, SIGNAL(changed()));
|
||||
connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)), this, SIGNAL(changed()));
|
||||
connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
connect(m_textWidthBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
IconsViewSettingsPage::~IconsViewSettingsPage()
|
||||
{
|
||||
}
|
||||
|
||||
void IconsViewSettingsPage::applySettings()
|
||||
{
|
||||
const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
|
||||
const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
|
||||
IconsModeSettings::setIconSize(iconSize);
|
||||
IconsModeSettings::setPreviewSize(previewSize);
|
||||
|
||||
const QFont font = m_fontRequester->font();
|
||||
IconsModeSettings::setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
IconsModeSettings::setFontFamily(font.family());
|
||||
IconsModeSettings::setFontSize(font.pointSizeF());
|
||||
IconsModeSettings::setItalicFont(font.italic());
|
||||
IconsModeSettings::setFontWeight(font.weight());
|
||||
|
||||
IconsModeSettings::setTextWidthIndex(m_textWidthBox->currentIndex());
|
||||
|
||||
IconsModeSettings::self()->writeConfig();
|
||||
}
|
||||
|
||||
void IconsViewSettingsPage::restoreDefaults()
|
||||
{
|
||||
IconsModeSettings::self()->useDefaults(true);
|
||||
loadSettings();
|
||||
IconsModeSettings::self()->useDefaults(false);
|
||||
}
|
||||
|
||||
void IconsViewSettingsPage::loadSettings()
|
||||
{
|
||||
const QSize iconSize(IconsModeSettings::iconSize(), IconsModeSettings::iconSize());
|
||||
const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
|
||||
m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
|
||||
|
||||
const QSize previewSize(IconsModeSettings::previewSize(), IconsModeSettings::previewSize());
|
||||
const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
|
||||
m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
|
||||
|
||||
if (IconsModeSettings::useSystemFont()) {
|
||||
m_fontRequester->setMode(DolphinFontRequester::SystemFont);
|
||||
} else {
|
||||
QFont font(IconsModeSettings::fontFamily(),
|
||||
qRound(IconsModeSettings::fontSize()));
|
||||
font.setItalic(IconsModeSettings::italicFont());
|
||||
font.setWeight(IconsModeSettings::fontWeight());
|
||||
font.setPointSizeF(IconsModeSettings::fontSize());
|
||||
m_fontRequester->setMode(DolphinFontRequester::CustomFont);
|
||||
m_fontRequester->setCustomFont(font);
|
||||
}
|
||||
|
||||
m_textWidthBox->setCurrentIndex(IconsModeSettings::textWidthIndex());
|
||||
}
|
||||
|
||||
#include "iconsviewsettingspage.moc"
|
|
@ -1,69 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 ICONSVIEWSETTINGSPAGE_H
|
||||
#define ICONSVIEWSETTINGSPAGE_H
|
||||
|
||||
#include "viewsettingspagebase.h"
|
||||
|
||||
class DolphinFontRequester;
|
||||
class IconSizeGroupBox;
|
||||
class KComboBox;
|
||||
class KIntSpinBox;
|
||||
|
||||
/**
|
||||
* @brief Tab page for the 'Icons Mode' settings
|
||||
* of the Dolphin settings dialog.
|
||||
*
|
||||
* Allows to set:
|
||||
* - icon size
|
||||
* - preview size
|
||||
* - text width
|
||||
* - font
|
||||
*
|
||||
* @see DolphinIconsViewSettings
|
||||
*/
|
||||
class IconsViewSettingsPage : public ViewSettingsPageBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IconsViewSettingsPage(QWidget* parent);
|
||||
virtual ~IconsViewSettingsPage();
|
||||
|
||||
/**
|
||||
* Applies the settings for the icons view.
|
||||
* The settings are persisted automatically when
|
||||
* closing Dolphin.
|
||||
*/
|
||||
virtual void applySettings();
|
||||
|
||||
/** Restores the settings to default values. */
|
||||
virtual void restoreDefaults();
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
|
||||
private:
|
||||
IconSizeGroupBox* m_iconSizeGroupBox;
|
||||
KComboBox* m_textWidthBox;
|
||||
DolphinFontRequester* m_fontRequester;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
#include "viewsettingspage.h"
|
||||
|
||||
#include "iconsviewsettingspage.h"
|
||||
#include "detailsviewsettingspage.h"
|
||||
#include <views/dolphinview.h>
|
||||
#include "viewsettingstab.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
|
||||
ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
|
||||
SettingsPageBase(parent),
|
||||
m_pages()
|
||||
m_tabs()
|
||||
{
|
||||
QVBoxLayout* topLayout = new QVBoxLayout(this);
|
||||
topLayout->setMargin(0);
|
||||
|
@ -40,20 +40,24 @@ ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
|
|||
|
||||
KTabWidget* tabWidget = new KTabWidget(this);
|
||||
|
||||
// initialize 'Icons' tab
|
||||
IconsViewSettingsPage* iconsPage = new IconsViewSettingsPage(tabWidget);
|
||||
tabWidget->addTab(iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
|
||||
connect(iconsPage, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
// Initialize 'Icons' tab
|
||||
ViewSettingsTab* iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
|
||||
tabWidget->addTab(iconsTab, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
|
||||
connect(iconsTab, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
|
||||
// TODO: initialize 'Compact' tab
|
||||
// Initialize 'Compact' tab
|
||||
ViewSettingsTab* compactTab = new ViewSettingsTab(ViewSettingsTab::CompactMode, tabWidget);
|
||||
tabWidget->addTab(compactTab, KIcon("view-list-details"), i18nc("@title:tab", "Compact"));
|
||||
connect(compactTab, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
|
||||
// initialize 'Details' tab
|
||||
DetailsViewSettingsPage* detailsPage = new DetailsViewSettingsPage(tabWidget);
|
||||
tabWidget->addTab(detailsPage, KIcon("view-list-text"), i18nc("@title:tab", "Details"));
|
||||
connect(detailsPage, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
// Initialize 'Details' tab
|
||||
ViewSettingsTab* detailsTab = new ViewSettingsTab(ViewSettingsTab::DetailsMode, tabWidget);
|
||||
tabWidget->addTab(detailsTab, KIcon("view-list-tree"), i18nc("@title:tab", "Details"));
|
||||
connect(detailsTab, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
|
||||
m_pages.append(iconsPage);
|
||||
m_pages.append(detailsPage);
|
||||
m_tabs.append(iconsTab);
|
||||
m_tabs.append(compactTab);
|
||||
m_tabs.append(detailsTab);
|
||||
|
||||
topLayout->addWidget(tabWidget, 0, 0);
|
||||
}
|
||||
|
@ -64,15 +68,15 @@ ViewSettingsPage::~ViewSettingsPage()
|
|||
|
||||
void ViewSettingsPage::applySettings()
|
||||
{
|
||||
foreach (ViewSettingsPageBase* page, m_pages) {
|
||||
page->applySettings();
|
||||
foreach (ViewSettingsTab* tab, m_tabs) {
|
||||
tab->applySettings();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewSettingsPage::restoreDefaults()
|
||||
{
|
||||
foreach (ViewSettingsPageBase* page, m_pages) {
|
||||
page->restoreDefaults();
|
||||
foreach (ViewSettingsTab* tab, m_tabs) {
|
||||
tab->restoreDefaultSettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <settings/settingspagebase.h>
|
||||
|
||||
class ViewSettingsPageBase;
|
||||
class ViewSettingsTab;
|
||||
class QWidget;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ public:
|
|||
virtual void restoreDefaults();
|
||||
|
||||
private:
|
||||
QList<ViewSettingsPageBase*> m_pages;
|
||||
QList<ViewSettingsTab*> m_tabs;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 "viewsettingspagebase.h"
|
||||
|
||||
ViewSettingsPageBase::ViewSettingsPageBase(QWidget* parent) :
|
||||
KVBox(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ViewSettingsPageBase::~ViewSettingsPageBase()
|
||||
{
|
||||
}
|
||||
|
||||
#include "viewsettingspagebase.moc"
|
|
@ -1,55 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 VIEWSETTINGSPAGEBASE_H
|
||||
#define VIEWSETTINGSPAGEBASE_H
|
||||
|
||||
#include <KVBox>
|
||||
|
||||
/**
|
||||
* @brief Base class for view settings configuration pages.
|
||||
*
|
||||
* @see GeneralViewSettingsPage;
|
||||
* @see IconViewSettingsPage
|
||||
* @see DetailsViewSettingsPage
|
||||
* @see ColumnViewSettingsPage
|
||||
*/
|
||||
class ViewSettingsPageBase : public KVBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ViewSettingsPageBase(QWidget* parent);
|
||||
virtual ~ViewSettingsPageBase();
|
||||
|
||||
/**
|
||||
* Applies the settings for the view.
|
||||
* The settings are persisted automatically when
|
||||
* closing Dolphin.
|
||||
*/
|
||||
virtual void applySettings() = 0;
|
||||
|
||||
/** Restores the settings to default values. */
|
||||
virtual void restoreDefaults() = 0;
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
};
|
||||
|
||||
#endif
|
215
src/settings/viewmodes/viewsettingstab.cpp
Normal file
215
src/settings/viewmodes/viewsettingstab.cpp
Normal file
|
@ -0,0 +1,215 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008-2011 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 "viewsettingstab.h"
|
||||
|
||||
#include "dolphinfontrequester.h"
|
||||
#include "dolphin_compactmodesettings.h"
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
#include "dolphin_iconsmodesettings.h"
|
||||
|
||||
#include <KComboBox>
|
||||
#include <KLocale>
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <views/zoomlevelinfo.h>
|
||||
|
||||
template<class T>
|
||||
void apply(int iconSizeValue, int previewSizeValue, const QFont& font, bool useSystemFont)
|
||||
{
|
||||
const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(iconSizeValue);
|
||||
const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(previewSizeValue);
|
||||
T::setIconSize(iconSize);
|
||||
T::setPreviewSize(previewSize);
|
||||
|
||||
T::setUseSystemFont(useSystemFont);
|
||||
T::setFontFamily(font.family());
|
||||
T::setFontSize(font.pointSizeF());
|
||||
T::setItalicFont(font.italic());
|
||||
T::setFontWeight(font.weight());
|
||||
|
||||
T::self()->writeConfig();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void load(int* iconSizeValue, int* previewSizeValue, QFont* font, bool* useSystemFont)
|
||||
{
|
||||
const QSize iconSize(T::iconSize(), T::iconSize());
|
||||
*iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
|
||||
|
||||
const QSize previewSize(T::previewSize(), T::previewSize());
|
||||
*previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
|
||||
|
||||
*useSystemFont = T::useSystemFont();
|
||||
|
||||
*font = QFont(T::fontFamily(), qRound(T::fontSize()));
|
||||
font->setItalic(T::italicFont());
|
||||
font->setWeight(T::fontWeight());
|
||||
font->setPointSizeF(T::fontSize());
|
||||
}
|
||||
|
||||
|
||||
ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
m_mode(mode),
|
||||
m_defaultSizeSlider(0),
|
||||
m_previewSizeSlider(0),
|
||||
m_fontRequester(0),
|
||||
m_textWidthBox(0)
|
||||
{
|
||||
QVBoxLayout* topLayout = new QVBoxLayout(this);
|
||||
|
||||
// Create "Icon Size" group
|
||||
QGroupBox* iconSizeGroup = new QGroupBox(this);
|
||||
iconSizeGroup->setTitle(i18nc("@title:group", "Icon Size"));
|
||||
|
||||
const int minRange = ZoomLevelInfo::minimumLevel();
|
||||
const int maxRange = ZoomLevelInfo::maximumLevel();
|
||||
|
||||
QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this);
|
||||
m_defaultSizeSlider = new QSlider(Qt::Horizontal, this);
|
||||
m_defaultSizeSlider->setPageStep(1);
|
||||
m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
|
||||
m_defaultSizeSlider->setRange(minRange, maxRange);
|
||||
|
||||
QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
|
||||
m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
|
||||
m_previewSizeSlider->setPageStep(1);
|
||||
m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
|
||||
m_previewSizeSlider->setRange(minRange, maxRange);
|
||||
|
||||
QGridLayout* layout = new QGridLayout(iconSizeGroup);
|
||||
layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
|
||||
layout->addWidget(m_defaultSizeSlider, 0, 1);
|
||||
layout->addWidget(previewLabel, 1, 0, Qt::AlignRight);
|
||||
layout->addWidget(m_previewSizeSlider, 1, 1);
|
||||
|
||||
// Create "Text" group
|
||||
QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
|
||||
|
||||
QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
|
||||
m_fontRequester = new DolphinFontRequester(textGroup);
|
||||
|
||||
QGridLayout* textGroupLayout = new QGridLayout(textGroup);
|
||||
textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
|
||||
textGroupLayout->addWidget(m_fontRequester, 0, 1);
|
||||
|
||||
if (m_mode == IconsMode) {
|
||||
QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
|
||||
m_textWidthBox = new KComboBox(textGroup);
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
|
||||
m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Huge"));
|
||||
|
||||
textGroupLayout->addWidget(textWidthLabel, 2, 0, Qt::AlignRight);
|
||||
textGroupLayout->addWidget(m_textWidthBox, 2, 1);
|
||||
}
|
||||
|
||||
topLayout->addWidget(iconSizeGroup);
|
||||
topLayout->addWidget(textGroup);
|
||||
topLayout->addStretch(1);
|
||||
|
||||
loadSettings();
|
||||
|
||||
connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
|
||||
connect(m_previewSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
|
||||
connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
if (m_mode == IconsMode) {
|
||||
connect(m_textWidthBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
|
||||
}
|
||||
}
|
||||
|
||||
ViewSettingsTab::~ViewSettingsTab()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewSettingsTab::applySettings()
|
||||
{
|
||||
const int defaultSize = m_defaultSizeSlider->value();
|
||||
const int previewSize = m_previewSizeSlider->value();
|
||||
const QFont font = m_fontRequester->currentFont();
|
||||
const bool useSystemFont = (m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
|
||||
switch (m_mode) {
|
||||
case IconsMode:
|
||||
IconsModeSettings::setTextWidthIndex(m_textWidthBox->currentIndex());
|
||||
apply<IconsModeSettings>(defaultSize, previewSize, font, useSystemFont);
|
||||
break;
|
||||
case CompactMode:
|
||||
apply<CompactModeSettings>(defaultSize, previewSize, font, useSystemFont);
|
||||
break;
|
||||
case DetailsMode:
|
||||
apply<DetailsModeSettings>(defaultSize, previewSize, font, useSystemFont);
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ViewSettingsTab::restoreDefaultSettings()
|
||||
{
|
||||
KConfigSkeleton* settings = 0;
|
||||
switch (m_mode) {
|
||||
case IconsMode: settings = IconsModeSettings::self(); break;
|
||||
case CompactMode: settings = CompactModeSettings::self(); break;
|
||||
case DetailsMode: settings = DetailsModeSettings::self(); break;
|
||||
default: Q_ASSERT(false); break;
|
||||
}
|
||||
|
||||
settings->useDefaults(true);
|
||||
loadSettings();
|
||||
settings->useDefaults(false);
|
||||
}
|
||||
|
||||
void ViewSettingsTab::loadSettings()
|
||||
{
|
||||
int iconSizeValue = 0;
|
||||
int previewSizeValue = 0;
|
||||
QFont font;
|
||||
bool useSystemFont = false;
|
||||
|
||||
switch (m_mode) {
|
||||
case IconsMode:
|
||||
m_textWidthBox->setCurrentIndex(IconsModeSettings::textWidthIndex());
|
||||
load<IconsModeSettings>(&iconSizeValue, &previewSizeValue, &font, &useSystemFont);
|
||||
break;
|
||||
case CompactMode:
|
||||
load<CompactModeSettings>(&iconSizeValue, &previewSizeValue, &font, &useSystemFont);
|
||||
break;
|
||||
case DetailsMode:
|
||||
load<DetailsModeSettings>(&iconSizeValue, &previewSizeValue, &font, &useSystemFont);
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
m_defaultSizeSlider->setValue(iconSizeValue);
|
||||
m_previewSizeSlider->setValue(previewSizeValue);
|
||||
m_fontRequester->setMode(useSystemFont ? DolphinFontRequester::SystemFont : DolphinFontRequester::CustomFont);
|
||||
m_fontRequester->setCustomFont(font);
|
||||
}
|
||||
|
||||
#include "viewsettingstab.moc"
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* Copyright (C) 2008-2011 by Peter Penz <peter.penz19@gmail.com> *
|
||||
* *
|
||||
* 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 *
|
||||
|
@ -17,42 +17,49 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef DETAILSVIEWSETTINGSPAGE_H
|
||||
#define DETAILSVIEWSETTINGSPAGE_H
|
||||
#ifndef VIEWSETTINGSTAB_H
|
||||
#define VIEWSETTINGSTAB_H
|
||||
|
||||
#include "viewsettingspagebase.h"
|
||||
#include <QWidget>
|
||||
|
||||
class DolphinFontRequester;
|
||||
class IconSizeGroupBox;
|
||||
class KComboBox;
|
||||
class QSlider;
|
||||
|
||||
/**
|
||||
* @brief Represents the page from the Dolphin Settings which allows
|
||||
* to modify the settings for the details view.
|
||||
* @brief Represents one tab of the view-settings page.
|
||||
*/
|
||||
class DetailsViewSettingsPage : public ViewSettingsPageBase
|
||||
class ViewSettingsTab : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DetailsViewSettingsPage(QWidget* parent);
|
||||
virtual ~DetailsViewSettingsPage();
|
||||
enum Mode
|
||||
{
|
||||
IconsMode,
|
||||
CompactMode,
|
||||
DetailsMode
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies the settings for the details view.
|
||||
* The settings are persisted automatically when
|
||||
* closing Dolphin.
|
||||
*/
|
||||
virtual void applySettings();
|
||||
explicit ViewSettingsTab(Mode mode, QWidget* parent = 0);
|
||||
virtual ~ViewSettingsTab();
|
||||
|
||||
/** Restores the settings to default values. */
|
||||
virtual void restoreDefaults();
|
||||
void applySettings();
|
||||
void restoreDefaultSettings();
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
|
||||
private:
|
||||
IconSizeGroupBox* m_iconSizeGroupBox;
|
||||
Mode m_mode;
|
||||
QSlider* m_defaultSizeSlider;
|
||||
QSlider* m_previewSizeSlider;
|
||||
|
||||
DolphinFontRequester* m_fontRequester;
|
||||
KComboBox* m_textWidthBox;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -96,8 +96,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
|
|||
QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
|
||||
m_viewMode = new KComboBox(propsGrid);
|
||||
m_viewMode->addItem(KIcon("view-list-icons"), i18nc("@item:inlistbox", "Icons"));
|
||||
m_viewMode->addItem(KIcon("feffi"), i18nc("@item:inlistbox", "Compact")); // TODO: adjust icons
|
||||
m_viewMode->addItem(KIcon("view-list-text"), i18nc("@item:inlistbox", "Details"));
|
||||
m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Compact"));
|
||||
m_viewMode->addItem(KIcon("view-list-tree"), i18nc("@item:inlistbox", "Details"));
|
||||
|
||||
QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
|
||||
QWidget* sortingBox = new QWidget(propsGrid);
|
||||
|
|
|
@ -480,7 +480,7 @@ KToggleAction* DolphinViewActionHandler::detailsModeAction()
|
|||
detailsView->setText(i18nc("@action:inmenu View Mode", "Details"));
|
||||
detailsView->setToolTip(i18nc("@info", "Details view mode"));
|
||||
detailsView->setShortcut(Qt::CTRL | Qt::Key_3);
|
||||
detailsView->setIcon(KIcon("view-list-text"));
|
||||
detailsView->setIcon(KIcon("view-list-tree"));
|
||||
detailsView->setData(QVariant::fromValue(DolphinView::DetailsView));
|
||||
return detailsView;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue