]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/viewmodes/generalviewsettingspage.cpp
2 * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Patrice Tremblay
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #include "generalviewsettingspage.h"
8 #include "dolphin_generalsettings.h"
9 #include "dolphinmainwindow.h"
10 #include "views/viewproperties.h"
12 #include <KLocalizedString>
14 #include <QButtonGroup>
16 #include <QFontDatabase>
17 #include <QFormLayout>
19 #include <QMimeDatabase>
20 #include <QVBoxLayout>
22 GeneralViewSettingsPage :: GeneralViewSettingsPage ( const QUrl
& url
, QWidget
* parent
)
23 : SettingsPageBase ( parent
)
26 QFormLayout
* topLayout
= new QFormLayout ( this );
29 m_globalViewProps
= new QRadioButton ( i18nc ( "@option:radio" , "Use common display style for all folders" ));
30 // i18n: The information in this sentence contradicts the preceding sentence. That's what the word "still" is communicating.
31 // The previous sentence is "Use common display style for all folders".
32 QLabel
* globalViewPropsLabel
= new QLabel ( i18nc ( "@info" , "Some special views like search, recent files, or trash will still use a custom display style." ));
33 globalViewPropsLabel
-> setFont ( QFontDatabase :: systemFont ( QFontDatabase :: SmallestReadableFont
));
34 globalViewPropsLabel
-> setWordWrap ( true );
35 globalViewPropsLabel
-> setSizePolicy ( QSizePolicy :: Expanding
, QSizePolicy :: Preferred
);
37 m_localViewProps
= new QRadioButton ( i18nc ( "@option:radio" , "Remember display style for each folder" ));
38 QLabel
* localViewPropsLabel
= new QLabel ( i18nc ( "@info" , "Dolphin will create a hidden .directory file in each folder you change view properties for." ));
39 localViewPropsLabel
-> setFont ( QFontDatabase :: systemFont ( QFontDatabase :: SmallestReadableFont
));
40 localViewPropsLabel
-> setWordWrap ( true );
41 localViewPropsLabel
-> setSizePolicy ( QSizePolicy :: Expanding
, QSizePolicy :: Preferred
);
43 QButtonGroup
* viewGroup
= new QButtonGroup ( this );
44 viewGroup
-> addButton ( m_globalViewProps
);
45 viewGroup
-> addButton ( m_localViewProps
);
46 topLayout
-> addRow ( i18nc ( "@title:group" , "Display style: " ), m_globalViewProps
);
47 topLayout
-> addRow ( QString (), globalViewPropsLabel
);
48 topLayout
-> addRow ( QString (), m_localViewProps
);
49 topLayout
-> addRow ( QString (), localViewPropsLabel
);
51 topLayout
-> addItem ( new QSpacerItem ( 0 , Dolphin :: VERTICAL_SPACER_HEIGHT
, QSizePolicy :: Fixed
, QSizePolicy :: Fixed
));
54 m_openArchivesAsFolder
= new QCheckBox ( i18nc ( "@option:check" , "Open archives as folder" ));
55 m_autoExpandFolders
= new QCheckBox ( i18nc ( "option:check" , "Open folders during drag operations" ));
56 topLayout
-> addRow ( i18nc ( "@title:group" , "Browsing: " ), m_openArchivesAsFolder
);
57 topLayout
-> addRow ( QString (), m_autoExpandFolders
);
59 topLayout
-> addItem ( new QSpacerItem ( 0 , Dolphin :: VERTICAL_SPACER_HEIGHT
, QSizePolicy :: Fixed
, QSizePolicy :: Fixed
));
63 m_showToolTips
= new QCheckBox ( i18nc ( "@option:check" , "Show tooltips" ));
64 topLayout
-> addRow ( i18nc ( "@title:group" , "Miscellaneous: " ), m_showToolTips
);
67 // 'Show selection marker'
68 m_showSelectionToggle
= new QCheckBox ( i18nc ( "@option:check" , "Show selection marker" ));
70 topLayout
-> addRow ( QString (), m_showSelectionToggle
);
72 topLayout
-> addRow ( i18nc ( "@title:group" , "Miscellaneous: " ), m_showSelectionToggle
);
75 // 'Inline renaming of items'
76 m_renameInline
= new QCheckBox ( i18nc ( "option:check" , "Rename inline" ));
77 topLayout
-> addRow ( QString (), m_renameInline
);
79 m_hideXtrashFiles
= new QCheckBox ( i18nc ( "option:check" , "Also hide backup files while hiding hidden files" ));
81 QMimeType mime
= db
. mimeTypeForName ( QStringLiteral ( "application/x-trash" ));
82 m_hideXtrashFiles
-> setToolTip ( i18nc ( "@info:tooltip %1 are the file patterns for mimetype application/x-trash" ,
83 "Backup files are the files whose mime-type is application/x-trash, patterns: %1 " ,
84 ( mime
. globPatterns (). join ( ", " ))));
85 topLayout
-> addRow ( QString (), m_hideXtrashFiles
);
89 connect ( m_localViewProps
, & QRadioButton :: toggled
, this , & GeneralViewSettingsPage :: changed
);
90 connect ( m_globalViewProps
, & QRadioButton :: toggled
, this , & GeneralViewSettingsPage :: changed
);
92 connect ( m_openArchivesAsFolder
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
93 connect ( m_autoExpandFolders
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
95 connect ( m_showToolTips
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
97 connect ( m_showSelectionToggle
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
98 connect ( m_renameInline
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
99 connect ( m_hideXtrashFiles
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
102 GeneralViewSettingsPage ::~ GeneralViewSettingsPage ()
106 void GeneralViewSettingsPage :: applySettings ()
108 GeneralSettings
* settings
= GeneralSettings :: self ();
109 ViewProperties
props ( m_url
); // read current view properties
110 const bool useGlobalViewProps
= m_globalViewProps
-> isChecked ();
111 settings
-> setGlobalViewProps ( useGlobalViewProps
);
113 settings
-> setShowToolTips ( m_showToolTips
-> isChecked ());
115 settings
-> setShowSelectionToggle ( m_showSelectionToggle
-> isChecked ());
116 settings
-> setRenameInline ( m_renameInline
-> isChecked ());
117 settings
-> setHideXTrashFile ( m_hideXtrashFiles
-> isChecked ());
118 settings
-> setAutoExpandFolders ( m_autoExpandFolders
-> isChecked ());
119 settings
-> setBrowseThroughArchives ( m_openArchivesAsFolder
-> isChecked ());
121 if ( useGlobalViewProps
) {
122 // Remember the global view properties by applying the current view properties.
123 // It is important that GeneralSettings::globalViewProps() is set before
124 // the class ViewProperties is used, as ViewProperties uses this setting
125 // to find the destination folder for storing the view properties.
126 ViewProperties
globalProps ( m_url
);
127 globalProps
. setDirProperties ( props
);
131 void GeneralViewSettingsPage :: restoreDefaults ()
133 GeneralSettings
* settings
= GeneralSettings :: self ();
134 settings
-> useDefaults ( true );
136 settings
-> useDefaults ( false );
139 void GeneralViewSettingsPage :: loadSettings ()
141 const bool useGlobalViewProps
= GeneralSettings :: globalViewProps ();
142 m_openArchivesAsFolder
-> setChecked ( GeneralSettings :: browseThroughArchives ());
143 m_autoExpandFolders
-> setChecked ( GeneralSettings :: autoExpandFolders ());
145 m_showToolTips
-> setChecked ( GeneralSettings :: showToolTips ());
147 m_showSelectionToggle
-> setChecked ( GeneralSettings :: showSelectionToggle ());
148 m_renameInline
-> setChecked ( GeneralSettings :: renameInline ());
149 m_hideXtrashFiles
-> setChecked ( GeneralSettings :: hideXTrashFile ());
151 m_localViewProps
-> setChecked (! useGlobalViewProps
);
152 m_globalViewProps
-> setChecked ( useGlobalViewProps
);
155 #include "moc_generalviewsettingspage.cpp"