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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
/*
Copyright (c) 2003,2004,2005 Clarence Dang <[email protected]>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <kpmainwindow.h>
#include <kpmainwindow_p.h>
#include <dcopclient.h>
#include <tdeaction.h>
#include <kactivelabel.h>
#include <tdeapplication.h>
#include <tdeconfig.h>
#include <kdebug.h>
#include <kdialogbase.h>
#include <krun.h>
#include <tdelocale.h>
#include <tdeshortcut.h>
#include <kptool.h>
// private
void kpMainWindow::setupHelpMenuActions ()
{
TDEActionCollection *ac = actionCollection ();
// Explanation for action name:
// "Taking" is like a digital camera when you record the image and is
// analogous to pressing PrintScreen. However, "Acquiring" is when
// the image is brought into KolourPaint, just as you would acquire
// from a digital camera in future versions of KolourPaint. Hence
// "Acquiring" is more appropriate.
// -- Thurston
d->m_actionHelpTakingScreenshots = new TDEAction (
i18n ("Acquiring &Screenshots"), 0,
TQT_TQOBJECT(this), TQT_SLOT (slotHelpTakingScreenshots ()),
ac, "help_taking_screenshots");
enableHelpMenuDocumentActions (false);
}
// private
void kpMainWindow::enableHelpMenuDocumentActions (bool /*enable*/)
{
}
// SYNC: tdebase/twin/twinbindings.cpp
static TQString printScreenShortcutString ()
{
TDEConfigGroupSaver cfgGroupSaver (TDEGlobal::config (), "Global Shortcuts");
TDEConfigBase *cfg = cfgGroupSaver.config ();
// TODO: i18n() entry name? twinbindings.cpp seems to but it doesn't
// make sense.
const TQString cfgEntryString = cfg->readEntry ("Desktop Screenshot");
// (only use 1st key sequence, if it exists)
const TQString humanReadableShortcut =
TDEShortcut (cfgEntryString).seq (0).toString ();
if (!humanReadableShortcut.isEmpty ())
{
return humanReadableShortcut;
}
else
{
// (localised)
return KKey (TQt::CTRL + TQt::Key_Print).toString ();
}
}
// private slot
void kpMainWindow::slotHelpTakingScreenshots ()
{
#if DEBUG_KP_MAIN_WINDOW
kdDebug () << "kpMainWindow::slotHelpTakingScreenshots()" << endl;
#endif
if (toolHasBegunShape ())
tool ()->endShapeInternal ();
// TODO: Totally bogus logic if twin not running under same user as KolourPaint.
// SYNC: KWin contains PrintScreen key logic
QCStringList dcopApps = TDEApplication::dcopClient ()->registeredApplications ();
#if DEBUG_KP_MAIN_WINDOW
kdDebug () << "\tdcopApps=" << dcopApps << endl;
#endif
bool isRunningKDE = (dcopApps.findIndex ("twin") >= 0);
#if 0
{
int i = 0;
FILE *fp = fopen ("/home/kdevel/kolourpaint.tmp", "rt");
if (fp && fscanf (fp, "Hello: %d", &i) == 1)
isRunningKDE = i, fclose (fp);
}
#endif
TQString message;
if (isRunningKDE)
{
message = i18n
(
"<p>"
"To acquire a screenshot, press <b>%1</b>."
" The screenshot will be placed into the clipboard"
" and you will be able to paste it in KolourPaint."
"</p>"
"<p>"
"You may configure the <b>Desktop Screenshot</b> shortcut"
" in the Trinity Control Center"
" module <a href=\"configure kde shortcuts\">Keyboard Shortcuts</a>."
"</p>"
"<p>Alternatively, you may try the application"
" <a href=\"run ksnapshot\">KSnapshot</a>."
"</p>"
);
}
else
{
message = i18n
(
"<p>"
"You do not appear to be running TDE."
"</p>"
// We tell them this much even though they aren't running KDE
// to entice them to use KDE since it's so easy.
"<p>"
"Once you have loaded TDE:<br>"
"<blockquote>"
"To acquire a screenshot, press <b>%1</b>."
" The screenshot will be placed into the clipboard"
" and you will be able to paste it in KolourPaint."
"</blockquote>"
"</p>"
"<p>Alternatively, you may try the application"
" <a href=\"run ksnapshot\">KSnapshot</a>."
"</p>"
);
}
// TODO: Totally bogus logic if twin not running under same user as KolourPaint.
message = message.arg (::printScreenShortcutString ());
// Add extra vertical space
message += "<p> </p>";
KDialogBase dlg (this, "helpTakingScreenshotsDialog", true/*modal*/,
i18n ("Acquiring Screenshots"),
KDialogBase::Close, KDialogBase::Close/*default btn*/,
true/*separator line*/);
KActiveLabel *messageLabel = new KActiveLabel (message, &dlg);
disconnect (messageLabel, TQT_SIGNAL (linkClicked (const TQString &)),
messageLabel, TQT_SLOT (openLink (const TQString &)));
connect (messageLabel, TQT_SIGNAL (linkClicked (const TQString &)),
TQT_TQOBJECT(this), TQT_SLOT (slotHelpTakingScreenshotsFollowLink (const TQString &)));
dlg.setMainWidget (messageLabel);
dlg.exec ();
}
// private
void kpMainWindow::slotHelpTakingScreenshotsFollowLink (const TQString &link)
{
#if DEBUG_KP_MAIN_WINDOW
kdDebug () << "kpMainWindow::slotHelpTakingScreenshotsFollowLink("
<< link << ")" << endl;
#endif
if (link == "configure kde shortcuts")
{
KRun::runCommand ("tdecmshell keys");
}
else if (link == "run ksnapshot")
{
KRun::runCommand ("ksnapshot");
}
else
{
kdError () << "kpMainWindow::slotHelpTakingScreenshotsFollowLink("
<< link << ")" << endl;
}
}
|