Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konqueror / about / konq_aboutpage.cc
blob8c98e9b724bc098268b028bf6acb37302dfa983d
1 #include "konq_aboutpage.h"
3 #include <QtCore/QTextCodec>
4 #include <QtCore/QDir>
6 #include <kaboutdata.h>
7 #include <kaction.h>
8 #include <kactioncollection.h>
9 #include <kapplication.h>
10 #include <kdebug.h>
11 #include <kiconloader.h>
12 #include <klocale.h>
13 #include <kmessagebox.h>
14 #include <ksavefile.h>
15 #include <kstandarddirs.h>
16 #include <ktoolinvocation.h>
18 K_EXPORT_COMPONENT_FACTORY( konq_aboutpage, KonqAboutPageFactory )
20 KComponentData *KonqAboutPageFactory::s_instance = 0;
21 QString *KonqAboutPageFactory::s_launch_html = 0;
22 QString *KonqAboutPageFactory::s_intro_html = 0;
23 QString *KonqAboutPageFactory::s_specs_html = 0;
24 QString *KonqAboutPageFactory::s_tips_html = 0;
25 QString *KonqAboutPageFactory::s_plugins_html = 0;
27 KonqAboutPageFactory::KonqAboutPageFactory( QObject *parent )
28 : KParts::Factory( parent )
30 s_instance = new KComponentData("konqaboutpage");
33 KonqAboutPageFactory::~KonqAboutPageFactory()
35 delete s_instance;
36 s_instance = 0;
37 delete s_launch_html;
38 s_launch_html = 0;
39 delete s_intro_html;
40 s_intro_html = 0;
41 delete s_specs_html;
42 s_specs_html = 0;
43 delete s_tips_html;
44 s_tips_html = 0;
45 delete s_plugins_html;
46 s_plugins_html = 0;
49 KParts::Part *KonqAboutPageFactory::createPartObject( QWidget *parentWidget, QObject *parent,
50 const char *, const QStringList & )
52 //KonqFrame *frame = dynamic_cast<KonqFrame *>( parentWidget );
53 //if ( !frame ) return 0;
55 return new KonqAboutPage( parentWidget, parent );
58 QString KonqAboutPageFactory::loadFile( const QString& file )
60 QString res;
61 if ( file.isEmpty() )
62 return res;
64 QFile f( file );
66 if ( !f.open( QIODevice::ReadOnly ) )
67 return res;
69 QTextStream t( &f );
71 res = t.readAll();
73 // otherwise all embedded objects are referenced as about:/...
74 QString basehref = QLatin1String("<BASE HREF=\"file:") +
75 file.left( file.lastIndexOf( '/' )) +
76 QLatin1String("/\">\n");
77 QRegExp reg("<head>");
78 reg.setCaseSensitivity(Qt::CaseInsensitive);
79 res.replace(reg, "<head>\n\t" + basehref);
80 return res;
83 QString KonqAboutPageFactory::launch()
85 if ( s_launch_html )
86 return *s_launch_html;
88 QString res = loadFile( KStandardDirs::locate( "data", "konqueror/about/launch.html" ));
89 if ( res.isEmpty() )
90 return res;
92 KIconLoader *iconloader = KIconLoader::global();
93 int iconSize = iconloader->currentSize(KIconLoader::Desktop);
94 QString home_icon_path = iconloader->iconPath("go-home", KIconLoader::Desktop );
95 QString storage_icon_path = iconloader->iconPath("computer", KIconLoader::Desktop );
96 QString remote_icon_path = iconloader->iconPath("folder-remote", KIconLoader::Desktop );
97 QString wastebin_icon_path = iconloader->iconPath("user-trash-full", KIconLoader::Desktop );
98 QString applications_icon_path = iconloader->iconPath("start-here-kde", KIconLoader::Desktop );
99 QString settings_icon_path = iconloader->iconPath("preferences-system", KIconLoader::Desktop );
100 QString home_folder = QDir::homePath();
101 QString continue_icon_path = iconloader->iconPath(QApplication::isRightToLeft() ? "go-previous" : "go-next", KIconLoader::Small );
103 res = res.arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage.css" ) );
104 if ( kapp->layoutDirection() == Qt::RightToLeft )
105 res = res.arg( "@import \"%1\";" ).arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage_rtl.css" ) );
106 else
107 res = res.arg( "" );
109 res = res.arg( i18n("Be free.") )
110 .arg( i18n( "Konqueror" ) )
111 .arg( i18n("Be free.") )
112 .arg( i18n("Konqueror is a web browser, file manager and universal document viewer.") )
113 .arg( i18n( "Starting Points" ) )
114 .arg( i18n( "Introduction" ) )
115 .arg( i18n( "Tips" ) )
116 .arg( i18n( "Specifications" ) )
117 .arg( home_folder )
118 .arg( home_icon_path )
119 .arg(iconSize).arg(iconSize)
120 .arg( home_folder )
121 .arg( i18n( "Home Folder" ) )
122 .arg( i18n( "Your personal files" ) )
123 .arg( wastebin_icon_path )
124 .arg(iconSize).arg(iconSize)
125 .arg( i18n( "Trash" ) )
126 .arg( i18n( "Browse and restore the trash" ) )
127 .arg( remote_icon_path )
128 .arg(iconSize).arg(iconSize)
129 .arg( i18n( "Network Folders" ) )
130 .arg( i18n( "Shared files and folders" ) )
131 .arg( applications_icon_path )
132 .arg(iconSize).arg(iconSize)
133 .arg( i18n( "Applications" ) )
134 .arg( i18n( "Installed programs" ) )
135 .arg( continue_icon_path )
136 .arg( KIconLoader::SizeSmall ).arg( KIconLoader::SizeSmall )
137 .arg( i18n( "Next: An Introduction to Konqueror" ) )
139 i18n("Search the Web");//i18n for possible future use
141 s_launch_html = new QString( res );
143 return res;
146 QString KonqAboutPageFactory::intro()
148 if ( s_intro_html )
149 return *s_intro_html;
151 QString res = loadFile( KStandardDirs::locate( "data", "konqueror/about/intro.html" ));
152 if ( res.isEmpty() )
153 return res;
155 KIconLoader *iconloader = KIconLoader::global();
156 QString back_icon_path = iconloader->iconPath(QApplication::isRightToLeft() ? "go-next" : "go-previous", KIconLoader::Small );
157 QString gohome_icon_path = iconloader->iconPath("go-home", KIconLoader::Small );
158 QString continue_icon_path = iconloader->iconPath(QApplication::isRightToLeft() ? "go-previous" : "go-next", KIconLoader::Small );
160 res = res.arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage.css" ) );
161 if ( kapp->layoutDirection() == Qt::RightToLeft )
162 res = res.arg( "@import \"%1\";" ).arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage_rtl.css" ) );
163 else
164 res = res.arg( "" );
166 res = res.arg( i18n("Be free.") )
167 .arg( i18n( "Konqueror" ) )
168 .arg( i18n( "Be free.") )
169 .arg( i18n( "Konqueror is your file manager, web browser and universal document viewer.") )
170 .arg( i18n( "Starting Points" ) )
171 .arg( i18n( "Introduction" ) )
172 .arg( i18n( "Tips" ) )
173 .arg( i18n( "Specifications" ) )
174 .arg( i18n( "Konqueror makes working with and managing your files easy. You can browse "
175 "both local and networked folders while enjoying advanced features "
176 "such as the powerful sidebar and file previews."
178 .arg( i18n( "Konqueror is also a full featured and easy to use web browser which you "
179 "can use to explore the Internet. "
180 "Enter the address (e.g. <a href=\"http://www.kde.org\">http://www.kde.org</a>) "
181 "of a web page you would like to visit in the location bar and press Enter, "
182 "or choose an entry from the Bookmarks menu.") )
183 .arg( i18n( "To return to the previous "
184 "location, press the back button <img width='16' height='16' src=\"%1\"></img> "
185 "in the toolbar. ", back_icon_path ) )
186 .arg( i18n( "To quickly go to your Home folder press the "
187 " home button <img width='16' height='16' src=\"%1\"></img>." , gohome_icon_path) )
188 .arg( i18n( "For more detailed documentation on Konqueror click <a href=\"%1\">here</a>." ,
189 QString("exec:/khelpcenter")) )
190 .arg( i18n( "<em>Tuning Tip:</em> If you want the Konqueror web browser to start faster,"
191 " you can turn off this information screen by clicking <a href=\"%1\">here</a>. You can re-enable it"
192 " by choosing the Help -> Konqueror Introduction menu option, and then pressing "
193 "Settings -> Save View Profile \"Web Browsing\".", QString("config:/disable_overview")) )
194 .arg( "<img width='16' height='16' src=\"%1\">" ).arg( continue_icon_path )
195 .arg( i18n( "Next: Tips &amp; Tricks" ) )
199 s_intro_html = new QString( res );
201 return res;
204 QString KonqAboutPageFactory::specs()
206 if ( s_specs_html )
207 return *s_specs_html;
209 KIconLoader *iconloader = KIconLoader::global();
210 QString res = loadFile( KStandardDirs::locate( "data", "konqueror/about/specs.html" ));
211 QString continue_icon_path = iconloader->iconPath(QApplication::isRightToLeft() ? "go-previous" : "go-next", KIconLoader::Small );
212 if ( res.isEmpty() )
213 return res;
215 res = res.arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage.css" ) );
216 if ( kapp->layoutDirection() == Qt::RightToLeft )
217 res = res.arg( "@import \"%1\";" ).arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage_rtl.css" ) );
218 else
219 res = res.arg( "" );
221 res = res.arg( i18n("Be free.") )
222 .arg( i18n( "Konqueror" ) )
223 .arg( i18n("Be free.") )
224 .arg( i18n("Konqueror is your file manager, web browser and universal document viewer.") )
225 .arg( i18n( "Starting Points" ) )
226 .arg( i18n( "Introduction" ) )
227 .arg( i18n( "Tips" ) )
228 .arg( i18n( "Specifications" ) )
229 .arg( i18n("Specifications") )
230 .arg( i18n("Konqueror is designed to embrace and support Internet standards. "
231 "The aim is to fully implement the officially sanctioned standards "
232 "from organizations such as the W3 and OASIS, while also adding "
233 "extra support for other common usability features that arise as "
234 "de facto standards across the Internet. Along with this support, "
235 "for such functions as favicons, Internet Keywords, and <A HREF=\"%1\">XBEL bookmarks</A>, "
236 "Konqueror also implements:", QString("http://pyxml.sourceforge.net/topics/xbel/")) )
237 .arg( i18n("Web Browsing") )
238 .arg( i18n("Supported standards") )
239 .arg( i18n("Additional requirements*") )
240 .arg( i18n("<A HREF=\"%1\">DOM</A> (Level 1, partially Level 2) based "
241 "<A HREF=\"%2\">HTML 4.01</A>", QString("http://www.w3.org/DOM"), QString("http://www.w3.org/TR/html4/")) )
242 .arg( i18n("built-in") )
243 .arg( i18n("<A HREF=\"%1\">Cascading Style Sheets</A> (CSS 1, partially CSS 2)", QString("http://www.w3.org/Style/CSS/")) )
244 .arg( i18n("built-in") )
245 .arg( i18n("<A HREF=\"%1\">ECMA-262</A> Edition 3 (roughly equals JavaScript 1.5)", QString("http://www.ecma.ch/ecma1/STAND/ECMA-262.HTM")) )
246 .arg( i18n("JavaScript disabled (globally). Enable JavaScript <A HREF=\"%1\">here</A>.", QString("exec:/kcmshell4 khtml_java_js")) )
247 .arg( i18n("JavaScript enabled (globally). Configure JavaScript <A HREF=\\\"%1\\\">here</A>.", QString("exec:/kcmshell4 khtml_java_js")) ) // leave the double backslashes here, they are necessary for javascript !
248 .arg( i18n("Secure <A HREF=\"%1\">Java</A><SUP>&reg;</SUP> support", QString("http://java.sun.com")) )
249 .arg( i18n("JDK 1.2.0 (Java 2) compatible VM (<A HREF=\"%1\">Blackdown</A>, <A HREF=\"%2\">IBM</A> or <A HREF=\"%3\">Sun</A>)",
250 QString("http://www.blackdown.org"), QString("http://www.ibm.com"), QString("http://java.sun.com")) )
251 .arg( i18n("Enable Java (globally) <A HREF=\"%1\">here</A>.", QString("exec:/kcmshell4 khtml_java_js")) ) // TODO Maybe test if Java is enabled ?
252 .arg( i18n("Netscape Communicator<SUP>&reg;</SUP> <A HREF=\"%4\">plugins</A> (for viewing <A HREF=\"%1\">Flash<SUP>&reg;</SUP></A>, <A HREF=\"%2\">Real<SUP>&reg;</SUP></A>Audio, <A HREF=\"%3\">Real<SUP>&reg;</SUP></A>Video, etc.)",
253 QString("http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"),
254 QString("http://www.real.com"), QString("http://www.real.com"),
255 QString("about:plugins")) )
256 .arg( i18n("built-in") )
257 .arg( i18n("Secure Sockets Layer") )
258 .arg( i18n("(TLS/SSL v2/3) for secure communications up to 168bit") )
259 .arg( i18n("OpenSSL") )
260 .arg( i18n("Bidirectional 16bit unicode support") )
261 .arg( i18n("built-in") )
262 .arg( i18n("AutoCompletion for forms") )
263 .arg( i18n("built-in") )
264 .arg( i18n("G E N E R A L") )
265 .arg( i18n("Feature") )
266 .arg( i18n("Details") )
267 .arg( i18n("Image formats") )
268 .arg( i18n("PNG<br />MNG<br />JPG<br />GIF") )
269 .arg( i18n("Transfer protocols") )
270 .arg( i18n("HTTP 1.1 (including gzip/bzip2 compression)") )
271 .arg( i18n("FTP") )
272 .arg( i18n("and <A HREF=\"%1\">many more...</A>", QString("exec:/kcmshell4 ioslaveinfo")) )
273 .arg( i18n("URL-Completion") )
274 .arg( i18n("Manual"))
275 .arg( i18n("Popup"))
276 .arg( i18n("(Short-) Automatic"))
277 .arg( "<img width='16' height='16' src=\"%1\">" ).arg( continue_icon_path )
278 .arg( i18n("<a href=\"%1\">Return to Starting Points</a>", QString("launch.html")) )
282 s_specs_html = new QString( res );
284 return res;
287 QString KonqAboutPageFactory::tips()
289 if ( s_tips_html )
290 return *s_tips_html;
292 QString res = loadFile( KStandardDirs::locate( "data", "konqueror/about/tips.html" ));
293 if ( res.isEmpty() )
294 return res;
296 KIconLoader *iconloader = KIconLoader::global();
297 QString viewmag_icon_path =
298 iconloader->iconPath("zoom-in", KIconLoader::Small );
299 QString history_icon_path =
300 iconloader->iconPath("view-history", KIconLoader::Small );
301 QString openterm_icon_path =
302 iconloader->iconPath("utilities-terminal", KIconLoader::Small );
303 QString locationbar_erase_rtl_icon_path =
304 iconloader->iconPath("edit-clear-locationbar-rtl", KIconLoader::Small );
305 QString locationbar_erase_icon_path =
306 iconloader->iconPath("edit-clear-locationbar-ltr", KIconLoader::Small );
307 QString window_fullscreen_icon_path =
308 iconloader->iconPath("view-fullscreen", KIconLoader::Small );
309 QString view_left_right_icon_path =
310 iconloader->iconPath("view-split-left-right", KIconLoader::Small );
311 QString continue_icon_path = iconloader->iconPath(QApplication::isRightToLeft() ? "go-previous" : "go-next", KIconLoader::Small );
313 res = res.arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage.css" ) );
314 if ( kapp->layoutDirection() == Qt::RightToLeft )
315 res = res.arg( "@import \"%1\";" ).arg( KStandardDirs::locate( "data", "kdeui/about/kde_infopage_rtl.css" ) );
316 else
317 res = res.arg( "" );
319 res = res.arg( i18n("Be free.") )
320 .arg( i18n( "Konqueror" ) )
321 .arg( i18n("Be free.") )
322 .arg( i18n("Konqueror is your file manager, web browser and universal document viewer.") )
323 .arg( i18n( "Starting Points" ) )
324 .arg( i18n( "Introduction" ) )
325 .arg( i18n( "Tips" ) )
326 .arg( i18n( "Specifications" ) )
327 .arg( i18n( "Tips &amp; Tricks" ) )
328 .arg( i18n( "Use Internet-Keywords and Web-Shortcuts: by typing \"gg: KDE\" one can search the Internet, "
329 "using Google, for the search phrase \"KDE\". There are a lot of "
330 "Web-Shortcuts predefined to make searching for software or looking "
331 "up certain words in an encyclopedia a breeze. You can even "
332 "<a href=\"%1\">create your own</a> Web-Shortcuts." , QString("exec:/kcmshell4 ebrowsing")) )
333 .arg( i18n( "Use the magnifier button <img width='16' height='16' src=\"%1\"></img> in the"
334 " toolbar to increase the font size on your web page.", viewmag_icon_path) )
335 .arg( i18n( "When you want to paste a new address into the Location toolbar you might want to "
336 "clear the current entry by pressing the black arrow with the white cross "
337 "<img width='16' height='16' src=\"%1\"></img> in the toolbar.",
338 QApplication::isRightToLeft() ? locationbar_erase_rtl_icon_path : locationbar_erase_icon_path))
339 .arg( i18n( "To create a link on your desktop pointing to the current page, "
340 "simply drag the \"Location\" label that is to the left of the Location toolbar, drop it on to "
341 "the desktop, and choose \"Link\"." ) )
342 .arg( i18n( "You can also find <img width='16' height='16' src=\"%1\" /> \"Full-Screen Mode\" "
343 "in the Settings menu. This feature is very useful for \"Talk\" "
344 "sessions.", window_fullscreen_icon_path) )
345 .arg( i18n( "Divide et impera (lat. \"Divide and conquer\") - by splitting a window "
346 "into two parts (e.g. Window -> <img width='16' height='16' src=\"%1\" /> Split View "
347 "Left/Right) you can make Konqueror appear the way you like. You"
348 " can even load some example view-profiles (e.g. Midnight Commander)"
349 ", or create your own ones." , view_left_right_icon_path))
350 .arg( i18n( "Use the <a href=\"%1\">user-agent</a> feature if the website you are visiting "
351 "asks you to use a different browser "
352 "(and do not forget to send a complaint to the webmaster!)" , QString("exec:/kcmshell4 useragent")) )
353 .arg( i18n( "The <img width='16' height='16' src=\"%1\"></img> History in your SideBar ensures "
354 "that you can keep track of the pages you have visited recently.", history_icon_path) )
355 .arg( i18n( "Use a caching <a href=\"%1\">proxy</a> to speed up your"
356 " Internet connection.", QString("exec:/kcmshell4 proxy")) )
357 .arg( i18n( "Advanced users will appreciate the Konsole which you can embed into "
358 "Konqueror (Window -> <img width='16' height='16' SRC=\"%1\"></img> Show "
359 "Terminal Emulator).", openterm_icon_path))
360 .arg( i18n( "<img width='16' height='16' src=\"%1\"></img>" , continue_icon_path ) )
361 .arg( i18n( "Next: Specifications" ) )
365 s_tips_html = new QString( res );
367 return res;
371 QString KonqAboutPageFactory::plugins()
373 if ( s_plugins_html )
374 return *s_plugins_html;
376 QString res = loadFile( KStandardDirs::locate( "data", kapp->layoutDirection() == Qt::RightToLeft ? "konqueror/about/plugins_rtl.html" : "konqueror/about/plugins.html" ))
377 .arg(i18n("Installed Plugins"))
378 .arg(i18n("<td>Plugin</td><td>Description</td><td>File</td><td>Types</td>"))
379 .arg(i18n("Installed"))
380 .arg(i18n("<td>Mime Type</td><td>Description</td><td>Suffixes</td><td>Plugin</td>"));
381 if ( res.isEmpty() )
382 return res;
384 s_plugins_html = new QString( res );
386 return res;
390 KonqAboutPage::KonqAboutPage( //KonqMainWindow *
391 QWidget *parentWidget, QObject *parent )
392 : KHTMLPart( parentWidget, parent, BrowserViewGUI )
394 //m_mainWindow = mainWindow;
395 QTextCodec* codec = KGlobal::locale()->codecForEncoding();
396 if (codec)
397 setEncoding(codec->name(), true);
398 else
399 setEncoding("iso-8859-1", true);
400 // about:blah isn't a kioslave -> disable View source
401 QAction * act = actionCollection()->action("viewDocumentSource");
402 if ( act )
403 act->setEnabled( false );
406 KonqAboutPage::~KonqAboutPage()
410 bool KonqAboutPage::openUrl( const KUrl &u )
412 if (u.url() == "about:plugins")
413 serve( KonqAboutPageFactory::plugins(), "plugins" );
414 else serve( KonqAboutPageFactory::launch(), "konqueror" );
415 return true;
418 bool KonqAboutPage::openFile()
420 return true;
423 void KonqAboutPage::saveState( QDataStream &stream )
425 stream << m_htmlDoc;
426 stream << m_what;
429 void KonqAboutPage::restoreState( QDataStream &stream )
431 stream >> m_htmlDoc;
432 stream >> m_what;
433 serve( m_htmlDoc, m_what );
436 void KonqAboutPage::serve( const QString& html, const QString& what )
438 m_what = what;
439 begin( KUrl( QString("about:%1").arg(what) ) );
440 write( html );
441 end();
442 m_htmlDoc = html;
445 bool KonqAboutPage::urlSelected( const QString &url, int button, int state, const QString &target,
446 const KParts::OpenUrlArguments& args,
447 const KParts::BrowserArguments& browserArgs )
449 KUrl u( url );
450 if ( u.protocol() == "exec" )
452 QStringList execArgs = url.mid( 6 ).split(QChar( ' ' ), QString::SkipEmptyParts );
453 QString executable = execArgs.first();
454 execArgs.erase( execArgs.begin() );
455 KToolInvocation::kdeinitExec( executable, execArgs );
456 return true;
459 if ( url == QLatin1String("launch.html") )
461 emit browserExtension()->openUrlNotify();
462 serve( KonqAboutPageFactory::launch(), "konqueror" );
463 return true;
465 else if ( url == QLatin1String("intro.html") )
467 emit browserExtension()->openUrlNotify();
468 serve( KonqAboutPageFactory::intro(), "konqueror" );
469 return true;
471 else if ( url == QLatin1String("specs.html") )
473 emit browserExtension()->openUrlNotify();
474 serve( KonqAboutPageFactory::specs(), "konqueror" );
475 return true;
477 else if ( url == QLatin1String("tips.html") )
479 emit browserExtension()->openUrlNotify();
480 serve( KonqAboutPageFactory::tips(), "konqueror" );
481 return true;
484 else if ( url == QLatin1String("config:/disable_overview") )
486 if ( KMessageBox::questionYesNo( widget(),
487 i18n("Do you want to disable showing "
488 "the introduction in the webbrowsing profile?"),
489 i18n("Faster Startup?"),KGuiItem(i18n("Disable")),KGuiItem(i18n("Keep")) )
490 == KMessageBox::Yes )
492 QString profile = KStandardDirs::locateLocal("data", "konqueror/profiles/webbrowsing");
493 KSaveFile file( profile );
494 if ( file.open() ) {
495 QTextStream stream(&file);
496 stream << "[Profile]\n"
497 "Name=Web-Browser";
500 return true;
503 return KHTMLPart::urlSelected( url, button, state, target, args, browserArgs );
506 #include "konq_aboutpage.moc"