1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Let the user chose whether view properties should be remembered for each directory or whether they should be valid globally. Per default the view properties are remembered for each directory. For testing purposes the MIME type information is shown per default in the icons mode (thanks to Fredrik for the cool implementation in KFileItemDelegate!).

svn path=/trunk/playground/utils/dolphin/; revision=615232
This commit is contained in:
Peter Penz 2006-12-20 19:10:39 +00:00
parent 3396d0dbee
commit 642110309a
16 changed files with 233 additions and 166 deletions

View File

@ -8,44 +8,45 @@ include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
########### next target ###############
set(dolphin_SRCS
main.cpp
applyviewpropsjob.cpp
bookmarkselector.cpp
bookmarkssettingspage.cpp
bookmarkssidebarpage.cpp
detailsviewsettingspage.cpp
dolphinapplication.cpp
dolphinmainwindow.cpp
dolphinview.cpp
urlnavigator.cpp
urlnavigatorbutton.cpp
viewpropertiesdialog.cpp
dolphinstatusbar.cpp
dolphindirlister.cpp
viewproperties.cpp
dolphindetailsview.cpp
dolphiniconsview.cpp
dolphinsettings.cpp
bookmarkselector.cpp
urlbutton.cpp
dolphincontextmenu.cpp
dolphinsortfilterproxymodel.cpp
undomanager.cpp
progressindicator.cpp
iconsviewsettingspage.cpp
pixmapviewer.cpp
dolphinsettingsdialog.cpp
viewsettingspage.cpp
detailsviewsettingspage.cpp
statusbarmessagelabel.cpp
generalsettingspage.cpp
bookmarkssettingspage.cpp
editbookmarkdialog.cpp
filterbar.cpp
generalsettingspage.cpp
generalviewsettingspage.cpp
iconsviewsettingspage.cpp
infosidebarpage.cpp
main.cpp
progressindicator.cpp
protocolcombo.cpp
pixmapviewer.cpp
renamedialog.cpp
settingspagebase.cpp
sidebarpage.cpp
bookmarkssidebarpage.cpp
infosidebarpage.cpp
statusbarspaceinfo.cpp
renamedialog.cpp
filterbar.cpp
protocolcombo.cpp
viewpropsprogressinfo.cpp
applyviewpropsjob.cpp )
statusbarmessagelabel.cpp
undomanager.cpp
urlbutton.cpp
urlnavigator.cpp
urlnavigatorbutton.cpp
viewpropertiesdialog.cpp
viewproperties.cpp
viewsettingspage.cpp
viewpropsprogressinfo.cpp )
kde4_automoc(${dolphin_SRCS})

View File

@ -84,75 +84,6 @@ void DolphinSettings::save()
manager->save(false);
}
void DolphinSettings::calculateGridSize(int hint)
{
// TODO: remove in KDE4
const int previewSize = m_iconsModeSettings->previewSize();
const int iconSize = m_iconsModeSettings->iconSize();
const int maxSize = (previewSize > iconSize) ? previewSize : iconSize;
const Q3IconView::Arrangement arrangement = (m_iconsModeSettings->arrangement() == "LeftToRight") ?
Q3IconView::LeftToRight : Q3IconView::TopToBottom;
int gridWidth = 0;
int gridHeight = 0;
if (arrangement == Q3IconView::LeftToRight) {
int widthUnit = maxSize + (maxSize / 2);
if (widthUnit < K3Icon::SizeLarge) {
widthUnit = K3Icon::SizeLarge;
}
gridWidth = widthUnit + hint * K3Icon::SizeLarge;
gridHeight = iconSize;
if (gridHeight <= K3Icon::SizeMedium) {
gridHeight = gridHeight * 2;
}
else {
gridHeight += maxSize / 2;
}
}
else {
assert(arrangement == Q3IconView::TopToBottom);
gridWidth = maxSize + (hint + 1) * (8 * m_iconsModeSettings->fontSize());
// The height-setting is ignored yet by KFileIconView if the TopToBottom
// arrangement is active. Anyway write the setting to have a defined value.
gridHeight = maxSize;
}
m_iconsModeSettings->setGridWidth(gridWidth);
m_iconsModeSettings->setGridHeight(gridHeight);
}
int DolphinSettings::textWidthHint() const
{
// TODO: remove in KDE4
const int previewSize = m_iconsModeSettings->previewSize();
const int iconSize = m_iconsModeSettings->iconSize();
const Q3IconView::Arrangement arrangement = (m_iconsModeSettings->arrangement() == "LeftToRight") ?
Q3IconView::LeftToRight : Q3IconView::TopToBottom;
const int gridWidth = m_iconsModeSettings->gridWidth();
const int maxSize = (previewSize > iconSize) ? previewSize : iconSize;
int hint = 0;
if (arrangement == Q3IconView::LeftToRight) {
int widthUnit = maxSize + (maxSize / 2);
if (widthUnit < K3Icon::SizeLarge) {
widthUnit = K3Icon::SizeLarge;
}
hint = (gridWidth - widthUnit) / K3Icon::SizeLarge;
}
else {
assert(arrangement == Q3IconView::TopToBottom);
hint = (gridWidth - maxSize) / (8 * m_iconsModeSettings->fontSize()) - 1;
if (hint > 2) {
hint = 2;
}
}
return hint;
}
DolphinSettings::DolphinSettings()
{
m_generalSettings = new GeneralSettings();

View File

@ -56,34 +56,6 @@ public:
/** @see DolphinSettingsBase::save */
virtual void save();
/**
* TODO: just temporary until the port to KDE4 has been done
*
* Calculates the width and the height of the grid dependant from \a hint and
* the current settings. The hint gives information about the wanted text
* width, where a lower value indicates a smaller text width. Currently
* in Dolphin the values 0, 1 and 2 are used. See also
* DolhinIconsViewSettings::textWidthHint.
*
* The calculation of the grid width and grid height is a little bit tricky,
* as the user model does not fit to the implementation model of QIconView. The user model
* allows to specify icon-, preview- and text width sizes, whereas the implementation
* model expects only a grid width and height. The nasty thing is that the specified
* width and height varies dependant from the arrangement (e. g. the height is totally
* ignored for the top-to-bottom arrangement inside QIconView).
*/
void calculateGridSize(int hint);
/**
* TODO: just temporary until the port to KDE4 has been done
*
* Returns the text width hint dependant from the given settings.
* A lower value indicates a smaller text width. Currently
* in Dolphin the values 0, 1 and 2 are used. The text width hint can
* be used later for DolphinIconsViewSettings::calculateGridSize().
*/
int textWidthHint() const;
protected:
DolphinSettings();
virtual ~DolphinSettings();

View File

@ -109,9 +109,10 @@ DolphinView::DolphinView(DolphinMainWindow *mainWindow,
m_proxyModel = new DolphinSortFilterProxyModel(this);
m_proxyModel->setSourceModel(m_dirModel);
m_iconsView->setModel(m_dirModel); // TODO: using m_proxyModel crashed when clicking on an item
m_iconsView->setModel(m_dirModel); // TODO: using m_proxyModel crashes when clicking on an item
KFileItemDelegate* delegate = new KFileItemDelegate(this);
delegate->setAdditionalInformation(KFileItemDelegate::FriendlyMimeType);
m_iconsView->setItemDelegate(delegate);
m_dirLister->setDelayedMimeTypes(true);
@ -985,19 +986,22 @@ void DolphinView::slotChangeNameFilter(const QString& nameFilter)
void DolphinView::applyModeToView()
{
//m_iconsView->setAlternatingRowColors(true);
m_iconsView->setSelectionMode(QAbstractItemView::ExtendedSelection);
// TODO: the following code just tries to test some QListView capabilities
switch (m_mode) {
case IconsView:
m_iconsView->setViewMode(QListView::IconMode);
m_iconsView->setGridSize(QSize(128, 64));
m_iconsView->setSpacing(32);
// m_iconsView->setAlternatingRowColors(false);
// m_iconsView->setGridSize(QSize(128, 64));
break;
case DetailsView:
m_iconsView->setViewMode(QListView::ListMode);
m_iconsView->setGridSize(QSize(256, 24));
m_iconsView->setSpacing(0);
// m_iconsView->setAlternatingRowColors(true);
// m_iconsView->setGridSize(QSize(256, 24));
break;
}
}

View File

@ -3,10 +3,6 @@
<kcfg>
<kcfgfile name="dolphinrc"/>
<group name="General">
<entry name="DefaultViewMode" type="Int">
<label>Default view mode</label>
<default>0</default>
</entry>
<entry name="EditableUrl" type="Bool">
<label>Should the URL be editable for the user</label>
<default>false</default>
@ -23,5 +19,9 @@
<label>Split the view into two panes</label>
<default>false</default>
</entry>
<entry name="globalViewProps" type="Bool">
<label>Should the view properties used for all directories</label>
<default>false</default>
</entry>
</group>
</kcfg>

View File

@ -64,7 +64,7 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* par
vBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
// create 'Home Url' editor
Q3GroupBox* homeGroup = new Q3GroupBox(1, Qt::Horizontal, i18n("Home Url"), vBox);
Q3GroupBox* homeGroup = new Q3GroupBox(1, Qt::Horizontal, i18n("Home Folder"), vBox);
homeGroup->setSizePolicy(sizePolicy);
homeGroup->setMargin(margin);
@ -89,27 +89,20 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* par
connect(useDefaultButton, SIGNAL(clicked()),
this, SLOT(useDefaulLocation()));
// create 'Default View Mode' group
Q3ButtonGroup* buttonGroup = new Q3ButtonGroup(3, Qt::Vertical, i18n("Default View Mode"), vBox);
buttonGroup->setSizePolicy(sizePolicy);
buttonGroup->setMargin(margin);
m_iconsView = new QRadioButton(i18n("Icons"), buttonGroup);
m_detailsView = new QRadioButton(i18n("Details"), buttonGroup);
switch (settings->defaultViewMode()) {
case DolphinView::IconsView: m_iconsView->setChecked(true); break;
case DolphinView::DetailsView: m_detailsView->setChecked(true); break;
}
QGroupBox* startBox = new QGroupBox(i18n("Start"), vBox);
// create 'Start with split view' checkbox
m_startSplit = new QCheckBox(i18n("Start with split view"), vBox);
m_startSplit = new QCheckBox(i18n("Start with split view"), startBox);
m_startSplit->setChecked(settings->splitView());
// create 'Start with editable navigation bar' checkbox
m_startEditable = new QCheckBox(i18n("Start with editable navigation bar"), vBox);
m_startEditable = new QCheckBox(i18n("Start with editable navigation bar"), startBox);
m_startEditable->setChecked(settings->editableUrl());
QVBoxLayout* startBoxLayout = new QVBoxLayout(startBox);
startBoxLayout->addWidget(m_startSplit);
startBoxLayout->addWidget(m_startEditable);
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
// is not stretched vertically.
@ -133,11 +126,6 @@ void GeneralSettingsPage::applySettings()
settings->setHomeUrl(url.prettyUrl());
}
const DolphinView::Mode viewMode = m_detailsView->isChecked() ?
DolphinView::DetailsView :
DolphinView::IconsView;
settings->setDefaultViewMode(viewMode);
settings->setSplitView(m_startSplit->isChecked());
settings->setEditableUrl(m_startEditable->isChecked());
}

View File

@ -54,8 +54,6 @@ private slots:
private:
DolphinMainWindow *m_mainWindow;
QLineEdit* m_homeUrl;
QRadioButton* m_iconsView;
QRadioButton* m_detailsView;
QCheckBox* m_startSplit;
QCheckBox* m_startEditable;
};

View File

@ -0,0 +1,85 @@
/***************************************************************************
* 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 "generalviewsettingspage.h"
#include "dolphinsettings.h"
#include "generalsettings.h"
#include <assert.h>
#include <QGroupBox>
#include <QRadioButton>
#include <QVBoxLayout>
#include <kdialog.h>
#include <klocale.h>
#include <kvbox.h>
GeneralViewSettingsPage::GeneralViewSettingsPage(QWidget* parent) :
KVBox(parent),
m_localProps(0),
m_globalProps(0)
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
assert(settings != 0);
const int spacing = KDialog::spacingHint();
const int margin = KDialog::marginHint();
const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
setSpacing(spacing);
setMargin(margin);
QGroupBox* propsBox = new QGroupBox(i18n("View Properties"), this);
m_localProps = new QRadioButton(i18n("Remember view properties for each folder."), propsBox);
m_globalProps = new QRadioButton(i18n("Use common view properties for all folders."), propsBox);
if (settings->globalViewProps()) {
m_globalProps->setChecked(true);
}
else {
m_localProps->setChecked(true);
}
QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
propsBoxLayout->addWidget(m_localProps);
propsBoxLayout->addWidget(m_globalProps);
QGroupBox* previewBox = new QGroupBox(i18n("File Previews"), this);
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
// is not stretched vertically.
new QWidget(this);
}
GeneralViewSettingsPage::~GeneralViewSettingsPage()
{
}
void GeneralViewSettingsPage::applySettings()
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
assert(settings != 0);
settings->setGlobalViewProps(m_globalProps->isChecked());
}
#include "generalviewsettingspage.moc"

View File

@ -0,0 +1,54 @@
/***************************************************************************
* 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 GENERALVIEWSETTINGSPAGE_H
#define GENERALVIEWSETTINGSPAGE_H
#include <kvbox.h>
class QRadioButton;
/**
* @brief Represents the page from the Dolphin Settings which allows
* to modify general settings for the view modes.
*
* @author Peter Penz <peter.penz@gmx.at>
*/
class GeneralViewSettingsPage : public KVBox
{
Q_OBJECT
public:
GeneralViewSettingsPage(QWidget* parent);
virtual ~GeneralViewSettingsPage();
/**
* Applies the general settings for the view modes
* The settings are persisted automatically when
* closing Dolphin.
*/
void applySettings();
private:
QRadioButton* m_localProps;
QRadioButton* m_globalProps;
};
#endif

View File

@ -43,5 +43,9 @@
<label>Preview size</label>
<default code="true">K3Icon::SizeMedium</default>
</entry>
<entry name="AdditionalInfo" type="Int">
<label>Additional information</label>
<default>0</default>
</entry>
</group>
</kcfg>

View File

@ -44,11 +44,12 @@ IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) :
m_iconSizeSlider(0),
m_previewSizeSlider(0),
m_textWidthBox(0),
m_gridSpacingBox(0),
m_fontFamilyBox(0),
m_fontSizeBox(0),
m_textlinesCountBox(0),
m_arrangementBox(0)
m_additionalInfo(0),
m_arrangementBox(0),
m_gridSpacingBox(0)
{
const int spacing = KDialog::spacingHint();
const int margin = KDialog::marginHint();
@ -131,6 +132,14 @@ IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) :
m_textWidthBox->addItem(i18n("Medium"));
m_textWidthBox->addItem(i18n("Large"));
new QLabel(i18n("Additional information:"), textGroup);
m_additionalInfo = new QComboBox(textGroup);
m_additionalInfo->addItem(i18n("No Information"));
m_additionalInfo->addItem(i18n("MIME Type"));
m_additionalInfo->addItem(i18n("Size"));
m_additionalInfo->addItem(i18n("Date"));
m_additionalInfo->setCurrentIndex(settings->additionalInfo());
Q3GroupBox* gridGroup = new Q3GroupBox(2, Qt::Horizontal, i18n("Grid"), this);
gridGroup->setSizePolicy(sizePolicy);
gridGroup->setMargin(margin);
@ -184,7 +193,7 @@ void IconsViewSettingsPage::applySettings()
"LeftToRight" :
"TopToBottom";
settings->setArrangement(arrangement);
DolphinSettings::instance().calculateGridSize(m_textWidthBox->currentIndex());
//DolphinSettings::instance().calculateGridSize(m_textWidthBox->currentIndex());
settings->setFontFamily(m_fontFamilyBox->currentFont().family());
settings->setFontSize(fontSize);
@ -253,7 +262,7 @@ void IconsViewSettingsPage::adjustTextWidthSelection()
{
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
assert(settings != 0);
m_textWidthBox->setCurrentIndex(DolphinSettings::instance().textWidthHint());
//m_textWidthBox->setCurrentIndex(DolphinSettings::instance().textWidthHint());
}
#include "iconsviewsettingspage.moc"

View File

@ -75,11 +75,13 @@ private:
QSlider* m_previewSizeSlider;
PixmapViewer* m_previewSizeViewer;
QComboBox* m_textWidthBox;
QComboBox* m_gridSpacingBox;
QFontComboBox* m_fontFamilyBox;
QSpinBox* m_fontSizeBox;
QSpinBox* m_textlinesCountBox;
QComboBox* m_additionalInfo;
QComboBox* m_arrangementBox;
QComboBox* m_gridSpacingBox;
/** Returns the icon size for the given slider value. */
int iconSize(int sliderValue) const;

View File

@ -47,7 +47,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
m_sortOrder(0),
m_showPreview(0),
m_showHiddenFiles(0),
m_applyToSubFolders(0)
m_applyToSubFolders(0),
m_useAsDefault(0)
{
assert(dolphinView != 0);
@ -110,8 +111,11 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
propsBoxLayout->addWidget(m_showHiddenFiles, 4, 0);
m_applyToSubFolders = new QCheckBox(i18n("Apply changes to all sub folders"), main);
m_useAsDefault = new QCheckBox(i18n("Use as default"), main);
topLayout->addWidget(propsBox);
topLayout->addWidget(m_applyToSubFolders);
topLayout->addWidget(m_useAsDefault);
connect(m_viewMode, SIGNAL(activated(int)),
this, SLOT(slotViewModeChanged(int)));
@ -124,6 +128,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
connect(m_showHiddenFiles, SIGNAL(clicked()),
this, SLOT(slotShowHiddenFilesChanged()));
connect(m_applyToSubFolders, SIGNAL(clicked()),
this, SLOT(markAsDirty()));
connect(m_applyToSubFolders, SIGNAL(clicked()),
this, SLOT(markAsDirty()));
@ -215,6 +221,8 @@ void ViewPropertiesDialog::applyViewProperties()
m_viewProps->save();
m_dolphinView->setViewProperties(*m_viewProps);
m_isDirty = false;
// TODO: handle m_useAsDefault setting
}
#include "viewpropertiesdialog.moc"

View File

@ -64,6 +64,7 @@ private:
QCheckBox* m_showPreview;
QCheckBox* m_showHiddenFiles;
QCheckBox* m_applyToSubFolders;
QCheckBox* m_useAsDefault;
void applyViewProperties();
};

View File

@ -19,19 +19,22 @@
***************************************************************************/
#include "viewsettingspage.h"
#include <qtabwidget.h>
#include <qlayout.h>
#include <qlabel.h>
//Added by qt3to4:
#include <Q3VBoxLayout>
#include <kdialog.h>
#include <klocale.h>
#include <kiconloader.h>
#include "generalviewsettingspage.h"
#include "iconsviewsettingspage.h"
#include "detailsviewsettingspage.h"
#include <Q3VBoxLayout>
#include <QTabWidget>
#include <QLayout>
#include <QLabel>
#include <kdialog.h>
#include <klocale.h>
#include <kiconloader.h>
ViewSettingsPage::ViewSettingsPage(QWidget *parent) :
SettingsPageBase(parent),
m_generalPage(0),
m_iconsPage(0),
m_detailsPage(0)
{
@ -39,6 +42,10 @@ ViewSettingsPage::ViewSettingsPage(QWidget *parent) :
QTabWidget* tabWidget = new QTabWidget(this);
// initialize 'General' tab
m_generalPage = new GeneralViewSettingsPage(tabWidget);
tabWidget->addTab(m_generalPage, SmallIcon("view_choose"), i18n("General"));
// initialize 'Icons' tab
m_iconsPage = new IconsViewSettingsPage(tabWidget);
tabWidget->addTab(m_iconsPage, SmallIcon("view_icon"), i18n("Icons"));
@ -56,6 +63,7 @@ ViewSettingsPage::~ViewSettingsPage()
void ViewSettingsPage::applySettings()
{
m_generalPage->applySettings();
m_iconsPage->applySettings();
m_detailsPage->applySettings();
}

View File

@ -23,14 +23,15 @@
#include <qwidget.h>
#include <settingspagebase.h>
class GeneralViewSettingsPage;
class IconsViewSettingsPage;
class DetailsViewSettingsPage;
/**
* @brief Page for the 'View' settings of the Dolphin settings dialog.
*
* The views settings allow to set the properties for the icons mode,
* the details mode and the previews mode.
* The views settings allow to set the properties for the icons mode and
* the details mode.
*
* @author Peter Penz <peter.penz@gmx.at>
*/
@ -47,6 +48,7 @@ public:
virtual void applySettings();
private:
GeneralViewSettingsPage* m_generalPage;
IconsViewSettingsPage* m_iconsPage;
DetailsViewSettingsPage* m_detailsPage;
};