00001 /*************************************************************************** 00002 * Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #include "PreCompiled.h" 00025 #ifndef _PreComp_ 00026 # include <QApplication> 00027 # include <QWhatsThisClickedEvent> 00028 #endif 00029 00030 #include "WhatsThis.h" 00031 #include "MainWindow.h" 00032 #include "Action.h" 00033 00034 00035 using namespace Gui; 00036 00037 00038 bool StdCmdDescription::_descrMode = false; 00039 00040 /* TRANSLATOR Gui::StdCmdDescription */ 00041 00042 StdCmdDescription::StdCmdDescription() 00043 : Command("Std_DescriptionMode") 00044 { 00045 sGroup = QT_TR_NOOP("Help"); 00046 sMenuText = QT_TR_NOOP("Des&cription"); 00047 sToolTipText = QT_TR_NOOP("Long description of commands"); 00048 sWhatsThis = QT_TR_NOOP("Long description of commands"); 00049 sStatusTip = QT_TR_NOOP("Long description of commands"); 00050 sAccel = "F1"; 00051 } 00052 00053 StdCmdDescription::~StdCmdDescription() 00054 { 00055 } 00056 00057 Action * StdCmdDescription::createAction(void) 00058 { 00059 Action *pcAction = Command::createAction(); 00060 pcAction->setCheckable( true ); 00061 return pcAction; 00062 } 00063 00064 void StdCmdDescription::activated(int iMsg) 00065 { 00066 if ( !inDescriptionMode() ) 00067 enterDescriptionMode(); 00068 else 00069 leaveDescriptionMode(); 00070 } 00071 00072 bool StdCmdDescription::inDescriptionMode() 00073 { 00074 return _descrMode; 00075 } 00076 00077 void StdCmdDescription::setSource( const QString& src ) 00078 { 00079 if ( !src.isEmpty() ) 00080 { 00081 QWhatsThisClickedEvent e(src); 00082 QApplication::sendEvent(getMainWindow(), &e); 00083 } 00084 } 00085 00086 void StdCmdDescription::enterDescriptionMode() 00087 { 00088 _descrMode = true; 00089 QApplication::setOverrideCursor(Qt::WhatsThisCursor); 00090 } 00091 00092 void StdCmdDescription::leaveDescriptionMode() 00093 { 00094 _descrMode = false; 00095 QApplication::restoreOverrideCursor(); 00096 } 00097