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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/*
miscutils.h - Misc functions
Copyright (C) 2004 Konrad Twardowski <kdtonline@poczta.onet.pl>
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.
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 program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __MISCUTILS_H__
#define __MISCUTILS_H__
#include <tqdatetime.h>
#include <kprocess.h>
class TDEAction;
class KPushButton;
/** @short Misc functions. */
class MiscUtils
{
public:
/**
* Closes the CD-ROM tray (if this option is enabled).
*/
static void closeCDTray();
/**
* Displays a custom message.
* @param text A text to display
* @param testCommand A command to execute (used internally in settings dialog to test entered command)
*/
static void customMessage(const TQString &text, const TQString &testCommand = TQString::null);
/**
* Converts seconds to time string.
* @param secs A number of seconds to convert
* @param format A date/time format
* @return Converted seconds or ">24", if @p secs >= 86400
*/
static TQString formatDateTime(const int secs, const TQString &format = TQString::null);
/**
* Converts seconds to time string.
* @param dt A date/time to convert
* @return Converted seconds or ">24", if @p secs >= 86400
*/
static TQString formatDateTime(const TQDateTime &dt);
inline static TQString HTML(const TQString &text) {
return ("<qt>" + text + "</qt>");
}
inline static TQString HTML(TQString &text) {
text.prepend("<qt>");
text.append("</qt>");
return text;
}
/**
* Returns @c true if function (@p key) is restricted (KDE Kiosk).
* The key value is read from the configuration file
* (usually /usr/share/config/kshutdownrc).
* See Handbook (F1) for details.
*/
static bool isRestricted(const TQString &key);
/**
* Visual and sound notifications.
* @param secs A number of seconds to action
*/
static void notifyUser(const int secs);
static void passiveMessage(const TQString &text, TQWidget *parent = 0);
static void plug(const TDEAction *action, KPushButton *pushButton);
/**
* Executes a command.
* @param command A command to execute
* @return @c true if successfull; otherwise @c false
*/
static bool runCommand(const TQString &command);
/**
* Executes a shell command before the specified action.
* @param configEntry A configuration entry (e.g. <i>"Shut Down"</i>)
*/
static void runCommandBeforeAction(const TQString &configEntry);
/**
* Executes a shell command.
* @param command A shell command to execute
* @param mode A run mode (@c TDEProcess::DontCare by default)
* @param pause A timeout in seconds (no timeout by default)
* @return @c true if successfull; otherwise @c false
*/
static bool runShellCommand(const TQString &command, const TDEProcess::RunMode mode = TDEProcess::DontCare, const int pause = -1);
static void setAutostart(const bool yes);
/**
* Sets "tool tip text" and "what's this text" of @p widget to @p value.
*/
static void setHint(TQWidget *widget, const TQString &value);
/**
* Displays a "KRun" error message in a passive message.
* @param command A command that failed
*/
static void showRunErrorMessage(const TQString &command);
/**
* Displays an information if KShutDown is in the <b>Test Mode</b>.
* @param message A message to display
*/
static void showTestMessage(const TQString &message);
private:
static void notifyUser(const TQString &name, const TQString &text);
};
#endif // __MISCUTILS_H__
|