mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Allow that Dolphin can also be used with global view properties. Per default Dolphin remembers the view properties for each directory, but from the feedback I've got there is a not ignorable amount of people who prefer having global view properties instead.
svn path=/trunk/playground/utils/dolphin/; revision=620774
This commit is contained in:
parent
4a0a832ddb
commit
445f0b64bd
|
@ -23,6 +23,7 @@
|
|||
#include "applyviewpropsjob.h"
|
||||
#include "viewproperties.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
ApplyViewPropsJob::ApplyViewPropsJob(const KUrl& dir,
|
||||
|
@ -74,12 +75,10 @@ void ApplyViewPropsJob::slotEntries(KIO::Job*, const KIO::UDSEntryList& list)
|
|||
KUrl url(m_dir);
|
||||
url.addPath(name);
|
||||
|
||||
assert(m_viewProps != 0);
|
||||
|
||||
ViewProperties props(url);
|
||||
props.setViewMode(m_viewProps->viewMode());
|
||||
props.setShowPreview(m_viewProps->showPreview());
|
||||
props.setShowHiddenFiles(m_viewProps->showHiddenFiles());
|
||||
props.setSorting(m_viewProps->sorting());
|
||||
props.setSortOrder(m_viewProps->sortOrder());
|
||||
props.setDirProperties(*m_viewProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,10 @@
|
|||
#include "dolphinsettings.h"
|
||||
#include "editbookmarkdialog.h"
|
||||
|
||||
BookmarksSettingsPage::BookmarksSettingsPage(QWidget*parent) :
|
||||
BookmarksSettingsPage::BookmarksSettingsPage(DolphinMainWindow* mainWindow,
|
||||
QWidget*parent) :
|
||||
SettingsPageBase(parent),
|
||||
m_mainWindow(mainWindow),
|
||||
m_addButton(0),
|
||||
m_removeButton(0),
|
||||
m_moveUpButton(0),
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <settingspagebase.h>
|
||||
#include <q3valuelist.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class K3ListView;
|
||||
class KPushButton;
|
||||
class Q3ListViewItem;
|
||||
|
@ -37,7 +38,7 @@ class BookmarksSettingsPage : public SettingsPageBase
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BookmarksSettingsPage(QWidget* parent);
|
||||
BookmarksSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
|
||||
|
||||
virtual ~BookmarksSettingsPage();
|
||||
|
||||
|
@ -70,6 +71,7 @@ private:
|
|||
IconIdx = 3
|
||||
};
|
||||
|
||||
DolphinMainWindow* m_mainWindow;
|
||||
K3ListView* m_listView;
|
||||
KPushButton* m_addButton;
|
||||
KPushButton* m_editButton;
|
||||
|
|
|
@ -37,8 +37,10 @@
|
|||
#include "detailsmodesettings.h"
|
||||
#include "dolphindetailsview.h"
|
||||
|
||||
DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget *parent) :
|
||||
DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
|
||||
QWidget* parent) :
|
||||
KVBox(parent),
|
||||
m_mainWindow(mainWindow),
|
||||
m_dateBox(0),
|
||||
m_permissionsBox(0),
|
||||
m_ownerBox(0),
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <kvbox.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class QCheckBox;
|
||||
class QFontComboBox;
|
||||
class QSpinBox;
|
||||
|
@ -32,15 +33,13 @@ class QRadioButton;
|
|||
/**
|
||||
* @brief Represents the page from the Dolphin Settings which allows
|
||||
* to modify the settings for the details view.
|
||||
*
|
||||
* @author Peter Penz <peter.penz@gmx.at>
|
||||
*/
|
||||
class DetailsViewSettingsPage : public KVBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DetailsViewSettingsPage(QWidget* parent);
|
||||
DetailsViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
|
||||
virtual ~DetailsViewSettingsPage();
|
||||
|
||||
/**
|
||||
|
@ -51,6 +50,7 @@ public:
|
|||
void applySettings();
|
||||
|
||||
private:
|
||||
DolphinMainWindow* m_mainWindow;
|
||||
QCheckBox* m_dateBox;
|
||||
QCheckBox* m_permissionsBox;
|
||||
QCheckBox* m_ownerBox;
|
||||
|
|
|
@ -42,11 +42,11 @@ DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
|
|||
KPageWidgetItem* generalSettingsFrame = addPage(m_generalSettingsPage, i18n("General"));
|
||||
generalSettingsFrame->setIcon(KIcon("exec"));
|
||||
|
||||
m_viewSettingsPage = new ViewSettingsPage(this);
|
||||
m_viewSettingsPage = new ViewSettingsPage(mainWindow, this);
|
||||
KPageWidgetItem* viewSettingsFrame = addPage(m_viewSettingsPage, i18n("View Modes"));
|
||||
viewSettingsFrame->setIcon(KIcon("view_choose"));
|
||||
|
||||
m_bookmarksSettingsPage = new BookmarksSettingsPage(this);
|
||||
m_bookmarksSettingsPage = new BookmarksSettingsPage(mainWindow, this);
|
||||
KPageWidgetItem* bookmarksSettingsFrame = addPage(m_bookmarksSettingsPage, i18n("Bookmarks"));
|
||||
bookmarksSettingsFrame->setIcon(KIcon("bookmark"));
|
||||
}
|
||||
|
|
|
@ -21,18 +21,17 @@
|
|||
#define GENERALSETTINGSPAGE_H
|
||||
|
||||
#include <settingspagebase.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class QLineEdit;
|
||||
class QRadioButton;
|
||||
class QCheckBox;
|
||||
class DolphinMainWindow;
|
||||
|
||||
/**
|
||||
* @brief Page for the 'General' settings of the Dolphin settings dialog.
|
||||
*
|
||||
* The general settings allow to set the home Url, the default view mode
|
||||
* and the split view mode.
|
||||
*
|
||||
* @author Peter Penz <peter.penz@gmx.at>
|
||||
*/
|
||||
class GeneralSettingsPage : public SettingsPageBase
|
||||
{
|
||||
|
@ -40,7 +39,6 @@ class GeneralSettingsPage : public SettingsPageBase
|
|||
|
||||
public:
|
||||
GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
|
||||
|
||||
virtual ~GeneralSettingsPage();
|
||||
|
||||
/** @see SettingsPageBase::applySettings */
|
||||
|
@ -52,7 +50,7 @@ private slots:
|
|||
void useDefaulLocation();
|
||||
|
||||
private:
|
||||
DolphinMainWindow *m_mainWindow;
|
||||
DolphinMainWindow* m_mainWindow;
|
||||
QLineEdit* m_homeUrl;
|
||||
QCheckBox* m_startSplit;
|
||||
QCheckBox* m_startEditable;
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include "generalviewsettingspage.h"
|
||||
#include "dolphinmainwindow.h"
|
||||
#include "dolphinsettings.h"
|
||||
#include "generalsettings.h"
|
||||
#include "viewproperties.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -32,8 +34,10 @@
|
|||
#include <klocale.h>
|
||||
#include <kvbox.h>
|
||||
|
||||
GeneralViewSettingsPage::GeneralViewSettingsPage(QWidget* parent) :
|
||||
GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
|
||||
QWidget* parent) :
|
||||
KVBox(parent),
|
||||
m_mainWindow(mainWindow),
|
||||
m_localProps(0),
|
||||
m_globalProps(0)
|
||||
{
|
||||
|
@ -77,9 +81,23 @@ GeneralViewSettingsPage::~GeneralViewSettingsPage()
|
|||
|
||||
void GeneralViewSettingsPage::applySettings()
|
||||
{
|
||||
const KUrl& url = m_mainWindow->activeView()->url();
|
||||
ViewProperties props(url); // read current view properties
|
||||
|
||||
const bool useGlobalProps = m_globalProps->isChecked();
|
||||
|
||||
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
|
||||
assert(settings != 0);
|
||||
settings->setGlobalViewProps(m_globalProps->isChecked());
|
||||
settings->setGlobalViewProps(useGlobalProps);
|
||||
|
||||
if (useGlobalProps) {
|
||||
// Remember the global view properties by applying the current view properties.
|
||||
// It is important that GeneralSettings::globalViewProps() is set before
|
||||
// the class ViewProperties is used, as ViewProperties uses this setting
|
||||
// to find the destination folder for storing the view properties.
|
||||
ViewProperties globalProps(url);
|
||||
globalProps.setDirProperties(props);
|
||||
}
|
||||
}
|
||||
|
||||
#include "generalviewsettingspage.moc"
|
||||
|
|
|
@ -23,20 +23,19 @@
|
|||
|
||||
#include <kvbox.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
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);
|
||||
GeneralViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
|
||||
virtual ~GeneralViewSettingsPage();
|
||||
|
||||
/**
|
||||
|
@ -47,6 +46,7 @@ public:
|
|||
void applySettings();
|
||||
|
||||
private:
|
||||
DolphinMainWindow* m_mainWindow;
|
||||
QRadioButton* m_localProps;
|
||||
QRadioButton* m_globalProps;
|
||||
};
|
||||
|
|
|
@ -41,8 +41,10 @@
|
|||
#define GRID_SPACING_BASE 8
|
||||
#define GRID_SPACING_INC 12
|
||||
|
||||
IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) :
|
||||
IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
|
||||
QWidget* parent) :
|
||||
KVBox(parent),
|
||||
m_mainWindow(mainWindow),
|
||||
m_iconSizeSlider(0),
|
||||
m_previewSizeSlider(0),
|
||||
m_textWidthBox(0),
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#ifndef ICONSVIEWSETTINGSPAGE_H
|
||||
#define ICONSVIEWSETTINGSPAGE_H
|
||||
|
||||
|
||||
#include <dolphiniconsview.h>
|
||||
#include <kvbox.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class QSlider;
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
|
@ -48,14 +48,13 @@ class PixmapViewer;
|
|||
* - arrangement
|
||||
*
|
||||
* @see DolphinIconsViewSettings
|
||||
* @author Peter Penz <peter.penz@gmx.at>
|
||||
*/
|
||||
class IconsViewSettingsPage : public KVBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IconsViewSettingsPage(QWidget* parent);
|
||||
IconsViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
|
||||
virtual ~IconsViewSettingsPage();
|
||||
|
||||
/**
|
||||
|
@ -70,6 +69,7 @@ private slots:
|
|||
void slotPreviewSizeChanged(int value);
|
||||
|
||||
private:
|
||||
DolphinMainWindow* m_mainWindow;
|
||||
QSlider* m_iconSizeSlider;
|
||||
PixmapViewer* m_iconSizeViewer;
|
||||
QSlider* m_previewSizeSlider;
|
||||
|
|
|
@ -40,7 +40,6 @@ ViewProperties::ViewProperties(const KUrl& url) :
|
|||
m_node(0)
|
||||
{
|
||||
KUrl cleanUrl(url);
|
||||
|
||||
cleanUrl.cleanPath();
|
||||
m_filepath = cleanUrl.path();
|
||||
|
||||
|
@ -52,22 +51,18 @@ ViewProperties::ViewProperties(const KUrl& url) :
|
|||
// We try and save it to a file in the directory being viewed.
|
||||
// If the directory is not writable by the user or the directory is not local,
|
||||
// we store the properties information in a local file.
|
||||
QString rootDir("/"); // TODO: should this be set to the root of the bookmark, if any?
|
||||
if (cleanUrl.isLocalFile()) {
|
||||
QFileInfo info(m_filepath);
|
||||
|
||||
const bool useGlobalViewProps = DolphinSettings::instance().generalSettings()->globalViewProps();
|
||||
if (useGlobalViewProps) {
|
||||
m_filepath = destinationDir("global");
|
||||
}
|
||||
else if (cleanUrl.isLocalFile()) {
|
||||
const QFileInfo info(m_filepath);
|
||||
if (!info.isWritable()) {
|
||||
QString basePath = KGlobal::instance()->instanceName();
|
||||
basePath.append("/view_properties/local");
|
||||
rootDir = KStandardDirs::locateLocal("data", basePath);
|
||||
m_filepath = rootDir + m_filepath;
|
||||
m_filepath = destinationDir("local") + m_filepath;
|
||||
}
|
||||
}
|
||||
else {
|
||||
QString basePath = KGlobal::instance()->instanceName();
|
||||
basePath.append("/view_properties/remote/").append(cleanUrl.host());
|
||||
rootDir = KStandardDirs::locateLocal("data", basePath);
|
||||
m_filepath = rootDir + m_filepath;
|
||||
m_filepath = destinationDir("remote") + m_filepath;
|
||||
}
|
||||
|
||||
m_node = new ViewPropertySettings(KSharedConfig::openConfig(m_filepath + FILE_NAME));
|
||||
|
@ -149,6 +144,15 @@ Qt::SortOrder ViewProperties::sortOrder() const
|
|||
return static_cast<Qt::SortOrder>(m_node->sortOrder());
|
||||
}
|
||||
|
||||
void ViewProperties::setDirProperties(const ViewProperties& props)
|
||||
{
|
||||
setViewMode(props.viewMode());
|
||||
setShowPreview(props.showPreview());
|
||||
setShowHiddenFiles(props.showHiddenFiles());
|
||||
setSorting(props.sorting());
|
||||
setSortOrder(props.sortOrder());
|
||||
}
|
||||
|
||||
void ViewProperties::setAutoSaveEnabled(bool autoSave)
|
||||
{
|
||||
m_autoSave = autoSave;
|
||||
|
@ -167,12 +171,16 @@ void ViewProperties::updateTimeStamp()
|
|||
|
||||
void ViewProperties::save()
|
||||
{
|
||||
const bool rememberSettings = !DolphinSettings::instance().generalSettings()->globalViewProps();
|
||||
if (rememberSettings) {
|
||||
KStandardDirs::makeDir(m_filepath);
|
||||
m_node->writeConfig();
|
||||
m_changedProps = false;
|
||||
}
|
||||
KStandardDirs::makeDir(m_filepath);
|
||||
m_node->writeConfig();
|
||||
m_changedProps = false;
|
||||
}
|
||||
|
||||
QString ViewProperties::destinationDir(const QString& subDir) const
|
||||
{
|
||||
QString basePath = KGlobal::instance()->instanceName();
|
||||
basePath.append("/view_properties/").append(subDir);
|
||||
return KStandardDirs::locateLocal("data", basePath);
|
||||
}
|
||||
|
||||
ViewProperties::ViewProperties(const ViewProperties& props)
|
||||
|
|
|
@ -66,6 +66,13 @@ public:
|
|||
void setSortOrder(Qt::SortOrder sortOrder);
|
||||
Qt::SortOrder sortOrder() const;
|
||||
|
||||
/**
|
||||
* Sets the directory properties view mode, show preview,
|
||||
* show hidden files, sorting and sort order like
|
||||
* set in \a props.
|
||||
*/
|
||||
void setDirProperties(const ViewProperties& props);
|
||||
|
||||
/**
|
||||
* If \a autoSave is true, the properties are automatically
|
||||
* saved when the destructor is called. Per default autosaving
|
||||
|
@ -80,23 +87,27 @@ public:
|
|||
* Saves the view properties for the directory specified
|
||||
* in the constructor. The method is automatically
|
||||
* invoked in the destructor, if
|
||||
* ViewProperties::isAutoSaveEnabled() returns true.
|
||||
*
|
||||
* Note that the saving of the properties will be ignored
|
||||
* if GeneralSettings::globalViewProps() returns true: in
|
||||
* this case view properties may not be remembered for
|
||||
* each directory.
|
||||
* ViewProperties::isAutoSaveEnabled() returns true and
|
||||
* at least one property has been changed.
|
||||
*/
|
||||
void save();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Returns the destination directory path where the view
|
||||
* properties are stored. \a subDir specifies the used sub
|
||||
* directory.
|
||||
*/
|
||||
QString destinationDir(const QString& subDir) const;
|
||||
|
||||
ViewProperties(const ViewProperties& props);
|
||||
ViewProperties& operator= (const ViewProperties& props);
|
||||
|
||||
private:
|
||||
bool m_changedProps;
|
||||
bool m_autoSave;
|
||||
QString m_filepath;
|
||||
ViewPropertySettings* m_node;
|
||||
|
||||
ViewProperties(const ViewProperties& props);
|
||||
ViewProperties& operator= (const ViewProperties& props);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,10 +48,7 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
|
|||
setButtons(KDialog::Cancel);
|
||||
|
||||
m_viewProps = new ViewProperties(dir);
|
||||
m_viewProps->setViewMode(viewProps.viewMode());
|
||||
m_viewProps->setShowHiddenFiles(viewProps.showHiddenFiles());
|
||||
m_viewProps->setSorting(viewProps.sorting());
|
||||
m_viewProps->setSortOrder(viewProps.sortOrder());
|
||||
m_viewProps->setDirProperties(viewProps);
|
||||
|
||||
// the view properties are stored by the ViewPropsApplierJob, so prevent
|
||||
// that the view properties are saved twice:
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <klocale.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
ViewSettingsPage::ViewSettingsPage(QWidget *parent) :
|
||||
ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow,
|
||||
QWidget* parent) :
|
||||
SettingsPageBase(parent),
|
||||
m_generalPage(0),
|
||||
m_iconsPage(0),
|
||||
|
@ -43,15 +44,15 @@ ViewSettingsPage::ViewSettingsPage(QWidget *parent) :
|
|||
QTabWidget* tabWidget = new QTabWidget(this);
|
||||
|
||||
// initialize 'General' tab
|
||||
m_generalPage = new GeneralViewSettingsPage(tabWidget);
|
||||
m_generalPage = new GeneralViewSettingsPage(mainWindow, tabWidget);
|
||||
tabWidget->addTab(m_generalPage, SmallIcon("view_choose"), i18n("General"));
|
||||
|
||||
// initialize 'Icons' tab
|
||||
m_iconsPage = new IconsViewSettingsPage(tabWidget);
|
||||
m_iconsPage = new IconsViewSettingsPage(mainWindow, tabWidget);
|
||||
tabWidget->addTab(m_iconsPage, SmallIcon("view_icon"), i18n("Icons"));
|
||||
|
||||
// initialize 'Details' tab
|
||||
m_detailsPage = new DetailsViewSettingsPage(tabWidget);
|
||||
m_detailsPage = new DetailsViewSettingsPage(mainWindow, tabWidget);
|
||||
tabWidget->addTab(m_detailsPage, SmallIcon("view_text"), i18n("Details"));
|
||||
|
||||
topLayout->addWidget(tabWidget, 0, 0 );
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <qwidget.h>
|
||||
#include <settingspagebase.h>
|
||||
|
||||
class DolphinMainWindow;
|
||||
class GeneralViewSettingsPage;
|
||||
class IconsViewSettingsPage;
|
||||
class DetailsViewSettingsPage;
|
||||
|
@ -32,16 +33,13 @@ class DetailsViewSettingsPage;
|
|||
*
|
||||
* The views settings allow to set the properties for the icons mode and
|
||||
* the details mode.
|
||||
*
|
||||
* @author Peter Penz <peter.penz@gmx.at>
|
||||
*/
|
||||
class ViewSettingsPage : public SettingsPageBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ViewSettingsPage(QWidget* parent);
|
||||
|
||||
ViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
|
||||
virtual ~ViewSettingsPage();
|
||||
|
||||
/** @see SettingsPageBase::applySettings */
|
||||
|
|
Loading…
Reference in New Issue
Block a user