filterbar.cpp
generalsettingspage.cpp
generalviewsettingspage.cpp
+ iconsizedialog.cpp
iconsviewsettingspage.cpp
infosidebarpage.cpp
main.cpp
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2006 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 "iconsizedialog.h"
+
+#include "dolphinsettings.h"
+#include "pixmapviewer.h"
+
+#include "dolphin_iconsmodesettings.h"
+
+#include <kglobalsettings.h>
+#include <klocale.h>
+#include <kvbox.h>
+
+#include <QGroupBox>
+#include <QLabel>
+#include <QSlider>
+#include <QVBoxLayout>
+
+IconSizeDialog::IconSizeDialog(QWidget* parent) :
+ KDialog(parent),
+ m_iconSize(0),
+ m_previewSize(0),
+ m_iconSizeSlider(0),
+ m_iconSizeViewer(0),
+ m_previewSizeSlider(0),
+ m_previewSizeViewer(0)
+
+{
+ IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+ Q_ASSERT(settings != 0);
+ m_iconSize = settings->iconSize();
+ m_previewSize = settings->previewSize();
+
+ const int spacing = KDialog::spacingHint();
+
+ setCaption(i18n("Change Icon and Preview Size"));
+ setButtons(Ok|Cancel);
+ setDefaultButton(Ok);
+
+ QWidget* main = new QWidget();
+ QHBoxLayout* topLayout = new QHBoxLayout();
+
+ // create 'Icon Size' group including slider and preview
+ QGroupBox* iconSizeBox = new QGroupBox(i18n("Icon Size"), main);
+
+ const QColor iconBackgroundColor(KGlobalSettings::baseColor());
+
+ KHBox* iconSizeHBox = new KHBox(iconSizeBox);
+ iconSizeHBox->setSpacing(spacing);
+ new QLabel(i18n("Small"), iconSizeHBox);
+ m_iconSizeSlider = new QSlider(0, 5, 1, 0, Qt::Horizontal, iconSizeHBox);
+ m_iconSizeSlider->setValue(sliderValue(settings->iconSize()));
+ m_iconSizeSlider->setTickmarks(QSlider::TicksBelow);
+ connect(m_iconSizeSlider, SIGNAL(valueChanged(int)),
+ this, SLOT(updateIconSize(int)));
+ new QLabel(i18n("Large"), iconSizeHBox);
+
+ m_iconSizeViewer = new PixmapViewer(iconSizeBox);
+ m_iconSizeViewer->setMinimumWidth(K3Icon::SizeEnormous);
+ m_iconSizeViewer->setFixedHeight(K3Icon::SizeEnormous);
+ m_iconSizeViewer->setEraseColor(iconBackgroundColor);
+ updateIconSize(m_iconSizeSlider->value());
+
+ QVBoxLayout* iconSizeLayout = new QVBoxLayout(iconSizeBox);
+ iconSizeLayout->addWidget(iconSizeHBox);
+ iconSizeLayout->addWidget(m_iconSizeViewer);
+
+ // create 'Preview Size' group including slider and preview
+ QGroupBox* previewSizeBox = new QGroupBox(i18n("Preview Size"), main);
+
+ KHBox* previewSizeHBox = new KHBox(previewSizeBox);
+ previewSizeHBox->setSpacing(spacing);
+ new QLabel(i18n("Small"), previewSizeHBox);
+ m_previewSizeSlider = new QSlider(0, 5, 1, 0, Qt::Horizontal, previewSizeHBox);
+ m_previewSizeSlider->setValue(sliderValue(settings->previewSize()));
+ m_previewSizeSlider->setTickmarks(QSlider::TicksBelow);
+ connect(m_previewSizeSlider, SIGNAL(valueChanged(int)),
+ this, SLOT(updatePreviewSize(int)));
+ new QLabel(i18n("Large"), previewSizeHBox);
+
+ m_previewSizeViewer = new PixmapViewer(previewSizeBox);
+ m_previewSizeViewer->setMinimumWidth(K3Icon::SizeEnormous);
+ m_previewSizeViewer->setFixedHeight(K3Icon::SizeEnormous);
+ m_previewSizeViewer->setEraseColor(iconBackgroundColor);
+ updatePreviewSize(m_previewSizeSlider->value());
+
+ QVBoxLayout* previewSizeLayout = new QVBoxLayout(previewSizeBox);
+ previewSizeLayout->addWidget(previewSizeHBox);
+ previewSizeLayout->addWidget(m_previewSizeViewer);
+
+ topLayout->addWidget(iconSizeBox);
+ topLayout->addWidget(previewSizeBox);
+ main->setLayout(topLayout);
+ setMainWidget(main);
+}
+
+IconSizeDialog::~IconSizeDialog()
+{
+}
+
+void IconSizeDialog::slotButtonClicked(int button)
+{
+ if (button == Ok) {
+ m_iconSize = iconSize(m_iconSizeSlider->value());
+
+ m_previewSize = iconSize(m_previewSizeSlider->value());
+ if (m_previewSize < m_iconSize) {
+ // assure that the preview size is never smaller than the icon size
+ m_previewSize = m_iconSize;
+ }
+ }
+
+ KDialog::slotButtonClicked(button);
+}
+
+void IconSizeDialog::updateIconSize(int value)
+{
+ KIconLoader iconLoader;
+ m_iconSizeViewer->setPixmap(iconLoader.loadIcon("folder", K3Icon::Desktop, iconSize(value)));
+
+ if (m_previewSizeSlider != 0) {
+ int previewSizeValue = m_previewSizeSlider->value();
+ if (previewSizeValue < value) {
+ // assure that the preview size is never smaller than the icon size
+ previewSizeValue = value;
+ }
+ updatePreviewSize(previewSizeValue);
+ }
+}
+
+void IconSizeDialog::updatePreviewSize(int value)
+{
+ KIconLoader iconLoader;
+ const int iconSizeValue = m_iconSizeSlider->value();
+ if (value < iconSizeValue) {
+ // assure that the preview size is never smaller than the icon size
+ value = iconSizeValue;
+ }
+ m_previewSizeViewer->setPixmap(iconLoader.loadIcon("preview", K3Icon::Desktop, iconSize(value)));
+}
+
+int IconSizeDialog::iconSize(int sliderValue) const
+{
+ int size = K3Icon::SizeMedium;
+ switch (sliderValue) {
+ case 0: size = K3Icon::SizeSmall; break;
+ case 1: size = K3Icon::SizeSmallMedium; break;
+ case 2: size = K3Icon::SizeMedium; break;
+ case 3: size = K3Icon::SizeLarge; break;
+ case 4: size = K3Icon::SizeHuge; break;
+ case 5: size = K3Icon::SizeEnormous; break;
+ }
+ return size;
+}
+
+int IconSizeDialog::sliderValue(int iconSize) const
+{
+ int value = 0;
+ switch (iconSize) {
+ case K3Icon::SizeSmall: value = 0; break;
+ case K3Icon::SizeSmallMedium: value = 1; break;
+ case K3Icon::SizeMedium: value = 2; break;
+ case K3Icon::SizeLarge: value = 3; break;
+ case K3Icon::SizeHuge: value = 4; break;
+ case K3Icon::SizeEnormous: value = 5; break;
+ default: break;
+ }
+ return value;
+}
+
+#include "iconsizedialog.moc"
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2006 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 ICONSIZEDIALOG_H
+#define ICONSIZEDIALOG_H
+
+#include <kdialog.h>
+
+class QSlider;
+class PixmapViewer;
+
+/**
+ * @brief Allows to adjust the size for icons and previews.
+ *
+ * Default usage:
+ * \code
+ * IconSizeDialog dialog(this);
+ * if (dialog.exec() == QDialog::Accepted) {
+ * const int iconSize = dialog.iconSize();
+ * const int previewSize = dialog.previewSize();
+ * // ...
+ * }
+ * \endcode
+ */
+class IconSizeDialog : public KDialog
+{
+ Q_OBJECT
+
+public:
+ explicit IconSizeDialog(QWidget* parent);
+ virtual ~IconSizeDialog();
+
+ int iconSize() const { return m_iconSize; }
+ int previewSize() const { return m_previewSize; }
+
+protected slots:
+ virtual void slotButtonClicked(int button);
+
+private slots:
+ void updateIconSize(int value);
+ void updatePreviewSize(int value);
+
+private:
+ /** Returns the icon size for the given slider value. */
+ int iconSize(int sliderValue) const;
+
+ /** Returns the slider value for the given icon size. */
+ int sliderValue(int iconSize) const;
+
+private:
+ int m_iconSize;
+ int m_previewSize;
+
+ QSlider* m_iconSizeSlider;
+ PixmapViewer* m_iconSizeViewer;
+ QSlider* m_previewSizeSlider;
+ PixmapViewer* m_previewSizeViewer;
+};
+
+#endif
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz *
- * peter.penz@gmx.at *
+ * Copyright (C) 2006 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 *
***************************************************************************/
#include "iconsviewsettingspage.h"
-#include "dolphin_iconsmodesettings.h"
+
#include "dolphinsettings.h"
+#include "iconsizedialog.h"
#include "pixmapviewer.h"
-#include <assert.h>
+#include "dolphin_iconsmodesettings.h"
#include <qlabel.h>
#include <qslider.h>
#include <klocale.h>
#include <kvbox.h>
+#include <QPushButton>
#include <QListView>
#define GRID_SPACING_BASE 8
QWidget* parent) :
KVBox(parent),
m_mainWindow(mainWindow),
- m_iconSizeSlider(0),
- m_previewSizeSlider(0),
+ m_iconSize(0),
+ m_previewSize(0),
+ m_iconSizeButton(0),
m_textWidthBox(0),
m_fontFamilyBox(0),
m_fontSizeBox(0),
setMargin(margin);
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
- assert(settings != 0);
+ Q_ASSERT(settings != 0);
+ m_iconSize = settings->iconSize();
+ m_previewSize = settings->previewSize();
KHBox* sizesLayout = new KHBox(this);
sizesLayout->setSpacing(spacing);
sizesLayout->setSizePolicy(sizePolicy);
- // create 'Icon Size' group including slider and preview
- Q3GroupBox* iconSizeGroup = new Q3GroupBox(2, Qt::Vertical, i18n("Icon Size"), sizesLayout);
- iconSizeGroup->setSizePolicy(sizePolicy);
- iconSizeGroup->setMargin(margin);
-
- const QColor iconBackgroundColor(KGlobalSettings::baseColor());
-
- KHBox* iconSizeVBox = new KHBox(iconSizeGroup);
- iconSizeVBox->setSpacing(spacing);
- new QLabel(i18n("Small"), iconSizeVBox);
- m_iconSizeSlider = new QSlider(0, 5, 1, 0, Qt::Horizontal, iconSizeVBox);
- m_iconSizeSlider->setValue(sliderValue(settings->iconSize()));
- m_iconSizeSlider->setTickmarks(QSlider::TicksBelow);
- connect(m_iconSizeSlider, SIGNAL(valueChanged(int)),
- this, SLOT(slotIconSizeChanged(int)));
- new QLabel(i18n("Large"), iconSizeVBox);
-
- m_iconSizeViewer = new PixmapViewer(iconSizeGroup);
- m_iconSizeViewer->setMinimumWidth(K3Icon::SizeEnormous);
- m_iconSizeViewer->setFixedHeight(K3Icon::SizeEnormous);
- m_iconSizeViewer->setEraseColor(iconBackgroundColor);
- slotIconSizeChanged(m_iconSizeSlider->value());
-
- // create 'Preview Size' group including slider and preview
- Q3GroupBox* previewSizeGroup = new Q3GroupBox(2, Qt::Vertical, i18n("Preview Size"), sizesLayout);
- previewSizeGroup->setSizePolicy(sizePolicy);
- previewSizeGroup->setMargin(margin);
-
- KHBox* previewSizeVBox = new KHBox(previewSizeGroup);
- previewSizeVBox->setSpacing(spacing);
- new QLabel(i18n("Small"), previewSizeVBox);
- m_previewSizeSlider = new QSlider(0, 5, 1, 0, Qt::Horizontal, previewSizeVBox);
- m_previewSizeSlider->setValue(sliderValue(settings->previewSize()));
- m_previewSizeSlider->setTickmarks(QSlider::TicksBelow);
- connect(m_previewSizeSlider, SIGNAL(valueChanged(int)),
- this, SLOT(slotPreviewSizeChanged(int)));
- new QLabel(i18n("Large"), previewSizeVBox);
-
- m_previewSizeViewer = new PixmapViewer(previewSizeGroup);
- m_previewSizeViewer->setMinimumWidth(K3Icon::SizeEnormous);
- m_previewSizeViewer->setFixedHeight(K3Icon::SizeEnormous);
- m_previewSizeViewer->setEraseColor(iconBackgroundColor);
-
- slotPreviewSizeChanged(m_previewSizeSlider->value());
+ m_iconSizeButton = new QPushButton(i18n("Change icon and preview size..."), this);
+ connect(m_iconSizeButton, SIGNAL(clicked()),
+ this, SLOT(openIconSizeDialog()));
Q3GroupBox* textGroup = new Q3GroupBox(2, Qt::Horizontal, i18n("Text"), this);
textGroup->setSizePolicy(sizePolicy);
void IconsViewSettingsPage::applySettings()
{
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
- assert(settings != 0);
-
- const int defaultSize = iconSize(m_iconSizeSlider->value());
- settings->setIconSize(defaultSize);
+ Q_ASSERT(settings != 0);
- int previewSize = iconSize(m_previewSizeSlider->value());
- if (previewSize < defaultSize) {
- // assure that the preview size is never smaller than the icon size
- previewSize = defaultSize;
- }
- settings->setPreviewSize(previewSize);
+ settings->setIconSize(m_iconSize);
+ settings->setPreviewSize(m_previewSize);
const int fontSize = m_fontSizeBox->value();
// TODO: this is just a very rough testing code to calculate the grid
// width and height
+ const int defaultSize = settings->iconSize();
int gridWidth = defaultSize;
int gridHeight = defaultSize;
const int textSizeIndex = m_textWidthBox->currentIndex();
m_gridSpacingBox->currentIndex() * GRID_SPACING_INC);
}
-void IconsViewSettingsPage::slotIconSizeChanged(int value)
+void IconsViewSettingsPage::openIconSizeDialog()
{
- KIconLoader iconLoader;
- m_iconSizeViewer->setPixmap(iconLoader.loadIcon("folder", K3Icon::Desktop, iconSize(value)));
-
- if (m_previewSizeSlider != 0) {
- int previewSizeValue = m_previewSizeSlider->value();
- if (previewSizeValue < value) {
- // assure that the preview size is never smaller than the icon size
- previewSizeValue = value;
- }
- slotPreviewSizeChanged(previewSizeValue);
+ IconSizeDialog dialog(this);
+ if (dialog.exec() == QDialog::Accepted) {
+ m_iconSize = dialog.iconSize();
+ m_previewSize = dialog.previewSize();
}
}
-void IconsViewSettingsPage::slotPreviewSizeChanged(int value)
-{
- KIconLoader iconLoader;
- const int iconSizeValue = m_iconSizeSlider->value();
- if (value < iconSizeValue) {
- // assure that the preview size is never smaller than the icon size
- value = iconSizeValue;
- }
- m_previewSizeViewer->setPixmap(iconLoader.loadIcon("preview", K3Icon::Desktop, iconSize(value)));
-}
-int IconsViewSettingsPage::iconSize(int sliderValue) const
-{
- int size = K3Icon::SizeMedium;
- switch (sliderValue) {
- case 0: size = K3Icon::SizeSmall; break;
- case 1: size = K3Icon::SizeSmallMedium; break;
- case 2: size = K3Icon::SizeMedium; break;
- case 3: size = K3Icon::SizeLarge; break;
- case 4: size = K3Icon::SizeHuge; break;
- case 5: size = K3Icon::SizeEnormous; break;
- }
- return size;
-}
-
-int IconsViewSettingsPage::sliderValue(int iconSize) const
-{
- int value = 0;
- switch (iconSize) {
- case K3Icon::SizeSmall: value = 0; break;
- case K3Icon::SizeSmallMedium: value = 1; break;
- case K3Icon::SizeMedium: value = 2; break;
- case K3Icon::SizeLarge: value = 3; break;
- case K3Icon::SizeHuge: value = 4; break;
- case K3Icon::SizeEnormous: value = 5; break;
- default: break;
- }
- return value;
-}
void IconsViewSettingsPage::adjustTextWidthSelection()
{
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
- assert(settings != 0);
+ Q_ASSERT(settings != 0);
//m_textWidthBox->setCurrentIndex(DolphinSettings::instance().textWidthHint());
}
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz *
- * peter.penz@gmx.at *
+ * Copyright (C) 2006 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 *
class QPushButton;
class QSpinBox;
class QFontComboBox;
-class PixmapViewer;
/**
* @brief Tab page for the 'Icons Mode' and 'Previews Mode' settings
void applySettings();
private slots:
- void slotIconSizeChanged(int value);
- void slotPreviewSizeChanged(int value);
+ void openIconSizeDialog();
+
+private:
+ /**
+ * Adjusts the selection of the text width combo box dependant
+ * from the grid width and grid height settings.
+ */
+ void adjustTextWidthSelection();
private:
DolphinMainWindow* m_mainWindow;
- QSlider* m_iconSizeSlider;
- PixmapViewer* m_iconSizeViewer;
- QSlider* m_previewSizeSlider;
- PixmapViewer* m_previewSizeViewer;
+ int m_iconSize;
+ int m_previewSize;
+
+ QPushButton* m_iconSizeButton;
QComboBox* m_textWidthBox;
QFontComboBox* m_fontFamilyBox;
QSpinBox* m_fontSizeBox;
QComboBox* m_arrangementBox;
QComboBox* m_gridSpacingBox;
-
- /** Returns the icon size for the given slider value. */
- int iconSize(int sliderValue) const;
-
- /** Returns the slider value for the given icon size. */
- int sliderValue(int iconSize) const;
-
- /**
- * Adjusts the selection of the text width combo box dependant
- * from the grid width and grid height settings.
- */
- void adjustTextWidthSelection();
};
#endif
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>
+ * Copyright (C) 2006 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 *