diff options
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/notifier/libkvinotifier.cpp | 646 | ||||
| -rw-r--r-- | src/modules/notifier/notifier_QT4_vc05.vcproj | 625 | ||||
| -rw-r--r-- | src/modules/notifier/notifiermessage.cpp | 209 | ||||
| -rw-r--r-- | src/modules/notifier/notifiermessage.h | 194 | ||||
| -rw-r--r-- | src/modules/notifier/notifiersettings.h | 132 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindow.cpp | 2623 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindow.h | 398 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowbody.cpp | 420 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowbody.h | 292 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowborder.cpp | 313 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowborder.h | 272 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowtabs.cpp | 1473 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindowtabs.h | 515 |
13 files changed, 4219 insertions, 3893 deletions
diff --git a/src/modules/notifier/libkvinotifier.cpp b/src/modules/notifier/libkvinotifier.cpp index ebae90f49..90f51ba7e 100644 --- a/src/modules/notifier/libkvinotifier.cpp +++ b/src/modules/notifier/libkvinotifier.cpp @@ -1,323 +1,323 @@ -//================================================================================== -// -// File : libkvinotifier.cpp -// Creation date : Tue Jul 7 2004 20:21:12 CEST by Szymon Stefanek -// -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// 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_module.h" - - -#include "notifierwindow.h" -#include "notifiermessage.h" - -#include "kvi_kvs_variant.h" -#include "kvi_app.h" -#include "kvi_frame.h" -#include "kvi_window.h" -#include "kvi_locale.h" -#include "kvi_iconmanager.h" -#include "kvi_time.h" -#include "kvi_options.h" - -#include <qsplitter.h> - -KviNotifierWindow * g_pNotifierWindow = 0; -kvi_time_t g_tNotifierDisabledUntil = 0; - -/* - @doc: notifier.message - @type: - command - @title: - notifier.message - @short: - Adds a message to the notifier window - @syntax: - notifier.message [-q|quiet] [-n|noanim] [-w[=<window_id:string>]!] [-i=<image_id:string>] [-t=<timeout:integer>] <messag:string> - @description: - Adds a message to the notifier window. - The notifier window is shown (if not already visible) - unless the -q switch is present. - The new message becomes the current message of the notifier - unless the user is already typing in the input window - and the typed message would be directed to a different window. - In that case the message is appended at the end of the - message queue and the user will be able to scroll to it - by using the proper notifier buttons.[br] - The <message> text can contain simple html tags: basically you are - allowed to use <b> and <i>. The usage of other - tags is possible but is discouraged since it tends to - mess up the message display. In particular you should avoid - any color and/or font specification since the notifier is - skinnable and you don't know which color will result in a visible text. - [b]Please note that the user can forcibly disable the notifier - for a limited period of time (a sort of "don't bug me" option).[/b] - @switches: - !sw: -n | --noanim - Do not animate - !sw: -w | --windowid - Causes the message gets attacched to the specified window and - the user is able to type commands in that window after - showing up the notifier input. If the "=<window_id>" part - is omitted then the current window is used.[br] - !sw: -i | --icon - If the -i=<image_id> switch is present then the - message has the specified image displayed. - See the [doc:image_id]documentation on the image identifier[/doc] - for more informations about the image_id parameter.[br] - !sw: -q | --quiet - If you use -q then you must explicitly call [cmd]notifier.show[/cmd] to - show the notifier. If the -n switch is present then - the show action will not be animated (the notifier - will be shown immediately instead of fading in). - Obviously -n has no meaning if -q is used.[br] - !sw: -t | --timeout - Set the message lifetime to <timeout> - Obviously this option has no meaning if the window is not going to be shown. - The timeout may be overriddent by new messages but only in the future. - If the timeout expires and is not overridden by any new message - then the window will be automatically hidden. - A zero timeout disables auto-hiding. - @seealso: - [cmd]notifier.show[/cmd] [cmd]notifier.hide[/cmd] [fnc]$notifier.isEnabled[/fnc]() - @examples: - [example] - notifier.message Hello world! - [cmd]notifier.hide[/cmd] - notifier.message -q This is a hidden message! - notifier.message -q -i=14 This is a second hidden message with an icon - [cmd]notifier.show[/cmd] - notifier.message -w This message has the current window associated - notifier.message -w=[fnc]$window[/fnc] This is equivalent to the above - notifier.message <b>Bold text</b> and normal text - [cmd]notifier.hide[/cmd] - notifier.message -t=10 This message will be shown only for 10 seconds - [/example] -*/ - -static bool notifier_kvs_cmd_message(KviKvsModuleCommandCall * c) -{ - QString szMessage; - KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("message",KVS_PT_STRING,0,szMessage) - KVSM_PARAMETERS_END(c) - - if(!g_pNotifierWindow) - g_pNotifierWindow = new KviNotifierWindow(); - - QString szIco=""; - QString szWnd=""; - - KviWindow * pWnd = c->window(); - - if(c->hasSwitch('w',"window_id")) - { - c->switches()->getAsStringIfExisting('w',"window_id",szWnd); - if(!szWnd.isEmpty()) - { - pWnd=g_pApp->findWindow(szWnd); - if(!pWnd) - c->warning(__tr2qs_ctx("The specified window does not exist","notifier")); - } - } - c->switches()->getAsStringIfExisting('i',"icon",szIco); - kvs_int_t uTime=0; - if(c->hasSwitch('t',"timeout")) - { - KviKvsVariant *time=c->getSwitch('t',"timeout"); - if(time) - { - bool bOk=time->asInteger(uTime); - if(!bOk) - { - uTime = 0; - c->warning(__tr2qs_ctx("The specified timeout is not valid, assuming 0","notifier")); - } - } else { - c->warning(__tr2qs_ctx("The -t switch expects a timeout in seconds","notifier")); - } - } - - g_pNotifierWindow->addMessage(pWnd,szIco,szMessage,uTime); - - if(!c->hasSwitch('q',"quiet")) - g_pNotifierWindow->doShow(!(c->hasSwitch('n',"new"))); - return true; -} - -/* - @doc: notifier.hide - @type: - command - @title: - notifier.hide - @short: - Hides the notifier window - @syntax: - notifier.hide [-n|--noanim] - @switches: - !sw: -n - Causes the hide operation is not animated. - @description: - Hide the notifier window - [b]Please note that the user can forcibly disable the notifier - for a limited period of time (a sort of "don't bug me" option).[/b] - @seealso: - [cmd]notifier.show[/cmd] [cmd]notifier.message[/cmd] [fnc]$notifier.isEnabled[/fnc] -*/ - -static bool notifier_kvs_cmd_hide(KviKvsModuleCommandCall * c) -{ - if(g_pNotifierWindow) g_pNotifierWindow->doHide(!(c->hasSwitch('n',"notanimated"))); - return true; -} - -/* - @doc: notifier.show - @type: - command - @title: - notifier.show - @short: - Shows the notifier window - @syntax: - notifier.show [-n|--noanim] - @switches: - !sw: -n - Disables the animation - @description: - Shows the notifier window if it is not already visible - If the -n switch is present then the show operation is - not animated.[br] - The notifier is shown ONLY if it contains some messages. - [b]Please note that the user can forcibly disable the notifier - for a limited period of time (a sort of "don't bug me" option).[/b] - @seealso: - [cmd]notifier.hide[/cmd] [cmd]notifier.message[/cmd] [fnc]$notifier.isEnabled[/fnc] -*/ - -static bool notifier_kvs_cmd_show(KviKvsModuleCommandCall * c) -{ - if(!g_pNotifierWindow)return true; - if(!g_pNotifierWindow->countTabs())return true; - - g_pNotifierWindow->setDisableHideOnMainWindowGotAttention(true); - g_pNotifierWindow->doShow(!(c->hasSwitch('n',"noanim"))); - - return true; -} -/* - @doc: notifier.isEnabled - @type: - function - @title: - $notifier.isEnabled - @short: - Returns 1 if the notifier window is enabled - @syntax: - <boolean> $notifier.isEnabled - @description: - Returns 1 if the notifier window is enabled and 0 otherwise. - The user can forcibly disable the notifier as a sort of "don't bug me" - feature for a limited period of time. When the notifier - is disabled the messages sent to it will not be shown.[br] - The only method that you (scripter) can use to forcibly - re-enable the notifier is to unload the module and - reload it...but [b]DON'T do it[/b] :)[br] - There is also a global option that allows forcibly disabling - the notifier forever, this option could be overridden with [cmd]option[/cmd] - instead.. but again [b]DON'T do it[/b] :)[br] - -*/ - -static bool notifier_kvs_fnc_isEnabled(KviKvsModuleFunctionCall * c) -{ - bool bCheck; - if(KVI_OPTION_BOOL(KviOption_boolForciblyDisableNotifier)) - bCheck=false; - else - bCheck=g_tNotifierDisabledUntil < kvi_unixTime(); - c->returnValue()->setBoolean(bCheck); - return true; -} - -static bool notifier_module_init(KviModule * m) -{ - - KVSM_REGISTER_SIMPLE_COMMAND(m,"message",notifier_kvs_cmd_message); - KVSM_REGISTER_SIMPLE_COMMAND(m,"show",notifier_kvs_cmd_show); - KVSM_REGISTER_SIMPLE_COMMAND(m,"hide",notifier_kvs_cmd_hide); - KVSM_REGISTER_FUNCTION(m,"isEnabled",notifier_kvs_fnc_isEnabled); - - return true; -} - -static bool notifier_module_cleanup(KviModule *m) -{ - if(g_pNotifierWindow) - { - delete g_pNotifierWindow; - g_pNotifierWindow = 0; - } - return true; -} - -static bool notifier_module_can_unload(KviModule *m) -{ - return (!g_pNotifierWindow); -} - -typedef struct _NotifierMessageSupaDupaParameterStruct -{ - KviWindow * pWindow; - QString szIcon; - QString szMessage; - unsigned int uMessageLifetime; // 0 means no hide -} NotifierMessageSupaDupaParameterStruct; - -static bool notifier_module_ctrl(KviModule *,const char *operation,void *param) -{ - if(kvi_strEqualCI("notifier::message",operation)) - { - NotifierMessageSupaDupaParameterStruct * p = (NotifierMessageSupaDupaParameterStruct *)param; - if(!p)return false; - - if(!g_pNotifierWindow) - g_pNotifierWindow = new KviNotifierWindow(); - - g_pNotifierWindow->addMessage(p->pWindow,p->szIcon,p->szMessage,p->uMessageLifetime); - g_pNotifierWindow->doShow(true); - - return true; - } - return false; -} - -KVIRC_MODULE( - "Notifier", - "2.0.0", - "Copyright (C) 2005:\n" \ - " Iacopo Palazzi (iakko at siena dot linux dot it)", - "KVIrc Client - Taskbar Notifier", - notifier_module_init, - notifier_module_can_unload, - notifier_module_ctrl, - notifier_module_cleanup -) +//==================================================================================
+//
+// File : libkvinotifier.cpp
+// Creation date : Tue Jul 7 2004 20:21:12 CEST by Szymon Stefanek
+//
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// 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_module.h"
+
+
+#include "notifierwindow.h"
+#include "notifiermessage.h"
+
+#include "kvi_kvs_variant.h"
+#include "kvi_app.h"
+#include "kvi_frame.h"
+#include "kvi_window.h"
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+#include "kvi_time.h"
+#include "kvi_options.h"
+
+#include <qsplitter.h>
+
+KviNotifierWindow * g_pNotifierWindow = 0;
+kvi_time_t g_tNotifierDisabledUntil = 0;
+
+/*
+ @doc: notifier.message
+ @type:
+ command
+ @title:
+ notifier.message
+ @short:
+ Adds a message to the notifier window
+ @syntax:
+ notifier.message [-q|quiet] [-n|noanim] [-w[=<window_id:string>]!] [-i=<image_id:string>] [-t=<timeout:integer>] <messag:string>
+ @description:
+ Adds a message to the notifier window.
+ The notifier window is shown (if not already visible)
+ unless the -q switch is present.
+ The new message becomes the current message of the notifier
+ unless the user is already typing in the input window
+ and the typed message would be directed to a different window.
+ In that case the message is appended at the end of the
+ message queue and the user will be able to scroll to it
+ by using the proper notifier buttons.[br]
+ The <message> text can contain simple html tags: basically you are
+ allowed to use <b> and <i>. The usage of other
+ tags is possible but is discouraged since it tends to
+ mess up the message display. In particular you should avoid
+ any color and/or font specification since the notifier is
+ skinnable and you don't know which color will result in a visible text.
+ [b]Please note that the user can forcibly disable the notifier
+ for a limited period of time (a sort of "don't bug me" option).[/b]
+ @switches:
+ !sw: -n | --noanim
+ Do not animate
+ !sw: -w | --windowid
+ Causes the message gets attacched to the specified window and
+ the user is able to type commands in that window after
+ showing up the notifier input. If the "=<window_id>" part
+ is omitted then the current window is used.[br]
+ !sw: -i | --icon
+ If the -i=<image_id> switch is present then the
+ message has the specified image displayed.
+ See the [doc:image_id]documentation on the image identifier[/doc]
+ for more informations about the image_id parameter.[br]
+ !sw: -q | --quiet
+ If you use -q then you must explicitly call [cmd]notifier.show[/cmd] to
+ show the notifier. If the -n switch is present then
+ the show action will not be animated (the notifier
+ will be shown immediately instead of fading in).
+ Obviously -n has no meaning if -q is used.[br]
+ !sw: -t | --timeout
+ Set the message lifetime to <timeout>
+ Obviously this option has no meaning if the window is not going to be shown.
+ The timeout may be overriddent by new messages but only in the future.
+ If the timeout expires and is not overridden by any new message
+ then the window will be automatically hidden.
+ A zero timeout disables auto-hiding.
+ @seealso:
+ [cmd]notifier.show[/cmd] [cmd]notifier.hide[/cmd] [fnc]$notifier.isEnabled[/fnc]()
+ @examples:
+ [example]
+ notifier.message Hello world!
+ [cmd]notifier.hide[/cmd]
+ notifier.message -q This is a hidden message!
+ notifier.message -q -i=14 This is a second hidden message with an icon
+ [cmd]notifier.show[/cmd]
+ notifier.message -w This message has the current window associated
+ notifier.message -w=[fnc]$window[/fnc] This is equivalent to the above
+ notifier.message <b>Bold text</b> and normal text
+ [cmd]notifier.hide[/cmd]
+ notifier.message -t=10 This message will be shown only for 10 seconds
+ [/example]
+*/
+
+static bool notifier_kvs_cmd_message(KviKvsModuleCommandCall * c)
+{
+ QString szMessage;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("message",KVS_PT_STRING,0,szMessage)
+ KVSM_PARAMETERS_END(c)
+
+ if(!g_pNotifierWindow)
+ g_pNotifierWindow = new KviNotifierWindow();
+
+ QString szIco="";
+ QString szWnd="";
+
+ KviWindow * pWnd = c->window();
+
+ if(c->hasSwitch('w',"window_id"))
+ {
+ c->switches()->getAsStringIfExisting('w',"window_id",szWnd);
+ if(!szWnd.isEmpty())
+ {
+ pWnd=g_pApp->findWindow(szWnd);
+ if(!pWnd)
+ c->warning(__tr2qs_ctx("The specified window does not exist","notifier"));
+ }
+ }
+ c->switches()->getAsStringIfExisting('i',"icon",szIco);
+ kvs_int_t uTime=0;
+ if(c->hasSwitch('t',"timeout"))
+ {
+ KviKvsVariant *time=c->getSwitch('t',"timeout");
+ if(time)
+ {
+ bool bOk=time->asInteger(uTime);
+ if(!bOk)
+ {
+ uTime = 0;
+ c->warning(__tr2qs_ctx("The specified timeout is not valid, assuming 0","notifier"));
+ }
+ } else {
+ c->warning(__tr2qs_ctx("The -t switch expects a timeout in seconds","notifier"));
+ }
+ }
+
+ g_pNotifierWindow->addMessage(pWnd,szIco,szMessage,uTime);
+
+ if(!c->hasSwitch('q',"quiet"))
+ g_pNotifierWindow->doShow(!(c->hasSwitch('n',"new")));
+ return true;
+}
+
+/*
+ @doc: notifier.hide
+ @type:
+ command
+ @title:
+ notifier.hide
+ @short:
+ Hides the notifier window
+ @syntax:
+ notifier.hide [-n|--noanim]
+ @switches:
+ !sw: -n
+ Causes the hide operation is not animated.
+ @description:
+ Hide the notifier window
+ [b]Please note that the user can forcibly disable the notifier
+ for a limited period of time (a sort of "don't bug me" option).[/b]
+ @seealso:
+ [cmd]notifier.show[/cmd] [cmd]notifier.message[/cmd] [fnc]$notifier.isEnabled[/fnc]
+*/
+
+static bool notifier_kvs_cmd_hide(KviKvsModuleCommandCall * c)
+{
+ if(g_pNotifierWindow) g_pNotifierWindow->doHide(!(c->hasSwitch('n',"notanimated")));
+ return true;
+}
+
+/*
+ @doc: notifier.show
+ @type:
+ command
+ @title:
+ notifier.show
+ @short:
+ Shows the notifier window
+ @syntax:
+ notifier.show [-n|--noanim]
+ @switches:
+ !sw: -n
+ Disables the animation
+ @description:
+ Shows the notifier window if it is not already visible
+ If the -n switch is present then the show operation is
+ not animated.[br]
+ The notifier is shown ONLY if it contains some messages.
+ [b]Please note that the user can forcibly disable the notifier
+ for a limited period of time (a sort of "don't bug me" option).[/b]
+ @seealso:
+ [cmd]notifier.hide[/cmd] [cmd]notifier.message[/cmd] [fnc]$notifier.isEnabled[/fnc]
+*/
+
+static bool notifier_kvs_cmd_show(KviKvsModuleCommandCall * c)
+{
+ if(!g_pNotifierWindow)return true;
+ if(!g_pNotifierWindow->countTabs())return true;
+
+ g_pNotifierWindow->setDisableHideOnMainWindowGotAttention(true);
+ g_pNotifierWindow->doShow(!(c->hasSwitch('n',"noanim")));
+
+ return true;
+}
+/*
+ @doc: notifier.isEnabled
+ @type:
+ function
+ @title:
+ $notifier.isEnabled
+ @short:
+ Returns 1 if the notifier window is enabled
+ @syntax:
+ <boolean> $notifier.isEnabled
+ @description:
+ Returns 1 if the notifier window is enabled and 0 otherwise.
+ The user can forcibly disable the notifier as a sort of "don't bug me"
+ feature for a limited period of time. When the notifier
+ is disabled the messages sent to it will not be shown.[br]
+ The only method that you (scripter) can use to forcibly
+ re-enable the notifier is to unload the module and
+ reload it...but [b]DON'T do it[/b] :)[br]
+ There is also a global option that allows forcibly disabling
+ the notifier forever, this option could be overridden with [cmd]option[/cmd]
+ instead.. but again [b]DON'T do it[/b] :)[br]
+
+*/
+
+static bool notifier_kvs_fnc_isEnabled(KviKvsModuleFunctionCall * c)
+{
+ bool bCheck;
+ if(KVI_OPTION_BOOL(KviOption_boolForciblyDisableNotifier))
+ bCheck=false;
+ else
+ bCheck=g_tNotifierDisabledUntil < kvi_unixTime();
+ c->returnValue()->setBoolean(bCheck);
+ return true;
+}
+
+static bool notifier_module_init(KviModule * m)
+{
+
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"message",notifier_kvs_cmd_message);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"show",notifier_kvs_cmd_show);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"hide",notifier_kvs_cmd_hide);
+ KVSM_REGISTER_FUNCTION(m,"isEnabled",notifier_kvs_fnc_isEnabled);
+
+ return true;
+}
+
+static bool notifier_module_cleanup(KviModule *m)
+{
+ if(g_pNotifierWindow)
+ {
+ delete g_pNotifierWindow;
+ g_pNotifierWindow = 0;
+ }
+ return true;
+}
+
+static bool notifier_module_can_unload(KviModule *m)
+{
+ return (!g_pNotifierWindow);
+}
+
+typedef struct _NotifierMessageSupaDupaParameterStruct
+{
+ KviWindow * pWindow;
+ QString szIcon;
+ QString szMessage;
+ unsigned int uMessageLifetime; // 0 means no hide
+} NotifierMessageSupaDupaParameterStruct;
+
+static bool notifier_module_ctrl(KviModule *,const char *operation,void *param)
+{
+ if(kvi_strEqualCI("notifier::message",operation))
+ {
+ NotifierMessageSupaDupaParameterStruct * p = (NotifierMessageSupaDupaParameterStruct *)param;
+ if(!p)return false;
+
+ if(!g_pNotifierWindow)
+ g_pNotifierWindow = new KviNotifierWindow();
+
+ g_pNotifierWindow->addMessage(p->pWindow,p->szIcon,p->szMessage,p->uMessageLifetime);
+ g_pNotifierWindow->doShow(KVI_OPTION_BOOL(KviOption_boolDisableNotifierFadein)?false:true);
+
+ return true;
+ }
+ return false;
+}
+
+KVIRC_MODULE(
+ "Notifier",
+ "2.0.0",
+ "Copyright (C) 2005:\n" \
+ " Iacopo Palazzi (iakko at siena dot linux dot it)",
+ "KVIrc Client - Taskbar Notifier",
+ notifier_module_init,
+ notifier_module_can_unload,
+ notifier_module_ctrl,
+ notifier_module_cleanup
+)
diff --git a/src/modules/notifier/notifier_QT4_vc05.vcproj b/src/modules/notifier/notifier_QT4_vc05.vcproj index c75474118..823a630bf 100644 --- a/src/modules/notifier/notifier_QT4_vc05.vcproj +++ b/src/modules/notifier/notifier_QT4_vc05.vcproj @@ -1,314 +1,313 @@ <?xml version="1.0" encoding="Windows-1252"?>
- <VisualStudioProject
- ProjectType="Visual C++"
- Version="8,00"
- Name="notifier"
- ProjectGUID="{2B3B9111-B275-404C-B565-29F08AD0471C}"
- RootNamespace="notifier"
- Keyword="Win32Proj"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)\win32build\bin\modules\"
- IntermediateDirectory="Debug"
- ConfigurationType="2"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=""$(ProjectDir)\..\..\kvirc\ui";"$(ProjectDir)\..\..\kvilib\core";"$(ProjectDir)\..\..\kvirc\module";"$(ProjectDir)\..\..\kvilib\config";"$(QTDIR)\include";"$(ProjectDir)\..\..\kvilib\system";"$(ProjectDir)\..\..\kvirc\uparser";"$(ProjectDir)\..\..\kvirc\sparser";"$(ProjectDir)\..\..\kvirc\kernel";"$(ProjectDir)\..\..\kvilib\ext";"$(ProjectDir)\..\..\kvilib\irc";"$(ProjectDir)\..\..\kvilib\tal";"$(ProjectDir)\..\..\kvirc\kvs";"$(ProjectDir)\..\..\kvilib\file";"$(ProjectDir)\..\..\kvilib\net";"$(QTDIR)\include\Qt3Support";"$(QTDIR)\include\QtCore\";"$(QTDIR)\include\QtGui";"$(QTDIR)\include\Qt";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtXml";"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;NOTIFIER_EXPORTS;_CRT_SECURE_NO_DEPRECATE;QT3_SUPPORT;"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="4"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib msvcrt.lib perl58.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib winmm.lib qt3supportd4.lib qtcored4.lib qtnetworkd4.lib qtguid4.lib "
- OutputFile="$(OutDir)/kvi$(ProjectName).dll"
- LinkIncremental="2"
- AdditionalLibraryDirectories=""$(SSLLIBDIR)";"$(PERLDIR)\lib\CORE";"$(QTDIR)\lib";"$(SolutionDir)\win32build\bin";"$(ZLIBLIBDIR)""
- GenerateManifest="true"
- IgnoreAllDefaultLibraries="true"
- GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/notifier.pdb"
- SubSystem="2"
- TurnOffAssemblyGeneration="true"
- ImportLibrary="$(OutDir)/notifier.lib"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- AdditionalManifestFiles="$(SolutionDir)/data/manifests/commctrl.manifest"
- EmbedManifest="true"
- VerboseOutput="true"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)\win32build\bin\modules"
- IntermediateDirectory="Release"
- ConfigurationType="2"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="1"
- InlineFunctionExpansion="2"
- EnableIntrinsicFunctions="true"
- FavorSizeOrSpeed="1"
- OmitFramePointers="true"
- EnableFiberSafeOptimizations="true"
- WholeProgramOptimization="true"
- AdditionalIncludeDirectories=""$(ProjectDir)\..\..\kvirc\ui";"$(ProjectDir)\..\..\kvilib\core";"$(ProjectDir)\..\..\kvirc\module";"$(ProjectDir)\..\..\kvilib\config";"$(QTDIR)\include";"$(ProjectDir)\..\..\kvilib\system";"$(ProjectDir)\..\..\kvirc\uparser";"$(ProjectDir)\..\..\kvirc\sparser";"$(ProjectDir)\..\..\kvirc\kernel";"$(ProjectDir)\..\..\kvilib\ext";"$(ProjectDir)\..\..\kvilib\irc";"$(ProjectDir)\..\..\kvilib\tal";"$(ProjectDir)\..\..\kvirc\kvs";"$(ProjectDir)\..\..\kvilib\file";"$(ProjectDir)\..\..\kvilib\net";"$(QTDIR)\include\Qt3Support";"$(QTDIR)\include\QtCore\";"$(QTDIR)\include\QtGui";"$(QTDIR)\include\Qt";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtXml";"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;NOTIFIER_EXPORTS;_CRT_SECURE_NO_DEPRECATE;QT3_SUPPORT;"
- StringPooling="true"
- MinimalRebuild="true"
- ExceptionHandling="1"
- RuntimeLibrary="0"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="true"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib msvcrt.lib perl58.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib winmm.lib qt3support4.lib qtcore4.lib qtnetwork4.lib qtgui4.lib "
- OutputFile="$(OutDir)/kvi$(ProjectName).dll"
- LinkIncremental="1"
- AdditionalLibraryDirectories=""$(SSLLIBDIR)";"$(PERLDIR)\lib\CORE";"$(QTDIR)\lib";"$(SolutionDir)\win32build\bin";"$(ZLIBLIBDIR)""
- GenerateManifest="true"
- IgnoreAllDefaultLibraries="true"
- GenerateDebugInformation="true"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- OptimizeForWindows98="1"
- LinkTimeCodeGeneration="1"
- TurnOffAssemblyGeneration="true"
- ImportLibrary="$(OutDir)/notifier.lib"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- AdditionalManifestFiles="$(SolutionDir)/data/manifests/commctrl.manifest"
- EmbedManifest="false"
- VerboseOutput="true"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\libkvinotifier.cpp"
- >
- </File>
- <File
- RelativePath=".\notifiermessage.cpp"
- >
- </File>
- <File
- RelativePath=".\notifierwindow.cpp"
- >
- </File>
- <File
- RelativePath=".\notifierwindowbody.cpp"
- >
- </File>
- <File
- RelativePath=".\notifierwindowborder.cpp"
- >
- </File>
- <File
- RelativePath=".\notifierwindowtabs.cpp"
- >
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- <File
- RelativePath=".\notifiermessage.h"
- >
- </File>
- <File
- RelativePath=".\notifiersettings.h"
- >
- </File>
- <File
- RelativePath=".\notifierwindow.h"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
- Outputs="$(InputDir)\m_$(InputName).moc"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
- Outputs="$(InputDir)\m_$(InputName).moc"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath=".\notifierwindowbody.h"
- >
- </File>
- <File
- RelativePath=".\notifierwindowborder.h"
- >
- </File>
- <File
- RelativePath=".\notifierwindowtabs.h"
- >
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
- Outputs="$(InputDir)\m_$(InputName).moc"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCustomBuildTool"
- CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
- Outputs="$(InputDir)\m_$(InputName).moc"
- />
- </FileConfiguration>
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
- </VisualStudioProject>
- +<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="notifier"
+ ProjectGUID="{2B3B9111-B275-404C-B565-29F08AD0471C}"
+ RootNamespace="notifier"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)\win32build\bin\modules\"
+ IntermediateDirectory="Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=""$(ProjectDir)\..\..\kvirc\ui";"$(ProjectDir)\..\..\kvilib\core";"$(ProjectDir)\..\..\kvirc\module";"$(ProjectDir)\..\..\kvilib\config";"$(QTDIR)\include";"$(ProjectDir)\..\..\kvilib\system";"$(ProjectDir)\..\..\kvirc\uparser";"$(ProjectDir)\..\..\kvirc\sparser";"$(ProjectDir)\..\..\kvirc\kernel";"$(ProjectDir)\..\..\kvilib\ext";"$(ProjectDir)\..\..\kvilib\irc";"$(ProjectDir)\..\..\kvilib\tal";"$(ProjectDir)\..\..\kvirc\kvs";"$(ProjectDir)\..\..\kvilib\file";"$(ProjectDir)\..\..\kvilib\net";"$(QTDIR)\include\Qt3Support";"$(QTDIR)\include\QtCore\";"$(QTDIR)\include\QtGui";"$(QTDIR)\include\Qt";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtXml";"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;NOTIFIER_EXPORTS;_CRT_SECURE_NO_DEPRECATE;QT3_SUPPORT;"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib msvcrt.lib perl58.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib winmm.lib qt3supportd4.lib qtcored4.lib qtnetworkd4.lib qtguid4.lib "
+ OutputFile="$(OutDir)/kvi$(ProjectName).dll"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories=""$(SSLLIBDIR)";"$(PERLDIR)\lib\CORE";"$(QTDIR)\lib";"$(SolutionDir)\win32build\bin";"$(ZLIBLIBDIR)""
+ GenerateManifest="true"
+ IgnoreAllDefaultLibraries="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/notifier.pdb"
+ SubSystem="2"
+ TurnOffAssemblyGeneration="true"
+ ImportLibrary="$(OutDir)/notifier.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="$(SolutionDir)/data/manifests/commctrl.manifest"
+ EmbedManifest="true"
+ VerboseOutput="true"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)\win32build\bin\modules"
+ IntermediateDirectory="Release"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ OmitFramePointers="true"
+ EnableFiberSafeOptimizations="true"
+ WholeProgramOptimization="true"
+ AdditionalIncludeDirectories=""$(ProjectDir)\..\..\kvirc\ui";"$(ProjectDir)\..\..\kvilib\core";"$(ProjectDir)\..\..\kvirc\module";"$(ProjectDir)\..\..\kvilib\config";"$(QTDIR)\include";"$(ProjectDir)\..\..\kvilib\system";"$(ProjectDir)\..\..\kvirc\uparser";"$(ProjectDir)\..\..\kvirc\sparser";"$(ProjectDir)\..\..\kvirc\kernel";"$(ProjectDir)\..\..\kvilib\ext";"$(ProjectDir)\..\..\kvilib\irc";"$(ProjectDir)\..\..\kvilib\tal";"$(ProjectDir)\..\..\kvirc\kvs";"$(ProjectDir)\..\..\kvilib\file";"$(ProjectDir)\..\..\kvilib\net";"$(QTDIR)\include\Qt3Support";"$(QTDIR)\include\QtCore\";"$(QTDIR)\include\QtGui";"$(QTDIR)\include\Qt";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtXml";"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;NOTIFIER_EXPORTS;_CRT_SECURE_NO_DEPRECATE;QT3_SUPPORT;"
+ StringPooling="true"
+ MinimalRebuild="true"
+ ExceptionHandling="1"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib msvcrt.lib perl58.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib winmm.lib qt3support4.lib qtcore4.lib qtnetwork4.lib qtgui4.lib "
+ OutputFile="$(OutDir)/kvi$(ProjectName).dll"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories=""$(SSLLIBDIR)";"$(PERLDIR)\lib\CORE";"$(QTDIR)\lib";"$(SolutionDir)\win32build\bin";"$(ZLIBLIBDIR)""
+ GenerateManifest="true"
+ IgnoreAllDefaultLibraries="true"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ LinkTimeCodeGeneration="1"
+ TurnOffAssemblyGeneration="true"
+ ImportLibrary="$(OutDir)/notifier.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ AdditionalManifestFiles="$(SolutionDir)/data/manifests/commctrl.manifest"
+ EmbedManifest="false"
+ VerboseOutput="true"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\libkvinotifier.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\notifiermessage.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\notifierwindow.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\notifierwindowbody.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\notifierwindowborder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\notifierwindowtabs.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\notifiermessage.h"
+ >
+ </File>
+ <File
+ RelativePath=".\notifiersettings.h"
+ >
+ </File>
+ <File
+ RelativePath=".\notifierwindow.h"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
+ Outputs="$(InputDir)\m_$(InputName).moc"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
+ Outputs="$(InputDir)\m_$(InputName).moc"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\notifierwindowbody.h"
+ >
+ </File>
+ <File
+ RelativePath=".\notifierwindowborder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\notifierwindowtabs.h"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
+ Outputs="$(InputDir)\m_$(InputName).moc"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\m_$(InputName).moc" "$(InputDir)\$(InputFileName)"
"
+ Outputs="$(InputDir)\m_$(InputName).moc"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/src/modules/notifier/notifiermessage.cpp b/src/modules/notifier/notifiermessage.cpp index 02d2bd900..4e088b409 100644 --- a/src/modules/notifier/notifiermessage.cpp +++ b/src/modules/notifier/notifiermessage.cpp @@ -1,102 +1,107 @@ -//============================================================================= -// -// File : notifiermessage.cpp -// Created on mar 02 nov 2004 02:41:18 by Iacopo -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2004 Iacopo <iakko@siena.linux.it> -// -// 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 "notifiermessage.h" -#include "notifierwindow.h" - -#include "kvi_iconmanager.h" -#include "kvi_config.h" -#include "kvi_app.h" -#include "kvi_window.h" - -#include "kvi_locale.h" -#include "kvi_frame.h" -#include "kvi_mirccntrl.h" -#include "kvi_options.h" - -/* -#ifdef COMPILE_ON_WINDOWS - #include <windows.h> -#endif - -#ifdef COMPILE_KDE_SUPPORT - #include <netwm.h> -#endif -*/ - -#include "kvi_tal_popupmenu.h" -#include <qapplication.h> -#include <qpainter.h> -#include <qimage.h> -#include <qdesktopwidget.h> -#include <qtooltip.h> - - -extern kvi_time_t g_tNotifierDisabledUntil; - -KviNotifierMessage::KviNotifierMessage(KviNotifierWindow * pNotifierWindow, QPixmap * pImage, const QString &szText) -{ - m_pText = new QSimpleRichText(KviMircCntrl::stripControlBytes(szText),pNotifierWindow->defaultFont()); - m_pText->setWidth(pNotifierWindow->textWidth()); - m_pImage = pImage; - m_bHistoric = false; -} - -KviNotifierMessage::~KviNotifierMessage() -{ - delete m_pText; - if(m_pImage)delete m_pImage; -} - -static void increase_transparency(QImage &buffer,QImage &srcimg,int iDivisor) -{ - buffer.create(srcimg.width(),srcimg.height(),32); - buffer.setAlphaBuffer(true); - - for(int y = 0;y < buffer.height();y++) - { - QRgb * dst = (QRgb *)buffer.scanLine(y); - QRgb * end = dst + buffer.width(); - QRgb * src = (QRgb *)srcimg.scanLine(y); - - while(dst < end) - { - *dst = qRgba(qRed(*src),qGreen(*src),qBlue(*src),qAlpha(*src) / iDivisor); - dst++; - src++; - } - } -} - -void KviNotifierMessage::setHistoric() -{ - m_bHistoric = true; - if(!m_pImage)return; - if(!m_pImage->hasAlphaChannel())return; - QImage tmp; - QImage out = m_pImage->convertToImage(); - increase_transparency(tmp,out,2); - m_pImage->convertFromImage(tmp); -} - +//=============================================================================
+//
+// File : notifiermessage.cpp
+// Created on mar 02 nov 2004 02:41:18 by Iacopo
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2004 Iacopo <iakko@siena.linux.it>
+//
+// 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 "notifiermessage.h"
+#include "notifierwindow.h"
+
+#include "kvi_iconmanager.h"
+#include "kvi_config.h"
+#include "kvi_app.h"
+#include "kvi_window.h"
+
+#include "kvi_locale.h"
+#include "kvi_frame.h"
+#include "kvi_mirccntrl.h"
+#include "kvi_options.h"
+
+/*
+#ifdef COMPILE_ON_WINDOWS
+ #include <windows.h>
+#endif
+
+#ifdef COMPILE_KDE_SUPPORT
+ #include <netwm.h>
+#endif
+*/
+
+#include <qapplication.h>
+#include <qpainter.h>
+#include <qimage.h>
+#include <qdesktopwidget.h>
+#include <qtooltip.h>
+
+#ifdef COMPILE_USE_QT4
+ #define QPopupMenu Q3PopupMenu
+ #include <q3popupmenu.h>
+#else
+ #include <qpopupmenu.h>
+#endif
+
+extern kvi_time_t g_tNotifierDisabledUntil;
+
+KviNotifierMessage::KviNotifierMessage(KviNotifierWindow * pNotifierWindow, QPixmap * pImage, const QString &szText)
+{
+ m_pText = new QSimpleRichText(KviMircCntrl::stripControlBytes(szText),pNotifierWindow->defaultFont());
+ m_pText->setWidth(pNotifierWindow->textWidth());
+ m_pImage = pImage;
+ m_bHistoric = false;
+}
+
+KviNotifierMessage::~KviNotifierMessage()
+{
+ delete m_pText;
+ if(m_pImage)delete m_pImage;
+}
+
+static void increase_transparency(QImage &buffer,QImage &srcimg,int iDivisor)
+{
+ buffer.create(srcimg.width(),srcimg.height(),32);
+ buffer.setAlphaBuffer(true);
+
+ for(int y = 0;y < buffer.height();y++)
+ {
+ QRgb * dst = (QRgb *)buffer.scanLine(y);
+ QRgb * end = dst + buffer.width();
+ QRgb * src = (QRgb *)srcimg.scanLine(y);
+
+ while(dst < end)
+ {
+ *dst = qRgba(qRed(*src),qGreen(*src),qBlue(*src),qAlpha(*src) / iDivisor);
+ dst++;
+ src++;
+ }
+ }
+}
+
+void KviNotifierMessage::setHistoric()
+{
+ m_bHistoric = true;
+ if(!m_pImage)return;
+ if(!m_pImage->hasAlphaChannel())return;
+ QImage tmp;
+ QImage out = m_pImage->convertToImage();
+ increase_transparency(tmp,out,2);
+ m_pImage->convertFromImage(tmp);
+}
+
diff --git a/src/modules/notifier/notifiermessage.h b/src/modules/notifier/notifiermessage.h index 8a86fa6a4..6094b2b97 100644 --- a/src/modules/notifier/notifiermessage.h +++ b/src/modules/notifier/notifiermessage.h @@ -1,97 +1,97 @@ -#ifndef _NOTIFIERMESSAGE_H_ -#define _NOTIFIERMESSAGE_H_ -//============================================================================= -// -// File : notifiermessage.h -// Created on mar 02 nov 2004 02:41:18 by -// Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// This file is part of the KVIrc distribution -// Copyright (C) 2004 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 <qwidget.h> -#include <qrect.h> -#include <qtimer.h> -#include <qpixmap.h> -#include <qimage.h> -#ifdef COMPILE_USE_QT4 - #include <q3simplerichtext.h> - #ifndef QSimpleRichText - #define QSimpleRichText Q3SimpleRichText - #endif -#else - #include <qsimplerichtext.h> -#endif -#include <qfont.h> -#include <qcolor.h> -#include <qlineedit.h> - - -#include "kvi_qstring.h" -#include "kvi_list.h" -#include "kvi_time.h" - -class KviWindow; -class KviNotifierWindow; - -class KviTalPopupMenu; - -class KviNotifierMessage -{ - friend class KviNotifierWindow; -public: - KviNotifierMessage(KviNotifierWindow * pNotifierWindow, QPixmap * pImage, const QString &szText); - ~KviNotifierMessage(); - -// ================================ -// Put members declaration below... -// ================================ -private: - -public: - -protected: - KviWindow * m_pWindow; - QPixmap * m_pImage; - QSimpleRichText * m_pText; - bool m_bHistoric; - -// ================================ -// Put methods declaration below... -// ================================ -private: - -public: - bool historic(){ return m_bHistoric; }; - void setHistoric(); - void setWindow(KviWindow * pWnd){ m_pWindow = pWnd; }; - QPixmap * image(){ return m_pImage; }; - QSimpleRichText * text(){ return m_pText; }; - -protected: - - -}; - -#define NUM_OLD_COLORS 6 - -#endif //!_NOTIFIERMESSAGE_H_ +#ifndef _NOTIFIERMESSAGE_H_
+#define _NOTIFIERMESSAGE_H_
+//=============================================================================
+//
+// File : notifiermessage.h
+// Created on mar 02 nov 2004 02:41:18 by
+// Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// This file is part of the KVIrc distribution
+// Copyright (C) 2004 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 <qwidget.h>
+#include <qrect.h>
+#include <qtimer.h>
+#include <qpixmap.h>
+#include <qimage.h>
+#include <qfont.h>
+#include <qcolor.h>
+#include <qlineedit.h>
+
+#include "kvi_qstring.h"
+#include "kvi_list.h"
+#include "kvi_time.h"
+
+#ifdef COMPILE_USE_QT4
+ #define QSimpleRichText Q3SimpleRichText
+ #define QPopupMenu Q3PopupMenu
+ #include <q3popupmenu.h>
+ #include <q3simplerichtext.h>
+#else
+ #include <qsimplerichtext.h>
+#endif
+
+class KviWindow;
+class KviNotifierWindow;
+
+class QPopupMenu;
+
+class KviNotifierMessage
+{
+ friend class KviNotifierWindow;
+public:
+ KviNotifierMessage(KviNotifierWindow * pNotifierWindow, QPixmap * pImage, const QString &szText);
+ ~KviNotifierMessage();
+
+// ================================
+// Put members declaration below...
+// ================================
+private:
+
+public:
+
+protected:
+ KviWindow * m_pWindow;
+ QPixmap * m_pImage;
+ QSimpleRichText * m_pText;
+ bool m_bHistoric;
+
+// ================================
+// Put methods declaration below...
+// ================================
+private:
+
+public:
+ bool historic(){ return m_bHistoric; };
+ void setHistoric();
+ void setWindow(KviWindow * pWnd){ m_pWindow = pWnd; };
+ QPixmap * image(){ return m_pImage; };
+ QSimpleRichText * text(){ return m_pText; };
+
+protected:
+
+
+};
+
+#define NUM_OLD_COLORS 6
+
+#endif //!_NOTIFIERMESSAGE_H_
diff --git a/src/modules/notifier/notifiersettings.h b/src/modules/notifier/notifiersettings.h index fe06b9b9e..07ee23ee4 100644 --- a/src/modules/notifier/notifiersettings.h +++ b/src/modules/notifier/notifiersettings.h @@ -1,66 +1,66 @@ -#ifndef _NOTIFIER_SETTINGS_H_ -#define _NOTIFIER_SETTINGS_H_ -//============================================================================= -// -// File : kvinotifierwindowcaption.h -// Created on gio 30 dic 2004 21:21:33 by Iacopo Palazzi -// -// This file is part of the Notifier - KVIrc Distribution distribution -// Copyright (C) 2004 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// 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. -// -//============================================================================= - -// Global settings for KviNotifier - - - -#define WDG_MIN_WIDTH 370 -#define WDG_MIN_HEIGHT 150 -#define WDG_BORDER_THICKNESS 5 -#define SPACING 2 - -#define WDG_ICON_OUT 0 -#define WDG_ICON_OVER 1 -#define WDG_ICON_CLICKED 2 -#define WDG_ICON_ON 3 -#define WDG_ICON_OFF 4 - -#define NTF_TABS_FONT_BASELINE 8 - -#define MAX_MESSAGES_IN_WINDOW 20 -// keep hidden messages for 600 seconds : 10 min -#define MAX_MESSAGE_LIFETIME 600 - -#define OPACITY_STEP 0.07 - -#define NUM_OLD_COLORS 6 - -#define WDG_UPSX 1 -#define WDG_UP 2 -#define WDG_UPDX 3 -#define WDG_DWNSX 4 -#define WDG_DWN 5 -#define WDG_DWNDX 6 -#define WDG_SX 7 -#define WDG_DX 8 - -#define m_mac_bkgColor QColor(236,233,216) // Light-brown color of notifier background widget - -enum State { Hidden, Showing, Visible, Hiding }; -enum TabState { Normal, Highlighted, Changed }; - -#endif //_NOTIFIER_SETTINGS_H_ +#ifndef _NOTIFIER_SETTINGS_H_
+#define _NOTIFIER_SETTINGS_H_
+//=============================================================================
+//
+// File : kvinotifierwindowcaption.h
+// Created on gio 30 dic 2004 21:21:33 by Iacopo Palazzi
+//
+// This file is part of the Notifier - KVIrc Distribution distribution
+// Copyright (C) 2004 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// 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.
+//
+//=============================================================================
+
+// Global settings for KviNotifier
+
+
+
+#define WDG_MIN_WIDTH 370
+#define WDG_MIN_HEIGHT 150
+#define WDG_BORDER_THICKNESS 5
+#define SPACING 2
+
+#define WDG_ICON_OUT 0
+#define WDG_ICON_OVER 1
+#define WDG_ICON_CLICKED 2
+#define WDG_ICON_ON 3
+#define WDG_ICON_OFF 4
+
+#define NTF_TABS_FONT_BASELINE 8
+
+#define MAX_MESSAGES_IN_WINDOW 20
+// keep hidden messages for 600 seconds : 10 min
+#define MAX_MESSAGE_LIFETIME 600
+
+#define OPACITY_STEP 0.07
+
+#define NUM_OLD_COLORS 6
+
+#define WDG_UPSX 1
+#define WDG_UP 2
+#define WDG_UPDX 3
+#define WDG_DWNSX 4
+#define WDG_DWN 5
+#define WDG_DWNDX 6
+#define WDG_SX 7
+#define WDG_DX 8
+
+#define m_mac_bkgColor QColor(236,233,216) // Light-brown color of notifier background widget
+
+enum State { Hidden, Showing, Visible, Hiding };
+enum TabState { Normal, Highlighted, Changed };
+
+#endif //_NOTIFIER_SETTINGS_H_
diff --git a/src/modules/notifier/notifierwindow.cpp b/src/modules/notifier/notifierwindow.cpp index fdf99a2b6..f682e77e5 100644 --- a/src/modules/notifier/notifierwindow.cpp +++ b/src/modules/notifier/notifierwindow.cpp @@ -1,1266 +1,1357 @@ -//================================================================================== -// -// File : notifierwindow.cpp -// Creation date : Tue Jul 6 2004 20:25:12 CEST by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2004 Iacopo Palazzi < iakko(at)siena.linux.it > -// -// This program is FREE software. You can redistribute it and/or -// modify it under the linkss 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 "notifiermessage.h" -#include "notifierwindow.h" - -#include "kvi_iconmanager.h" -#include "kvi_config.h" -#include "kvi_app.h" -#include "kvi_window.h" - -#include "kvi_locale.h" -#include "kvi_frame.h" -#include "kvi_mirccntrl.h" -#include "kvi_options.h" -#include "kvi_userinput.h" - -#include "kvi_tal_popupmenu.h" -#include <qapplication.h> -#include <qpainter.h> -#include <qimage.h> -#include <qdesktopwidget.h> -#include <qtooltip.h> -#include <qevent.h> -#include <qpainter.h> -#include <qpen.h> -#include <qfontmetrics.h> -#include <qregexp.h> - -#include "notifierwindowtabs.h" -#include "notifierwindowbody.h" -#include "notifierwindowborder.h" - -extern KviNotifierWindow * g_pNotifierWindow; - -KviNotifierWindow::KviNotifierWindow() -: QWidget(0,"kvirc_notifier_window", -#ifdef COMPILE_ON_WINDOWS - Qt::WStyle_Customize | - Qt::WStyle_NoBorder | - Qt::WStyle_Tool | - Qt::WStyle_StaysOnTop) -#else - Qt::WStyle_Customize | - Qt::WStyle_NoBorder | -#ifndef Q_OS_MACX - Qt::WStyle_Tool | - Qt::WX11BypassWM | -#endif - Qt::WStyle_StaysOnTop) -#endif -{ - - g_pNotifierWindow = this; - - m_eState = Hidden; - m_dOpacity = 0.0; - m_pShowHideTimer = 0; - m_pBlinkTimer = 0; - m_tAutoHideAt = 0; - m_tStartedAt=0; - m_pAutoHideTimer = 0; - m_pProgressTimer = 0; - - m_pWndBorder = new KviNotifierWindowBorder(); - - reloadImages(); - - KviStr buffer; - g_pApp->getReadOnlyConfigPath(buffer,"libkvinotifier.kvc",KviApp::ConfigPlugins,true); - - KviConfig cfg(buffer.ptr() - ,KviConfig::Read); - - cfg.setGroup("NotifierSkin"); - - QString szFamily = cfg.readEntry("TextFontFamily","Arial"); - m_pDefaultFont = new QFont(szFamily,cfg.readIntEntry("TextFontSize",9)); - szFamily = cfg.readEntry("TitleFontFamily","Arial"); - m_pTitleFont = new QFont(szFamily,cfg.readIntEntry("TitleFontSize",9)); - - m_clrCurText = cfg.readColorEntry("CurTextColor",QColor(40,0,0)); - m_clrHistoricText = cfg.readColorEntry("HistoricTextColor",QColor(125,125,125)); - m_clrTitle = QColor(255,255,255); //cfg.readColorEntry("TitleColor",QColor(0,0,0)); - for(int i=0;i<NUM_OLD_COLORS;i++) - { - KviStr szKey; - szKey.sprintf("OldTextColor%d",i + 1); - m_clrOldText[i] = cfg.readColorEntry(szKey.ptr(),QColor(90,90,90)); - } - - m_iBlinkTimeout = cfg.readIntEntry("BlinkTimeout",650); - if(m_iBlinkTimeout < 100)m_iBlinkTimeout = 100; - m_iInputHeight = cfg.readIntEntry("InputHeight",20); - if(m_iInputHeight < 10)m_iInputHeight = 10; - -#ifdef COMPILE_USE_QT4 - setAttribute(Qt::WA_NoSystemBackground); // This disables automatic qt double buffering
- setAutoFillBackground(false); - setFocusPolicy(Qt::NoFocus); -#else - setBackgroundMode(QWidget::NoBackground); - setFocusPolicy(QWidget::NoFocus); -#endif - setMouseTracking(true); - //setCursor(m_cursor); - - m_pLineEdit = new QLineEdit(this); - m_pLineEdit->setGeometry(0,0,0,0); - m_pLineEdit->hide(); - m_pLineEdit->installEventFilter(this); - connect(m_pLineEdit,SIGNAL(returnPressed()),this,SLOT(returnPressed())); - - szFamily = cfg.readEntry("InputFontFamily","Arial"); - m_pLineEdit->setFont(QFont(szFamily,cfg.readIntEntry("InputFontSize",9))); - - m_bBlinkOn = false; - - m_bCloseDown = false; - m_bPrevDown = false; - m_bNextDown = false; - m_bWriteDown = false; - - m_bKeyShiftPressed = false; - m_bKeyAltPressed = false; - - m_bLeftButtonIsPressed = false; - m_bDiagonalResizing = false; - m_bResizing = false; - - m_pContextPopup = 0; - m_pDisablePopup = 0; - - m_bDragging = false; - - m_bDisableHideOnMainWindowGotAttention = false; - - // Positioning the notifier bottom-right - int iWidth = m_pixBackground.width(); - int iHeight = m_pixBackground.height(); - QDesktopWidget * w = QApplication::desktop(); - QRect r = w->availableGeometry(w->primaryScreen()); //w->screenGeometry(w->primaryScreen()); - - /*debug("r.x(),r.y(): %d,%d",r.x(),r.y()); - debug("r.width(),r.height(): %d,%d",r.width(),r.height());*/ - - m_wndRect.setRect( r.x() + r.width() - (iWidth + SPACING), r.y() + r.height() - (iHeight + SPACING), iWidth, iHeight ); - - //m_pWndBorder = new KviNotifierWindowBorder(); - m_pWndTabs = new KviNotifierWindowTabs(m_pWndBorder->tabsRect(),this); - m_pWndBody = new KviNotifierWindowBody(m_pWndBorder->bodyRect()); - - m_pProgressBar = new KviNotifierWindowProgressBar(m_pWndBorder->progressRect()); - - // FIXME: Ugly global-font initialization.. - QFontMetrics titleFontMetrics(*m_pTitleFont); - m_pWndBorder->centerTitle(titleFontMetrics.height()); - - connect(g_pApp,SIGNAL(reloadImages()),this,SLOT(reloadImages())); - - hide(); -} - -KviNotifierWindow::~KviNotifierWindow() -{ - stopShowHideTimer(); - stopBlinkTimer(); - stopAutoHideTimer(); - delete m_pDefaultFont; - delete m_pTitleFont; - delete m_pWndBorder; - delete m_pWndTabs; - delete m_pWndBody; -} - -int KviNotifierWindow::countTabs() { - return m_pWndTabs->count(); -} - -void KviNotifierWindow::reloadImages() -{ - QPixmap * p; - if((p = g_pIconManager->getPixmap("notifier_background.png"))) - m_pixBckgrnd = *p; - -#ifdef COMPILE_USE_QT4 - setMask(p->mask()); -#else - if(p->mask()) - setMask(*(p->mask())); -#endif - m_pixBackground = m_pixBckgrnd; - m_pixBackgroundHighlighted = m_pixBckgrnd; - m_pWndBorder->resize(m_pixBackground.size()); -} - - -void KviNotifierWindow::addMessage(KviWindow * pWnd,const QString &szImageId,const QString &szText,unsigned int uMessageTime) -{ - QPixmap * pIcon; - QString szMessage=szText; - szMessage.replace( QRegExp("\r([^\r])*\r([^\r])+\r"), "\\2" ); - if(szImageId.isEmpty())pIcon = 0; - else pIcon = g_pIconManager->getImage(szImageId); - - KviNotifierMessage * m = new KviNotifierMessage(this,pIcon ? new QPixmap(*pIcon) : 0,szMessage); - - m_pWndTabs->addMessage(pWnd, m); // Adds a tab about the sender pWnd - - if(!isActiveWindow()) - startBlinking(); - - if(uMessageTime > 0) - { - kvi_time_t tAutoHide = kvi_unixTime() + uMessageTime; - if(m_tAutoHideAt < tAutoHide) - { - m_tAutoHideAt = tAutoHide; - if(m_eState == Visible)startAutoHideTimer(); - } - } else { - // never hide - stopAutoHideTimer(); - m_tAutoHideAt = 0; - } - - if(pWnd) - { - if(pWnd->hasAttention())m_bDisableHideOnMainWindowGotAttention = true; - } - - //m_pWndTabs->setCurrentMessage(m); - if(isVisible())update(); - // else the line edit was hidden -} - - -int KviNotifierWindow::textWidth() { - return m_pWndBody->textRect().width() - 20; -}; - -void KviNotifierWindow::stopShowHideTimer() -{ - if(!m_pShowHideTimer)return; - delete m_pShowHideTimer; - m_pShowHideTimer = 0; -} - -void KviNotifierWindow::stopBlinkTimer() -{ - if(!m_pBlinkTimer)return; - delete m_pBlinkTimer; - m_pBlinkTimer = 0; -} - -void KviNotifierWindow::stopAutoHideTimer() -{ - if(m_pProgressTimer) delete m_pProgressTimer; - m_pProgressTimer = 0; - - if(!m_pAutoHideTimer)return; - delete m_pAutoHideTimer; - m_pAutoHideTimer = 0; - m_pProgressBar->setProgress(0); -} - -void KviNotifierWindow::computeRect() -{ - int iWidth = m_pixBackground.width(); - int iHeight = m_pixBackground.height(); - m_pWndBorder->setGeometry(QPoint(x(),y()), QSize(iWidth,iHeight)); - update(); -} - -void KviNotifierWindow::doShow(bool bDoAnimate) -{ - if(KVI_OPTION_BOOL(KviOption_boolForciblyDisableNotifier))return; - - kvi_time_t tNow = kvi_unixTime(); - if(g_tNotifierDisabledUntil > tNow)return; - g_tNotifierDisabledUntil = 0; - - switch(m_eState) - { - case Showing: - // already showing up - return; - break; - case Visible: - // already visible - return; - break; - case Hiding: - // ops.. hiding! - m_eState = Showing; - break; - case Hidden: - stopShowHideTimer(); - stopBlinkTimer(); - computeRect(); - m_bDragging = false; - m_bCloseDown = false; - m_bPrevDown = false; - m_bNextDown = false; - m_bWriteDown = false; - m_bBlinkOn = false; - m_imgDesktop = QPixmap::grabWindow( - QApplication::desktop()->winId(), - m_wndRect.x(), - m_wndRect.y(), - m_wndRect.width(), - m_wndRect.height()).convertToImage(); - - // QPixmap tmp = QPixmap::grabWindow( QApplication::desktop()->winId(),m_wndRect.x(), m_wndRect.y(), m_wndRect.width(), m_wndRect.height()); - // tmp.save("/root/pix.png","PNG"); - m_pixForeground.resize(m_pixBackground.size()); - m_imgBuffer.create(m_pixBackground.width(),m_pixBackground.height(),32); - if(bDoAnimate) - { - m_pShowHideTimer = new QTimer(); - connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); - m_dOpacity = OPACITY_STEP; - m_eState = Showing; - show(); - m_pShowHideTimer->start(100); - } else { - m_dOpacity = 1.0; - m_eState = Visible; - show(); - startAutoHideTimer(); - } - break; - } -} - -bool KviNotifierWindow::shouldHideIfMainWindowGotAttention() -{ - if(m_bDisableHideOnMainWindowGotAttention)return false; - KviNotifierWindowTab * t = m_pWndTabs->currentTab(); - if(!t)return false; - if(!t->window())return false; - return t->window()->hasAttention(); -} - - -void KviNotifierWindow::heartbeat() -{ - switch(m_eState) - { - case Hidden: - hideNow(); - break; - case Visible: - stopShowHideTimer(); - m_dOpacity = 1.0; - if(!isVisible())show(); //!!! - break; - case Showing: - // if the main window got attention while - // showing up then just hide now - if(shouldHideIfMainWindowGotAttention()) - { - m_eState = Hiding; - } else { - m_dOpacity += OPACITY_STEP; - if(m_dOpacity >= 1.0) - { - m_dOpacity = 1.0; - m_eState = Visible; - stopShowHideTimer(); - startBlinking(); - startAutoHideTimer(); - } - if(!isVisible())show(); //!!! - if(m_pLineEdit->isVisible())m_pLineEdit->hide(); - update(); - } - break; - case Hiding: - m_dOpacity -= OPACITY_STEP; - if(m_pLineEdit->isVisible())m_pLineEdit->hide(); - if(m_dOpacity <= 0.0)hideNow(); - else update(); - break; - } -} - -void KviNotifierWindow::hideNow() -{ - stopBlinkTimer(); - stopShowHideTimer(); - stopAutoHideTimer(); - m_eState = Hidden; - m_dOpacity = 0.0; - m_tAutoHideAt = 0; - - if(m_pLineEdit->isVisible())m_pLineEdit->hide(); - hide();//if(isVisible())hide(); -} - -void KviNotifierWindow::doHide(bool bDoAnimate) -{ - stopAutoHideTimer(); - - switch(m_eState) - { - case Hiding: - // already hiding up - if(!bDoAnimate)hideNow(); - return; - break; - case Hidden: - // already hidden - if(isVisible())hideNow(); // !!! - return; - break; - case Showing: - // ops.. hiding! - if(!bDoAnimate)hideNow(); - else { - // continue animating, but hide - m_eState = Hiding; - } - break; - case Visible: - stopBlinkTimer(); - stopShowHideTimer(); - if(m_pLineEdit->isVisible())m_pLineEdit->hide(); - if((!bDoAnimate) || (x() != m_pWndBorder->x()) || (y() != m_pWndBorder->y())) - { - // the user asked to not animate or - // the window has been moved and the animation would suck anyway - // just hide quickly - hideNow(); - } else { - m_pShowHideTimer = new QTimer(); - connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); - m_dOpacity = 1.0 - OPACITY_STEP; - m_eState = Hiding; - update(); - m_pShowHideTimer->start(100); - } - break; - } -} - -void KviNotifierWindow::showEvent(QShowEvent *e) -{ - computeRect(); - setGeometry(m_wndRect); // w_win = w_wndRect -} - -void KviNotifierWindow::hideEvent(QHideEvent * e) -{ - stopBlinkTimer(); - stopShowHideTimer(); - stopAutoHideTimer(); - m_eState = Hidden; // make sure it's true - m_tAutoHideAt = 0; // make sure it's true - markAllMessagesAsHistoric(); - m_bDisableHideOnMainWindowGotAttention = false; -} - -void KviNotifierWindow::startBlinking() -{ - stopBlinkTimer(); - m_bBlinkOn = false; - if(!KVI_OPTION_BOOL(KviOption_boolDisableNotifierFlashing)) - { - m_pBlinkTimer = new QTimer(); - connect(m_pBlinkTimer,SIGNAL(timeout()),this,SLOT(blink())); - m_iBlinkCount = 0; - m_pBlinkTimer->start(m_iBlinkTimeout); - } -} - -void KviNotifierWindow::startAutoHideTimer() -{ - stopAutoHideTimer(); - m_tStartedAt = kvi_unixTime(); - m_qtStartedAt.start(); - if(m_tAutoHideAt <= m_tStartedAt)return; - - int nSecs = m_tAutoHideAt - m_tStartedAt; - if(nSecs < 5)nSecs = 5; - m_pAutoHideTimer = new QTimer(); - connect(m_pAutoHideTimer,SIGNAL(timeout()),this,SLOT(autoHide())); - m_pAutoHideTimer->start(nSecs * 1000); - - m_pProgressTimer= new QTimer(); - connect(m_pProgressTimer,SIGNAL(timeout()),this,SLOT(progressUpdate())); - m_pProgressTimer->start(60); -} - -void KviNotifierWindow::autoHide() -{ - m_tAutoHideAt = 0; - stopAutoHideTimer(); - doHide(true); -} - -void KviNotifierWindow::blink() -{ - m_iBlinkCount++; - m_bBlinkOn = !m_bBlinkOn; - - if(m_iBlinkCount > 100) - { - // stop blinking at a certain point and remain highlighted - m_bBlinkOn = true; - stopBlinkTimer(); - } else { - // if the main window got attention while - // showing up then just hide now - if(shouldHideIfMainWindowGotAttention()) - { - doHide(false); // don't animate: the background has almost surely changed - return; - } - } - update(); -} - -void KviNotifierWindow::markAllMessagesAsHistoric() -{ - m_pWndTabs->markAllMessagesAsHistoric(); -} - - -static void blend_images(QImage &buffer,QImage &background,QImage &foreground,double dValue) -{ - for(int y = 0;y < buffer.height();y++) - { - QRgb * dst = (QRgb *)buffer.scanLine(y); - QRgb * end = dst + buffer.width(); - QRgb * bkg = (QRgb *)background.scanLine(y); - QRgb * fgn = (QRgb *)foreground.scanLine(y); - - double dRemaining = 1.0 - dValue; - - while(dst < end) - { - *dst = qRgb( - (int)((qRed(*bkg) * dRemaining) + (qRed(*fgn) * dValue)), - (int)((qGreen(*bkg) * dRemaining) + (qGreen(*fgn) * dValue)), - (int)((qBlue(*bkg) * dRemaining) + (qBlue(*fgn) * dValue)) - ); - dst++; - bkg++; - fgn++; - } - - } -} - -void KviNotifierWindow::paintEvent(QPaintEvent * e) -{ - -/* - if(m_bBlinkOn) - bitBlt(&m_pixForeground,QPoint(0,0),&m_pixBackgroundHighlighted); - else - bitBlt(&m_pixForeground,QPoint(0,0),&m_pixBackground); - - QPainter p(&m_pixForeground); -*/ - - bitBlt(&m_pixForeground,QPoint(0,0),&m_pixBackground); - redrawWindow(); - redrawText(); - - bitBlt(this,QPoint(0,0),&m_pixForeground); -} - -void KviNotifierWindow::redrawText() -{ - QPainter p(&m_pixForeground); - - // the current tab - KviNotifierWindowTab * tab = m_pWndTabs->currentTab(); - if(!tab)return; - - // it's message list - KviPtrList<KviNotifierMessage> * l = tab->messageList(); - if(!l)return; - if(l->isEmpty())return; - - // the current message - KviNotifierMessage * cur = tab->currentMessage(); - if(!cur)cur = l->last(); - - // this is useful in several places - KviNotifierMessage * last = l->last(); - - // make sure that we can loop - int iIdx = l->findRef(cur); - if(iIdx == -1) - { - tab->setCurrentMessage(last); - cur = last; - iIdx = l->findRef(cur); - } - - int y = m_pWndBody->textRect().y() + m_pWndBody->textRect().height(); - - if(m_pLineEdit->isVisible())y -= (m_pLineEdit->height() + 4); - - QColorGroup grp = colorGroup(); - - int idx = iIdx; - KviNotifierMessage * m = cur; - while(m && (y > m_pWndBody->textRect().y())) - { - int iHeight = m->text()->height(); - if(iHeight < 18)iHeight = 18; - y -= iHeight; - if(m->historic()) - { - grp.setColor(QColorGroup::Text,m_clrHistoricText); - } else { - if(m == last) - grp.setColor(QColorGroup::Text,m_clrCurText); - else { - int iClrIdx = l->count() - (idx + 2); - if(iClrIdx < 0)iClrIdx = 0; - else if(iClrIdx >= NUM_OLD_COLORS)iClrIdx = (NUM_OLD_COLORS - 1); - grp.setColor(QColorGroup::Text,m_clrOldText[iClrIdx]); - } - } - int iMaxY = y > m_pWndBody->textRect().y() ? y : m_pWndBody->textRect().y(); - QRect clip(m_pWndBody->textRect().x(),iMaxY,m_pWndBody->textRect().width(),iHeight); - - m->text()->draw(&p,m_pWndBody->textRect().x(),y,clip,grp); // - m = l->prev(); - idx--; - } - - p.setPen(QPen(m_clrTitle)); - p.setFont(*m_pTitleFont); - QString title; - KviQString::sprintf(title,"[%d/%d]",iIdx + 1,l->count()); - - if(tab->window()) - { - title += " "; - title += tab->window()->plainTextCaption(); - } - p.drawText(m_pWndBorder->titleRect(),Qt::AlignLeft | Qt::SingleLine,title); - p.end(); -} - -void KviNotifierWindow::mouseMoveEvent(QMouseEvent * e) -{ - - bool bCursorSetted = false; - //debug ("move on x,y: %d,%d", e->pos().x(), e->pos().y()); - -// if (!m_bLeftButtonIsPressed) { - - if(m_bKeyAltPressed && m_bDragging) { - move( e->globalPos() - m_pntDrag ); - setCursor(Qt::SizeAllCursor); - bCursorSetted = true; - } else { - if(m_pWndTabs->currentTab()) - { - /* ### MOUSE-MOVE-EVENT -> m_pWndTabs ### */ - if (m_pWndTabs->rect().contains(e->pos())) { - m_pWndTabs->mouseMoveEvent(e); - bCursorSetted =true; - } else { - m_pWndTabs->leaveEvent(); - } - - if (m_pWndBody->rect().contains(e->pos())) { - if (m_pWndBody->rctWriteIcon().contains(e->pos())) { - m_pWndBody->setWriteIcon(WDG_ICON_ON); - setCursor(Qt::PointingHandCursor); - bCursorSetted = true; - } else { - m_pWndBody->setWriteIcon(WDG_ICON_OFF); - } - } - } - } - if(!bCursorSetted) setCursor(Qt::ArrowCursor); - /* ### END ### */ -} - -void KviNotifierWindow::mousePressEvent(QMouseEvent * e) -{ - - // stop blinking first of all :) - bool bWasBlinkOn = m_bBlinkOn; - m_bBlinkOn = false; - stopBlinkTimer(); - m_tAutoHideAt = 0; - stopAutoHideTimer(); - - setActiveWindow(); - setFocus(); - - m_pntClick = e->pos(); - - if(e->button() == Qt::RightButton) - { - contextPopup(e->pos()); - return; - } else if(e->button() == Qt::LeftButton) { - m_bLeftButtonIsPressed = true; - } - - if(checkResizing(m_pntClick)) goto sartelo; - - if(m_pWndTabs->rect().contains(e->pos())) - { - m_pWndTabs->mousePressEvent(e); - goto sartelo; - } - - if( m_bKeyAltPressed) { - m_bDragging = true; - m_pntDrag = e->pos(); - m_pntPos = pos(); - goto sartelo; - } - - //debug ("x,y: %d,%d - width,height: %d,%d", m_pWndBorder->rect().x(),m_pWndBorder->rect().y(),m_pWndBorder->rect().width(),m_pWndBorder->rect().height()); - - if (m_pWndBorder->rect().contains(e->pos())) { - if(m_pWndTabs->currentTab()) - { - //debug ("Clicked on m_pWndBody->textRect()"); - if(m_pWndBody->rctWriteIcon().contains(e->pos())) - { - m_pWndBody->setWriteIcon(WDG_ICON_CLICKED); - showLineEdit(!(m_pLineEdit->isVisible())); - } - - if(m_pWndBody->rctPrevIcon().contains(e->pos()) && m_pWndBody->prevIconState()!=WDG_ICON_OFF) - { - m_bPrevDown = true; - m_pWndBody->setPrevIcon(WDG_ICON_CLICKED); - prevButtonClicked(); - } - - if(m_pWndBody->rctNextIcon().contains(e->pos()) && m_pWndBody->nextIconState()!=WDG_ICON_OFF) - { - m_bNextDown = true; - m_pWndBody->setNextIcon(WDG_ICON_CLICKED); - nextButtonClicked(); - } - } - goto sartelo; - } - - if(bWasBlinkOn) goto sartelo; else return; - -sartelo: - update(); - -} - -void KviNotifierWindow::mouseReleaseEvent(QMouseEvent * e) -{ - m_bWriteDown = false; - m_bNextDown = false; - m_bPrevDown = false; - m_bCloseDown = false; - m_bLeftButtonIsPressed = false; - m_bResizing = false; - - //m_pWndBody->setWriteIcon(WDG_ICON_ON); - m_pWndBody->setNextIcon(WDG_ICON_ON); - m_pWndBody->setPrevIcon(WDG_ICON_ON); - m_pWndTabs->setCloseTabIcon(WDG_ICON_OFF); - - if(m_bDragging) - { - m_bDragging = false; - if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); - return; - } - - if(m_pWndBorder->captionRect().contains(e->pos())) { - - if(m_pWndBorder->closeRect().contains(e->pos())) { - hideNow(); - } else { - update(); - } - - } - - if(m_pWndTabs->rect().contains(e->pos())) - { - m_pWndTabs->mouseReleaseEvent(e); - } - - setCursor(-1); - -} - -void KviNotifierWindow::mouseDoubleClickEvent(QMouseEvent * e) -{ - if(!m_pWndBody->textRect().contains(e->pos())) - { - QWidget::mouseDoubleClickEvent(e); - return; - } - - KviNotifierWindowTab * tab = m_pWndTabs->currentTab(); - if(!tab)return; - - if(!tab->window())return; - - hideNow(); - delayedRaise(tab->window()); -} - -void KviNotifierWindow::keyPressEvent(QKeyEvent * e) -{ - if (e->key()==Qt::Key_Shift) { - m_bKeyShiftPressed = true; - return; - } - - if (e->key()==Qt::Key_Alt) { - m_bKeyAltPressed = true; - setCursor(Qt::SizeAllCursor); - return; - } - - if (e->key()==Qt::Key_Left && m_bKeyShiftPressed) { - m_pWndTabs->prev(); - return; - } - if (e->key()==Qt::Key_Right && m_bKeyShiftPressed) { - m_pWndTabs->next(); - return; - } - - if (e->key()==Qt::Key_Escape) { - hideNow(); - return; - } -} - -void KviNotifierWindow::keyReleaseEvent(QKeyEvent * e) -{ - if (e->key()==Qt::Key_Shift) { - m_bKeyShiftPressed = false; - } - - if (e->key()==Qt::Key_Alt) { - m_bKeyAltPressed = false; - setCursor(Qt::ArrowCursor); - m_bDragging = false; - return; - } -} - -void KviNotifierWindow::delayedRaise(KviWindow * pWnd) -{ - m_pWindowToRaise = pWnd; - QTimer::singleShot(0,this,SLOT(delayedRaiseSlot())); -} - -void KviNotifierWindow::delayedRaiseSlot() -{ - if(!m_pWindowToRaise)return; - if(!g_pApp->windowExists(m_pWindowToRaise))return; - - if(m_pWindowToRaise->mdiParent()) - { - if(!m_pWindowToRaise->frame()->isVisible()) - m_pWindowToRaise->frame()->show(); - - m_pWindowToRaise->frame()->raise(); - ((QWidget *)(m_pWindowToRaise->frame()))->setActiveWindow(); - m_pWindowToRaise->frame()->setFocus(); - } - - m_pWindowToRaise->delayedAutoRaise(); -} - -bool KviNotifierWindow::checkResizing(QPoint e) -{ - if (e.y()<WDG_BORDER_THICKNESS) { - if (e.x()<WDG_BORDER_THICKNESS) { - //// UP LEFT CORNER //// - setCursor(Qt::SizeFDiagCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_UPSX; - } - } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) { - //// UP RIGHT CORNER //// - setCursor(Qt::SizeBDiagCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_UPDX; - } - } else { - //// UP SIDE //// - setCursor(Qt::SizeVerCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_UP; - } } - } else if (e.y() > (size().height()-WDG_BORDER_THICKNESS)) { - if (e.x()<WDG_BORDER_THICKNESS) { - //// DOWN LEFT CORNER //// - setCursor(Qt::SizeBDiagCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_DWNSX; - } - } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) { - //// DOWN RIGHT CORNER //// - setCursor(Qt::SizeFDiagCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_DWNDX; - } - } else { - //// DOWN SIDE //// - setCursor(Qt::SizeVerCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_DWN; - } - } - } else { - if (e.x()<WDG_BORDER_THICKNESS) { - //// LEFT SIZE //// - setCursor(Qt::SizeHorCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_SX; - } - } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) { - //// RIGHT SIZE //// - setCursor(Qt::SizeHorCursor); - if (m_bLeftButtonIsPressed) { - m_bResizing = true; - m_whereResizing = WDG_DX; - } - } else { - //// ELSEWHERE //// - m_whereResizing = 0; - m_bResizing = false; - setCursor(-1); - } - } - return m_bResizing; -}; - - - -void KviNotifierWindow::resize(QPoint p, bool up) -{ - //QPoint aux = mapToGlobal(p); - - if (m_whereResizing==WDG_UPSX || m_whereResizing==WDG_SX || m_whereResizing==WDG_DWNSX) { - if ( x()+width()-cursor().pos().x()<WDG_MIN_WIDTH ) - m_wndRect.setLeft(x()+width()-WDG_MIN_WIDTH); - else - m_wndRect.setLeft(cursor().pos().x()); - } - - if (m_whereResizing==WDG_UPSX || m_whereResizing==WDG_UP || m_whereResizing==WDG_UPDX) { - if ( y()+height()-cursor().pos().y()<WDG_MIN_HEIGHT ) - m_wndRect.setTop(y()+height()-WDG_MIN_HEIGHT); - else - m_wndRect.setTop(cursor().pos().y()); - } - - if (m_whereResizing==WDG_DX || m_whereResizing==WDG_UPDX || m_whereResizing==WDG_DWNDX) { - if ( cursor().pos().x()-x()>WDG_MIN_WIDTH ) - m_wndRect.setRight(cursor().pos().x()); - else - m_wndRect.setRight(x()+WDG_MIN_WIDTH); - } - - if (m_whereResizing==WDG_DWN || m_whereResizing==WDG_DWNDX || m_whereResizing==WDG_DWNSX) { - if ( cursor().pos().y()-y()>WDG_MIN_HEIGHT ) - m_wndRect.setBottom(cursor().pos().y()); - else - m_wndRect.setBottom(y()+WDG_MIN_HEIGHT); - } - - showLineEdit(m_pLineEdit->isVisible()); - setGeometry(m_wndRect); -} - -void KviNotifierWindow::redrawWindow() -{ - QPainter paint; - paint.begin(&m_pixBackground); - m_pWndBorder->draw(&paint); - m_pWndTabs->draw(&paint); - m_pWndBody->draw(&paint); - m_pProgressBar->draw(&paint); - paint.end(); - bitBlt(&m_pixForeground, 0,0, &m_pixBackground); -} - -void KviNotifierWindow::setCursor(int cur) { - if (m_cursor.shape()!=cur) { - if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); -#ifdef COMPILE_USE_QT4 - m_cursor.setShape((Qt::CursorShape)cur); -#else - m_cursor.setShape(cur); -#endif - QApplication::setOverrideCursor(m_cursor); - } else if (cur==-1) - if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); -} - -void KviNotifierWindow::leaveEvent(QEvent * e) -{ - // Leaving the widget area, restore default cursor - m_pWndBorder->resetIcons(); - m_pWndTabs->resetIcons(); - if (!m_bResizing) - setCursor(-1); -} - -void KviNotifierWindow::contextPopup(const QPoint &pos) -{ - if(!m_pContextPopup) - { - m_pContextPopup = new KviTalPopupMenu(this); - connect(m_pContextPopup,SIGNAL(aboutToShow()),this,SLOT(fillContextPopup())); - m_pDisablePopup = new KviTalPopupMenu(this); - } - - m_pContextPopup->clear(); - if(m_pWndTabs->rect().contains(pos)) - { - m_pWndTabs->contextPopup(m_pContextPopup,pos); - } - - m_pContextPopup->popup(mapToGlobal(pos)); -} - -void KviNotifierWindow::hideTab(int param) -{ - int i = 0; - QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab; - for (tab = m_pWndTabs->tabs()->begin(); tab != m_pWndTabs->tabs()->end(); tab++ ) { - if (i==param) { - m_pWndTabs->closeTab(tab.data()); - } - i++; - } -} - -void KviNotifierWindow::fillContextPopup() -{ - //m_pContextPopup->clear(); - - m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)),__tr2qs_ctx("Hide","notifier"),this,SLOT(hideNow())); - m_pContextPopup->insertSeparator(); - m_pDisablePopup->clear(); - m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("1 Minute","notifier"),this,SLOT(disableFor1Minute())); - m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("5 Minutes","notifier"),this,SLOT(disableFor5Minutes())); - m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("15 Minutes","notifier"),this,SLOT(disableFor15Minutes())); - m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("30 Minutes","notifier"),this,SLOT(disableFor30Minutes())); - m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("1 Hour","notifier"),this,SLOT(disableFor60Minutes())); - m_pDisablePopup->insertSeparator(); - m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),__tr2qs_ctx("Until KVIrc is Restarted","notifier"),this,SLOT(disableUntilKVIrcRestarted())); - m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),__tr2qs_ctx("Permanently (Until Explicitly Enabled)","notifier"),this,SLOT(disablePermanently())); - - m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),__tr2qs_ctx("Disable","notifier"),m_pDisablePopup); -} - -void KviNotifierWindow::disableFor15Minutes() -{ - kvi_time_t tNow = kvi_unixTime(); - g_tNotifierDisabledUntil = tNow + (60 * 15); - - hideNow(); -} - -void KviNotifierWindow::disableFor5Minutes() -{ - kvi_time_t tNow = kvi_unixTime(); - g_tNotifierDisabledUntil = tNow + (60 * 5); - - hideNow(); -} - - -void KviNotifierWindow::disableFor1Minute() -{ - kvi_time_t tNow = kvi_unixTime(); - g_tNotifierDisabledUntil = tNow + 60; - - hideNow(); -} - -void KviNotifierWindow::disableFor30Minutes() -{ - kvi_time_t tNow = kvi_unixTime(); - g_tNotifierDisabledUntil = tNow + (60 * 30); - - hideNow(); -} - -void KviNotifierWindow::disableFor60Minutes() -{ - kvi_time_t tNow = kvi_unixTime(); - g_tNotifierDisabledUntil = tNow + (60 * 60); - - hideNow(); -} - -void KviNotifierWindow::disableUntilKVIrcRestarted() -{ - kvi_time_t tNow = kvi_unixTime(); - // in fact we just disable for one year - g_tNotifierDisabledUntil = tNow + (3600 * 24 * 360); // one year :D - // this will NOT work if the module is forcibly unloaded with /notifier.unload - // but the user should never do it :D - hideNow(); -} - -void KviNotifierWindow::disablePermanently() -{ - KVI_OPTION_BOOL(KviOption_boolForciblyDisableNotifier) = true; - hideNow(); -} - -void KviNotifierWindow::wheelEvent(QWheelEvent * e) -{ - if(e->delta() > 0)prevButtonClicked(); - else nextButtonClicked(); -} - - -void KviNotifierWindow::prevButtonClicked() -{ - KviNotifierWindowTab * tab = m_pWndTabs->currentTab(); - if(!tab)return; - tab->setPrevMessageAsCurrent(); - update(); -} - -void KviNotifierWindow::nextButtonClicked() -{ - KviNotifierWindowTab * tab = m_pWndTabs->currentTab(); - if(!tab)return; - tab->setNextMessageAsCurrent(); - update(); -} - -void KviNotifierWindow::showLineEdit(bool bShow) -{ - if(bShow) - { - //if(m_pLineEdit->isVisible())return; - if(!m_pWndTabs->currentMessage())return; - if(!m_pWndTabs->currentTab()->window())return; - QToolTip::remove(m_pLineEdit); - QString tip = __tr2qs_ctx("Write text or commands to window","notifier"); - tip += " \""; - tip += m_pWndTabs->currentTab()->window()->plainTextCaption(); - tip += "\""; - QToolTip::add(m_pLineEdit,tip); - m_pLineEdit->setGeometry(m_pWndBody->textRect().x(),m_pWndBody->textRect().y() + m_pWndBody->textRect().height() - m_iInputHeight,m_pWndBody->textRect().width(),m_iInputHeight); - m_pLineEdit->show(); - m_pLineEdit->setFocus(); - redrawWindow(); - setActiveWindow(); - } else { - if(!m_pLineEdit->isVisible())return; - m_pLineEdit->hide(); - setFocus(); - KviNotifierWindowTab * tab = m_pWndTabs->currentTab(); - if(tab)tab->setLastMessageAsCurrent(); - update(); - } -} - -bool KviNotifierWindow::eventFilter(QObject * pEdit,QEvent * e) -{ - if(pEdit != (QObject *)m_pLineEdit)return false; // huh ? - if(!m_pLineEdit->isVisible())return false; - if(e->type() == QEvent::MouseButtonPress) - { - bool bWasBlinkOn = m_bBlinkOn; - m_bBlinkOn = false; - m_tAutoHideAt = 0; - stopAutoHideTimer(); - stopBlinkTimer(); - setActiveWindow(); - m_pLineEdit->setFocus(); - if(bWasBlinkOn)update(); - return true; - } - if(e->type() == QEvent::KeyPress) - { - if(((QKeyEvent *)e)->key() == Qt::Key_Escape) - { - hideNow(); - return true; - } - } - return false; -} - -void KviNotifierWindow::returnPressed() -{ - if(!m_pLineEdit->isVisible())return; - - KviNotifierWindowTab * tab = m_pWndTabs->currentTab(); - if(!tab)return; - if(!tab->currentMessage())return; - if(!tab->window())return; - - QString txt = m_pLineEdit->text(); - if(txt.isEmpty())return; - QString html = txt; - html.replace("<","<"); - html.replace(">",">"); - KviStr tmp(KviStr::Format,"%d",KVI_SMALLICON_OWNPRIVMSG); - - addMessage(tab->window(),tmp.ptr(),html,0); //m_pCurrentFocusedWindowTab on place of m_pCurrentMessage->window() - m_pLineEdit->setText(""); - KviUserInput::parse(txt,tab->window(),QString::null,1); -} - -void KviNotifierWindow::progressUpdate() -{ - double dProgress = m_qtStartedAt.elapsed()/(m_tAutoHideAt - m_tStartedAt); - dProgress/=1000; - m_pProgressBar->setProgress(dProgress); - QPainter p(this); - m_pProgressBar->draw(&p); -} -#include "m_notifierwindow.moc" - +//==================================================================================
+//
+// File : notifierwindow.cpp
+// Creation date : Tue Jul 6 2004 20:25:12 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2004 Iacopo Palazzi < iakko(at)siena.linux.it >
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the linkss 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"
+
+#ifdef COMPILE_USE_QT4
+ #define QPopupMenu Q3PopupMenu
+ #define QSimpleRichText Q3SimpleRichText
+
+ #include <q3popupmenu.h>
+ #include <q3simplerichtext.h>
+#else
+ #include <qpopupmenu.h>
+ #include <qsimplerichtext.h>
+#endif
+
+ #include <qpainter.h>
+
+#include "notifiermessage.h"
+#include "notifierwindow.h"
+
+#include "kvi_iconmanager.h"
+#include "kvi_config.h"
+#include "kvi_app.h"
+#include "kvi_window.h"
+
+#include "kvi_locale.h"
+#include "kvi_frame.h"
+#include "kvi_mirccntrl.h"
+#include "kvi_options.h"
+#include "kvi_userinput.h"
+
+#include <qapplication.h>
+#include <qimage.h>
+#include <qdesktopwidget.h>
+#include <qtooltip.h>
+#include <qevent.h>
+#include <qpen.h>
+#include <qfontmetrics.h>
+#include <qregexp.h>
+
+#include "notifierwindowtabs.h"
+#include "notifierwindowbody.h"
+#include "notifierwindowborder.h"
+
+extern KviNotifierWindow * g_pNotifierWindow;
+
+KviNotifierWindow::KviNotifierWindow()
+: QWidget(0,"kvirc_notifier_window",
+#ifdef COMPILE_ON_WINDOWS
+ Qt::WStyle_Customize |
+ Qt::WStyle_NoBorder |
+ Qt::WStyle_Tool |
+ Qt::WStyle_StaysOnTop)
+#else
+ Qt::WStyle_Customize |
+ Qt::WStyle_NoBorder |
+#ifndef Q_OS_MACX
+ Qt::WStyle_Tool |
+ Qt::WX11BypassWM |
+#endif
+ Qt::WStyle_StaysOnTop)
+#endif
+{
+
+ g_pNotifierWindow = this;
+
+ m_eState = Hidden;
+ m_dOpacity = 0.0;
+ m_pShowHideTimer = 0;
+ m_pBlinkTimer = 0;
+ m_tAutoHideAt = 0;
+ m_tStartedAt=0;
+ m_pAutoHideTimer = 0;
+ m_pProgressTimer = 0;
+
+ m_pWndBorder = new KviNotifierWindowBorder();
+
+ reloadImages();
+
+ KviStr buffer;
+ g_pApp->getReadOnlyConfigPath(buffer,"libkvinotifier.kvc",KviApp::ConfigPlugins,true);
+
+ KviConfig cfg(buffer.ptr(),KviConfig::Read);
+
+ cfg.setGroup("NotifierSkin");
+
+ QString szFamily = cfg.readEntry("TextFontFamily","Arial");
+ m_pDefaultFont = new QFont(szFamily,cfg.readIntEntry("TextFontSize",9));
+ szFamily = cfg.readEntry("TitleFontFamily","Arial");
+ m_pTitleFont = new QFont(szFamily,cfg.readIntEntry("TitleFontSize",9));
+
+ m_clrCurText = cfg.readColorEntry("CurTextColor",QColor(40,0,0));
+ m_clrHistoricText = cfg.readColorEntry("HistoricTextColor",QColor(125,125,125));
+ m_clrTitle = QColor(255,255,255); //cfg.readColorEntry("TitleColor",QColor(0,0,0));
+ for(int i=0;i<NUM_OLD_COLORS;i++)
+ {
+ KviStr szKey;
+ szKey.sprintf("OldTextColor%d",i + 1);
+ m_clrOldText[i] = cfg.readColorEntry(szKey.ptr(),QColor(90,90,90));
+ }
+
+ m_iBlinkTimeout = cfg.readIntEntry("BlinkTimeout",650);
+ if(m_iBlinkTimeout < 100)m_iBlinkTimeout = 100;
+ m_iInputHeight = cfg.readIntEntry("InputHeight",20);
+ if(m_iInputHeight < 10)m_iInputHeight = 10;
+
+ setBackgroundMode(Qt::NoBackground);
+#ifdef COMPILE_USE_QT4
+ setFocusPolicy(Qt::NoFocus);
+#else
+ setFocusPolicy(QWidget::NoFocus);
+#endif
+ setMouseTracking(true);
+ //setCursor(m_cursor);
+
+ hide();
+ m_pLineEdit = new QLineEdit(this);
+ m_pLineEdit->setGeometry(0,0,0,0);
+ m_pLineEdit->hide();
+ m_pLineEdit->installEventFilter(this);
+ connect(m_pLineEdit,SIGNAL(returnPressed()),this,SLOT(returnPressed()));
+
+ szFamily = cfg.readEntry("InputFontFamily","Arial");
+ m_pLineEdit->setFont(QFont(szFamily,cfg.readIntEntry("InputFontSize",9)));
+
+ m_bBlinkOn = false;
+
+ m_bCloseDown = false;
+ m_bPrevDown = false;
+ m_bNextDown = false;
+ m_bWriteDown = false;
+
+ m_bKeyShiftPressed = false;
+
+ m_bLeftButtonIsPressed = false;
+ m_bDiagonalResizing = false;
+ m_bResizing = false;
+
+ m_pContextPopup = 0;
+ m_pDisablePopup = 0;
+
+ m_bDragging = false;
+
+ m_bDisableHideOnMainWindowGotAttention = false;
+
+ // Positioning the notifier bottom-right
+ int iWidth = m_pixBackground.width();
+ int iHeight = m_pixBackground.height();
+ QDesktopWidget * w = QApplication::desktop();
+ QRect r = w->availableGeometry(w->primaryScreen()); //w->screenGeometry(w->primaryScreen());
+
+ /*debug("r.x(),r.y(): %d,%d",r.x(),r.y());
+ debug("r.width(),r.height(): %d,%d",r.width(),r.height());*/
+
+ m_wndRect.setRect( r.x() + r.width() - (iWidth + SPACING), r.y() + r.height() - (iHeight + SPACING), iWidth, iHeight );
+
+ //m_pWndBorder = new KviNotifierWindowBorder();
+ m_pWndTabs = new KviNotifierWindowTabs(m_pWndBorder->tabsRect());
+ m_pWndBody = new KviNotifierWindowBody(m_pWndBorder->bodyRect());
+
+ m_pProgressBar = new KviNotifierWindowProgressBar(m_pWndBorder->progressRect());
+
+ // FIXME: Ugly global-font initialization..
+ QFontMetrics titleFontMetrics(*m_pTitleFont);
+ m_pWndBorder->centerTitle(titleFontMetrics.height());
+
+ connect(g_pApp,SIGNAL(reloadImages()),this,SLOT(reloadImages()));
+}
+
+KviNotifierWindow::~KviNotifierWindow()
+{
+ stopShowHideTimer();
+ stopBlinkTimer();
+ stopAutoHideTimer();
+ delete m_pDefaultFont;
+ delete m_pTitleFont;
+ delete m_pWndBorder;
+ delete m_pWndTabs;
+ delete m_pWndBody;
+}
+
+int KviNotifierWindow::countTabs() {
+ return m_pWndTabs->count();
+}
+
+void KviNotifierWindow::reloadImages()
+{
+ m_pixBackground.resize(WDG_MIN_WIDTH,WDG_MIN_HEIGHT);
+ m_pixBackground.fill();
+ m_pixBackgroundHighlighted.resize(m_pixBackground.size());
+ m_pixBackgroundHighlighted.fill();
+
+ m_pWndBorder->resize(m_pixBackground.size());
+}
+
+
+void KviNotifierWindow::addMessage(KviWindow * pWnd,const QString &szImageId,const QString &szText,unsigned int uMessageTime)
+{
+ QPixmap * pIcon;
+ QString szMessage=szText;
+ szMessage.replace( QRegExp("\r([^\r])*\r([^\r])+\r"), "\\2" );
+ if(szImageId.isEmpty())pIcon = 0;
+ else pIcon = g_pIconManager->getImage(szImageId);
+
+ KviNotifierMessage * m = new KviNotifierMessage(this,pIcon ? new QPixmap(*pIcon) : 0,szMessage);
+
+ m_pWndTabs->addMessage(pWnd, m); // Adds a tab about the sender pWnd
+
+ if(!isActiveWindow())
+ startBlinking();
+
+ if(uMessageTime > 0)
+ {
+ kvi_time_t tAutoHide = kvi_unixTime() + uMessageTime;
+ if(m_tAutoHideAt < tAutoHide)
+ {
+ m_tAutoHideAt = tAutoHide;
+ if(m_eState == Visible)startAutoHideTimer();
+ }
+ } else {
+ // never hide
+ stopAutoHideTimer();
+ m_tAutoHideAt = 0;
+ }
+
+ if(pWnd)
+ {
+ if(pWnd->hasAttention())m_bDisableHideOnMainWindowGotAttention = true;
+ }
+
+ //m_pWndTabs->setCurrentMessage(m);
+ if(isVisible())update();
+ // else the line edit was hidden
+}
+
+
+int KviNotifierWindow::textWidth() {
+ return m_pWndBody->textRect().width() - 20;
+};
+
+void KviNotifierWindow::stopShowHideTimer()
+{
+ if(!m_pShowHideTimer)return;
+ debug ("Deleting show/hide timer");
+ delete m_pShowHideTimer;
+ m_pShowHideTimer = 0;
+}
+
+void KviNotifierWindow::stopBlinkTimer()
+{
+ if(!m_pBlinkTimer)return;
+ delete m_pBlinkTimer;
+ m_pBlinkTimer = 0;
+}
+
+void KviNotifierWindow::stopAutoHideTimer()
+{
+ if(m_pProgressTimer) delete m_pProgressTimer;
+ m_pProgressTimer = 0;
+
+ if(!m_pAutoHideTimer)return;
+ delete m_pAutoHideTimer;
+ m_pAutoHideTimer = 0;
+ m_pProgressBar->setProgress(0);
+}
+
+void KviNotifierWindow::computeRect()
+{
+ int iWidth = m_pixBackground.width();
+ int iHeight = m_pixBackground.height();
+ m_pWndBorder->setGeometry(QPoint(x(),y()), QSize(iWidth,iHeight));
+ update();
+}
+
+void KviNotifierWindow::doShow(bool bDoAnimate)
+{
+ if(KVI_OPTION_BOOL(KviOption_boolForciblyDisableNotifier))return;
+
+ kvi_time_t tNow = kvi_unixTime();
+ if(g_tNotifierDisabledUntil > tNow)return;
+ g_tNotifierDisabledUntil = 0;
+
+ switch(m_eState)
+ {
+ case Showing:
+ // already showing up
+ return;
+ break;
+ case Visible:
+ // already visible
+ return;
+ break;
+ case Hiding:
+ // ops.. hiding!
+ m_eState = Showing;
+ break;
+ case Hidden:
+ stopShowHideTimer();
+ stopBlinkTimer();
+
+ m_bDragging = false;
+ m_bCloseDown = false;
+ m_bPrevDown = false;
+ m_bNextDown = false;
+ m_bWriteDown = false;
+ m_bBlinkOn = false;
+ #if (!defined COMPILE_USE_QT4) || !(defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX)))
+ m_imgDesktop = QPixmap::grabWindow(
+ QApplication::desktop()->winId(),
+ m_wndRect.x(),
+ m_wndRect.y(),
+ m_wndRect.width(),
+ m_wndRect.height()).convertToImage();
+ #endif
+ // QPixmap tmp = QPixmap::grabWindow( QApplication::desktop()->winId(),m_wndRect.x(), m_wndRect.y(), m_wndRect.width(), m_wndRect.height());
+ // tmp.save("/root/pix.png","PNG");
+ m_pixForeground.resize(m_pixBackground.size());
+ m_imgBuffer.create(m_pixBackground.width(),m_pixBackground.height(),32);
+ if(bDoAnimate)
+ {
+ m_pShowHideTimer = new QTimer();
+ connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat()));
+ m_dOpacity = OPACITY_STEP;
+ m_eState = Showing;
+ m_bCrashShowWorkAround=true;
+ #if defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX))
+ setWindowOpacity(m_dOpacity);
+ #endif
+ show();
+ #if defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX))
+ m_pShowHideTimer->start(40);
+ #else
+ m_pShowHideTimer->start(100);
+ #endif
+ computeRect();
+ m_bCrashShowWorkAround=false;
+ //show();
+
+ } else {
+ m_dOpacity = 1.0;
+ m_eState = Visible;
+ show();
+ startBlinking();
+ startAutoHideTimer();
+ }
+ break;
+ }
+}
+
+bool KviNotifierWindow::shouldHideIfMainWindowGotAttention()
+{
+ if(m_bDisableHideOnMainWindowGotAttention)return false;
+ KviNotifierWindowTab * t = m_pWndTabs->currentTab();
+ if(!t)return false;
+ if(!t->window())return false;
+ return t->window()->hasAttention();
+}
+
+
+void KviNotifierWindow::heartbeat()
+
+{
+ switch(m_eState)
+ {
+ case Hidden:
+ hideNow();
+ break;
+ case Visible:
+ stopShowHideTimer();
+ m_dOpacity = 1.0;
+ if(!isVisible())show(); //!!!
+ break;
+ case Showing:
+ // if the main window got attention while
+ // showing up then just hide now
+ if(shouldHideIfMainWindowGotAttention())
+ {
+ m_eState = Hiding;
+ } else {
+ m_dOpacity += OPACITY_STEP;
+ if(m_dOpacity >= 1.0)
+ {
+ m_dOpacity = 1.0;
+ m_eState = Visible;
+ stopShowHideTimer();
+ startBlinking();
+ startAutoHideTimer();
+ }
+
+ if(!isVisible())show(); //!!!
+ if(m_pLineEdit->isVisible())m_pLineEdit->hide();
+ #if defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX))
+ setWindowOpacity(m_dOpacity);
+ #endif
+ update();
+
+ }
+ break;
+ case Hiding:
+ m_dOpacity -= OPACITY_STEP;
+ #if defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX))
+ setWindowOpacity(m_dOpacity);
+ #endif
+ if(m_pLineEdit->isVisible())m_pLineEdit->hide();
+ if(m_dOpacity <= 0.0)hideNow();
+ else update();
+ break;
+ }
+}
+
+void KviNotifierWindow::hideNow()
+{
+ stopBlinkTimer();
+ stopShowHideTimer();
+ stopAutoHideTimer();
+ m_eState = Hidden;
+ m_dOpacity = 0.0;
+ m_tAutoHideAt = 0;
+
+ if(m_pLineEdit->isVisible())m_pLineEdit->hide();
+ hide();//if(isVisible())hide();
+}
+
+void KviNotifierWindow::doHide(bool bDoAnimate)
+{
+ stopAutoHideTimer();
+ switch(m_eState)
+ {
+ case Hiding:
+ // already hiding up
+ if(!bDoAnimate)hideNow();
+ return;
+ break;
+ case Hidden:
+ // already hidden
+ if(isVisible())hideNow(); // !!!
+ return;
+ break;
+ case Showing:
+ // ops.. hiding!
+ if(!bDoAnimate)hideNow();
+ else {
+ // continue animating, but hide
+ m_eState = Hiding;
+ }
+ break;
+ case Visible:
+ stopBlinkTimer();
+ stopShowHideTimer();
+ if(m_pLineEdit->isVisible())m_pLineEdit->hide();
+ if((!bDoAnimate) || (x() != m_pWndBorder->x()) || (y() != m_pWndBorder->y()))
+ {
+
+ debug ("just hide quickly with notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate);
+ // the user asked to not animate or
+ // the window has been moved and the animation would suck anyway
+ // just hide quickly
+ hideNow();
+ } else {
+ debug ("starting hide animation notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate);
+ m_pShowHideTimer = new QTimer();
+ connect(m_pShowHideTimer,SIGNAL(timeout()),this,SLOT(heartbeat()));
+ m_dOpacity = 1.0 - OPACITY_STEP;
+ m_eState = Hiding;
+ #if defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX))
+ setWindowOpacity(m_dOpacity);
+ update();
+ m_pShowHideTimer->start(40);
+ #else
+ update();
+ m_pShowHideTimer->start(100);
+ #endif
+
+
+ }
+ break;
+ }
+}
+
+void KviNotifierWindow::showEvent(QShowEvent *e)
+{
+ computeRect();
+ setGeometry(m_wndRect); // w_win = w_wndRect
+
+}
+
+void KviNotifierWindow::hideEvent(QHideEvent * e)
+{
+ if (m_bCrashShowWorkAround) return;
+ stopBlinkTimer();
+ stopShowHideTimer();
+ stopAutoHideTimer();
+ m_eState = Hidden; // make sure it's true
+ m_tAutoHideAt = 0; // make sure it's true
+ markAllMessagesAsHistoric();
+ m_bDisableHideOnMainWindowGotAttention = false;
+}
+
+void KviNotifierWindow::startBlinking()
+{
+ stopBlinkTimer();
+ m_bBlinkOn = false;
+
+
+ if(!KVI_OPTION_BOOL(KviOption_boolDisableNotifierFlashing))
+ {
+ m_pBlinkTimer = new QTimer();
+ connect(m_pBlinkTimer,SIGNAL(timeout()),this,SLOT(blink()));
+ m_iBlinkCount = 0;
+ m_pBlinkTimer->start(m_iBlinkTimeout);
+ }
+}
+
+void KviNotifierWindow::startAutoHideTimer()
+{
+ stopAutoHideTimer();
+ m_tStartedAt = kvi_unixTime();
+ m_qtStartedAt.start();
+ if(m_tAutoHideAt <= m_tStartedAt)return;
+
+ int nSecs = m_tAutoHideAt - m_tStartedAt;
+ if(nSecs < 5)nSecs = 5;
+ m_pAutoHideTimer = new QTimer();
+ connect(m_pAutoHideTimer,SIGNAL(timeout()),this,SLOT(autoHide()));
+ m_pAutoHideTimer->start(nSecs * 1000);
+
+ m_pProgressTimer= new QTimer();
+ connect(m_pProgressTimer,SIGNAL(timeout()),this,SLOT(progressUpdate()));
+ m_pProgressTimer->start(60);
+}
+
+void KviNotifierWindow::autoHide()
+{
+ m_tAutoHideAt = 0;
+ stopAutoHideTimer();
+ doHide(true);
+}
+
+void KviNotifierWindow::blink()
+{
+ m_iBlinkCount++;
+ m_bBlinkOn = !m_bBlinkOn;
+
+ if(m_iBlinkCount > 100)
+ {
+ // stop blinking at a certain point and remain highlighted
+ m_bBlinkOn = true;
+ stopBlinkTimer();
+ } else {
+ // if the main window got attention while
+ // showing up then just hide now
+ if(shouldHideIfMainWindowGotAttention())
+ {
+ doHide(false); // don't animate: the background has almost surely changed
+ return;
+ }
+ }
+ update();
+}
+
+void KviNotifierWindow::markAllMessagesAsHistoric()
+{
+ m_pWndTabs->markAllMessagesAsHistoric();
+}
+
+
+static void blend_images(QImage &buffer,QImage &background,QImage &foreground,double dValue)
+{
+ for(int y = 0;y < buffer.height();y++)
+ {
+ QRgb * dst = (QRgb *)buffer.scanLine(y);
+ QRgb * end = dst + buffer.width();
+ QRgb * bkg = (QRgb *)background.scanLine(y);
+ QRgb * fgn = (QRgb *)foreground.scanLine(y);
+
+ double dRemaining = 1.0 - dValue;
+
+ while(dst < end)
+ {
+ *dst = qRgb(
+ (int)((qRed(*bkg) * dRemaining) + (qRed(*fgn) * dValue)),
+ (int)((qGreen(*bkg) * dRemaining) + (qGreen(*fgn) * dValue)),
+ (int)((qBlue(*bkg) * dRemaining) + (qBlue(*fgn) * dValue))
+ );
+ dst++;
+ bkg++;
+ fgn++;
+ }
+
+ }
+}
+
+void KviNotifierWindow::paintEvent(QPaintEvent * e)
+{
+
+/*
+ if(m_bBlinkOn)
+ bitBlt(&m_pixForeground,QPoint(0,0),&m_pixBackgroundHighlighted);
+ else
+ bitBlt(&m_pixForeground,QPoint(0,0),&m_pixBackground);
+
+ QPainter p(&m_pixForeground);
+*/
+ redrawWindow();
+ redrawText();
+ QPainter px(this);
+ if(m_dOpacity < 1.0)
+ {
+
+ #if defined(COMPILE_USE_QT4) && (defined(COMPILE_ON_WINDOWS) || defined(Q_OS_MACX))
+ px.drawPixmap(0,0,m_pixForeground);
+ #else
+ QImage temp_image = m_pixForeground.convertToImage();
+ blend_images(m_imgBuffer,m_imgDesktop,temp_image,m_dOpacity);
+ px.drawImage(0,0,m_imgBuffer);
+ #endif
+ px.end();
+ } else {
+#ifdef COMPILE_USE_QT4
+ px.drawPixmap(0,0,m_pixForeground);
+#else
+ bitBlt(this,QPoint(0,0),&m_pixForeground);
+#endif
+ }
+}
+
+void KviNotifierWindow::redrawText()
+{
+ QPainter p(&m_pixForeground);
+
+ // the current tab
+ KviNotifierWindowTab * tab = m_pWndTabs->currentTab();
+ if(!tab)return;
+
+ // it's message list
+ KviPtrList<KviNotifierMessage> * l = tab->messageList();
+ if(!l)return;
+ if(l->isEmpty())return;
+
+ // the current message
+ KviNotifierMessage * cur = tab->currentMessage();
+ if(!cur)cur = l->last();
+
+ // this is useful in several places
+ KviNotifierMessage * last = l->last();
+
+ // make sure that we can loop
+ int iIdx = l->findRef(cur);
+ if(iIdx == -1)
+ {
+ tab->setCurrentMessage(last);
+ cur = last;
+ iIdx = l->findRef(cur);
+ }
+
+ int y = m_pWndBody->textRect().y() + m_pWndBody->textRect().height();
+
+ if(m_pLineEdit->isVisible())y -= (m_pLineEdit->height() + 4);
+
+ QColorGroup grp = colorGroup();
+
+ int idx = iIdx;
+ KviNotifierMessage * m = cur;
+ while(m && (y > m_pWndBody->textRect().y()))
+ {
+ int iHeight = m->text()->height();
+ if(iHeight < 18)iHeight = 18;
+ y -= iHeight;
+ if(m->historic())
+ {
+ grp.setColor(QColorGroup::Text,m_clrHistoricText);
+ } else {
+ if(m == last)
+ grp.setColor(QColorGroup::Text,m_clrCurText);
+ else {
+ int iClrIdx = l->count() - (idx + 2);
+ if(iClrIdx < 0)iClrIdx = 0;
+ else if(iClrIdx >= NUM_OLD_COLORS)iClrIdx = (NUM_OLD_COLORS - 1);
+ grp.setColor(QColorGroup::Text,m_clrOldText[iClrIdx]);
+ }
+ }
+ int iMaxY = y > m_pWndBody->textRect().y() ? y : m_pWndBody->textRect().y();
+ QRect clip(m_pWndBody->textRect().x() + 20,iMaxY,m_pWndBody->textRect().width() - 20,iHeight);
+
+ m->text()->draw(&p,m_pWndBody->textRect().x() + 20,y,clip,grp); //
+ if(y > m_pWndBody->textRect().y())
+ {
+ if(m->image())
+ p.drawPixmap(m_pWndBody->textRect().x() + 1,y + 1,*(m->image()),0,0,16,16);
+ }
+ m = l->prev();
+ idx--;
+ }
+
+ p.setPen(QPen(m_clrTitle));
+ p.setFont(*m_pTitleFont);
+ QString title;
+ KviQString::sprintf(title,"[%d/%d]",iIdx + 1,l->count());
+
+ if(tab->window())
+ {
+ title += " ";
+ title += tab->window()->plainTextCaption();
+ }
+ p.drawText(m_pWndBorder->titleRect(),Qt::AlignLeft | Qt::SingleLine,title);
+ p.end();
+}
+
+void KviNotifierWindow::mouseMoveEvent(QMouseEvent * e)
+{
+
+ //debug ("move on x,y: %d,%d", e->pos().x(), e->pos().y());
+
+ if (!m_bLeftButtonIsPressed) {
+
+ if(checkResizing(e->pos())) goto sartelo;
+
+ /* ### MOUSE-MOVE-EVENT -> m_pWndBorder ### */
+ if (m_pWndBorder->captionRect().contains(e->pos())) {
+ if (m_pWndBorder->closeRect().contains(e->pos())) {
+ m_pWndBorder->setCloseIcon(WDG_ICON_OVER);
+ } else {
+ m_pWndBorder->setCloseIcon(WDG_ICON_OUT);
+ }
+ goto sartelo;
+ }
+
+ if(m_pWndTabs->currentTab())
+ {
+ /* ### MOUSE-MOVE-EVENT -> m_pWndTabs ### */
+ if (m_pWndTabs->rect().contains(e->pos())) {
+ m_pWndTabs->mouseMoveEvent(e);
+ goto sartelo;
+ }
+
+ /* ### MOUSE-MOVE-EVENT -> m_pWndBody ### */
+ if (m_pWndBody->rect().contains(e->pos())) {
+ if (m_pWndBody->rctWriteIcon().contains(e->pos())) {
+ m_pWndBody->setWriteIcon(WDG_ICON_ON);
+ } else {
+ m_pWndBody->setWriteIcon(WDG_ICON_OFF);
+ }
+ goto sartelo;
+ }
+ }
+ /* ### END ### */
+
+sartelo:
+
+ update();
+
+ }
+
+ if(m_bDragging) {
+ setCursor(Qt::SizeAllCursor);
+
+ int w = m_wndRect.width();
+ int h = m_wndRect.height();
+
+ m_wndRect.setX( m_pntPos.x() + cursor().pos().x() - m_pntDrag.x() );
+ m_wndRect.setY( m_pntPos.y() + cursor().pos().y() - m_pntDrag.y() );
+
+ m_wndRect.setWidth(w);
+ m_wndRect.setHeight(h);
+
+ setGeometry(m_wndRect);
+
+ return;
+ } else if (m_bResizing) {
+ resize(e->pos());
+ }
+
+}
+
+void KviNotifierWindow::mousePressEvent(QMouseEvent * e)
+{
+
+ // stop blinking first of all :)
+ bool bWasBlinkOn = m_bBlinkOn;
+ m_bBlinkOn = false;
+ stopBlinkTimer();
+ m_tAutoHideAt = 0;
+ stopAutoHideTimer();
+
+ setActiveWindow();
+ setFocus();
+
+ m_pntClick = e->pos();
+
+ if(e->button() == Qt::RightButton)
+ {
+ contextPopup(mapToGlobal(e->pos()));
+ return;
+ } else if(e->button() == Qt::LeftButton) {
+ m_bLeftButtonIsPressed = true;
+ }
+
+ if(checkResizing(m_pntClick)) goto sartelo;
+
+ if(m_pWndTabs->rect().contains(e->pos()))
+ {
+ m_pWndTabs->mousePressEvent(e);
+ goto sartelo;
+ }
+
+ if(m_pWndBorder->captionRect().contains(e->pos())) {
+ //debug ("Clicked on m_pWndBorder->rect()");
+ if(m_pWndBorder->closeRect().contains(e->pos())) {
+ //debug ("\tClicked on m_pWndBorder->closeRect()");
+ m_bCloseDown = true;
+ m_pWndBorder->setCloseIcon(WDG_ICON_CLICKED);
+ goto sartelo;
+ }
+
+ if( !m_bResizing) {
+ m_bDragging = true;
+ m_pntDrag = cursor().pos();
+ m_pntPos = pos();
+ goto sartelo;
+ }
+ }
+
+ //debug ("x,y: %d,%d - width,height: %d,%d", m_pWndBorder->rect().x(),m_pWndBorder->rect().y(),m_pWndBorder->rect().width(),m_pWndBorder->rect().height());
+
+ if (m_pWndBorder->rect().contains(e->pos())) {
+ if(m_pWndTabs->currentTab())
+ {
+ //debug ("Clicked on m_pWndBody->textRect()");
+ if(m_pWndBody->rctWriteIcon().contains(e->pos()))
+ {
+ m_pWndBody->setWriteIcon(WDG_ICON_CLICKED);
+ showLineEdit(!(m_pLineEdit->isVisible()));
+ }
+
+ if(m_pWndBody->rctPrevIcon().contains(e->pos()) && m_pWndBody->prevIconState()!=WDG_ICON_OFF)
+ {
+ m_bPrevDown = true;
+ m_pWndBody->setPrevIcon(WDG_ICON_CLICKED);
+ prevButtonClicked();
+ }
+
+ if(m_pWndBody->rctNextIcon().contains(e->pos()) && m_pWndBody->nextIconState()!=WDG_ICON_OFF)
+ {
+ m_bNextDown = true;
+ m_pWndBody->setNextIcon(WDG_ICON_CLICKED);
+ nextButtonClicked();
+ }
+ }
+ goto sartelo;
+ }
+
+ if(bWasBlinkOn) goto sartelo; else return;
+
+sartelo:
+ update();
+
+}
+
+void KviNotifierWindow::mouseReleaseEvent(QMouseEvent * e)
+{
+ m_bWriteDown = false;
+ m_bNextDown = false;
+ m_bPrevDown = false;
+ m_bCloseDown = false;
+ m_bLeftButtonIsPressed = false;
+ m_bResizing = false;
+
+ //m_pWndBody->setWriteIcon(WDG_ICON_ON);
+ m_pWndBody->setNextIcon(WDG_ICON_ON);
+ m_pWndBody->setPrevIcon(WDG_ICON_ON);
+ m_pWndTabs->setCloseTabIcon(WDG_ICON_OFF);
+
+ if(m_bDragging)
+ {
+ m_bDragging = false;
+ if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor();
+ return;
+ }
+
+ if(m_pWndBorder->captionRect().contains(e->pos())) {
+
+ if(m_pWndBorder->closeRect().contains(e->pos())) {
+ debug ("hide now from release event");
+ hideNow();
+ } else {
+ update();
+ }
+
+ }
+
+ if(m_pWndTabs->rect().contains(e->pos()))
+ {
+ m_pWndTabs->mouseReleaseEvent(e);
+ }
+
+ setCursor(-1);
+
+}
+
+void KviNotifierWindow::mouseDoubleClickEvent(QMouseEvent * e)
+{
+ if(!m_pWndBody->textRect().contains(e->pos()))
+ {
+ QWidget::mouseDoubleClickEvent(e);
+ return;
+ }
+
+ KviNotifierWindowTab * tab = m_pWndTabs->currentTab();
+ if(!tab)return;
+
+ if(!tab->window())return;
+
+ hideNow();
+ delayedRaise(tab->window());
+}
+
+void KviNotifierWindow::keyPressEvent(QKeyEvent * e)
+{
+ if (e->key()==Qt::Key_Shift) {
+ m_bKeyShiftPressed = true;
+ return;
+ }
+
+ if (e->key()==Qt::Key_Left && m_bKeyShiftPressed) {
+ m_pWndTabs->prev();
+ return;
+ }
+ if (e->key()==Qt::Key_Right && m_bKeyShiftPressed) {
+ m_pWndTabs->next();
+ return;
+ }
+
+ if (e->key()==Qt::Key_Escape) {
+ hideNow();
+ return;
+ }
+}
+
+void KviNotifierWindow::keyReleaseEvent(QKeyEvent * e)
+{
+ if (e->key()==Qt::Key_Shift) {
+ m_bKeyShiftPressed = false;
+ }
+}
+
+void KviNotifierWindow::delayedRaise(KviWindow * pWnd)
+{
+ m_pWindowToRaise = pWnd;
+ QTimer::singleShot(0,this,SLOT(delayedRaiseSlot()));
+}
+
+void KviNotifierWindow::delayedRaiseSlot()
+{
+ if(!m_pWindowToRaise)return;
+ if(!g_pApp->windowExists(m_pWindowToRaise))return;
+
+ if(m_pWindowToRaise->mdiParent())
+ {
+ if(!m_pWindowToRaise->frame()->isVisible())
+ m_pWindowToRaise->frame()->show();
+
+ m_pWindowToRaise->frame()->raise();
+ ((QWidget *)(m_pWindowToRaise->frame()))->setActiveWindow();
+ m_pWindowToRaise->frame()->setFocus();
+ }
+
+ m_pWindowToRaise->delayedAutoRaise();
+}
+
+bool KviNotifierWindow::checkResizing(QPoint e)
+{
+ if (e.y()<WDG_BORDER_THICKNESS) {
+ if (e.x()<WDG_BORDER_THICKNESS) {
+ //// UP LEFT CORNER ////
+ setCursor(Qt::SizeFDiagCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_UPSX;
+ }
+ } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) {
+ //// UP RIGHT CORNER ////
+ setCursor(Qt::SizeBDiagCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_UPDX;
+ }
+ } else {
+ //// UP SIDE ////
+ setCursor(Qt::SizeVerCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_UP;
+ } }
+ } else if (e.y() > (size().height()-WDG_BORDER_THICKNESS)) {
+ if (e.x()<WDG_BORDER_THICKNESS) {
+ //// DOWN LEFT CORNER ////
+ setCursor(Qt::SizeBDiagCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_DWNSX;
+ }
+ } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) {
+ //// DOWN RIGHT CORNER ////
+ setCursor(Qt::SizeFDiagCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_DWNDX;
+ }
+ } else {
+ //// DOWN SIDE ////
+ setCursor(Qt::SizeVerCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_DWN;
+ }
+ }
+ } else {
+ if (e.x()<WDG_BORDER_THICKNESS) {
+ //// LEFT SIZE ////
+ setCursor(Qt::SizeHorCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_SX;
+ }
+ } else if (e.x() > (size().width()-WDG_BORDER_THICKNESS)) {
+ //// RIGHT SIZE ////
+ setCursor(Qt::SizeHorCursor);
+ if (m_bLeftButtonIsPressed) {
+ m_bResizing = true;
+ m_whereResizing = WDG_DX;
+ }
+ } else {
+ //// ELSEWHERE ////
+ m_whereResizing = 0;
+ m_bResizing = false;
+ setCursor(-1);
+ }
+ }
+ return m_bResizing;
+};
+
+
+
+void KviNotifierWindow::resize(QPoint p, bool up)
+{
+ //QPoint aux = mapToGlobal(p);
+
+ if (m_whereResizing==WDG_UPSX || m_whereResizing==WDG_SX || m_whereResizing==WDG_DWNSX) {
+ if ( x()+width()-cursor().pos().x()<WDG_MIN_WIDTH )
+ m_wndRect.setLeft(x()+width()-WDG_MIN_WIDTH);
+ else
+ m_wndRect.setLeft(cursor().pos().x());
+ }
+
+ if (m_whereResizing==WDG_UPSX || m_whereResizing==WDG_UP || m_whereResizing==WDG_UPDX) {
+ if ( y()+height()-cursor().pos().y()<WDG_MIN_HEIGHT )
+ m_wndRect.setTop(y()+height()-WDG_MIN_HEIGHT);
+ else
+ m_wndRect.setTop(cursor().pos().y());
+ }
+
+ if (m_whereResizing==WDG_DX || m_whereResizing==WDG_UPDX || m_whereResizing==WDG_DWNDX) {
+ if ( cursor().pos().x()-x()>WDG_MIN_WIDTH )
+ m_wndRect.setRight(cursor().pos().x());
+ else
+ m_wndRect.setRight(x()+WDG_MIN_WIDTH);
+ }
+
+ if (m_whereResizing==WDG_DWN || m_whereResizing==WDG_DWNDX || m_whereResizing==WDG_DWNSX) {
+ if ( cursor().pos().y()-y()>WDG_MIN_HEIGHT )
+ m_wndRect.setBottom(cursor().pos().y());
+ else
+ m_wndRect.setBottom(y()+WDG_MIN_HEIGHT);
+ }
+
+ showLineEdit(m_pLineEdit->isVisible());
+ setGeometry(m_wndRect);
+}
+
+void KviNotifierWindow::redrawWindow()
+{
+ if(m_pixBackground.size()!=m_wndRect.size())
+ {
+ // Redraw only if size was modified..
+ m_pixBackground.resize(m_wndRect.size());
+ m_pixForeground.resize(m_wndRect.size());
+ m_pixBackgroundHighlighted.resize(m_wndRect.size());
+
+ m_pWndBorder->resize( m_wndRect.size() );
+ m_pWndTabs->setWidth( m_pWndBorder->tabsRect().width() );
+ m_pWndBody->resize( m_pWndBorder->bodyRect() );
+ }
+
+ QPainter paint;
+ if(m_bBlinkOn)
+ {
+ m_pWndBorder->touch();
+ m_pWndTabs->touch();
+ m_pWndBody->touch();
+ paint.begin(&m_pixBackgroundHighlighted);
+ m_pWndBorder->draw(&paint,true);
+ m_pWndTabs->draw(&paint);
+ m_pWndBody->draw(&paint);
+ m_pProgressBar->draw(&paint);
+ paint.end();
+ bitBlt(&m_pixForeground, 0,0, &m_pixBackgroundHighlighted);
+ m_pWndBorder->touch();
+ m_pWndTabs->touch();
+ m_pWndBody->touch();
+ } else {
+ paint.begin(&m_pixBackground);
+ m_pWndBorder->draw(&paint);
+ m_pWndTabs->draw(&paint);
+ m_pWndBody->draw(&paint);
+ m_pProgressBar->draw(&paint);
+ paint.end();
+ bitBlt(&m_pixForeground, 0,0, &m_pixBackground);
+ }
+
+}
+
+inline void KviNotifierWindow::setCursor(int cur) {
+ if (m_cursor.shape() != cur) {
+ if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor();
+ m_cursor.setShape((Qt::CursorShape)cur);
+ QApplication::setOverrideCursor(m_cursor);
+ } else if (cur==-1)
+ if(QApplication::overrideCursor()) QApplication::restoreOverrideCursor();
+}
+
+void KviNotifierWindow::leaveEvent(QEvent * e)
+{
+ // Leaving the widget area, restore default cursor
+ m_pWndBorder->resetIcons();
+ m_pWndTabs->resetIcons();
+ if (!m_bResizing)
+ setCursor(-1);
+}
+
+void KviNotifierWindow::contextPopup(const QPoint &pos)
+{
+ if(!m_pContextPopup)
+ {
+ m_pContextPopup = new QPopupMenu(this);
+ connect(m_pContextPopup,SIGNAL(aboutToShow()),this,SLOT(fillContextPopup()));
+ m_pDisablePopup = new QPopupMenu(this);
+ }
+
+ m_pContextPopup->popup(pos);
+}
+
+void KviNotifierWindow::fillContextPopup()
+{
+ m_pContextPopup->clear();
+
+ m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)),__tr2qs_ctx("Hide","notifier"),this,SLOT(hideNow()));
+ m_pContextPopup->insertSeparator();
+ m_pDisablePopup->clear();
+ m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("1 Minute","notifier"),this,SLOT(disableFor1Minute()));
+ m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("5 Minutes","notifier"),this,SLOT(disableFor5Minutes()));
+ m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("15 Minutes","notifier"),this,SLOT(disableFor15Minutes()));
+ m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("30 Minutes","notifier"),this,SLOT(disableFor30Minutes()));
+ m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_TIME)),__tr2qs_ctx("1 Hour","notifier"),this,SLOT(disableFor60Minutes()));
+ m_pDisablePopup->insertSeparator();
+ m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),__tr2qs_ctx("Until KVIrc is Restarted","notifier"),this,SLOT(disableUntilKVIrcRestarted()));
+ m_pDisablePopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),__tr2qs_ctx("Permanently (Until Explicitly Enabled)","notifier"),this,SLOT(disablePermanently()));
+
+ m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),__tr2qs_ctx("Disable","notifier"),m_pDisablePopup);
+}
+
+void KviNotifierWindow::disableFor15Minutes()
+{
+ kvi_time_t tNow = kvi_unixTime();
+ g_tNotifierDisabledUntil = tNow + (60 * 15);
+
+ hideNow();
+}
+
+void KviNotifierWindow::disableFor5Minutes()
+{
+ kvi_time_t tNow = kvi_unixTime();
+ g_tNotifierDisabledUntil = tNow + (60 * 5);
+
+ hideNow();
+}
+
+
+void KviNotifierWindow::disableFor1Minute()
+{
+ kvi_time_t tNow = kvi_unixTime();
+ g_tNotifierDisabledUntil = tNow + 60;
+
+ hideNow();
+}
+
+void KviNotifierWindow::disableFor30Minutes()
+{
+ kvi_time_t tNow = kvi_unixTime();
+ g_tNotifierDisabledUntil = tNow + (60 * 30);
+
+ hideNow();
+}
+
+void KviNotifierWindow::disableFor60Minutes()
+{
+ kvi_time_t tNow = kvi_unixTime();
+ g_tNotifierDisabledUntil = tNow + (60 * 60);
+
+ hideNow();
+}
+
+void KviNotifierWindow::disableUntilKVIrcRestarted()
+{
+ kvi_time_t tNow = kvi_unixTime();
+ // in fact we just disable for one year
+ g_tNotifierDisabledUntil = tNow + (3600 * 24 * 360); // one year :D
+ // this will NOT work if the module is forcibly unloaded with /notifier.unload
+ // but the user should never do it :D
+ hideNow();
+}
+
+void KviNotifierWindow::disablePermanently()
+{
+ KVI_OPTION_BOOL(KviOption_boolForciblyDisableNotifier) = true;
+ hideNow();
+}
+
+void KviNotifierWindow::wheelEvent(QWheelEvent * e)
+{
+ if(e->delta() > 0)prevButtonClicked();
+ else nextButtonClicked();
+}
+
+
+void KviNotifierWindow::prevButtonClicked()
+{
+ KviNotifierWindowTab * tab = m_pWndTabs->currentTab();
+ if(!tab)return;
+ tab->setPrevMessageAsCurrent();
+ update();
+}
+
+void KviNotifierWindow::nextButtonClicked()
+{
+ KviNotifierWindowTab * tab = m_pWndTabs->currentTab();
+ if(!tab)return;
+ tab->setNextMessageAsCurrent();
+ update();
+}
+
+void KviNotifierWindow::showLineEdit(bool bShow)
+{
+ if(bShow)
+ {
+ //if(m_pLineEdit->isVisible())return;
+ if(!m_pWndTabs->currentMessage())return;
+ if(!m_pWndTabs->currentTab()->window())return;
+ QToolTip::remove(m_pLineEdit);
+ QString tip = __tr2qs_ctx("Write text or commands to window","notifier");
+ tip += " \"";
+ tip += m_pWndTabs->currentTab()->window()->plainTextCaption();
+ tip += "\"";
+ QToolTip::add(m_pLineEdit,tip);
+ m_pLineEdit->setGeometry(m_pWndBody->textRect().x(),m_pWndBody->textRect().y() + m_pWndBody->textRect().height() - m_iInputHeight,m_pWndBody->textRect().width(),m_iInputHeight);
+ m_pLineEdit->show();
+ m_pLineEdit->setFocus();
+ redrawWindow();
+ setActiveWindow();
+ } else {
+ if(!m_pLineEdit->isVisible())return;
+ m_pLineEdit->hide();
+ setFocus();
+ KviNotifierWindowTab * tab = m_pWndTabs->currentTab();
+ if(tab)tab->setLastMessageAsCurrent();
+ update();
+ }
+}
+
+bool KviNotifierWindow::eventFilter(QObject * pEdit,QEvent * e)
+{
+ if(pEdit != (QObject *)m_pLineEdit)return false; // huh ?
+ if(!m_pLineEdit->isVisible())return false;
+ if(e->type() == QEvent::MouseButtonPress)
+ {
+ bool bWasBlinkOn = m_bBlinkOn;
+ m_bBlinkOn = false;
+ m_tAutoHideAt = 0;
+ stopAutoHideTimer();
+ stopBlinkTimer();
+ setActiveWindow();
+ m_pLineEdit->setFocus();
+ if(bWasBlinkOn)update();
+ return true;
+ }
+ if(e->type() == QEvent::KeyPress)
+ {
+ if(((QKeyEvent *)e)->key() == Qt::Key_Escape)
+ {
+ hideNow();
+ return true;
+ }
+ }
+ return false;
+}
+
+void KviNotifierWindow::returnPressed()
+{
+ if(!m_pLineEdit->isVisible())return;
+
+ KviNotifierWindowTab * tab = m_pWndTabs->currentTab();
+ if(!tab)return;
+ if(!tab->currentMessage())return;
+ if(!tab->window())return;
+
+ QString txt = m_pLineEdit->text();
+ if(txt.isEmpty())return;
+ QString html = txt;
+ html.replace("<","<");
+ html.replace(">",">");
+ KviStr tmp(KviStr::Format,"%d",KVI_SMALLICON_OWNPRIVMSG);
+
+ addMessage(tab->window(),tmp.ptr(),html,0); //m_pCurrentFocusedWindowTab on place of m_pCurrentMessage->window()
+ m_pLineEdit->setText("");
+ KviUserInput::parse(txt,tab->window(),QString::null,1);
+}
+
+void KviNotifierWindow::progressUpdate()
+{
+ double dProgress = m_qtStartedAt.elapsed()/(m_tAutoHideAt - m_tStartedAt);
+ dProgress/=1000;
+ m_pProgressBar->setProgress(dProgress);
+ QPainter p(this);
+ m_pProgressBar->draw(&p);
+}
+#include "m_notifierwindow.moc"
+
diff --git a/src/modules/notifier/notifierwindow.h b/src/modules/notifier/notifierwindow.h index f986393a7..0bfbc5f6c 100644 --- a/src/modules/notifier/notifierwindow.h +++ b/src/modules/notifier/notifierwindow.h @@ -1,205 +1,193 @@ -#ifndef _NOTIFIERWINDOW_H_ -#define _NOTIFIERWINDOW_H_ -//================================================================================== -// -// File : notifierwindow.h -// Creation date : Tue Jul 6 2004 20:25:12 CEST by Szymon Stefanek -// -// This file is part of the KVirc irc client distribution -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// This program is FREE software. You can redistribute it and/or -// modify it under the linkss 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 <qwidget.h> -#include <qrect.h> -#include <qtimer.h> -#include <qpixmap.h> -#include <qimage.h> -#ifdef COMPILE_USE_QT4 - #include <q3simplerichtext.h> - #ifndef QSimpleRichText - #define QSimpleRichText Q3SimpleRichText - #endif -#else - #include <qsimplerichtext.h> -#endif - -#include <qfont.h> -#include <qcolor.h> -#include <qlineedit.h> -#include <qcursor.h> -#include <qbitmap.h> -#include <qdatetime.h> - -#include "kvi_qstring.h" -#include "kvi_list.h" -#include "kvi_time.h" - -#include "notifiersettings.h" - -class KviWindow; -class KviNotifierMessage; - -class KviNotifierWindowTabs; -class KviNotifierWindowBody; -class KviNotifierWindowBorder; -class KviNotifierWindowProgressBar; - -class KviTalPopupMenu; - -extern kvi_time_t g_tNotifierDisabledUntil; - -class KviNotifierWindow : public QWidget -{ - Q_OBJECT -public: - KviNotifierWindow(); - ~KviNotifierWindow(); -protected: - QTimer * m_pShowHideTimer; - QTimer * m_pProgressTimer; - QTimer * m_pBlinkTimer; - QTimer * m_pAutoHideTimer; - State m_eState; - bool m_bBlinkOn; - bool m_bKeyAltPressed; - double m_dOpacity; - QImage m_imgDesktop; // the desktop screenshot - QPixmap m_pixBackground; // our background image - QPixmap m_pixBackgroundHighlighted; - QPixmap m_pixForeground; // we paint the stuff HERE - - // Notifier graphic layout - QPixmap m_pixBckgrnd; - - QImage m_imgBuffer; // here we merge the two images - - bool m_bCloseDown; - bool m_bPrevDown; - bool m_bNextDown; - bool m_bWriteDown; - - bool m_bKeyShiftPressed; - - QFont * m_pDefaultFont; - QFont * m_pTitleFont; - - QRect m_wndRect; - - QColor m_clrCurText; - QColor m_clrOldText[NUM_OLD_COLORS]; - QColor m_clrHistoricText; - QColor m_clrTitle; - - KviNotifierMessage * m_pCurrentMessage; - QLineEdit * m_pLineEdit; - - bool m_bDragging; - bool m_bLeftButtonIsPressed; - bool m_bDiagonalResizing; - bool m_bResizing; - - int m_whereResizing; - - QPoint m_pntDrag; - QPoint m_pntPos; - QPoint m_pntClick; - int m_iInputHeight; - int m_iBlinkTimeout; - int m_iBlinkCount; - KviTalPopupMenu * m_pContextPopup; - KviTalPopupMenu * m_pDisablePopup; - KviWindow * m_pWindowToRaise; - kvi_time_t m_tAutoHideAt; - kvi_time_t m_tStartedAt; - QTime m_qtStartedAt; - bool m_bDisableHideOnMainWindowGotAttention; - //bool m_bForceShowing; - - QCursor m_cursor; - - KviNotifierWindowTabs * m_pWndTabs; - KviNotifierWindowProgressBar * m_pProgressBar; - KviNotifierWindowBody * m_pWndBody; - KviNotifierWindowBorder * m_pWndBorder; -public: - QPixmap* background() { return &m_pixBckgrnd;}; - void doShow(bool bDoAnimate); - void doHide(bool bDoAnimate); - const QFont & defaultFont(){ return *m_pDefaultFont; }; - int textWidth(); - void addMessage(KviWindow * pWnd,const QString &szImageId,const QString &szText,unsigned int uMessageTime); - State state() { return m_eState; }; - void setDisableHideOnMainWindowGotAttention(bool b){ m_bDisableHideOnMainWindowGotAttention = b; }; - int countTabs(); - void showLineEdit(bool bShow); - bool shiftPressed() { return m_bKeyShiftPressed; }; - void setCursor(int); -protected: - virtual void showEvent(QShowEvent *e); - virtual void hideEvent(QHideEvent * e); - virtual void paintEvent(QPaintEvent * e); - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseReleaseEvent(QMouseEvent * e); - virtual void mouseMoveEvent(QMouseEvent * e); - virtual void leaveEvent(QEvent * e); - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual void wheelEvent(QWheelEvent * e); - virtual bool eventFilter(QObject * pEdit,QEvent * e); - virtual void keyPressEvent ( QKeyEvent * e ); - virtual void keyReleaseEvent ( QKeyEvent * e ); -public slots: - void hideTab(int); -protected slots: - void blink(); - void heartbeat(); - void returnPressed(); - void reloadImages(); - void fillContextPopup(); - void hideNow(); - void disableFor1Minute(); - void disableFor5Minutes(); - void disableFor15Minutes(); - void disableFor30Minutes(); - void disableFor60Minutes(); - void disableUntilKVIrcRestarted(); - void disablePermanently(); - void delayedRaiseSlot(); - void autoHide(); - void progressUpdate(); -private: - void contextPopup(const QPoint &pos); - void startBlinking(); - void markAllMessagesAsHistoric(); - void computeRect(); - void stopShowHideTimer(); - void stopBlinkTimer(); - void stopAutoHideTimer(); - void startAutoHideTimer(); - void delayedRaise(KviWindow * pWnd); - void prevButtonClicked(); - void nextButtonClicked(); - bool shouldHideIfMainWindowGotAttention(); - void resize(QPoint p, bool = true); - void redrawWindow(); - void redrawText(); - bool checkResizing(QPoint); -}; - -#endif //_NOTIFIERWINDOW_H_ +#ifndef _NOTIFIERWINDOW_H_
+#define _NOTIFIERWINDOW_H_
+//==================================================================================
+//
+// File : notifierwindow.h
+// Creation date : Tue Jul 6 2004 20:25:12 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the linkss 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 <qbitmap.h>
+#include <qcolor.h>
+#include <qcursor.h>
+#include <qdatetime.h>
+#include <qfont.h>
+#include <qimage.h>
+#include <qlineedit.h>
+#include <qpixmap.h>
+#include <qrect.h>
+#include <qtimer.h>
+#include <qwidget.h>
+
+#include "kvi_qstring.h"
+#include "kvi_list.h"
+#include "kvi_time.h"
+
+#include "notifiersettings.h"
+
+class KviWindow;
+class KviNotifierMessage;
+
+class KviNotifierWindowTabs;
+class KviNotifierWindowBody;
+class KviNotifierWindowBorder;
+class KviNotifierWindowProgressBar;
+
+class QPainter;
+class QPopupMenu;
+
+extern kvi_time_t g_tNotifierDisabledUntil;
+
+class KviNotifierWindow : public QWidget
+{
+ Q_OBJECT
+public:
+ KviNotifierWindow();
+ ~KviNotifierWindow();
+protected:
+ QTimer * m_pShowHideTimer;
+ QTimer * m_pProgressTimer;
+ QTimer * m_pBlinkTimer;
+ QTimer * m_pAutoHideTimer;
+ State m_eState;
+ bool m_bBlinkOn;
+ double m_dOpacity;
+ QImage m_imgDesktop; // the desktop screenshot
+ QPixmap m_pixBackground; // our background image
+ QPixmap m_pixBackgroundHighlighted;
+ QPixmap m_pixForeground; // we paint the stuff HERE
+
+ // Notifier graphic layout
+ QPixmap m_pixBckgrnd;
+
+ QImage m_imgBuffer; // here we merge the two images
+
+ bool m_bCloseDown;
+ bool m_bPrevDown;
+ bool m_bNextDown;
+ bool m_bWriteDown;
+ bool m_bCrashShowWorkAround;
+
+ bool m_bKeyShiftPressed;
+
+ QFont * m_pDefaultFont;
+ QFont * m_pTitleFont;
+
+ QRect m_wndRect;
+
+ QColor m_clrCurText;
+ QColor m_clrOldText[NUM_OLD_COLORS];
+ QColor m_clrHistoricText;
+ QColor m_clrTitle;
+
+ KviNotifierMessage * m_pCurrentMessage;
+ QLineEdit * m_pLineEdit;
+
+ bool m_bDragging;
+ bool m_bLeftButtonIsPressed;
+ bool m_bDiagonalResizing;
+ bool m_bResizing;
+
+ int m_whereResizing;
+
+ QPoint m_pntDrag;
+ QPoint m_pntPos;
+ QPoint m_pntClick;
+ int m_iInputHeight;
+ int m_iBlinkTimeout;
+ int m_iBlinkCount;
+ QPopupMenu * m_pContextPopup;
+ QPopupMenu * m_pDisablePopup;
+ KviWindow * m_pWindowToRaise;
+ kvi_time_t m_tAutoHideAt;
+ kvi_time_t m_tStartedAt;
+ QTime m_qtStartedAt;
+ bool m_bDisableHideOnMainWindowGotAttention;
+ //bool m_bForceShowing;
+
+ QCursor m_cursor;
+
+ KviNotifierWindowTabs * m_pWndTabs;
+ KviNotifierWindowProgressBar * m_pProgressBar;
+ KviNotifierWindowBody * m_pWndBody;
+ KviNotifierWindowBorder * m_pWndBorder;
+public:
+ void doShow(bool bDoAnimate);
+ void doHide(bool bDoAnimate);
+ const QFont & defaultFont(){ return *m_pDefaultFont; };
+ int textWidth();
+ void addMessage(KviWindow * pWnd,const QString &szImageId,const QString &szText,unsigned int uMessageTime);
+ State state() { return m_eState; };
+ void setDisableHideOnMainWindowGotAttention(bool b){ m_bDisableHideOnMainWindowGotAttention = b; };
+ int countTabs();
+ void showLineEdit(bool bShow);
+protected:
+ virtual void showEvent(QShowEvent *e);
+ virtual void hideEvent(QHideEvent * e);
+ virtual void paintEvent(QPaintEvent * e);
+ virtual void mousePressEvent(QMouseEvent * e);
+ virtual void mouseReleaseEvent(QMouseEvent * e);
+ virtual void mouseMoveEvent(QMouseEvent * e);
+ virtual void leaveEvent(QEvent * e);
+ virtual void mouseDoubleClickEvent(QMouseEvent * e);
+ virtual void wheelEvent(QWheelEvent * e);
+ virtual bool eventFilter(QObject * pEdit,QEvent * e);
+ virtual void keyPressEvent ( QKeyEvent * e );
+ virtual void keyReleaseEvent ( QKeyEvent * e );
+protected slots:
+ void blink();
+ void heartbeat();
+ void returnPressed();
+ void reloadImages();
+ void fillContextPopup();
+ void hideNow();
+ void disableFor1Minute();
+ void disableFor5Minutes();
+ void disableFor15Minutes();
+ void disableFor30Minutes();
+ void disableFor60Minutes();
+ void disableUntilKVIrcRestarted();
+ void disablePermanently();
+ void delayedRaiseSlot();
+ void autoHide();
+ void progressUpdate();
+private:
+ void contextPopup(const QPoint &pos);
+ void startBlinking();
+ void markAllMessagesAsHistoric();
+ void computeRect();
+ void stopShowHideTimer();
+ void stopBlinkTimer();
+ void stopAutoHideTimer();
+ void startAutoHideTimer();
+ void delayedRaise(KviWindow * pWnd);
+ void prevButtonClicked();
+ void nextButtonClicked();
+ bool shouldHideIfMainWindowGotAttention();
+ void setCursor(int);
+ void resize(QPoint p, bool = true);
+ void redrawWindow();
+ void redrawText();
+ bool checkResizing(QPoint);
+};
+
+#endif //_NOTIFIERWINDOW_H_
diff --git a/src/modules/notifier/notifierwindowbody.cpp b/src/modules/notifier/notifierwindowbody.cpp index 23fd67001..9f4299a4a 100644 --- a/src/modules/notifier/notifierwindowbody.cpp +++ b/src/modules/notifier/notifierwindowbody.cpp @@ -1,164 +1,258 @@ -//============================================================================= -// -// File : kvinotifierwindowbody.cpp -// Created on dom 02 gen 2005 17:53:29 by Iacopo Palazzi -// -// This file is part of the KVIrc distribution -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// 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 "notifierwindowbody.h" -#include "kvi_iconmanager.h" - -#include <qpainter.h> -#include <qbrush.h> -#include <qcolor.h> - -KviNotifierWindowBody::KviNotifierWindowBody(QRect r) -{ - loadImages(); - setHeight(r.height()); - setWidth(r.width()); - m_pnt.setX(r.x()); - m_pnt.setY(r.y()); - recalculatePositions(); -} - -KviNotifierWindowBody::~KviNotifierWindowBody() -{ -} - - -void KviNotifierWindowBody::loadImages() -{ - QPixmap * p; - - if((p = g_pIconManager->getPixmap("notifier_up.png"))) - m_pixIconPrev = *p; - - if((p = g_pIconManager->getPixmap("notifier_down.png"))) - m_pixIconNext = *p; - - if((p = g_pIconManager->getPixmap("notifier_pen.png"))) - m_pixIconWrite = *p; - - needToRedraw(); - -} - -void KviNotifierWindowBody::setWidth(int w) -{ - m_rct.setWidth(w); - recalculatePositions(); -} - -void KviNotifierWindowBody::setHeight(int h) -{ - m_rct.setHeight(h); - recalculatePositions(); -} - -void KviNotifierWindowBody::recalculatePositions() -{ - m_textRect.setX(m_pnt.x()); - m_textRect.setY(m_pnt.y()); - m_textRect.setWidth(m_rct.width()-m_pixIconPrev.width()); - m_textRect.setHeight(m_rct.height()); - - m_rctWriteIcon.setX(m_textRect.x()+m_textRect.width()); - m_rctWriteIcon.setY(m_pnt.y()+m_textRect.height()-m_pixIconWrite.height()); - m_rctWriteIcon.setWidth(m_pixIconWrite.width()); - m_rctWriteIcon.setHeight(m_pixIconWrite.height()); - - m_rctPrevIcon.setX(m_textRect.x()+m_textRect.width()); - m_rctPrevIcon.setY(m_pnt.y()+2); //FIXME: Maybe the spacing should be calculated? - m_rctPrevIcon.setWidth(m_pixIconPrev.width()); - m_rctPrevIcon.setHeight(m_pixIconPrev.height()); - - m_rctNextIcon.setX(m_textRect.x()+m_textRect.width()); - m_rctNextIcon.setY(m_pnt.y()+m_textRect.height()-m_pixIconNext.height()-m_pixIconWrite.height()); - m_rctNextIcon.setWidth(m_pixIconNext.width()); - m_rctNextIcon.setHeight(m_pixIconNext.height()); - - needToRedraw(); -} - -void KviNotifierWindowBody::setPrevIcon(int state) -{ - -}; - -void KviNotifierWindowBody::setNextIcon(int state) { - -}; - -void KviNotifierWindowBody::setWriteIcon(int state) { - -}; - -void KviNotifierWindowBody::draw(QPainter * p) { - - if (m_bNeedToRedraw) { - - // Draw Icons - p->drawPixmap(m_rctPrevIcon.x(), m_rctPrevIcon.y(), m_pixIconPrev); - p->drawPixmap(m_rctNextIcon.x(), m_rctNextIcon.y(), m_pixIconNext); - p->drawPixmap(m_rctWriteIcon.x(), m_rctWriteIcon.y(), m_pixIconWrite); - - m_bNeedToRedraw = false; - - } -} - -void KviNotifierWindowBody::mouseMoveEvent(QMouseEvent * e) { - -} - -void KviNotifierWindowBody::mousePressEvent(QMouseEvent * e) { - -} - -void KviNotifierWindowBody::mouseReleaseEvent(QMouseEvent * e) { - -} - -KviNotifierWindowProgressBar::KviNotifierWindowProgressBar(QRect r) -:m_rect(r) -{ - -} - -KviNotifierWindowProgressBar::~KviNotifierWindowProgressBar() -{ - m_dProgress=0; -} - -void KviNotifierWindowProgressBar::draw(QPainter *p) -{ - p->fillRect(m_rect,QColor(236,233,216)); - p->fillRect( - QRect( - m_rect.x()+1, - m_rect.y()+1+m_rect.height()*(1-m_dProgress), - m_rect.width()-2, - (m_rect.height()-2)*m_dProgress - ), - QColor(175,28,95) - ); - p->drawRect(m_rect); +//=============================================================================
+//
+// File : kvinotifierwindowbody.cpp
+// Created on dom 02 gen 2005 17:53:29 by Iacopo Palazzi
+//
+// This file is part of the KVIrc distribution
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// 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 "notifierwindowbody.h"
+#include "kvi_iconmanager.h"
+
+#include <qbrush.h>
+#include <qcolor.h>
+
+#include <qpainter.h>
+
+/*
+#ifdef QT3_SUPPORT
+ #include <Q3Painter>
+#else
+ #include <qpainter.h>
+#endif
+*/
+
+KviNotifierWindowBody::KviNotifierWindowBody(QRect r)
+{
+ loadImages();
+ setHeight(r.height());
+ setWidth(r.width());
+ m_pnt.setX(r.x());
+ m_pnt.setY(r.y());
+ recalculatePositions();
+}
+
+KviNotifierWindowBody::~KviNotifierWindowBody()
+{
+}
+
+
+void KviNotifierWindowBody::loadImages()
+{
+ QPixmap * p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_dx.png")))
+ m_pixDX = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_sx.png")))
+ m_pixSX = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_dwnsx.png")))
+ m_pixDWNSX = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_dwndx.png")))
+ m_pixDWNDX = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_dwn.png")))
+ m_pixDWN = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_kvirc_sx.png")))
+ m_pixKVIrcSX = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_kvirc_dwn.png")))
+ m_pixKVIrcDWN = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_body_kvirc.png")))
+ m_pixKVIrc = *p;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_prev_off.png")))
+ m_pixIconPrev_off = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_prev_on.png")))
+ m_pixIconPrev_on = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_prev_clicked.png")))
+ m_pixIconPrev_clicked = *p;
+
+ m_pixIconPrev = m_pixIconPrev_off;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_next_off.png")))
+ m_pixIconNext_off = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_next_on.png")))
+ m_pixIconNext_on = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_next_clicked.png")))
+ m_pixIconNext_clicked = *p;
+
+ m_pixIconNext = m_pixIconNext_off;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_write_off.png")))
+ m_pixIconWrite_off = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_write_on.png")))
+ m_pixIconWrite_on = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_body_write_clicked.png")))
+ m_pixIconWrite_clicked = *p;
+
+ m_pixIconWrite = m_pixIconWrite_off;
+
+ needToRedraw();
+
+ m_prevIconState = WDG_ICON_OFF;
+ m_nextIconState = WDG_ICON_OFF;
+ m_writeIconState = WDG_ICON_OFF;
+
+}
+
+void KviNotifierWindowBody::setWidth(int w)
+{
+ m_rct.setWidth(w);
+ recalculatePositions();
+}
+
+void KviNotifierWindowBody::setHeight(int h)
+{
+ m_rct.setHeight(h);
+ recalculatePositions();
+}
+
+void KviNotifierWindowBody::recalculatePositions()
+{
+ m_textRect.setX(m_pnt.x()+m_pixSX.width());
+ m_textRect.setY(m_pnt.y());
+ m_textRect.setWidth(m_rct.width()-m_pixSX.width()-m_pixDX.width()-m_pixIconPrev.width());
+ m_textRect.setHeight(m_rct.height()-m_pixDWN.height());
+
+ m_rctWriteIcon.setX(m_textRect.x()+m_textRect.width());
+ m_rctWriteIcon.setY(m_pnt.y()+m_textRect.height()-m_pixIconWrite.height());
+ m_rctWriteIcon.setWidth(m_pixIconWrite.width());
+ m_rctWriteIcon.setHeight(m_pixIconWrite.height());
+
+ m_rctPrevIcon.setX(m_textRect.x()+m_textRect.width());
+ m_rctPrevIcon.setY(m_pnt.y()+2); //FIXME: Maybe the spacing should be calculated?
+ m_rctPrevIcon.setWidth(m_pixIconPrev.width());
+ m_rctPrevIcon.setHeight(m_pixIconPrev.height());
+
+ m_rctNextIcon.setX(m_textRect.x()+m_textRect.width());
+ m_rctNextIcon.setY(m_pnt.y()+m_textRect.height()-m_pixIconNext.height()-m_pixIconWrite.height());
+ m_rctNextIcon.setWidth(m_pixIconNext.width());
+ m_rctNextIcon.setHeight(m_pixIconNext.height());
+
+ needToRedraw();
+}
+
+void KviNotifierWindowBody::setPrevIcon(int state)
+{
+ //if (m_prevIconState==WDG_ICON_OFF && state!=WDG_ICON_OFF)
+ if (m_prevIconState!=state) {
+ switch (state) {
+ case WDG_ICON_ON: m_pixIconPrev = m_pixIconPrev_on; break;
+ case WDG_ICON_OFF: m_pixIconPrev = m_pixIconPrev_off; break;
+ case WDG_ICON_CLICKED: m_pixIconPrev = m_pixIconPrev_clicked; break;
+ };
+
+ m_prevIconState=state;
+ needToRedraw();
+ }
+};
+
+void KviNotifierWindowBody::setNextIcon(int state) {
+
+ //if (m_nextIconState==WDG_ICON_OFF && state!=WDG_ICON_OFF)
+ if (m_nextIconState!=state) {
+ switch (state) {
+ case WDG_ICON_ON: m_pixIconNext = m_pixIconNext_on; break;
+ case WDG_ICON_OFF: m_pixIconNext = m_pixIconNext_off; break;
+ case WDG_ICON_CLICKED: m_pixIconNext = m_pixIconNext_clicked; break;
+ };
+
+ needToRedraw();
+ m_nextIconState=state;
+ }
+};
+
+void KviNotifierWindowBody::setWriteIcon(int state) {
+
+ //if (m_writeIconState==WDG_ICON_OFF && state!=WDG_ICON_OFF)
+ if (m_writeIconState!=state) {
+ switch (state) {
+ case WDG_ICON_ON: m_pixIconWrite = m_pixIconWrite_on; break;
+ case WDG_ICON_OFF: m_pixIconWrite = m_pixIconWrite_off; break;
+ case WDG_ICON_CLICKED: m_pixIconWrite = m_pixIconWrite_clicked; break;};
+
+ needToRedraw();
+ m_writeIconState=state;
+ }
+};
+
+void KviNotifierWindowBody::draw(QPainter * p) {
+
+ if (m_bNeedToRedraw) {
+
+ p->fillRect(QRect(m_pnt,m_rct.size()),m_mac_bkgColor);
+
+ // Autotiled borders
+ p->drawTiledPixmap(m_pnt.x(), m_pnt.y(), m_pixSX.width(), m_rct.height() - m_pixDWNSX.height() - m_pixKVIrcSX.height(), m_pixSX);
+ p->drawTiledPixmap(m_pnt.x() + m_rct.width() - m_pixDX.width(), m_pnt.y(),m_pixDX.width(), m_rct.height() - m_pixDWNDX.height(), m_pixDX);
+ p->drawTiledPixmap(m_pnt.x() + m_pixKVIrcDWN.width() + m_pixDWNSX.width(), m_pnt.y() + m_rct.height() - m_pixDWN.height(), m_rct.width() - m_pixKVIrcDWN.width() - m_pixDWNSX.width() - m_pixDWNDX.width(), m_pixDWN.height(), m_pixDWN);
+
+ // Bottom corners
+ p->drawPixmap(m_pnt.x(), m_pnt.y() + m_rct.height() - m_pixDWNSX.height(), m_pixDWNSX);
+ p->drawPixmap(m_pnt.x() + m_rct.width() - m_pixDWNSX.width(), m_pnt.y() + m_rct.height() - m_pixDWNDX.height(), m_pixDWNDX);
+
+ // KVIrc image
+ p->drawPixmap(m_pnt.x(), m_pnt.y() + m_rct.height() - m_pixKVIrcSX.height() - m_pixDWNSX.height(), m_pixKVIrcSX);
+ p->drawPixmap(m_pnt.x() + m_pixKVIrcSX.width(), m_pnt.y() + m_rct.height() - m_pixKVIrcDWN.height(), m_pixKVIrcDWN);
+ p->drawPixmap(m_pnt.x() + m_pixKVIrcSX.width(), m_pnt.y() + m_rct.height() - m_pixKVIrc.height() - m_pixKVIrcDWN.height(), m_pixKVIrc, 0, 0, m_pixKVIrcSX.width(), m_pixKVIrcSX.height());
+
+ // Draw Icons
+ p->drawPixmap(m_rctPrevIcon.x(), m_rctPrevIcon.y(), m_pixIconPrev);
+ p->drawPixmap(m_rctNextIcon.x(), m_rctNextIcon.y(), m_pixIconNext);
+ p->drawPixmap(m_rctWriteIcon.x(), m_rctWriteIcon.y(), m_pixIconWrite);
+
+ m_bNeedToRedraw = false;
+
+ }
+}
+
+void KviNotifierWindowBody::mouseMoveEvent(QMouseEvent * e) {
+
+}
+
+void KviNotifierWindowBody::mousePressEvent(QMouseEvent * e) {
+
+}
+
+void KviNotifierWindowBody::mouseReleaseEvent(QMouseEvent * e) {
+
+}
+
+KviNotifierWindowProgressBar::KviNotifierWindowProgressBar(QRect r)
+:m_rect(r)
+{
+
+}
+
+KviNotifierWindowProgressBar::~KviNotifierWindowProgressBar()
+{
+ m_dProgress=0;
+}
+
+void KviNotifierWindowProgressBar::draw(QPainter *p)
+{
+ p->fillRect(m_rect,QColor(236,233,216));
+ p->fillRect(
+ QRect(
+ m_rect.x()+1,
+ m_rect.y()+1+m_rect.height()*(1-m_dProgress),
+ m_rect.width()-2,
+ (m_rect.height()-2)*m_dProgress
+ ),
+ QColor(175,28,95)
+ );
+ p->drawRect(m_rect);
}
\ No newline at end of file diff --git a/src/modules/notifier/notifierwindowbody.h b/src/modules/notifier/notifierwindowbody.h index db90ab71f..60751ecda 100644 --- a/src/modules/notifier/notifierwindowbody.h +++ b/src/modules/notifier/notifierwindowbody.h @@ -1,133 +1,159 @@ -#ifndef _KVINOTIFIERWINDOWBODY_H_ -#define _KVINOTIFIERWINDOWBODY_H_ -//============================================================================= -// -// File : kvinotifierwindowbody.h -// Created on dom 02 gen 2005 17:53:29 by Iacopo Palazzi -// -// This file is part of the KVIrc distribution -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// 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 <qevent.h> -#include <qrect.h> -#include <qpoint.h> -#include <qpixmap.h> - -#include "notifiersettings.h" - -class KviNotifierWindowBody -{ -public: - KviNotifierWindowBody(QRect r); - ~KviNotifierWindowBody(); - -// ================================ -// Put members declaration below... -// ================================ -private: - QRect m_rct; - QPoint m_pnt; - - QRect m_textRect; - - QRect m_rctWriteIcon; - QRect m_rctPrevIcon; - QRect m_rctNextIcon; - QRect m_rctCloseTabIcon; - - // Pictures - QPixmap m_pixIconPrev; - - QPixmap m_pixIconNext; - - QPixmap m_pixIconWrite; - - bool m_bNeedToRedraw; - - int m_prevIconState; - int m_nextIconState; - int m_writeIconState; - -public: - -protected: - - -// ================================ -// Put methods declaration below... -// ================================ -private: - void loadImages(); - -public: - void setWidth(int w); - void setHeight(int h); - void resize(int w, int h) { setWidth(w); setHeight(h); }; - void resize(QRect r) { setWidth(r.width()); setHeight(r.height()); }; - void setPoint(int x, int y) { m_pnt.setX(x); m_pnt.setY(y); }; - - void setPrevIcon(int state); - void setNextIcon(int state); - void setWriteIcon(int state); - - int nextIconState() { return m_nextIconState; }; - int prevIconState() { return m_prevIconState; }; - int writeIconState() { return m_writeIconState; }; - - int x() { return m_pnt.x(); }; - int y() { return m_pnt.y(); }; - int width() { return m_rct.width(); }; - int height() { return m_rct.height(); }; - int baseLine() { return (y()+height()); }; - - QRect rect() { return m_rct; }; - QRect textRect() { return m_textRect; }; - QRect rctPrevIcon() { return m_rctPrevIcon; }; - QRect rctNextIcon() { return m_rctNextIcon; }; - QRect rctWriteIcon() { return m_rctWriteIcon; }; - - void needToRedraw() { m_bNeedToRedraw = true; }; - - void recalculatePositions(); - void touch() { m_bNeedToRedraw = true; }; - void draw(QPainter *); - - void mouseMoveEvent(QMouseEvent * e); - void mousePressEvent(QMouseEvent * e); - void mouseReleaseEvent(QMouseEvent * e); - - - -protected: - -}; - -class KviNotifierWindowProgressBar -{ -public: - KviNotifierWindowProgressBar(QRect r); - ~KviNotifierWindowProgressBar(); -protected: - QRect m_rect; - double m_dProgress; -public: - void setProgress(double progress) { m_dProgress=progress; }; - void draw(QPainter *); -}; -#endif //!_KVINOTIFIERWINDOWBODY_H_ +#ifndef _KVINOTIFIERWINDOWBODY_H_
+#define _KVINOTIFIERWINDOWBODY_H_
+//=============================================================================
+//
+// File : kvinotifierwindowbody.h
+// Created on dom 02 gen 2005 17:53:29 by Iacopo Palazzi
+//
+// This file is part of the KVIrc distribution
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// 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 <qevent.h>
+#include <qrect.h>
+#include <qpoint.h>
+#include <qpixmap.h>
+
+#include "notifiersettings.h"
+
+/*
+#ifdef QT3_SUPPORT
+ #define QPainter Q3Painter
+#endif
+*/
+
+class QPainter;
+
+class KviNotifierWindowBody
+{
+public:
+ KviNotifierWindowBody(QRect r);
+ ~KviNotifierWindowBody();
+
+// ================================
+// Put members declaration below...
+// ================================
+private:
+ QRect m_rct;
+ QPoint m_pnt;
+
+ QRect m_textRect;
+
+ QRect m_rctWriteIcon;
+ QRect m_rctPrevIcon;
+ QRect m_rctNextIcon;
+ QRect m_rctCloseTabIcon;
+
+ // Pictures
+ QPixmap m_pixDX;
+ QPixmap m_pixSX;
+ QPixmap m_pixDWNSX;
+ QPixmap m_pixDWNDX;
+ QPixmap m_pixDWN;
+ QPixmap m_pixKVIrcSX;
+ QPixmap m_pixKVIrcDWN;
+ QPixmap m_pixKVIrc;
+
+ QPixmap m_pixIconPrev;
+ QPixmap m_pixIconPrev_off;
+ QPixmap m_pixIconPrev_on;
+ QPixmap m_pixIconPrev_clicked;
+
+ QPixmap m_pixIconNext;
+ QPixmap m_pixIconNext_off;
+ QPixmap m_pixIconNext_on;
+ QPixmap m_pixIconNext_clicked;
+
+ QPixmap m_pixIconWrite;
+ QPixmap m_pixIconWrite_off;
+ QPixmap m_pixIconWrite_on;
+ QPixmap m_pixIconWrite_clicked;
+
+ bool m_bNeedToRedraw;
+
+ int m_prevIconState;
+ int m_nextIconState;
+ int m_writeIconState;
+
+public:
+
+protected:
+
+
+// ================================
+// Put methods declaration below...
+// ================================
+private:
+ void loadImages();
+
+public:
+ void setWidth(int w);
+ void setHeight(int h);
+ void resize(int w, int h) { setWidth(w); setHeight(h); };
+ void resize(QRect r) { setWidth(r.width()); setHeight(r.height()); };
+ void setPoint(int x, int y) { m_pnt.setX(x); m_pnt.setY(y); };
+
+ void setPrevIcon(int state);
+ void setNextIcon(int state);
+ void setWriteIcon(int state);
+
+ int nextIconState() { return m_nextIconState; };
+ int prevIconState() { return m_prevIconState; };
+ int writeIconState() { return m_writeIconState; };
+
+ int x() { return m_pnt.x(); };
+ int y() { return m_pnt.y(); };
+ int width() { return m_rct.width(); };
+ int height() { return m_rct.height(); };
+ int baseLine() { return (y()+height()); };
+
+ QRect rect() { return m_rct; };
+ QRect textRect() { return m_textRect; };
+ QRect rctPrevIcon() { return m_rctPrevIcon; };
+ QRect rctNextIcon() { return m_rctNextIcon; };
+ QRect rctWriteIcon() { return m_rctWriteIcon; };
+
+ void needToRedraw() { m_bNeedToRedraw = true; };
+
+ void recalculatePositions();
+ void touch() { m_bNeedToRedraw = true; };
+ void draw(QPainter *);
+
+ void mouseMoveEvent(QMouseEvent * e);
+ void mousePressEvent(QMouseEvent * e);
+ void mouseReleaseEvent(QMouseEvent * e);
+
+
+
+protected:
+
+};
+
+class KviNotifierWindowProgressBar
+{
+public:
+ KviNotifierWindowProgressBar(QRect r);
+ ~KviNotifierWindowProgressBar();
+protected:
+ QRect m_rect;
+ double m_dProgress;
+public:
+ void setProgress(double progress) { m_dProgress=progress; };
+ void draw(QPainter *);
+};
+#endif //!_KVINOTIFIERWINDOWBODY_H_
diff --git a/src/modules/notifier/notifierwindowborder.cpp b/src/modules/notifier/notifierwindowborder.cpp index 24e4d0e54..b88baef68 100644 --- a/src/modules/notifier/notifierwindowborder.cpp +++ b/src/modules/notifier/notifierwindowborder.cpp @@ -1,91 +1,222 @@ -//============================================================================= -// -// File : kvinotifierwindowborder.cpp -// Created on lun 03 gen 2005 02:27:22 by Iacopo Palazzi -// -// This file is part of the KVIrc distribution -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// 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 "notifierwindowborder.h" -#include "notifierwindowtabs.h" -#include "kvi_iconmanager.h" - -#include <qpainter.h> - -KviNotifierWindowBorder::KviNotifierWindowBorder(QSize s) -{ - loadImages(); - resize(s); -} - -KviNotifierWindowBorder::~KviNotifierWindowBorder() -{ -} - -void KviNotifierWindowBorder::loadImages() { - - - -} - -void KviNotifierWindowBorder::setPics(bool b) -{ - -} - -void KviNotifierWindowBorder::setWidth(int w) { - m_iRctWidth = w; - recalculatePositions(); -} - -void KviNotifierWindowBorder::setHeight(int h) { - m_iRctHeight = h; - recalculatePositions(); -} - -void KviNotifierWindowBorder::recalculatePositions() -{ - m_rct.setHeight(m_iRctHeight); - m_rct.setWidth(m_iRctWidth); - m_rct.setTopLeft(QPoint(0,0)); - - m_tabsRect.setTopLeft( QPoint(9,9) ); - m_tabsRect.setSize( QSize(m_rct.width()-9*2,14) ); - - m_bodyRect.setTopLeft( QPoint(9,9+14) ); - m_bodyRect.setSize( QSize(m_rct.width()-9*2,m_rct.height()-2*9-14) ); - - m_bNeedToRedraw = true; -} - -void KviNotifierWindowBorder::setCloseIcon(int state) { - -} - -void KviNotifierWindowBorder::resetIcons() { - setCloseIcon(WDG_ICON_OUT); -} - -void KviNotifierWindowBorder::draw(QPainter * p, bool b) { - - if (m_bNeedToRedraw) { - - m_bNeedToRedraw = false; - } -} +//=============================================================================
+//
+// File : kvinotifierwindowborder.cpp
+// Created on lun 03 gen 2005 02:27:22 by Iacopo Palazzi
+//
+// This file is part of the KVIrc distribution
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// 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 "notifierwindowborder.h"
+#include "notifierwindowtabs.h"
+#include "kvi_iconmanager.h"
+
+#include <qpainter.h>
+
+KviNotifierWindowBorder::KviNotifierWindowBorder(QSize s)
+{
+ loadImages();
+ resize(s);
+}
+
+KviNotifierWindowBorder::~KviNotifierWindowBorder()
+{
+}
+
+void KviNotifierWindowBorder::loadImages() {
+
+ // Normal Border
+
+ QPixmap * p;
+
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_sx.png")))
+ m_pixSX_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dx.png")))
+ m_pixDX_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dwn.png")))
+ m_pixDWN_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dwndx.png")))
+ m_pixDWNDX_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dwnsx.png")))
+ m_pixDWNSX_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_caption_sx.png")))
+ m_pixCaptionSX_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_caption_dx.png")))
+ m_pixCaptionDX_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_caption_bkg.png")))
+ m_pixCaptionBKG_N = *p;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_close_out.png")))
+ m_pixIconClose_out_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_close_over.png")))
+ m_pixIconClose_over_N = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_close_clicked.png")))
+ m_pixIconClose_clicked_N = *p;
+
+ // Highlighted Border
+
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_sx_hl.png")))
+ m_pixSX_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dx_hl.png")))
+ m_pixDX_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dwn_hl.png")))
+ m_pixDWN_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dwndx_hl.png")))
+ m_pixDWNDX_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_wnd_dwnsx_hl.png")))
+ m_pixDWNSX_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_caption_sx_hl.png")))
+ m_pixCaptionSX_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_caption_dx_hl.png")))
+ m_pixCaptionDX_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_caption_bkg_hl.png")))
+ m_pixCaptionBKG_HL = *p;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_close_out_hl.png")))
+ m_pixIconClose_out_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_close_over_hl.png")))
+ m_pixIconClose_over_HL = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_close_clicked_hl.png")))
+ m_pixIconClose_clicked_HL = *p;
+
+ setPics();
+ setCloseIcon(WDG_ICON_OUT);
+
+ if ( m_pixCaptionDX->height()==m_pixCaptionSX->height() && m_pixCaptionDX->height()==m_pixCaptionBKG->height()) // just to be sure that the height is fitting
+ m_captionRect.setHeight(m_pixCaptionDX->height());
+
+ // We want to see the tabs height to calculate the appropriate rect..
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_sx.png")))
+ m_iTabsHeight = p->height();
+ else
+ m_iTabsHeight = 10;
+
+ m_bNeedToRedraw = true;
+
+}
+
+void KviNotifierWindowBorder::setPics(bool b)
+{
+ if (b) {
+ m_pixSX = &m_pixSX_HL;
+ m_pixDX = &m_pixDX_HL;
+ m_pixDWN = &m_pixDWN_HL;
+ m_pixDWNSX = &m_pixDWNSX_HL;
+ m_pixDWNDX = &m_pixDWNDX_HL;
+ m_pixCaptionSX = &m_pixCaptionSX_HL;
+ m_pixCaptionDX = &m_pixCaptionDX_HL;
+ m_pixCaptionBKG = &m_pixCaptionBKG_HL;
+ m_pixIconClose_out = &m_pixIconClose_out_HL;
+ m_pixIconClose_over = &m_pixIconClose_over_HL;
+ m_pixIconClose_clicked = &m_pixIconClose_clicked_HL;
+ } else {
+ m_pixSX = &m_pixSX_N;
+ m_pixDX = &m_pixDX_N;
+ m_pixDWN = &m_pixDWN_N;
+ m_pixDWNSX = &m_pixDWNSX_N;
+ m_pixDWNDX = &m_pixDWNDX_N;
+ m_pixCaptionSX = &m_pixCaptionSX_N;
+ m_pixCaptionDX = &m_pixCaptionDX_N;
+ m_pixCaptionBKG = &m_pixCaptionBKG_N;
+ m_pixIconClose_out = &m_pixIconClose_out_N;
+ m_pixIconClose_over = &m_pixIconClose_over_N;
+ m_pixIconClose_clicked = &m_pixIconClose_clicked_N;
+ }
+}
+
+void KviNotifierWindowBorder::setWidth(int w) {
+ m_iRctWidth = w;
+ recalculatePositions();
+}
+
+void KviNotifierWindowBorder::setHeight(int h) {
+ m_iRctHeight = h;
+ recalculatePositions();
+}
+
+void KviNotifierWindowBorder::recalculatePositions()
+{
+ m_rct.setHeight(m_iRctHeight);
+ m_rct.setWidth(m_iRctWidth);
+ m_rct.setTopLeft(QPoint(0,0));
+
+ m_closeIconRect.setX(m_rct.width()-m_pixCaptionDX->width()-m_pixIconClose->width());
+ m_closeIconRect.setY(2);
+ m_closeIconRect.setWidth(m_pixIconClose->width());
+ m_closeIconRect.setHeight(m_pixIconClose->height());
+
+ m_captionRect.setTopLeft( m_rct.topLeft() );
+ m_captionRect.setSize( QSize(m_rct.width(),m_pixCaptionDX->height()) );
+
+ m_tabsRect.setTopLeft( QPoint(m_pixCaptionDX->width()+7,m_captionRect.height()) );
+ m_tabsRect.setSize( QSize(m_captionRect.width()-(2*m_pixCaptionDX->width())-7,m_iTabsHeight) );
+
+ m_bodyRect.setTopLeft( QPoint(m_pixCaptionDX->width()+7,m_captionRect.height()+m_tabsRect.height()) );
+ m_bodyRect.setSize( QSize(m_captionRect.width()-(2*m_pixCaptionDX->width())-7,m_rct.height()-m_captionRect.height()-m_pixDWN->height()-m_tabsRect.height()) );
+
+ m_titleRect.setTopLeft( QPoint(m_pixCaptionSX->width(), (m_captionRect.height()-m_iTitleFontHeight)/2 ) );
+ m_titleRect.setSize( QSize(m_rct.width()-m_pixCaptionSX->width()-m_pixCaptionDX->width(),m_iTitleFontHeight) );
+
+ m_progressRect.setTopLeft( QPoint(m_pixCaptionDX->width(),m_pixCaptionDX->height()));
+ m_progressRect.setSize( QSize(6,m_iRctHeight-m_pixCaptionDX->height()-m_pixDWN->height()));
+
+ m_bNeedToRedraw = true;
+}
+
+void KviNotifierWindowBorder::setCloseIcon(int state) {
+ m_bNeedToRedraw = true; m_eIconState = state;
+ switch (m_eIconState) {
+ case WDG_ICON_OUT: m_pixIconClose = m_pixIconClose_out; break;
+ case WDG_ICON_OVER: m_pixIconClose = m_pixIconClose_over; break;
+ case WDG_ICON_CLICKED: m_pixIconClose = m_pixIconClose_clicked; break;
+ };
+}
+
+void KviNotifierWindowBorder::resetIcons() {
+ setCloseIcon(WDG_ICON_OUT);
+}
+
+void KviNotifierWindowBorder::draw(QPainter * p, bool b) {
+
+ if (m_bNeedToRedraw) {
+
+ setPics(b);
+ setCloseIcon(m_eIconState);
+ // Draw the caption
+
+ p->drawPixmap(m_captionRect.x(),m_captionRect.y(), *m_pixCaptionSX);
+ p->drawTiledPixmap(m_pixCaptionSX->width(), 0, m_captionRect.width()-(m_pixCaptionSX->width()+m_pixCaptionDX->width()), m_captionRect.height(), *m_pixCaptionBKG);
+ p->drawPixmap(m_captionRect.width()-m_pixCaptionDX->width(), 0, *m_pixCaptionDX);
+
+ // Draw the tiled borders
+ p->drawTiledPixmap(0,m_captionRect.height(), m_pixSX->width(), m_bodyRect.height()+m_iTabsHeight, *m_pixSX );
+ p->drawTiledPixmap(m_bodyRect.width()+m_bodyRect.x(),m_captionRect.height(), m_pixDX->width(), m_bodyRect.height()+m_iTabsHeight, *m_pixDX );
+ p->drawTiledPixmap(m_pixDWNSX->width(),m_captionRect.height()+m_bodyRect.height()+m_iTabsHeight, m_bodyRect.width(), m_pixDWN->height(), *m_pixDWN );
+
+ // Draw down corners
+ p->drawPixmap(0,m_captionRect.height()+m_bodyRect.height()+m_iTabsHeight, *m_pixDWNSX);
+ p->drawPixmap(m_bodyRect.width()+m_bodyRect.x(),m_captionRect.height()+m_bodyRect.height()+m_iTabsHeight, *m_pixDWNDX);
+
+ //Drawing icons
+ p->drawPixmap(m_closeIconRect.x(), m_closeIconRect.y(), *m_pixIconClose);
+
+ m_bNeedToRedraw = false;
+
+ }
+
+}
diff --git a/src/modules/notifier/notifierwindowborder.h b/src/modules/notifier/notifierwindowborder.h index 13f6302ff..83f3a68ce 100644 --- a/src/modules/notifier/notifierwindowborder.h +++ b/src/modules/notifier/notifierwindowborder.h @@ -1,118 +1,154 @@ -#ifndef _KVINOTIFIERWINDOWBORDER_H_ -#define _KVINOTIFIERWINDOWBORDER_H_ -//============================================================================= -// -// File : kvinotifierwindowborder.h -// Created on lun 03 gen 2005 02:27:22 by Iacopo Palazzi -// -// This file is part of the KVIrc distribution -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// 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 "notifiersettings.h" - -#include <qsize.h> -#include <qrect.h> -#include <qpixmap.h> - -class QPainter; - -class KviNotifierWindowBorder -{ -public: - KviNotifierWindowBorder(QSize = QSize(WDG_MIN_WIDTH,WDG_MIN_HEIGHT)); - ~KviNotifierWindowBorder(); - -// ================================ -// Put members declaration below... -// ================================ -private: - QRect m_rct; - QPoint m_pnt; - - QRect m_closeIconRect; - - QRect m_captionRect; - QRect m_bodyRect; - QRect m_tabsRect; - QRect m_titleRect; - - QRect m_progressRect; - - // Pictures - - int m_iTabsHeight; - int m_iTitleFontHeight; - int m_eIconState; - int m_iRctWidth; - int m_iRctHeight; - - bool m_bNeedToRedraw; - -public: -protected: - - -// ================================ -// Put methods declaration below... -// ================================ -private: - void loadImages(); - void recalculatePositions(); - -public: - // reading methods... - void setWidth(int w); - void setHeight(int h); - void resize(int w, int h) { setWidth(w); setHeight(h); }; - void resize(QSize r) { setWidth(r.width()); setHeight(r.height()); }; - void setGeometry(QRect r) { r.topLeft(); r.size(); /*debug("x,y: %d,%d", r.x(), r.y()); debug("w,h: %d,%d", r.width(), r.height());*/ }; - void setGeometry(QPoint p, QSize s) { setPoint (p.x(), p.y()); setWidth (s.width()); setHeight (s.height()); }; - - void setPoint(int x, int y) { m_pnt.setX(x); m_pnt.setY(y); m_rct.setX(x); m_rct.setY(y); }; - - void setCloseIcon(int state); - void resetIcons(); - - // writing methods... - int x() { return m_pnt.x(); }; - int y() { return m_pnt.y(); }; - int width() { return m_rct.width(); }; - int height() { return m_rct.height(); }; - int baseLine() { return (y()+height()); }; - - QRect bodyRect() { return m_bodyRect; }; - QRect tabsRect() { return m_tabsRect; }; - QRect captionRect() { return m_captionRect; }; - QRect rect() { return m_rct; }; - QRect closeRect() { return m_closeIconRect; }; - QRect titleRect() { return m_titleRect; }; - QRect progressRect() { return m_progressRect; }; - - void centerTitle(int h) { m_iTitleFontHeight = h; }; - - void touch() { m_bNeedToRedraw = true; }; - - void draw(QPainter *, bool b = false); - void setPics(bool b = false); - -protected: - -}; - -#endif //!_KVINOTIFIERWINDOWBORDER_H_ +#ifndef _KVINOTIFIERWINDOWBORDER_H_
+#define _KVINOTIFIERWINDOWBORDER_H_
+//=============================================================================
+//
+// File : kvinotifierwindowborder.h
+// Created on lun 03 gen 2005 02:27:22 by Iacopo Palazzi
+//
+// This file is part of the KVIrc distribution
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// 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 "notifiersettings.h"
+
+#include <qsize.h>
+#include <qrect.h>
+#include <qpixmap.h>
+
+class QPainter;
+
+class KviNotifierWindowBorder
+{
+public:
+ KviNotifierWindowBorder(QSize = QSize(WDG_MIN_WIDTH,WDG_MIN_HEIGHT));
+ ~KviNotifierWindowBorder();
+
+// ================================
+// Put members declaration below...
+// ================================
+private:
+ QRect m_rct;
+ QPoint m_pnt;
+
+ QRect m_closeIconRect;
+
+ QRect m_captionRect;
+ QRect m_bodyRect;
+ QRect m_tabsRect;
+ QRect m_titleRect;
+
+ QRect m_progressRect;
+
+ // Pictures
+ QPixmap * m_pixSX;
+ QPixmap * m_pixDX;
+ QPixmap * m_pixDWN;
+ QPixmap * m_pixDWNSX;
+ QPixmap * m_pixDWNDX;
+ QPixmap * m_pixCaptionSX;
+ QPixmap * m_pixCaptionDX;
+ QPixmap * m_pixCaptionBKG;
+ QPixmap * m_pixIconClose_out;
+ QPixmap * m_pixIconClose_over;
+ QPixmap * m_pixIconClose_clicked;
+ QPixmap * m_pixIconClose;
+
+ QPixmap m_pixSX_N;
+ QPixmap m_pixDX_N;
+ QPixmap m_pixDWN_N;
+ QPixmap m_pixDWNSX_N;
+ QPixmap m_pixDWNDX_N;
+ QPixmap m_pixCaptionSX_N;
+ QPixmap m_pixCaptionDX_N;
+ QPixmap m_pixCaptionBKG_N;
+ QPixmap m_pixIconClose_out_N;
+ QPixmap m_pixIconClose_over_N;
+ QPixmap m_pixIconClose_clicked_N;
+
+ QPixmap m_pixSX_HL;
+ QPixmap m_pixDX_HL;
+ QPixmap m_pixDWN_HL;
+ QPixmap m_pixDWNSX_HL;
+ QPixmap m_pixDWNDX_HL;
+ QPixmap m_pixCaptionSX_HL;
+ QPixmap m_pixCaptionDX_HL;
+ QPixmap m_pixCaptionBKG_HL;
+ QPixmap m_pixIconClose_out_HL;
+ QPixmap m_pixIconClose_over_HL;
+ QPixmap m_pixIconClose_clicked_HL;
+
+ int m_iTabsHeight;
+ int m_iTitleFontHeight;
+ int m_eIconState;
+ int m_iRctWidth;
+ int m_iRctHeight;
+
+ bool m_bNeedToRedraw;
+
+public:
+protected:
+
+
+// ================================
+// Put methods declaration below...
+// ================================
+private:
+ void loadImages();
+ void recalculatePositions();
+
+public:
+ // reading methods...
+ void setWidth(int w);
+ void setHeight(int h);
+ void resize(int w, int h) { setWidth(w); setHeight(h); };
+ void resize(QSize r) { setWidth(r.width()); setHeight(r.height()); };
+ void setGeometry(QRect r) { r.topLeft(); r.size(); /*debug("x,y: %d,%d", r.x(), r.y()); debug("w,h: %d,%d", r.width(), r.height());*/ };
+ void setGeometry(QPoint p, QSize s) { setPoint (p.x(), p.y()); setWidth (s.width()); setHeight (s.height()); };
+
+ void setPoint(int x, int y) { m_pnt.setX(x); m_pnt.setY(y); m_rct.setX(x); m_rct.setY(y); };
+
+ void setCloseIcon(int state);
+ void resetIcons();
+
+ // writing methods...
+ int x() { return m_pnt.x(); };
+ int y() { return m_pnt.y(); };
+ int width() { return m_rct.width(); };
+ int height() { return m_rct.height(); };
+ int baseLine() { return (y()+height()); };
+
+ QRect bodyRect() { return m_bodyRect; };
+ QRect tabsRect() { return m_tabsRect; };
+ QRect captionRect() { return m_captionRect; };
+ QRect rect() { return m_rct; };
+ QRect closeRect() { return m_closeIconRect; };
+ QRect titleRect() { return m_titleRect; };
+ QRect progressRect() { return m_progressRect; };
+
+ void centerTitle(int h) { m_iTitleFontHeight = h; };
+
+ void touch() { m_bNeedToRedraw = true; };
+
+ void draw(QPainter *, bool b = false);
+ void setPics(bool b = false);
+
+protected:
+
+};
+
+#endif //!_KVINOTIFIERWINDOWBORDER_H_
diff --git a/src/modules/notifier/notifierwindowtabs.cpp b/src/modules/notifier/notifierwindowtabs.cpp index 21c1e0dfe..18109339c 100644 --- a/src/modules/notifier/notifierwindowtabs.cpp +++ b/src/modules/notifier/notifierwindowtabs.cpp @@ -1,772 +1,701 @@ -//============================================================================= -// -// File : kvinotifierwindowtabs.cpp -// Created on dom 02 gen 2005 15:30:50 by Iacopo Palazzi -// -// This file is part of the KVIrc irc client distribution -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it > -// -// 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_app.h" -#include "kvi_config.h" -#include "kvi_qstring.h" -#include "kvi_iconmanager.h" -#include "kvi_locale.h" -#include "kvi_options.h" -#include "kvi_window.h" - -#include <qevent.h> -#include <qpainter.h> -#include <qbrush.h> -#include <qcolor.h> -#include <qfontmetrics.h> - -#include "notifiermessage.h" -#include "notifierwindowtabs.h" - -extern KviNotifierWindow * g_pNotifierWindow; -KviNotifierWindowTabs * g_pTabs; - - -// --- tab object definition class - -KviNotifierWindowTab::KviNotifierWindowTab(KviWindow * pWnd, QString label) -{ - m_pWnd = pWnd; - m_label = label; - m_pMessageList = new KviPtrList<KviNotifierMessage>; - m_pMessageList->setAutoDelete(true); - m_bFocused = false; - m_pCurrentMessage = 0; - - KviStr buffer; - g_pApp->getReadOnlyConfigPath(buffer,"libkvinotifier.kvc",KviApp::ConfigPlugins,true); - KviConfig cfg(buffer.ptr(),KviConfig::Read); - cfg.setGroup("NotifierSkin"); - m_clrHighlightedLabel = cfg.readColorEntry("HighlightedTabLablerColor",QColor(255,0,0)); - m_clrNormalLabel = cfg.readColorEntry("NormalTabLablerColor",QColor(0,0,0)); - m_clrChangedLabel = cfg.readColorEntry("ChangedTabLablerColor",QColor(0,0,100)); - - if(pWnd) - { - connect(pWnd,SIGNAL(windowNameChanged()),this,SLOT(labelChanged())); - connect(pWnd,SIGNAL(destroyed()),this,SLOT(closeMe())); - } -} - -KviNotifierWindowTab::~KviNotifierWindowTab() -{ - delete m_pMessageList; -} - -void KviNotifierWindowTab::setNextMessageAsCurrent() -{ - if(!m_pCurrentMessage)return; - m_pMessageList->findRef(m_pCurrentMessage); - m_pCurrentMessage = m_pMessageList->next(); - if(!m_pCurrentMessage)m_pCurrentMessage = m_pMessageList->last(); -} - -void KviNotifierWindowTab::setPrevMessageAsCurrent() -{ - if(!m_pCurrentMessage)return; - m_pMessageList->findRef(m_pCurrentMessage); - m_pCurrentMessage = m_pMessageList->prev(); - if(!m_pCurrentMessage)m_pCurrentMessage = m_pMessageList->first(); -} - -void KviNotifierWindowTab::setLastMessageAsCurrent() -{ - m_pCurrentMessage = m_pMessageList->last(); -} - -void KviNotifierWindowTab::appendMessage(KviNotifierMessage * m) -{ - if(m_pCurrentMessage == m_pMessageList->last())m_pCurrentMessage = m; - m_pMessageList->append(m); - // avoid having too much messages floating around - while(m_pMessageList->count() > MAX_MESSAGES_IN_WINDOW) - { - m = m_pMessageList->first(); - m_pMessageList->removeFirst(); - if(m == m_pCurrentMessage) - m_pCurrentMessage = m_pMessageList->first(); - } - if(focused())setState(Normal); - else setState(Highlighted); -} - -void KviNotifierWindowTab::labelChanged() -{ - if(!m_pWnd)return; - m_label = m_pWnd->windowName(); - setState(Changed); - g_pTabs->needToRedraw(); - g_pNotifierWindow->update(); -} - -void KviNotifierWindowTab::closeMe() -{ - g_pTabs->closeTab(this); -} - -void KviNotifierWindowTab::setFocused(bool b) -{ - m_bFocused = b; - if(m_bFocused)setState(Normal); -} - -void KviNotifierWindowTab::setState(TabState state) -{ - m_eState=state; - switch (m_eState) { - case Normal: - m_cLabel = m_clrNormalLabel; - break; - case Highlighted: - m_cLabel = m_clrHighlightedLabel; - break; - case Changed: - m_cLabel = m_clrChangedLabel; - break; - } -}; - -int KviNotifierWindowTab::width(bool b) { - int width = 0; - QFont * font; - - - if (focused()) { - font = g_pTabs->fontFocused(); - } else { - font = g_pTabs->fontUnfocused(); - } - - QFontMetrics fm(*font); - width = fm.width(label())+8; - - return width; -} - -// ##################################################################################à -// ### end of tab object definition class -// ##################################################################################à - - -KviNotifierWindowTabs::KviNotifierWindowTabs(QRect r,KviNotifierWindow * wnd) -:m_pWindow(wnd) -{ - g_pTabs = this; - m_pPixmap = new QPixmap(); - m_pPainter = new QPainter(); - m_pTabFocused = 0; - m_pWndTabFocused = 0; - m_iTabToStartFrom = 0; - - m_tabPtrList.clear(); - - loadImages(); - initConfig(); - resize(r); - m_pLastTab = 0; -} - -KviNotifierWindowTabs::~KviNotifierWindowTabs() -{ - QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab; - for(tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ ) - delete tab.data(); - m_tabMap.clear(); - delete m_pFocusedFont; - delete m_pUnfocusedFont; - delete m_pPainter; - delete m_pPixmap; -} - -void KviNotifierWindowTabs::initConfig() -{ - KviStr buffer; - g_pApp->getReadOnlyConfigPath(buffer,"libkvinotifier.kvc",KviApp::ConfigPlugins,true); - - KviConfig cfg(buffer.ptr(),KviConfig::Read); - - cfg.setGroup("NotifierSkin"); - - QString szFamily = cfg.readEntry("TextFontFocusedTab","Arial"); - m_pFocusedFont = new QFont(szFamily,cfg.readIntEntry("TextFocusedFontSize",9)); - m_pFocusedFont->setItalic(true); - m_pFocusedFont->setBold(true); - szFamily = cfg.readEntry("TextFontUnfocusedTab","Arial"); - m_pUnfocusedFont = new QFont(szFamily,cfg.readIntEntry("TextUnfocusedFontSize",9)); - m_pUnfocusedFont->setItalic(true); -} - -void KviNotifierWindowTabs::loadImages() -{ - QPixmap * p; - if((p = g_pIconManager->getPixmap("notifier_right.png"))) - m_pixIconTabNext = *p; - - if((p = g_pIconManager->getPixmap("notifier_left.png"))) - m_pixIconTabPrev = *p; - - if((p = g_pIconManager->getPixmap("notifier_close.png"))) - m_pixIconCloseTab = *p; - - m_closeTabIconState = WDG_ICON_OFF; - -} - - - -void KviNotifierWindowTabs::addMessage(KviWindow * pWnd, KviNotifierMessage * message) -{ - QString sender = pWnd ? pWnd->windowName() : "----"; - - // Qui servirebbe anche una lista... perche' quando si inserisce - // un tab lui lo piazza dove gli pare nell'ordine - // e quindi iterando i tab nuovi possono trovarsi PRIMA dei tab vecchi - // il che' confonde un po - KviNotifierWindowTab * tab; - if (!m_tabMap.contains(pWnd)) { - m_tabMap.insert(pWnd, tab = new KviNotifierWindowTab(pWnd, sender)); - m_tabPtrList.append(tab); - } else { - tab = m_tabMap[pWnd]; - } - - tab->appendMessage(message); - - setFocusOn(tab); - if((g_pNotifierWindow->state()==Hidden) || (!m_pTabFocused)) - { -// setFocusOn(tab); - } else { - needToRedraw(); - } -} - -void KviNotifierWindowTabs::resize(QRect r) -{ - m_rct.setX(r.x()); - m_rct.setY(r.y()); - m_rct.setHeight(r.height()); - setWidth(r.width()); - - recalculatePositions(); -} - -void KviNotifierWindowTabs::setWidth(int w) { - m_rct.setWidth(w); - recalculatePositions(); -} - -void KviNotifierWindowTabs::recalculatePositions() -{ - m_rctCloseTabIcon.setX(m_rct.x()+m_rct.width()-m_pixIconCloseTab.width()); - m_rctCloseTabIcon.setY(m_rct.y()); - m_rctCloseTabIcon.setWidth(m_pixIconCloseTab.width()); - m_rctCloseTabIcon.setHeight(m_pixIconCloseTab.height()); - // The sensible area for the Close Icon - m_rctCloseTabIconHotArea = m_rctCloseTabIcon; - - if (m_bIsOverRightBound) { - m_rctNextIcon.setX(m_rct.x() + m_rct.width() - m_rctCloseTabIcon.width() - m_pixIconTabNext.width()); - m_rctNextIcon.setY(m_rct.y()); - m_rctNextIcon.setWidth(m_pixIconTabNext.width()); - m_rctNextIcon.setHeight(m_pixIconTabNext.height()); - } - - if (m_bIsOverLeftBound) { - m_rctPrevIcon.setX(m_rct.x()); - m_rctPrevIcon.setY(m_rct.y()); - m_rctPrevIcon.setWidth(m_pixIconTabPrev.width()); - m_rctPrevIcon.setHeight(m_pixIconTabPrev.height()); - } - - int tmpX, tmpWidth; - - tmpWidth = m_rctCloseTabIcon.x() - m_rct.x(); - - if (m_bIsOverRightBound) { - tmpWidth -= m_rctNextIcon.width(); - } - - if (m_bIsOverLeftBound) { - tmpWidth -= m_rctPrevIcon.width(); - tmpX = m_rct.x() + m_rctPrevIcon.width(); - } else { - tmpX = m_rct.x(); - } - - m_rctTabs.setX(tmpX); - m_rctTabs.setY(m_rct.y()); - - m_rctTabs.setWidth(tmpWidth); - m_rctTabs.setHeight(m_rct.height()); - - needToRedraw(); -} - -void KviNotifierWindowTabs::prev() -{ - if(!m_pTabFocused)return; - - KviNotifierWindowTab * tab; - KviPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList); - - tab = m_tabMap[m_pTabFocused->wnd()]; - tabIterator.atFirst(); - while ((tabIterator.current()) != tab) { - ++tabIterator; - } - - if (!tabIterator.atFirst()) { - --tabIterator; - tab = tabIterator.current(); - setFocusOn(tab); - } - -} - -void KviNotifierWindowTabs::next() -{ - if(!m_pTabFocused)return; - - KviNotifierWindowTab * tab; - KviPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList); - - tab = m_tabMap[m_pTabFocused->wnd()]; - tabIterator.atFirst(); - while ((tabIterator.current()) != tab) { - ++tabIterator; - } - - if (!tabIterator.atLast()) { - ++tabIterator; - tab = tabIterator.current(); - setFocusOn(tab); - } - -} - -void KviNotifierWindowTabs::mousePressEvent(QMouseEvent * e) { - - if (m_bIsOverRightBound && m_rctNextIcon.contains(e->pos())) { - return; - } - - if (m_bIsOverLeftBound && m_rctPrevIcon.contains(e->pos())) { - return; - } - - if(m_rctTabs.contains(e->pos())) - { - QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab; - for (tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ ) { - if (tab.data()->rect().contains(e->pos())) { - if(g_pNotifierWindow->shiftPressed()) - closeTab(tab.data()); - else - setFocusOn(tab.data()); - return; - } - } - } - - if (m_rctCloseTabIconHotArea.contains(e->pos())) { - setCloseTabIcon(WDG_ICON_CLICKED); - return; - } - -} -void KviNotifierWindowTabs::leaveEvent() -{ - if(m_pLastTab) { - g_pNotifierWindow->update(); - m_bNeedToRedraw = true; - m_pLastTab = 0; - } -} - - -void KviNotifierWindowTabs::mouseMoveEvent(QMouseEvent * e) -{ - bool bInTab = false; - bool bNewTab = false; - if(m_rctTabs.contains(e->pos())) - { - QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab; - for (tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ ) { - if (tab.data()->rect().contains(e->pos())) { - if(m_pLastTab != tab.data()) { - bNewTab = true; - m_pLastTab = tab.data(); - } - bInTab = true; - break; - } - } - } - - if(bInTab || m_rctCloseTabIconHotArea.contains(e->pos())) - { - g_pNotifierWindow->setCursor(Qt::PointingHandCursor); - } else { - g_pNotifierWindow->setCursor(Qt::ArrowCursor); - if(m_pLastTab) { - bNewTab = true; - m_pLastTab = 0; - } - } - if(bNewTab) { - g_pNotifierWindow->update(); - m_bNeedToRedraw = true; - } -} - -void KviNotifierWindowTabs::mouseReleaseEvent(QMouseEvent * e) -{ - - if (m_bIsOverRightBound && m_rctNextIcon.contains(e->pos())) { - scrollTabsLeft(); - return; - } - - if (m_bIsOverLeftBound && m_rctPrevIcon.contains(e->pos())) { - scrollTabsRight(); - return; - } - - if(currentTab()) - { - if (rctCloseTabIconHotArea().contains(e->pos())) - { - g_pNotifierWindow->close(); - g_pNotifierWindow->update(); - } - } - -} - -void KviNotifierWindowTabs::scrollTabsLeft() { - if (m_bIsOverRightBound) { - m_iTabToStartFrom++; - } - needToRedraw(); - g_pNotifierWindow->update(); -}; - -void KviNotifierWindowTabs::scrollTabsRight() { - if (m_bIsOverLeftBound) { - m_iTabToStartFrom--; - } - needToRedraw(); - g_pNotifierWindow->update(); -}; - -void KviNotifierWindowTabs::setCloseTabIcon(int state) { - -} - -void KviNotifierWindowTabs::resetIcons() -{ - setCloseTabIcon(WDG_ICON_OFF); -} - -void KviNotifierWindowTabs::setFocusOn(KviNotifierWindowTab * tab) -{ - if(m_pTabFocused)m_pTabFocused->setFocused(false); - m_pTabFocused = tab; - if(m_pTabFocused)m_pTabFocused->setFocused(); - - if (m_lastVisitedTabPtrList.containsRef(tab)) { - m_lastVisitedTabPtrList.removeRef(tab); - } - - m_lastVisitedTabPtrList.insert(0, tab); - - //scrollTabsRight(); - - KviPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList); - - - tabIterator.toFirst(); - - int i = 0; - while(m_iTabToStartFrom!=i) { - if(tabIterator.current()==m_pTabFocused) - { - m_iTabToStartFrom=i; - break; - } - i++; - ++tabIterator; - } - int iWidth = 0; - KviPtrListIterator<KviNotifierWindowTab> startIterator (m_tabPtrList); - - i=0; - while(m_iTabToStartFrom!=i) { - i++; - ++startIterator; - } - - KviNotifierWindowTab * pTab = tabIterator.current(); - while ( pTab ) - { - iWidth+=pTab->width(); - while(iWidth>=m_rctTabs.width()) - { - m_iTabToStartFrom++; - iWidth-=startIterator.current()->width(); - ++startIterator; - } - - if(pTab == m_pTabFocused ) break; - - ++tabIterator; - pTab = tabIterator.current(); - } - - needToRedraw(); - - g_pNotifierWindow->update(); -} - -void KviNotifierWindowTabs::contextPopup(KviTalPopupMenu *pPopup,const QPoint& pos) -{ - if(m_rctTabs.contains(pos)) - { - int i=0; - QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab; - for (tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ ) { - if (tab.data()->rect().contains(pos)) { - int id = pPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLOSE)),__tr2qs_ctx("Close tab","notifier"),g_pNotifierWindow,SLOT(hideTab(int))); - pPopup->setItemParameter(id,i); - } - i++; - } - } -} - -void KviNotifierWindowTabs::draw(QPainter * p) -{ - if(!m_bNeedToRedraw)return; - - - m_pPixmap->resize(m_rct.width(), m_rct.height()); - - m_pPainter->begin(m_pPixmap); - bitBlt(m_pPixmap,0,0,m_pWindow->background(),m_rct.x(), m_rct.y()); - - QFont tmpFont; - tmpFont = p->font(); - - m_pPainter->setFont(tmpFont); - - QString str; - - bool isBigger = false; - - int offset = 0; - - int closeIcon_X = m_rct.width() - m_rctCloseTabIcon.width(); - int nextIcon_X = closeIcon_X - m_pixIconTabNext.width(); - int prevIcon_X = m_rct.x(); - - int tmpTabsWidth = 0; - - KviPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList); - - //m_tabPtrList.findRef(m_tabMap[m_pTabFocused->wnd()]); - -// QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab; - KviNotifierWindowTab * tab; - //for (tab = m_tabMap.begin(); tab != m_tabMap.end() && !isBigger; tab++ ) - tabIterator.toFirst(); - - int i = 0; - while(m_iTabToStartFrom!=i) { - i++; - ++tabIterator; - } - - if (m_iTabToStartFrom) { - // Draw the left arrow for more tabs - m_bIsOverLeftBound = true; - m_pPainter->drawPixmap(0, 0, m_pixIconTabPrev); - m_rctPrevIcon = QRect(m_rct.x(),m_rct.y(),m_pixIconTabPrev.width(),m_pixIconTabPrev.height()); - offset = m_pixIconTabPrev.width(); - } else { - m_bIsOverLeftBound = false; - } - - while ( (tab = tabIterator.current()) != 0) - { - ++tabIterator; - - isBigger = ( offset+4+tab->width() > m_rctTabs.width()); - if(isBigger) break; - if (tab->focused()) { - - m_pPainter->setFont(*m_pFocusedFont); - - tab->setRect(offset + m_rct.y(), m_rct.y(), tab->width(), - m_rctTabs.height()); - - QPen tmpP = m_pPainter->pen(); - - m_pPainter->setPen(QColor(143,154,202)); - - - if(tab == m_pLastTab) - { - QBrush tmpB = m_pPainter->brush(); - m_pPainter->setBrush(QColor(212,212,212)); - m_pPainter->drawRect(offset,0, tab->width(), - m_rctTabs.height()); - m_pPainter->setBrush(tmpB); - } else { - m_pPainter->drawRoundRect(offset,0, tab->width(), - m_rctTabs.height(),10); - } - - m_pPainter->setPen(tab->labelColor()); - m_pPainter->drawText(offset+4,m_rctTabs.height()-2,tab->label()); - m_pPainter->setPen(tmpP); - - offset += tab->width(); - - } else { - - m_pPainter->setFont(*m_pUnfocusedFont); - - tab->setRect(offset + m_rct.y(), m_rct.y(), tab->width(), - m_rctTabs.height() ); - QPen tmpP = m_pPainter->pen(); - - m_pPainter->setPen(QColor(212,212,212)); - - if(tab == m_pLastTab) - { - QBrush tmpB = m_pPainter->brush(); - m_pPainter->setBrush(QColor(212,212,212)); - m_pPainter->drawRect(offset,0, tab->width(), - m_rctTabs.height()); - m_pPainter->setBrush(tmpB); - } else - m_pPainter->drawRoundRect(offset,0, tab->width(), - m_rctTabs.height(),10); - - m_pPainter->setPen(tab->labelColor()); - m_pPainter->drawText(offset+4,m_rctTabs.height()-2,tab->label()); - - offset += tab->width()+2; - } - } - - if (isBigger) { - // Draw the right arrow for more tabs - m_bIsOverRightBound = true; - m_pPainter->drawPixmap(nextIcon_X, 0, m_pixIconTabNext); - m_rctNextIcon = QRect(m_rct.x()+nextIcon_X,m_rct.y(),m_pixIconTabNext.width(),m_pixIconTabNext.height()); - } else { - m_bIsOverRightBound = false; - } - - m_pPainter->drawPixmap(closeIcon_X, 0, m_pixIconCloseTab); - - m_pPainter->end(); - - p->drawPixmap(m_rct.x(), m_rct.y(), *m_pPixmap, 0, 0, m_pPixmap->width(), m_pPixmap->height()); - - m_bNeedToRedraw = false; - -} - -void KviNotifierWindowTabs::markAllMessagesAsHistoric() -{ - QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab; - // Iterating every tab - for (tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ ) - { - // Setting all messages of the current tab as historic - // tab.data()->expireMessages(); - KviPtrList<KviNotifierMessage> * tmpMessageList = tab.data()->messageList(); - for(KviNotifierMessage * m = tmpMessageList->last();m;m = tmpMessageList->prev()) { - if(m->historic())break; - m->setHistoric(); - } - } -} - -void KviNotifierWindowTabs::closeTab(KviWindow * pWnd) -{ - KviNotifierWindowTab * pTab = m_tabMap.find(pWnd).data(); - closeTab(pWnd, pTab); -} - -void KviNotifierWindowTabs::closeTab(KviNotifierWindowTab * pTab) -{ - KviWindow * pWnd = pTab->wnd(); - closeTab(pWnd, pTab); -} - -void KviNotifierWindowTabs::closeCurrentTab() -{ - // Paranoic checks... - if (!m_pTabFocused) return; // The current tab is null? Please, kill me... - KviNotifierWindowTab * pTab = m_pTabFocused; - if (m_tabMap.isEmpty()) return; // Empty??? The World is ending... - KviWindow * pWnd = pTab->wnd(); - if (!m_tabMap.contains(pWnd)) return; // The current tab is not on the map??? Call 911!! - // End paranoic stuff, go back to sanity... - - closeTab(pWnd, pTab); -} - -void KviNotifierWindowTabs::closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab) -{ - // Ok, we should be sure to delete the right tab... - m_tabPtrList.removeRef(pTab); - m_lastVisitedTabPtrList.removeRef(pTab); - m_tabMap.remove(pWnd); - delete pTab; - - if(m_tabMap.empty()) - { - m_pTabFocused = 0; - g_pNotifierWindow->showLineEdit(false); - g_pNotifierWindow->doHide(false); - } else { - - if (m_lastVisitedTabPtrList.count()) { - m_pTabFocused = m_lastVisitedTabPtrList.getFirst(); - } else { - m_pTabFocused = m_tabPtrList.getLast(); - } - - m_pTabFocused->setFocused(true); - } - m_bNeedToRedraw = true; - g_pNotifierWindow->update(); -} - -#include "m_notifierwindowtabs.moc" +//=============================================================================
+//
+// File : kvinotifierwindowtabs.cpp
+// Created on dom 02 gen 2005 15:30:50 by Iacopo Palazzi
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena(dot)linux(dot)it >
+//
+// 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_app.h"
+#include "kvi_config.h"
+#include "kvi_qstring.h"
+#include "kvi_iconmanager.h"
+#include "kvi_locale.h"
+#include "kvi_options.h"
+#include "kvi_window.h"
+
+#include <qevent.h>
+#include <qpainter.h>
+#include <qbrush.h>
+#include <qcolor.h>
+#include <qfontmetrics.h>
+
+#include "notifiermessage.h"
+#include "notifierwindowtabs.h"
+
+extern KviNotifierWindow * g_pNotifierWindow;
+KviNotifierWindowTabs * g_pTabs;
+
+
+// --- tab object definition class
+
+KviNotifierWindowTab::KviNotifierWindowTab(KviWindow * pWnd, QString label)
+{
+ m_pWnd = pWnd;
+ m_label = label;
+ m_pMessageList = new KviPtrList<KviNotifierMessage>;
+ m_pMessageList->setAutoDelete(true);
+ m_bFocused = false;
+ m_pCurrentMessage = 0;
+
+ KviStr buffer;
+ g_pApp->getReadOnlyConfigPath(buffer,"libkvinotifier.kvc",KviApp::ConfigPlugins,true);
+ KviConfig cfg(buffer.ptr(),KviConfig::Read);
+ cfg.setGroup("NotifierSkin");
+ m_clrHighlightedLabel = cfg.readColorEntry("HighlightedTabLablerColor",QColor(200,0,0));
+ m_clrNormalLabel = cfg.readColorEntry("NormalTabLablerColor",QColor(0,0,0));
+ m_clrChangedLabel = cfg.readColorEntry("ChangedTabLablerColor",QColor(0,0,100));
+
+ if(pWnd)
+ {
+ connect(pWnd,SIGNAL(windowNameChanged()),this,SLOT(labelChanged()));
+ connect(pWnd,SIGNAL(destroyed()),this,SLOT(closeMe()));
+ }
+}
+
+KviNotifierWindowTab::~KviNotifierWindowTab()
+{
+ delete m_pMessageList;
+}
+
+void KviNotifierWindowTab::setNextMessageAsCurrent()
+{
+ if(!m_pCurrentMessage)return;
+ m_pMessageList->findRef(m_pCurrentMessage);
+ m_pCurrentMessage = m_pMessageList->next();
+ if(!m_pCurrentMessage)m_pCurrentMessage = m_pMessageList->last();
+}
+
+void KviNotifierWindowTab::setPrevMessageAsCurrent()
+{
+ if(!m_pCurrentMessage)return;
+ m_pMessageList->findRef(m_pCurrentMessage);
+ m_pCurrentMessage = m_pMessageList->prev();
+ if(!m_pCurrentMessage)m_pCurrentMessage = m_pMessageList->first();
+}
+
+void KviNotifierWindowTab::setLastMessageAsCurrent()
+{
+ m_pCurrentMessage = m_pMessageList->last();
+}
+
+void KviNotifierWindowTab::appendMessage(KviNotifierMessage * m)
+{
+ if(m_pCurrentMessage == m_pMessageList->last())m_pCurrentMessage = m;
+ m_pMessageList->append(m);
+ // avoid having too much messages floating around
+ while(m_pMessageList->count() > MAX_MESSAGES_IN_WINDOW)
+ {
+ m = m_pMessageList->first();
+ m_pMessageList->removeFirst();
+ if(m == m_pCurrentMessage)
+ m_pCurrentMessage = m_pMessageList->first();
+ }
+ if(focused())setState(Normal);
+ else setState(Highlighted);
+}
+
+void KviNotifierWindowTab::labelChanged()
+{
+ if(!m_pWnd)return;
+ m_label = m_pWnd->windowName();
+ setState(Changed);
+ g_pTabs->needToRedraw();
+ g_pNotifierWindow->update();
+}
+
+void KviNotifierWindowTab::closeMe()
+{
+ g_pTabs->closeTab(this);
+}
+
+void KviNotifierWindowTab::setFocused(bool b)
+{
+ m_bFocused = b;
+ if(m_bFocused)setState(Normal);
+}
+
+void KviNotifierWindowTab::setState(TabState state)
+{
+ m_eState=state;
+ switch (m_eState) {
+ case Normal:
+ m_cLabel = m_clrNormalLabel;
+ break;
+ case Highlighted:
+ m_cLabel = m_clrHighlightedLabel;
+ break;
+ case Changed:
+ m_cLabel = m_clrChangedLabel;
+ break;
+ }
+};
+
+int KviNotifierWindowTab::width(bool b) {
+ int width = 0;
+ QFont * font;
+
+ QPixmap * sx;
+ QPixmap * dx;
+
+ if (focused()) {
+ font = g_pTabs->fontFocused();
+ sx = g_pTabs->tabFocusedPixSx();
+ dx = g_pTabs->tabFocusedPixSx();
+ } else {
+ sx = g_pTabs->tabUnfocusedPixSx();
+ dx = g_pTabs->tabUnfocusedPixSx();
+ font = g_pTabs->fontUnfocused();
+ }
+
+ QFontMetrics fm(*font);
+ width = fm.width(label())+2;
+ if (!b) width += sx->width() + dx->width();
+
+ return width;
+}
+
+// ##################################################################################à
+// ### end of tab object definition class
+// ##################################################################################à
+
+
+KviNotifierWindowTabs::KviNotifierWindowTabs(QRect r)
+{
+ g_pTabs = this;
+ m_pPixmap = new QPixmap();
+ m_pPainter = new QPainter();
+ m_pTabFocused = 0;
+ m_pWndTabFocused = 0;
+ m_iTabToStartFrom = 0;
+
+ m_tabPtrList.clear();
+
+ loadImages();
+ initConfig();
+ resize(r);
+}
+
+KviNotifierWindowTabs::~KviNotifierWindowTabs()
+{
+ QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab;
+ for(tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ )
+ delete tab.data();
+ m_tabMap.clear();
+ delete m_pFocusedFont;
+ delete m_pUnfocusedFont;
+ delete m_pPainter;
+ delete m_pPixmap;
+}
+
+void KviNotifierWindowTabs::initConfig()
+{
+ KviStr buffer;
+ g_pApp->getReadOnlyConfigPath(buffer,"libkvinotifier.kvc",KviApp::ConfigPlugins,true);
+
+ KviConfig cfg(buffer.ptr(),KviConfig::Read);
+
+ cfg.setGroup("NotifierSkin");
+
+ QString szFamily = cfg.readEntry("TextFontFocusedTab","Arial");
+ m_pFocusedFont = new QFont(szFamily,cfg.readIntEntry("TextFocusedFontSize",10));
+ m_pFocusedFont->setBold(true);
+ szFamily = cfg.readEntry("TextFontUnfocusedTab","Arial");
+ m_pUnfocusedFont = new QFont(szFamily,cfg.readIntEntry("TextUnfocusedFontSize",9));
+}
+
+void KviNotifierWindowTabs::loadImages()
+{
+ QPixmap * p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_dx.png")))
+ m_pixDX = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_sx.png")))
+ m_pixSX = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_bkg.png")))
+ m_pixBKG = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_focused_sx.png")))
+ m_pixSXFocused = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_focused_dx.png")))
+ m_pixDXFocused = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_focused_bkg.png")))
+ m_pixBKGFocused = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_unfocused_sx.png")))
+ m_pixSXUnfocused = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_unfocused_dx.png")))
+ m_pixDXUnfocused = *p;
+ if((p = g_pIconManager->getPixmap("notifier_pix_tab_unfocused_bkg.png")))
+ m_pixBKGUnfocused = *p;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_next_out.png")))
+ m_pixIconTabNext_out = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_next_over.png")))
+ m_pixIconTabNext_over = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_next_clicked.png")))
+ m_pixIconTabNext_clicked = *p;
+
+ m_pixIconTabNext = m_pixIconTabNext_out;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_prev_out.png")))
+ m_pixIconTabPrev_out = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_prev_over.png")))
+ m_pixIconTabPrev_over = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_prev_clicked.png")))
+ m_pixIconTabPrev_clicked = *p;
+
+ m_pixIconTabPrev = m_pixIconTabPrev_out;
+
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_close_off.png")))
+ m_pixIconCloseTab_off = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_close_on.png")))
+ m_pixIconCloseTab_on = *p;
+ if((p = g_pIconManager->getPixmap("notifier_icon_tab_close_clicked.png")))
+ m_pixIconCloseTab_clicked = *p;
+
+ m_pixIconCloseTab = m_pixIconCloseTab_off;
+
+ m_closeTabIconState = WDG_ICON_OFF;
+
+}
+
+
+
+void KviNotifierWindowTabs::addMessage(KviWindow * pWnd, KviNotifierMessage * message)
+{
+ QString sender = pWnd ? pWnd->windowName() : "----";
+
+ // Qui servirebbe anche una lista... perche' quando si inserisce
+ // un tab lui lo piazza dove gli pare nell'ordine
+ // e quindi iterando i tab nuovi possono trovarsi PRIMA dei tab vecchi
+ // il che' confonde un po
+ KviNotifierWindowTab * tab;
+ if (!m_tabMap.contains(pWnd)) {
+ m_tabMap.insert(pWnd, tab = new KviNotifierWindowTab(pWnd, sender));
+ m_tabPtrList.append(tab);
+ } else {
+ tab = m_tabMap[pWnd];
+ }
+
+ tab->appendMessage(message);
+
+ if((g_pNotifierWindow->state()==Hidden) || (!m_pTabFocused))
+ {
+ setFocusOn(tab);
+ } else {
+ needToRedraw();
+ }
+}
+
+void KviNotifierWindowTabs::resize(QRect r)
+{
+ m_rct.setX(r.x());
+ m_rct.setY(r.y());
+ m_rct.setHeight(r.height());
+ setWidth(r.width());
+
+ recalculatePositions();
+}
+
+void KviNotifierWindowTabs::setWidth(int w) {
+ m_rct.setWidth(w);
+ recalculatePositions();
+}
+
+void KviNotifierWindowTabs::recalculatePositions()
+{
+ m_rctCloseTabIcon.setX(m_rct.x()+m_rct.width()-m_pixIconCloseTab.width());
+ m_rctCloseTabIcon.setY(m_rct.y());
+ m_rctCloseTabIcon.setWidth(m_pixIconCloseTab.width());
+ m_rctCloseTabIcon.setHeight(m_pixIconCloseTab.height());
+ // The sensible area for the Close Icon
+ m_rctCloseTabIconHotArea.setX(m_rctCloseTabIcon.x()+6);
+ m_rctCloseTabIconHotArea.setY(m_rctCloseTabIcon.y()+3);
+ m_rctCloseTabIconHotArea.setWidth(16);
+ m_rctCloseTabIconHotArea.setHeight(16);
+
+ if (m_bIsOverRightBound) {
+ m_rctNextIcon.setX(m_rct.x() + m_rct.width() - m_rctCloseTabIcon.width() - m_pixIconTabNext.width());
+ m_rctNextIcon.setY(m_rct.y());
+ m_rctNextIcon.setWidth(m_pixIconTabNext.width());
+ m_rctNextIcon.setHeight(m_pixIconTabNext.height());
+ }
+
+ if (m_bIsOverLeftBound) {
+ m_rctPrevIcon.setX(m_rct.x());
+ m_rctPrevIcon.setY(m_rct.y());
+ m_rctPrevIcon.setWidth(m_pixIconTabPrev.width());
+ m_rctPrevIcon.setHeight(m_pixIconTabPrev.height());
+ }
+
+ int tmpX, tmpWidth;
+
+ tmpWidth = m_rctCloseTabIcon.x() - m_rct.x();
+
+ if (m_bIsOverRightBound) {
+ tmpWidth -= m_rctNextIcon.width();
+ }
+
+ if (m_bIsOverLeftBound) {
+ tmpWidth -= m_rctPrevIcon.width();
+ tmpX = m_rct.x() + m_rctPrevIcon.width();
+ } else {
+ tmpX = m_rct.x();
+ }
+
+ m_rctTabs.setX(tmpX);
+ m_rctTabs.setY(m_rct.y());
+
+ m_rctTabs.setWidth(tmpWidth);
+ m_rctTabs.setHeight(m_rct.height());
+
+ needToRedraw();
+}
+
+void KviNotifierWindowTabs::prev()
+{
+ if(!m_pTabFocused)return;
+
+ KviNotifierWindowTab * tab;
+ QPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
+
+ tab = m_tabMap[m_pTabFocused->wnd()];
+
+ tabIterator.atFirst();
+
+ while ((tabIterator.current()) != tab) {
+ ++tabIterator;
+ }
+
+ if (!tabIterator.atFirst()) {
+ --tabIterator;
+ tab = tabIterator.current();
+ setFocusOn(tab);
+ }
+
+}
+
+void KviNotifierWindowTabs::next()
+{
+ if(!m_pTabFocused)return;
+
+ KviNotifierWindowTab * tab;
+ QPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
+
+ tab = m_tabMap[m_pTabFocused->wnd()];
+ tabIterator.atFirst();
+ while ((tabIterator.current()) != tab) {
+ ++tabIterator;
+ }
+
+ if (!tabIterator.atLast()) {
+ ++tabIterator;
+ tab = tabIterator.current();
+ setFocusOn(tab);
+ }
+
+}
+
+void KviNotifierWindowTabs::mousePressEvent(QMouseEvent * e) {
+
+ if (m_bIsOverRightBound && m_rctNextIcon.contains(e->pos())) {
+ return;
+ }
+
+ if (m_bIsOverLeftBound && m_rctPrevIcon.contains(e->pos())) {
+ return;
+ }
+
+ if(m_rctTabs.contains(e->pos()))
+ {
+ QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab;
+ for (tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ ) {
+ if (tab.data()->rect().contains(e->pos())) {
+ setFocusOn(tab.data());
+ return;
+ }
+ }
+ }
+
+ if (m_rctCloseTabIconHotArea.contains(e->pos())) {
+ setCloseTabIcon(WDG_ICON_CLICKED);
+ return;
+ }
+
+}
+
+void KviNotifierWindowTabs::mouseMoveEvent(QMouseEvent * e)
+{
+ if (m_rctCloseTabIconHotArea.contains(e->pos()))
+ {
+ setCloseTabIcon(WDG_ICON_ON);
+ } else {
+ if (closeTabIconState()!=WDG_ICON_OFF)
+ setCloseTabIcon(WDG_ICON_OFF);
+ }
+}
+
+void KviNotifierWindowTabs::mouseReleaseEvent(QMouseEvent * e)
+{
+
+ if (m_bIsOverRightBound && m_rctNextIcon.contains(e->pos())) {
+ scrollTabsLeft();
+ return;
+ }
+
+ if (m_bIsOverLeftBound && m_rctPrevIcon.contains(e->pos())) {
+ scrollTabsRight();
+ return;
+ }
+
+ if(currentTab())
+ {
+ if (rctCloseTabIconHotArea().contains(e->pos()))
+ {
+ closeCurrentTab();
+ g_pNotifierWindow->update();
+ }
+ }
+
+}
+
+void KviNotifierWindowTabs::scrollTabsLeft() {
+ if (m_bIsOverRightBound) {
+ m_iTabToStartFrom++;
+ }
+ needToRedraw();
+ g_pNotifierWindow->update();
+};
+
+void KviNotifierWindowTabs::scrollTabsRight() {
+ if (m_bIsOverLeftBound) {
+ m_iTabToStartFrom--;
+ }
+ needToRedraw();
+ g_pNotifierWindow->update();
+};
+
+void KviNotifierWindowTabs::setCloseTabIcon(int state) {
+
+ //if (m_writeIconState==WDG_ICON_OFF && state!=WDG_ICON_OFF)
+ if (m_closeTabIconState!=state) {
+ switch (state) {
+ case WDG_ICON_ON: m_pixIconCloseTab = m_pixIconCloseTab_on; break;
+ case WDG_ICON_OFF: m_pixIconCloseTab = m_pixIconCloseTab_off; break;
+ case WDG_ICON_CLICKED: m_pixIconCloseTab = m_pixIconCloseTab_clicked; break;
+ }
+ needToRedraw();
+ m_closeTabIconState = state;
+ }
+}
+
+void KviNotifierWindowTabs::resetIcons()
+{
+ setCloseTabIcon(WDG_ICON_OFF);
+}
+
+void KviNotifierWindowTabs::setFocusOn(KviNotifierWindowTab * tab)
+{
+ if(m_pTabFocused)m_pTabFocused->setFocused(false);
+ m_pTabFocused = tab;
+ if(m_pTabFocused)m_pTabFocused->setFocused();
+
+ if (m_lastVisitedTabPtrList.containsRef(tab)) {
+ m_lastVisitedTabPtrList.removeRef(tab);
+ }
+
+ m_lastVisitedTabPtrList.insert(0, tab);
+
+ needToRedraw();
+
+ g_pNotifierWindow->update();
+}
+
+void KviNotifierWindowTabs::draw(QPainter * p)
+{
+ if(!m_bNeedToRedraw)return;
+
+ m_pPixmap->resize(m_rct.width(), m_rct.height());
+
+ m_pPainter->begin(m_pPixmap);
+
+ QFont tmpFont;
+ tmpFont = p->font();
+
+ m_pPainter->setFont(tmpFont);
+
+ QString str;
+
+ bool isBigger = false;
+
+ int offset = 0;
+
+ int closeIcon_X = m_rct.width() - m_rctCloseTabIcon.width();
+ int nextIcon_X = closeIcon_X - m_pixIconTabNext_out.width();
+ int prevIcon_X = m_rct.x();
+
+ int tmpTabsWidth = 0;
+
+ m_pPainter->drawPixmap(0,0,m_pixSX);
+ m_pPainter->drawPixmap(m_rct.width()-m_pixDX.width(),0,m_pixDX);
+ m_pPainter->drawTiledPixmap(m_pixSX.width(),0,m_rct.width()-m_pixSX.width()-m_pixDX.width(),m_rct.height(),m_pixBKG);
+
+ QPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
+
+ //m_tabPtrList.findRef(m_tabMap[m_pTabFocused->wnd()]);
+
+// QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab;
+ KviNotifierWindowTab * tab;
+ //for (tab = m_tabMap.begin(); tab != m_tabMap.end() && !isBigger; tab++ )
+ tabIterator.toFirst();
+
+ int i = 0;
+ while(m_iTabToStartFrom!=i) {
+ i++;
+ ++tabIterator;
+ }
+
+ while ( ((tab = tabIterator.current()) != 0) && !isBigger)
+ {
+ ++tabIterator;
+
+ if (tab->focused()) {
+
+ m_pPainter->setFont(*m_pFocusedFont);
+
+ tab->setRect(m_rct.x() + offset, m_rctTabs.y(), tab->width(), m_rctTabs.height());
+
+ m_pPainter->drawPixmap(offset,0,m_pixSXFocused);
+ m_pPainter->drawTiledPixmap(offset+m_pixSXFocused.width(),0,tab->width(true),m_rctTabs.height(),m_pixBKGFocused);
+ m_pPainter->drawPixmap(offset+m_pixSXFocused.width()+tab->width(true),0,m_pixDXFocused);
+ QPen tmpP = m_pPainter->pen(); m_pPainter->setPen(tab->labelColor());
+ m_pPainter->drawText(offset+m_pixSXFocused.width()+1,m_rctTabs.height()-NTF_TABS_FONT_BASELINE,tab->label());
+ m_pPainter->setPen(tmpP);
+
+ offset += tab->width();
+
+ } else {
+
+ m_pPainter->setFont(*m_pUnfocusedFont);
+
+ tab->setRect(m_rct.x() + offset, m_rctTabs.y(), tab->width(), m_rctTabs.height());
+
+ m_pPainter->drawPixmap(offset, 0, m_pixSXUnfocused);
+ m_pPainter->drawTiledPixmap(offset+m_pixSXUnfocused.width(), 0, tab->width(true), m_rctTabs.height(), m_pixBKGUnfocused);
+ m_pPainter->drawPixmap(offset+m_pixSXUnfocused.width()+tab->width(true), 0, m_pixDXUnfocused);
+ QPen tmpP = m_pPainter->pen(); m_pPainter->setPen(tab->labelColor());
+ m_pPainter->drawText(offset+m_pixSXUnfocused.width()+1,m_rctTabs.height()-NTF_TABS_FONT_BASELINE+1,tab->label());
+ m_pPainter->setPen(tmpP);
+ offset += tab->width();
+ }
+
+ if (offset > m_rctTabs.width()) isBigger = true; else isBigger = false;
+ }
+
+ if (m_iTabToStartFrom) {
+ // Draw the left arrow for more tabs
+ m_bIsOverLeftBound = true;
+ m_pPainter->drawPixmap(0, 0, m_pixIconTabPrev);
+ } else {
+ m_bIsOverLeftBound = false;
+ }
+
+ if (isBigger) {
+ // Draw the right arrow for more tabs
+ m_bIsOverRightBound = true;
+ m_pPainter->drawPixmap(nextIcon_X, 0, m_pixIconTabNext);
+ } else {
+ m_bIsOverRightBound = false;
+ }
+
+ m_pPainter->drawPixmap(closeIcon_X, 0, m_pixIconCloseTab);
+
+ m_pPainter->end();
+
+ p->drawPixmap(m_rct.x(), m_rct.y(), *m_pPixmap, 0, 0, m_pPixmap->width(), m_pPixmap->height());
+
+ m_bNeedToRedraw = false;
+
+}
+
+void KviNotifierWindowTabs::markAllMessagesAsHistoric()
+{
+ QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab;
+ // Iterating every tab
+ for (tab = m_tabMap.begin(); tab != m_tabMap.end(); tab++ )
+ {
+ // Setting all messages of the current tab as historic
+ // tab.data()->expireMessages();
+ KviPtrList<KviNotifierMessage> * tmpMessageList = tab.data()->messageList();
+ for(KviNotifierMessage * m = tmpMessageList->last();m;m = tmpMessageList->prev()) {
+ if(m->historic())break;
+ m->setHistoric();
+ }
+ }
+}
+
+void KviNotifierWindowTabs::closeTab(KviWindow * pWnd)
+{
+ KviNotifierWindowTab * pTab = m_tabMap.find(pWnd).data();
+ closeTab(pWnd, pTab);
+}
+
+void KviNotifierWindowTabs::closeTab(KviNotifierWindowTab * pTab)
+{
+ KviWindow * pWnd = pTab->wnd();
+ closeTab(pWnd, pTab);
+}
+
+void KviNotifierWindowTabs::closeCurrentTab()
+{
+ // Paranoic checks...
+ if (!m_pTabFocused) return; // The current tab is null? Please, kill me...
+ KviNotifierWindowTab * pTab = m_pTabFocused;
+ if (m_tabMap.isEmpty()) return; // Empty??? The World is ending...
+ KviWindow * pWnd = pTab->wnd();
+ if (!m_tabMap.contains(pWnd)) return; // The current tab is not on the map??? Call 911!!
+ // End paranoic stuff, go back to sanity...
+
+ closeTab(pWnd, pTab);
+}
+
+void KviNotifierWindowTabs::closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab)
+{
+ // Ok, we should be sure to delete the right tab...
+ m_tabPtrList.removeRef(pTab);
+ m_lastVisitedTabPtrList.removeRef(pTab);
+ m_tabMap.remove(pWnd);
+ delete pTab;
+
+ if(m_tabMap.empty())
+ {
+ m_pTabFocused = 0;
+ g_pNotifierWindow->showLineEdit(false);
+ g_pNotifierWindow->doHide(false);
+ } else {
+
+ if (m_lastVisitedTabPtrList.count()) {
+ m_pTabFocused = m_lastVisitedTabPtrList.getFirst();
+ } else {
+ m_pTabFocused = m_tabPtrList.getLast();
+ }
+
+ m_pTabFocused->setFocused(true);
+ }
+}
+
+#include "m_notifierwindowtabs.moc"
diff --git a/src/modules/notifier/notifierwindowtabs.h b/src/modules/notifier/notifierwindowtabs.h index ae828d98f..daa10b18a 100644 --- a/src/modules/notifier/notifierwindowtabs.h +++ b/src/modules/notifier/notifierwindowtabs.h @@ -1,244 +1,271 @@ -#ifndef _KVINOTIFIERWINDOWTABS_H_ -#define _KVINOTIFIERWINDOWTABS_H_ -//============================================================================= -// -// File : kvinotifierwindowtabs.h -// Created on dom 02 gen 2005 15:30:50 by Iacopo Palazzi -// -// This file is part of the KVIrc distribution -// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena.linux.it > -// -// 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 <qfont.h> -#include <qmap.h> -#include <qobject.h> -#include <qpixmap.h> -#include <qpoint.h> -#include <qrect.h> -#include "kvi_tal_popupmenu.h" - -#include "kvi_list.h" -#include "notifiersettings.h" -#include "notifierwindow.h" - -#include "notifiermessage.h" - -class QPainter; -class KviWindow; -class KviNotifierWindowTab; - -typedef struct wndTabPair_s { - KviNotifierWindowTab * pTab; - KviWindow * pWnd; -} wndTabPair; - -class KviNotifierWindowTab : public QObject // this class defines an object for every single tab about the tabs area -{ - Q_OBJECT -public: - KviNotifierWindowTab(KviWindow *, QString); - ~KviNotifierWindowTab(); - -// ================================ -// Put members declaration below... -// ================================ -private: - bool m_bFocused; - - QColor m_cLabel; - QColor m_clrHighlightedLabel; - QColor m_clrNormalLabel; - QColor m_clrChangedLabel; - - QRect m_rect; - - QString m_label; - - KviPtrList<KviNotifierMessage> * m_pMessageList; - KviWindow * m_pWnd; - KviNotifierMessage * m_pCurrentMessage; - - TabState m_eState; - -public: - -protected: - - -// ================================ -// Put methods declaration below... -// ================================ -private: - -private slots: - void labelChanged(); - void closeMe(); - -public: - bool focused() { return m_bFocused; }; - - int countMessage() { return m_pMessageList->count(); }; - int width(bool b = false); - - void appendMessage(KviNotifierMessage * m); - void setCurrentMessage(KviNotifierMessage * m) { m_pCurrentMessage = m; }; - void setFocused(bool b = true); - void setLastMessageAsCurrent(); - void setNextMessageAsCurrent(); - void setPrevMessageAsCurrent(); - void setState(TabState state); - void setRect(int x, int y, int w, int h) { m_rect.setX(x); m_rect.setY(y); m_rect.setWidth(w); m_rect.setHeight(h); }; - - QColor labelColor() {return m_cLabel; } - QRect rect() { return m_rect; }; - QString label() { return m_label; }; - - KviNotifierMessage * currentMessage() { return m_pCurrentMessage; }; - KviPtrList<KviNotifierMessage> * messageList() { return m_pMessageList; }; - KviWindow * window() { return m_pWnd; }; - KviWindow * wnd() {return m_pWnd; }; - - TabState state() { return m_eState; }; - -protected: - - - -}; - - -//#################################################################################################### -//## Tabs Manager -//#################################################################################################### - - -class KviNotifierWindowTabs // this class defines the tabs area -{ -public: - KviNotifierWindowTabs(QRect r,KviNotifierWindow * wnd); - ~KviNotifierWindowTabs(); - -// ================================ -// Put members declaration below... -// ================================ -private: - KviNotifierWindow * m_pWindow; - KviNotifierWindowTab * m_pLastTab; - QRect m_rct; - QPoint m_pnt; - - QMap<KviWindow *, KviNotifierWindowTab *> m_tabMap; - KviPtrList<KviNotifierWindowTab> m_tabPtrList; - KviPtrList<KviNotifierWindowTab> m_lastVisitedTabPtrList; - - QFont * m_pFocusedFont; - QFont * m_pUnfocusedFont; - - KviNotifierWindowTab * m_pTabFocused; - KviWindow * m_pWndTabFocused; - - QRect m_rctNextIcon; - QRect m_rctPrevIcon; - QRect m_rctCloseTabIcon; - QRect m_rctCloseTabIconHotArea; - QRect m_rctTabs; - - QPainter * m_pPainter; - QPixmap * m_pPixmap; - - QPixmap m_pixIconTabPrev; - - QPixmap m_pixIconTabNext; - - QPixmap m_pixIconCloseTab; - - int m_closeTabIconState; - int m_iTabToStartFrom; - - bool m_bIsOverLeftBound; - bool m_bIsOverRightBound; - bool m_bNeedToRedraw; - -public: - -protected: - - -// ================================ -// Put methods declaration below... -// ================================ -private: - void initConfig(); - void loadImages(); - -public: - QMap<KviWindow *, KviNotifierWindowTab *>* tabs() { return &m_tabMap; }; - void contextPopup(KviTalPopupMenu *pPopup,const QPoint& pos); - void addMessage(KviWindow *, KviNotifierMessage *); - void closeCurrentTab(); - void closeTab(KviWindow * pWnd); // referes to void closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab); - void closeTab(KviNotifierWindowTab * pTab); // referes to void closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab); - void closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab); - void draw(QPainter *); - void needToRedraw() { m_bNeedToRedraw = true; }; - void markAllMessagesAsHistoric(); - void mouseMoveEvent(QMouseEvent * e); - void mousePressEvent(QMouseEvent * e); - void mouseReleaseEvent(QMouseEvent * e); - void leaveEvent(); - void next(); - void prev(); - void recalculatePositions(); - void resetIcons(); - void resize(QRect); - void scrollTabsLeft(); - void scrollTabsRight(); - void setCloseTabIcon(int state); - void setCurrentMessage(KviNotifierMessage * m) { if(m_pTabFocused)m_pTabFocused->setCurrentMessage(m); }; - void setFocusOn(KviNotifierWindowTab *); - void setPoint(int x, int y) { m_pnt.setX(x); m_pnt.setY(y); }; - void setWidth(int w); - void touch() { m_bNeedToRedraw = true; }; - - int baseLine() { return (y()+height()); }; - int closeTabIconState() { return m_closeTabIconState; }; - int count() { return (int)m_tabMap.count(); }; - int height() { return m_rct.height(); }; - int width() { return m_rct.width(); }; - int x() { return m_pnt.x(); }; - int y() { return m_pnt.y(); }; - - QFont * fontFocused() { return m_pFocusedFont; }; - QFont * fontUnfocused() { return m_pUnfocusedFont; }; - - QRect rect() {return m_rct;}; - QRect rctCloseTabIconHotArea() {return m_rctCloseTabIconHotArea; }; - - KviNotifierWindowTab * currentTab() { return m_pTabFocused; }; - - KviNotifierMessage * currentMessage() { return m_pTabFocused ? m_pTabFocused->currentMessage() : 0; }; - - KviWindow * window() { return m_pTabFocused->wnd(); }; - - - -protected: - -}; - -#endif //!_KVINOTIFIERWINDOWTABS_H_ +#ifndef _KVINOTIFIERWINDOWTABS_H_
+#define _KVINOTIFIERWINDOWTABS_H_
+//=============================================================================
+//
+// File : kvinotifierwindowtabs.h
+// Created on dom 02 gen 2005 15:30:50 by Iacopo Palazzi
+//
+// This file is part of the KVIrc distribution
+// Copyright (C) 2005 Iacopo Palazzi < iakko(at)siena.linux.it >
+//
+// 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 <qfont.h>
+#include <qmap.h>
+#include <qobject.h>
+#include <qpixmap.h>
+#include <qpoint.h>
+#include <qrect.h>
+#include "kvi_settings.h"
+#include "kvi_list.h"
+#include "notifiersettings.h"
+#include "notifierwindow.h"
+
+#include "notifiermessage.h"
+
+#ifdef COMPILE_USE_QT4
+ #define QPtrList Q3PtrList
+ #define QPtrListIterator Q3PtrListIterator
+ #include <q3ptrlist.h>
+#else
+ #include <qptrlist.h>
+ //#include <qptrlistiterator.h>
+#endif
+
+class QPainter;
+class KviWindow;
+class KviNotifierWindowTab;
+
+typedef struct wndTabPair_s {
+ KviNotifierWindowTab * pTab;
+ KviWindow * pWnd;
+} wndTabPair;
+
+class KviNotifierWindowTab : public QObject // this class defines an object for every single tab about the tabs area
+{
+ Q_OBJECT
+public:
+ KviNotifierWindowTab(KviWindow *, QString);
+ ~KviNotifierWindowTab();
+
+// ================================
+// Put members declaration below...
+// ================================
+private:
+ bool m_bFocused;
+
+ QColor m_cLabel;
+ QColor m_clrHighlightedLabel;
+ QColor m_clrNormalLabel;
+ QColor m_clrChangedLabel;
+
+ QRect m_rect;
+
+ QString m_label;
+
+ KviPtrList<KviNotifierMessage> * m_pMessageList;
+ KviWindow * m_pWnd;
+ KviNotifierMessage * m_pCurrentMessage;
+
+ TabState m_eState;
+
+public:
+
+protected:
+
+
+// ================================
+// Put methods declaration below...
+// ================================
+private:
+
+private slots:
+ void labelChanged();
+ void closeMe();
+
+public:
+ bool focused() { return m_bFocused; };
+
+ int countMessage() { return m_pMessageList->count(); };
+ int width(bool b = false);
+
+ void appendMessage(KviNotifierMessage * m);
+ void setCurrentMessage(KviNotifierMessage * m) { m_pCurrentMessage = m; };
+ void setFocused(bool b = true);
+ void setLastMessageAsCurrent();
+ void setNextMessageAsCurrent();
+ void setPrevMessageAsCurrent();
+ void setState(TabState state);
+ void setRect(int x, int y, int w, int h) { m_rect.setX(x); m_rect.setY(y); m_rect.setWidth(w); m_rect.setHeight(h); };
+
+ QColor labelColor() {return m_cLabel; }
+ QRect rect() { return m_rect; };
+ QString label() { return m_label; };
+
+ KviNotifierMessage * currentMessage() { return m_pCurrentMessage; };
+ KviPtrList<KviNotifierMessage> * messageList() { return m_pMessageList; };
+ KviWindow * window() { return m_pWnd; };
+ KviWindow * wnd() {return m_pWnd; };
+
+ TabState state() { return m_eState; };
+
+protected:
+
+
+
+};
+
+
+//####################################################################################################
+//## Tabs Manager
+//####################################################################################################
+
+
+class KviNotifierWindowTabs // this class defines the tabs area
+{
+public:
+ KviNotifierWindowTabs(QRect r);
+ ~KviNotifierWindowTabs();
+
+// ================================
+// Put members declaration below...
+// ================================
+private:
+ QRect m_rct;
+ QPoint m_pnt;
+
+ QMap<KviWindow *, KviNotifierWindowTab *> m_tabMap;
+ QPtrList<KviNotifierWindowTab> m_tabPtrList;
+ QPtrList<KviNotifierWindowTab> m_lastVisitedTabPtrList;
+
+ QFont * m_pFocusedFont;
+ QFont * m_pUnfocusedFont;
+
+ KviNotifierWindowTab * m_pTabFocused;
+ KviWindow * m_pWndTabFocused;
+
+ QRect m_rctNextIcon;
+ QRect m_rctPrevIcon;
+ QRect m_rctCloseTabIcon;
+ QRect m_rctCloseTabIconHotArea;
+ QRect m_rctTabs;
+
+ QPainter * m_pPainter;
+ QPixmap * m_pPixmap;
+
+ QPixmap m_pixDX;
+ QPixmap m_pixSX;
+ QPixmap m_pixBKG;
+ QPixmap m_pixSXFocused;
+ QPixmap m_pixDXFocused;
+ QPixmap m_pixBKGFocused;
+ QPixmap m_pixSXUnfocused;
+ QPixmap m_pixDXUnfocused;
+ QPixmap m_pixBKGUnfocused;
+
+ QPixmap m_pixIconTabPrev;
+ QPixmap m_pixIconTabPrev_out;
+ QPixmap m_pixIconTabPrev_over;
+ QPixmap m_pixIconTabPrev_clicked;
+
+ QPixmap m_pixIconTabNext;
+ QPixmap m_pixIconTabNext_out;
+ QPixmap m_pixIconTabNext_over;
+ QPixmap m_pixIconTabNext_clicked;
+
+ QPixmap m_pixIconCloseTab;
+ QPixmap m_pixIconCloseTab_off;
+ QPixmap m_pixIconCloseTab_on;
+ QPixmap m_pixIconCloseTab_clicked;
+
+ int m_closeTabIconState;
+ int m_iTabToStartFrom;
+
+ bool m_bIsOverLeftBound;
+ bool m_bIsOverRightBound;
+ bool m_bNeedToRedraw;
+
+public:
+
+protected:
+
+
+// ================================
+// Put methods declaration below...
+// ================================
+private:
+ void initConfig();
+ void loadImages();
+
+public:
+ void addMessage(KviWindow *, KviNotifierMessage *);
+ void closeCurrentTab();
+ void closeTab(KviWindow * pWnd); // referes to void closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab);
+ void closeTab(KviNotifierWindowTab * pTab); // referes to void closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab);
+ void closeTab(KviWindow * pWnd, KviNotifierWindowTab * pTab);
+ void draw(QPainter *);
+ void needToRedraw() { m_bNeedToRedraw = true; };
+ void markAllMessagesAsHistoric();
+ void mouseMoveEvent(QMouseEvent * e);
+ void mousePressEvent(QMouseEvent * e);
+ void mouseReleaseEvent(QMouseEvent * e);
+ void next();
+ void prev();
+ void recalculatePositions();
+ void resetIcons();
+ void resize(QRect);
+ void scrollTabsLeft();
+ void scrollTabsRight();
+ void setCloseTabIcon(int state);
+ void setCurrentMessage(KviNotifierMessage * m) { if(m_pTabFocused)m_pTabFocused->setCurrentMessage(m); };
+ void setFocusOn(KviNotifierWindowTab *);
+ void setPoint(int x, int y) { m_pnt.setX(x); m_pnt.setY(y); };
+ void setWidth(int w);
+ void touch() { m_bNeedToRedraw = true; };
+
+ int baseLine() { return (y()+height()); };
+ int closeTabIconState() { return m_closeTabIconState; };
+ int count() { return (int)m_tabMap.count(); };
+ int height() { return m_rct.height(); };
+ int width() { return m_rct.width(); };
+ int x() { return m_pnt.x(); };
+ int y() { return m_pnt.y(); };
+
+ QFont * fontFocused() { return m_pFocusedFont; };
+ QFont * fontUnfocused() { return m_pUnfocusedFont; };
+
+ QPixmap * tabFocusedPixSx() {return &m_pixSXFocused; };
+ QPixmap * tabFocusedPixDx() {return &m_pixDXFocused; };
+ QPixmap * tabUnfocusedPixSx() {return &m_pixSXUnfocused; };
+ QPixmap * tabUnfocusedPixDx() {return &m_pixDXUnfocused; };
+
+ QRect rect() {return m_rct;};
+ QRect rctCloseTabIconHotArea() {return m_rctCloseTabIconHotArea; };
+
+ KviNotifierWindowTab * currentTab() { return m_pTabFocused; };
+
+ KviNotifierMessage * currentMessage() { return m_pTabFocused ? m_pTabFocused->currentMessage() : 0; };
+
+ KviWindow * window() { return m_pTabFocused->wnd(); };
+
+
+
+protected:
+
+};
+
+#endif //!_KVINOTIFIERWINDOWTABS_H_
|
