diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b761458b6a..18cba1ba33 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,20 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-30 11:39 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/hbqt/generator/qt45.qtp + * harbour/contrib/hbqt/hbqt.h + * harbour/contrib/hbqt/Makefile_gen + + harbour/contrib/hbqt/QSystemTrayIcon.prg + + harbour/contrib/hbqt/hbqt_qsystemtrayicon.cpp + + harbour/contrib/hbqt/qth/QSystemTrayIcon.qth + + Added QSystemTrayIcon() class. + + + harbour/contrib/hbqt/tests/demoqt.prg + ! Demonstrated the use to put application in system tray. Press + toolbar button. Then right-click on icon in system tray. + Every 10 seconds, a message will appear automatically. + 2009-06-30 18:04 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbtypes.h * harbour/source/vm/maindllp.c diff --git a/harbour/contrib/hbqt/Makefile_gen b/harbour/contrib/hbqt/Makefile_gen index bea0903a9d..ed05d95066 100644 --- a/harbour/contrib/hbqt/Makefile_gen +++ b/harbour/contrib/hbqt/Makefile_gen @@ -160,6 +160,7 @@ CPP_SOURCES=\ hbqt_qstyleoptiontoolbutton.cpp \ hbqt_qstyleoptionviewitem.cpp \ hbqt_qstylepainter.cpp \ + hbqt_qsystemtrayicon.cpp \ hbqt_qtabbar.cpp \ hbqt_qtableview.cpp \ hbqt_qtablewidget.cpp \ @@ -382,6 +383,7 @@ PRG_SOURCES=\ TQStyleOptionToolButton.prg \ TQStyleOptionViewItem.prg \ TQStylePainter.prg \ + TQSystemTrayIcon.prg \ TQTabBar.prg \ TQTableView.prg \ TQTableWidget.prg \ diff --git a/harbour/contrib/hbqt/TQSystemTrayIcon.prg b/harbour/contrib/hbqt/TQSystemTrayIcon.prg new file mode 100644 index 0000000000..fe8890fef5 --- /dev/null +++ b/harbour/contrib/hbqt/TQSystemTrayIcon.prg @@ -0,0 +1,94 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Marcos Antonio Gambeta + * Copyright 2009 Pritpal Bedi + * www - http://www.harbour-project.org + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ + + +#include "hbclass.ch" + + +CREATE CLASS QSystemTrayIcon INHERIT QObject + + VAR pParent + VAR pPtr + + METHOD New() + + METHOD contextMenu() INLINE Qt_QSystemTrayIcon_contextMenu( ::pPtr ) + METHOD geometry() INLINE Qt_QSystemTrayIcon_geometry( ::pPtr ) + METHOD icon() INLINE Qt_QSystemTrayIcon_icon( ::pPtr ) + METHOD isVisible() INLINE Qt_QSystemTrayIcon_isVisible( ::pPtr ) + METHOD setContextMenu( pMenu ) INLINE Qt_QSystemTrayIcon_setContextMenu( ::pPtr, pMenu ) + METHOD setIcon( cIcon ) INLINE Qt_QSystemTrayIcon_setIcon( ::pPtr, cIcon ) + METHOD setToolTip( cTip ) INLINE Qt_QSystemTrayIcon_setToolTip( ::pPtr, cTip ) + METHOD showMessage( cTitle, cMessage, nIcon, nMillisecondsTimeoutHint ) INLINE Qt_QSystemTrayIcon_showMessage( ::pPtr, cTitle, cMessage, nIcon, nMillisecondsTimeoutHint ) + METHOD toolTip() INLINE Qt_QSystemTrayIcon_toolTip( ::pPtr ) + METHOD isSystemTrayAvailable() INLINE Qt_QSystemTrayIcon_isSystemTrayAvailable( ::pPtr ) + METHOD supportsMessages() INLINE Qt_QSystemTrayIcon_supportsMessages( ::pPtr ) + METHOD hide() INLINE Qt_QSystemTrayIcon_hide( ::pPtr ) + METHOD setVisible( lVisible ) INLINE Qt_QSystemTrayIcon_setVisible( ::pPtr, lVisible ) + METHOD show() INLINE Qt_QSystemTrayIcon_show( ::pPtr ) + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD New( pParent ) CLASS QSystemTrayIcon + + ::pParent := pParent + + ::pPtr := Qt_QSystemTrayIcon( pParent ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbqt/generator/qt45.qtp b/harbour/contrib/hbqt/generator/qt45.qtp index 7f84af6a70..caca7442b6 100644 --- a/harbour/contrib/hbqt/generator/qt45.qtp +++ b/harbour/contrib/hbqt/generator/qt45.qtp @@ -172,6 +172,7 @@ QStyleOptionToolButton.qth QStyleOptionViewItem.qth QStylePainter.qth +QSystemTrayIcon.qth QTabBar.qth QTableView.qth QTableWidget.qth diff --git a/harbour/contrib/hbqt/hbqt.h b/harbour/contrib/hbqt/hbqt.h index 2b900b6e26..d2d9468695 100644 --- a/harbour/contrib/hbqt/hbqt.h +++ b/harbour/contrib/hbqt/hbqt.h @@ -331,6 +331,7 @@ #define hbqt_par_QDragEnterEvent( n ) ( ( QDragEnterEvent* ) hb_parptr( n ) ) #define hbqt_par_QDragLeaveEvent( n ) ( ( QDragLeaveEvent* ) hb_parptr( n ) ) #define hbqt_par_QMouseEvent( n ) ( ( QMouseEvent* ) hb_parptr( n ) ) +#define hbqt_par_QSystemTrayIcon( n ) ( ( QSystemTrayIcon* ) hb_parptr( n ) ) #define hbqt_par_QString( n ) ( ( QString ) hb_parcx( n ) ) #define hbqt_par_QRgb( n ) ( hb_parnint( n ) ) diff --git a/harbour/contrib/hbqt/hbqt_qsystemtrayicon.cpp b/harbour/contrib/hbqt/hbqt_qsystemtrayicon.cpp new file mode 100644 index 0000000000..d8a280305b --- /dev/null +++ b/harbour/contrib/hbqt/hbqt_qsystemtrayicon.cpp @@ -0,0 +1,192 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Marcos Antonio Gambeta + * Copyright 2009 Pritpal Bedi + * www - http://www.harbour-project.org + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ + +#include "hbapi.h" +#include "hbqt.h" + +/*----------------------------------------------------------------------*/ +#if QT_VERSION >= 0x040500 +/*----------------------------------------------------------------------*/ + + +#include + + +/* + * QSystemTrayIcon ( QObject * parent = 0 ) + * QSystemTrayIcon ( const QIcon & icon, QObject * parent = 0 ) + * ~QSystemTrayIcon () + */ +HB_FUNC( QT_QSYSTEMTRAYICON ) +{ + hb_retptr( ( QSystemTrayIcon* ) new QSystemTrayIcon( hbqt_par_QWidget( 1 ) ) ); +} + +/* + * QMenu * contextMenu () const + */ +HB_FUNC( QT_QSYSTEMTRAYICON_CONTEXTMENU ) +{ + hb_retptr( ( QMenu* ) hbqt_par_QSystemTrayIcon( 1 )->contextMenu() ); +} + +/* + * QRect geometry () const + */ +HB_FUNC( QT_QSYSTEMTRAYICON_GEOMETRY ) +{ + hb_retptr( new QRect( hbqt_par_QSystemTrayIcon( 1 )->geometry() ) ); +} + +/* + * QIcon icon () const + */ +HB_FUNC( QT_QSYSTEMTRAYICON_ICON ) +{ + hb_retptr( new QIcon( hbqt_par_QSystemTrayIcon( 1 )->icon() ) ); +} + +/* + * bool isVisible () const + */ +HB_FUNC( QT_QSYSTEMTRAYICON_ISVISIBLE ) +{ + hb_retl( hbqt_par_QSystemTrayIcon( 1 )->isVisible() ); +} + +/* + * void setContextMenu ( QMenu * menu ) + */ +HB_FUNC( QT_QSYSTEMTRAYICON_SETCONTEXTMENU ) +{ + hbqt_par_QSystemTrayIcon( 1 )->setContextMenu( hbqt_par_QMenu( 2 ) ); +} + +/* + * void setIcon ( const QIcon & icon ) + */ +HB_FUNC( QT_QSYSTEMTRAYICON_SETICON ) +{ + hbqt_par_QSystemTrayIcon( 1 )->setIcon( QIcon( hbqt_par_QString( 2 ) ) ); +} + +/* + * void setToolTip ( const QString & tip ) + */ +HB_FUNC( QT_QSYSTEMTRAYICON_SETTOOLTIP ) +{ + hbqt_par_QSystemTrayIcon( 1 )->setToolTip( hbqt_par_QString( 2 ) ); +} + +/* + * void showMessage ( const QString & title, const QString & message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000 ) + */ +HB_FUNC( QT_QSYSTEMTRAYICON_SHOWMESSAGE ) +{ + hbqt_par_QSystemTrayIcon( 1 )->showMessage( hbqt_par_QString( 2 ), hbqt_par_QString( 3 ), ( HB_ISNUM( 4 ) ? ( QSystemTrayIcon::MessageIcon ) hb_parni( 4 ) : ( QSystemTrayIcon::MessageIcon ) QSystemTrayIcon::Information ), ( HB_ISNUM( 5 ) ? hb_parni( 5 ) : 10000 ) ); +} + +/* + * QString toolTip () const + */ +HB_FUNC( QT_QSYSTEMTRAYICON_TOOLTIP ) +{ + hb_retc( hbqt_par_QSystemTrayIcon( 1 )->toolTip().toLatin1().data() ); +} + +/* + * bool isSystemTrayAvailable () + */ +HB_FUNC( QT_QSYSTEMTRAYICON_ISSYSTEMTRAYAVAILABLE ) +{ + hb_retl( hbqt_par_QSystemTrayIcon( 1 )->isSystemTrayAvailable() ); +} + +/* + * bool supportsMessages () + */ +HB_FUNC( QT_QSYSTEMTRAYICON_SUPPORTSMESSAGES ) +{ + hb_retl( hbqt_par_QSystemTrayIcon( 1 )->supportsMessages() ); +} + +/* + * void hide () + */ +HB_FUNC( QT_QSYSTEMTRAYICON_HIDE ) +{ + hbqt_par_QSystemTrayIcon( 1 )->hide(); +} + +/* + * void setVisible ( bool visible ) + */ +HB_FUNC( QT_QSYSTEMTRAYICON_SETVISIBLE ) +{ + hbqt_par_QSystemTrayIcon( 1 )->setVisible( hb_parl( 2 ) ); +} + +/* + * void show () + */ +HB_FUNC( QT_QSYSTEMTRAYICON_SHOW ) +{ + hbqt_par_QSystemTrayIcon( 1 )->show(); +} + + +/*----------------------------------------------------------------------*/ +#endif /* #if QT_VERSION >= 0x040500 */ +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbqt/qth/QSystemTrayIcon.qth b/harbour/contrib/hbqt/qth/QSystemTrayIcon.qth new file mode 100644 index 0000000000..0ea5ee20bb --- /dev/null +++ b/harbour/contrib/hbqt/qth/QSystemTrayIcon.qth @@ -0,0 +1,113 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT Source Generator for Harbour + * + * Copyright 2009 Pritpal Bedi + * www - http://www.harbour-project.org + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ +; +; Header File to Generate QT Wrapper Sources +; + + +Inherits = QObject +Type = Core +New = + + + +#include + + +/* + * QSystemTrayIcon ( QObject * parent = 0 ) + * QSystemTrayIcon ( const QIcon & icon, QObject * parent = 0 ) + * ~QSystemTrayIcon () + */ +HB_FUNC( QT_QSYSTEMTRAYICON ) +{ + hb_retptr( ( QSystemTrayIcon* ) new QSystemTrayIcon( hbqt_par_QObject( 1 ) ) ); +} + + + +enum ActivationReason { Unknown, Context, DoubleClick, Trigger, MiddleClick } +enum MessageIcon { NoIcon, Information, Warning, Critical } + + + +QMenu * contextMenu () const +QRect geometry () const +QIcon icon () const +bool isVisible () const +void setContextMenu ( QMenu * menu ) +void setIcon ( const QIcon & icon ) +void setToolTip ( const QString & tip ) +void showMessage ( const QString & title, const QString & message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000 ) +QString toolTip () const + +bool isSystemTrayAvailable () +bool supportsMessages () + + + +void hide () +void setVisible ( bool visible ) +void show () + + + +void activated ( QSystemTrayIcon::ActivationReason reason ) +void messageClicked () + + + + + + + diff --git a/harbour/contrib/hbqt/tests/demoqt.prg b/harbour/contrib/hbqt/tests/demoqt.prg index 0d424bb29e..85c5ded884 100644 --- a/harbour/contrib/hbqt/tests/demoqt.prg +++ b/harbour/contrib/hbqt/tests/demoqt.prg @@ -132,6 +132,7 @@ PROCEDURE Main() oWnd:Show() + qt_qapplication_exec() RETURN /*----------------------------------------------------------------------*/ @@ -256,6 +257,12 @@ STATIC FUNCTION Build_ToolBar( oWnd ) Qt_Connect_Signal( QT_PTROF( oAct ), QT_EVE_TRIGGERED_B, {|w,l| Dialogs( "Wizard", w, l ) } ) oTB:addAction( QT_PTROF( oAct ) ) + oAct := QAction():new( QT_PTROF( oWnd ) ) + oAct:setText( "&SystemTray" ) + oAct:setToolTip( "Show in System Tray!" ) + Qt_Connect_Signal( QT_PTROF( oAct ), QT_EVE_TRIGGERED_B, {|w,l| ShowInSystemTray( oWnd, w, l ) } ) + oTB:addAction( QT_PTROF( oAct ) ) + /* Add this toolbar with main window */ oWnd:addToolBar_1( QT_PTROF( oTB ) ) @@ -721,3 +728,24 @@ STATIC FUNCTION Dummies() /*----------------------------------------------------------------------*/ +FUNCTION ShowInSystemTray( oWnd ) + LOCAL oSys + LOCAL oMenu + + oMenu := QMenu():new( QT_PTROF( oWnd ) ) + oMenu:setTitle( "&File" ) + Qt_Connect_Signal( oMenu:addAction_1( "new.png" , "&Show" ), QT_EVE_TRIGGERED_B, {|w,l| oWnd:show() } ) + oMenu:addSeparator() + Qt_Connect_Signal( oMenu:addAction_1( "save.png", "&Hide" ), QT_EVE_TRIGGERED_B, {|w,l| oWnd:hide() } ) + + oSys := QSystemTrayIcon():new( QT_PTROF( oWnd ) ) + oSys:setIcon( 'new.png' ) + oSys:setContextMenu( QT_PTROF( oMenu ) ) + oSys:showMessage( "Harbour-QT", "This is Harbour-QT System Tray" ) + oSys:show() + oWnd:hide() + + RETURN nil + +/*----------------------------------------------------------------------*/ +