#include <kmessagebox.h>
#include <kstandarddirs.h>
#include <kurl.h>
+#include <kcombobox.h>
#include <QAction>
#include <QButtonGroup>
#include <QCheckBox>
-#include <QComboBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QLabel>
m_additionalInfo(0),
m_applyToCurrentFolder(0),
m_applyToSubFolders(0),
+ m_applyToAllFolders(0),
m_useAsDefault(0)
{
Q_ASSERT(dolphinView != 0);
QWidget* propsGrid = new QWidget();
QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
- m_viewMode = new QComboBox(propsGrid);
+ m_viewMode = new KComboBox(propsGrid);
m_viewMode->addItem(KIcon("view-list-icons"), i18nc("@item:inlistbox", "Icons"));
m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Details"));
m_viewMode->addItem(KIcon("view-file-columns"), i18nc("@item:inlistbox", "Column"));
QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
QWidget* sortingBox = new QWidget(propsGrid);
- m_sortOrder = new QComboBox(sortingBox);
- m_sortOrder->addItem(i18nc("@item:inlistbox", "Ascending"));
- m_sortOrder->addItem(i18nc("@item:inlistbox", "Descending"));
+ m_sortOrder = new KComboBox(sortingBox);
+ m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Ascending"));
+ m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Descending"));
- m_sorting = new QComboBox(sortingBox);
+ m_sorting = new KComboBox(sortingBox);
m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Name"));
m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Size"));
m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Date"));
sortingBox->setLayout(sortingLayout);
QGridLayout* propsGridLayout = new QGridLayout(propsGrid);
- propsGridLayout->addWidget(viewModeLabel, 0, 0);
+ propsGridLayout->addWidget(viewModeLabel, 0, 0, Qt::AlignRight);
propsGridLayout->addWidget(m_viewMode, 0, 1);
- propsGridLayout->addWidget(sortingLabel, 1, 0);
+ propsGridLayout->addWidget(sortingLabel, 1, 0, Qt::AlignRight);
propsGridLayout->addWidget(sortingBox, 1, 1);
QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
void ViewPropertiesDialog::applyViewProperties()
{
- const bool applyToSubFolders = m_isDirty &&
- (m_applyToSubFolders != 0) &&
+ // if nothing changed in the dialog, we have nothing to apply
+ if (!m_isDirty) {
+ return;
+ }
+
+ const bool applyToSubFolders = (m_applyToSubFolders != 0) &&
m_applyToSubFolders->isChecked();
if (applyToSubFolders) {
const QString text(i18nc("@info", "The view properties of all sub folders will be changed. Do you want to continue?"));
}
ViewPropsProgressInfo* info = new ViewPropsProgressInfo(m_dolphinView,
- m_dolphinView->url(),
- *m_viewProps);
+ m_dolphinView->url(),
+ *m_viewProps);
+ info->setAttribute(Qt::WA_DeleteOnClose);
info->setWindowModality(Qt::NonModal);
info->show();
}
- const bool applyToAllFolders = m_isDirty &&
- (m_applyToAllFolders != 0) &&
+ const bool applyToAllFolders = (m_applyToAllFolders != 0) &&
m_applyToAllFolders->isChecked();
+
+ // If the user selected 'Apply To All Folders' the view properties implicitely
+ // are also used as default for new folders.
+ const bool useAsDefault = applyToAllFolders ||
+ ((m_useAsDefault != 0) && m_useAsDefault->isChecked());
+ if (useAsDefault) {
+ // For directories where no .directory file is available, the .directory
+ // file stored for the global view properties is used as fallback. To update
+ // this file we temporary turn on the global view properties mode.
+ GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+ Q_ASSERT(!settings->globalViewProps());
+
+ settings->setGlobalViewProps(true);
+ ViewProperties defaultProps(m_dolphinView->url());
+ defaultProps.setDirProperties(*m_viewProps);
+ defaultProps.save();
+ settings->setGlobalViewProps(false);
+ }
+
if (applyToAllFolders) {
const QString text(i18nc("@info", "The view properties of all folders will be changed. Do you want to continue?"));
if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) {
// all existing viewproperties invalid, as they have a smaller time stamp.
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
settings->setViewPropsTimestamp(QDateTime::currentDateTime());
-
- // This is also a good chance to make a cleanup of all mirrored view properties:
- const KUrl mirroredDir = ViewProperties::mirroredDirectory();
- KIO::NetAccess::del(mirroredDir, this);
}
- m_viewProps->save();
-
m_dolphinView->setMode(m_viewProps->viewMode());
m_dolphinView->setSorting(m_viewProps->sorting());
m_dolphinView->setSortOrder(m_viewProps->sortOrder());
m_dolphinView->setShowPreview(m_viewProps->showPreview());
m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles());
- m_isDirty = false;
-
- if (m_useAsDefault && m_useAsDefault->isChecked()) {
- // For directories where no .directory file is available, the .directory
- // file stored for the global view properties is used as fallback. To update
- // this file we temporary turn on the global view properties mode.
- GeneralSettings* settings = DolphinSettings::instance().generalSettings();
- Q_ASSERT(!settings->globalViewProps());
+ m_viewProps->save();
- settings->setGlobalViewProps(true);
- ViewProperties defaultProps(m_dolphinView->url());
- defaultProps.setDirProperties(*m_viewProps);
- defaultProps.save();
- settings->setGlobalViewProps(false);
- }
+ m_isDirty = false;
}
void ViewPropertiesDialog::loadSettings()