#include "applyviewpropsjob.h"
#include "viewproperties.h"
+#include <assert.h>
#include <kdebug.h>
ApplyViewPropsJob::ApplyViewPropsJob(const KUrl& dir,
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);
}
}
}
#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),
#include <settingspagebase.h>
#include <q3valuelist.h>
+class DolphinMainWindow;
class K3ListView;
class KPushButton;
class Q3ListViewItem;
Q_OBJECT
public:
- BookmarksSettingsPage(QWidget* parent);
+ BookmarksSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
virtual ~BookmarksSettingsPage();
IconIdx = 3
};
+ DolphinMainWindow* m_mainWindow;
K3ListView* m_listView;
KPushButton* m_addButton;
KPushButton* m_editButton;
#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),
#include <kvbox.h>
+class DolphinMainWindow;
class QCheckBox;
class QFontComboBox;
class QSpinBox;
/**
* @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();
/**
void applySettings();
private:
+ DolphinMainWindow* m_mainWindow;
QCheckBox* m_dateBox;
QCheckBox* m_permissionsBox;
QCheckBox* m_ownerBox;
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"));
}
#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
{
public:
GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
-
virtual ~GeneralSettingsPage();
/** @see SettingsPageBase::applySettings */
void useDefaulLocation();
private:
- DolphinMainWindow *m_mainWindow;
+ DolphinMainWindow* m_mainWindow;
QLineEdit* m_homeUrl;
QCheckBox* m_startSplit;
QCheckBox* m_startEditable;
***************************************************************************/
#include "generalviewsettingspage.h"
+#include "dolphinmainwindow.h"
#include "dolphinsettings.h"
#include "generalsettings.h"
+#include "viewproperties.h"
#include <assert.h>
#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)
{
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"
#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();
/**
void applySettings();
private:
+ DolphinMainWindow* m_mainWindow;
QRadioButton* m_localProps;
QRadioButton* m_globalProps;
};
#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),
#ifndef ICONSVIEWSETTINGSPAGE_H
#define ICONSVIEWSETTINGSPAGE_H
-
#include <dolphiniconsview.h>
#include <kvbox.h>
+class DolphinMainWindow;
class QSlider;
class QComboBox;
class QCheckBox;
* - 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();
/**
void slotPreviewSizeChanged(int value);
private:
+ DolphinMainWindow* m_mainWindow;
QSlider* m_iconSizeSlider;
PixmapViewer* m_iconSizeViewer;
QSlider* m_previewSizeSlider;
m_node(0)
{
KUrl cleanUrl(url);
-
cleanUrl.cleanPath();
m_filepath = cleanUrl.path();
// 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));
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;
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)
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
* 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
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:
#include <klocale.h>
#include <kiconloader.h>
-ViewSettingsPage::ViewSettingsPage(QWidget *parent) :
+ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow,
+ QWidget* parent) :
SettingsPageBase(parent),
m_generalPage(0),
m_iconsPage(0),
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 );
#include <qwidget.h>
#include <settingspagebase.h>
+class DolphinMainWindow;
class GeneralViewSettingsPage;
class IconsViewSettingsPage;
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 */