mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Settings Add ViewModes > Content display
This does not move the settings location in files though. baby step for https://invent.kde.org/system/dolphin/-/issues/36
This commit is contained in:
parent
d8bf2f3f19
commit
3338c2834a
|
@ -183,6 +183,7 @@ kconfig_add_kcfg_files(dolphinprivate
|
|||
settings/dolphin_directoryviewpropertysettings.kcfgc
|
||||
settings/dolphin_detailsmodesettings.kcfgc
|
||||
settings/dolphin_iconsmodesettings.kcfgc
|
||||
settings/dolphin_contentdisplaysettings.kcfgc
|
||||
settings/dolphin_generalsettings.kcfgc
|
||||
settings/dolphin_contextmenusettings.kcfgc
|
||||
settings/dolphin_versioncontrolsettings.kcfgc
|
||||
|
@ -305,6 +306,7 @@ target_sources(dolphinstatic PRIVATE
|
|||
settings/viewmodes/viewsettingspage.cpp
|
||||
settings/viewmodes/viewmodesettings.cpp
|
||||
settings/viewmodes/viewsettingstab.cpp
|
||||
settings/viewmodes/contentdisplaytab.cpp
|
||||
statusbar/dolphinstatusbar.cpp
|
||||
statusbar/mountpointobserver.cpp
|
||||
statusbar/mountpointobservercache.cpp
|
||||
|
@ -364,6 +366,7 @@ target_sources(dolphinstatic PRIVATE
|
|||
settings/viewmodes/viewsettingspage.h
|
||||
settings/viewmodes/viewmodesettings.h
|
||||
settings/viewmodes/viewsettingstab.h
|
||||
settings/viewmodes/contentdisplaytab.h
|
||||
statusbar/dolphinstatusbar.h
|
||||
statusbar/mountpointobserver.h
|
||||
statusbar/mountpointobservercache.h
|
||||
|
@ -408,6 +411,7 @@ kconfig_add_kcfg_files(dolphinstatic
|
|||
settings/dolphin_detailsmodesettings.kcfgc
|
||||
settings/dolphin_contextmenusettings.kcfgc
|
||||
settings/dolphin_iconsmodesettings.kcfgc
|
||||
settings/dolphin_contentdisplaysettings.kcfgc
|
||||
search/dolphin_searchsettings.kcfgc
|
||||
settings/dolphin_versioncontrolsettings.kcfgc
|
||||
)
|
||||
|
@ -544,6 +548,7 @@ if(NOT WIN32)
|
|||
settings/dolphin_directoryviewpropertysettings.kcfgc
|
||||
settings/dolphin_detailsmodesettings.kcfgc
|
||||
settings/dolphin_iconsmodesettings.kcfgc
|
||||
settings/dolphin_contentdisplaysettings.kcfgc
|
||||
settings/dolphin_generalsettings.kcfgc
|
||||
settings/dolphin_versioncontrolsettings.kcfgc
|
||||
)
|
||||
|
@ -586,6 +591,7 @@ install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
|
|||
settings/dolphin_compactmodesettings.kcfg
|
||||
settings/dolphin_iconsmodesettings.kcfg
|
||||
settings/dolphin_detailsmodesettings.kcfg
|
||||
settings/dolphin_contentdisplaysettings.kcfg
|
||||
settings/dolphin_versioncontrolsettings.kcfg
|
||||
DESTINATION ${KDE_INSTALL_KCFGDIR} )
|
||||
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
|
||||
#include "dolphinviewcontainer.h"
|
||||
|
||||
#include "dolphin_compactmodesettings.h"
|
||||
#include "dolphin_contentdisplaysettings.h"
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
#include "dolphin_generalsettings.h"
|
||||
#include "dolphin_iconsmodesettings.h"
|
||||
#include "dolphindebug.h"
|
||||
#include "dolphinplacesmodelsingleton.h"
|
||||
#include "filterbar/filterbar.h"
|
||||
|
@ -176,11 +179,9 @@ DolphinViewContainer::DolphinViewContainer(const QUrl &url, QWidget *parent)
|
|||
|
||||
setSearchModeEnabled(isSearchUrl(url));
|
||||
|
||||
connect(DetailsModeSettings::self(), &KCoreConfigSkeleton::configChanged, this, [=]() {
|
||||
if (view()->viewMode() == DolphinView::Mode::DetailsView) {
|
||||
view()->reload();
|
||||
}
|
||||
});
|
||||
// Update view as the ContentDisplaySettings change
|
||||
// this happens here and not in DolphinView as DolphinviewContainer and DolphinView are not in the same build target ATM
|
||||
connect(ContentDisplaySettings::self(), &KCoreConfigSkeleton::configChanged, m_view, &DolphinView::reload);
|
||||
|
||||
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
|
||||
connect(placesModel, &KFilePlacesModel::dataChanged, this, &DolphinViewContainer::slotPlacesModelChanged);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "kfileitemmodel.h"
|
||||
#include "kitemlistview.h"
|
||||
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
#include "dolphin_contentdisplaysettings.h"
|
||||
|
||||
#include <KFormat>
|
||||
#include <KLocalizedString>
|
||||
|
@ -56,7 +56,7 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHa
|
|||
// use a hash + switch for a linear runtime.
|
||||
|
||||
auto formatDate = [formatter, local](const QDateTime &time) {
|
||||
if (DetailsModeSettings::useShortRelativeDates()) {
|
||||
if (ContentDisplaySettings::useShortRelativeDates()) {
|
||||
return formatter.formatRelativeDateTime(time, QLocale::ShortFormat);
|
||||
} else {
|
||||
return local.toString(time, QLocale::ShortFormat);
|
||||
|
@ -67,7 +67,7 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHa
|
|||
if (values.value("isDir").toBool()) {
|
||||
if (!roleValue.isNull() && roleValue != -1) {
|
||||
// The item represents a directory.
|
||||
if (DetailsModeSettings::directorySizeCount() || roleValue == -2 /* size is invalid */) {
|
||||
if (ContentDisplaySettings::directorySizeCount() || roleValue == -2 /* size is invalid */) {
|
||||
// Show the number of sub directories instead of the file size of the directory.
|
||||
const int count = values.value("count").toInt();
|
||||
text = i18ncp("@item:intable", "%1 item", "%1 items", count);
|
||||
|
@ -101,14 +101,14 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHa
|
|||
} else if (role == "permissions") {
|
||||
const auto permissions = roleValue.value<QVariantList>();
|
||||
|
||||
switch (DetailsModeSettings::usePermissionsFormat()) {
|
||||
case DetailsModeSettings::EnumUsePermissionsFormat::SymbolicFormat:
|
||||
switch (ContentDisplaySettings::usePermissionsFormat()) {
|
||||
case ContentDisplaySettings::EnumUsePermissionsFormat::SymbolicFormat:
|
||||
text = permissions.at(0).toString();
|
||||
break;
|
||||
case DetailsModeSettings::EnumUsePermissionsFormat::NumericFormat:
|
||||
case ContentDisplaySettings::EnumUsePermissionsFormat::NumericFormat:
|
||||
text = QString::number(permissions.at(1).toInt(), 8);
|
||||
break;
|
||||
case DetailsModeSettings::EnumUsePermissionsFormat::CombinedFormat:
|
||||
case ContentDisplaySettings::EnumUsePermissionsFormat::CombinedFormat:
|
||||
text = QString("%1 (%2)").arg(permissions.at(0).toString()).arg(permissions.at(1).toInt(), 0, 8);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "kfileitemmodel.h"
|
||||
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
#include "dolphin_contentdisplaysettings.h"
|
||||
#include "dolphin_generalsettings.h"
|
||||
#include "dolphindebug.h"
|
||||
#include "private/kfileitemmodelsortalgorithm.h"
|
||||
|
@ -1991,7 +1991,7 @@ bool KFileItemModel::lessThan(const ItemData *a, const ItemData *b, const QColla
|
|||
}
|
||||
}
|
||||
|
||||
if (m_sortDirsFirst || (DetailsModeSettings::directorySizeCount() && m_sortRole == SizeRole)) {
|
||||
if (m_sortDirsFirst || (ContentDisplaySettings::directorySizeCount() && m_sortRole == SizeRole)) {
|
||||
const bool isDirA = a->item.isDir();
|
||||
const bool isDirB = b->item.isDir();
|
||||
if (isDirA && !isDirB) {
|
||||
|
@ -2043,7 +2043,7 @@ int KFileItemModel::sortRoleCompare(const ItemData *a, const ItemData *b, const
|
|||
break;
|
||||
|
||||
case SizeRole: {
|
||||
if (DetailsModeSettings::directorySizeCount() && itemA.isDir()) {
|
||||
if (ContentDisplaySettings::directorySizeCount() && itemA.isDir()) {
|
||||
// folders first then
|
||||
// items A and B are folders thanks to lessThan checks
|
||||
auto valueA = a->values.value("count");
|
||||
|
@ -2303,7 +2303,7 @@ QList<QPair<int, QVariant>> KFileItemModel::sizeRoleGroups() const
|
|||
KIO::filesize_t fileSize = !item.isNull() ? item.size() : ~0U;
|
||||
QString newGroupValue;
|
||||
if (!item.isNull() && item.isDir()) {
|
||||
if (DetailsModeSettings::directorySizeCount() || m_sortDirsFirst) {
|
||||
if (ContentDisplaySettings::directorySizeCount() || m_sortDirsFirst) {
|
||||
newGroupValue = i18nc("@title:group Size", "Folders");
|
||||
} else {
|
||||
fileSize = m_itemData.at(i)->values.value("size").toULongLong();
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "kfileitemmodel.h"
|
||||
#include "private/kdirectorycontentscounter.h"
|
||||
#include "private/kpixmapmodifier.h"
|
||||
#include "qdir.h"
|
||||
|
||||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
|
@ -21,7 +20,7 @@
|
|||
#include <KPluginMetaData>
|
||||
#include <KSharedConfig>
|
||||
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
#include "dolphin_contentdisplaysettings.h"
|
||||
|
||||
#if HAVE_BALOO
|
||||
#include "private/kbaloorolesprovider.h"
|
||||
|
@ -1269,7 +1268,7 @@ bool KFileItemModelRolesUpdater::applyResolvedRoles(int index, ResolveHint hint)
|
|||
|
||||
void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &item, int index)
|
||||
{
|
||||
if (DetailsModeSettings::directorySizeCount() || item.isSlow() || !item.isLocalFile()) {
|
||||
if (ContentDisplaySettings::directorySizeCount() || item.isSlow() || !item.isLocalFile()) {
|
||||
// fastpath no recursion necessary
|
||||
|
||||
auto data = m_model->data(index);
|
||||
|
|
|
@ -40,6 +40,7 @@ KItemListWidget::KItemListWidget(KItemListWidgetInformant *informant, QGraphicsI
|
|||
, m_data()
|
||||
, m_visibleRoles()
|
||||
, m_columnWidths()
|
||||
, m_sidePadding(0)
|
||||
, m_styleOption()
|
||||
, m_siblingsInfo()
|
||||
, m_hoverOpacity(0)
|
||||
|
@ -49,7 +50,6 @@ KItemListWidget::KItemListWidget(KItemListWidgetInformant *informant, QGraphicsI
|
|||
, m_selectionToggle(nullptr)
|
||||
, m_editedRole()
|
||||
, m_iconSize(-1)
|
||||
, m_sidePadding(0)
|
||||
{
|
||||
connect(&m_hoverSequenceTimer, &QTimer::timeout, this, &KItemListWidget::slotHoverSequenceTimerTimeout);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "kdirectorycontentscounter.h"
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
#include "dolphin_contentdisplaysettings.h"
|
||||
#include "kitemviews/kfileitemmodel.h"
|
||||
|
||||
#include <KDirWatch>
|
||||
|
@ -224,7 +224,7 @@ void KDirectoryContentsCounter::scheduleNext()
|
|||
}
|
||||
|
||||
m_workerIsBusy = true;
|
||||
Q_EMIT requestDirectoryContentsCount(m_currentPath, options, DetailsModeSettings::recursiveDirectorySizeLimit());
|
||||
Q_EMIT requestDirectoryContentsCount(m_currentPath, options, ContentDisplaySettings::recursiveDirectorySizeLimit());
|
||||
}
|
||||
|
||||
void KDirectoryContentsCounter::enqueuePathScanning(const QString &path, bool alreadyInCache, PathCountPriority priority)
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
Q_SIGNALS:
|
||||
/**
|
||||
* Signals that the directory \a path contains \a count items of size \a
|
||||
* Size calculation depends on parameter DetailsModeSettings::recursiveDirectorySizeLimit
|
||||
* Size calculation depends on parameter ContentDisplaySettings::recursiveDirectorySizeLimit
|
||||
*/
|
||||
void result(const QString &path, int count, long long size);
|
||||
|
||||
|
|
31
src/settings/dolphin_contentdisplaysettings.kcfg
Normal file
31
src/settings/dolphin_contentdisplaysettings.kcfg
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
|
||||
<kcfgfile name="dolphinrc"/>
|
||||
<group name="ContentDisplay">
|
||||
<entry name="DirectorySizeCount" type="Bool">
|
||||
<label>Whether or not content count is used as directory size</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="RecursiveDirectorySizeLimit" type="UInt">
|
||||
<label>Recursive directory size limit</label>
|
||||
<default>10</default>
|
||||
</entry>
|
||||
<entry name="UseShortRelativeDates" type="Bool">
|
||||
<label>if true we use short relative dates, if not short dates</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="UsePermissionsFormat" type="Enum">
|
||||
<label>Permissions style format</label>
|
||||
<choices>
|
||||
<choice name="SymbolicFormat" />
|
||||
<choice name="NumericFormat" />
|
||||
<choice name="CombinedFormat" />
|
||||
</choices>
|
||||
<default>0</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
4
src/settings/dolphin_contentdisplaysettings.kcfgc
Normal file
4
src/settings/dolphin_contentdisplaysettings.kcfgc
Normal file
|
@ -0,0 +1,4 @@
|
|||
File=dolphin_contentdisplaysettings.kcfg
|
||||
ClassName=ContentDisplaySettings
|
||||
Singleton=yes
|
||||
Mutators=true
|
|
@ -39,26 +39,5 @@
|
|||
<label>Expandable folders</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="DirectorySizeCount" type="Bool">
|
||||
<label>Whether or not content count is used as directory size</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="RecursiveDirectorySizeLimit" type="UInt">
|
||||
<label>Recursive directory size limit</label>
|
||||
<default>10</default>
|
||||
</entry>
|
||||
<entry name="UseShortRelativeDates" type="Bool">
|
||||
<label>if true we use short relative dates, if not short dates</label>
|
||||
<default>true</default>
|
||||
</entry>
|
||||
<entry name="UsePermissionsFormat" type="Enum">
|
||||
<label>Permissions style format</label>
|
||||
<choices>
|
||||
<choice name="SymbolicFormat" />
|
||||
<choice name="NumericFormat" />
|
||||
<choice name="CombinedFormat" />
|
||||
</choices>
|
||||
<default>0</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
|
|
|
@ -5,4 +5,13 @@ Version=5
|
|||
Id=rename-leading-padding
|
||||
File=dolphinrc
|
||||
Group=DetailsMode
|
||||
Key=LeadingPadding,SidePadding
|
||||
Key=LeadingPadding,SidePadding
|
||||
|
||||
#Rename Move content-display from detailsMode
|
||||
Id=move-content-display
|
||||
File=dolphinrc
|
||||
Group=DetailsMode,ContentDisplay
|
||||
Key=DirectorySizeCount
|
||||
Key=RecursiveDirectorySizeLimit
|
||||
Key=UseShortRelativeDates
|
||||
Key=UsePermissionsFormat
|
||||
|
|
148
src/settings/viewmodes/contentdisplaytab.cpp
Normal file
148
src/settings/viewmodes/contentdisplaytab.cpp
Normal file
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Méven Car <meven@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "contentdisplaytab.h"
|
||||
#include "dolphin_contentdisplaysettings.h"
|
||||
|
||||
#include <KFormat>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QFormLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QRadioButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
ContentDisplayTab::ContentDisplayTab(QWidget *parent)
|
||||
: SettingsPageBase(parent)
|
||||
, m_numberOfItems(nullptr)
|
||||
, m_sizeOfContents(nullptr)
|
||||
, m_recursiveDirectorySizeLimit(nullptr)
|
||||
, m_useRelatetiveDates(nullptr)
|
||||
, m_useShortDates(nullptr)
|
||||
, m_useSymbolicPermissions(nullptr)
|
||||
, m_useNumericPermissions(nullptr)
|
||||
, m_useCombinedPermissions(nullptr)
|
||||
{
|
||||
QFormLayout *topLayout = new QFormLayout(this);
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
// Sorting properties
|
||||
m_numberOfItems = new QRadioButton(i18nc("option:radio", "Number of items"));
|
||||
m_sizeOfContents = new QRadioButton(i18nc("option:radio", "Size of contents, up to "));
|
||||
|
||||
QButtonGroup *sortingModeGroup = new QButtonGroup(this);
|
||||
sortingModeGroup->addButton(m_numberOfItems);
|
||||
sortingModeGroup->addButton(m_sizeOfContents);
|
||||
|
||||
m_recursiveDirectorySizeLimit = new QSpinBox();
|
||||
connect(m_recursiveDirectorySizeLimit, &QSpinBox::valueChanged, this, [this](int value) {
|
||||
m_recursiveDirectorySizeLimit->setSuffix(i18np(" level deep", " levels deep", value));
|
||||
});
|
||||
m_recursiveDirectorySizeLimit->setRange(1, 20);
|
||||
m_recursiveDirectorySizeLimit->setSingleStep(1);
|
||||
|
||||
QHBoxLayout *contentsSizeLayout = new QHBoxLayout();
|
||||
contentsSizeLayout->addWidget(m_sizeOfContents);
|
||||
contentsSizeLayout->addWidget(m_recursiveDirectorySizeLimit);
|
||||
|
||||
topLayout->addRow(i18nc("@title:group", "Folder size displays:"), m_numberOfItems);
|
||||
topLayout->addRow(QString(), contentsSizeLayout);
|
||||
#endif
|
||||
|
||||
QDateTime thirtyMinutesAgo = QDateTime::currentDateTime().addSecs(-30 * 60);
|
||||
QLocale local;
|
||||
KFormat formatter(local);
|
||||
|
||||
m_useRelatetiveDates = new QRadioButton(
|
||||
i18nc("option:radio as in relative date", "Relative (e.g. '%1')", formatter.formatRelativeDateTime(thirtyMinutesAgo, QLocale::ShortFormat)));
|
||||
m_useShortDates =
|
||||
new QRadioButton(i18nc("option:radio as in absolute date", "Absolute (e.g. '%1')", local.toString(thirtyMinutesAgo, QLocale::ShortFormat)));
|
||||
|
||||
QButtonGroup *dateFormatGroup = new QButtonGroup(this);
|
||||
dateFormatGroup->addButton(m_useRelatetiveDates);
|
||||
dateFormatGroup->addButton(m_useShortDates);
|
||||
|
||||
topLayout->addRow(i18nc("@title:group", "Date style:"), m_useRelatetiveDates);
|
||||
topLayout->addRow(QString(), m_useShortDates);
|
||||
|
||||
m_useSymbolicPermissions = new QRadioButton(i18nc("option:radio as symbolic style ", "Symbolic (e.g. 'drwxr-xr-x')"));
|
||||
m_useNumericPermissions = new QRadioButton(i18nc("option:radio as numeric style", "Numeric (Octal) (e.g. '755')"));
|
||||
m_useCombinedPermissions = new QRadioButton(i18nc("option:radio as combined style", "Combined (e.g. 'drwxr-xr-x (755)')"));
|
||||
|
||||
topLayout->addRow(i18nc("@title:group", "Permissions style:"), m_useSymbolicPermissions);
|
||||
topLayout->addRow(QString(), m_useNumericPermissions);
|
||||
topLayout->addRow(QString(), m_useCombinedPermissions);
|
||||
|
||||
QButtonGroup *permissionsFormatGroup = new QButtonGroup(this);
|
||||
permissionsFormatGroup->addButton(m_useSymbolicPermissions);
|
||||
permissionsFormatGroup->addButton(m_useNumericPermissions);
|
||||
permissionsFormatGroup->addButton(m_useCombinedPermissions);
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
connect(m_recursiveDirectorySizeLimit, &QSpinBox::valueChanged, this, &SettingsPageBase::changed);
|
||||
connect(m_numberOfItems, &QRadioButton::toggled, this, &SettingsPageBase::changed);
|
||||
connect(m_sizeOfContents, &QRadioButton::toggled, this, [=]() {
|
||||
m_recursiveDirectorySizeLimit->setEnabled(m_sizeOfContents->isChecked());
|
||||
});
|
||||
#endif
|
||||
|
||||
connect(m_useRelatetiveDates, &QRadioButton::toggled, this, &SettingsPageBase::changed);
|
||||
connect(m_useShortDates, &QRadioButton::toggled, this, &SettingsPageBase::changed);
|
||||
connect(m_useSymbolicPermissions, &QRadioButton::toggled, this, &SettingsPageBase::changed);
|
||||
connect(m_useNumericPermissions, &QRadioButton::toggled, this, &SettingsPageBase::changed);
|
||||
connect(m_useCombinedPermissions, &QRadioButton::toggled, this, &SettingsPageBase::changed);
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
void ContentDisplayTab::applySettings()
|
||||
{
|
||||
auto settings = ContentDisplaySettings::self();
|
||||
#ifndef Q_OS_WIN
|
||||
settings->setDirectorySizeCount(m_numberOfItems->isChecked());
|
||||
settings->setRecursiveDirectorySizeLimit(m_recursiveDirectorySizeLimit->value());
|
||||
#endif
|
||||
|
||||
settings->setUseShortRelativeDates(m_useRelatetiveDates->isChecked());
|
||||
|
||||
if (m_useSymbolicPermissions->isChecked()) {
|
||||
settings->setUsePermissionsFormat(ContentDisplaySettings::EnumUsePermissionsFormat::SymbolicFormat);
|
||||
} else if (m_useNumericPermissions->isChecked()) {
|
||||
settings->setUsePermissionsFormat(ContentDisplaySettings::EnumUsePermissionsFormat::NumericFormat);
|
||||
} else if (m_useCombinedPermissions->isChecked()) {
|
||||
settings->setUsePermissionsFormat(ContentDisplaySettings::EnumUsePermissionsFormat::CombinedFormat);
|
||||
}
|
||||
settings->save();
|
||||
}
|
||||
|
||||
void ContentDisplayTab::loadSettings()
|
||||
{
|
||||
auto settings = ContentDisplaySettings::self();
|
||||
#ifndef Q_OS_WIN
|
||||
if (settings->directorySizeCount()) {
|
||||
m_numberOfItems->setChecked(true);
|
||||
m_recursiveDirectorySizeLimit->setEnabled(false);
|
||||
} else {
|
||||
m_sizeOfContents->setChecked(true);
|
||||
m_recursiveDirectorySizeLimit->setEnabled(true);
|
||||
}
|
||||
m_recursiveDirectorySizeLimit->setValue(settings->recursiveDirectorySizeLimit());
|
||||
#endif
|
||||
m_useRelatetiveDates->setChecked(settings->useShortRelativeDates());
|
||||
m_useShortDates->setChecked(!settings->useShortRelativeDates());
|
||||
m_useSymbolicPermissions->setChecked(settings->usePermissionsFormat() == ContentDisplaySettings::EnumUsePermissionsFormat::SymbolicFormat);
|
||||
m_useNumericPermissions->setChecked(settings->usePermissionsFormat() == ContentDisplaySettings::EnumUsePermissionsFormat::NumericFormat);
|
||||
m_useCombinedPermissions->setChecked(settings->usePermissionsFormat() == ContentDisplaySettings::EnumUsePermissionsFormat::CombinedFormat);
|
||||
}
|
||||
|
||||
void ContentDisplayTab::restoreDefaults()
|
||||
{
|
||||
auto settings = ContentDisplaySettings::self();
|
||||
settings->useDefaults(true);
|
||||
loadSettings();
|
||||
settings->useDefaults(false);
|
||||
}
|
39
src/settings/viewmodes/contentdisplaytab.h
Normal file
39
src/settings/viewmodes/contentdisplaytab.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Méven Car <meven@kde.org>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
#ifndef GENERALTAB_H
|
||||
#define GENERALTAB_H
|
||||
|
||||
#include "settings/settingspagebase.h"
|
||||
|
||||
class QRadioButton;
|
||||
class QSpinBox;
|
||||
|
||||
class ContentDisplayTab : public SettingsPageBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ContentDisplayTab(QWidget *parent);
|
||||
|
||||
public:
|
||||
// SettingsPageBase interface
|
||||
void applySettings() override;
|
||||
void restoreDefaults() override;
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
|
||||
QRadioButton *m_numberOfItems;
|
||||
QRadioButton *m_sizeOfContents;
|
||||
QSpinBox *m_recursiveDirectorySizeLimit;
|
||||
QRadioButton *m_useRelatetiveDates;
|
||||
QRadioButton *m_useShortDates;
|
||||
QRadioButton *m_useSymbolicPermissions;
|
||||
QRadioButton *m_useNumericPermissions;
|
||||
QRadioButton *m_useCombinedPermissions;
|
||||
};
|
||||
|
||||
#endif // GENERALTAB_H
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "viewsettingspage.h"
|
||||
|
||||
#include "views/dolphinview.h"
|
||||
#include "contentdisplaytab.h"
|
||||
#include "viewsettingstab.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
@ -21,7 +21,14 @@ ViewSettingsPage::ViewSettingsPage(QWidget *parent)
|
|||
QVBoxLayout *topLayout = new QVBoxLayout(this);
|
||||
topLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QTabWidget *tabWidget = new QTabWidget(this);
|
||||
tabWidget = new QTabWidget(this);
|
||||
|
||||
// Content Display Tab
|
||||
contentDisplayTab = new ContentDisplayTab(tabWidget);
|
||||
tabWidget->addTab(contentDisplayTab,
|
||||
QIcon::fromTheme(QStringLiteral("view-choose")),
|
||||
i18nc("@title:tab how file items columns are displayed", "Content Display"));
|
||||
connect(contentDisplayTab, &SettingsPageBase::changed, this, &ViewSettingsPage::changed);
|
||||
|
||||
// Initialize 'Icons' tab
|
||||
ViewSettingsTab *iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
|
||||
|
@ -51,6 +58,8 @@ ViewSettingsPage::~ViewSettingsPage()
|
|||
|
||||
void ViewSettingsPage::applySettings()
|
||||
{
|
||||
contentDisplayTab->applySettings();
|
||||
|
||||
for (ViewSettingsTab *tab : qAsConst(m_tabs)) {
|
||||
tab->applySettings();
|
||||
}
|
||||
|
@ -58,7 +67,15 @@ void ViewSettingsPage::applySettings()
|
|||
|
||||
void ViewSettingsPage::restoreDefaults()
|
||||
{
|
||||
if (tabWidget->currentWidget() == contentDisplayTab) {
|
||||
contentDisplayTab->restoreDefaults();
|
||||
return;
|
||||
}
|
||||
|
||||
for (ViewSettingsTab *tab : qAsConst(m_tabs)) {
|
||||
tab->restoreDefaultSettings();
|
||||
if (tabWidget->currentWidget() == tab) {
|
||||
tab->restoreDefaultSettings();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
class ViewSettingsTab;
|
||||
class QWidget;
|
||||
class ContentDisplayTab;
|
||||
class QTabWidget;
|
||||
|
||||
/**
|
||||
* @brief Page for the 'View' settings of the Dolphin settings dialog.
|
||||
|
@ -32,6 +34,8 @@ public:
|
|||
void restoreDefaults() override;
|
||||
|
||||
private:
|
||||
ContentDisplayTab *contentDisplayTab;
|
||||
QTabWidget *tabWidget;
|
||||
QList<ViewSettingsTab *> m_tabs;
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "settings/viewmodes/viewmodesettings.h"
|
||||
#include "views/zoomlevelinfo.h"
|
||||
|
||||
#include <KFormat>
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QApplication>
|
||||
|
@ -35,12 +34,6 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget *parent)
|
|||
, m_widthBox(nullptr)
|
||||
, m_maxLinesBox(nullptr)
|
||||
, m_expandableFolders(nullptr)
|
||||
, m_recursiveDirectorySizeLimit(nullptr)
|
||||
, m_useRelatetiveDates(nullptr)
|
||||
, m_useShortDates(nullptr)
|
||||
, m_useSymbolicPermissions(nullptr)
|
||||
, m_useNumericPermissions(nullptr)
|
||||
, m_useCombinedPermissions(nullptr)
|
||||
{
|
||||
QFormLayout *topLayout = new QFormLayout(this);
|
||||
|
||||
|
@ -113,61 +106,6 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget *parent)
|
|||
topLayout->addRow(i18nc("@title:group", "Open files and folders:"), m_entireRow);
|
||||
// clang-format on
|
||||
topLayout->addRow(QString(), m_iconAndNameOnly);
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
// Sorting properties
|
||||
m_numberOfItems = new QRadioButton(i18nc("option:radio", "Number of items"));
|
||||
m_sizeOfContents = new QRadioButton(i18nc("option:radio", "Size of contents, up to "));
|
||||
|
||||
QButtonGroup *sortingModeGroup = new QButtonGroup(this);
|
||||
sortingModeGroup->addButton(m_numberOfItems);
|
||||
sortingModeGroup->addButton(m_sizeOfContents);
|
||||
|
||||
m_recursiveDirectorySizeLimit = new QSpinBox();
|
||||
connect(m_recursiveDirectorySizeLimit, &QSpinBox::valueChanged, this, [this](int value) {
|
||||
m_recursiveDirectorySizeLimit->setSuffix(i18np(" level deep", " levels deep", value));
|
||||
});
|
||||
m_recursiveDirectorySizeLimit->setRange(1, 20);
|
||||
m_recursiveDirectorySizeLimit->setSingleStep(1);
|
||||
|
||||
QHBoxLayout *contentsSizeLayout = new QHBoxLayout();
|
||||
contentsSizeLayout->addWidget(m_sizeOfContents);
|
||||
contentsSizeLayout->addWidget(m_recursiveDirectorySizeLimit);
|
||||
|
||||
topLayout->addRow(i18nc("@title:group", "Folder size displays:"), m_numberOfItems);
|
||||
topLayout->addRow(QString(), contentsSizeLayout);
|
||||
#endif
|
||||
|
||||
QDateTime thirtyMinutesAgo = QDateTime::currentDateTime().addSecs(-30 * 60);
|
||||
QLocale local;
|
||||
KFormat formatter(local);
|
||||
|
||||
m_useRelatetiveDates = new QRadioButton(
|
||||
i18nc("option:radio as in relative date", "Relative (e.g. '%1')", formatter.formatRelativeDateTime(thirtyMinutesAgo, QLocale::ShortFormat)));
|
||||
m_useShortDates =
|
||||
new QRadioButton(i18nc("option:radio as in absolute date", "Absolute (e.g. '%1')", local.toString(thirtyMinutesAgo, QLocale::ShortFormat)));
|
||||
|
||||
QButtonGroup *dateFormatGroup = new QButtonGroup(this);
|
||||
dateFormatGroup->addButton(m_useRelatetiveDates);
|
||||
dateFormatGroup->addButton(m_useShortDates);
|
||||
|
||||
topLayout->addRow(i18nc("@title:group", "Date style:"), m_useRelatetiveDates);
|
||||
topLayout->addRow(QString(), m_useShortDates);
|
||||
|
||||
m_useSymbolicPermissions = new QRadioButton(i18nc("option:radio as symbolic style ", "Symbolic (e.g. 'drwxr-xr-x')"));
|
||||
|
||||
m_useNumericPermissions = new QRadioButton(i18nc("option:radio as numeric style", "Numeric (Octal) (e.g. '755')"));
|
||||
|
||||
m_useCombinedPermissions = new QRadioButton(i18nc("option:radio as combined style", "Combined (e.g. 'drwxr-xr-x (755)')"));
|
||||
|
||||
topLayout->addRow(i18nc("@title:group", "Permissions style:"), m_useSymbolicPermissions);
|
||||
topLayout->addRow(QString(), m_useNumericPermissions);
|
||||
topLayout->addRow(QString(), m_useCombinedPermissions);
|
||||
|
||||
QButtonGroup *permissionsFormatGroup = new QButtonGroup(this);
|
||||
permissionsFormatGroup->addButton(m_useSymbolicPermissions);
|
||||
permissionsFormatGroup->addButton(m_useNumericPermissions);
|
||||
permissionsFormatGroup->addButton(m_useCombinedPermissions);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -188,18 +126,6 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget *parent)
|
|||
case DetailsMode:
|
||||
connect(m_entireRow, &QCheckBox::toggled, this, &ViewSettingsTab::changed);
|
||||
connect(m_expandableFolders, &QCheckBox::toggled, this, &ViewSettingsTab::changed);
|
||||
#ifndef Q_OS_WIN
|
||||
connect(m_recursiveDirectorySizeLimit, &QSpinBox::valueChanged, this, &ViewSettingsTab::changed);
|
||||
connect(m_numberOfItems, &QRadioButton::toggled, this, &ViewSettingsTab::changed);
|
||||
connect(m_sizeOfContents, &QRadioButton::toggled, this, [=]() {
|
||||
m_recursiveDirectorySizeLimit->setEnabled(m_sizeOfContents->isChecked());
|
||||
});
|
||||
#endif
|
||||
connect(m_useRelatetiveDates, &QRadioButton::toggled, this, &ViewSettingsTab::changed);
|
||||
connect(m_useShortDates, &QRadioButton::toggled, this, &ViewSettingsTab::changed);
|
||||
connect(m_useSymbolicPermissions, &QRadioButton::toggled, this, &ViewSettingsTab::changed);
|
||||
connect(m_useNumericPermissions, &QRadioButton::toggled, this, &ViewSettingsTab::changed);
|
||||
connect(m_useCombinedPermissions, &QRadioButton::toggled, this, &ViewSettingsTab::changed);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -212,50 +138,35 @@ ViewSettingsTab::~ViewSettingsTab()
|
|||
|
||||
void ViewSettingsTab::applySettings()
|
||||
{
|
||||
const QFont font = m_fontRequester->currentFont();
|
||||
const bool useSystemFont = (m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
|
||||
switch (m_mode) {
|
||||
case IconsMode:
|
||||
IconsModeSettings::setTextWidthIndex(m_widthBox->currentIndex());
|
||||
IconsModeSettings::setMaximumTextLines(m_maxLinesBox->currentIndex());
|
||||
IconsModeSettings::self()->save();
|
||||
break;
|
||||
case CompactMode:
|
||||
CompactModeSettings::setMaximumTextWidthIndex(m_widthBox->currentIndex());
|
||||
CompactModeSettings::self()->save();
|
||||
break;
|
||||
case DetailsMode:
|
||||
auto detailsModeSettings = DetailsModeSettings::self();
|
||||
// We need side-padding when the full row is a click target to still be able to not click items.
|
||||
// So here the default padding is enabled when the full row highlight is enabled.
|
||||
if (m_entireRow->isChecked() && !DetailsModeSettings::highlightEntireRow()) {
|
||||
auto detailsModeSettings = DetailsModeSettings::self();
|
||||
if (m_entireRow->isChecked() && !detailsModeSettings->highlightEntireRow()) {
|
||||
const bool usedDefaults = detailsModeSettings->useDefaults(true);
|
||||
const uint defaultSidePadding = detailsModeSettings->sidePadding();
|
||||
detailsModeSettings->useDefaults(usedDefaults);
|
||||
if (DetailsModeSettings::sidePadding() < defaultSidePadding) {
|
||||
DetailsModeSettings::setSidePadding(defaultSidePadding);
|
||||
if (detailsModeSettings->sidePadding() < defaultSidePadding) {
|
||||
detailsModeSettings->setSidePadding(defaultSidePadding);
|
||||
}
|
||||
} else if (!m_entireRow->isChecked() && DetailsModeSettings::highlightEntireRow()) {
|
||||
} else if (!m_entireRow->isChecked() && detailsModeSettings->highlightEntireRow()) {
|
||||
// The full row click target is disabled so now most of the view area can be used to interact
|
||||
// with the view background. Having an extra side padding has no usability benefit in this case.
|
||||
DetailsModeSettings::setSidePadding(0);
|
||||
detailsModeSettings->setSidePadding(0);
|
||||
}
|
||||
DetailsModeSettings::setHighlightEntireRow(m_entireRow->isChecked());
|
||||
DetailsModeSettings::setExpandableFolders(m_expandableFolders->isChecked());
|
||||
#ifndef Q_OS_WIN
|
||||
DetailsModeSettings::setDirectorySizeCount(m_numberOfItems->isChecked());
|
||||
DetailsModeSettings::setRecursiveDirectorySizeLimit(m_recursiveDirectorySizeLimit->value());
|
||||
#endif
|
||||
DetailsModeSettings::setUseShortRelativeDates(m_useRelatetiveDates->isChecked());
|
||||
|
||||
if (m_useSymbolicPermissions->isChecked()) {
|
||||
DetailsModeSettings::setUsePermissionsFormat(DetailsModeSettings::EnumUsePermissionsFormat::SymbolicFormat);
|
||||
} else if (m_useNumericPermissions->isChecked()) {
|
||||
DetailsModeSettings::setUsePermissionsFormat(DetailsModeSettings::EnumUsePermissionsFormat::NumericFormat);
|
||||
} else if (m_useCombinedPermissions->isChecked()) {
|
||||
DetailsModeSettings::setUsePermissionsFormat(DetailsModeSettings::EnumUsePermissionsFormat::CombinedFormat);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
detailsModeSettings->setHighlightEntireRow(m_entireRow->isChecked());
|
||||
detailsModeSettings->setExpandableFolders(m_expandableFolders->isChecked());
|
||||
detailsModeSettings->save();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -266,6 +177,9 @@ void ViewSettingsTab::applySettings()
|
|||
settings.setIconSize(iconSize);
|
||||
settings.setPreviewSize(previewSize);
|
||||
|
||||
const QFont font = m_fontRequester->currentFont();
|
||||
const bool useSystemFont = (m_fontRequester->mode() == DolphinFontRequester::SystemFont);
|
||||
|
||||
settings.setUseSystemFont(useSystemFont);
|
||||
settings.setViewFont(font);
|
||||
|
||||
|
@ -294,21 +208,6 @@ void ViewSettingsTab::loadSettings()
|
|||
m_entireRow->setChecked(DetailsModeSettings::highlightEntireRow());
|
||||
m_iconAndNameOnly->setChecked(!m_entireRow->isChecked());
|
||||
m_expandableFolders->setChecked(DetailsModeSettings::expandableFolders());
|
||||
#ifndef Q_OS_WIN
|
||||
if (DetailsModeSettings::directorySizeCount()) {
|
||||
m_numberOfItems->setChecked(true);
|
||||
m_recursiveDirectorySizeLimit->setEnabled(false);
|
||||
} else {
|
||||
m_sizeOfContents->setChecked(true);
|
||||
m_recursiveDirectorySizeLimit->setEnabled(true);
|
||||
}
|
||||
m_recursiveDirectorySizeLimit->setValue(DetailsModeSettings::recursiveDirectorySizeLimit());
|
||||
#endif
|
||||
m_useRelatetiveDates->setChecked(DetailsModeSettings::useShortRelativeDates());
|
||||
m_useShortDates->setChecked(!DetailsModeSettings::useShortRelativeDates());
|
||||
m_useSymbolicPermissions->setChecked(DetailsModeSettings::usePermissionsFormat() == DetailsModeSettings::EnumUsePermissionsFormat::SymbolicFormat);
|
||||
m_useNumericPermissions->setChecked(DetailsModeSettings::usePermissionsFormat() == DetailsModeSettings::EnumUsePermissionsFormat::NumericFormat);
|
||||
m_useCombinedPermissions->setChecked(DetailsModeSettings::usePermissionsFormat() == DetailsModeSettings::EnumUsePermissionsFormat::CombinedFormat);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -55,14 +55,6 @@ private:
|
|||
QRadioButton *m_entireRow;
|
||||
QRadioButton *m_iconAndNameOnly;
|
||||
QCheckBox *m_expandableFolders;
|
||||
QRadioButton *m_numberOfItems;
|
||||
QRadioButton *m_sizeOfContents;
|
||||
QSpinBox *m_recursiveDirectorySizeLimit;
|
||||
QRadioButton *m_useRelatetiveDates;
|
||||
QRadioButton *m_useShortDates;
|
||||
QRadioButton *m_useSymbolicPermissions;
|
||||
QRadioButton *m_useNumericPermissions;
|
||||
QRadioButton *m_useCombinedPermissions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "dolphinitemlistview.h"
|
||||
|
||||
#include "dolphin_compactmodesettings.h"
|
||||
#include "dolphin_contentdisplaysettings.h"
|
||||
#include "dolphin_detailsmodesettings.h"
|
||||
#include "dolphin_generalsettings.h"
|
||||
#include "dolphin_iconsmodesettings.h"
|
||||
|
@ -81,6 +82,8 @@ void DolphinItemListView::readSettings()
|
|||
CompactModeSettings::self()->load();
|
||||
DetailsModeSettings::self()->load();
|
||||
|
||||
ContentDisplaySettings::self()->load();
|
||||
|
||||
beginTransaction();
|
||||
|
||||
setEnabledSelectionToggles(m_selectionTogglesEnabled);
|
||||
|
|
|
@ -225,8 +225,6 @@ public:
|
|||
/** Returns the additional information which should be shown for the items. */
|
||||
QList<QByteArray> visibleRoles() const;
|
||||
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Refreshes the view to get synchronized with the settings (e.g. icons size,
|
||||
* font, ...).
|
||||
|
@ -347,6 +345,9 @@ public:
|
|||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Changes the directory to \a url. If the current directory is equal to
|
||||
* \a url, nothing will be done (use DolphinView::reload() instead).
|
||||
|
|
Loading…
Reference in a new issue