diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:43:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:43:50 +0000 |
commit | ceea23677c61f20759ae986bd77b0d5c4d673edb (patch) | |
tree | 3fcec1702eaf9c14d1dd736e594f5df08dab4001 /kbfxlib/common | |
download | kbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.tar.gz kbfx-ceea23677c61f20759ae986bd77b0d5c4d673edb.zip |
Added old KDE3 version of kbfx
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kbfx@1091549 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbfxlib/common')
-rw-r--r-- | kbfxlib/common/CMakeLists.txt | 48 | ||||
-rw-r--r-- | kbfxlib/common/kbfxconfig.cpp | 862 | ||||
-rw-r--r-- | kbfxlib/common/kbfxconfig.h | 295 | ||||
-rw-r--r-- | kbfxlib/common/kbfxfontchooser.cpp | 79 | ||||
-rw-r--r-- | kbfxlib/common/kbfxfontchooser.h | 70 | ||||
-rw-r--r-- | kbfxlib/common/kbfxkiodownload.cpp | 78 | ||||
-rw-r--r-- | kbfxlib/common/kbfxkiodownload.h | 75 | ||||
-rw-r--r-- | kbfxlib/common/kbfxpixmaplabel.cpp | 92 | ||||
-rw-r--r-- | kbfxlib/common/kbfxpixmaplabel.h | 53 | ||||
-rw-r--r-- | kbfxlib/common/kbfxplasmapixmapprovider.cpp | 146 | ||||
-rw-r--r-- | kbfxlib/common/kbfxplasmapixmapprovider.h | 53 | ||||
-rw-r--r-- | kbfxlib/common/kbfxpushbutton.cpp | 48 | ||||
-rw-r--r-- | kbfxlib/common/kbfxpushbutton.h | 41 | ||||
-rw-r--r-- | kbfxlib/common/kbfxthemesdata.cpp | 90 | ||||
-rw-r--r-- | kbfxlib/common/kbfxthemesdata.h | 52 |
15 files changed, 2082 insertions, 0 deletions
diff --git a/kbfxlib/common/CMakeLists.txt b/kbfxlib/common/CMakeLists.txt new file mode 100644 index 0000000..f318f74 --- /dev/null +++ b/kbfxlib/common/CMakeLists.txt @@ -0,0 +1,48 @@ +SET(libkbfxcommonsrc + kbfxkiodownload.cpp + kbfxpixmaplabel.cpp + kbfxconfig.cpp + kbfxpushbutton.cpp + kbfxthemesdata.cpp + kbfxfontchooser.cpp + kbfxplasmapixmapprovider.cpp + ) + +FILE(GLOB HEADERS *.h) + +IF (NOT USE_KDE4) + KDE3_AUTOMOC(${libkbfxcommonsrc}) + + ADD_LIBRARY(kbfxcommon SHARED ${libkbfxcommonsrc}) + SET_TARGET_PROPERTIES(kbfxcommon + PROPERTIES + COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + # SET_TARGET_PROPERTIES(kbfxcommon PROPERTIES + # SOVERSION ${LIB_MAJOR} + # VERSION ${APPLICATION_VERSION}) + TARGET_LINK_LIBRARIES(kbfxcommon + ${QT_AND_KDECORE_LIBS} + ${KDE3_KIO_LIBRARY} + ${KDE3_UI_LIBRARY} + ${KDE3_KHTML_LIBRARY} + ${M_LIBRARY} + ) + + KDE3_INSTALL_LIBTOOL_FILE(kbfxcommon ${LIB_INSTALL_DIR}) +ELSE (NOT USE_KDE4) + KDE4_AUTOMOC(${libkbfxcommonsrc}) + + KDE4_ADD_LIBRARY(kbfxcommon SHARED ${libkbfxcommonsrc}) + TARGET_LINK_LIBRARIES(kbfxcommon + ${KDE4_KDECORE_LIBS} + ${KDE4_KIO_LIBS} + ${KDE4_KDEUI_LIBS} + ${KDE4_KHTML_LIBS} + ${M_LIBRARY} + ) + + KDE4_INSTALL_LIBTOOL_FILE(kbfxcommon ${LIB_INSTALL_DIR}) +ENDIF (NOT USE_KDE4) + +INSTALL(TARGETS kbfxcommon DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kbfx/common) diff --git a/kbfxlib/common/kbfxconfig.cpp b/kbfxlib/common/kbfxconfig.cpp new file mode 100644 index 0000000..15c2590 --- /dev/null +++ b/kbfxlib/common/kbfxconfig.cpp @@ -0,0 +1,862 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kbfxconfig.h" + +KbfxConfig::KbfxConfig() +{ + /* set default configuration values */ + + /* KBFX internal settings */ + KbfxThemeRcDestination = KGlobal::dirs()->saveLocation ( "data", QString ( "kbfx/themerc/" ), TRUE ); + KbfxRcPath = KGlobal::dirs()->findResource ( "config", "kbfxrc" ); + m_KbfxDeleteOldConf = FALSE; + QString _unspecified = tr2i18n ( "Not Specified" ); + QString path = locate ( "data", "kbfx/skins/default/bg.png" ); + path.remove ( "default/bg.png" ); + + kdDebug() << "Configuration path skins: " + path << endl; + + /* KBFX general settings */ + m_KbfxGeneralVersionDefault = APPLICATION_INTERNAL_VERSION; + m_KbfxThemesVersion = "version-2"; + + m_KbfxHistoryDefault = ""; + + /* theme properties */ + m_SpinxThemeNameDefault = "default"; + m_SpinxThemeBasePathDefault = path; + m_UserSpinxThemeBasePathDefault = path; + + m_KbfxMenuTypeDefault = "spinx"; + m_ToolBarResizeDefault = FALSE; + m_KbfxWatcherDefault = TRUE; + m_KbfxShowOldThemesDefault = FALSE; + + /* user(dude) image properties */ + m_SpinxDudeBlinkDefault = FALSE; + KUser *user = new KUser(); + m_SpinxDudeImageDefault = locate ( "data", user->homeDir () + "/.face.icon" ); + delete user; + + /* tooltip properties */ + m_ToolTipDefault = FALSE; + m_ToolTipAnimationDefault = TRUE; + m_ToolTipTextDefault = "Application menu"; + m_ToolTipAvatarDefault = path + "default/butterfly.png"; + m_SpinxTooltipDudeboxDefault = path + "default/tooltip_dudebox.png"; + m_SpinxTooltipMaskDefault = path + "default/tooltip_mask.png"; + m_SpinxTooltipWindowDefault = path + "default/tooltip_window.png"; + m_SpinxTooltipLogoDefault = path + "default/tooltip_logo.png"; + + /* KBFX plugins */ + m_pluginsLeftDefault="Applications"; + m_pluginsRightDefault="Settings"; + + /* specific theme KBFX settings */ + + /* KBFX panel button */ + m_KbfxNormalButtonPathDefault = path + "default/normal.png"; + m_KbfxHoverButtonPathDefault = path + "default/hover.png"; + m_KbfxPressedButtonPathDefault = path + "default/pressed.png"; + + /* face properties */ + m_facePos_xDefault = -1; + m_facePos_yDefault = -1; + m_faceIconXDefault = 27; + m_faceIconYDefault = 8; + m_faceIconHDefault = 64; + m_faceIconWDefault = 65; + m_userNamePos_xDefault = 130; + m_userNamePos_yDefault = 32; + m_faceBoxHideTextDefault = FALSE; + + /* top bar properties */ + m_topBar_xDefault = 0; + m_topBar_yDefault = 0; + m_topBar_hDefault = 95; + m_topBar_wDefault = 504; //108+190+74; + + /* bottom bar properties */ + m_botBar_xDefault = 0; + m_botBar_yDefault = 428; + m_botBar_hDefault = 38; + m_botBar_wDefault = 504; //108+190+74; + + /* scroll bar properties */ + m_scrollBarBotYDefault = 95; + m_scrollBarBotXDefault = 108; + m_scrollBarTopXDefault = 108; + m_scrollBarTopYDefault = 95; + + /* listbox properties */ + m_listBox_xDefault = 0; + m_listBox_yDefault = m_topBar_hDefault; + m_listBox_wDefault = 132; + m_listBox_hDefault = 275; + + /* search box properties */ + m_searchBox_hDefault = 22; + m_searchBox_wDefault = 240; + m_searchBox_xDefault = 130; + m_searchBox_yDefault = 48; + m_searchBox_staticDefault = TRUE; + + /* item view properties */ + m_itemView_hDefault = 380; + m_itemView_wDefault = 240; + m_itemView_xDefault = 132; + m_itemView_yDefault = m_topBar_hDefault; + + /* toolbar properties */ + m_toolBarButtonNormalSizeDefault = 48; + m_toolBarButtonExpandSizeDefault = 48; + + /* KBFX misc properties */ + m_userMenuHeightDefault = 513; + m_userMenuWidthDefault = 504; + m_startHiddenDefault = FALSE; + m_fadeTimeDefault = 75; + m_noCommentsDefault = FALSE; + m_commentMargineDefault = 66; + m_iconSizeDefault = 32; + + /* set default fonts values */ + m_fontTooltipColorDefault = QColor ( 0,0,0 ); + m_fontTooltipFontDefault = QFont ( "Arial", 8, QFont::Normal ); + m_fontAppNameColorDefault = QColor ( 0,0,0 ); + m_fontAppNameFontDefault = QFont ( "Arial", 8, QFont::Normal ); + m_fontAppCommentColorDefault = QColor ( 128,125,0 ); + m_fontAppCommentFontDefault = QFont ( "Arial", 8, QFont::Normal ); + m_fontIndexColorDefault = QColor ( 0,0,0 ); + m_fontIndexFontDefault = QFont ( "Arial", 8, QFont::Normal ); + m_userNameColorDefault = QColor ( 255,255,255 ); + m_userNameFontDefault = QFont ( "Arial", 10, QFont::Bold ); + m_sepNameColorDefault = QColor ( 0,0,0 ); + m_sepNameFontDefault = QFont ( "Arial", 8, QFont::Bold ); + m_pluginNameColorDefault = QColor ( 0,0,0 ); + m_pluginNameFontDefault = QFont ( "Arial", 8, QFont::Normal ); + m_lineColorDefault = QColor ( 255,220,125 ); + m_fontHoverBoldDefault = FALSE; + + /* set default theme info values */ + m_InfoVersionDefault = _unspecified; + m_InfoAuthorDefault = _unspecified; + m_InfoEmailDefault = _unspecified; + m_InfoUrlDefault = _unspecified; + + read(); +} + +KbfxConfig& ConfigInit() +{ + static KbfxConfig _config; + return _config; +} + +void KbfxConfig::setDefault() +{ + /* set default configuration */ + m_KbfxHistory = m_KbfxHistoryDefault; + + m_SpinxThemeName = m_SpinxThemeNameDefault; + m_SpinxThemeBasePath = m_SpinxThemeBasePathDefault; + m_UserSpinxThemeBasePath = m_UserSpinxThemeBasePathDefault; + + m_KbfxMenuType = m_KbfxMenuTypeDefault; + m_ToolBarResize = m_ToolBarResizeDefault; + m_KbfxWatcher = m_KbfxWatcherDefault; + m_KbfxShowOldThemes = m_KbfxShowOldThemesDefault; + + m_SpinxDudeBlink = m_SpinxDudeBlinkDefault; + m_SpinxDudeImage = m_SpinxDudeImageDefault; + + m_ToolTip = m_ToolTipDefault; + m_ToolTipAnimation = m_ToolTipAnimationDefault; + m_ToolTipText = m_ToolTipTextDefault; + + m_pluginsLeft = m_pluginsLeftDefault; + m_pluginsRight = m_pluginsRightDefault; +} + +void KbfxConfig::setThemeInfoDefault() +{ + /* set default configuration */ + m_InfoVersion = m_InfoVersionDefault; + m_InfoAuthor = m_InfoAuthorDefault; + m_InfoEmail = m_InfoEmailDefault; + m_InfoUrl = m_InfoUrlDefault; +} + +void KbfxConfig::setThemeDefault() +{ + /* set default theme layout configuration */ + m_KbfxNormalButtonPath = m_KbfxNormalButtonPathDefault; + m_KbfxHoverButtonPath = m_KbfxHoverButtonPathDefault; + m_KbfxPressedButtonPath = m_KbfxPressedButtonPathDefault; + + m_ToolTipAvatar = m_ToolTipAvatarDefault; + m_SpinxTooltipDudebox = m_SpinxTooltipDudeboxDefault; + m_SpinxTooltipMask = m_SpinxTooltipMaskDefault; + m_SpinxTooltipWindow = m_SpinxTooltipWindowDefault; + m_SpinxTooltipLogo = m_SpinxTooltipLogoDefault; + + m_facePos_x = m_facePos_xDefault; + m_facePos_y = m_facePos_yDefault; + m_faceIconX = m_faceIconXDefault; + m_faceIconY = m_faceIconYDefault; + m_faceIconH = m_faceIconHDefault; + m_faceIconW = m_faceIconWDefault; + m_userNamePos_x = m_userNamePos_xDefault; + m_userNamePos_y = m_userNamePos_yDefault; + m_faceBoxHideText = m_faceBoxHideTextDefault; + + m_topBar_x = m_topBar_xDefault; + m_topBar_y = m_topBar_yDefault; + m_topBar_h = m_topBar_hDefault; + m_topBar_w = m_topBar_wDefault; + + m_botBar_x = m_botBar_xDefault; + m_botBar_y = m_botBar_yDefault; + m_botBar_h = m_botBar_hDefault; + m_botBar_w = m_botBar_wDefault; + + m_scrollBarBotY = m_scrollBarBotYDefault; + m_scrollBarBotX = m_scrollBarBotXDefault; + m_scrollBarTopX = m_scrollBarTopXDefault; + m_scrollBarTopY = m_scrollBarTopYDefault; + + m_listBox_x = m_listBox_xDefault; + m_listBox_y = m_listBox_yDefault; + m_listBox_w = m_listBox_wDefault; + m_listBox_h = m_listBox_hDefault; + + m_searchBox_h = m_searchBox_hDefault; + m_searchBox_w = m_searchBox_wDefault; + m_searchBox_x = m_searchBox_xDefault; + m_searchBox_y = m_searchBox_yDefault; + m_searchBox_static = m_searchBox_staticDefault; + + m_itemView_h = m_itemView_hDefault; + m_itemView_w = m_itemView_wDefault; + m_itemView_x = m_itemView_xDefault; + m_itemView_y = m_itemView_yDefault; + + m_toolBarButtonNormalSize = m_toolBarButtonNormalSizeDefault; + m_toolBarButtonExpandSize = m_toolBarButtonExpandSizeDefault; + + m_userMenuHeight = m_userMenuHeightDefault; + m_userMenuWidth = m_userMenuWidthDefault; + m_startHidden = m_startHiddenDefault; + m_fadeTime = m_fadeTimeDefault; + m_noComments = m_noCommentsDefault; + m_commentMargine = m_commentMargineDefault; + m_iconSize = m_iconSizeDefault; +} + +void KbfxConfig::setFontsDefault() +{ + /* set default fonts values */ + m_fontTooltipColor = m_fontTooltipColorDefault; + m_fontTooltipFont = m_fontTooltipFontDefault; + m_fontAppNameColor = m_fontAppNameColorDefault; + m_fontAppNameFont = m_fontAppNameFontDefault; + m_fontAppCommentColor = m_fontAppCommentColorDefault; + m_fontAppCommentFont = m_fontAppCommentFontDefault; + m_fontIndexColor = m_fontIndexColorDefault; + m_fontIndexFont = m_fontIndexFontDefault; + m_userNameColor = m_userNameColorDefault; + m_userNameFont = m_userNameFontDefault; + m_sepNameColor = m_sepNameColorDefault; + m_sepNameFont = m_sepNameFontDefault; + m_pluginNameColor = m_pluginNameColorDefault; + m_pluginNameFont = m_pluginNameFontDefault; + m_lineColor = m_lineColorDefault; + m_fontHoverBold = m_fontHoverBoldDefault; +} + +void KbfxConfig::readThemeInfo ( QString &themePath, QString &themeName ) +{ + setThemeInfoDefault(); + + QFileInfo * info_theme = new QFileInfo ( themePath + themeName + "/" + m_KbfxThemesVersion ); + KConfig * infoconfig = 0; + + if ( info_theme->exists() == TRUE ) + { + infoconfig = new KConfig ( info_theme->absFilePath() ); + infoconfig->setGroup ( "ThemeGeneral" ); + m_InfoVersion = infoconfig->readEntry ( "ThemeVersion", m_InfoVersionDefault ); + m_InfoAuthor = infoconfig->readEntry ( "AuthorName", m_InfoAuthorDefault ); + m_InfoEmail = infoconfig->readEntry ( "AuthorEmail", m_InfoEmailDefault ); + m_InfoUrl = infoconfig->readEntry ( "Homepage", m_InfoUrlDefault ); + } + +/* + kdDebug() << " m_InfoVersion: " << m_InfoVersion + << endl << " m_InfoAuthor: " << m_InfoAuthor + << endl << " m_InfoEmail: " << m_InfoEmail + << endl << " m_InfoUrl: " << m_InfoUrl + << endl; +*/ + + delete info_theme; + delete infoconfig; +} + +void KbfxConfig::read() +{ + /* read general configuration */ + KConfigSkeleton *confskel = new KConfigSkeleton ( QString::fromLatin1 ( "kbfxrc" ) ); + + KConfig *conf = confskel->config(); + + QString __default = KGlobal::iconLoader()->iconPath ( "kbfx", ( int ) KIcon::Desktop, FALSE ); + + conf->setGroup ( "KbfxGeneral" ); + m_KbfxGeneralVersion = conf->readNumEntry ( "Version", 0 ); + m_ToolBarResize = conf->readBoolEntry ( "ToolBarResize", m_ToolBarResizeDefault ); + m_KbfxMenuType = conf->readEntry ( "MenuType", m_KbfxMenuTypeDefault ); + m_KbfxWatcher = conf->readBoolEntry ( "KbfxWatcher", m_KbfxWatcherDefault ); + m_KbfxShowOldThemes = conf->readBoolEntry ( "KbfxShowOld", m_KbfxShowOldThemesDefault ); + + conf->setGroup ( "SpinxTheme" ); + m_UserSpinxThemeBasePath = conf->readEntry ( "UserThemePath", m_UserSpinxThemeBasePathDefault ); + /* if a new version use default theme */ + if ( m_KbfxGeneralVersion < m_KbfxGeneralVersionDefault ) + { + m_SpinxThemeName = m_SpinxThemeNameDefault; + m_SpinxThemeBasePath = m_SpinxThemeBasePathDefault; + } + else + { + m_SpinxThemeName = conf->readEntry ( "ThemeName", m_SpinxThemeNameDefault ); + m_SpinxThemeBasePath = conf->readEntry ( "ThemePath", m_SpinxThemeBasePathDefault ); + } + + conf->setGroup ( "UserImage" ); + m_SpinxDudeBlink = conf->readBoolEntry ( "DudeBlink", m_SpinxDudeBlinkDefault ); + + conf->setGroup ( "ToolTip" ); + m_ToolTip = conf->readBoolEntry ( "EnableToolTip", m_ToolTipDefault ); + m_ToolTipAnimation = conf->readBoolEntry ( "AnimatedTooltip", m_ToolTipAnimationDefault ); + m_ToolTipText = conf->readEntry ( "ToolTipText", m_ToolTipTextDefault ); + + conf->setGroup ( "Plugins" ); + m_pluginsLeft = conf->readListEntry ( "LoadedPluginsLeft", m_pluginsLeftDefault ); + m_pluginsRight = conf->readListEntry ( "LoadedPluginsRight", m_pluginsRightDefault ); + + conf->setGroup ( "Runtime" ); + m_KbfxHistory = conf->readEntry ( "History", m_KbfxHistoryDefault ); + + /* + kdDebug() << " m_KbfxGeneralVersion: " << m_KbfxGeneralVersion + << endl << " m_KbfxMenuType: " << m_KbfxMenuType + << endl << " m_KbfxWatcher: " << m_KbfxWatcher + << endl << " m_KbfxShowOldThemes: " << m_KbfxShowOldThemes + << endl << " m_ToolBarResize: " << m_ToolBarResize + << endl << " m_UserSpinxThemeBasePath : " << m_UserSpinxThemeBasePath + << endl << " m_SpinxThemeName: " << m_SpinxThemeName + << endl << " m_SpinxThemeBasePath: " << m_SpinxThemeBasePath + << endl << " m_SpinxDudeBlink: " << m_SpinxDudeBlink + << endl << " m_ToolTip: " << m_ToolTip + << endl << " m_ToolTipAnimation: " << m_ToolTipAnimation + << endl << " m_ToolTipText: " << m_ToolTipText + << endl << " m_KbfxHoverButtonPath: " << m_KbfxHoverButtonPath + << endl << " m_KbfxPressedButtonPath: " << m_KbfxPressedButtonPath + << endl << " m_pluginsLeft: " << m_pluginsLeft + << endl << " m_pluginsRight: " << m_pluginsRight + << endl << " m_KbfxHistory: " << m_KbfxHistory + << endl; + */ + + delete confskel; + + readFontrc ( m_SpinxThemeBasePath, m_SpinxThemeName ); + readThemerc ( m_SpinxThemeBasePath, m_SpinxThemeName ); + + if ( m_KbfxGeneralVersion < m_KbfxGeneralVersionDefault ) + { + m_KbfxGeneralVersion = m_KbfxGeneralVersionDefault; + m_KbfxDeleteOldConf = TRUE; + } +} + +void KbfxConfig::readFontrc ( QString & themePath, QString & themeName, bool user_rc ) +{ + setFontsDefault(); + + /* if a new version use default theme fonts */ + if ( m_KbfxGeneralVersion < m_KbfxGeneralVersionDefault ) + { + themePath = m_SpinxThemeBasePathDefault; + themeName = m_SpinxThemeNameDefault; + } + /* get some font settings from theme file or from theme section */ + QString _abs_path = ""; + QFileInfo * info = new QFileInfo ( themePath + themeName + "/kbfxfontrc" ); + QFileInfo * info_theme = new QFileInfo ( KbfxThemeRcDestination + "/" + themeName + "_fontrc" ); + KConfig * fontconfig = 0; + + /* if theme kbfxfontrc exists, make its configuration as default values - prefer users' configuration */ + if ( info_theme->exists() == TRUE || info->exists() == TRUE ) + { + if ( info_theme->exists() == TRUE && m_KbfxGeneralVersion >= m_KbfxGeneralVersionDefault && user_rc ) + { + _abs_path = info_theme->absFilePath(); + } + else if ( info->exists() == TRUE || m_KbfxGeneralVersion < m_KbfxGeneralVersionDefault ) + { + _abs_path = info->absFilePath(); + } + fontconfig = new KConfig ( _abs_path ); + + fontconfig->setGroup ( "Fonts" ); + m_fontTooltipColor = fontconfig->readColorEntry ( "TooltipText", &m_fontTooltipColorDefault ); + m_fontTooltipFont = fontconfig->readFontEntry ( "TooltipTextFont", &m_fontTooltipFontDefault ); + m_fontAppNameColor = fontconfig->readColorEntry ( "ApplicationText", &m_fontAppNameColorDefault ); + m_fontAppNameFont = fontconfig->readFontEntry ( "ApplicationTextFont", &m_fontAppNameFontDefault ); + m_fontAppCommentColor = fontconfig->readColorEntry ( "CommentText", &m_fontAppCommentColorDefault ); + m_fontAppCommentFont = fontconfig->readFontEntry ( "CommentTextFont", &m_fontAppCommentFontDefault ); + m_fontIndexColor = fontconfig->readColorEntry ( "GroupText", &m_fontIndexColorDefault ); + m_fontIndexFont = fontconfig->readFontEntry ( "GroupTextFont", &m_fontIndexFontDefault ); + m_userNameColor = fontconfig->readColorEntry ( "UserName", &m_userNameColorDefault ); + m_userNameFont = fontconfig->readFontEntry ( "UserNameFont", &m_userNameFontDefault ); + m_sepNameColor = fontconfig->readColorEntry ( "SeparatorColor", &m_sepNameColorDefault ); + m_sepNameFont = fontconfig->readFontEntry ( "SeparatorFont", &m_sepNameFontDefault ); + m_pluginNameColor = fontconfig->readColorEntry ( "PluginColor", &m_pluginNameColorDefault ); + m_pluginNameFont = fontconfig->readFontEntry ( "PluginFont", &m_pluginNameFontDefault ); + m_lineColor = fontconfig->readColorEntry ( "LineColor", &m_lineColorDefault ); + m_fontHoverBold = fontconfig->readBoolEntry ( "HoverBold",m_fontHoverBoldDefault ); + kdDebug() << "Read default font settings for theme: " + << themeName + << " from file: " + << _abs_path + << endl; + } + else + { + kdDebug() << "Left Default Font Values for theme: " + << themeName + << endl; + } + + /* + kdDebug() << "Font Values:" << endl + << m_fontTooltipColor << endl + << m_fontTooltipFont << endl + << m_fontAppNameColor << endl + << m_fontAppNameFont << endl + << m_fontAppCommentColor << endl + << m_fontAppCommentFont << endl + << m_fontIndexColor << endl + << m_fontIndexFont << endl + << m_userNameColor << endl + << m_userNameFont << endl + << m_sepNameColor << endl + << m_sepNameFont << endl + << m_pluginNameColor << endl + << m_pluginNameFont << endl + << m_fontHoverBold << endl + << m_lineColor << endl + ; + */ + + delete info; + delete info_theme; + delete fontconfig; +} + +void KbfxConfig::readThemerc ( QString &themePath, QString &themeName, bool user_rc ) +{ + /* if a new version use default theme layout */ + if ( m_KbfxGeneralVersion < m_KbfxGeneralVersionDefault ) + { + themePath = m_SpinxThemeBasePathDefault; + themeName = m_SpinxThemeNameDefault; + } + + /* load theme's on and off buttons if any */ + KbfxOnImg = QPixmap::QPixmap ( KbfxPlasmaPixmapProvider::PixmapPath ( "on", themePath, themeName ) ); + KbfxOffImg = QPixmap::QPixmap ( KbfxPlasmaPixmapProvider::PixmapPath ( "off", themePath, themeName ) ); + + /* use theme's default dude image if any */ + KConfigSkeleton *confskel = new KConfigSkeleton ( QString::fromLatin1 ( "kbfxrc" ) ); + KConfig *conf = confskel->config(); + QString __default = KGlobal::iconLoader()->iconPath ( "kbfx", ( int ) KIcon::Desktop, FALSE ); + + if ( m_SpinxDudeImageDefault == QString::null || !KStandardDirs::exists ( m_SpinxDudeImageDefault ) ) + { + m_SpinxDudeImageDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "menu_top_image_person", themePath, themeName ); + } + conf->setGroup ( "UserImage" ); + m_SpinxDudeImage = conf->readEntry ( "DudeImage", m_SpinxDudeImageDefault ); + delete confskel; + + /* load theme's default buttons if any */ + m_KbfxNormalButtonPathDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "normal", themePath, themeName ); + m_KbfxHoverButtonPathDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "hover", themePath, themeName ); + m_KbfxPressedButtonPathDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "pressed", themePath, themeName ); + + /* load theme's default tooltip images if any */ + m_ToolTipAvatarDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "butterfly", themePath, themeName ); + m_SpinxTooltipDudeboxDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "tooltip_dudebox", themePath, themeName ); + m_SpinxTooltipMaskDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "tooltip_mask", themePath, themeName ); + m_SpinxTooltipWindowDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "tooltip_window", themePath, themeName ); + m_SpinxTooltipLogoDefault = KbfxPlasmaPixmapProvider::PixmapPath ( "tooltip_logo", themePath, themeName ); + + setThemeDefault(); + + /* get some theme layout settings from theme file or from theme section */ + QString _abs_path = ""; + QFileInfo * info = new QFileInfo ( themePath + themeName + "/kbfxlayoutrc" ); + QFileInfo * info_theme = new QFileInfo ( KbfxThemeRcDestination + "/" + themeName + "_layoutrc" ); + KConfig *layoutconfig = 0; + + /* if theme kbfxlayoutrc exists, make its configuration as default values - prefer users' configuration */ + if ( info_theme->exists() == TRUE || info->exists() == TRUE ) + { + if ( info_theme->exists() == TRUE && m_KbfxGeneralVersion >= m_KbfxGeneralVersionDefault && user_rc ) + { + _abs_path = info_theme->absFilePath(); + } + else if ( info->exists() == TRUE || m_KbfxGeneralVersion < m_KbfxGeneralVersionDefault ) + { + _abs_path = info->absFilePath(); + } + + layoutconfig = new KConfig ( _abs_path ); + + layoutconfig->setGroup ( "KbfxButton" ); + m_KbfxNormalButtonPath = layoutconfig->readEntry ( "Normal", m_KbfxNormalButtonPathDefault ); + m_KbfxHoverButtonPath = layoutconfig->readEntry ( "Hover", m_KbfxHoverButtonPathDefault ); + m_KbfxPressedButtonPath = layoutconfig->readEntry ( "Press", m_KbfxPressedButtonPathDefault ); + m_fadeTime = layoutconfig->readNumEntry ( "FadeTime", m_fadeTimeDefault ); + + layoutconfig->setGroup ( "ToolTip" ); + m_ToolTipAvatar = layoutconfig->readEntry ( "Avatar", m_ToolTipAvatarDefault ); + m_SpinxTooltipDudebox = layoutconfig->readEntry ( "Dudebox", m_SpinxTooltipDudeboxDefault ); + m_SpinxTooltipMask = layoutconfig->readEntry ( "Mask", m_SpinxTooltipMaskDefault ); + m_SpinxTooltipWindow = layoutconfig->readEntry ( "Window", m_SpinxTooltipWindowDefault ); + m_SpinxTooltipLogo = layoutconfig->readEntry ( "Logo", m_SpinxTooltipLogoDefault ); + + layoutconfig->setGroup ( "TopBar" ); + m_facePos_x = layoutconfig->readNumEntry ( "DudeX", m_facePos_xDefault ); + m_facePos_y = layoutconfig->readNumEntry ( "DudeY", m_facePos_yDefault ); + m_faceIconX = layoutconfig->readNumEntry ( "FaceX",m_faceIconXDefault ); + m_faceIconY = layoutconfig->readNumEntry ( "FaceY",m_faceIconYDefault ); + m_faceIconH = layoutconfig->readNumEntry ( "FaceH",m_faceIconHDefault ); + m_faceIconW = layoutconfig->readNumEntry ( "FaceW",m_faceIconWDefault ); + m_userNamePos_x = layoutconfig->readNumEntry ( "UserNameX", m_userNamePos_xDefault ); + m_userNamePos_y = layoutconfig->readNumEntry ( "UserNameY", m_userNamePos_yDefault ); + m_faceBoxHideText= layoutconfig->readBoolEntry ( "DisableUserName", m_faceBoxHideTextDefault ); + m_topBar_h = layoutconfig->readNumEntry ( "Height", m_topBar_hDefault ); + m_topBar_w = layoutconfig->readNumEntry ( "Width", m_topBar_wDefault ); + m_topBar_x = layoutconfig->readNumEntry ( "X", m_topBar_xDefault ); + m_topBar_y = layoutconfig->readNumEntry ( "Y", m_topBar_yDefault ); + + layoutconfig->setGroup ( "BottomBar" ); + m_botBar_h = layoutconfig->readNumEntry ( "Height", m_botBar_hDefault ); + m_botBar_w = layoutconfig->readNumEntry ( "Width", m_botBar_wDefault ); + m_botBar_x = layoutconfig->readNumEntry ( "X", m_botBar_xDefault ); + m_botBar_y = layoutconfig->readNumEntry ( "Y", m_botBar_yDefault ); + + layoutconfig->setGroup ( "Scrollbars" ); + m_scrollBarBotX = layoutconfig->readNumEntry ( "ScrollBarBotX", m_scrollBarBotXDefault ); + m_scrollBarBotY = layoutconfig->readNumEntry ( "ScrollBarBotY", m_scrollBarBotYDefault ); + m_scrollBarTopX = layoutconfig->readNumEntry ( "ScrollBarTopX", m_scrollBarTopXDefault ); + m_scrollBarTopY = layoutconfig->readNumEntry ( "ScrollBarTopY", m_scrollBarTopYDefault ); + + layoutconfig->setGroup ( "ListBox" ); + m_listBox_h = layoutconfig->readNumEntry ( "Height", m_listBox_hDefault ); + m_listBox_w = layoutconfig->readNumEntry ( "Width", m_listBox_wDefault ); + m_listBox_x = layoutconfig->readNumEntry ( "X", m_listBox_xDefault ); + m_listBox_y = layoutconfig->readNumEntry ( "Y", m_listBox_yDefault ); + + layoutconfig->setGroup ( "SearchBox" ); + m_searchBox_h = layoutconfig->readNumEntry ( "Height", m_searchBox_hDefault ); + m_searchBox_w = layoutconfig->readNumEntry ( "Width", m_searchBox_wDefault ); + m_searchBox_x = layoutconfig->readNumEntry ( "X", m_searchBox_xDefault ); + m_searchBox_y = layoutconfig->readNumEntry ( "Y", m_searchBox_yDefault ); + m_searchBox_static = layoutconfig->readBoolEntry ( "FixedPos", m_searchBox_staticDefault ); + + layoutconfig->setGroup ( "ItemView" ); + m_itemView_h = layoutconfig->readNumEntry ( "Height", m_itemView_hDefault ); + m_itemView_w = layoutconfig->readNumEntry ( "Width", m_itemView_wDefault ); + m_itemView_x = layoutconfig->readNumEntry ( "X", m_itemView_xDefault ); + m_itemView_y = layoutconfig->readNumEntry ( "Y", m_itemView_yDefault ); + + layoutconfig->setGroup ( "ToolBar" ); + m_toolBarButtonNormalSize = layoutconfig->readNumEntry ( "ButtonNormalSize", m_toolBarButtonNormalSizeDefault ); + m_toolBarButtonExpandSize = layoutconfig->readNumEntry ( "ButtonPressedSize", m_toolBarButtonExpandSizeDefault ); + + layoutconfig->setGroup ( "MainMenu" ); + m_userMenuHeight = layoutconfig->readNumEntry ( "UserMenuHeight",m_userMenuHeightDefault ); + m_userMenuWidth = layoutconfig->readNumEntry ( "UserMenuWidth",m_userMenuWidthDefault ); + m_startHidden = layoutconfig->readBoolEntry ( "ContractedMenu", m_startHiddenDefault ); + + layoutconfig->setGroup ( "ItemProperties" ); + m_noComments = layoutconfig->readBoolEntry ( "NoComments",m_noCommentsDefault ); + m_commentMargine = layoutconfig->readNumEntry ( "CommentMargin",m_commentMargineDefault ); + m_iconSize = layoutconfig->readNumEntry ( "IconSize",m_iconSizeDefault ); + + kdDebug() << "Read default layout settings for theme: " + << themeName + << " from file: " + << _abs_path + << endl; + } + else + { + kdDebug() << "Left Default Layout Values for theme: " + << themeName + << endl; + } + + /* + kdDebug() << " m_KbfxNormalButtonPath: " << m_KbfxNormalButtonPath + << endl << " m_KbfxHoverButtonPath: " << m_KbfxHoverButtonPath + << endl << " m_KbfxPressedButtonPath: " << m_KbfxPressedButtonPath + << endl << " m_fadeTime: " << m_fadeTime + << endl << " m_SpinxDudeImage: " << m_SpinxDudeImage + << endl << " m_ToolTipAvatar: " << m_ToolTipAvatar + << endl << " m_SpinxTooltipDudebox: " << m_SpinxTooltipDudebox + << endl << " m_SpinxTooltipMask: " << m_SpinxTooltipMask + << endl << " m_SpinxTooltipWindow: " << m_SpinxTooltipWindow + << endl << " m_SpinxTooltipLogo: " << m_SpinxTooltipLogo + << endl << " m_facePos_x: " << m_facePos_x + << endl << " m_facePos_y: " << m_facePos_y + << endl << " m_faceIconX: " << m_faceIconX + << endl << " m_faceIconY: " << m_faceIconY + << endl << " m_faceIconH: " << m_faceIconH + << endl << " m_faceIconW: " << m_faceIconW + << endl << " m_userNamePos_x: " << m_userNamePos_x + << endl << " m_userNamePos_y: " << m_userNamePos_y + << endl << " m_faceBoxHideText: " << m_faceBoxHideText + << endl << " m_topBar_x: " << m_topBar_x + << endl << " m_topBar_y: " << m_topBar_y + << endl << " m_topBar_h: " << m_topBar_h + << endl << " m_topBar_w: " << m_topBar_w + << endl << " m_botBar_x: " << m_botBar_x + << endl << " m_botBar_y: " << m_botBar_y + << endl << " m_botBar_h: " << m_botBar_h + << endl << " m_botBar_w: " << m_botBar_w + << endl << " m_scrollBarBotY: " << m_scrollBarBotY + << endl << " m_scrollBarBotX: " << m_scrollBarBotX + << endl << " m_scrollBarTopX: " << m_scrollBarTopX + << endl << " m_scrollBarTopY: " << m_scrollBarTopY + << endl << " m_listBox_x: " << m_listBox_x + << endl << " m_listBox_y: " << m_listBox_y + << endl << " m_listBox_w: " << m_listBox_w + << endl << " m_listBox_h: " << m_listBox_h + << endl << " m_searchBox_h: " << m_searchBox_h + << endl << " m_searchBox_w: " << m_searchBox_w + << endl << " m_searchBox_x: " << m_searchBox_x + << endl << " m_searchBox_y: " << m_searchBox_y + << endl << " m_searchBox_static: " << m_searchBox_static + << endl << " m_itemView_h: " << m_itemView_h + << endl << " m_itemView_w: " << m_itemView_w + << endl << " m_itemView_x: " << m_itemView_x + << endl << " m_itemView_y: " << m_itemView_y + << endl << " m_toolBarButtonNormalSize: " << m_toolBarButtonNormalSize + << endl << " m_toolBarButtonExpandSize: " << m_toolBarButtonExpandSize + << endl << " m_userMenuHeight: " << m_userMenuHeight + << endl << " m_userMenuWidth: " << m_userMenuHeight + << endl << " m_startHidden: " << m_startHidden + << endl << " m_noComments: " << m_noComments + << endl << " m_commentMargine: " << m_commentMargine + << endl << " m_iconSize: " << m_iconSize + << endl; + */ + + checkValues(); + + delete info; + delete info_theme; + delete layoutconfig; +} + +void KbfxConfig::write() +{ + if ( m_KbfxDeleteOldConf && KbfxRcPath != QString::null ) + { + QFile::remove ( KbfxRcPath ); + kdDebug() << "Deleting general RC file: " << KbfxRcPath << endl; + } + + KConfigSkeleton *confskel = new KConfigSkeleton ( QString::fromLatin1 ( "kbfxrc" ) ); + + /* write general KBFX configuration options */ + KConfig *conf = confskel->config(); + + conf->setGroup ( "KDE Action Restrictions" ); + conf->writeEntry ( "warn_unwritable_config", FALSE ); + + conf->setGroup ( "KbfxGeneral" ); + conf->writeEntry ( "Version", m_KbfxGeneralVersion ); + conf->writeEntry ( "MenuType", m_KbfxMenuType ); + conf->writeEntry ( "ToolBarResize", m_ToolBarResize ); + conf->writeEntry ( "KbfxWatcher", m_KbfxWatcher ); + conf->writeEntry ( "KbfxShowOld", m_KbfxShowOldThemes ); + + conf->setGroup ( "SpinxTheme" ); + conf->writeEntry ( "UserThemePath", m_UserSpinxThemeBasePath ); + conf->writeEntry ( "ThemeName", m_SpinxThemeName ); + conf->writeEntry ( "ThemePath", m_SpinxThemeBasePath ); + + conf->setGroup ( "UserImage" ); + conf->writeEntry ( "DudeBlink", m_SpinxDudeBlink ); + conf->writeEntry ( "DudeImage", m_SpinxDudeImage ); + + conf->setGroup ( "ToolTip" ); + conf->writeEntry ( "EnableToolTip", m_ToolTip ); + conf->writeEntry ( "AnimatedTooltip", m_ToolTipAnimation ); + conf->writeEntry ( "ToolTipText", m_ToolTipText ); + + conf->setGroup ( "Plugins" ); + conf->writeEntry ( "LoadedPluginsLeft", m_pluginsLeft ); + conf->writeEntry ( "LoadedPluginsRight", m_pluginsRight ); + + conf->setGroup ( "Runtime" ); + conf->writeEntry ( "History", m_KbfxHistory ); + + conf->sync(); + + delete confskel; +} + +void KbfxConfig::writeFontrc ( QString & themeName ) +{ + /* write fonts KBFX configuration from theme name */ + KConfig *fontconfig = new KConfig ( KbfxThemeRcDestination + "/" + themeName + "_fontrc" ); + + fontconfig->setGroup ( "Fonts" ); + fontconfig->writeEntry ( "TooltipText", m_fontTooltipColor ); + fontconfig->writeEntry ( "TooltipTextFont", m_fontTooltipFont ); + fontconfig->writeEntry ( "ApplicationText", m_fontAppNameColor ); + fontconfig->writeEntry ( "ApplicationTextFont", m_fontAppNameFont ); + fontconfig->writeEntry ( "CommentText", m_fontAppCommentColor ); + fontconfig->writeEntry ( "CommentTextFont", m_fontAppCommentFont ); + fontconfig->writeEntry ( "GroupText", m_fontIndexColor ); + fontconfig->writeEntry ( "GroupTextFont", m_fontIndexFont ); + fontconfig->writeEntry ( "UserName", m_userNameColor ); + fontconfig->writeEntry ( "UserNameFont", m_userNameFont ); + fontconfig->writeEntry ( "SeparatorColor", m_sepNameColor ); + fontconfig->writeEntry ( "SeparatorFont", m_sepNameFont ); + fontconfig->writeEntry ( "PluginColor", m_pluginNameColor ); + fontconfig->writeEntry ( "PluginFont", m_pluginNameFont ); + fontconfig->writeEntry ( "LineColor", m_lineColor ); + fontconfig->writeEntry ( "HoverBold",m_fontHoverBold ); + fontconfig->sync(); + + delete fontconfig; +} + +void KbfxConfig::writeThemerc ( QString & themeName ) +{ + checkValues(); + + /* write layout theme configuration from theme name */ + KConfig *layoutconfig = new KConfig ( KbfxThemeRcDestination + "/" + themeName + "_layoutrc" ); + + layoutconfig->setGroup ( "KbfxButton" ); + layoutconfig->writeEntry ( "Normal", m_KbfxNormalButtonPath ); + layoutconfig->writeEntry ( "Hover", m_KbfxHoverButtonPath ); + layoutconfig->writeEntry ( "Press", m_KbfxPressedButtonPath ); + layoutconfig->writeEntry ( "FadeTime", m_fadeTime ); + + layoutconfig->setGroup ( "ToolTip" ); + layoutconfig->writeEntry ( "Avatar", m_ToolTipAvatar ); + layoutconfig->writeEntry ( "Dudebox", m_SpinxTooltipDudebox ); + layoutconfig->writeEntry ( "Mask", m_SpinxTooltipMask ); + layoutconfig->writeEntry ( "Window", m_SpinxTooltipWindow ); + layoutconfig->writeEntry ( "Logo", m_SpinxTooltipLogo ); + + layoutconfig->setGroup ( "TopBar" ); + layoutconfig->writeEntry ( "DudeX", m_facePos_x ); + layoutconfig->writeEntry ( "DudeY", m_facePos_y ); + layoutconfig->writeEntry ( "FaceX",m_faceIconX ); + layoutconfig->writeEntry ( "FaceY",m_faceIconY ); + layoutconfig->writeEntry ( "FaceH",m_faceIconH ); + layoutconfig->writeEntry ( "FaceW",m_faceIconW ); + layoutconfig->writeEntry ( "UserNameX", m_userNamePos_x ); + layoutconfig->writeEntry ( "UserNameY", m_userNamePos_y ); + layoutconfig->writeEntry ( "DisableUserName", m_faceBoxHideText ); + layoutconfig->writeEntry ( "Height", m_topBar_h ); + layoutconfig->writeEntry ( "Width", m_topBar_w ); + layoutconfig->writeEntry ( "X", m_topBar_x ); + layoutconfig->writeEntry ( "Y", m_topBar_y ); + + layoutconfig->setGroup ( "BottomBar" ); + layoutconfig->writeEntry ( "Height", m_botBar_h ); + layoutconfig->writeEntry ( "Width", m_botBar_w ); + layoutconfig->writeEntry ( "X", m_botBar_x ); + layoutconfig->writeEntry ( "Y", m_botBar_y ); + + layoutconfig->setGroup ( "Scrollbars" ); + layoutconfig->writeEntry ( "ScrollBarBotX", m_scrollBarBotX ); + layoutconfig->writeEntry ( "ScrollBarBotY", m_scrollBarBotY ); + layoutconfig->writeEntry ( "ScrollBarTopX", m_scrollBarTopX ); + layoutconfig->writeEntry ( "ScrollBarTopY", m_scrollBarTopY ); + + layoutconfig->setGroup ( "ListBox" ); + layoutconfig->writeEntry ( "Height", m_listBox_h ); + layoutconfig->writeEntry ( "Width", m_listBox_w ); + layoutconfig->writeEntry ( "X", m_listBox_x ); + layoutconfig->writeEntry ( "Y", m_listBox_y ); + + layoutconfig->setGroup ( "SearchBox" ); + layoutconfig->writeEntry ( "Height", m_searchBox_h ); + layoutconfig->writeEntry ( "Width", m_searchBox_w ); + layoutconfig->writeEntry ( "X", m_searchBox_x ); + layoutconfig->writeEntry ( "Y", m_searchBox_y ); + layoutconfig->writeEntry ( "FixedPos", m_searchBox_static ); + + layoutconfig->setGroup ( "ItemView" ); + layoutconfig->writeEntry ( "Height", m_itemView_h ); + layoutconfig->writeEntry ( "Width", m_itemView_w ); + layoutconfig->writeEntry ( "X", m_itemView_x ); + layoutconfig->writeEntry ( "Y", m_itemView_y ); + + layoutconfig->setGroup ( "ToolBar" ); + layoutconfig->writeEntry ( "ButtonNormalSize", m_toolBarButtonNormalSize ); + layoutconfig->writeEntry ( "ButtonPressedSize", m_toolBarButtonExpandSize ); + + layoutconfig->setGroup ( "MainMenu" ); + layoutconfig->writeEntry ( "UserMenuHeight",m_userMenuHeight ); + layoutconfig->writeEntry ( "UserMenuWidth",m_userMenuWidth ); + layoutconfig->writeEntry ( "ContractedMenu", m_startHidden ); + + layoutconfig->setGroup ( "ItemProperties" ); + layoutconfig->writeEntry ( "NoComments",m_noComments ); + layoutconfig->writeEntry ( "CommentMargin",m_commentMargine ); + layoutconfig->writeEntry ( "IconSize",m_iconSize ); + + layoutconfig->sync(); + + delete layoutconfig; +} + +void KbfxConfig::checkValues() +{ + /* Protect some of the values */ + m_fadeTime = ( m_fadeTime == 0 ) ? m_fadeTime: ( m_fadeTime < 20 ) ? 20: ( m_fadeTime > 1000 ) ? 1000: m_fadeTime; +} diff --git a/kbfxlib/common/kbfxconfig.h b/kbfxlib/common/kbfxconfig.h new file mode 100644 index 0000000..739524b --- /dev/null +++ b/kbfxlib/common/kbfxconfig.h @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_CONFIG_H +#define KBFX_CONFIG_H + +#include <config.h> + +#include <qcolor.h> +#include <qfile.h> +#include <qfileinfo.h> +#include <qfont.h> +#include <qpixmap.h> +#include <qstring.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <kconfigskeleton.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kuser.h> + +#include <kbfxplasmapixmapprovider.h> + +class KbfxConfig +{ + public: + void read(); + void readFontrc ( QString &themePath, QString &themeName, bool user_rc=TRUE ); + void readThemerc ( QString &themePath, QString &themeName, bool user_rc=TRUE ); + void readThemeInfo ( QString &themePath, QString &themeName ); + void setDefault(); + void setThemeDefault(); + void setFontsDefault(); + void setThemeInfoDefault(); + void write(); + void writeFontrc ( QString &themeName ); + void writeThemerc ( QString &themeName ); + void checkValues(); + + /* Theme info resources */ + QString m_InfoVersion; + QString m_InfoVersionDefault; + QString m_InfoAuthor; + QString m_InfoAuthorDefault; + QString m_InfoEmail; + QString m_InfoEmailDefault; + QString m_InfoUrl; + QString m_InfoUrlDefault; + + /* kbfx_menu_button config items list */ + QString m_KbfxThemesVersion; + QString KbfxThemeRcDestination; + QString KbfxRcPath; + QPixmap KbfxOnImg; + QPixmap KbfxOffImg; + int m_KbfxGeneralVersion; + int m_KbfxGeneralVersionDefault; + QString m_KbfxNormalButtonPath; + QString m_KbfxNormalButtonPathDefault; + QString m_KbfxHoverButtonPath; + QString m_KbfxHoverButtonPathDefault; + QString m_KbfxPressedButtonPath; + QString m_KbfxPressedButtonPathDefault; + QString m_KbfxMouseOverAnimationPath; + QString m_KbfxMouseOverAnimationPathDefault; + QColor m_KbfxButtonColor; + QColor m_KbfxButtonColorDefault; + int m_KbfxButtonSize; + int m_KbfxButtonSizeDefault; + bool m_KbfxButtonGlow; + bool m_KbfxButtonGlowDefault; + bool m_KbfxButtonKikerResize; + bool m_KbfxButtonKikerResizeDefault; + QString m_KbfxMenuType; + QString m_KbfxMenuTypeDefault; + + /* spinx config items list */ + QString m_SpinxThemeBasePath; + QString m_SpinxThemeBasePathDefault; + QString m_UserSpinxThemeBasePath; + QString m_UserSpinxThemeBasePathDefault; + bool m_SpinxDudeBlink; + bool m_SpinxDudeBlinkDefault; + QString m_SpinxDudeImage; + QString m_SpinxDudeImageDefault; + QString m_SpinxThemeName; + QString m_SpinxThemeNameDefault; + bool m_ToolBarResize; + bool m_ToolBarResizeDefault; + bool m_KbfxWatcher; + bool m_KbfxWatcherDefault; + bool m_KbfxShowOldThemes; + bool m_KbfxShowOldThemesDefault; + + + /* tooltip options list */ + bool m_ToolTipAnimation; + bool m_ToolTipAnimationDefault; + bool m_ToolTip; + bool m_ToolTipDefault; + QString m_ToolTipText; + QString m_ToolTipTextDefault; + QString m_ToolTipAvatar; + QString m_ToolTipAvatarDefault; + QString m_SpinxTooltipDudebox; + QString m_SpinxTooltipDudeboxDefault; + QString m_SpinxTooltipMask; + QString m_SpinxTooltipMaskDefault; + QString m_SpinxTooltipWindow; + QString m_SpinxTooltipWindowDefault; + QString m_SpinxTooltipLogo; + QString m_SpinxTooltipLogoDefault; + + QString m_KbfxHistory; + QString m_KbfxHistoryDefault; + + /* font settings */ + QColor m_fontTooltipColor; + QColor m_fontTooltipColorDefault; + QFont m_fontTooltipFont; + QFont m_fontTooltipFontDefault; + QColor m_fontAppNameColor; + QColor m_fontAppNameColorDefault; + QFont m_fontAppNameFont; + QFont m_fontAppNameFontDefault; + QColor m_fontAppCommentColor; + QColor m_fontAppCommentColorDefault; + QFont m_fontAppCommentFont; + QFont m_fontAppCommentFontDefault; + QColor m_lineColor; + QColor m_lineColorDefault; + QColor m_fontIndexColor; + QColor m_fontIndexColorDefault; + QFont m_fontIndexFont; + QFont m_fontIndexFontDefault; + QColor m_userImageColor; + QColor m_userImageColorDefault; + QColor m_userNameColor; + QColor m_userNameColorDefault; + QFont m_userNameFont; + QFont m_userNameFontDefault; + QColor m_sepNameColor; + QColor m_sepNameColorDefault; + QFont m_sepNameFont; + QFont m_sepNameFontDefault; + QColor m_pluginNameColor; + QColor m_pluginNameColorDefault; + QFont m_pluginNameFont; + QFont m_pluginNameFontDefault; + bool m_fontHoverBold; + bool m_fontHoverBoldDefault; + + /* history */ + QStringList m_pluginsLeft; + QStringList m_pluginsLeftDefault; + QStringList m_pluginsRight; + QStringList m_pluginsRightDefault; + + /* layout */ + int m_facePos_x; + int m_facePos_xDefault; + int m_facePos_y; + int m_facePos_yDefault; + int m_userNamePos_x; + int m_userNamePos_xDefault; + int m_userNamePos_y; + int m_userNamePos_yDefault; + bool m_faceBoxHideText; + bool m_faceBoxHideTextDefault; + int m_userMenuHeight; + int m_userMenuHeightDefault; + int m_userMenuWidth; + int m_userMenuWidthDefault; + + int m_topBar_x; + int m_topBar_xDefault; + int m_topBar_y; + int m_topBar_yDefault; + int m_topBar_h; + int m_topBar_hDefault; + int m_topBar_w; + int m_topBar_wDefault; + + int m_botBar_x; + int m_botBar_xDefault; + int m_botBar_y; + int m_botBar_yDefault; + int m_botBar_h; + int m_botBar_hDefault; + int m_botBar_w; + int m_botBar_wDefault; + + int m_scrollBarTopX; + int m_scrollBarTopXDefault; + int m_scrollBarTopY; + int m_scrollBarTopYDefault; + int m_scrollBarBotX; + int m_scrollBarBotXDefault; + int m_scrollBarBotY; + int m_scrollBarBotYDefault; + + int m_listBox_x; + int m_listBox_xDefault; + int m_listBox_y; + int m_listBox_yDefault; + int m_listBox_w; + int m_listBox_wDefault; + int m_listBox_h; + int m_listBox_hDefault; + + int m_searchBox_x; + int m_searchBox_xDefault; + int m_searchBox_y; + int m_searchBox_yDefault; + int m_searchBox_w; + int m_searchBox_wDefault; + int m_searchBox_h; + int m_searchBox_hDefault; + bool m_searchBox_static; + bool m_searchBox_staticDefault; + + int m_itemView_x; + int m_itemView_xDefault; + int m_itemView_y; + int m_itemView_yDefault; + int m_itemView_h; + int m_itemView_hDefault; + int m_itemView_w; + int m_itemView_wDefault; + + int m_fadeTime; + int m_fadeTimeDefault; + + /* toolbar */ + int m_toolBarButtonNormalSizeDefault; + int m_toolBarButtonNormalSize; + int m_toolBarButtonExpandSizeDefault; + int m_toolBarButtonExpandSize; + + /* Face Icon */ + int m_faceIconX; + int m_faceIconXDefault; + int m_faceIconY; + int m_faceIconYDefault; + int m_faceIconH; + int m_faceIconHDefault; + int m_faceIconW; + int m_faceIconWDefault; + + /* element controll */ + int m_iconSize; + int m_iconSizeDefault; + bool m_noComments; + bool m_noCommentsDefault; + int m_commentMargine; + int m_commentMargineDefault; + /* states */ + bool m_startHidden; + bool m_startHiddenDefault; + + bool m_KbfxDeleteOldConf; + + private: + KbfxConfig(); + KbfxConfig ( const KbfxConfig& ); + + friend KbfxConfig& ConfigInit(); +}; + +KbfxConfig & ConfigInit(); + +#endif + diff --git a/kbfxlib/common/kbfxfontchooser.cpp b/kbfxlib/common/kbfxfontchooser.cpp new file mode 100644 index 0000000..c05a81e --- /dev/null +++ b/kbfxlib/common/kbfxfontchooser.cpp @@ -0,0 +1,79 @@ +//************************************************************************** +// Copyright (C) 2004, 2005 by Petri Damstén +// petri.damsten@iki.fi +// +// 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., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +//************************************************************************** + +#include "kbfxfontchooser.h" + +KBFXFontChooser::KBFXFontChooser ( QWidget *parent, const char *name ) + : QWidget ( parent, name ) +{ + QHBoxLayout* layout = new QHBoxLayout ( this, 0, KDialog::spacingHint() ); + + m_label = new QLabel ( this, "fontLabel" ); + m_label->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Fixed, TRUE); +// m_label->setFrameShape ( QFrame::StyledPanel ); +// m_label->setFrameShadow ( QFrame::Sunken ); + + layout->addWidget ( m_label ); + + m_button = new QPushButton ( this, "fontButton" ); + m_label->setMaximumHeight ( m_button -> height() ); + m_label->setMinimumHeight ( m_button -> height() ); + QString fontText = i18n ( "Font..." ); +// m_button->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Minimum, TRUE); + m_button->setText ( fontText ); + QIconSet iconSet = SmallIconSet ( QString::fromLatin1 ( "fonts" ) ); + QPixmap pixmap = iconSet.pixmap ( QIconSet::Small, QIconSet::Normal ); + m_button->setIconSet ( iconSet ); + m_button->setFixedWidth ( m_button->fontMetrics().width ( fontText ) + + 3 * KDialog::spacingHint() + pixmap.width() ); + layout->addWidget ( m_button ); + + connect ( m_button, SIGNAL ( clicked() ), this, SLOT ( buttonClicked() ) ); + + updateFontLabel(); + + setFocusProxy ( m_button ); +} + +KBFXFontChooser::~KBFXFontChooser() +{} + +void KBFXFontChooser::setFont ( const QFont& font ) +{ + m_font = font; + updateFontLabel(); +} + +void KBFXFontChooser::updateFontLabel() +{ + QString s = QString ( "%1 (%2pt) " ).arg ( m_font.family() ).arg ( m_font.pointSize() ); + m_label->setFont ( m_font ); + m_label->setText ( s ); + m_label->setAlignment ( Qt::AlignLeft | Qt::AlignVCenter ); + emit FontChanged(); +} + +void KBFXFontChooser::buttonClicked() +{ + KFontDialog::getFont ( m_font ); + updateFontLabel(); +} + +#include "kbfxfontchooser.moc" diff --git a/kbfxlib/common/kbfxfontchooser.h b/kbfxlib/common/kbfxfontchooser.h new file mode 100644 index 0000000..639a674 --- /dev/null +++ b/kbfxlib/common/kbfxfontchooser.h @@ -0,0 +1,70 @@ +//************************************************************************** +// Copyright (C) 2004, 2005 by Petri Damstén +// petri.damsten@iki.fi +// +// 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., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +//************************************************************************** +#ifndef KBFX_FONT_CHOOSER_H +#define KBFX_FONT_CHOOSER_H + +#include <kdialog.h> +#include <kfontdialog.h> +#include <klocale.h> +#include <kiconloader.h> +#include <qwidget.h> +#include <qlabel.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qfont.h> +#include <qsizepolicy.h> + +class QLabel; +class QPushButton; +class QFont; + +/** + @author Petri Damsten <petri.damsten@iki.fi> +*/ + +class KBFXFontChooser : public QWidget +{ + Q_OBJECT + Q_PROPERTY ( QFont font READ font WRITE setFont ) + public: + KBFXFontChooser ( QWidget *parent = 0, const char *name = 0 ); + ~KBFXFontChooser(); + + QFont font() const { return m_font; }; + + public slots: + void setFont ( const QFont& font ); + + protected: + void updateFontLabel(); + + protected slots: + void buttonClicked(); + + private: + QFont m_font; + QLabel* m_label; + QPushButton* m_button; + + signals: + void FontChanged(); +}; + +#endif diff --git a/kbfxlib/common/kbfxkiodownload.cpp b/kbfxlib/common/kbfxkiodownload.cpp new file mode 100644 index 0000000..ff6dccc --- /dev/null +++ b/kbfxlib/common/kbfxkiodownload.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kbfxkiodownload.h" + +KbfxKioDownload::KbfxKioDownload ( QObject *parent, const char *name ) + : QObject ( parent, name ) +{ + m_KbfxBrowserError = 0; + m_KbfxBrowserErrorText = "No error"; + m_KbfxBrowserTmpFile = tmpF.name(); + + kdDebug() << "Created temp file for download transfer: " + << m_KbfxBrowserTmpFile + << endl; +} + +KbfxKioDownload::~KbfxKioDownload() +{} + +void KbfxKioDownload::KbfxKioDownloadStart ( QString &url ) +{ + KIO::Job *download_job = KIO::file_copy ( KURL ( url ), + KURL ( m_KbfxBrowserTmpFile ), + -1, + TRUE ); + connect ( download_job, SIGNAL ( result ( KIO::Job* ) ), + this, SLOT ( KbfxBrowserResult ( KIO::Job * ) ) ); +} + +void KbfxKioDownload::KbfxBrowserResult ( KIO::Job *download_job ) +{ + m_KbfxBrowserError = download_job->error(); + + if ( m_KbfxBrowserError ) + { + KbfxKioDownloadEnd(); + m_KbfxBrowserErrorText = download_job->errorString(); + } + else m_KbfxBrowserErrorText = "No error"; + + kdDebug() << "Download transfer error: " + << m_KbfxBrowserError + << " - " + << m_KbfxBrowserErrorText + << endl; + + emit KbfxKioDownloadReady(); +} + +void KbfxKioDownload::KbfxKioDownloadEnd() +{ + kdDebug() << "Deleting temp file for download transfer: " + << tmpF.name() + <<endl; + + tmpF.unlink(); + deleteLater(); +} +#include "kbfxkiodownload.moc" diff --git a/kbfxlib/common/kbfxkiodownload.h b/kbfxlib/common/kbfxkiodownload.h new file mode 100644 index 0000000..61efb91 --- /dev/null +++ b/kbfxlib/common/kbfxkiodownload.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_KIO_DOWNLOAD_H +#define KBFX_KIO_DOWNLOAD_H + +#include <kio/job.h> +#include <ktempfile.h> +#include <kdebug.h> + +/** + * @author PhobosK <phobosk@mail.kbfx.org> + */ +class KbfxKioDownload : public QObject +{ + Q_OBJECT + + public: + KbfxKioDownload ( QObject * parent = 0, const char * name = 0 ); + ~KbfxKioDownload(); + + /* KbfxKioDownload invocation - pass an url as QString */ + void KbfxKioDownloadStart ( QString &url ); + + /* return temp file name for the download */ + QString KbfxBrowserTmpFile() {return m_KbfxBrowserTmpFile;} + + /* return error number occured during download + * see definition in global.h + */ + int KbfxBrowserError() {return m_KbfxBrowserError;} + + /* return error text occured during download */ + QString KbfxBrowserErrorText() {return m_KbfxBrowserErrorText;} + + protected: + QString m_KbfxBrowserTmpFile; + int m_KbfxBrowserError; + QString m_KbfxBrowserErrorText; + + private: + KTempFile tmpF; + + public slots: + /* call when you are ready to delete the temp file for the download */ + virtual void KbfxKioDownloadEnd(); + + private slots: + /* current job is done here */ + virtual void KbfxBrowserResult ( KIO::Job * ); + + signals: + /* emitted when the download is ready */ + void KbfxKioDownloadReady(); +}; + +#endif diff --git a/kbfxlib/common/kbfxpixmaplabel.cpp b/kbfxlib/common/kbfxpixmaplabel.cpp new file mode 100644 index 0000000..a85627e --- /dev/null +++ b/kbfxlib/common/kbfxpixmaplabel.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kbfxpixmaplabel.h" + +KbfxPixmapLabel::KbfxPixmapLabel ( QWidget *parent, const char *name, WFlags fl ) + : QLabel ( parent, name, fl ) +{ + // setFrameShape(QLabel::WinPanel); + // setFrameShadow(QLabel::Sunken); + setFrameShape ( QLabel::LineEditPanel ); + setFrameShadow ( QLabel::Plain ); + setScaledContents ( FALSE ); + setAlignment ( int ( QLabel::WordBreak | QLabel::AlignCenter ) ); + setMouseTracking ( TRUE ); +} + +KbfxPixmapLabel::~KbfxPixmapLabel() +{ +} + +/* normalize label */ +void KbfxPixmapLabel::normalize () +{ + setFrameShape ( QLabel::NoFrame ); + setFrameShadow ( QLabel::Plain ); + setScaledContents ( FALSE ); + setAlignment ( int ( QLabel::WordBreak | QLabel::AlignCenter ) ); +} + +/* processing drag events over label */ +void KbfxPixmapLabel::dragEnterEvent ( QDragEnterEvent *mouseDragEnterEvent ) +{ + kdDebug() << "Accepting drag..." << endl; + mouseDragEnterEvent->accept ( QTextDrag::canDecode ( mouseDragEnterEvent ) ); +} + +/* processing drop events over label */ +void KbfxPixmapLabel::dropEvent ( QDropEvent *mouseDropEvent ) +{ + QString text; + + if ( QTextDrag::decode ( mouseDropEvent,text ) ) + { + if ( text.startsWith ( "file://" ) ) text.remove ( "file://" ); + + kdDebug() << "Dropping drag..." << text << endl; + + emit targetDrop ( text ); + } +} + +/* processing mouse click events over label */ +void KbfxPixmapLabel::mousePressEvent ( QMouseEvent * e ) +{ + e->accept(); + ButtonState _btn = e->button(); + kdDebug() << "Mouse Clicked: " << _btn << endl; + emit clicked(); + emit mouseClicked (); + emit mouseClicked ( _btn ); +} + +/* processing mouse double click events over label */ +void KbfxPixmapLabel::mouseDoubleClickEvent ( QMouseEvent * e ) +{ + e->accept(); + ButtonState _btn = e->button(); + kdDebug() << "Mouse Double Clicked: " << _btn << endl; + emit mouseDoubleClicked (); + emit mouseDoubleClicked ( _btn ); +} + +#include "kbfxpixmaplabel.moc" diff --git a/kbfxlib/common/kbfxpixmaplabel.h b/kbfxlib/common/kbfxpixmaplabel.h new file mode 100644 index 0000000..1e20b99 --- /dev/null +++ b/kbfxlib/common/kbfxpixmaplabel.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_PIXMAP_LABEL_H +#define KBFX_PIXMAP_LABEL_H + +#include <qlabel.h> +#include <kdebug.h> +#include <qdragobject.h> +#include <qtooltip.h> + +class KbfxPixmapLabel : public QLabel +{ + Q_OBJECT + + public: + KbfxPixmapLabel ( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + ~KbfxPixmapLabel (); + + void dragEnterEvent ( QDragEnterEvent *mouseDragEnterEvent ); + void dropEvent ( QDropEvent *mouseDropEvent ); + void mousePressEvent ( QMouseEvent * e ); + void mouseDoubleClickEvent ( QMouseEvent * e ); + void normalize (); + + signals: + void targetDrop ( const QString & ); + void clicked(); + void mouseClicked (); + void mouseClicked ( const ButtonState & ); + void mouseDoubleClicked (); + void mouseDoubleClicked ( const ButtonState & ); +}; + +#endif // KBFX_PIXMAP_LABEL_H diff --git a/kbfxlib/common/kbfxplasmapixmapprovider.cpp b/kbfxlib/common/kbfxplasmapixmapprovider.cpp new file mode 100644 index 0000000..e505c62 --- /dev/null +++ b/kbfxlib/common/kbfxplasmapixmapprovider.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kbfxplasmapixmapprovider.h" + +int +KbfxPlasmaPixmapProvider::addPixmap ( QString pixmapname ) +{ + QString lFileName = PixmapPath( pixmapname ); + QPixmap * lPixmapPtr = 0; + + if ( ( lPixmapPtr = QPixmapCache::find ( pixmapname ) ) == NULL ) + { + lPixmapPtr = new QPixmap ( lFileName ); + QPixmapCache::insert ( pixmapname,lPixmapPtr ); + return ( lPixmapPtr->height() *lPixmapPtr->width() *lPixmapPtr->depth() ) /8; + } + return 0; +} + +QString +KbfxPlasmaPixmapProvider::PixmapPath ( QString pixmapName ) +{ + QString lFileName = ConfigInit ().m_SpinxThemeBasePath + ConfigInit ().m_SpinxThemeName + "/" + pixmapName + ".png"; + + if ( QPixmap::QPixmap ( lFileName ).isNull() ) + lFileName = locate ( "data", "kbfx/skins/default/" + pixmapName + ".png" ); + + return lFileName; +} + +QString +KbfxPlasmaPixmapProvider::PixmapPath ( QString pixmapName, QString themePath, QString themeName ) +{ + QString lFileName = themePath + themeName + "/" + pixmapName + ".png"; + + if ( QPixmap::QPixmap ( lFileName ).isNull() ) + lFileName = locate ( "data", "kbfx/skins/default/" + pixmapName + ".png" ); + + return lFileName; +} + +bool +KbfxPlasmaPixmapProvider::PixmapPathCheck ( QString pixmapPath ) +{ + if ( QPixmap::QPixmap ( pixmapPath ).isNull() ) + return FALSE; + + return TRUE; +} + +void +KbfxPlasmaPixmapProvider::deletePixmap ( const QString & key ) +{ + QPixmapCache::remove ( key ); +} + +void +KbfxPlasmaPixmapProvider::rebuildCache() +{ + QPixmapCache::clear (); + buildCache(); +} + +void KbfxPlasmaPixmapProvider::buildCache() +{ +//m_skinElements.append("topbg"); + QPixmapCache::setCacheLimit ( 1024*5 ); + static QStringList m_skinElements; + m_skinElements + <<"appfind" + <<"bg" + <<"botbg" + <<"butterfly" + <<"dudebox" + <<"find" + <<"hover" + <<"indexseparator" + <<"listboxbg" + <<"lock" + <<"lockhover" + <<"logout" + <<"logouthover" + <<"mask" + <<"menu_top" + <<"menu_top_image_person" + <<"middleboxbg" + <<"normal" + <<"off" + <<"on" + <<"pressed" + <<"preview" + <<"rhshovertile" + <<"rhstile" + <<"scrollnormal" + <<"separator" + <<"tabbg" + <<"tilehover" + <<"tilenormal" + <<"topbg" + <<"appviewbg" + ; + + for ( QStringList::Iterator it = m_skinElements.begin(); it != m_skinElements.end(); ++it ) + { + QPixmapCache::setCacheLimit ( KbfxPlasmaPixmapProvider::addPixmap ( *it ) +QPixmapCache::cacheLimit() ); + } + + +} + +QPixmap * +KbfxPlasmaPixmapProvider::pixmap ( const QString & key ) +{ + QPixmap* pp; + QPixmap p; + if ( ( pp=QPixmapCache::find ( key ) ) ) + { + return pp; + } + else + { + addPixmap ( key ); + return pixmap ( key ); + } + +} + diff --git a/kbfxlib/common/kbfxplasmapixmapprovider.h b/kbfxlib/common/kbfxplasmapixmapprovider.h new file mode 100644 index 0000000..00fd5b4 --- /dev/null +++ b/kbfxlib/common/kbfxplasmapixmapprovider.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_PLASMA_PIXMAP_PROVIDER_H +#define KBFX_PLASMA_PIXMAP_PROVIDER_H + + +#include <qfileinfo.h> +#include <qpixmapcache.h> +#include <qpixmap.h> +#include <qstring.h> +#include <qstringlist.h> + +#include <kbfxconfig.h> + +class KbfxPlasmaPixmapProvider +{ + + public: + + KbfxPlasmaPixmapProvider() + {} + ~KbfxPlasmaPixmapProvider() {} + + static int addPixmap ( QString ); + static void deletePixmap ( const QString & ); + static void rebuildCache(); + static void buildCache(); + static QPixmap* pixmap ( const QString & ); + static QString PixmapPath ( QString, QString, QString ); + static QString PixmapPath ( QString ); + static bool PixmapPathCheck ( QString ); +}; + +#endif diff --git a/kbfxlib/common/kbfxpushbutton.cpp b/kbfxlib/common/kbfxpushbutton.cpp new file mode 100644 index 0000000..e971993 --- /dev/null +++ b/kbfxlib/common/kbfxpushbutton.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kbfxpushbutton.h" + +KbfxPushButton::KbfxPushButton ( QWidget *parent, const char *name ) + : KPushButton ( parent, name ) +{ + setText ( "P R E V I E W" ); + setToggleButton ( TRUE ); + setFocusPolicy ( QWidget::NoFocus ); +} + +KbfxPushButton::~KbfxPushButton() +{ +} + +/* process hover events */ +void KbfxPushButton::enterEvent ( QEvent * ) +{ + if ( this->state() == 0 ) this->setPixmap ( ConfigInit().m_KbfxHoverButtonPath ); +} + +void KbfxPushButton::leaveEvent ( QEvent * ) +{ + if ( this->state() == 2 ) this->setPixmap ( ConfigInit().m_KbfxPressedButtonPath ); + if ( this->state() == 0 ) this->setPixmap ( ConfigInit().m_KbfxNormalButtonPath ); +} + +#include "kbfxpushbutton.moc" diff --git a/kbfxlib/common/kbfxpushbutton.h b/kbfxlib/common/kbfxpushbutton.h new file mode 100644 index 0000000..3d90bf7 --- /dev/null +++ b/kbfxlib/common/kbfxpushbutton.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_PUSH_BUTTON_H +#define KBFX_PUSH_BUTTON_H + +#include <kpushbutton.h> + +#include "kbfxconfig.h" + +class KbfxPushButton: public KPushButton +{ + Q_OBJECT + + public: + KbfxPushButton ( QWidget *parent = 0, const char *name = 0 ); + ~KbfxPushButton(); + + void enterEvent ( QEvent * ); + void leaveEvent ( QEvent * ); +}; + +#endif // KBFX_PUSH_BUTTON_H diff --git a/kbfxlib/common/kbfxthemesdata.cpp b/kbfxlib/common/kbfxthemesdata.cpp new file mode 100644 index 0000000..2ebaa10 --- /dev/null +++ b/kbfxlib/common/kbfxthemesdata.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "kbfxthemesdata.h" + +KbfxThemesData::KbfxThemesData() +{} + +KbfxThemesData::~KbfxThemesData() +{ + m_themesMap.clear(); +} + +ThemesMap KbfxThemesData::setThemeList ( QString path ) +{ + QString m_KbfxThemesVersion = ConfigInit().m_KbfxThemesVersion; + bool m_KbfxShowOldThemes = ConfigInit().m_KbfxShowOldThemes; + QFileInfo *fi=0, *f=0; + + m_themesMap.clear(); + + KStandardDirs *tmp = new KStandardDirs(); + + /* search themes in KDE Resource Folders and append user selected folder */ + QStringList skinsFolders = tmp->findDirs ( "data", "kbfx/skins" ); + if ( tmp->exists ( path ) ) + { + skinsFolders.append ( path ); + } + else + { + kdDebug() << "KbfxThemesData: Path doesn't exist! :" << path << endl; + } + + for ( QStringList::Iterator skinsIt = skinsFolders.begin(); skinsIt != skinsFolders.end(); ++skinsIt ) + { + QDir d ( *skinsIt ); + d.setFilter ( QDir::Dirs ); + + const QFileInfoList *list = d.entryInfoList(); + QFileInfoListIterator it ( *list ); + + while ( ( fi = it.current() ) != 0 ) + { + if ( !fi->fileName().startsWith ( "." ) ) + { + f = new QFileInfo ( d, fi->fileName() + "/" + m_KbfxThemesVersion ); + if ( m_KbfxShowOldThemes ) + { + m_themesMap[fi->fileName() ] = ( fi->dirPath ( TRUE ) ).append ( "/" ); + } + else + { + if ( f->exists () ) + m_themesMap[fi->fileName() ] = ( fi->dirPath ( TRUE ) ).append ( "/" ); + } + } + ++it; + } + } + + /* kdDebug() << "Available Themes - " + * << m_themesMap.keys() + * << m_themesMap.values() + * << endl; + */ + + delete fi; + delete f; + delete tmp; + return m_themesMap; +} diff --git a/kbfxlib/common/kbfxthemesdata.h b/kbfxlib/common/kbfxthemesdata.h new file mode 100644 index 0000000..5dd0bf1 --- /dev/null +++ b/kbfxlib/common/kbfxthemesdata.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2006 + * Siraj Razick <siraj@kdemail.net> + * PhobosK <phobosk@mail.kbfx.org> + * see Also AUTHORS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License version 2 as + * published by the Free Software Foundation + * + * 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KBFX_THEMES_DATA_H +#define KBFX_THEMES_DATA_H + +#include <kdebug.h> +#include <qstringlist.h> +#include <kio/netaccess.h> +#include <kstandarddirs.h> +#include <qmap.h> +#include <qdir.h> +#include <qfileinfo.h> + +#include "kbfxconfig.h" + +typedef QMap<QString, QString> ThemesMap; + +/** + * @author PhobosK <phobosk@mail.kbfx.org> + */ +class KbfxThemesData +{ + public: + KbfxThemesData(); + ~KbfxThemesData(); + + ThemesMap setThemeList ( QString path ); + + private: + ThemesMap m_themesMap; +}; + +#endif |