moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / toggleaction.cpp
blob3c1b2adcdc0a5fa90d45a042b34b1f100bd8e453
1 /***************************************************************************
2 toggleaction.cpp - description
3 -------------------
4 begin : Son Feb 10 2002
5 copyright : (C) 2002 by Mark Hollomon
6 email : mhh@mindspring.com
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include "toggleaction.h"
20 ToggleAction::ToggleAction(const QString& ontext, const QIconSet& onpix,
21 const QString& offtext, const QIconSet& offpix,
22 int accel, const QObject* receiver, const char* slot, QObject* parent, const char* name ) :
23 KAction(ontext, onpix, accel, receiver, slot, parent, name),
24 officon(offpix),
25 onicon(onpix),
26 offcap(offtext),
27 oncap(ontext),
28 state(true)
31 ToggleAction::ToggleAction(const QString& ontext, const QString& offtext,
32 int accel, const QObject* receiver, const char* slot, QObject* parent, const char* name ) :
33 KAction(ontext, accel, receiver, slot, parent, name),
34 officon(),
35 onicon(),
36 offcap(offtext),
37 oncap(ontext),
38 state(true)
41 void ToggleAction::turnOff() {
42 if ( !officon.isNull() ) setIconSet(officon);
43 setText(offcap);
44 setToolTip(offTip);
45 state = false;
48 void ToggleAction::turnOn() {
49 if ( !onicon.isNull() ) setIconSet(onicon);
50 setText(oncap);
51 setToolTip(onTip);
52 state = true;
55 void ToggleAction::setOnToolTip(QString tip) {
56 onTip = tip;
57 if (state)
58 setToolTip(tip);
61 void ToggleAction::setOffToolTip(QString tip) {
62 offTip = tip;
63 if (!state)
64 setToolTip(tip);
67 #include "toggleaction.moc"