KVIrc 5.2.6
Developer APIs
KviOptions.cpp File Reference
#include "KviOptions.h"
#include "kvi_confignames.h"
#include "kvi_defaults.h"
#include "kvi_out.h"
#include "kvi_settings.h"
#include "KviApplication.h"
#include "KviConfigurationFile.h"
#include "KviControlCodes.h"
#include "KviFileUtils.h"
#include "KviIconManager.h"
#include "KviInternalCommand.h"
#include "KviLocale.h"
#include "KviMainWindow.h"
#include "KviStringConversion.h"
#include "KviTheme.h"
#include "KviWindow.h"
#include <QDir>
#include <QMessageBox>
#include <QStringList>

Namespaces

namespace  KviTheme
 

Macros

#define _KVI_OPTIONS_CPP_
 
#define BOOL_OPTION(_txt, _val, _flags)
 
#define COLOR_OPTION(_name, _red, _green, _blue, _alpha, _flags)
 
#define FONT_OPTION(_name, _face, _size, _flags)
 
#define GET_OPTION_STRING(__numOpt, __table, __prefix, __prefixLen)
 
#define IC_COLOR_OPTION(_num, _red, _green, _blue)
 
#define LIST_OPTIONS(__txt, __num, __table)
 
#define MIRC_COLOR_OPTION(_num, _red, _green, _blue)
 
#define MSGTYPE_OPTION(_name, _text, _icon, _levl)
 
#define MSGTYPE_OPTION_SPEC(_name, _text, _icon, _fore, _back, _levl)
 
#define PIXMAP_OPTION(_name, _flags)
 
#define READ_ALL_OPTIONS(_num, _table, _readFnc)
 
#define READ_OPTIONS(_num, _table, _readFnc)
 
#define READ_OPTIONS(_num, _table, _readFnc)
 
#define RECT_OPTION(_txt, _val, _flags)
 
#define RUN_THE_BROWSER   "run xdg-open $0"
 
#define SET_OPTION_VALUE(__numOpt, __table, __prefix, __prefixLen)
 
#define STRING_OPTION(_txt, _val, _flags)
 
#define STRINGLIST_OPTION(_txt, _flags)
 
#define STRINGLIST_OPTION_WITHDEFAULT(_txt, _flags, _def)
 
#define UINT_OPTION(_name, _value, _flags)
 
#define WRITE_OPTIONS(_num, _table)
 
#define WRITE_OPTIONS(_num, _table)
 

Functions

bool KviTheme::apply (const QString &szThemeDir, KviThemeInfo::Location eLocation, KviThemeInfo &buffer)
 
static void config_set_section (int flag, KviConfigurationFile *cfg)
 
bool KviTheme::save (KviThemeInfo &options, bool bSaveIcons)
 

Variables

KviBoolOption g_boolOptionsTable [KVI_NUM_BOOL_OPTIONS]
 
KviColorOption g_colorOptionsTable [KVI_NUM_COLOR_OPTIONS]
 
KviFontOption g_fontOptionsTable [KVI_NUM_FONT_OPTIONS]
 
KviColorOption g_iccolorOptionsTable [KVI_NUM_ICCOLOR_OPTIONS]
 
KVIRC_API int g_iIdentDaemonRunningUsers
 
KviColorOption g_mirccolorOptionsTable [KVI_NUM_MIRCCOLOR_OPTIONS]
 
KviMessageTypeSettingsOption g_msgtypeOptionsTable [KVI_NUM_MSGTYPE_OPTIONS]
 
KviPixmapOption g_pixmapOptionsTable [KVI_NUM_PIXMAP_OPTIONS]
 
KviRectOption g_rectOptionsTable [KVI_NUM_RECT_OPTIONS]
 
KviStringListOption g_stringlistOptionsTable [KVI_NUM_STRINGLIST_OPTIONS]
 
KviStringOption g_stringOptionsTable [KVI_NUM_STRING_OPTIONS]
 
KviUIntOption g_uintOptionsTable [KVI_NUM_UINT_OPTIONS]
 
static const char * options_section_table [KVI_NUM_OPTION_SECT_FLAGS]
 

Macro Definition Documentation

◆ _KVI_OPTIONS_CPP_

#define _KVI_OPTIONS_CPP_

◆ BOOL_OPTION

#define BOOL_OPTION ( _txt,
_val,
_flags )
Value:
KviBoolOption(KVI_BOOL_OPTIONS_PREFIX _txt, _val, _flags)
#define KVI_BOOL_OPTIONS_PREFIX
Definition KviOptions.h:88

◆ COLOR_OPTION

#define COLOR_OPTION ( _name,
_red,
_green,
_blue,
_alpha,
_flags )
Value:
KviColorOption(KVI_COLOR_OPTIONS_PREFIX _name, \
QColor(_red, _green, _blue, _alpha), \
_flags | KviOption_resetUpdateGui | KviOption_groupTheme | KviOption_resetUpdatePseudoTransparency)
#define KVI_COLOR_OPTIONS_PREFIX
Definition KviOptions.h:445

◆ FONT_OPTION

#define FONT_OPTION ( _name,
_face,
_size,
_flags )
Value:
KviFontOption( \
QFont(_face, _size), \
_flags | KviOption_groupTheme)
#define KVI_FONT_OPTIONS_PREFIX
Definition KviOptions.h:615

◆ GET_OPTION_STRING

#define GET_OPTION_STRING ( __numOpt,
__table,
__prefix,
__prefixLen )
Value:
if(KviQString::equalCIN(optName, __prefix, __prefixLen)) \
{ \
for(int i = 0; i < __numOpt; i++) \
{ \
if(KviQString::equalCI(optName, __table[i].name)) \
{ \
KviStringConversion::toString(__table[i].option, buffer); \
return true; \
} \
} \
return false; \
}
#define i
Definition detector.cpp:74
bool equalCI(const QString &sz1, const QString &sz2)
Compares two strings with case insensitive.
Definition KviQString.cpp:283
bool equalCIN(const QString &sz1, const QString &sz2, unsigned int uLen)
Compares two strings with case insensitive up to N chars.
Definition KviQString.cpp:84

Referenced by KviApplication::getOptionString().

◆ IC_COLOR_OPTION

#define IC_COLOR_OPTION ( _num,
_red,
_green,
_blue )
Value:
KviColorOption( \
QColor(_red, _green, _blue), \
KviOption_sectFlagWindowList | KviOption_resetUpdateGui | KviOption_groupTheme)
#define KVI_ICCOLOR_OPTIONS_PREFIX
Definition KviOptions.h:630

◆ LIST_OPTIONS

#define LIST_OPTIONS ( __txt,
__num,
__table )
Value:
for(i = 0; i < __num; i++) \
wnd->outputNoFmt(KVI_OUT_SYSTEMMESSAGE, __table[i].name);
#define KVI_OUT_SYSTEMMESSAGE
Definition kvi_out.h:42
@ Bold
Definition KviControlCodes.h:153

Referenced by KviApplication::listAvailableOptions().

◆ MIRC_COLOR_OPTION

#define MIRC_COLOR_OPTION ( _num,
_red,
_green,
_blue )
Value:
KviColorOption(KVI_MIRCCOLOR_OPTIONS_PREFIX _num, QColor(_red, _green, _blue), \
KviOption_sectFlagMircColor | KviOption_resetUpdateGui | KviOption_groupTheme)
#define KVI_MIRCCOLOR_OPTIONS_PREFIX
Definition KviOptions.h:641

◆ MSGTYPE_OPTION

#define MSGTYPE_OPTION ( _name,
_text,
_icon,
_levl )
Value:
KviMessageTypeSettingsOption( \
KviOption_sectFlagMsgType | KviOption_groupTheme)
#define KVI_MSGTYPE_OPTIONS_PREFIX
Definition KviOptions.h:636
Definition KviMessageTypeSettings.h:47
@ Transparent
Definition KviControlCodes.h:142
@ Black
Definition KviControlCodes.h:127

◆ MSGTYPE_OPTION_SPEC

#define MSGTYPE_OPTION_SPEC ( _name,
_text,
_icon,
_fore,
_back,
_levl )
Value:
KviMessageTypeSettingsOption( \
KviMessageTypeSettings(_text, _icon, _fore, _back, true, _levl), \
KviOption_sectFlagMsgType | KviOption_groupTheme)

◆ PIXMAP_OPTION

#define PIXMAP_OPTION ( _name,
_flags )
Value:
KviPixmapOption( \
KviPixmap(), \
_flags | KviOption_resetUpdateGui)
#define KVI_PIXMAP_OPTIONS_PREFIX
Definition KviOptions.h:500
Definition KviPixmap.h:35

◆ READ_ALL_OPTIONS

#define READ_ALL_OPTIONS ( _num,
_table,
_readFnc )
Value:
for(i = 0; i < _num; i++) \
{ \
if(cfg.hasKey(_table[i].name)) \
{ \
iResetFlags |= (_table[i].flags & KviOption_resetMask); \
_table[i].option = cfg._readFnc(_table[i].name, _table[i].option); \
} \
}

Referenced by KviTheme::apply().

◆ READ_OPTIONS [1/2]

#define READ_OPTIONS ( _num,
_table,
_readFnc )
Value:
for(i = 0; i < _num; i++) \
{ \
config_set_section(_table[i].flags, &cfg); \
_table[i].option = cfg._readFnc(_table[i].name, _table[i].option); \
}

Referenced by KviTheme::apply(), and KviApplication::loadOptions().

◆ READ_OPTIONS [2/2]

#define READ_OPTIONS ( _num,
_table,
_readFnc )
Value:
for(i = 0; i < _num; i++) \
{ \
if(_table[i].flags & KviOption_groupTheme) \
{ \
if(cfg.hasKey(_table[i].name)) \
{ \
iResetFlags |= (_table[i].flags & KviOption_resetMask); \
_table[i].option = cfg._readFnc(_table[i].name, _table[i].option); \
} \
} \
}

◆ RECT_OPTION

#define RECT_OPTION ( _txt,
_val,
_flags )
Value:
KviRectOption(KVI_RECT_OPTIONS_PREFIX _txt, _val, _flags)
#define KVI_RECT_OPTIONS_PREFIX
Definition KviOptions.h:77

◆ RUN_THE_BROWSER

#define RUN_THE_BROWSER   "run xdg-open $0"

◆ SET_OPTION_VALUE

#define SET_OPTION_VALUE ( __numOpt,
__table,
__prefix,
__prefixLen )
Value:
if(KviQString::equalCIN(optName, __prefix, __prefixLen)) \
{ \
for(int i = 0; i < __numOpt; i++) \
{ \
if(KviQString::equalCI(optName, __table[i].name)) \
{ \
if(!KviStringConversion::fromString(value, __table[i].option)) \
return false; \
optionResetUpdate(__table[i].flags); \
return true; \
} \
} \
return false; \
}
bool fromString(const QString &szValue, bool &bBuffer)
Definition KviStringConversion.cpp:114

Referenced by KviApplication::setCommonOptionValue().

◆ STRING_OPTION

#define STRING_OPTION ( _txt,
_val,
_flags )
Value:
KviStringOption(KVI_STRING_OPTIONS_PREFIX _txt, _val, _flags)
#define KVI_STRING_OPTIONS_PREFIX
Definition KviOptions.h:363

◆ STRINGLIST_OPTION

#define STRINGLIST_OPTION ( _txt,
_flags )
Value:
KviStringListOption(KVI_STRINGLIST_OPTIONS_PREFIX _txt, QStringList(), _flags)
#define KVI_STRINGLIST_OPTIONS_PREFIX
Definition KviOptions.h:430

◆ STRINGLIST_OPTION_WITHDEFAULT

#define STRINGLIST_OPTION_WITHDEFAULT ( _txt,
_flags,
_def )
Value:
KviStringListOption(KVI_STRINGLIST_OPTIONS_PREFIX _txt, QStringList(_def), _flags)

◆ UINT_OPTION

#define UINT_OPTION ( _name,
_value,
_flags )
Value:
KviUIntOption( \
_value, \
_flags)
#define KVI_UINT_OPTIONS_PREFIX
Definition KviOptions.h:515

◆ WRITE_OPTIONS [1/2]

#define WRITE_OPTIONS ( _num,
_table )
Value:
for(i = 0; i < _num; i++) \
{ \
config_set_section(_table[i].flags, &cfg); \
cfg.writeEntry(_table[i].name, _table[i].option); \
}

Referenced by KviTheme::save(), and KviApplication::saveOptions().

◆ WRITE_OPTIONS [2/2]

#define WRITE_OPTIONS ( _num,
_table )
Value:
for(i = 0; i < _num; i++) \
{ \
if(_table[i].flags & KviOption_groupTheme) \
cfg.writeEntry(_table[i].name, _table[i].option); \
}

Function Documentation

◆ config_set_section()

static void config_set_section ( int flag,
KviConfigurationFile * cfg )
static

Variable Documentation

◆ g_boolOptionsTable

◆ g_colorOptionsTable

◆ g_fontOptionsTable

◆ g_iccolorOptionsTable

KviColorOption g_iccolorOptionsTable[KVI_NUM_ICCOLOR_OPTIONS]
Initial value:
= {
IC_COLOR_OPTION("0", 250, 250, 0),
IC_COLOR_OPTION("1", 0, 0, 0),
IC_COLOR_OPTION("2", 0, 0, 200),
IC_COLOR_OPTION("3", 200, 0, 0),
IC_COLOR_OPTION("4", 255, 255, 255),
IC_COLOR_OPTION("5", 0, 150, 190),
IC_COLOR_OPTION("6", 0, 130, 0),
}
#define IC_COLOR_OPTION(_num, _red, _green, _blue)
Definition KviOptions.cpp:521

Referenced by KviTheme::apply(), KviApplication::getOptionString(), KviApplication::listAvailableOptions(), KviApplication::loadOptions(), KviTheme::save(), KviApplication::saveOptions(), and KviApplication::setCommonOptionValue().

◆ g_iIdentDaemonRunningUsers

KVIRC_API int g_iIdentDaemonRunningUsers
extern

◆ g_mirccolorOptionsTable

KviColorOption g_mirccolorOptionsTable[KVI_NUM_MIRCCOLOR_OPTIONS]
Initial value:
= {
MIRC_COLOR_OPTION("0", 255, 255, 255),
MIRC_COLOR_OPTION("1", 0, 0, 0),
MIRC_COLOR_OPTION("2", 0, 0, 140),
MIRC_COLOR_OPTION("3", 0, 100, 0),
MIRC_COLOR_OPTION("4", 230, 0, 0),
MIRC_COLOR_OPTION("5", 150, 0, 0),
MIRC_COLOR_OPTION("6", 80, 0, 80),
MIRC_COLOR_OPTION("7", 255, 90, 0),
MIRC_COLOR_OPTION("8", 255, 255, 0),
MIRC_COLOR_OPTION("9", 0, 255, 0),
MIRC_COLOR_OPTION("10", 0, 150, 180),
MIRC_COLOR_OPTION("11", 170, 170, 255),
MIRC_COLOR_OPTION("12", 15, 15, 255),
MIRC_COLOR_OPTION("13", 200, 0, 200),
MIRC_COLOR_OPTION("14", 80, 80, 80),
}
#define MIRC_COLOR_OPTION(_num, _red, _green, _blue)
Definition KviOptions.cpp:441

Referenced by KviTheme::apply(), KviApplication::getOptionString(), KviApplication::listAvailableOptions(), KviApplication::loadOptions(), KviTheme::save(), KviApplication::saveOptions(), and KviApplication::setCommonOptionValue().

◆ g_msgtypeOptionsTable

◆ g_pixmapOptionsTable

KviPixmapOption g_pixmapOptionsTable[KVI_NUM_PIXMAP_OPTIONS]
Initial value:
= {
PIXMAP_OPTION("IrcViewBackground", KviOption_sectFlagIrcView | KviOption_groupTheme),
PIXMAP_OPTION("InputBackground", KviOption_sectFlagInput | KviOption_groupTheme),
PIXMAP_OPTION("UserListViewBackground", KviOption_sectFlagUserListView | KviOption_groupTheme),
PIXMAP_OPTION("LabelBackground", KviOption_sectFlagLabel | KviOption_groupTheme),
PIXMAP_OPTION("MyAvatar", KviOption_sectFlagUser),
PIXMAP_OPTION("IrcToolBarAppletBackground", KviOption_sectFlagIrcToolBar | KviOption_groupTheme),
PIXMAP_OPTION("TreeWindowListBackground", KviOption_sectFlagWindowList | KviOption_groupTheme),
PIXMAP_OPTION("GlobalTransparencyBackground", KviOption_sectFlagGui | KviOption_resetUpdatePseudoTransparency | KviOption_groupTheme),
}
#define PIXMAP_OPTION(_name, _flags)
Definition KviOptions.cpp:538

Referenced by KviOptionsWidget::addPixmapSelector(), KviTheme::apply(), KviApplication::getOptionString(), KviApplication::listAvailableOptions(), KviApplication::loadOptions(), KviTheme::save(), KviApplication::saveOptions(), and KviApplication::setOptionValue().

◆ g_rectOptionsTable

KviRectOption g_rectOptionsTable[KVI_NUM_RECT_OPTIONS]
Initial value:
= {
RECT_OPTION("FrameGeometry", QRect(0, 0, 10, 10), KviOption_sectFlagGeometry),
RECT_OPTION("GeneralOptionsDialogGeometry", QRect(50, 50, 600, 450), KviOption_sectFlagGeometry),
}
#define RECT_OPTION(_txt, _val, _flags)
Definition KviOptions.cpp:52

Referenced by KviTheme::apply(), KviApplication::getOptionString(), KviApplication::listAvailableOptions(), KviApplication::loadOptions(), KviTheme::save(), KviApplication::saveOptions(), and KviApplication::setCommonOptionValue().

◆ g_stringlistOptionsTable

KviStringListOption g_stringlistOptionsTable[KVI_NUM_STRINGLIST_OPTIONS]
Initial value:
= {
STRINGLIST_OPTION("HighlightWords", KviOption_sectFlagIrcView),
STRINGLIST_OPTION("SpamWords", KviOption_sectFlagAntiSpam),
STRINGLIST_OPTION_WITHDEFAULT("RecentChannels", KviOption_sectFlagRecent, "#kvirc" KVI_RECENT_CHANNELS_SEPARATOR "LiberaChat"),
STRINGLIST_OPTION("RecentServers", KviOption_sectFlagRecent),
STRINGLIST_OPTION("RecentNicknames", KviOption_sectFlagRecent),
STRINGLIST_OPTION("ModuleExtensionToolbars", KviOption_sectFlagFrame),
STRINGLIST_OPTION("ImageSearchPaths", KviOption_sectFlagFrame | KviOption_encodePath),
STRINGLIST_OPTION("RecentIrcUrls", KviOption_sectFlagRecent),
}
#define STRINGLIST_OPTION_WITHDEFAULT(_txt, _flags, _def)
Definition KviOptions.cpp:426
#define STRINGLIST_OPTION(_txt, _flags)
Definition KviOptions.cpp:423
#define KVI_RECENT_CHANNELS_SEPARATOR
Definition KviOptions.h:701

Referenced by KviOptionsWidget::addStringListSelector(), KviTheme::apply(), KviApplication::getOptionString(), KviApplication::listAvailableOptions(), KviApplication::loadOptions(), KviTheme::save(), KviApplication::saveOptions(), and KviApplication::setCommonOptionValue().

◆ g_stringOptionsTable

◆ g_uintOptionsTable

◆ options_section_table

const char* options_section_table[KVI_NUM_OPTION_SECT_FLAGS]
static
Initial value:
= {
"None", "Frame", "Mdi", "Windows",
"WindowList", "IrcView", "MsgType", "MircColor",
"Input", "UserParser", "Connection", "IrcSocket",
"User", "UserListView", "Label", "Modules",
"Ctcp", "Dcc", "Gui", "IrcToolBar",
"Logging", "AntiSpam", "Avatar", "Url",
"Recent", "Geometry", "Notifier"
}

Referenced by config_set_section().