]>
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 item information on hover" ));
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 single items inline" ));
77 m_renameInline
-> setToolTip ( i18n ( "Renaming multiple items is always done with a dialog window." ));
78 topLayout
-> addRow ( QString (), m_renameInline
);
80 m_hideXtrashFiles
= new QCheckBox ( i18nc ( "option:check" , "Also hide backup files while hiding hidden files" ));
82 QMimeType mime
= db
. mimeTypeForName ( QStringLiteral ( "application/x-trash" ));
83 m_hideXtrashFiles
-> setToolTip ( i18nc ( "@info:tooltip %1 are the file patterns for mimetype application/x-trash" ,
84 "Backup files are the files whose mime-type is application/x-trash, patterns: %1 " ,
85 ( mime
. globPatterns (). join ( ", " ))));
86 topLayout
-> addRow ( QString (), m_hideXtrashFiles
);
90 connect ( m_localViewProps
, & QRadioButton :: toggled
, this , & GeneralViewSettingsPage :: changed
);
91 connect ( m_globalViewProps
, & QRadioButton :: toggled
, this , & GeneralViewSettingsPage :: changed
);
93 connect ( m_openArchivesAsFolder
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
94 connect ( m_autoExpandFolders
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
96 connect ( m_showToolTips
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
98 connect ( m_showSelectionToggle
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
99 connect ( m_renameInline
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
100 connect ( m_hideXtrashFiles
, & QCheckBox :: toggled
, this , & GeneralViewSettingsPage :: changed
);
103 GeneralViewSettingsPage ::~ GeneralViewSettingsPage ()
107 void GeneralViewSettingsPage :: applySettings ()
109 GeneralSettings
* settings
= GeneralSettings :: self ();
110 ViewProperties
props ( m_url
); // read current view properties
111 const bool useGlobalViewProps
= m_globalViewProps
-> isChecked ();
112 settings
-> setGlobalViewProps ( useGlobalViewProps
);
114 settings
-> setShowToolTips ( m_showToolTips
-> isChecked ());
116 settings
-> setShowSelectionToggle ( m_showSelectionToggle
-> isChecked ());
117 settings
-> setRenameInline ( m_renameInline
-> isChecked ());
118 settings
-> setHideXTrashFile ( m_hideXtrashFiles
-> isChecked ());
119 settings
-> setAutoExpandFolders ( m_autoExpandFolders
-> isChecked ());
120 settings
-> setBrowseThroughArchives ( m_openArchivesAsFolder
-> isChecked ());
122 if ( useGlobalViewProps
) {
123 // Remember the global view properties by applying the current view properties.
124 // It is important that GeneralSettings::globalViewProps() is set before
125 // the class ViewProperties is used, as ViewProperties uses this setting
126 // to find the destination folder for storing the view properties.
127 ViewProperties
globalProps ( m_url
);
128 globalProps
. setDirProperties ( props
);
132 void GeneralViewSettingsPage :: restoreDefaults ()
134 GeneralSettings
* settings
= GeneralSettings :: self ();
135 settings
-> useDefaults ( true );
137 settings
-> useDefaults ( false );
140 void GeneralViewSettingsPage :: loadSettings ()
142 const bool useGlobalViewProps
= GeneralSettings :: globalViewProps ();
143 m_openArchivesAsFolder
-> setChecked ( GeneralSettings :: browseThroughArchives ());
144 m_autoExpandFolders
-> setChecked ( GeneralSettings :: autoExpandFolders ());
146 m_showToolTips
-> setChecked ( GeneralSettings :: showToolTips ());
148 m_showSelectionToggle
-> setChecked ( GeneralSettings :: showSelectionToggle ());
149 m_renameInline
-> setChecked ( GeneralSettings :: renameInline ());
150 m_hideXtrashFiles
-> setChecked ( GeneralSettings :: hideXTrashFile ());
152 m_localViewProps
-> setChecked (! useGlobalViewProps
);
153 m_globalViewProps
-> setChecked ( useGlobalViewProps
);
156 #include "moc_generalviewsettingspage.cpp"