diff options
| author | 2006-12-18 01:34:15 +0000 | |
|---|---|---|
| committer | 2006-12-18 01:34:15 +0000 | |
| commit | c75b9f00eaeee4b8503ba662b3d7ccc9e1914096 (patch) | |
| tree | a5e7ee244fa4124588a114732c4ecbc248c7c199 /src/modules/dockwidget | |
| parent | Switching from cvs to svn, initial import (diff) | |
| download | KVIrc-c75b9f00eaeee4b8503ba662b3d7ccc9e1914096.tar.gz KVIrc-c75b9f00eaeee4b8503ba662b3d7ccc9e1914096.tar.bz2 KVIrc-c75b9f00eaeee4b8503ba662b3d7ccc9e1914096.zip | |
Switching from cvs to svn, initial import
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@14 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/dockwidget')
| -rw-r--r-- | src/modules/dockwidget/.svnignore | 12 | ||||
| -rw-r--r-- | src/modules/dockwidget/Makefile.am | 32 | ||||
| -rwxr-xr-x | src/modules/dockwidget/dockwidget.vcproj | 166 | ||||
| -rw-r--r-- | src/modules/dockwidget/dockwidget_vc05.vcproj | 253 | ||||
| -rw-r--r-- | src/modules/dockwidget/kvi_dock.png | bin | 0 -> 1963 bytes | |||
| -rwxr-xr-x | src/modules/dockwidget/kvi_dock_win32.png | bin | 0 -> 1299 bytes | |||
| -rw-r--r-- | src/modules/dockwidget/kvidockwidget.dsp | 139 | ||||
| -rw-r--r-- | src/modules/dockwidget/kvidockwidget.dsw | 29 | ||||
| -rw-r--r-- | src/modules/dockwidget/libkvidockwidget.cpp | 831 | ||||
| -rw-r--r-- | src/modules/dockwidget/libkvidockwidget.h | 91 | ||||
| -rw-r--r-- | src/modules/dockwidget/trayicon.cpp | 292 | ||||
| -rw-r--r-- | src/modules/dockwidget/trayicon.h | 96 | ||||
| -rw-r--r-- | src/modules/dockwidget/trayicon_mac.cpp | 21 | ||||
| -rw-r--r-- | src/modules/dockwidget/trayicon_win.cpp | 259 | ||||
| -rw-r--r-- | src/modules/dockwidget/trayicon_x11.cpp | 413 |
15 files changed, 2634 insertions, 0 deletions
diff --git a/src/modules/dockwidget/.svnignore b/src/modules/dockwidget/.svnignore new file mode 100644 index 000000000..679d79f70 --- /dev/null +++ b/src/modules/dockwidget/.svnignore @@ -0,0 +1,12 @@ +Makefile.in +Makefile +.deps +*.o +*.lo +*.la +*.moc +.libs +.mospics +.pics +.xvpics +moc_* diff --git a/src/modules/dockwidget/Makefile.am b/src/modules/dockwidget/Makefile.am new file mode 100644 index 000000000..476c47930 --- /dev/null +++ b/src/modules/dockwidget/Makefile.am @@ -0,0 +1,32 @@ +############################################################################### +# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +AM_CPPFLAGS = -I$(SS_TOPSRCDIR)/src/kvilib/include/ -I$(SS_TOPSRCDIR)/src/kvirc/include/ \ +$(SS_INCDIRS) $(SS_CPPFLAGS) -DGLOBAL_KVIRC_DIR=\"$(globalkvircdir)\" + +pluglib_LTLIBRARIES = libkvidockwidget.la + +libkvidockwidget_la_LDFLAGS = -module -avoid-version $(SS_LDFLAGS) $(SS_LIBDIRS) + +libkvidockwidget_la_SOURCES = libkvidockwidget.cpp trayicon_x11.cpp trayicon.cpp trayicon_mac.cpp + +nodist_libkvidockwidget_la_SOURCES = moc_trayicon.cpp + +libkvidockwidget_la_LIBADD = $(SS_LIBLINK) ../../kvilib/build/libkvilib.la + +noinst_HEADERS= libkvidockwidget.h trayicon.h + +tmpdir = $(picsdir) + +tmp_DATA = kvi_dock.png + +EXTRA_DIST = $(tmp_DATA) + +%.moc: %.h + $(SS_QT_MOC) $< -o $@ + +moc_%.cpp: %.h + $(SS_QT_MOC) $< -o $@ + +libkvidockwidget.cpp: libkvidockwidget.moc diff --git a/src/modules/dockwidget/dockwidget.vcproj b/src/modules/dockwidget/dockwidget.vcproj new file mode 100755 index 000000000..10e30dfdd --- /dev/null +++ b/src/modules/dockwidget/dockwidget.vcproj @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="dockwidget" + ProjectGUID="{4528E26C-195B-4EEE-BEC4-8CD73C564B0D}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)\win32build\bin\modules" + IntermediateDirectory="Debug" + ConfigurationType="2" + CharacterSet="2"> + <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"" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DOCKWIDGET_EXPORTS" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="1" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="qt-mtnc321.lib qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib msvcrt.lib" + OutputFile="$(OutDir)/kvi$(ProjectName).dll" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(SSLLIBDIR)";"$(QTDIR)\lib";"$(SolutionDir)\win32build\bin"" + IgnoreAllDefaultLibraries="TRUE" + GenerateDebugInformation="TRUE" + ProgramDatabaseFile="$(OutDir)/dockwidget.pdb" + SubSystem="2" + ImportLibrary="$(OutDir)/dockwidget.lib" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)\win32build\bin\modules" + IntermediateDirectory="Release" + ConfigurationType="2" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + GlobalOptimizations="TRUE" + InlineFunctionExpansion="2" + FavorSizeOrSpeed="1" + OmitFramePointers="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"" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DOCKWIDGET_EXPORTS" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="TRUE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="qt-mtnc321.lib qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib msvcrt.lib" + OutputFile="$(OutDir)/kvi$(ProjectName).dll" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(SSLLIBDIR)";"$(QTDIR)\lib";"$(SolutionDir)\win32build\bin"" + IgnoreAllDefaultLibraries="TRUE" + GenerateDebugInformation="TRUE" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + OptimizeForWindows98="1" + ImportLibrary="$(OutDir)/dockwidget.lib" + TargetMachine="1"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCWebDeploymentTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </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=".\libkvidockwidget.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\libkvidockwidget.h"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCustomBuildTool" + CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\$(InputName).moc" "$(InputDir)\$(InputFileName)" +" + Outputs="$(InputDir)\$(InputName).moc"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCustomBuildTool" + CommandLine="$(QTDIR)\bin\moc -o $(InputDir)\$(InputName).moc $(InputDir)\$(InputFileName) +" + Outputs="$(InputDir)\$(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/dockwidget/dockwidget_vc05.vcproj b/src/modules/dockwidget/dockwidget_vc05.vcproj new file mode 100644 index 000000000..740de5f96 --- /dev/null +++ b/src/modules/dockwidget/dockwidget_vc05.vcproj @@ -0,0 +1,253 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="dockwidget" + ProjectGUID="{4528E26C-195B-4EEE-BEC4-8CD73C564B0D}" + RootNamespace="dockwidget" + 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"" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DOCKWIDGET_EXPORTS;_CRT_SECURE_NO_DEPRECATE" + 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="qt-$(QTTAG).lib 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" + 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)/dockwidget.pdb" + SubSystem="2" + TurnOffAssemblyGeneration="true" + ImportLibrary="$(OutDir)/dockwidget.lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + 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="2" + 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"" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DOCKWIDGET_EXPORTS;_CRT_SECURE_NO_DEPRECATE" + 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="qt-$(QTTAG).lib 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" + 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)/dockwidget.lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + EmbedManifest="true" + 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=".\libkvidockwidget.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\libkvidockwidget.h" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\$(InputName).moc" "$(InputDir)\$(InputFileName)"
" + Outputs="$(InputDir)\$(InputName).moc" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + CommandLine="$(QTDIR)\bin\moc -o "$(InputDir)\$(InputName).moc" "$(InputDir)\$(InputFileName)"
" + Outputs="$(InputDir)\$(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/dockwidget/kvi_dock.png b/src/modules/dockwidget/kvi_dock.png Binary files differnew file mode 100644 index 000000000..6f809e8b1 --- /dev/null +++ b/src/modules/dockwidget/kvi_dock.png diff --git a/src/modules/dockwidget/kvi_dock_win32.png b/src/modules/dockwidget/kvi_dock_win32.png Binary files differnew file mode 100755 index 000000000..afec5798c --- /dev/null +++ b/src/modules/dockwidget/kvi_dock_win32.png diff --git a/src/modules/dockwidget/kvidockwidget.dsp b/src/modules/dockwidget/kvidockwidget.dsp new file mode 100644 index 000000000..85e5cbbb9 --- /dev/null +++ b/src/modules/dockwidget/kvidockwidget.dsp @@ -0,0 +1,139 @@ +# Microsoft Developer Studio Project File - Name="kvidockwidget" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=kvidockwidget - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "kvidockwidget.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "kvidockwidget.mak" CFG="kvidockwidget - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "kvidockwidget - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "kvidockwidget - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "kvidockwidget - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KVIDOCKWIDGET_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "_$(QTDIR)\include" /I "$(QTDIR)\include" /I "..\..\kvilib\tal" /I "..\..\kvilib\system" /I "..\..\kvilib\irc" /I "..\..\kvilib\file" /I "..\..\kvilib\ext" /I "..\..\kvilib\net" /I "..\..\kvilib\core\wstring" /I "..\..\kvilib\core" /I "..\..\kvilib\config" /I "..\..\kvirc\kvs" /I "..\..\kvirc\module" /I "..\..\kvirc\uparser\scripttoolbar" /I "..\..\kvirc\uparser" /I "..\..\kvirc\sparser" /I "..\..\kvirc\kernel" /I "..\..\kvirc\ui" /I "C:\ssl" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KVIDOCKWIDGET_EXPORTS" /D "QT_DLL" /D "QT_THREAD_SUPPORT" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x410 /d "NDEBUG" +# ADD RSC /l 0x410 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 imm32.lib wsock32.lib winmm.lib kvirc.lib kernel32.lib odbc32.lib odbccp32.lib $(QTDIR)\lib\qt-mtnc321.lib $(QTDIR)\lib\qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"..\..\..\win32build\bin\modules\kvidockwidget.dll" /libpath:"C:\OpenSSL\lib\VC" /libpath:"..\..\kvilib\Release" /libpath:"..\..\kvirc\Release" + +!ELSEIF "$(CFG)" == "kvidockwidget - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KVIDOCKWIDGET_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "_$(QTDIR)\include" /I "$(QTDIR)\include" /I "..\..\kvilib\tal" /I "..\..\kvilib\system" /I "..\..\kvilib\irc" /I "..\..\kvilib\file" /I "..\..\kvilib\ext" /I "..\..\kvilib\net" /I "..\..\kvilib\core\wstring" /I "..\..\kvilib\core" /I "..\..\kvilib\config" /I "..\..\kvirc\kvs" /I "..\..\kvirc\module" /I "..\..\kvirc\uparser\scripttoolbar" /I "..\..\kvirc\uparser" /I "..\..\kvirc\sparser" /I "..\..\kvirc\kernel" /I "..\..\kvirc\ui" /I "C:\ssl" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KVIDCC_EXPORTS" /D "QT_DLL" /D "QT_THREAD_SUPPORT" /Fp"Debug/kvidcc.pch" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x410 /d "_DEBUG" +# ADD RSC /l 0x410 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 imm32.lib wsock32.lib winmm.lib kvirc.lib kernel32.lib odbc32.lib odbccp32.lib $(QTDIR)\lib\qt-mtnc321.lib $(QTDIR)\lib\qtmain.lib libeay32.lib SSLeay32.lib ws2_32.lib kvilib.lib kvirc.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"..\..\..\win32build\KviDebug\modules\kvidockwidget.dll" /pdbtype:sept /libpath:"C:\OpenSSL\lib\VC" /libpath:"..\..\kvilib\Debug" /libpath:"..\..\kvirc\Debug" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "kvidockwidget - Win32 Release" +# Name "kvidockwidget - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\libkvidockwidget.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\libkvidockwidget.h + +!IF "$(CFG)" == "kvidockwidget - Win32 Release" + +# Begin Custom Build +InputDir=. +InputPath=.\libkvidockwidget.h +InputName=libkvidockwidget + +"$(InputDir)\$(InputName).moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + %qtdir%\bin\moc.exe $(InputDir)\$(InputName).h -o $(InputDir)\$(InputName).moc + +# End Custom Build + +!ELSEIF "$(CFG)" == "kvidockwidget - Win32 Debug" + +# Begin Custom Build +InputDir=. +InputPath=.\libkvidockwidget.h +InputName=libkvidockwidget + +"$(InputDir)\$(InputName).moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + %qtdir%\bin\moc.exe $(InputDir)\$(InputName).h -o $(InputDir)\$(InputName).moc + +# End Custom Build + +!ENDIF + +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/src/modules/dockwidget/kvidockwidget.dsw b/src/modules/dockwidget/kvidockwidget.dsw new file mode 100644 index 000000000..067707c5f --- /dev/null +++ b/src/modules/dockwidget/kvidockwidget.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "kvidockwidget"=.\kvidockwidget.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/src/modules/dockwidget/libkvidockwidget.cpp b/src/modules/dockwidget/libkvidockwidget.cpp new file mode 100644 index 000000000..79e7ea223 --- /dev/null +++ b/src/modules/dockwidget/libkvidockwidget.cpp @@ -0,0 +1,831 @@ +// +// File : libkvidockwidget.cpp +// Creation date : Tue Jan 02 20001 14:34:12 CEST by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2000-2001 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_app.h" +#include "kvi_module.h" +#include "kvi_locale.h" +#include "kvi_memmove.h" +#include "kvi_taskbar.h" +#include "kvi_window.h" +#include "kvi_dynamictooltip.h" +#include "kvi_iconmanager.h" +#include "kvi_internalcmd.h" +#include "kvi_console.h" +#include "kvi_ircconnection.h" +#include "kvi_ircconnectionuserinfo.h" +#include "kvi_imagelib.h" +#include "kvi_options.h" +#include "kvi_ircview.h" + +#include "libkvidockwidget.h" +#include "kvi_doublebuffer.h" + +#ifdef COMPILE_KDE_SUPPORT + #include <kwin.h> + #include <kpopupmenu.h> +#else + #include <qpopupmenu.h> + #include <qlabel.h> +#endif + +#include <qpixmap.h> +#include <qpainter.h> +#include <qtimer.h> + +#include <qregexp.h> + +#include <stdlib.h> +#include <time.h> + +#ifdef COMPILE_ON_WINDOWS + #include <windows.h> + + #include <qbitmap.h> + #include <qcursor.h> + + #define ID_DOCKWIDGET_TASKBAR_ICON 0xdeadbeef + #define WM_KVIRC_NOTIFY_ICON_MESSAGE (WM_USER + 0xbeef) + + static UINT WM_KVIRC_TASKBAR_CREATED = 0; +#else +#ifndef Q_OS_MACX + #include <X11/Xlib.h> + + //const int XFocusOut = FocusOut; + const int XFocusIn = FocusIn; + #undef FocusOut + #undef FocusIn + #undef KeyPress + #undef KeyRelease + + //#warning "Later remove this stuff and use a wrapper for #include <X11/Xlib.h>" + #ifdef Bool + #undef Bool + #endif +#endif +#endif + +extern KVIRC_API QAsciiDict<KviWindow> * g_pGlobalWindowDict; +static KviPtrList<KviDockWidget> * g_pDockWidgetList = 0; + +static QPixmap * g_pDock1 = 0; +static QPixmap * g_pDock2 = 0; +static QPixmap * g_pDock3 = 0; + +#ifdef COMPILE_ON_WINDOWS + static HICON g_pCurrentIcon = 0; + static QPixmap * g_pCurrentPixmap = 0; +#endif + + +KviDockWidget::KviDockWidget(KviFrame * frm,const char * name) +: QWidget(0,name) +{ + m_iConsoles = 0; + m_iChannels = 0; + m_iQueries = 0; + m_iOther = 0; + + m_pFlashingTimer = new QTimer(this,"flashing_timer"); + connect( m_pFlashingTimer, SIGNAL(timeout()), this, SLOT(flashingTimerShot()) ); + m_bFlashed=0; + g_pDockWidgetList->append(this); + m_pFrm = frm; + m_pFrm->setDockExtension(this); + +#ifdef COMPILE_ON_WINDOWS + // kode54 + if(!WM_KVIRC_TASKBAR_CREATED)WM_KVIRC_TASKBAR_CREATED = RegisterWindowMessage(TEXT("TaskbarCreated")); + createTaskbarIcon(); +#else //!COMPILE_ON_WINDOWS + setMinimumSize(22,22); + setBackgroundMode(X11ParentRelative); + #ifdef COMPILE_KDE_SUPPORT + KWin::setSystemTrayWindowFor(winId(),frm->winId()); + #endif +#endif //!COMPILE_ON_WINDOWS + + m_pTip = new KviDynamicToolTip(this,"dock_tooltip"); + connect(m_pTip,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &))); + + m_pAwayPopup = new QPopupMenu(this); + +#ifdef COMPILE_KDE_SUPPORT + m_pContextPopup = new KPopupMenu(this); + m_pContextPopup->insertTitle(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_KVIRC)),__tr2qs("KVIrc")); +#else + m_pContextPopup = new QPopupMenu(this); + QLabel * l = new QLabel(__tr2qs("KVIrc"),m_pContextPopup); + l->setFrameStyle(QFrame::Raised | QFrame::StyledPanel); + m_pContextPopup->insertItem(l); +#endif + m_pContextPopup->setCaption(__tr2qs("Context")); + m_iAwayMenuId = m_pContextPopup->insertItem ( __tr2qs("Away"), m_pAwayPopup); + m_pContextPopup->changeItem(m_iAwayMenuId,*(g_pIconManager->getSmallIcon(KVI_SMALLICON_AWAY)),__tr2qs("Away")); + + int id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_OPTIONS)),__tr2qs("&Configure KVIrc..."),m_pFrm,SLOT(executeInternalCommand(int))); + m_pContextPopup->setItemParameter(id,KVI_INTERNALCOMMAND_OPTIONS_DIALOG); + id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_KVIRC)),__tr2qs("&About KVIrc"),m_pFrm,SLOT(executeInternalCommand(int))); + m_pContextPopup->setItemParameter(id,KVI_INTERNALCOMMAND_ABOUT_ABOUTKVIRC); + m_pContextPopup->insertSeparator(); + m_iToggleFrame = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_RAW)),QString(""),this,SLOT(toggleParentFrame())); + m_pContextPopup->insertSeparator(); + id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DOCKWIDGET)),__tr2qs("Un&dock"),m_pFrm,SLOT(executeInternalCommand(int))); + m_pContextPopup->setItemParameter(id,KVI_INTERNALCOMMAND_DOCKWIDGET_HIDE); + id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUITAPP)),__tr2qs("&Quit"),g_pApp,SLOT(quit())); + m_pContextPopup->setAccel(__tr2qs("Ctrl+Q"),id); + connect(m_pContextPopup,SIGNAL(aboutToShow()),this,SLOT(fillContextPopup())); +} + + +KviDockWidget::~KviDockWidget() +{ +#ifdef COMPILE_ON_WINDOWS + destroyTaskbarIcon(); +#endif + m_pFrm->setDockExtension(0); + g_pDockWidgetList->removeRef(this); +} + +void KviDockWidget::die() +{ + delete this; +} +void KviDockWidget::flashingTimerShot() +{ + m_bFlashed=!m_bFlashed; +#ifdef COMPILE_ON_WINDOWS + updateTaskbarIcon(); +#else + update(); +#endif +} + +#ifdef COMPILE_ON_WINDOWS +void KviDockWidget::createTaskbarIcon() +{ + ICONINFO inf; + g_pCurrentPixmap=new QPixmap(*g_pDock1); + inf.hbmColor = g_pCurrentPixmap->hbm(); + if(!g_pCurrentPixmap->mask())g_pCurrentPixmap->setMask(g_pCurrentPixmap->createHeuristicMask()); + inf.hbmMask = g_pCurrentPixmap->mask()->hbm(); + g_pCurrentIcon=CreateIconIndirect(&inf); + + NOTIFYICONDATA nid; + nid.cbSize = sizeof(nid); + nid.hWnd = winId(); + nid.uID = ID_DOCKWIDGET_TASKBAR_ICON; + nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + nid.uCallbackMessage = WM_KVIRC_NOTIFY_ICON_MESSAGE; + kvi_memmove(nid.szTip,"KVIrc",6); + nid.hIcon = g_pCurrentIcon; + Shell_NotifyIcon(NIM_ADD,&nid); +} + +void KviDockWidget::destroyTaskbarIcon() +{ + NOTIFYICONDATA nid; + nid.cbSize = sizeof(nid); + nid.hWnd = winId(); + nid.uID = ID_DOCKWIDGET_TASKBAR_ICON; + nid.uFlags = 0; + Shell_NotifyIcon(NIM_DELETE,&nid); +} + +void KviDockWidget::updateTaskbarIcon() +{ + ICONINFO inf; + QPixmap* pix = m_bFlashed ? g_pIconManager->getSmallIcon(KVI_SMALLICON_MESSAGE) : g_pCurrentPixmap; + inf.hbmColor = pix->hbm(); + if(!pix->mask())pix->setMask(pix->createHeuristicMask()); + inf.hbmMask = pix->mask()->hbm(); + HICON hIcon=CreateIconIndirect(&inf); + + NOTIFYICONDATA nid; + nid.cbSize = sizeof(nid); + nid.hWnd = winId(); + nid.uID = ID_DOCKWIDGET_TASKBAR_ICON; + nid.uFlags = NIF_ICON; + nid.hIcon = hIcon; + Shell_NotifyIcon(NIM_MODIFY,&nid); + DestroyIcon(g_pCurrentIcon); + g_pCurrentIcon=hIcon; +} + +bool KviDockWidget::winEvent(MSG * m) +{ + if(m->message == WM_KVIRC_NOTIFY_ICON_MESSAGE) + { + if(m->wParam == ID_DOCKWIDGET_TASKBAR_ICON) + { + switch(m->lParam) + { + case WM_MOUSEMOVE: + tipRequest(m_pTip,QCursor::pos()); + break; + case WM_LBUTTONDOWN: + toggleParentFrame(); + break; + case WM_RBUTTONDOWN: + m_pContextPopup->popup(QCursor::pos()); + break; + } + return true; + } + } else if(m->message == WM_KVIRC_TASKBAR_CREATED) + { + // kode54 : when the window shell dies and is restarted + // it sends the "TaskbarCreated" message to all the toplevel windows + // We recreate the taskbar icon then + createTaskbarIcon(); + refresh(); + } + return false; +} + +#endif + +#define NIDLEMSGS 18 + +static const char * idlemsgs[NIDLEMSGS]= +{ + __tr("Nothing is happening...") , + __tr("Just idling...") , + __tr("Dum de dum de dum...") , + __tr("Hey man... do something!") , + __tr("Umpf!") , + __tr("Silence speaking") , + __tr("Are ya here?") , + __tr("The world has stopped?") , + __tr("Everything is all right") , + __tr("idle()") , + __tr("It's so cold here...") , + __tr("Do not disturb... watching TV") , + __tr("Just vegetating") , + __tr("Hey... are ya sure that your network is up?") , + __tr("Seems like the world has stopped spinning") , + __tr("This silence is freaking me out!") , + __tr("Mieeeeeowww!") , + __tr("idle idle idle idle!") +}; + +#ifdef COMPILE_KDE_SUPPORT + extern Time qt_x_time; +#endif + +void KviDockWidget::enterEvent( QEvent* ) +{ +#ifdef COMPILE_KDE_SUPPORT + if(!g_pApp->focusWidget()) + { + XEvent ev; + kvi_memset(&ev, 0, sizeof(ev)); + ev.xfocus.display = qt_xdisplay(); + ev.xfocus.type = XFocusIn; + ev.xfocus.window = winId(); + ev.xfocus.mode = NotifyNormal; + ev.xfocus.detail = NotifyAncestor; + Time time = qt_x_time; + qt_x_time = 1; + g_pApp->x11ProcessEvent( &ev ); + qt_x_time = time; + } +#endif +} + +void KviDockWidget::tipRequest(KviDynamicToolTip *tip,const QPoint &pnt) +{ + QString tmp; + + KviTaskBarBase * t = m_pFrm->taskBar(); + + QString line; + + for(KviTaskBarItem * b = t->firstItem();b;b = t->nextItem()) + { + + if(b->window()->view()) + { + if(b->window()->view()->haveUnreadedMessages()) + { + line = b->window()->lastMessageText(); + if(!line.isEmpty()) + { + line.replace(QChar('&'),"&"); + line.replace(QChar('<'),"<"); + line.replace(QChar('>'),">"); + tmp += "<b>"; + tmp += b->window()->plainTextCaption(); + tmp += "</b><br>"; + tmp += line; + tmp += "<br><br>\n"; + } + } + } + } + + + srand(time(0)); + + // We use the bad way to generate random numbers :))))) + + if(tmp.isEmpty())tmp = __tr2qs_no_xgettext(idlemsgs[(int)(rand() % NIDLEMSGS)]); + +#ifdef COMPILE_ON_WINDOWS + +#else + m_pTip->tip(rect(),tmp); +#endif +} + +//int KviDockWidget::message(int,void *) +//{ +// debug("Message"); +// update(); +// return 0; +//} + +void KviDockWidget::mousePressEvent(QMouseEvent *e) +{ + if(e->button() & LeftButton)toggleParentFrame(); + else if(e->button() & RightButton) + m_pContextPopup->popup(mapToGlobal(e->pos())); +} + +void KviDockWidget::doAway(int id) +{ + if(id<0) + { + QAsciiDictIterator<KviWindow> it(*g_pGlobalWindowDict); + while(KviWindow * wnd = it.current()) + { + if(wnd->type()==KVI_WINDOW_TYPE_CONSOLE) + { + KviConsole* pConsole=(KviConsole*)wnd; + if(pConsole->isConnected()) + if(id==-2) + pConsole->connection()->sendFmtData("AWAY"); + else + pConsole->connection()->sendFmtData("AWAY :%s", + pConsole->connection()->encodeText(KVI_OPTION_STRING(KviOption_stringAwayMessage)).data() + ); + } + ++it; + } + } else { + KviConsole* pConsole=g_pApp->findConsole((unsigned int)id); + if(pConsole) + if(pConsole->isConnected()) + if(pConsole->connection()->userInfo()->isAway()) + pConsole->connection()->sendFmtData("AWAY"); + else + pConsole->connection()->sendFmtData("AWAY :%s", + pConsole->connection()->encodeText(KVI_OPTION_STRING(KviOption_stringAwayMessage)).data() + ); + } +} + +void KviDockWidget::fillContextPopup() +{ + m_pContextPopup->changeItem(m_iToggleFrame,m_pFrm->isVisible() ? __tr2qs("Hide Window") : __tr2qs("Show Window")); + if(g_pApp->topmostConnectedConsole()) + { + m_pContextPopup->setItemVisible(m_iAwayMenuId,true); + m_pAwayPopup->clear(); + + int iAllAway=m_pAwayPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CONSOLE)),__tr2qs("Away on all"),this,SLOT(doAway(int))); + m_pAwayPopup->setItemParameter(iAllAway,-1); + + int iAllUnaway=m_pAwayPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CONSOLE)),__tr2qs("Back on all"),this,SLOT(doAway(int))); + m_pAwayPopup->setItemParameter(iAllUnaway,-2); + + int iSeparator=m_pAwayPopup->insertSeparator(); + + QAsciiDictIterator<KviWindow> it(*g_pGlobalWindowDict); + bool bAllAway=1; + bool bAllUnaway=1; + int iNetCount=0; + while(KviWindow * wnd = it.current()) + { + if(wnd->type()==KVI_WINDOW_TYPE_CONSOLE) + { + KviConsole* pConsole=(KviConsole*)wnd; + if(pConsole->isConnected()) + { + int id; + if(pConsole->connection()->userInfo()->isAway()) + { + id=m_pAwayPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CONSOLE)),__tr2qs("Back on %1").arg(pConsole->currentNetworkName()),this,SLOT(doAway(int))); + bAllUnaway=0; + } else { + id=m_pAwayPopup->insertItem(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CONSOLE)),__tr2qs("Away on %1").arg(pConsole->currentNetworkName()),this,SLOT(doAway(int))); + bAllAway=0; + } + m_pAwayPopup->setItemParameter(id,pConsole->ircContextId()); + iNetCount++; + } + } + ++it; + } + if(iNetCount==1) + { + m_pAwayPopup->setItemVisible(iAllAway,false); + m_pAwayPopup->setItemVisible(iAllUnaway,false); + m_pAwayPopup->setItemVisible(iSeparator,false); + } else { + m_pAwayPopup->setItemVisible(iAllAway,!bAllAway); + m_pAwayPopup->setItemVisible(iAllUnaway,!bAllUnaway); + } + } else { + m_pContextPopup->setItemVisible(m_iAwayMenuId,false); + } +} + +void KviDockWidget::toggleParentFrame() +{ + QWidget *top_widget = m_pFrm->topLevelWidget(); + + if(m_pFrm->isVisible()) { + m_pFrm->hide(); + } else { + top_widget->show(); + top_widget->raise(); + top_widget->setActiveWindow(); + m_pFrm->setFocus(); + if(m_pFrm->isMinimized()) + m_pFrm->showNormal(); + else + m_pFrm->show(); + } +} + +void KviDockWidget::refresh() +{ + grabActivityInfo(); + +#ifdef COMPILE_ON_WINDOWS + // how to copy transparency???? + delete g_pCurrentPixmap; + g_pCurrentPixmap=new QPixmap(16,16); + bitBlt(g_pCurrentPixmap,0,0,m_iOther ? ((m_iOther == 2) ? g_pDock3 : g_pDock2) : g_pDock1,0,0,8,8,Qt::ClearROP); + bitBlt(g_pCurrentPixmap,0,8,m_iConsoles ? ((m_iConsoles == 2) ? g_pDock3 : g_pDock2) : g_pDock1,0,8,8,8,Qt::ClearROP); + bitBlt(g_pCurrentPixmap,8,0,m_iQueries ? ((m_iQueries == 2) ? g_pDock3 : g_pDock2) : g_pDock1,8,0,8,8,Qt::ClearROP); + bitBlt(g_pCurrentPixmap,8,8,m_iChannels ? ((m_iChannels == 2) ? g_pDock3 : g_pDock2) : g_pDock1,8,8,8,8,Qt::ClearROP); +#endif + + if( (m_iChannels == 2) || (m_iQueries == 2) ) + { + if(!m_pFlashingTimer->isActive() && KVI_OPTION_BOOL(KviOption_boolEnableTrayIconFlashing) ) m_pFlashingTimer->start(1000); + } else { + if(m_pFlashingTimer->isActive()) m_pFlashingTimer->stop(); + m_bFlashed=false; + } + +#ifdef COMPILE_ON_WINDOWS + updateTaskbarIcon(); +#else + update(); +#endif +} + +void KviDockWidget::grabActivityInfo() +{ + KviTaskBarBase * t = m_pFrm->taskBar(); + + if(KVI_OPTION_BOOL(KviOption_boolUseLevelBasedTrayNotification)) + { + if(KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)>5) KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)=5; + if(KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)>5) KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)=5; + + if(KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)<1) KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)=1; + if(KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)<1) KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)=1; + + if(KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)<KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)) + KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)=KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage); + } + + m_iConsoles = 0; + m_iChannels = 0; + m_iQueries = 0; + m_iOther = 0; + + for(KviTaskBarItem * b = t->firstItem();b;b = t->nextItem()) + { + if(KVI_OPTION_BOOL(KviOption_boolUseLevelBasedTrayNotification)) + { + int iLevel = b->highlightLevel(); + switch(b->window()->type()) + { + case KVI_WINDOW_TYPE_CONSOLE: + if(m_iConsoles < iLevel) m_iConsoles = iLevel; + break; + case KVI_WINDOW_TYPE_CHANNEL: + if(m_iChannels < iLevel) m_iChannels = iLevel; + break; + case KVI_WINDOW_TYPE_QUERY: + if(m_iQueries < iLevel) m_iQueries = iLevel; + break; + default: + if(m_iOther < iLevel) m_iOther = iLevel; + break; + } + } else { + int iLevel=0; + if(b->window()->view()) + { + if(b->window()->view()->haveUnreadedHighlightedMessages()) + { + iLevel=2; + } else if(b->window()->view()->haveUnreadedMessages()) + { + iLevel=1; + } + if(iLevel>0) + switch(b->window()->type()) + { + case KVI_WINDOW_TYPE_CONSOLE: + if(m_iConsoles < iLevel) m_iConsoles = iLevel; + break; + case KVI_WINDOW_TYPE_CHANNEL: + if(m_iChannels < iLevel) m_iChannels = iLevel; + break; + case KVI_WINDOW_TYPE_QUERY: + if(m_iQueries < iLevel) m_iQueries = iLevel; + break; + default: + if(m_iOther < iLevel) m_iOther = iLevel; + break; + } + } + } + } + + if(KVI_OPTION_BOOL(KviOption_boolUseLevelBasedTrayNotification)) + { + if(m_iConsoles >= KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)) m_iConsoles=2; + else if(m_iConsoles >= KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)) m_iConsoles=1; + else m_iConsoles=0; + + if(m_iChannels >= KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)) m_iChannels=2; + else if(m_iChannels >= KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)) m_iChannels=1; + else m_iChannels=0; + + if(m_iQueries >= KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)) m_iQueries=2; + else if(m_iQueries >= KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)) m_iQueries=1; + else m_iQueries=0; + + if(m_iOther >= KVI_OPTION_UINT(KviOption_uintMinTrayHighLevelMessage)) m_iOther=2; + else if(m_iOther >= KVI_OPTION_UINT(KviOption_uintMinTrayLowLevelMessage)) m_iOther=1; + else m_iOther=0; + } +} + +void KviDockWidget::paintEvent(QPaintEvent * event) +{ + if(m_bFlashed) + { + erase(); + bitBlt(this,4,4,g_pIconManager->getSmallIcon(KVI_SMALLICON_MESSAGE),0,0,16,16); + } else { + bitBlt(this,0,0,m_iOther ? ((m_iOther == 2) ? g_pDock3 : g_pDock2) : g_pDock1,0,0,12,12,Qt::CopyROP,false); + bitBlt(this,0,12,m_iConsoles ? ((m_iConsoles == 2) ? g_pDock3 : g_pDock2) : g_pDock1,0,12,12,12,Qt::CopyROP,false); + bitBlt(this,12,0,m_iQueries ? ((m_iQueries == 2) ? g_pDock3 : g_pDock2) : g_pDock1,12,0,12,12,Qt::CopyROP,false); + bitBlt(this,12,12,m_iChannels ? ((m_iChannels == 2) ? g_pDock3 : g_pDock2) : g_pDock1,12,12,12,12,Qt::CopyROP,false); + } +} + + +static KviDockWidget * dockwidget_find(KviFrame *f) +{ + if(!g_pDockWidgetList)return 0; + for(KviDockWidget * w = g_pDockWidgetList->first();w;w = g_pDockWidgetList->next()) + { + if(w->frame() == f)return w; + } + return 0; +} + +/* + @doc: dockwidget.show + @type: + command + @title: + dockwidget.show + @short: + Shows the dock widget for the current frame window + @keyterms: + dock widget , system tray + @syntax: + dockwidget.show + @description: + Shows the dock widget for the current frame window.[br] + The dock widget is a small widget that docks in the KDE panel.[br] + It shows a small icon of the earth and eventually displays four squares + that cover this icon: the bottom left square appears when there is some new + text in any console window, the square becomes red if the text is highlighted.[br] + The bottom right square appears when there is some new text in any channel window, + and it becomes red when the text is highlighted.[br] The upper right square refers to + query windows and the upper left one to any other kind of window (dcc , links...).[br] + If you move the mouse over the dock widget a tooltip will show you the last lines + of the "new" text in all these windows.[br] + This is useful when you keep the main KVIrc window minimized and you're working on something else: + if the dock widget shows nothing but the earth icon , nothing is happening in the main KVIrc window. + If the dock widget shows one or more white (or red) squares , you can move the mouse over + and check what's happened exactly and eventually bring up the main KVIrc window by clicking on the widget.[br] + [big]tecnical details[/big] + The dock widget is currently working in KDE compilation mode only: + it relies on the KWin implementation of the Window Manager interaction protocol. + @seealso: + [cmd]dockwidget.hide[/doc] +*/ + +static bool dockwidget_kvs_cmd_show(KviKvsModuleCommandCall * c) +{ + if(!(dockwidget_find(c->window()->frame()))) + { + KviDockWidget * w = new KviDockWidget(c->window()->frame(),"dock_widget"); +#ifndef COMPILE_ON_WINDOWS + w->show(); +#else + w->hide(); +#endif + } + return true; +} + +/* + @doc: dockwidget.hide + @type: + command + @title: + dockwidget.hide + @short: + Hides the dock widget for the current frame window + @syntax: + dockwidget.hide + @description: + Hides the dock widget for the current frame window + @seealso: + [cmd]dockwidget.show[/doc] +*/ + +static bool dockwidget_kvs_cmd_hide(KviKvsModuleCommandCall * c) +{ + KviDockWidget * w= dockwidget_find(c->window()->frame()); + if(w)delete w; + // show the parent frame.. otherwise there will be no way to get it back + if(!c->window()->frame()->isVisible()) + { + c->window()->frame()->show(); + } + return true; +} + +/* + @doc: dockwidget.hidewindow + @type: + command + @title: + dockwidget.hidewindow + @short: + Returns the state of the dock widget + @syntax: + dockwidget.hidewindow + @description: + Hides the window, assotiated with dockwidget + @seealso: + [cmd]dockwidget.show[/cmd] [cmd]dockwidget.hide[/cmd] +*/ + +static bool dockwidget_kvs_cmd_hidewindow(KviKvsModuleCommandCall * c) +{ + KviDockWidget * w= dockwidget_find(c->window()->frame()); + if(w) + { +#if QT_VERSION > 0x030201 + w->setPrevWindowState(c->window()->frame()->windowState()); +#endif + c->window()->frame()->hide(); + } + return true; +} + +/* + @doc: dockwidget.isvisible + @type: + function + @title: + $dockwidget.isVisible + @short: + Returns the state of the dock widget + @syntax: + $reguser.isVisible() + @description: + Returns 1 if the dock widget is actually visible , 0 otherwise. + @seealso: + [cmd]dockwidget.show[/cmd] +*/ + +static bool dockwidget_kvs_fnc_isvisible(KviKvsModuleFunctionCall * c) +{ + c->returnValue()->setBoolean(dockwidget_find(c->window()->frame())); + return true; +} + + + +// ======================================= +// init routine +// ======================================= +static bool dockwidget_module_init(KviModule * m) +{ + KviStr buffer; +#ifdef COMPILE_ON_WINDOWS + g_pApp->findImage(buffer,"kvi_dock_win32.png"); + KviImageLibrary l1(buffer.ptr(),16,16); +#else + g_pApp->findImage(buffer,"kvi_dock.png"); + KviImageLibrary l1(buffer.ptr(),22,22); +#endif + g_pDock1 = new QPixmap(l1.getImage(0)); + g_pDock2 = new QPixmap(l1.getImage(1)); + g_pDock3 = new QPixmap(l1.getImage(2)); + +#ifdef COMPILE_ON_WINDOWS + +#endif + + + g_pDockWidgetList = new KviPtrList<KviDockWidget>; + g_pDockWidgetList->setAutoDelete(false); + + + KVSM_REGISTER_SIMPLE_COMMAND(m,"hide",dockwidget_kvs_cmd_hide); + KVSM_REGISTER_SIMPLE_COMMAND(m,"hidewindow",dockwidget_kvs_cmd_hidewindow); + KVSM_REGISTER_SIMPLE_COMMAND(m,"show",dockwidget_kvs_cmd_show); + KVSM_REGISTER_FUNCTION(m,"isVisible",dockwidget_kvs_fnc_isvisible); + + return true; +} + +static bool dockwidget_module_cleanup(KviModule *m) +{ + while(g_pDockWidgetList->first())delete g_pDockWidgetList->first(); + delete g_pDockWidgetList; + g_pDockWidgetList = 0; + +#ifdef COMPILE_ON_WINDOWS + DestroyIcon(g_pCurrentIcon); +#endif + + delete g_pDock1; + g_pDock1 = 0; + delete g_pDock2; + g_pDock2 = 0; + delete g_pDock3; + g_pDock3 = 0; + + return true; +} + +static bool dockwidget_module_can_unload(KviModule *) +{ + return g_pDockWidgetList->isEmpty(); +} + +// ======================================= +// plugin definition structure +// ======================================= +KVIRC_MODULE( + "KVIrc dock widget implementation", + "1.0.0", + "Szymon Stefanek <pragma at kvirc dot net>" , + "exports the /dockwidget.* interface\n", + dockwidget_module_init , + dockwidget_module_can_unload, + 0, + dockwidget_module_cleanup +) + +#include "libkvidockwidget.moc" diff --git a/src/modules/dockwidget/libkvidockwidget.h b/src/modules/dockwidget/libkvidockwidget.h new file mode 100644 index 000000000..343b18be3 --- /dev/null +++ b/src/modules/dockwidget/libkvidockwidget.h @@ -0,0 +1,91 @@ +#ifndef _KVI_DOCKWIDGET_H_ +#define _KVI_DOCKWIDGET_H_ +// +// This file is part of the KVirc irc client distribution +// Creation date : Tue 02 Jan 2001 14:28:25 by Szymon Stefanek +// Copyright (C) 2000-2001 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// + +#include "kvi_settings.h" +#include "kvi_frame.h" + +#ifdef COMPILE_KDE_SUPPORT + class KPopupMenu; +#else + class QPopupMenu; +#endif +class QPixmap; +class QTimer; + +//class KviFrame; +class KviDynamicToolTip; + +class KviDockWidget : public QWidget , public KviDockExtension +{ + Q_OBJECT +public: + KviDockWidget(KviFrame * win,const char * name); + ~KviDockWidget(); +protected: + KviFrame * m_pFrm; + KviDynamicToolTip * m_pTip; +#ifdef COMPILE_KDE_SUPPORT + KPopupMenu * m_pContextPopup; +#else + QPopupMenu * m_pContextPopup; +#endif + QPopupMenu * m_pAwayPopup; + int m_iToggleFrame; + int m_iAwayMenuId; + + bool m_bFlashed; + + QTimer* m_pFlashingTimer; + int m_iConsoles; + int m_iChannels; + int m_iQueries; + int m_iOther; +public: + KviFrame * frame(){ return m_pFrm; }; +public: +// virtual int message(int msgtype,void * data); + virtual void enterEvent(QEvent *); + virtual void refresh(); + virtual void die(); +protected: + virtual void paintEvent(QPaintEvent *e); + virtual void mousePressEvent(QMouseEvent *e); + void grabActivityInfo(); + +#ifdef COMPILE_ON_WINDOWS +private: + void createTaskbarIcon(); + void destroyTaskbarIcon(); + void updateTaskbarIcon(); +protected: + bool winEvent(MSG * m); +#endif + +protected slots: + void fillContextPopup(); + void toggleParentFrame(); + void tipRequest(KviDynamicToolTip *tip,const QPoint &pnt); + void doAway(int); + void flashingTimerShot(); +}; + +#endif //_KVI_DOCKWIDGET_H_ diff --git a/src/modules/dockwidget/trayicon.cpp b/src/modules/dockwidget/trayicon.cpp new file mode 100644 index 000000000..de8b590d2 --- /dev/null +++ b/src/modules/dockwidget/trayicon.cpp @@ -0,0 +1,292 @@ +/* + * trayicon.cpp - system-independent trayicon class (adapted from Qt example) + * Copyright (C) 2003 Justin Karneges + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "trayicon.h" +#include "qpopupmenu.h" + +/*! + \class TrayIcon qtrayicon.h + \brief The TrayIcon class implements an entry in the system tray. +*/ + +/*! + Creates a TrayIcon object. \a parent and \a name are propagated + to the QObject constructor. The icon is initially invisible. + + \sa show +*/ +TrayIcon::TrayIcon( QObject *parent, const char *name ) +: QObject(parent, name), pop(0), d(0) +{ + v_isWMDock = FALSE; +} + +/*! + Creates a TrayIcon object displaying \a icon and \a tooltip, and opening + \a popup when clicked with the right mousebutton. \a parent and \a name are + propagated to the QObject constructor. The icon is initially invisible. + + \sa show +*/ +TrayIcon::TrayIcon( const QPixmap &icon, const QString &tooltip, QPopupMenu *popup, QObject *parent, const char *name ) +: QObject(parent, name), pop(popup), pm(icon), tip(tooltip), d(0) +{ + v_isWMDock = FALSE; + + if ( !pm.width() || !pm.height() ) + pm = QPixmap( 16, 16 ); +} + +/*! + Removes the icon from the system tray and frees all allocated resources. +*/ +TrayIcon::~TrayIcon() +{ + sysRemove(); +} + +/*! + Informs the trayicon that the notification owner has probably been changed; + and that it should attempt to register or re-register. +*/ +void TrayIcon::newTrayOwner() +{ + // detach ourself from any existing notification area. + hide(); + // show ourself on the new notification area + show(); +} + + +/*! + Sets the context menu to \a popup. The context menu will pop up when the + user clicks the system tray entry with the right mouse button. +*/ +void TrayIcon::setPopup( QPopupMenu* popup ) +{ + pop = popup; +} + +/*! + Returns the current popup menu. + + \sa setPopup +*/ +QPopupMenu* TrayIcon::popup() const +{ + return pop; +} + +/*! + \property TrayIcon::icon + \brief the system tray icon. +*/ +void TrayIcon::setIcon( const QPixmap &icon ) +{ + //if(!popup()) { + // tip = ""; + //} + + pm = icon; + sysUpdateIcon(); +} + +QPixmap TrayIcon::icon() const +{ + return pm; +} + +/*! + \property TrayIcon::toolTip + \brief the tooltip for the system tray entry + + On some systems, the tooltip's length is limited and will be truncated as necessary. +*/ +void TrayIcon::setToolTip( const QString &tooltip ) +{ + tip = tooltip; + sysUpdateToolTip(); +} + +QString TrayIcon::toolTip() const +{ + return tip; +} + +/*! + Shows the icon in the system tray. + + \sa hide +*/ +void TrayIcon::show() +{ + sysInstall(); +} + +/*! + Hides the system tray entry. +*/ +void TrayIcon::hide() +{ + sysRemove(); +} + +/*! + \reimp +*/ +bool TrayIcon::event( QEvent *e ) +{ + switch ( e->type() ) { + case QEvent::MouseMove: + mouseMoveEvent( (QMouseEvent*)e ); + break; + + case QEvent::MouseButtonPress: + mousePressEvent( (QMouseEvent*)e ); + break; + + case QEvent::MouseButtonRelease: + mouseReleaseEvent( (QMouseEvent*)e ); + break; + + case QEvent::MouseButtonDblClick: + mouseDoubleClickEvent( (QMouseEvent*)e ); + break; + default: + return QObject::event( e ); + } + + return TRUE; +} + +/*! + This event handler can be reimplemented in a subclass to receive + mouse move events for the system tray entry. + + \sa mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), QMouseEvent +*/ +void TrayIcon::mouseMoveEvent( QMouseEvent *e ) +{ + e->ignore(); +} + +/*! + This event handler can be reimplemented in a subclass to receive + mouse press events for the system tray entry. + + \sa mouseReleaseEvent(), mouseDoubleClickEvent(), + mouseMoveEvent(), QMouseEvent +*/ +void TrayIcon::mousePressEvent( QMouseEvent *e ) +{ +#ifndef Q_WS_WIN +// This is for X11, menus appear on mouse press +// I'm not sure whether Mac should be here or below.. Somebody check? + switch ( e->button() ) { + case RightButton: + if ( pop ) { + pop->popup( e->globalPos() ); + e->accept(); + } + break; + case LeftButton: + case MidButton: + emit clicked( e->globalPos(), e->button() ); + break; + default: + break; + } +#endif + e->ignore(); +} + +/*! + This event handler can be reimplemented in a subclass to receive + mouse release events for the system tray entry. + + The default implementations opens the context menu when the entry + has been clicked with the right mouse button. + + \sa setPopup(), mousePressEvent(), mouseDoubleClickEvent(), + mouseMoveEvent(), QMouseEvent +*/ +void TrayIcon::mouseReleaseEvent( QMouseEvent *e ) +{ +#ifdef Q_WS_WIN +// This is for Windows, where menus appear on mouse release + switch ( e->button() ) { + case RightButton: + if ( pop ) { + // Necessary to make keyboard focus + // and menu closing work on Windows. + pop->setActiveWindow(); + pop->popup( e->globalPos() ); + pop->setActiveWindow(); + e->accept(); + } + break; + case LeftButton: + case MidButton: + emit clicked( e->globalPos(), e->button() ); + break; + default: + break; + } +#endif + e->ignore(); +} + +/*! + This event handler can be reimplemented in a subclass to receive + mouse double click events for the system tray entry. + + Note that the system tray entry gets a mousePressEvent() and a + mouseReleaseEvent() before the mouseDoubleClickEvent(). + + \sa mousePressEvent(), mouseReleaseEvent(), + mouseMoveEvent(), QMouseEvent +*/ +void TrayIcon::mouseDoubleClickEvent( QMouseEvent *e ) +{ + if ( e->button() == LeftButton ) + emit doubleClicked( e->globalPos() ); + e->accept(); +} + +/*! + \fn void TrayIcon::clicked( const QPoint &p ) + + This signal is emitted when the user clicks the system tray icon + with the left mouse button, with \a p being the global mouse position + at that moment. +*/ + +/*! + \fn void TrayIcon::doubleClicked( const QPoint &p ) + + This signal is emitted when the user double clicks the system tray + icon with the left mouse button, with \a p being the global mouse position + at that moment. +*/ + +void TrayIcon::gotCloseEvent() +{ + closed(); +} diff --git a/src/modules/dockwidget/trayicon.h b/src/modules/dockwidget/trayicon.h new file mode 100644 index 000000000..b0ef7c087 --- /dev/null +++ b/src/modules/dockwidget/trayicon.h @@ -0,0 +1,96 @@ +/* + * trayicon.h - system-independent trayicon class (adapted from Qt example) + * Copyright (C) 2003 Justin Karneges + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef CS_TRAYICON_H +#define CS_TRAYICON_H + +#include "kvi_settings.h" + +#include <qobject.h> +#include <qimage.h> + +class QPopupMenu; + +class TrayIcon : public QObject +{ + Q_OBJECT + + Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip ) + Q_PROPERTY( QPixmap icon READ icon WRITE setIcon ) + +public: + TrayIcon( QObject *parent = 0, const char *name = 0 ); + TrayIcon( const QPixmap &, const QString &, QPopupMenu *popup = 0, QObject *parent = 0, const char *name = 0 ); + ~TrayIcon(); + + // use WindowMaker dock mode. ignored on non-X11 platforms + void setWMDock(bool use) { v_isWMDock = use; } + bool isWMDock() { return v_isWMDock; } + + // Set a popup menu to handle RMB + void setPopup( QPopupMenu * ); + QPopupMenu* popup() const; + + QPixmap icon() const; + QString toolTip() const; + + void gotCloseEvent(); + +public slots: + void setIcon( const QPixmap &icon ); + void setToolTip( const QString &tip ); + + void show(); + void hide(); + + void newTrayOwner(); + +signals: + void clicked( const QPoint&, int); + void doubleClicked( const QPoint& ); + void closed(); + +protected: + bool event( QEvent * ); + virtual void mouseMoveEvent( QMouseEvent *e ); + virtual void mousePressEvent( QMouseEvent *e ); + virtual void mouseReleaseEvent( QMouseEvent *e ); + virtual void mouseDoubleClickEvent( QMouseEvent *e ); + +private: + QPopupMenu *pop; + QPixmap pm; + QString tip; + bool v_isWMDock; + + // system-dependant part +public: + class TrayIconPrivate; +private: + TrayIconPrivate *d; + void sysInstall(); + void sysRemove(); + void sysUpdateIcon(); + void sysUpdateToolTip(); + + friend class TrayIconPrivate; +}; + +#endif // CS_TRAYICON_H diff --git a/src/modules/dockwidget/trayicon_mac.cpp b/src/modules/dockwidget/trayicon_mac.cpp new file mode 100644 index 000000000..e8e98375a --- /dev/null +++ b/src/modules/dockwidget/trayicon_mac.cpp @@ -0,0 +1,21 @@ +#ifdef Q_OS_MACX + +#include "trayicon.h" + +void TrayIcon::sysInstall() +{ +} + +void TrayIcon::sysRemove() +{ +} + +void TrayIcon::sysUpdateIcon() +{ +} + +void TrayIcon::sysUpdateToolTip() +{ +} + +#endif diff --git a/src/modules/dockwidget/trayicon_win.cpp b/src/modules/dockwidget/trayicon_win.cpp new file mode 100644 index 000000000..5ba57625b --- /dev/null +++ b/src/modules/dockwidget/trayicon_win.cpp @@ -0,0 +1,259 @@ +/* + * trayicon_win.cpp - Windows trayicon, adapted from Qt example + * Copyright (C) 2003 Justin Karneges + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "trayicon.h" + +#include <qwidget.h> +#include <qapplication.h> +#include <qimage.h> +#include <qpixmap.h> +#include <qbitmap.h> +#include <qcursor.h> +#include <qlibrary.h> + +#include <qt_windows.h> + +static uint WM_TASKBARCREATED = 0; +#define WM_NOTIFYICON (WM_APP+101) + +typedef BOOL (WINAPI *PtrShell_NotifyIcon)(DWORD,PNOTIFYICONDATA); +static PtrShell_NotifyIcon ptrShell_NotifyIcon = 0; + +static void resolveLibs() +{ + QLibrary lib("shell32"); + lib.setAutoUnload( FALSE ); + static bool triedResolve = FALSE; + if ( !ptrShell_NotifyIcon && !triedResolve ) { + triedResolve = TRUE; + ptrShell_NotifyIcon = (PtrShell_NotifyIcon) lib.resolve( "Shell_NotifyIconW" ); + } +} + +class TrayIcon::TrayIconPrivate : public QWidget +{ +public: + HICON hIcon; + HBITMAP hMask; + TrayIcon *iconObject; + + TrayIconPrivate( TrayIcon *object ) + : QWidget( 0 ), hIcon( 0 ), hMask( 0 ), iconObject( object ) + { + if ( !WM_TASKBARCREATED ) + WM_TASKBARCREATED = RegisterWindowMessage( TEXT("TaskbarCreated") ); + } + + ~TrayIconPrivate() + { + if ( hMask ) { + DeleteObject( hMask ); + hMask = 0; // michalj + } + if ( hIcon ) { + DestroyIcon( hIcon ); + hIcon = 0; // michalj + } + } + + // the unavoidable A/W versions. Don't forget to keep them in sync! + bool trayMessageA( DWORD msg ) + { + NOTIFYICONDATAA tnd; + ZeroMemory( &tnd, sizeof(NOTIFYICONDATAA) ); + tnd.cbSize = sizeof(NOTIFYICONDATAA); + tnd.hWnd = winId(); + tnd.uID = 1; // michalj + + if ( msg != NIM_DELETE ) { + tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; + tnd.uCallbackMessage= WM_NOTIFYICON; + tnd.hIcon = hIcon; + if ( !iconObject->toolTip().isNull() ) { + // Tip is limited to 63 + NULL; lstrcpyn appends a NULL terminator. + QString tip = iconObject->toolTip().left( 63 ) + QChar(); + lstrcpynA(tnd.szTip, (const char*)tip.local8Bit(), QMIN( tip.length()+1, 64 ) ); + } + } + + return Shell_NotifyIconA(msg, &tnd); + } + +#ifdef UNICODE + bool trayMessageW( DWORD msg ) + { + resolveLibs(); + if ( ! (ptrShell_NotifyIcon && qWinVersion() & Qt::WV_NT_based) ) + return trayMessageA( msg ); + + NOTIFYICONDATAW tnd; + ZeroMemory( &tnd, sizeof(NOTIFYICONDATAW) ); + tnd.cbSize = sizeof(NOTIFYICONDATAW); + tnd.hWnd = winId(); + tnd.uID = 1; // michalj + + if ( msg != NIM_DELETE ) { + tnd.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; + tnd.uCallbackMessage= WM_NOTIFYICON; + tnd.hIcon = hIcon; + if ( !iconObject->toolTip().isNull() ) { + // Tip is limited to 63 + NULL; lstrcpyn appends a NULL terminator. + QString tip = iconObject->toolTip().left( 63 ) + QChar(); + lstrcpynW(tnd.szTip, (TCHAR*)tip.unicode(), QMIN( tip.length()+1, 64 ) ); + // lstrcpynW(tnd.szTip, (TCHAR*)qt_winTchar( tip, FALSE ), QMIN( tip.length()+1, 64 ) ); + } + } + return ptrShell_NotifyIcon(msg, &tnd); + } +#endif + + bool trayMessage( DWORD msg ) + { + QT_WA( + return trayMessageW(msg); + , + return trayMessageA(msg); + ) + } + + bool iconDrawItem(LPDRAWITEMSTRUCT lpdi) + { + if (!hIcon) + return FALSE; + + DrawIconEx(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top, hIcon, 0, 0, 0, NULL, DI_NORMAL ); + return TRUE; + } + + bool winEvent( MSG *m ) + { + switch(m->message) { + case WM_DRAWITEM: + return iconDrawItem( (LPDRAWITEMSTRUCT)m->lParam ); + case WM_NOTIFYICON: + { + QMouseEvent *e = 0; + QPoint gpos = QCursor::pos(); + switch (m->lParam) { + case WM_MOUSEMOVE: e = new QMouseEvent( QEvent::MouseMove, mapFromGlobal( gpos ), gpos, 0, 0 ); break; + case WM_LBUTTONDOWN: e = new QMouseEvent( QEvent::MouseButtonPress, mapFromGlobal( gpos ), gpos, LeftButton, LeftButton ); break; + case WM_LBUTTONUP: e = new QMouseEvent( QEvent::MouseButtonRelease, mapFromGlobal( gpos ), gpos, LeftButton, LeftButton ); break; + case WM_LBUTTONDBLCLK: e = new QMouseEvent( QEvent::MouseButtonDblClick, mapFromGlobal( gpos ), gpos, LeftButton, LeftButton ); break; + case WM_RBUTTONDOWN: e = new QMouseEvent( QEvent::MouseButtonPress, mapFromGlobal( gpos ), gpos, RightButton, RightButton ); break; + case WM_RBUTTONUP: e = new QMouseEvent( QEvent::MouseButtonRelease, mapFromGlobal( gpos ), gpos, RightButton, RightButton ); break; + case WM_RBUTTONDBLCLK: e = new QMouseEvent( QEvent::MouseButtonDblClick, mapFromGlobal( gpos ), gpos, RightButton, RightButton ); break; + case WM_MBUTTONDOWN: e = new QMouseEvent( QEvent::MouseButtonPress, mapFromGlobal( gpos ), gpos, MidButton, MidButton ); break; + case WM_MBUTTONUP: e = new QMouseEvent( QEvent::MouseButtonRelease, mapFromGlobal( gpos ), gpos, MidButton, MidButton ); break; + case WM_MBUTTONDBLCLK: e = new QMouseEvent( QEvent::MouseButtonDblClick, mapFromGlobal( gpos ), gpos, MidButton, MidButton ); break; + case WM_CONTEXTMENU: e = new QMouseEvent( QEvent::MouseButtonRelease, mapFromGlobal( gpos ), gpos, RightButton, RightButton ); break; + } + if ( e ) { + bool res = QApplication::sendEvent( iconObject, e ); + delete e; + return res; + } + } + break; + default: + if ( m->message == WM_TASKBARCREATED ) trayMessage( NIM_ADD ); + } + return QWidget::winEvent( m ); + } +}; + +static HBITMAP createIconMask( const QPixmap &qp ) +{ + QImage bm = qp.convertToImage(); + int w = bm.width(); + int h = bm.height(); + int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment + uchar *bits = new uchar[bpl*h]; + bm.invertPixels(); + for ( int y=0; y<h; y++ ) + memcpy( bits+y*bpl, bm.scanLine(y), bpl ); + HBITMAP hbm = CreateBitmap( w, h, 1, 1, bits ); + delete [] bits; + return hbm; +} + +static HICON createIcon( const QPixmap &pm, HBITMAP &hbm ) +{ + QPixmap maskpm( pm.size(), pm.depth(), QPixmap::NormalOptim ); + QBitmap mask( pm.size(), FALSE, QPixmap::NormalOptim ); + if ( pm.mask() ) { + maskpm.fill( Qt::black ); // make masked area black + bitBlt( &mask, 0, 0, pm.mask() ); + } else + maskpm.fill( Qt::color1 ); + + bitBlt( &maskpm, 0, 0, &pm); + ICONINFO iconInfo; + iconInfo.fIcon = TRUE; + iconInfo.hbmMask = hbm = createIconMask(mask); + iconInfo.hbmColor = maskpm.hbm(); + + HICON icon = CreateIconIndirect( &iconInfo ); + DeleteObject(iconInfo.hbmMask); + iconInfo.hbmMask = hbm = 0; // michalj + return icon; +} + +void TrayIcon::sysInstall() +{ + if ( !d ) { + d = new TrayIconPrivate( this ); + d->hIcon = createIcon( pm, d->hMask ); + + d->trayMessage( NIM_ADD ); + } +} + +void TrayIcon::sysRemove() +{ + if ( d ) { + d->trayMessage( NIM_DELETE ); + + delete d; + d = 0; + } +} + +void TrayIcon::sysUpdateIcon() +{ + if ( d ) { + if ( d->hMask ) { + DeleteObject( d->hMask ); + d->hMask = 0; // michalj + } + if ( d->hIcon ) { + DestroyIcon( d->hIcon ); + d->hIcon = 0; // michalj + } + + d->hIcon = createIcon( pm, d->hMask ); + d->trayMessage( NIM_MODIFY ); + } +} + +void TrayIcon::sysUpdateToolTip() +{ + if ( d ) + d->trayMessage( NIM_MODIFY ); +} diff --git a/src/modules/dockwidget/trayicon_x11.cpp b/src/modules/dockwidget/trayicon_x11.cpp new file mode 100644 index 000000000..a3966a7f4 --- /dev/null +++ b/src/modules/dockwidget/trayicon_x11.cpp @@ -0,0 +1,413 @@ +/* + * trayicon_x11.cpp - X11 trayicon (for use with KDE and GNOME) + * Copyright (C) 2003 Justin Karneges + * GNOME2 Notification Area support: Tomasz Sterna + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "kvi_settings.h" // Needed for the two define checks below +#ifndef Q_OS_MACX +#ifndef COMPILE_ON_WINDOWS + +#include "trayicon.h" + +#include <qapplication.h> +#include <qimage.h> +#include <qpixmap.h> +#include <qtooltip.h> +#include <qpainter.h> + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xatom.h> + +//#if QT_VERSION < 0x030200 +extern Time qt_x_time; +//#endif + +//---------------------------------------------------------------------------- +// common stuff +//---------------------------------------------------------------------------- + +// for Gnome2 Notification Area +static XErrorHandler old_handler = 0; +static int dock_xerror = 0; +extern "C" int dock_xerrhandler(Display* dpy, XErrorEvent* err) +{ + dock_xerror = err->error_code; + return old_handler(dpy, err); +} + +static void trap_errors() +{ + dock_xerror = 0; + old_handler = XSetErrorHandler(dock_xerrhandler); +} + +static bool untrap_errors() +{ + XSetErrorHandler(old_handler); + return (dock_xerror == 0); +} + +static bool send_message( + Display* dpy, /* display */ + Window w, /* sender (tray icon window) */ + long message, /* message opcode */ + long data1, /* message data 1 */ + long data2, /* message data 2 */ + long data3 /* message data 3 */ +) { + XEvent ev; + + memset(&ev, 0, sizeof(ev)); + ev.xclient.type = ClientMessage; + ev.xclient.window = w; + ev.xclient.message_type = XInternAtom (dpy, "_NET_SYSTEM_TRAY_OPCODE", False ); + ev.xclient.format = 32; + ev.xclient.data.l[0] = CurrentTime; + ev.xclient.data.l[1] = message; + ev.xclient.data.l[2] = data1; + ev.xclient.data.l[3] = data2; + ev.xclient.data.l[4] = data3; + + trap_errors(); + XSendEvent(dpy, w, False, NoEventMask, &ev); + XSync(dpy, False); + return untrap_errors(); +} + +#define SYSTEM_TRAY_REQUEST_DOCK 0 +#define SYSTEM_TRAY_BEGIN_MESSAGE 1 +#define SYSTEM_TRAY_CANCEL_MESSAGE 2 + +//---------------------------------------------------------------------------- +// TrayIcon::TrayIconPrivate +//---------------------------------------------------------------------------- + +class TrayIcon::TrayIconPrivate : public QWidget +{ +public: + TrayIconPrivate(TrayIcon *object, int size); + ~TrayIconPrivate() { } + + virtual void initWM(WId icon); + + virtual void setPixmap(const QPixmap &pm); + + virtual void paintEvent(QPaintEvent *); + virtual void enterEvent(QEvent *); + virtual void mouseMoveEvent(QMouseEvent *e); + virtual void mousePressEvent(QMouseEvent *e); + virtual void mouseReleaseEvent(QMouseEvent *e); + virtual void mouseDoubleClickEvent(QMouseEvent *e); + virtual void closeEvent(QCloseEvent *e); + +private: + TrayIcon *iconObject; + QPixmap pix; + int size; +}; + +TrayIcon::TrayIconPrivate::TrayIconPrivate(TrayIcon *object, int _size) + : QWidget(0, "psidock", WRepaintNoErase) +{ + iconObject = object; + size = _size; + + setFocusPolicy(NoFocus); + setBackgroundMode(X11ParentRelative); + + setMinimumSize(size, size); + setMaximumSize(size, size); +} + +// This base stuff is required by both FreeDesktop specification and WindowMaker +void TrayIcon::TrayIconPrivate::initWM(WId icon) +{ + Display *dsp = x11Display(); + WId leader = winId(); + + // set the class hint + XClassHint classhint; + classhint.res_name = (char*)"psidock"; + classhint.res_class = (char*)"Psi"; + XSetClassHint(dsp, leader, &classhint); + + // set the Window Manager hints + XWMHints *hints; + hints = XGetWMHints(dsp, leader); // init hints + hints->flags = WindowGroupHint | IconWindowHint | StateHint; // set the window group hint + hints->window_group = leader; // set the window hint + hints->initial_state = WithdrawnState; // initial state + hints->icon_window = icon; // in WM, this should be winId() of separate widget + hints->icon_x = 0; + hints->icon_y = 0; + XSetWMHints(dsp, leader, hints); // set the window hints for WM to use. + XFree( hints ); +} + +void TrayIcon::TrayIconPrivate::setPixmap(const QPixmap &pm) +{ + pix = pm; + setIcon(pix); + repaint(); +} + +void TrayIcon::TrayIconPrivate::paintEvent(QPaintEvent *) +{ + QPainter p(this); + p.drawPixmap((width() - pix.width())/2, (height() - pix.height())/2, pix); +} + +void TrayIcon::TrayIconPrivate::enterEvent(QEvent *e) +{ + // Taken from KSystemTray.. +//#if QT_VERSION < 0x030200 + //if ( !qApp->focusWidget() ) { + XEvent ev; + memset(&ev, 0, sizeof(ev)); + ev.xfocus.display = qt_xdisplay(); + ev.xfocus.type = FocusIn; + ev.xfocus.window = winId(); + ev.xfocus.mode = NotifyNormal; + ev.xfocus.detail = NotifyAncestor; + Time time = qt_x_time; + qt_x_time = 1; + qApp->x11ProcessEvent( &ev ); + qt_x_time = time; + //} +//#endif + QWidget::enterEvent(e); +} + +void TrayIcon::TrayIconPrivate::mouseMoveEvent(QMouseEvent *e) +{ + QApplication::sendEvent(iconObject, e); +} + +void TrayIcon::TrayIconPrivate::mousePressEvent(QMouseEvent *e) +{ + QApplication::sendEvent(iconObject, e); +} + +void TrayIcon::TrayIconPrivate::mouseReleaseEvent(QMouseEvent *e) +{ + QApplication::sendEvent(iconObject, e); +} + +void TrayIcon::TrayIconPrivate::mouseDoubleClickEvent(QMouseEvent *e) +{ + QApplication::sendEvent(iconObject, e); +} + +void TrayIcon::TrayIconPrivate::closeEvent(QCloseEvent *e) +{ + iconObject->gotCloseEvent(); + e->accept(); +} + +//---------------------------------------------------------------------------- +// TrayIconFreeDesktop +//---------------------------------------------------------------------------- + +class TrayIconFreeDesktop : public TrayIcon::TrayIconPrivate +{ +public: + TrayIconFreeDesktop(TrayIcon *object, const QPixmap &pm); +protected: + virtual bool x11Event(XEvent*); +}; + +TrayIconFreeDesktop::TrayIconFreeDesktop(TrayIcon *object, const QPixmap &pm) + : TrayIconPrivate(object, 22) +{ + initWM( winId() ); + + // initialize NetWM + Display *dsp = x11Display(); + + // dock the widget (adapted from SIM-ICQ) + Screen *screen = XDefaultScreenOfDisplay(dsp); // get the screen + int screen_id = XScreenNumberOfScreen(screen); // and it's number + + // tell X that we want to see ClientMessage and Deleted events, which + // are picked up by QApplication::x11EventFilter + Window root_window = QApplication::desktop()->winId(); + XWindowAttributes attr; + + XGetWindowAttributes(dsp, root_window, &attr); + XSelectInput(dsp, root_window, attr.your_event_mask | StructureNotifyMask); + + char buf[32]; + snprintf(buf, sizeof(buf), "_NET_SYSTEM_TRAY_S%d", screen_id); + Atom selection_atom = XInternAtom(dsp, buf, false); + XGrabServer(dsp); + Window manager_window = XGetSelectionOwner(dsp, selection_atom); + if ( manager_window != None ) + XSelectInput(dsp, manager_window, StructureNotifyMask); + XUngrabServer(dsp); + XFlush(dsp); + + if ( manager_window != None ) + send_message(dsp, manager_window, SYSTEM_TRAY_REQUEST_DOCK, winId(), 0, 0); + else + { + object->hide(); + return; + } + + // some KDE mumbo-jumbo... why is it there? anybody? + Atom kwm_dockwindow_atom = XInternAtom(dsp, "KWM_DOCKWINDOW", false); + Atom kde_net_system_tray_window_for_atom = XInternAtom(dsp, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", false); + + long data = 0; + XChangeProperty(dsp, winId(), kwm_dockwindow_atom, kwm_dockwindow_atom, 32, PropModeReplace, (uchar*)&data, 1); + XChangeProperty(dsp, winId(), kde_net_system_tray_window_for_atom, XA_WINDOW, 32, PropModeReplace, (uchar*)&data, 1); + + setPixmap(pm); +} + +bool TrayIconFreeDesktop::x11Event(XEvent *ev) +{ + switch(ev->type) + { + case ReparentNotify: + show(); + + } + return false; +} + +//---------------------------------------------------------------------------- +// TrayIconWindowMaker +//---------------------------------------------------------------------------- + +class TrayIconWharf : public TrayIcon::TrayIconPrivate +{ +public: + TrayIconWharf(TrayIcon *object, const QPixmap &pm) + : TrayIconPrivate(object, 44) + { + // set the class hint + XClassHint classhint; + classhint.res_name = (char*)"psidock-wharf"; + classhint.res_class = (char*)"Psi"; + XSetClassHint(x11Display(), winId(), &classhint); + + setPixmap(pm); + } + + void setPixmap(const QPixmap &_pm) + { + QPixmap pm; + QImage i = _pm.convertToImage(); + i = i.scale(i.width() * 2, i.height() * 2); + pm.convertFromImage(i); + + TrayIconPrivate::setPixmap(pm); + + // thanks to Robert Spier for this: + // for some reason the repaint() isn't being honored, or isn't for + // the icon. So force one on the widget behind the icon + erase(); + QPaintEvent pe( rect() ); + paintEvent(&pe); + } +}; + +class TrayIconWindowMaker : public TrayIcon::TrayIconPrivate +{ +public: + TrayIconWindowMaker(TrayIcon *object, const QPixmap &pm); + ~TrayIconWindowMaker(); + + void setPixmap(const QPixmap &pm); + +private: + TrayIconWharf *wharf; +}; + +TrayIconWindowMaker::TrayIconWindowMaker(TrayIcon *object, const QPixmap &pm) + : TrayIconPrivate(object, 32) +{ + wharf = new TrayIconWharf(object, pm); + + initWM( wharf->winId() ); +} + +TrayIconWindowMaker::~TrayIconWindowMaker() +{ + delete wharf; +} + +void TrayIconWindowMaker::setPixmap(const QPixmap &pm) +{ + wharf->setPixmap(pm); +} + +//---------------------------------------------------------------------------- +// TrayIcon +//---------------------------------------------------------------------------- + +void TrayIcon::sysInstall() +{ + if ( d ) + return; + + if ( v_isWMDock ) + d = (TrayIconPrivate *)(new TrayIconWindowMaker(this, pm)); + else + d = (TrayIconPrivate *)(new TrayIconFreeDesktop(this, pm)); + + sysUpdateToolTip(); + + if ( v_isWMDock ) + d->show(); +} + +void TrayIcon::sysRemove() +{ + if ( !d ) + return; + + delete d; + d = 0; +} + +void TrayIcon::sysUpdateIcon() +{ + if ( !d ) + return; + + QPixmap pix = pm; + d->setPixmap(pix); +} + +void TrayIcon::sysUpdateToolTip() +{ + if ( !d ) + return; + + if ( tip.isEmpty() ) + QToolTip::remove(d); + else + QToolTip::add(d, tip); +} + +#endif +#endif
\ No newline at end of file |
