diff options
| author | 2008-10-10 23:40:56 +0000 | |
|---|---|---|
| committer | 2008-10-10 23:40:56 +0000 | |
| commit | bcb468055027196f7d2309fb14ed25d57bb44aea (patch) | |
| tree | 6d3ba53948a9cfcc656e52710090774b7408eaf4 /src | |
| parent | quick fix (diff) | |
| download | KVIrc-bcb468055027196f7d2309fb14ed25d57bb44aea.tar.gz KVIrc-bcb468055027196f7d2309fb14ed25d57bb44aea.tar.bz2 KVIrc-bcb468055027196f7d2309fb14ed25d57bb44aea.zip | |
rework on toolbars;
bumped sources date;
partial fix for Noldor's commit;
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2692 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvilib/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/kvilib/config/kvi_sourcesdate.h | 4 | ||||
| -rw-r--r-- | src/kvilib/tal/kvi_tal_toolbar.cpp | 57 | ||||
| -rw-r--r-- | src/kvilib/tal/kvi_tal_toolbar.h | 95 | ||||
| -rw-r--r-- | src/kvilib/tal/kvi_tal_toolbar_kde.h | 40 | ||||
| -rw-r--r-- | src/kvilib/tal/kvi_tal_toolbar_qt.h | 49 | ||||
| -rw-r--r-- | src/kvilib/tal/kvi_tal_toolbardocktype.h | 50 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_app.cpp | 5 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_customtoolbardescriptor.cpp | 61 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_customtoolbardescriptor.h | 12 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_customtoolbarmanager.cpp | 27 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_customtoolbarmanager.h | 10 | ||||
| -rw-r--r-- | src/kvirc/module/kvi_mextoolbar.cpp | 5 | ||||
| -rw-r--r-- | src/kvirc/module/kvi_mextoolbar.h | 2 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_customtoolbar.cpp | 309 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_customtoolbar.h | 54 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_toolbar.cpp | 58 | ||||
| -rw-r--r-- | src/kvirc/ui/kvi_toolbar.h | 9 | ||||
| -rw-r--r-- | src/modules/objects/class_button.cpp | 9 | ||||
| -rw-r--r-- | src/modules/objects/libkviobjects.cpp | 4 |
20 files changed, 365 insertions, 502 deletions
diff --git a/src/kvilib/CMakeLists.txt b/src/kvilib/CMakeLists.txt index fd9ed2e58..1abdd0c7b 100644 --- a/src/kvilib/CMakeLists.txt +++ b/src/kvilib/CMakeLists.txt @@ -15,6 +15,7 @@ INCLUDE_DIRECTORIES( SET(kvilib_MOC_HDRS ext/kvi_animatedpixmap.h + ext/kvi_animatedpixmapcache.h ext/kvi_crypt.h ext/kvi_garbage.h ext/kvi_regusersdb.h @@ -34,26 +35,24 @@ SET(kvilib_MOC_HDRS tal/kvi_tal_scrollview.h tal/kvi_tal_tabdialog.h tal/kvi_tal_tablewidget.h - tal/kvi_tal_tooltip.h tal/kvi_tal_textedit.h + tal/kvi_tal_toolbar.h + tal/kvi_tal_tooltip.h tal/kvi_tal_treewidget.h tal/kvi_tal_vbox.h tal/kvi_tal_widgetstack.h tal/kvi_tal_wizard.h - ext/kvi_animatedpixmapcache.h ) IF(COMPILE_KDE_SUPPORT) LIST(APPEND kvilib_MOC_HDRS tal/kvi_tal_menubar_kde.h tal/kvi_tal_mainwindow_kde.h - tal/kvi_tal_toolbar_kde.h ) ELSE() LIST(APPEND kvilib_MOC_HDRS tal/kvi_tal_menubar_qt.h tal/kvi_tal_mainwindow_qt.h - tal/kvi_tal_toolbar_qt.h ) ENDIF() diff --git a/src/kvilib/config/kvi_sourcesdate.h b/src/kvilib/config/kvi_sourcesdate.h index c5e7b0a76..cd55259f4 100644 --- a/src/kvilib/config/kvi_sourcesdate.h +++ b/src/kvilib/config/kvi_sourcesdate.h @@ -36,8 +36,8 @@ * \def KVI_SOURCES_DATE Defines the sources date * \def KVI_SOURCES_DATE_NUMERIC Defines the sources date */ -#define KVI_SOURCES_DATE "20081002" -#define KVI_SOURCES_DATE_NUMERIC 0x20081002 +#define KVI_SOURCES_DATE "20081011" +#define KVI_SOURCES_DATE_NUMERIC 0x20081011 /** * \brief This is the date of the sources before that we should force a setup diff --git a/src/kvilib/tal/kvi_tal_toolbar.cpp b/src/kvilib/tal/kvi_tal_toolbar.cpp index 4cc8ac05d..119089905 100644 --- a/src/kvilib/tal/kvi_tal_toolbar.cpp +++ b/src/kvilib/tal/kvi_tal_toolbar.cpp @@ -25,38 +25,30 @@ #include "kvi_tal_toolbar.h" #ifdef COMPILE_KDE_SUPPORT - KviTalToolBar::KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam) - : KToolBar(nam,w,dock,bNewLine) + KviTalToolBar::KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type, bool bNewLine, const char * pcName) + : KToolBar(pcName,pWnd,type,bNewLine) { - setWindowTitle(label); + setWindowTitle(szLabel); } - - KviTalToolBar::~KviTalToolBar() - { - } - -#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_toolbar_kde.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES - #else - KviTalToolBar::KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam) - : QToolBar(label,w) + KviTalToolBar::KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type, bool bNewLine, const char * pcName) + : QToolBar(szLabel,pWnd) { //setFrameStyle(QFrame::NoFrame); - setObjectName(nam); + setObjectName(pcName); if(!layout()) this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); - w->addToolBar(dock,this); + pWnd->addToolBar(type,this); } - KviTalToolBar::KviTalToolBar(QMainWindow *w,const char * name) - : QToolBar(w) + + KviTalToolBar::KviTalToolBar(QMainWindow * pWnd, const char * pcName) + : QToolBar(pWnd) { //setFrameStyle(QFrame::NoFrame); - setObjectName(name); + setObjectName(pcName); if(!layout()) this->setLayout(new QBoxLayout(QBoxLayout::LeftToRight)); - w->addToolBar(this); + pWnd->addToolBar(this); } QBoxLayout * KviTalToolBar::boxLayout() @@ -64,9 +56,9 @@ return (QBoxLayout*)this->layout(); } - void KviTalToolBar::setBoxLayout(QBoxLayout * l) + void KviTalToolBar::setBoxLayout(QBoxLayout * pLayout) { - this->setLayout(l); + this->setLayout(pLayout); } bool KviTalToolBar::usesBigPixmaps() @@ -74,18 +66,19 @@ return (iconSize().width() > 40); } - void KviTalToolBar::setUsesBigPixmaps(bool b) + void KviTalToolBar::setUsesBigPixmaps(bool bUse) { - if(b)setIconSize(QSize(48,48)); - else setIconSize(QSize(22,22)); + if(bUse) + setIconSize(QSize(48,48)); + else + setIconSize(QSize(22,22)); } +#endif // COMPILE_KDE_SUPPORT - KviTalToolBar::~KviTalToolBar() - { - } +KviTalToolBar::~KviTalToolBar() +{ +} #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES - #include "kvi_tal_toolbar_qt.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES - -#endif + #include "kvi_tal_toolbar.moc" +#endif // COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvilib/tal/kvi_tal_toolbar.h b/src/kvilib/tal/kvi_tal_toolbar.h index a81322b1e..29cc7951f 100644 --- a/src/kvilib/tal/kvi_tal_toolbar.h +++ b/src/kvilib/tal/kvi_tal_toolbar.h @@ -7,6 +7,7 @@ // // This file is part of the KVirc irc client distribution // Copyright (C) 2001-2008 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2008 Elvio Basello (hellvis69 at netsons dot org) // // This program is FREE software. You can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -24,12 +25,98 @@ // //============================================================================= +/** +* \file kvi_tal_toolbar.h +* \author Szymon Stefanek +* \brief Toolkit Abstraction Layer class +*/ + #include "kvi_settings.h" +/** +* \def QT_TOOLBAR_MINIMIZED Defines 'Minimized' as it was 'Top' +* \def QT_TOOLBAR_TORNOFF Defines 'Tornoff' as it was 'Top' +*/ +// THESE ARE UNSUPPORTED UNDER QT4! +#define QT_TOOLBAR_MINIMIZED Qt::TopToolBarArea +#define QT_TOOLBAR_TORNOFF Qt::TopToolBarArea + + +/** +* \class KviTalToolBar +* \brief Toolkit Abstraction Layer: toolnar class +*/ + #ifdef COMPILE_KDE_SUPPORT - #include "kvi_tal_toolbar_kde.h" -#else - #include "kvi_tal_toolbar_qt.h" -#endif + +#include <ktoolbar.h> + +class KVILIB_API KviTalToolBar : public KToolBar + +#else // COMPILE_KDE_SUPPORT + +#include <QToolBar> +#include <QMainWindow> +#include <QBoxLayout> + +class KVILIB_API KviTalToolBar : public QToolBar + +#endif // COMPILE_KDE_SUPPORT + +{ + Q_OBJECT +public: + /** + * \brief Constructs a toolbar object + * \param szLabel The label of the toolbar + * \param pWnd The mainwindow where to attach the toolbar + * \param dock The type of the toolbar + * \param bNewLine Whether to add a newline + * \param pcName The name of the toolbar + * \return KviTalToolBar + */ + KviTalToolBar(const QString & szLabel, QMainWindow * pWnd, Qt::ToolBarArea type = Qt::TopToolBarArea, bool bNewLine = false, const char * pcName = 0); + + /** + * \brief Destroys a toolbar object + */ + ~KviTalToolBar(); +#ifndef COMPILE_KDE_SUPPORT +public: + /** + * \brief Constructs a toolbar object + * \param pWnd The mainwindow where to attach the toolbar + * \param pcName The name of the toolbar + * \return KviTalToolBar + */ + KviTalToolBar(QMainWindow * pWnd, const char * pcName = 0); +public: + /** + * \brief Returns the box layout object + * \return QBoxLayout * + */ + QBoxLayout * boxLayout(); + + /** + * \brief Sets the box layout + * \param pLayout The box layout + * \return void + */ + void setBoxLayout(QBoxLayout * pLayout); + + /** + * \brief Returns true if the toolbar uses big pixmaps + * \return bool + */ + bool usesBigPixmaps(); + + /** + * \brief Sets the use of big pixmaps + * \param bUse Whether to use big pixmaps + * \return void + */ + void setUsesBigPixmaps(bool bUse); +#endif // COMPILE_KDE_SUPPORT +}; #endif //_KVI_TAL_TOOLBAR_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbar_kde.h b/src/kvilib/tal/kvi_tal_toolbar_kde.h deleted file mode 100644 index 99f14f027..000000000 --- a/src/kvilib/tal/kvi_tal_toolbar_kde.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _KVI_TAL_TOOLBAR_KDE_H_ -#define _KVI_TAL_TOOLBAR_KDE_H_ -//============================================================================= -// -// File : kvi_tal_toolbar_kde.h -// Creation date : Mon Aug 13 05:05:52 2001 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2001-2008 Szymon Stefanek (pragma at kvirc dot net) -// -// 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 opinion) 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "kvi_tal_toolbardocktype.h" - -#include <ktoolbar.h> - -class KVILIB_API KviTalToolBar : public KToolBar -{ - Q_OBJECT -public: - KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock = QT_DOCK_TOP,bool bNewLine = false,const char * nam = 0); - ~KviTalToolBar(); -}; - -#endif //_KVI_TAL_TOOLBAR_KDE_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbar_qt.h b/src/kvilib/tal/kvi_tal_toolbar_qt.h deleted file mode 100644 index 8b0fe258f..000000000 --- a/src/kvilib/tal/kvi_tal_toolbar_qt.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _KVI_TAL_TOOLBAR_QT_H_ -#define _KVI_TAL_TOOLBAR_QT_H_ -//============================================================================= -// -// File : kvi_tal_toolbar_qt4.h -// Creation date : Wed Feb 1 2007 04:11:11 2001 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2007-2008 Szymon Stefanek (pragma at kvirc dot net) -// -// 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 opinion) 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -//============================================================================= - -#include "kvi_settings.h" -#include "kvi_tal_toolbardocktype.h" - -#include <QToolBar> -#include <QMainWindow> -#include <QBoxLayout> - - -class KVILIB_API KviTalToolBar : public QToolBar -{ - Q_OBJECT -public: - KviTalToolBar(const QString &label,QMainWindow *w,QT_TOOLBARDOCK_TYPE dock = QT_DOCK_TOP,bool bNewLine = false,const char * nam = 0); - KviTalToolBar(QMainWindow *w,const char * name=0); - ~KviTalToolBar(); -public: - QBoxLayout * boxLayout(); - void setBoxLayout(QBoxLayout *l); - bool usesBigPixmaps(); - void setUsesBigPixmaps(bool b); -}; - -#endif //_KVI_TAL_TOOLBAR_QT_H_ diff --git a/src/kvilib/tal/kvi_tal_toolbardocktype.h b/src/kvilib/tal/kvi_tal_toolbardocktype.h deleted file mode 100644 index 494ba8310..000000000 --- a/src/kvilib/tal/kvi_tal_toolbardocktype.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _KVI_TAL_TOOLBARDOCKTYPE_H_ -#define _KVI_TAL_TOOLBARDOCKTYPE_H_ -//============================================================================= -// -// File : kvi_tal_toolbardocktype.h -// Creation date : Tue Sep 17 02:11:28 2002 GMT by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2002-2008 Szymon Stefanek (pragma at kvirc dot net) -// -// 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 opinion) 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. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -//============================================================================= - -#include "kvi_settings.h" - -/* - #define QT_TOOLBARDOCK_TYPE Qt::Dock - #define QT_DOCK_TOP Qt::DockTop - #define QT_DOCK_LEFT Qt::DockLeft - #define QT_DOCK_RIGHT Qt::DockRight - #define QT_DOCK_BOTTOM Qt::DockBottom - #define QT_DOCK_MINIMIZED Qt::DockMinimized - #define QT_DOCK_TORNOFF Qt::DockTornOff - #define QT_DOCK_UNMANAGED Qt::DockUnmanaged -*/ - // We will need these when we'll use the real QToolBar in Qt 4.x - #define QT_TOOLBARDOCK_TYPE Qt::ToolBarArea - #define QT_DOCK_TOP Qt::TopToolBarArea - #define QT_DOCK_LEFT Qt::LeftToolBarArea - #define QT_DOCK_RIGHT Qt::RightToolBarArea - #define QT_DOCK_BOTTOM Qt::BottomToolBarArea - // THESE ARE UNSUPPORTED UNDER QT4! - #define QT_DOCK_MINIMIZED Qt::TopToolBarArea - #define QT_DOCK_TORNOFF Qt::TopToolBarArea - #define QT_DOCK_UNMANAGED Qt::TopToolBarArea - -#endif //_KVI_TAL_TOOLBARDOCKTYPE_H_ diff --git a/src/kvirc/kernel/kvi_app.cpp b/src/kvirc/kernel/kvi_app.cpp index ae179d445..28761d674 100644 --- a/src/kvirc/kernel/kvi_app.cpp +++ b/src/kvirc/kernel/kvi_app.cpp @@ -363,11 +363,6 @@ void KviApp::setup() KviCustomToolBarManager::init(); if(getReadOnlyConfigPath(tmp,KVI_CONFIGFILE_CUSTOMTOOLBARS)) KviCustomToolBarManager::instance()->load(tmp); - // THIS IS A COMPATIBILITY ENTRY ADDED AT 3.0.2 TIME THAT SHOULD BE DROPPED IN A COUPLE OF VERSION BUMPS! - getLocalKvircDirectory(tmp,Config,KVI_CONFIGFILE_SCRIPTTOOLBARS); - if(KviFileUtils::fileExists(tmp)) - KviCustomToolBarManager::instance()->loadScripttoolbarsCompat(tmp); - // EOF COMPATIBILITY KVI_SPLASH_SET_PROGRESS(70) diff --git a/src/kvirc/kernel/kvi_customtoolbardescriptor.cpp b/src/kvirc/kernel/kvi_customtoolbardescriptor.cpp index 92f0277ad..b4429f39b 100644 --- a/src/kvirc/kernel/kvi_customtoolbardescriptor.cpp +++ b/src/kvirc/kernel/kvi_customtoolbardescriptor.cpp @@ -148,7 +148,7 @@ KviCustomToolBar * KviCustomToolBarDescriptor::createToolBar() if(!m_pToolBar) { QByteArray dd = id().toUtf8(); - m_pToolBar = new KviCustomToolBar(this,label(),QT_DOCK_TOP,false,dd.data()); + m_pToolBar = new KviCustomToolBar(this,label(),Qt::TopToolBarArea,false,dd.data()); fillToolBar(); } return m_pToolBar; @@ -181,65 +181,6 @@ void KviCustomToolBarDescriptor::clear() } } -#ifdef SCRIPTTOOLBARDESCRIPTOR_COMPAT -// THIS IS A COMPATIBILITY ENTRY ADDED AT 3.0.2 TIME THAT SHOULD BE DROPPED IN A COUPLE OF VERSION BUMPS! -#include "kvi_kvs_useraction.h" -#include "kvi_string.h" - -bool KviCustomToolBarDescriptor::loadScripttoolbarCompat(const char * szPrefix,KviConfig * cfg) -{ - m_pActions->clear(); - KviStr tmp; - tmp.sprintf("%s_Name",szPrefix); - m_szId = cfg->readQStringEntry(tmp.ptr(),""); - tmp.sprintf("%s_Label",szPrefix); - QString szLabelCode = cfg->readQStringEntry(tmp.ptr(),""); - if(szLabelCode.isEmpty())szLabelCode = "$tr(Unnamed)"; - delete m_pLabelScript; - createLabelScript(szLabelCode); - - tmp.sprintf("%s_Visible",szPrefix); - m_bVisibleAtStartup = (cfg->readIntEntry(tmp.ptr(),0) > 0); - tmp.sprintf("%s_Count",szPrefix); - unsigned int cnt = cfg->readUIntEntry(tmp.ptr(),0); - for(unsigned int i=0;i<cnt;i++) - { - tmp.sprintf("%s_%d",szPrefix,i); - KviStr tmp2; - tmp2.sprintf("%s_Type",tmp.ptr()); - tmp2 = cfg->readEntry(tmp2.ptr(),"separator"); - if(kvi_strEqualCI(tmp2.ptr(),"button")) - { - tmp2.sprintf("%s_Name",tmp.ptr()); - QString szName = cfg->readQStringEntry(tmp2.ptr(),""); - tmp2.sprintf("%s_Code",tmp.ptr()); - QString szCode = cfg->readQStringEntry(tmp2.ptr(),""); - tmp2.sprintf("%s_Icon",tmp.ptr()); - QString szIcon = cfg->readQStringEntry(tmp2.ptr(),""); - tmp2.sprintf("%s_Text",tmp.ptr()); - QString szText = cfg->readQStringEntry(tmp2.ptr(),""); - //tmp2.sprintf("%s_Enabled",tmp.ptr()); - //bool bEnabled = cfg->readBoolEntry(tmp2.ptr(),true); - - if(KviAction * old = KviActionManager::instance()->getAction(szName)) - { - if(!old->isKviUserActionNeverOverrideThis()) - szName = KviActionManager::instance()->nameForAutomaticAction(szName); - } - KviKvsUserAction * a = new KviKvsUserAction(KviActionManager::instance(), - szName,szCode,szText, - __tr2qs("Backward compatibility action for toolbar.define"), - "generic",szIcon,szIcon,0); - KviActionManager::instance()->registerAction(a); - m_pActions->append(new QString(szName)); - } else { - m_pActions->append(new QString("separator")); - } - } - return true; -} -#endif - bool KviCustomToolBarDescriptor::load(KviConfig * cfg) { m_pActions->clear(); diff --git a/src/kvirc/kernel/kvi_customtoolbardescriptor.h b/src/kvirc/kernel/kvi_customtoolbardescriptor.h index 25957f42d..860f667aa 100644 --- a/src/kvirc/kernel/kvi_customtoolbardescriptor.h +++ b/src/kvirc/kernel/kvi_customtoolbardescriptor.h @@ -33,15 +33,12 @@ class KviConfig; class KviKvsScript; -// THIS IS A COMPATIBILITY ENTRY ADDED AT 3.0.2 TIME THAT SHOULD BE DROPPED IN A COUPLE OF VERSION BUMPS! -#define SCRIPTTOOLBARDESCRIPTOR_COMPAT 1 - class KVIRC_API KviCustomToolBarDescriptor { friend class KviCustomToolBar; friend class KviCustomToolBarManager; protected: - KviCustomToolBarDescriptor(const QString &szId,const QString &szLabelCode); + KviCustomToolBarDescriptor(const QString & szId, const QString & szLabelCode); public: ~KviCustomToolBarDescriptor(); protected: @@ -73,14 +70,9 @@ protected: void createLabelScript(const QString &szNewLabelCode); void fillToolBar(); bool load(KviConfig * cfg); -#ifdef SCRIPTTOOLBARDESCRIPTOR_COMPAT -// THIS IS A COMPATIBILITY ENTRY ADDED AT 3.0.2 TIME THAT SHOULD BE DROPPED IN A COUPLE OF VERSION BUMPS! - bool loadScripttoolbarCompat(const char * prefix,KviConfig * cfg); -#endif void save(KviConfig * cfg); void registerToolBar(KviCustomToolBar * t); void unregisterToolBar(KviCustomToolBar * t); }; - -#endif //!_KVI_CUSTOMTOOLBARDESCRIPTOR_H_ +#endif //_KVI_CUSTOMTOOLBARDESCRIPTOR_H_ diff --git a/src/kvirc/kernel/kvi_customtoolbarmanager.cpp b/src/kvirc/kernel/kvi_customtoolbarmanager.cpp index 0c631ea1c..be24df001 100644 --- a/src/kvirc/kernel/kvi_customtoolbarmanager.cpp +++ b/src/kvirc/kernel/kvi_customtoolbarmanager.cpp @@ -210,30 +210,3 @@ void KviCustomToolBarManager::save(const QString &szFileName) ++it; } } - - -// THIS IS A COMPATIBILITY ENTRY ADDED AT 3.0.2 TIME THAT SHOULD BE DROPPED IN A COUPLE OF VERSION BUMPS! -#ifdef SCRIPTTOOLBAR_COMPAT - -#include <QDir> -void KviCustomToolBarManager::loadScripttoolbarsCompat(const QString &szFileName) -{ - KviConfig cfg(szFileName,KviConfig::Read); - - unsigned int cnt = cfg.readUIntEntry("Count",0); - KviStr tmp; - - for(unsigned int i=0;i<cnt;i++) - { - tmp.sprintf("%d",i); - KviCustomToolBarDescriptor * d = new KviCustomToolBarDescriptor(QString(),QString()); - if(!d->loadScripttoolbarCompat(tmp.ptr(),&cfg))delete d; - else m_pDescriptors->replace(d->id(),d); - } - - // get rid of the file now... - QString szNewFileName = szFileName + ".old"; - QDir d; - d.rename(szFileName,szNewFileName); -} -#endif diff --git a/src/kvirc/kernel/kvi_customtoolbarmanager.h b/src/kvirc/kernel/kvi_customtoolbarmanager.h index fd13cfa22..bd91e13eb 100644 --- a/src/kvirc/kernel/kvi_customtoolbarmanager.h +++ b/src/kvirc/kernel/kvi_customtoolbarmanager.h @@ -35,9 +35,6 @@ class KviCustomToolBar; -// THIS IS A COMPATIBILITY ENTRY ADDED AT 3.0.2 TIME THAT SHOULD BE DROPPED IN A COUPLE OF VERSION BUMPS! -#define SCRIPTTOOLBAR_COMPAT 1 - class KVIRC_API KviCustomToolBarManager { protected: @@ -65,12 +62,7 @@ public: bool renameDescriptor(const QString &szId,const QString &szNewId,const QString &szNewLabelCode); bool destroyDescriptor(const QString &szId); void load(const QString &szFileName); - // THIS IS A COMPATIBILITY ENTRY ADDED AT 3.0.2 TIME THAT SHOULD BE DROPPED IN A COUPLE OF VERSION BUMPS! -#ifdef SCRIPTTOOLBAR_COMPAT - void loadScripttoolbarsCompat(const QString &szFileName); -#endif void save(const QString &szFileName); }; - -#endif //!_KVI_CUSTOMTOOLBARMANAGER_H_ +#endif //_KVI_CUSTOMTOOLBARMANAGER_H_ diff --git a/src/kvirc/module/kvi_mextoolbar.cpp b/src/kvirc/module/kvi_mextoolbar.cpp index 4d8235b2a..97755ca2d 100644 --- a/src/kvirc/module/kvi_mextoolbar.cpp +++ b/src/kvirc/module/kvi_mextoolbar.cpp @@ -26,8 +26,8 @@ #include "kvi_mextoolbar.h" #include "kvi_frame.h" -KviMexToolBar::KviMexToolBar(KviModuleExtensionDescriptor * d,const QString &szName) -: KviToolBar(szName,QT_DOCK_TOP) , KviModuleExtension(d) +KviMexToolBar::KviMexToolBar(KviModuleExtensionDescriptor * pDesc, const QString & szName) +: KviToolBar(szName,Qt::TopToolBarArea) , KviModuleExtension(pDesc) { g_pFrame->registerModuleExtensionToolBar(this); } @@ -36,4 +36,3 @@ KviMexToolBar::~KviMexToolBar() { g_pFrame->unregisterModuleExtensionToolBar(this); } - diff --git a/src/kvirc/module/kvi_mextoolbar.h b/src/kvirc/module/kvi_mextoolbar.h index f70647e78..a18727f18 100644 --- a/src/kvirc/module/kvi_mextoolbar.h +++ b/src/kvirc/module/kvi_mextoolbar.h @@ -33,7 +33,7 @@ class KVIRC_API KviMexToolBar : public KviToolBar , public KviModuleExtension { Q_OBJECT public: - KviMexToolBar(KviModuleExtensionDescriptor * d,const QString &szName); + KviMexToolBar(KviModuleExtensionDescriptor * pDesc, const QString & szName); ~KviMexToolBar(); }; diff --git a/src/kvirc/ui/kvi_customtoolbar.cpp b/src/kvirc/ui/kvi_customtoolbar.cpp index 8dd20642c..d67a9be8c 100644 --- a/src/kvirc/ui/kvi_customtoolbar.cpp +++ b/src/kvirc/ui/kvi_customtoolbar.cpp @@ -41,40 +41,16 @@ #include <QStyleOption> #include <QDragEnterEvent> #include <QMimeData> + #define QDragObject QMimeData #define QTextDrag QMimeData #define QIconDrag QMimeData -KviCustomToolBarSeparator::KviCustomToolBarSeparator(KviCustomToolBar *pParent,const char * name) -: QWidget(pParent) -{ - setObjectName(name); - m_pToolBar = pParent; - setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); -} - -QSize KviCustomToolBarSeparator::sizeHint() const -{ - QStyleOption opt; - opt.initFrom(this); - int extent = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent,&opt,this); - if(m_pToolBar->orientation() == Qt::Horizontal)return QSize(extent,0); - else return QSize(0,extent); -} - -void KviCustomToolBarSeparator::paintEvent(QPaintEvent *) -{ - QPainter p(this); - QStyleOption opt; - opt.initFrom(this); - style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator,&opt,&p,this); -} - -KviCustomToolBar::KviCustomToolBar(KviCustomToolBarDescriptor * d,const QString &label,QT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam) -: KviToolBar(label,dock,bNewLine,nam) +KviCustomToolBar::KviCustomToolBar(KviCustomToolBarDescriptor * pDesc, const QString & szLabel, Qt::ToolBarArea type, bool bNewLine, const char * pcName) +: KviToolBar(szLabel,type,bNewLine,pcName) { - m_pDescriptor = d; + m_pDescriptor = pDesc; m_pMovedChild = 0; m_pDraggedChild = 0; m_pFilteredChildren = 0; @@ -82,7 +58,7 @@ KviCustomToolBar::KviCustomToolBar(KviCustomToolBarDescriptor * d,const QString connect(KviActionManager::instance(),SIGNAL(beginCustomizeToolBars()),this,SLOT(beginCustomize())); connect(KviActionManager::instance(),SIGNAL(endCustomizeToolBars()),this,SLOT(endCustomize())); setMinimumSize(20,20); - d->registerToolBar(this); + pDesc->registerToolBar(this); if(KviActionManager::customizingToolBars()) beginCustomize(); // because we will not get the signal } @@ -92,12 +68,15 @@ KviCustomToolBar::~KviCustomToolBar() if(KviActionManager::customizingToolBars()) syncDescriptor(); // because we will not get endCustomize() m_pDescriptor->unregisterToolBar(this); + if(KviActionManager::customizingToolBars()) { if(KviActionManager::currentToolBar() == this) KviActionManager::instance()->setCurrentToolBar(0); } - if(m_pFilteredChildren)delete m_pFilteredChildren; + + if(m_pFilteredChildren) + delete m_pFilteredChildren; } void KviCustomToolBar::paintEvent(QPaintEvent * e) @@ -113,17 +92,19 @@ void KviCustomToolBar::paintEvent(QPaintEvent * e) void KviCustomToolBar::filteredChildDestroyed() { - if(!m_pFilteredChildren)return; + if(!m_pFilteredChildren) + return; const QObject * o = sender(); m_pFilteredChildren->remove((void *)o); } void KviCustomToolBar::filterChild(QObject * o) { - bool * b = new bool(((QWidget *)o)->isEnabled()); + bool * pBool = new bool(((QWidget *)o)->isEnabled()); if(m_pFilteredChildren) - m_pFilteredChildren->insert(o,b); - if(!*b)((QWidget *)o)->setEnabled(true); + m_pFilteredChildren->insert(o,pBool); + if(!*pBool) + ((QWidget *)o)->setEnabled(true); o->installEventFilter(this); connect(o,SIGNAL(destroyed()),this,SLOT(filteredChildDestroyed())); } @@ -132,10 +113,11 @@ void KviCustomToolBar::unfilterChild(QObject * o) { if(m_pFilteredChildren) { - bool * b = m_pFilteredChildren->find(o); - if(b) + bool * pBool = m_pFilteredChildren->find(o); + if(pBool) { - if(!*b)((QWidget *)o)->setEnabled(false); + if(!*pBool) + ((QWidget *)o)->setEnabled(false); o->removeEventFilter(this); disconnect(o,SIGNAL(destroyed()),this,SLOT(filteredChildDestroyed())); } @@ -144,12 +126,14 @@ void KviCustomToolBar::unfilterChild(QObject * o) void KviCustomToolBar::beginCustomize() { - if(m_pFilteredChildren)delete m_pFilteredChildren; + if(m_pFilteredChildren) + delete m_pFilteredChildren; + m_pFilteredChildren = new KviPointerHashTable<void *,bool>; m_pFilteredChildren->setAutoDelete(true); // filter the events for all the children - QList<QObject*> l = children(); - for(QList<QObject*>::Iterator it = l.begin();it != l.end();++it) + QList<QObject *> list = children(); + for(QList<QObject *>::Iterator it = list.begin(); it != list.end(); ++it) { if((*it)->isWidgetType()) filterChild(*it); @@ -159,8 +143,8 @@ void KviCustomToolBar::beginCustomize() void KviCustomToolBar::endCustomize() { // stop filtering events - QList<QObject*> l = children(); - for(QList<QObject*>::Iterator it = l.begin();it != l.end();++it) + QList<QObject *> list = children(); + for(QList<QObject *>::Iterator it = list.begin(); it != list.end(); ++it) { if((*it)->isWidgetType()) unfilterChild(*it); @@ -180,7 +164,7 @@ void KviCustomToolBar::syncDescriptor() { // store the item order in the descriptor // There was boxLayouts - QLayout * lay = layout(); + QLayout * pLayout = layout(); /* QLayoutIterator iter = lay->iterator(); QLayoutItem * i; m_pDescriptor->actions()->clear(); @@ -191,18 +175,15 @@ void KviCustomToolBar::syncDescriptor() ++iter; } */ - int i = 0; - for (int i=0;i<layout()->count();i++) - { - if (QWidget * w=layout()->itemAt(i)->widget()) - m_pDescriptor->actions()->append(new QString(w->objectName())); - } - - + for(int i=0; i < pLayout->count(); i++) + { + if(QWidget * w = pLayout->itemAt(i)->widget()) + m_pDescriptor->actions()->append(new QString(w->objectName())); + } } -void KviCustomToolBar::childEvent(QChildEvent *e) +void KviCustomToolBar::childEvent(QChildEvent * e) { if(KviActionManager::customizingToolBars()) { @@ -225,37 +206,39 @@ done: KviToolBar::childEvent(e); } -void KviCustomToolBar::dragEnterEvent(QDragEnterEvent *e) +void KviCustomToolBar::dragEnterEvent(QDragEnterEvent * e) { - if(!KviActionManager::customizingToolBars())return; + if(!KviActionManager::customizingToolBars()) + return; + KviActionManager::instance()->setCurrentToolBar(this); - QString text; + QString szText; if(e->mimeData()->hasUrls()) { - if(!text.isEmpty()) + if(!szText.isEmpty()) { - KviAction * a = KviActionManager::instance()->getAction(text); - if(a) + KviAction * pAction = KviActionManager::instance()->getAction(szText); + if(pAction) { e->acceptProposedAction(); int idx = dropIndexAt(mapFromGlobal(QCursor::pos()),0,0); - m_pDraggedChild = a->addToCustomToolBar(this); + m_pDraggedChild = pAction->addToCustomToolBar(this); QWidget * pWidgetToMove = widgetAt(idx); bool bDone = false; - QAction * a; + QAction * pAction; if(pWidgetToMove) { - a = actionForWidget(pWidgetToMove); - if(a) + pAction = actionForWidget(pWidgetToMove); + if(pAction) { bDone = true; - a = insertWidget(a,m_pDraggedChild); + pAction = insertWidget(pAction,m_pDraggedChild); } } if(!bDone) - a = addWidget(m_pDraggedChild); - a->setVisible(true); + pAction = addWidget(m_pDraggedChild); + pAction->setVisible(true); #ifdef COMPILE_KDE_SUPPORT // bleah :///// //insertWidget(-1,m_pDraggedChild->sizeHint().width(),m_pDraggedChild,idx); @@ -268,13 +251,15 @@ void KviCustomToolBar::dragEnterEvent(QDragEnterEvent *e) } else e->ignore(); } -void KviCustomToolBar::dragMoveEvent(QDragMoveEvent *e) +void KviCustomToolBar::dragMoveEvent(QDragMoveEvent * e) { - if(!m_pDraggedChild)return; + if(!m_pDraggedChild) + return; + drag(m_pDraggedChild,mapFromGlobal(QCursor::pos())); } -void KviCustomToolBar::dragLeaveEvent(QDragLeaveEvent *e) +void KviCustomToolBar::dragLeaveEvent(QDragLeaveEvent * e) { if(m_pDraggedChild) { @@ -285,26 +270,30 @@ void KviCustomToolBar::dragLeaveEvent(QDragLeaveEvent *e) } } -void KviCustomToolBar::dropEvent(QDropEvent *e) +void KviCustomToolBar::dropEvent(QDropEvent * e) { - if(!m_pDraggedChild)return; + if(!m_pDraggedChild) + return; m_pDraggedChild = 0; - if(e->mimeData()->hasUrls()) e->acceptProposedAction(); + if(e->mimeData()->hasUrls()) + e->acceptProposedAction(); // nuthin :) } -int KviCustomToolBar::dropIndexAt(const QPoint &pnt,QWidget * exclude,int * excludeIdx) +int KviCustomToolBar::dropIndexAt(const QPoint & pnt, QWidget * pExclude, int * piExcludeIdx) { // find the widget at the current poisition // treating exclude as if it was going to be removed // find also the exclude index if needed - QLayout * l = layout(); + QLayout * pLayout = layout(); QLayoutItem * i = 0; - if(excludeIdx)*excludeIdx = -1; - int idx = 0; + if(piExcludeIdx) + *piExcludeIdx = -1; + int iIdx = 0; - if(!l)return 0; + if(!pLayout) + return 0; // QLayoutIterator it = l->iterator(); // find the children with minimum distance @@ -313,29 +302,29 @@ int KviCustomToolBar::dropIndexAt(const QPoint &pnt,QWidget * exclude,int * excl unsigned int uMinDist = 0xffffffff; int iExcludeIdx = -1; QPoint pntExclude; - QWidget * w = 0; + QWidget * pWidget = 0; // QLayoutItem *child; // while((i = it.current())) - for (int i=0;i<l->count();i++) + for (int i=0; i < pLayout->count(); i++) { - if((w = l->itemAt(i)->widget())) + if((pWidget = pLayout->itemAt(i)->widget())) { if(uMinDist != 0) { - int iRight = w->x() + w->width(); - int iBottom = w->y() + w->height(); - if((pnt.x() >= w->x()) && (pnt.y() >= w->y()) && (pnt.x() <= iRight) && (pnt.y() <= iBottom)) + int iRight = pWidget->x() + pWidget->width(); + int iBottom = pWidget->y() + pWidget->height(); + if((pnt.x() >= pWidget->x()) && (pnt.y() >= pWidget->y()) && (pnt.x() <= iRight) && (pnt.y() <= iBottom)) { // inside the widget // distance 0 - pMinDistW = w; - iMinDistIdx = idx; + pMinDistW = pWidget; + iMinDistIdx = iIdx; uMinDist = 0; } else { // outside the widget // compute the distance - unsigned int uXDist = (pnt.x() < w->x()) ? (w->x() - pnt.x()) : (pnt.x() > iRight ? (pnt.x() - iRight) : 0); - unsigned int uYDist = (pnt.y() < w->y()) ? (w->y() - pnt.y()) : (pnt.y() > iBottom ? (pnt.y() - iBottom) : 0); + unsigned int uXDist = (pnt.x() < pWidget->x()) ? (pWidget->x() - pnt.x()) : (pnt.x() > iRight ? (pnt.x() - iRight) : 0); + unsigned int uYDist = (pnt.y() < pWidget->y()) ? (pWidget->y() - pnt.y()) : (pnt.y() > iBottom ? (pnt.y() - iBottom) : 0); if((uXDist < 8192) && (uYDist < 8192)) { // it is in reasonable rect @@ -344,19 +333,19 @@ int KviCustomToolBar::dropIndexAt(const QPoint &pnt,QWidget * exclude,int * excl { // min distance for now uMinDist = uDist; - pMinDistW = w; - iMinDistIdx = idx; + pMinDistW = pWidget; + iMinDistIdx = iIdx; } } // else the user has a really HUUUGE screen } } // else the minimum distance widget has already been found - if(w == exclude) + if(pWidget == pExclude) { - iExcludeIdx = idx; - pntExclude = w->pos(); + iExcludeIdx = iIdx; + pntExclude = pWidget->pos(); } } - idx++; + iIdx++; //++it; } @@ -365,12 +354,14 @@ int KviCustomToolBar::dropIndexAt(const QPoint &pnt,QWidget * exclude,int * excl // ops.. not found at all (empty toolbar or really far from any button) if(orientation() == Qt::Horizontal) { - if(pnt.x() < (width() / 2))iMinDistIdx = 0; // insert at position 0 - else iMinDistIdx = idx; + if(pnt.x() < (width() / 2)) + iMinDistIdx = 0; // insert at position 0 + else iMinDistIdx = iIdx; // else insert at the last position found } else { - if(pnt.y() < (height() / 2))iMinDistIdx = 0; // insert at position 0 - else iMinDistIdx = idx; + if(pnt.y() < (height() / 2)) + iMinDistIdx = 0; // insert at position 0 + else iMinDistIdx = iIdx; // else insert at the last position found } } else { @@ -406,21 +397,24 @@ int KviCustomToolBar::dropIndexAt(const QPoint &pnt,QWidget * exclude,int * excl } } - if(iMinDistIdx < 0)iMinDistIdx = 0; - if(excludeIdx)*excludeIdx = iExcludeIdx; + if(iMinDistIdx < 0) + iMinDistIdx = 0; + if(piExcludeIdx) + *piExcludeIdx = iExcludeIdx; return iMinDistIdx; - } -QWidget * KviCustomToolBar::widgetAt(int index) +QWidget * KviCustomToolBar::widgetAt(int iIndex) { - QLayout * l = layout(); - if(!l) + QLayout * pLayout = layout(); + if(!pLayout) return NULL; - QLayoutItem * it = l->itemAt(index); + + QLayoutItem * it = pLayout->itemAt(iIndex); if(!it) return NULL; + return it->widget(); } @@ -429,43 +423,46 @@ QAction * KviCustomToolBar::actionForWidget(QWidget * pWidget) return actionAt(pWidget->x() + 1,pWidget->y() + 1); } -void KviCustomToolBar::drag(QWidget * child,const QPoint &pnt) +void KviCustomToolBar::drag(QWidget * pChild, const QPoint & pnt) { - int me = -1; - int idx = dropIndexAt(pnt,child,&me); - debug("DROP INDEX IS %d, ME IS %d",idx,me); - if(idx == me) return; // would move over itself + int iMe = -1; + int iIdx = dropIndexAt(pnt,pChild,&iMe); + debug("DROP INDEX IS %d, ME IS %d",iIdx,iMe); + if(iIdx == iMe) return; // would move over itself - QWidget * pWidgetToMove = widgetAt(idx > me ? idx-1 : idx); - debug("SEARCHING FOR WIDGET TO MOVE AT %d AND FOUND %x (ME=%x)",idx > me ? idx-1 : idx,pWidgetToMove,child); - if(pWidgetToMove == child) + QWidget * pWidgetToMove = widgetAt(iIdx > iMe ? iIdx-1 : iIdx); + debug("SEARCHING FOR WIDGET TO MOVE AT %d AND FOUND %x (ME=%x)",iIdx > iMe ? iIdx-1 : iIdx,pWidgetToMove,pChild); + if(pWidgetToMove == pChild) return; // hmmm + bool bDone = false; - QAction * pMyOwnAction = actionForWidget(child); + QAction * pMyOwnAction = actionForWidget(pChild); if(!pMyOwnAction) return; - QAction * a; + + QAction * pAction; removeAction(pMyOwnAction); if(pWidgetToMove) { - a = actionForWidget(pWidgetToMove); - if(a) + pAction = actionForWidget(pWidgetToMove); + if(pAction) { debug("AND GOT ACTION FOR THAT WIDGET"); bDone = true; - a = insertWidget(a,child); + pAction = insertWidget(pAction,pChild); } } else { - addAction(a); + addAction(pAction); } + if(!bDone) - a = addWidget(child); - a->setVisible(true); + pAction = addWidget(pChild); + pAction->setVisible(true); #ifdef COMPILE_KDE_SUPPORT // bleah :///// - // not sure if i'm losing anythig from insertWidget(-1,child->width(),child,idx); - addWidget(child); + // not sure if i'm losing anythig from insertWidget(-1,pChild->width(),pChild,idx); + addWidget(pChild); #endif QEvent ev(QEvent::LayoutRequest); QApplication::sendEvent(this,&ev); @@ -478,22 +475,27 @@ void KviCustomToolBar::mousePressEvent(QMouseEvent * e) KviToolBar::mousePressEvent(e); } -bool KviCustomToolBar::eventFilter(QObject *o,QEvent *e) +bool KviCustomToolBar::eventFilter(QObject * o,QEvent * e) { - if(!KviActionManager::customizingToolBars())goto unhandled; // anything here is done when customizing only + if(!KviActionManager::customizingToolBars()) + goto unhandled; // anything here is done when customizing only if(e->type() == QEvent::Enter) { - if(m_pMovedChild)return true; // kill it while moving other children + if(m_pMovedChild) + return true; // kill it while moving other children } + if(e->type() == QEvent::Leave) { - if(m_pMovedChild)return true; // kill it while moving other children + if(m_pMovedChild) + return true; // kill it while moving other children } + if(e->type() == QEvent::MouseButtonPress) { KviActionManager::instance()->setCurrentToolBar(this); - QMouseEvent * ev = (QMouseEvent *)e; - if(ev->button() & Qt::LeftButton) + QMouseEvent * pEvent = (QMouseEvent *)e; + if(pEvent->button() & Qt::LeftButton) { if(o->isWidgetType()) { @@ -510,7 +512,7 @@ bool KviCustomToolBar::eventFilter(QObject *o,QEvent *e) // FIXME: do it only if the child is really resizable if(m_pMovedChild->width() > 20) // might be an applet { - if(ev->pos().x() > (m_pMovedChild->width() - 4)) + if(pEvent->pos().x() > (m_pMovedChild->width() - 4)) { m_pMovedChild = 0; goto unhandled; // let the applet handle the event it @@ -523,6 +525,7 @@ bool KviCustomToolBar::eventFilter(QObject *o,QEvent *e) } goto unhandled; } + if(e->type() == QEvent::MouseButtonRelease) { if(m_pMovedChild) @@ -533,21 +536,22 @@ bool KviCustomToolBar::eventFilter(QObject *o,QEvent *e) } goto unhandled; } + if(e->type() == QEvent::MouseMove) { if(m_pMovedChild) { - QMouseEvent * ev = (QMouseEvent *)e; + QMouseEvent * pEvent = (QMouseEvent *)e; - QPoint pnt = mapFromGlobal(m_pMovedChild->mapToGlobal(ev->pos())); + QPoint pnt = mapFromGlobal(m_pMovedChild->mapToGlobal(pEvent->pos())); if((pnt.y() < 0) || (pnt.y() > height()) || (pnt.x() < 0) || (pnt.x() > width())) { // drag out! -// FIXME: This is screwed up in Qt4.... :/ - QDrag * d = new QDrag(this); - QMimeData * m = new QMimeData(); - m->setText(m_pMovedChild->objectName()); - d->setMimeData(m); + // FIXME: This is screwed up in Qt4.... :/ + QDrag * pDrag = new QDrag(this); + QMimeData * pMime = new QMimeData(); + pMime->setText(m_pMovedChild->objectName()); + pDrag->setMimeData(pMime); KviAction * act = KviActionManager::instance()->getAction(m_pMovedChild->objectName()); if(act) @@ -555,11 +559,11 @@ bool KviCustomToolBar::eventFilter(QObject *o,QEvent *e) QPixmap * pixie = act->bigIcon(); if(pixie) { - d->setPixmap(*pixie); - d->setHotSpot(QPoint(3,3)); + pDrag->setPixmap(*pixie); + pDrag->setHotSpot(QPoint(3,3)); } } - //d->setPixmap(QPixmap::grabWidget(m_pMovedChild),QPoint(m_pMovedChild->width() / 2,m_pMovedChild->height() / 2)); + //pDrag->setPixmap(QPixmap::grabWidget(m_pMovedChild),QPoint(m_pMovedChild->width() / 2,m_pMovedChild->height() / 2)); // throw it somewhere else for now if(m_pFilteredChildren) unfilterChild(m_pMovedChild); @@ -571,7 +575,7 @@ bool KviCustomToolBar::eventFilter(QObject *o,QEvent *e) QEvent ev(QEvent::LayoutRequest); QApplication::sendEvent(this,&ev); - if(!d->exec(Qt::MoveAction) != Qt::MoveAction) + if(!pDrag->exec(Qt::MoveAction) != Qt::MoveAction) { // the user has probably failed to remove the action from the toolbar // flash the trashcan in the customize toolbars dialog @@ -604,3 +608,30 @@ bool KviCustomToolBar::eventFilter(QObject *o,QEvent *e) unhandled: return KviToolBar::eventFilter(o,e); } + +KviCustomToolBarSeparator::KviCustomToolBarSeparator(KviCustomToolBar * pParent, const char * pcName) +: QWidget(pParent) +{ + setObjectName(pcName); + m_pToolBar = pParent; + setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum)); +} + +QSize KviCustomToolBarSeparator::sizeHint() const +{ + QStyleOption opt; + opt.initFrom(this); + int iExtent = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent,&opt,this); + + if(m_pToolBar->orientation() == Qt::Horizontal) + return QSize(iExtent,0); + else return QSize(0,iExtent); +} + +void KviCustomToolBarSeparator::paintEvent(QPaintEvent * e) +{ + QPainter p(this); + QStyleOption opt; + opt.initFrom(this); + style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator,&opt,&p,this); +} diff --git a/src/kvirc/ui/kvi_customtoolbar.h b/src/kvirc/ui/kvi_customtoolbar.h index ec6a1c429..ed33faaf5 100644 --- a/src/kvirc/ui/kvi_customtoolbar.h +++ b/src/kvirc/ui/kvi_customtoolbar.h @@ -33,47 +33,34 @@ #else class KviCustomToolBarDescriptor; #endif -class KviCustomToolBar; - -class KviCustomToolBarSeparator : public QWidget -{ - Q_OBJECT -public: - KviCustomToolBarSeparator(KviCustomToolBar *pParent,const char * name); - QSize sizeHint() const; -protected: - KviCustomToolBar * m_pToolBar; -protected: - void paintEvent(QPaintEvent *e); -}; class KVIRC_API KviCustomToolBar : public KviToolBar { friend class KviCustomToolBarDescriptor; Q_OBJECT protected: - KviCustomToolBar(KviCustomToolBarDescriptor * d,const QString &label,QT_TOOLBARDOCK_TYPE dock = QT_DOCK_TOP,bool bNewLine = false,const char * nam = 0); + KviCustomToolBar(KviCustomToolBarDescriptor * d, const QString & szLabel, Qt::ToolBarArea type = Qt::TopToolBarArea, bool bNewLine = false, const char * pcName = 0); public: ~KviCustomToolBar(); protected: - KviCustomToolBarDescriptor * m_pDescriptor; - QWidget * m_pMovedChild; - QWidget * m_pDraggedChild; + KviCustomToolBarDescriptor * m_pDescriptor; + QWidget * m_pMovedChild; + QWidget * m_pDraggedChild; KviPointerHashTable<void *,bool> * m_pFilteredChildren; public: KviCustomToolBarDescriptor * descriptor(){ return m_pDescriptor; }; protected: virtual void mousePressEvent(QMouseEvent * e); - virtual void dragEnterEvent(QDragEnterEvent *e); - virtual void dragMoveEvent(QDragMoveEvent *e); - virtual void dragLeaveEvent(QDragLeaveEvent *e); - virtual void dropEvent(QDropEvent *e); - virtual void childEvent(QChildEvent *e); - virtual bool eventFilter(QObject *o,QEvent *e); - int dropIndexAt(const QPoint &pnt,QWidget * exclude,int * excludeIdx); - QWidget * widgetAt(int index); + virtual void dragEnterEvent(QDragEnterEvent * e); + virtual void dragMoveEvent(QDragMoveEvent * e); + virtual void dragLeaveEvent(QDragLeaveEvent * e); + virtual void dropEvent(QDropEvent * e); + virtual void childEvent(QChildEvent * e); + virtual bool eventFilter(QObject * o, QEvent * e); + int dropIndexAt(const QPoint & pnt, QWidget * pExclude, int * piExcludeIdx); + QWidget * widgetAt(int iIndex); QAction * actionForWidget(QWidget * pWidget); - void drag(QWidget * child,const QPoint &pnt); + void drag(QWidget * pChild, const QPoint & pnt); void filterChild(QObject * o); void unfilterChild(QObject * o); virtual void paintEvent(QPaintEvent * e); @@ -84,4 +71,17 @@ protected slots: void filteredChildDestroyed(); }; -#endif //!_KVI_CUSTOMTOOLBAR_H_ +class KviCustomToolBarSeparator : public QWidget +{ + Q_OBJECT +public: + KviCustomToolBarSeparator(KviCustomToolBar * pParent, const char * pcName); +protected: + KviCustomToolBar * m_pToolBar; +public: + QSize sizeHint() const; +protected: + void paintEvent(QPaintEvent * e); +}; + +#endif //_KVI_CUSTOMTOOLBAR_H_ diff --git a/src/kvirc/ui/kvi_toolbar.cpp b/src/kvirc/ui/kvi_toolbar.cpp index 068a2d40d..996b89163 100644 --- a/src/kvirc/ui/kvi_toolbar.cpp +++ b/src/kvirc/ui/kvi_toolbar.cpp @@ -22,8 +22,6 @@ // //============================================================================= - - #include "kvi_toolbar.h" #include "kvi_frame.h" #include "kvi_locale.h" @@ -34,31 +32,35 @@ #include <QEvent> #include <QMouseEvent> -static KviTalPopupMenu * g_pToolBarContextPopup = 0; -static KviTalPopupMenu * g_pToolBarWindowsPopup = 0; +static KviTalPopupMenu * g_pToolBarContextPopup = 0; +static KviTalPopupMenu * g_pToolBarWindowsPopup = 0; static KviTalPopupMenu * g_pToolBarIconSizesPopup = 0; static KviTalPopupMenu * g_pToolBarPositionsPopup = 0; -KviToolBar::KviToolBar(const QString &label,QT_TOOLBARDOCK_TYPE dock,bool bNewLine,const char * nam) -: KviTalToolBar(label,g_pFrame,dock,bNewLine,nam) +KviToolBar::KviToolBar(const QString & szLabel, Qt::ToolBarArea type, bool bNewLine, const char * pcName) +: KviTalToolBar(szLabel,g_pFrame,type,bNewLine,pcName) { } KviToolBar::~KviToolBar() { - if(g_pToolBarContextPopup)delete g_pToolBarContextPopup; - if(g_pToolBarIconSizesPopup)delete g_pToolBarIconSizesPopup; - if(g_pToolBarPositionsPopup)delete g_pToolBarPositionsPopup; - if(g_pToolBarWindowsPopup)delete g_pToolBarWindowsPopup; + if(g_pToolBarContextPopup) + delete g_pToolBarContextPopup; + if(g_pToolBarIconSizesPopup) + delete g_pToolBarIconSizesPopup; + if(g_pToolBarPositionsPopup) + delete g_pToolBarPositionsPopup; + if(g_pToolBarWindowsPopup) + delete g_pToolBarWindowsPopup; - g_pToolBarContextPopup = 0; + g_pToolBarContextPopup = 0; g_pToolBarIconSizesPopup = 0; g_pToolBarPositionsPopup = 0; - g_pToolBarWindowsPopup = 0; + g_pToolBarWindowsPopup = 0; } -void KviToolBar::mousePressEvent(QMouseEvent *e) +void KviToolBar::mousePressEvent(QMouseEvent * e) { if(!(e->button() & Qt::RightButton)) { @@ -66,10 +68,14 @@ void KviToolBar::mousePressEvent(QMouseEvent *e) return; } - if(!g_pToolBarContextPopup)g_pToolBarContextPopup = new KviTalPopupMenu(); - if(!g_pToolBarIconSizesPopup)g_pToolBarIconSizesPopup = new KviTalPopupMenu(); - if(!g_pToolBarPositionsPopup)g_pToolBarPositionsPopup = new KviTalPopupMenu(); - if(!g_pToolBarWindowsPopup)g_pToolBarWindowsPopup = new KviTalPopupMenu(); + if(!g_pToolBarContextPopup) + g_pToolBarContextPopup = new KviTalPopupMenu(); + if(!g_pToolBarIconSizesPopup) + g_pToolBarIconSizesPopup = new KviTalPopupMenu(); + if(!g_pToolBarPositionsPopup) + g_pToolBarPositionsPopup = new KviTalPopupMenu(); + if(!g_pToolBarWindowsPopup) + g_pToolBarWindowsPopup = new KviTalPopupMenu(); g_pToolBarContextPopup->clear(); g_pToolBarIconSizesPopup->clear(); @@ -97,41 +103,41 @@ void KviToolBar::mousePressEvent(QMouseEvent *e) g_pToolBarContextPopup->popup(QCursor::pos()); } -void KviToolBar::moveTo(QT_TOOLBARDOCK_TYPE dock) +void KviToolBar::moveTo(Qt::ToolBarArea type) { // FIXME: this should be hidden in Tal g_pFrame->removeToolBar(this); - g_pFrame->addToolBar(dock,this); + g_pFrame->addToolBar(type,this); } void KviToolBar::moveToTop() { - moveTo(QT_DOCK_TOP); + moveTo(Qt::TopToolBarArea); } void KviToolBar::moveToLeft() { - moveTo(QT_DOCK_LEFT); + moveTo(Qt::LeftToolBarArea); } void KviToolBar::moveToRight() { - moveTo(QT_DOCK_RIGHT); + moveTo(Qt::RightToolBarArea); } void KviToolBar::moveToBottom() { - moveTo(QT_DOCK_BOTTOM); + moveTo(Qt::BottomToolBarArea); } void KviToolBar::moveToMinimized() { - moveTo(QT_DOCK_MINIMIZED); + moveTo(QT_TOOLBAR_MINIMIZED); } void KviToolBar::moveToTornOff() { - moveTo(QT_DOCK_TORNOFF); + moveTo(QT_TOOLBAR_TORNOFF); } void KviToolBar::setBigIcons() @@ -146,4 +152,4 @@ void KviToolBar::setSmallIcons() #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "kvi_toolbar.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/kvirc/ui/kvi_toolbar.h b/src/kvirc/ui/kvi_toolbar.h index 4765116ed..0feaa349c 100644 --- a/src/kvirc/ui/kvi_toolbar.h +++ b/src/kvirc/ui/kvi_toolbar.h @@ -26,17 +26,15 @@ #include "kvi_tal_toolbar.h" -class KviFrame; - class KVIRC_API KviToolBar : public KviTalToolBar { Q_OBJECT public: - KviToolBar(const QString &label,QT_TOOLBARDOCK_TYPE dock = QT_DOCK_TOP,bool bNewLine = false,const char * nam = 0); + KviToolBar(const QString & szLabel, Qt::ToolBarArea type = Qt::TopToolBarArea, bool bNewLine = false, const char * pcName = 0); ~KviToolBar(); protected: - virtual void mousePressEvent(QMouseEvent *e); - void moveTo(QT_TOOLBARDOCK_TYPE dock); + virtual void mousePressEvent(QMouseEvent * e); + void moveTo(Qt::ToolBarArea type); public slots: void moveToTop(); void moveToLeft(); @@ -48,5 +46,4 @@ public slots: void setSmallIcons(); }; - #endif //_KVI_TOOLBAR_H_ diff --git a/src/modules/objects/class_button.cpp b/src/modules/objects/class_button.cpp index 99323cf98..1f4d2ef52 100644 --- a/src/modules/objects/class_button.cpp +++ b/src/modules/objects/class_button.cpp @@ -27,13 +27,15 @@ #include "kvi_locale.h" #include "kvi_error.h" #include "kvi_iconmanager.h" +#include "kvi_file.h" + #include "class_button.h" #include "class_pixmap.h" #include <QIcon> #include <QPushButton> -#include <kvi_file.h> + /* @@ -82,7 +84,7 @@ KVSO_END_CONSTRUCTOR(KviKvsObject_button) KVSO_BEGIN_DESTRUCTOR(KviKvsObject_button) -KVSO_END_CONSTRUCTOR(KviKvsObject_button) +KVSO_END_DESTRUCTOR(KviKvsObject_button) bool KviKvsObject_button::init(KviKvsRunTimeContext * pContext,KviKvsVariantList *pParams) { @@ -156,5 +158,4 @@ void KviKvsObject_button::slotClicked() #ifndef COMPILE_USE_STANDALONE_MOC_SOURCES #include "m_class_button.moc" -#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES - +#endif //COMPILE_USE_STANDALONE_MOC_SOURCES diff --git a/src/modules/objects/libkviobjects.cpp b/src/modules/objects/libkviobjects.cpp index 5a3cf5fe9..862c3b993 100644 --- a/src/modules/objects/libkviobjects.cpp +++ b/src/modules/objects/libkviobjects.cpp @@ -40,7 +40,6 @@ #include "class_list.h" #include "class_listwidget.h" #include "class_mainwindow.h" -#include "class_memorybuffer.h" #include "class_menubar.h" #include "class_multilineedit.h" #include "class_painter.h" @@ -90,8 +89,6 @@ static bool objects_module_cleanup(KviModule *m) // Don't attempt to change the order of these calls. // Derived classes must be unregistered before the base ones. - KviKvsObject_memorybuffer::unregisterSelf(); - KviKvsObject_process::unregisterSelf(); KviKvsObject_ftp::unregisterSelf(); KviKvsObject_http::unregisterSelf(); @@ -999,7 +996,6 @@ static bool objects_module_init(KviModule * m) KviKvsObject_ftp::registerSelf(); KviKvsObject_process::registerSelf(); - KviKvsObject_memorybuffer::registerSelf(); return true; } |
