summaryrefslogtreecommitdiffstats
path: root/kstars/kstars/toggleaction.cpp
blob: a0b59a64798929bc08d696e512eb9e4b2157b5c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/***************************************************************************
                          toggleaction.cpp  -  description
                             -------------------
    begin                : Son Feb 10 2002
    copyright            : (C) 2002 by Mark Hollomon
    email                : mhh@mindspring.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "toggleaction.h"

ToggleAction::ToggleAction(const TQString& ontext, const TQIconSet& onpix,
	const TQString& offtext, const TQIconSet& offpix,
	int accel, const TQObject* receiver, const char* slot, TQObject* parent, const char* name ) :
		KAction(ontext, onpix, accel, receiver, slot, parent, name),
		officon(offpix),
		onicon(onpix),
		offcap(offtext),
		oncap(ontext),
		state(true)
{}

ToggleAction::ToggleAction(const TQString& ontext, const TQString& offtext,
	int accel, const TQObject* receiver, const char* slot, TQObject* parent, const char* name ) :
		KAction(ontext, accel, receiver, slot, parent, name),
		officon(),
		onicon(),
		offcap(offtext),
		oncap(ontext),
		state(true)
{}

void ToggleAction::turnOff() {
	if ( !officon.isNull() ) setIconSet(officon);
	setText(offcap);
	setToolTip(offTip);
	state = false;
}

void ToggleAction::turnOn() {
	if ( !onicon.isNull() ) setIconSet(onicon);
	setText(oncap);
	setToolTip(onTip);
	state = true;
}

void ToggleAction::setOnToolTip(TQString tip) {
	onTip = tip;
	if (state)
		setToolTip(tip);
}

void ToggleAction::setOffToolTip(TQString tip) {
	offTip = tip;
	if (!state)
		setToolTip(tip);
}

#include "toggleaction.moc"