| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
#include <QApplication> |
| 25 |
#include <QWhatsThisClickedEvent> |
| 26 |
|
| 27 |
|
| 28 |
#include "WhatsThis.h" |
| 29 |
#include "Action.h" |
| 30 |
#include "MainWindow.h" |
| 31 |
|
| 32 |
|
| 33 |
using namespace Gui; |
| 34 |
|
| 35 |
|
| 36 |
bool StdCmdDescription::_descrMode = false; |
| 37 |
|
| 38 |
/* TRANSLATOR Gui::StdCmdDescription */ |
| 39 |
|
| 40 |
StdCmdDescription::StdCmdDescription() |
| 41 |
: Command("Std_DescriptionMode") |
| 42 |
{ |
| 43 |
sGroup = "Help"; |
| 44 |
sMenuText = QT_TR_NOOP("Des&cription"); |
| 45 |
sToolTipText = QT_TR_NOOP("Long description of commands"); |
| 46 |
sWhatsThis = "Std_DescriptionMode"; |
| 47 |
sStatusTip = sToolTipText; |
| 48 |
sAccel = "F1"; |
| 49 |
} |
| 50 |
|
| 51 |
StdCmdDescription::~StdCmdDescription() = default; |
| 52 |
|
| 53 |
Action* StdCmdDescription::createAction() |
| 54 |
{ |
| 55 |
Action* pcAction = Command::createAction(); |
| 56 |
pcAction->setCheckable(true); |
| 57 |
return pcAction; |
| 58 |
} |
| 59 |
|
| 60 |
void StdCmdDescription::activated(int iMsg) |
| 61 |
{ |
| 62 |
Q_UNUSED(iMsg); |
| 63 |
if (!inDescriptionMode()) { |
| 64 |
enterDescriptionMode(); |
| 65 |
} |
| 66 |
else { |
| 67 |
leaveDescriptionMode(); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
bool StdCmdDescription::inDescriptionMode() |
| 72 |
{ |
| 73 |
return _descrMode; |
| 74 |
} |
| 75 |
|
| 76 |
void StdCmdDescription::setSource(const QString& src) |
| 77 |
{ |
| 78 |
if (!src.isEmpty()) { |
| 79 |
QWhatsThisClickedEvent e(src); |
| 80 |
QApplication::sendEvent(getMainWindow(), &e); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
void StdCmdDescription::enterDescriptionMode() |
| 85 |
{ |
| 86 |
_descrMode = true; |
| 87 |
QApplication::setOverrideCursor(Qt::WhatsThisCursor); |
| 88 |
} |
| 89 |
|
| 90 |
void StdCmdDescription::leaveDescriptionMode() |
| 91 |
{ |
| 92 |
_descrMode = false; |
| 93 |
QApplication::restoreOverrideCursor(); |
| 94 |
} |