Moved konqsettings here, so that kdesktop and koqy can use it,

as well as the defaults.
Improved konqsettings to handle 3 static instances (html/fm/kdestop).

svn path=/trunk/kdebase/libkonq/; revision=30091
This commit is contained in:
David Faure 1999-10-04 20:36:48 +00:00
parent dbe9258cfd
commit 5c7be3ba57
4 changed files with 329 additions and 5 deletions

View file

@ -24,18 +24,17 @@ libkonq_la_LIBADD = -lkded $(LIB_KFILE) -lkpartsui -lkparts
libkonq_la_SOURCES = kbookmarkmenu.cc kbookmark.cc knewmenu.cc kpopupmenu.cc \
kpropsdlg.cc \
kdirlister.cc kfileitem.cc kfileivi.cc qiconview.cpp qiconview_hack.cc
# kdirlister.cc kfileitem.cc kiconcontainer.cc kicondrag.cc kfileivi.cc
kdirlister.cc kfileitem.cc kfileivi.cc konqsettings.cc \
qiconview.cpp qiconview_hack.cc
METASOURCES = kbookmark.moc kbookmarkmenu.moc knewmenu.moc kpopupmenu.moc \
kpropsdlg.moc \
kdirlister.moc kfileivi.moc
# kdirlister.moc kiconcontainer.moc kicondrag.moc
include_HEADERS = kbookmark.h kbookmarkmenu.h knewmenu.h kpopupmenu.h \
kpropsdlg.h \
kdirlister.h kfileitem.h kfileivi.h qiconview.h
# kdirlister.h kfileitem.h kiconcontainer.h kicondrag.h kfileivi.h
kdirlister.h kfileitem.h kfileivi.h konqdefaults.h konqsettings.h\
qiconview.h
messages:
$(XGETTEXT) -C -ki18n -x $(includedir)/kde.pot *.cc *.h && mv messages.po ../po/libkonq.pot

76
lib/konq/konqdefaults.h Normal file
View file

@ -0,0 +1,76 @@
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// Default values for konqueror/kdesktop settings
// This file is used by konqueror and kdesktop, and will be used by kcmkonq,
// to share the same defaults
#if 0 // OLD KFM STUFF - we might want to do this also in konq ?
#define ID_STRING_OPEN 1 /* Open */
#define ID_STRING_CD 2 /* Cd */
#define ID_STRING_NEW_VIEW 3 /* New View */
#define ID_STRING_COPY 4 /* Copy */
#define ID_STRING_DELETE 5 /* Delete */
#define ID_STRING_MOVE_TO_TRASH 6 /* Move to Trash */
#define ID_STRING_PASTE 7 /* Paste */
#define ID_STRING_OPEN_WITH 8 /* Open With */
#define ID_STRING_CUT 9 /* Cut */
#define ID_STRING_MOVE 10 /* Move */
#define ID_STRING_PROP 11 /* Properties */
#define ID_STRING_LINK 12 /* Link */
#define ID_STRING_TRASH 13 /* Empty Trash Bin*/
#define ID_STRING_ADD_TO_BOOMARKS 14
#define ID_STRING_SAVE_URL_PROPS 15 /* sven */
#define ID_STRING_SHOW_MENUBAR 16 /* sven */
#define ID_STRING_UP 17 /* sven */
#define ID_STRING_BACK 18 /* sven */
#define ID_STRING_FORWARD 19 /* sven */
#endif
// browser/tree window color defaults -- Bernd
#define HTML_DEFAULT_BG_COLOR Qt::white
#define HTML_DEFAULT_LNK_COLOR Qt::blue
#define HTML_DEFAULT_TXT_COLOR Qt::black
#define HTML_DEFAULT_VLNK_COLOR Qt::magenta
// icon spacing defaults
#define DEFAULT_ICON_SPACING 5
// root window icon text transparency default -- stefan@space.twc.de
#define DEFAULT_TRANSPARENT_ICON_TEXT true
// show hidden files on desktop default
#define DEFAULT_SHOW_HIDDEN_ROOT_ICONS false
// lets be modern .. -- Bernd
#define DEFAULT_VIEW_FONT "helvetica"
#define DEFAULT_VIEW_FIXED_FONT "courier"
#define DEFAULT_VIEW_FONT_SIZE 12
// the default size of the main window
#define MAINWINDOW_HEIGHT 360
#define MAINWINDOW_WIDTH 540
// Default terminal for Open Terminal and for 'run in terminal'
#define DEFAULT_TERMINAL "konsole"
// Default editor for viewing HTML source
#define DEFAULT_EDITOR "kedit"
// Default UserAgent string (e.g. Konqueror/2.0)
#define DEFAULT_USERAGENT_STRING QString("Konqueror/")+KDE_VERSION_STRING

119
lib/konq/konqsettings.cc Normal file
View file

@ -0,0 +1,119 @@
/* This file is part of the KDE project
Copyright (C) 1997 David Faure <faure@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "konqsettings.h"
#include "konqdefaults.h"
#include <kconfig.h>
#include <kapp.h>
// We have to handle three instances of this class in the code
// Everything's handled by arrays to avoid code duplication
KonqSettings * KonqSettings::s_pSettings[] = { 0L, 0L, 0L };
static char * s_sGroupName[] = { "KFM HTML Defaults", "KFM HTML Defaults", "KFM HTML Defaults" };
// TODO : update group names to html / fm / desktop when kcmkonq supports it
#define KS_HTML 0
#define KS_FM 1
#define KS_DESKTOP 2
KonqSettings * KonqSettings::getInstance( int nr )
{
if (!s_pSettings[nr])
{
KConfig *config = kapp->getConfig();
KConfigGroupSaver cgs(config, s_sGroupName[nr]);
s_pSettings[nr] = new KonqSettings(config);
}
return s_pSettings[nr];
}
//static
inline KonqSettings * KonqSettings::defaultDesktopSettings()
{
return getInstance( KS_DESKTOP );
}
//static
inline KonqSettings * KonqSettings::defaultFMSettings()
{
return getInstance( KS_FM );
}
//static
inline KonqSettings * KonqSettings::defaultHTMLSettings()
{
return getInstance( KS_HTML );
}
//static
void KonqSettings::reparseConfiguration()
{
KConfig *config = kapp->getConfig();
for (int i = 0 ; i < 3 ; i++ )
{
if (s_pSettings[i])
{
KConfigGroupSaver cgs(config, s_sGroupName[i]);
s_pSettings[i]->init( config );
}
}
}
KonqSettings::KonqSettings( KConfig * config )
{
init( config );
}
void KonqSettings::init( KConfig * config )
{
m_iFontSize = config->readNumEntry( "FontSize", DEFAULT_VIEW_FONT_SIZE );
if ( m_iFontSize < 8 )
m_iFontSize = 8;
else if ( m_iFontSize > 24 )
m_iFontSize = 24;
m_strStdFontName = config->readEntry( "StandardFont" );
if ( m_strStdFontName.isEmpty() )
m_strStdFontName = DEFAULT_VIEW_FONT;
m_strFixedFontName = config->readEntry( "FixedFont" );
if ( m_strFixedFontName.isEmpty() )
m_strFixedFontName = DEFAULT_VIEW_FIXED_FONT;
m_bgColor = config->readColorEntry( "BgColor", &HTML_DEFAULT_BG_COLOR );
m_textColor = config->readColorEntry( "TextColor", &HTML_DEFAULT_TXT_COLOR );
m_linkColor = config->readColorEntry( "LinkColor", &HTML_DEFAULT_LNK_COLOR );
m_vLinkColor = config->readColorEntry( "VLinkColor", &HTML_DEFAULT_VLNK_COLOR);
// Behaviour
KConfigGroupSaver cgs( config, "Behaviour" );
m_bSingleClick = config->readBoolEntry("SingleClick", true);
m_iAutoSelect = config->readNumEntry("AutoSelect", -1);
m_bChangeCursor = config->readBoolEntry( "ChangeCursor", false );
m_underlineLink = config->readBoolEntry( "UnderlineLink", true );
// Other
config->setGroup( "Misc Defaults" ); // group will be restored by cgs anyway
m_bAutoLoadImages = config->readBoolEntry( "AutoLoadImages", true );
}
KonqSettings::~KonqSettings()
{
}

130
lib/konq/konqsettings.h Normal file
View file

@ -0,0 +1,130 @@
/* This file is part of the KDE project
Copyright (C) 1997 David Faure <faure@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __konq_settings_h__
#define __konq_settings_h__
class KConfig;
#include <qcolor.h>
#include <qstring.h>
/** The class KonqSettings holds the general settings for konqueror/kdesktop.
* There is no 'local' (per-URL) instance of it.
* All those settings can only be changed in kcmkonq.
*
* For further customization, we could have one instance for
* all HTML views, one for all FileManager views, and one for the desktop.
* (TODO in kcmkonq/kcmkdesktop, using different groups/files :
* currently KFM HTML Defaults, KFM FM Defaults)
*
* <vapor>
* Or even one for icon view and one for tree view, ...
* But then all that has to be done in kcmkonq as well.
* </vapor>
*/
class KonqSettings
{
protected:
/** @internal
* Constructs a KonqSettings instance from a config file.
* Set the group before calling.
* (done by defaultFMSettings and defaultHTMLSettings)
*/
KonqSettings( KConfig * config );
/** Called by constructor and reparseConfiguration */
void init( KConfig * config );
/** Destructor. Don't delete any instance by yourself. */
virtual ~KonqSettings();
public:
/**
* A static instance of KonqSettings, holding the values for KDesktop
*/
static inline KonqSettings * defaultDesktopSettings();
/**
* A static instance of KonqSettings, holding the values for FileManager
*/
static inline KonqSettings * defaultFMSettings();
/**
* A static instance of KonqSettings, holding the values for HTML
*/
static inline KonqSettings * defaultHTMLSettings();
/**
* Reparse the configuration to update the already-created instances
* TODO : will have to be called on slotConfigure
*/
static void reparseConfiguration();
// Behaviour settings
bool singleClick() { return m_bSingleClick; }
int autoSelect() { return m_iAutoSelect; }
bool changeCursor() { return m_bChangeCursor; }
bool underlineLink() { return m_underlineLink; }
// Font settings
const char* stdFontName() { return m_strStdFontName; }
const char* fixedFontName() { return m_strFixedFontName; }
int fontSize() { return m_iFontSize; }
// Color settings
const QColor& bgColor() { return m_bgColor; }
const QColor& textColor() { return m_textColor; }
const QColor& linkColor() { return m_linkColor; }
const QColor& vLinkColor() { return m_vLinkColor; }
// Autoload images (only means something for HMTL configuration)
bool autoLoadImages() { return m_bAutoLoadImages; }
protected:
// The three instances
static KonqSettings * s_pSettings[3];
static KonqSettings * getInstance( int nr );
bool m_bSingleClick;
int m_iAutoSelect;
bool m_bChangeCursor;
bool m_underlineLink;
QString m_strStdFontName;
QString m_strFixedFontName;
int m_iFontSize;
QColor m_bgColor;
QColor m_textColor;
QColor m_linkColor;
QColor m_vLinkColor;
bool m_bAutoLoadImages;
private:
// There is no default constructor. Use the provided ones.
KonqSettings();
// No copy constructor either. What for ?
KonqSettings( const KonqSettings &);
};
#endif