File indexing completed on 2024-11-10 05:13:56

0001 /*
0002     SPDX-FileCopyrightText: 1998 Michael Kropfberger <michael.kropfberger@gmx.net>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 /*
0007 ** Bug reports and questions can be sent to <kde-devel@kde.org>
0008 */
0009 
0010 #include "stdoption.h"
0011 
0012 #include <KConfigGroup>
0013 #include <KSharedConfig>
0014 
0015 
0016 QString CStdOption::mDefaultFileManager = QStringLiteral( "dolphin %m" );
0017 int CStdOption::mDefaultUpdateFrequency = 60;
0018 
0019 CStdOption::CStdOption()
0020 {
0021     setDefault();
0022 }
0023 
0024 
0025 CStdOption::~CStdOption()
0026 {
0027 }
0028 
0029 
0030 void CStdOption::updateConfiguration()
0031 {
0032     KConfigGroup config(KSharedConfig::openConfig(), QStringLiteral("KDFConfig"));
0033     mFileManager = config.readPathEntry(
0034                        "FileManagerCommand", mDefaultFileManager );
0035     mUpdateFrequency = config.readEntry(
0036                            "UpdateFrequency", mDefaultUpdateFrequency );
0037     mPopupIfFull = config.readEntry(
0038                        "PopupIfFull", true );
0039     mOpenFileManagerOnMount = config.readEntry(
0040                                   "OpenFileMgrOnMount", false );
0041     mUseSystemFileManager = config.readEntry(
0042                        "UseSystemFileMgr", true);
0043 }
0044 
0045 
0046 void CStdOption::writeConfiguration()
0047 {
0048     KConfigGroup config(KSharedConfig::openConfig(), QStringLiteral("KDFConfig"));
0049     config.writeEntry( "UpdateFrequency", mUpdateFrequency );
0050     config.writePathEntry( "FileManagerCommand", mFileManager );
0051     config.writeEntry( "PopupIfFull", mPopupIfFull );
0052     config.writeEntry( "OpenFileMgrOnMount", mOpenFileManagerOnMount );
0053     config.writeEntry( "UseSystemFileMgr", mUseSystemFileManager);
0054     config.sync();
0055 }
0056 
0057 
0058 void CStdOption::writeDefaultFileManager()
0059 {
0060     KConfigGroup config(KSharedConfig::openConfig(), QStringLiteral("KDFConfig"));
0061     config.writePathEntry( "FileManagerCommand", mDefaultFileManager );
0062     config.sync();
0063 }
0064 
0065 
0066 
0067 QString CStdOption::fileManager() const
0068 {
0069     return( mFileManager );
0070 }
0071 
0072 
0073 int CStdOption::updateFrequency() const
0074 {
0075     return( mUpdateFrequency );
0076 }
0077 
0078 
0079 bool CStdOption::popupIfFull() const
0080 {
0081     return( mPopupIfFull );
0082 }
0083 
0084 
0085 bool CStdOption::openFileManager() const
0086 {
0087     return( mOpenFileManagerOnMount );
0088 }
0089 
0090 
0091 bool CStdOption::useSystemFileManager() const
0092 {
0093     return( mUseSystemFileManager );
0094 }
0095 
0096 
0097 void CStdOption::setDefault()
0098 {
0099     mFileManager     = mDefaultFileManager;
0100     mUpdateFrequency = mDefaultUpdateFrequency;
0101     mPopupIfFull     = true;
0102     mOpenFileManagerOnMount = false;
0103     mUseSystemFileManager   = true;
0104 }
0105 
0106 
0107 void CStdOption::setFileManager( const QString &fileManager )
0108 {
0109     mFileManager = fileManager;
0110 }
0111 
0112 
0113 void CStdOption::setUpdateFrequency( int frequency )
0114 {
0115     mUpdateFrequency = frequency;
0116 }
0117 
0118 
0119 void CStdOption::setPopupIfFull( bool popupIfFull )
0120 {
0121     mPopupIfFull = popupIfFull;
0122 }
0123 
0124 
0125 void CStdOption::setOpenFileManager( bool openFileManagerOnMount )
0126 {
0127     mOpenFileManagerOnMount = openFileManagerOnMount;
0128 }
0129 
0130 
0131 void CStdOption::setUseSystemFileManager( bool useSystemFileManager )
0132 {
0133     mUseSystemFileManager = useSystemFileManager;
0134 }
0135