28 #include "tdehtml_ext.h"
29 #include "tdehtmlview.h"
30 #include "tdehtml_pagecache.h"
31 #include "rendering/render_form.h"
32 #include "rendering/render_image.h"
33 #include "html/html_imageimpl.h"
34 #include "misc/loader.h"
35 #include "dom/html_form.h"
36 #include "dom/html_image.h"
37 #include <tqclipboard.h>
38 #include <tqfileinfo.h>
39 #include <tqpopupmenu.h>
41 #include <tqmetaobject.h>
42 #include <private/tqucomextra_p.h>
43 #include <tqdragobject.h>
47 #include <tdefiledialog.h>
48 #include <tdeio/job.h>
49 #include <tdeprocess.h>
50 #include <tdetoolbarbutton.h>
51 #include <tdetoolbar.h>
52 #include <ksavefile.h>
54 #include <kstringhandler.h>
55 #include <tdeapplication.h>
56 #include <tdemessagebox.h>
57 #include <kstandarddirs.h>
59 #include <kurifilter.h>
60 #include <kiconloader.h>
61 #include <kdesktopfile.h>
62 #include <tdemultipledrag.h>
63 #include <kinputdialog.h>
65 #include "tdehtml_factory.h"
67 #include "dom/dom_element.h"
68 #include "misc/htmltags.h"
70 #include "tdehtmlpart_p.h"
72 TDEHTMLPartBrowserExtension::TDEHTMLPartBrowserExtension(
TDEHTMLPart *parent,
const char *name )
73 : KParts::BrowserExtension( parent,
name )
76 setURLDropHandlingEnabled(
true );
78 enableAction(
"cut",
false );
79 enableAction(
"copy",
false );
80 enableAction(
"paste",
false );
82 m_connectedToClipboard =
false;
85 int TDEHTMLPartBrowserExtension::xOffset()
87 return m_part->
view()->contentsX();
90 int TDEHTMLPartBrowserExtension::yOffset()
92 return m_part->
view()->contentsY();
95 void TDEHTMLPartBrowserExtension::saveState( TQDataStream &stream )
101 void TDEHTMLPartBrowserExtension::restoreState( TQDataStream &stream )
107 void TDEHTMLPartBrowserExtension::editableWidgetFocused( TQWidget *widget )
109 m_editableFormWidget = widget;
112 if ( !m_connectedToClipboard && m_editableFormWidget )
114 connect( TQApplication::clipboard(), TQ_SIGNAL( dataChanged() ),
115 this, TQ_SLOT( updateEditActions() ) );
117 if ( m_editableFormWidget->inherits(
"TQLineEdit" ) || m_editableFormWidget->inherits(
"TQTextEdit" ) )
118 connect( m_editableFormWidget, TQ_SIGNAL( selectionChanged() ),
119 this, TQ_SLOT( updateEditActions() ) );
121 m_connectedToClipboard =
true;
123 editableWidgetFocused();
126 void TDEHTMLPartBrowserExtension::editableWidgetBlurred( TQWidget * )
128 TQWidget *oldWidget = m_editableFormWidget;
130 m_editableFormWidget = 0;
133 m_part->emitSelectionChanged();
135 if ( m_connectedToClipboard )
137 disconnect( TQApplication::clipboard(), TQ_SIGNAL( dataChanged() ),
138 this, TQ_SLOT( updateEditActions() ) );
142 if ( oldWidget->inherits(
"TQLineEdit" ) || oldWidget->inherits(
"TQTextEdit" ) )
143 disconnect( oldWidget, TQ_SIGNAL( selectionChanged() ),
144 this, TQ_SLOT( updateEditActions() ) );
147 m_connectedToClipboard =
false;
149 editableWidgetBlurred();
154 if ( m_extensionProxy )
156 disconnect( m_extensionProxy, TQ_SIGNAL(
enableAction(
const char *,
bool ) ),
157 this, TQ_SLOT( extensionProxyActionEnabled(
const char *,
bool ) ) );
158 if ( m_extensionProxy->inherits(
"TDEHTMLPartBrowserExtension" ) )
160 disconnect( m_extensionProxy, TQ_SIGNAL( editableWidgetFocused() ),
161 this, TQ_SLOT( extensionProxyEditableWidgetFocused() ) );
162 disconnect( m_extensionProxy, TQ_SIGNAL( editableWidgetBlurred() ),
163 this, TQ_SLOT( extensionProxyEditableWidgetBlurred() ) );
167 m_extensionProxy = proxy;
169 if ( m_extensionProxy )
171 connect( m_extensionProxy, TQ_SIGNAL(
enableAction(
const char *,
bool ) ),
172 this, TQ_SLOT( extensionProxyActionEnabled(
const char *,
bool ) ) );
173 if ( m_extensionProxy->inherits(
"TDEHTMLPartBrowserExtension" ) )
175 connect( m_extensionProxy, TQ_SIGNAL( editableWidgetFocused() ),
176 this, TQ_SLOT( extensionProxyEditableWidgetFocused() ) );
177 connect( m_extensionProxy, TQ_SIGNAL( editableWidgetBlurred() ),
178 this, TQ_SLOT( extensionProxyEditableWidgetBlurred() ) );
181 enableAction(
"cut", m_extensionProxy->isActionEnabled(
"cut" ) );
182 enableAction(
"copy", m_extensionProxy->isActionEnabled(
"copy" ) );
183 enableAction(
"paste", m_extensionProxy->isActionEnabled(
"paste" ) );
192 void TDEHTMLPartBrowserExtension::cut()
194 if ( m_extensionProxy )
196 callExtensionProxyMethod(
"cut()" );
200 if ( !m_editableFormWidget )
203 if ( m_editableFormWidget->inherits(
"TQLineEdit" ) )
204 static_cast<TQLineEdit *
>( &(*m_editableFormWidget) )->cut();
205 else if ( m_editableFormWidget->inherits(
"TQTextEdit" ) )
206 static_cast<TQTextEdit *
>( &(*m_editableFormWidget) )->cut();
209 void TDEHTMLPartBrowserExtension::copy()
211 if ( m_extensionProxy )
213 callExtensionProxyMethod(
"copy()" );
217 kdDebug( 6050 ) <<
"************! TDEHTMLPartBrowserExtension::copy()" <<
endl;
218 if ( !m_editableFormWidget )
222 text.replace( TQChar( 0xa0 ),
' ' );
225 TQClipboard *cb = TQApplication::clipboard();
226 disconnect( cb, TQ_SIGNAL( selectionChanged() ), m_part, TQ_SLOT( slotClearSelection() ) );
227 #ifndef TQT_NO_MIMECLIPBOARD
238 TQTextDrag *textdrag =
new TQTextDrag(text, 0L);
241 if(!htmltext.isEmpty()) {
242 htmltext.replace( TQChar( 0xa0 ),
' ' );
243 TQTextDrag *htmltextdrag =
new TQTextDrag(htmltext, 0L);
244 htmltextdrag->setSubtype(
"html");
252 connect( cb, TQ_SIGNAL( selectionChanged() ), m_part, TQ_SLOT( slotClearSelection() ) );
256 if ( m_editableFormWidget->inherits(
"TQLineEdit" ) )
257 static_cast<TQLineEdit *
>( &(*m_editableFormWidget) )->copy();
258 else if ( m_editableFormWidget->inherits(
"TQTextEdit" ) )
259 static_cast<TQTextEdit *
>( &(*m_editableFormWidget) )->copy();
263 void TDEHTMLPartBrowserExtension::searchProvider()
266 const TQString searchProviderPrefix = TQString( sender()->
name() ).mid( 14 );
270 data.setData( searchProviderPrefix + m_part->
selectedText() );
271 list <<
"kurisearchfilter" <<
"kuriikwsfilter";
273 if( !KURIFilter::self()->filterURI(data, list) )
275 KDesktopFile file(
"searchproviders/google.desktop",
true,
"services");
277 TQUrl::encode(encodedSearchTerm);
278 data.setData(file.readEntry(
"Query").replace(
"\\{@}", encodedSearchTerm));
287 void TDEHTMLPartBrowserExtension::openSelection()
295 void TDEHTMLPartBrowserExtension::paste()
297 if ( m_extensionProxy )
299 callExtensionProxyMethod(
"paste()" );
303 if ( !m_editableFormWidget )
306 if ( m_editableFormWidget->inherits(
"TQLineEdit" ) )
307 static_cast<TQLineEdit *
>( &(*m_editableFormWidget) )->paste();
308 else if ( m_editableFormWidget->inherits(
"TQTextEdit" ) )
309 static_cast<TQTextEdit *
>( &(*m_editableFormWidget) )->paste();
312 void TDEHTMLPartBrowserExtension::callExtensionProxyMethod(
const char *method )
314 if ( !m_extensionProxy )
317 int slot = m_extensionProxy->metaObject()->findSlot( method );
322 m_extensionProxy->tqt_invoke( slot, o );
325 void TDEHTMLPartBrowserExtension::updateEditActions()
327 if ( !m_editableFormWidget )
336 #ifndef TQT_NO_MIMECLIPBOARD
337 TQMimeSource *data = TQApplication::clipboard()->data();
338 enableAction(
"paste", data->provides(
"text/plain" ) );
340 TQString data=TQApplication::clipboard()->text();
343 bool hasSelection =
false;
345 if( m_editableFormWidget) {
346 if ( ::tqt_cast<TQLineEdit*>(m_editableFormWidget))
347 hasSelection =
static_cast<TQLineEdit *
>( &(*m_editableFormWidget) )->hasSelectedText();
348 else if(::tqt_cast<TQTextEdit*>(m_editableFormWidget))
349 hasSelection =
static_cast<TQTextEdit *
>( &(*m_editableFormWidget) )->hasSelectedText();
356 void TDEHTMLPartBrowserExtension::extensionProxyEditableWidgetFocused() {
357 editableWidgetFocused();
360 void TDEHTMLPartBrowserExtension::extensionProxyEditableWidgetBlurred() {
361 editableWidgetBlurred();
364 void TDEHTMLPartBrowserExtension::extensionProxyActionEnabled(
const char *action,
bool enable )
367 if ( strcmp( action,
"cut" ) == 0 ||
368 strcmp( action,
"copy" ) == 0 ||
369 strcmp( action,
"paste" ) == 0 ) {
374 void TDEHTMLPartBrowserExtension::reparseConfiguration()
376 m_part->reparseConfiguration();
379 void TDEHTMLPartBrowserExtension::print()
384 void TDEHTMLPartBrowserExtension::disableScrolling()
386 TQScrollView *scrollView = m_part->
view();
389 scrollView->setHScrollBarMode(TQScrollView::AlwaysOff);
393 class TDEHTMLPopupGUIClient::TDEHTMLPopupGUIClientPrivate
400 TQString m_suggestedFilename;
404 TDEHTMLPopupGUIClient::TDEHTMLPopupGUIClient(
TDEHTMLPart *tdehtml,
const TQString &doc,
const KURL &url )
405 : TQObject( tdehtml )
407 d =
new TDEHTMLPopupGUIClientPrivate;
408 d->m_tdehtml = tdehtml;
410 bool isImage =
false;
417 if ( !e.
isNull() && (e.elementId() == ID_IMG ||
420 if (e.elementId() == ID_IMG) {
421 DOM::HTMLImageElementImpl *ie =
static_cast<DOM::HTMLImageElementImpl*
>(e.handle());
422 tdehtml::RenderImage *ri =
dynamic_cast<tdehtml::RenderImage*
>(ie->renderer());
423 if (ri && ri->contentObject()) {
424 d->m_suggestedFilename =
static_cast<tdehtml::CachedImage*
>(ri->contentObject())->suggestedFilename();
433 copyAction->
setText(i18n(
"&Copy Text"));
434 copyAction->
setEnabled(d->m_tdehtml->browserExtension()->isActionEnabled(
"copy" ));
440 config.setGroup(
"General");
441 const TQString defaultEngine = config.readEntry(
"DefaultSearchEngine",
"google");
442 const char keywordDelimiter = config.readNumEntry(
"KeywordDelimiter",
':');
446 selectedText.replace(
"&",
"&&");
447 if ( selectedText.length()>18 ) {
448 selectedText.truncate(15);
453 KService::Ptr service = KService::serviceByDesktopPath(TQString(
"searchproviders/%1.desktop").arg(defaultEngine));
459 data.setData( TQString(
"some keyword") );
460 list <<
"kurisearchfilter" <<
"kuriikwsfilter";
463 if ( KURIFilter::self()->filterURI(data, list) )
465 TQString iconPath =
locate(
"cache", KMimeType::favIconForURL(data.uri()) +
".png");
466 if ( iconPath.isEmpty() )
467 icon = SmallIcon(
"edit-find");
469 icon = TQPixmap( iconPath );
470 name = service->name();
474 icon = SmallIcon(
"google");
479 new TDEAction( i18n(
"Search for '%1' with %2" ).arg( selectedText, name ), icon, 0, d->m_tdehtml->browserExtension(),
480 TQ_SLOT( searchProvider() ), actionCollection(),
"searchProvider" );
483 TQStringList favoriteEngines;
484 favoriteEngines <<
"google" <<
"google_groups" <<
"google_news" <<
"webster" <<
"dmoz" <<
"wikipedia";
485 favoriteEngines = config.readListEntry(
"FavoriteSearchEngines", favoriteEngines);
487 if ( !favoriteEngines.isEmpty()) {
488 TDEActionMenu* providerList =
new TDEActionMenu( i18n(
"Search for '%1' with" ).arg( selectedText ), actionCollection(),
"searchProviderList" );
490 TQStringList::ConstIterator it = favoriteEngines.begin();
491 for ( ; it != favoriteEngines.end(); ++it ) {
492 if (*it==defaultEngine)
494 service = KService::serviceByDesktopPath(TQString(
"searchproviders/%1.desktop").arg(*it));
497 const TQString searchProviderPrefix = *(service->property(
"Keys").toStringList().begin()) + keywordDelimiter;
498 data.setData( searchProviderPrefix +
"some keyword" );
500 if ( KURIFilter::self()->filterURI(data, list) )
502 TQString iconPath =
locate(
"cache", KMimeType::favIconForURL(data.uri()) +
".png");
503 if ( iconPath.isEmpty() )
504 icon = SmallIcon(
"edit-find");
506 icon = TQPixmap( iconPath );
507 name = service->name();
509 providerList->insert(
new TDEAction( name, icon, 0, d->m_tdehtml->browserExtension(),
510 TQ_SLOT( searchProvider() ), actionCollection(), TQString(
"searchProvider" + searchProviderPrefix ).latin1() ) );
516 if ( selectedText.contains(
"://") &&
KURL(selectedText).isValid() )
517 new TDEAction( i18n(
"Open '%1'" ).arg( selectedText ),
"window-new", 0,
518 d->m_tdehtml->browserExtension(), TQ_SLOT( openSelection() ), actionCollection(),
"openSelection" );
520 else if ( url.
isEmpty() && !isImage )
524 new TDEAction( i18n(
"Stop Animations" ), 0,
this, TQ_SLOT( slotStopAnimations() ),
525 actionCollection(),
"stopanimations" );
532 new TDEAction( i18n(
"Copy Email Address" ), 0,
this, TQ_SLOT( slotCopyLinkLocation() ),
533 actionCollection(),
"copylinklocation" );
537 new TDEAction( i18n(
"&Save Link As..." ), 0,
this, TQ_SLOT( slotSaveLinkAs() ),
538 actionCollection(),
"savelinkas" );
539 new TDEAction( i18n(
"Copy &Link Address" ), 0,
this, TQ_SLOT( slotCopyLinkLocation() ),
540 actionCollection(),
"copylinklocation" );
549 new TDEAction( i18n(
"Open in New &Window" ),
"window-new", 0,
this, TQ_SLOT( slotFrameInWindow() ),
550 actionCollection(),
"frameinwindow" );
551 new TDEAction( i18n(
"Open in &This Window" ), 0,
this, TQ_SLOT( slotFrameInTop() ),
552 actionCollection(),
"frameintop" );
553 new TDEAction( i18n(
"Open in &New Tab" ),
"tab_new", 0,
this, TQ_SLOT( slotFrameInTab() ),
554 actionCollection(),
"frameintab" );
555 new TDEAction( i18n(
"Reload Frame" ), 0,
this, TQ_SLOT( slotReloadFrame() ),
556 actionCollection(),
"reloadframe" );
558 if ( TDEHTMLFactory::defaultHTMLSettings()->isAdFilterEnabled() ) {
559 if ( tdehtml->d->m_frame->m_type == tdehtml::ChildFrame::IFrame )
560 new TDEAction( i18n(
"Block IFrame..." ), 0,
this, TQ_SLOT( slotBlockIFrame() ), actionCollection(),
"blockiframe" );
563 new TDEAction( i18n(
"View Frame Source" ), 0, d->m_tdehtml, TQ_SLOT( slotViewDocumentSource() ),
564 actionCollection(),
"viewFrameSource" );
565 new TDEAction( i18n(
"View Frame Information" ), 0, d->m_tdehtml, TQ_SLOT( slotViewPageInfo() ), actionCollection(),
"viewFrameInfo" );
569 new TDEAction( i18n(
"Print Frame..." ),
"frameprint", 0, d->m_tdehtml->browserExtension(), TQ_SLOT(
print() ), actionCollection(),
"printFrame" );
570 new TDEAction( i18n(
"Save &Frame As..." ), 0, d->m_tdehtml, TQ_SLOT( slotSaveFrame() ), actionCollection(),
"saveFrame" );
578 }
else if (isImage || !url.
isEmpty()) {
581 new TDEAction( i18n(
"Stop Animations" ), 0,
this, TQ_SLOT( slotStopAnimations() ),
582 actionCollection(),
"stopanimations" );
587 if ( e.elementId() == ID_IMG ) {
589 DOM::HTMLImageElementImpl *imageimpl =
static_cast<DOM::HTMLImageElementImpl *
>( e.handle() );
593 if(imageimpl->complete()) {
594 d->m_pixmap = imageimpl->currentPixmap();
600 new TDEAction( i18n(
"Save Image As..." ), 0,
this, TQ_SLOT( slotSaveImageAs() ),
601 actionCollection(),
"saveimageas" );
602 new TDEAction( i18n(
"Send Image..." ), 0,
this, TQ_SLOT( slotSendImage() ),
603 actionCollection(),
"sendimage" );
606 #ifndef TQT_NO_MIMECLIPBOARD
607 (
new TDEAction( i18n(
"Copy Image" ), 0,
this, TQ_SLOT( slotCopyImage() ),
608 actionCollection(),
"copyimage" ))->setEnabled(!d->m_pixmap.isNull());
611 if(d->m_pixmap.isNull()) {
612 new TDEAction( i18n(
"Copy Image Location" ), 0,
this, TQ_SLOT( slotCopyImageLocation() ),
613 actionCollection(),
"copyimagelocation" );
617 new TDEAction( i18n(
"View Image (%1)" ).arg(d->m_suggestedFilename.isEmpty() ?
name.replace(
"&",
"&&") : d->m_suggestedFilename.replace(
"&",
"&&")), 0,
this, TQ_SLOT( slotViewImage() ),
618 actionCollection(),
"viewimage" );
620 if (TDEHTMLFactory::defaultHTMLSettings()->isAdFilterEnabled())
622 new TDEAction( i18n(
"Block Image..." ), 0,
this, TQ_SLOT( slotBlockImage() ),
623 actionCollection(),
"blockimage" );
625 if (!d->m_imageURL.host().isEmpty() &&
626 !d->m_imageURL.protocol().isEmpty())
628 new TDEAction( i18n(
"Block Images From %1" ).arg(d->m_imageURL.host()), 0,
this, TQ_SLOT( slotBlockHost() ),
629 actionCollection(),
"blockhost" );
635 setDOMDocument( TQDomDocument(),
true );
637 TQDomElement menu = domDocument().documentElement().namedItem(
"Menu" ).toElement();
639 if ( actionCollection()->count() > 0 )
640 menu.insertBefore( domDocument().createElement(
"separator" ), menu.firstChild() );
643 TDEHTMLPopupGUIClient::~TDEHTMLPopupGUIClient()
648 void TDEHTMLPopupGUIClient::slotSaveLinkAs()
650 TDEIO::MetaData metaData;
651 metaData[
"referrer"] = d->m_tdehtml->referrer();
652 saveURL( d->m_tdehtml->widget(), i18n(
"Save Link As" ), d->m_url, metaData );
655 void TDEHTMLPopupGUIClient::slotSendImage()
658 urls.append( d->m_imageURL.url());
659 TQString subject = d->m_imageURL.url();
660 kapp->invokeMailer(TQString::null, TQString::null, TQString::null, subject,
668 void TDEHTMLPopupGUIClient::slotSaveImageAs()
670 TDEIO::MetaData metaData;
671 metaData[
"referrer"] = d->m_tdehtml->referrer();
672 saveURL( d->m_tdehtml->widget(), i18n(
"Save Image As" ), d->m_imageURL, metaData, TQString::null, 0, d->m_suggestedFilename );
675 void TDEHTMLPopupGUIClient::slotBlockHost()
677 TQString
name=d->m_imageURL.protocol()+
"://"+d->m_imageURL.host()+
"/*";
678 TDEHTMLFactory::defaultHTMLSettings()->addAdFilter( name );
679 d->m_tdehtml->reparseConfiguration();
682 void TDEHTMLPopupGUIClient::slotBlockImage()
687 i18n(
"Enter the URL:"),
691 TDEHTMLFactory::defaultHTMLSettings()->addAdFilter( url );
692 d->m_tdehtml->reparseConfiguration();
696 void TDEHTMLPopupGUIClient::slotBlockIFrame()
700 i18n(
"Enter the URL:"),
701 d->m_tdehtml->url().url(),
704 TDEHTMLFactory::defaultHTMLSettings()->addAdFilter( url );
705 d->m_tdehtml->reparseConfiguration();
709 void TDEHTMLPopupGUIClient::slotCopyLinkLocation()
711 KURL safeURL(d->m_url);
712 safeURL.setPass(TQString::null);
713 #ifndef TQT_NO_MIMECLIPBOARD
716 lst.append( safeURL );
717 TQApplication::clipboard()->setData(
new KURLDrag( lst ), TQClipboard::Clipboard );
718 TQApplication::clipboard()->setData(
new KURLDrag( lst ), TQClipboard::Selection );
720 TQApplication::clipboard()->setText( safeURL.url() );
724 void TDEHTMLPopupGUIClient::slotStopAnimations()
726 d->m_tdehtml->stopAnimations();
729 void TDEHTMLPopupGUIClient::slotCopyImage()
731 #ifndef TQT_NO_MIMECLIPBOARD
732 KURL safeURL(d->m_imageURL);
733 safeURL.setPass(TQString::null);
736 lst.append( safeURL );
739 drag->
addDragObject(
new TQImageDrag(d->m_pixmap.convertToImage()) );
743 TQApplication::clipboard()->setData( drag, TQClipboard::Clipboard );
744 TQApplication::clipboard()->setData(
new KURLDrag(lst), TQClipboard::Selection );
746 kdDebug() <<
"slotCopyImage called when the clipboard does not support this. This should not be possible." <<
endl;
750 void TDEHTMLPopupGUIClient::slotCopyImageLocation()
752 KURL safeURL(d->m_imageURL);
753 safeURL.setPass(TQString::null);
754 #ifndef TQT_NO_MIMECLIPBOARD
757 lst.append( safeURL );
758 TQApplication::clipboard()->setData(
new KURLDrag( lst ), TQClipboard::Clipboard );
759 TQApplication::clipboard()->setData(
new KURLDrag( lst ), TQClipboard::Selection );
761 TQApplication::clipboard()->setText( safeURL.url() );
765 void TDEHTMLPopupGUIClient::slotViewImage()
767 d->m_tdehtml->browserExtension()->createNewWindow(d->m_imageURL);
770 void TDEHTMLPopupGUIClient::slotReloadFrame()
774 args.
metaData()[
"referrer"] = d->m_tdehtml->pageReferrer();
776 d->m_tdehtml->closeURL();
777 d->m_tdehtml->browserExtension()->setURLArgs( args );
778 d->m_tdehtml->openURL( d->m_tdehtml->url() );
781 void TDEHTMLPopupGUIClient::slotFrameInWindow()
784 args.
metaData()[
"referrer"] = d->m_tdehtml->pageReferrer();
785 args.
metaData()[
"forcenewwindow"] =
"true";
786 emit d->m_tdehtml->browserExtension()->createNewWindow( d->m_tdehtml->url(), args );
789 void TDEHTMLPopupGUIClient::slotFrameInTop()
792 args.
metaData()[
"referrer"] = d->m_tdehtml->pageReferrer();
794 emit d->m_tdehtml->browserExtension()->openURLRequest( d->m_tdehtml->url(), args );
797 void TDEHTMLPopupGUIClient::slotFrameInTab()
800 args.
metaData()[
"referrer"] = d->m_tdehtml->pageReferrer();
802 emit d->m_tdehtml->browserExtension()->createNewWindow( d->m_tdehtml->url(), args );
805 void TDEHTMLPopupGUIClient::saveURL( TQWidget *parent,
const TQString &caption,
807 const TQMap<TQString, TQString> &metadata,
808 const TQString &filter,
long cacheId,
809 const TQString & suggestedFilename )
811 TQString
name = TQString::fromLatin1(
"index.html" );
812 if ( !suggestedFilename.isEmpty() )
813 name = suggestedFilename;
814 else if ( !url.
fileName().isEmpty() )
820 query = KMessageBox::Yes;
821 destURL = KFileDialog::getSaveURL( name, filter, parent, caption );
824 TQFileInfo info( destURL.
path() );
825 if( info.exists() ) {
827 query =
KMessageBox::warningContinueCancel( parent, i18n(
"A file named \"%1\" already exists. " "Are you sure you want to overwrite it?" ).arg( info.fileName() ), i18n(
"Overwrite File?" ), i18n(
"Overwrite" ) );
830 }
while ( query == KMessageBox::Cancel );
833 saveURL(url, destURL, metadata, cacheId);
836 void TDEHTMLPopupGUIClient::saveURL(
const KURL &url,
const KURL &destURL,
837 const TQMap<TQString, TQString> &metadata,
848 if (destFile.status() == 0)
858 if (destFile.
status() == 0)
864 TDEIO::file_move(url2, destURL, -1,
true );
875 bool downloadViaKIO =
true;
878 TDEConfig cfg(
"konquerorrc",
false,
false);
879 cfg.setGroup(
"HTML Settings");
880 TQString downloadManger = cfg.readPathEntry(
"DownloadManager");
881 if (!downloadManger.isEmpty())
884 kdDebug(1000) <<
"Using: "<<downloadManger <<
" as Download Manager" <<
endl;
888 TQString errMsg=i18n(
"The Download Manager (%1) could not be found in your $PATH ").arg(downloadManger);
889 TQString errMsgEx= i18n(
"Try to reinstall it \n\nThe integration with Konqueror will be disabled!");
891 cfg.writePathEntry(
"DownloadManager",TQString::null);
896 downloadViaKIO =
false;
897 KURL cleanDest = destURL;
898 cleanDest.
setPass( TQString::null );
902 KRun::runCommand(cmd);
907 if ( downloadViaKIO )
909 TDEIO::Job *job = TDEIO::file_copy( url, destURL, -1,
true );
910 job->setMetaData(metadata);
911 job->addMetaData(
"MaxCacheSize",
"0");
912 job->addMetaData(
"cache",
"cache");
913 job->setAutoErrorHandlingEnabled(
true );
919 TDEHTMLPartBrowserHostExtension::TDEHTMLPartBrowserHostExtension(
TDEHTMLPart *part )
920 : KParts::BrowserHostExtension( part )
925 TDEHTMLPartBrowserHostExtension::~TDEHTMLPartBrowserHostExtension()
929 TQStringList TDEHTMLPartBrowserHostExtension::frameNames()
const
934 const TQPtrList<KParts::ReadOnlyPart> TDEHTMLPartBrowserHostExtension::frames()
const
936 return m_part->frames();
939 bool TDEHTMLPartBrowserHostExtension::openURLInFrame(
const KURL &url,
const KParts::URLArgs &urlArgs )
941 return m_part->openURLInFrame( url, urlArgs );
944 void TDEHTMLPartBrowserHostExtension::virtual_hook(
int id,
void *data )
946 if (
id == VIRTUAL_FIND_FRAME_PARENT)
948 FindFrameParentParams *param =
static_cast<FindFrameParentParams*
>(data);
951 param->parent = parentPart->browserHostExtension();
954 BrowserHostExtension::virtual_hook(
id, data );
959 extern const int TDE_NO_EXPORT fastZoomSizes[];
960 extern const int TDE_NO_EXPORT fastZoomSizeCount;
963 TDEHTMLZoomFactorAction::TDEHTMLZoomFactorAction(
TDEHTMLPart *part,
bool direction,
const TQString &text,
const TQString &icon,
const TQObject *receiver,
const char *slot, TQObject *parent,
const char *name )
966 init(part, direction);
969 TDEHTMLZoomFactorAction::TDEHTMLZoomFactorAction(
TDEHTMLPart *part,
bool direction,
const TQString &text,
const TQString &icon,
const TDEShortcut &cut,
const TQObject *receiver,
const char *slot, TQObject *parent,
const char *name )
972 init(part, direction);
975 void TDEHTMLZoomFactorAction::init(
TDEHTMLPart *part,
bool direction)
977 m_direction = direction;
980 m_popup =
new TQPopupMenu;
982 m_popup->insertItem( i18n(
"Default Font Size (100%)" ) );
984 int m = m_direction ? 1 : -1;
985 int ofs = fastZoomSizeCount / 2;
988 for (
int i = m; i != m*(ofs+1); i += m )
991 TQString numStr = TQString::number( num );
992 if ( num > 0 ) numStr.prepend(
'+' );
995 m_popup->insertItem( i18n(
"%1%" ).arg( fastZoomSizes[ofs + i] ) );
998 connect( m_popup, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( slotActivated(
int ) ) );
1001 TDEHTMLZoomFactorAction::~TDEHTMLZoomFactorAction()
1006 int TDEHTMLZoomFactorAction::plug( TQWidget *w,
int index )
1009 if ( containerId == -1 || !w->inherits(
"TDEToolBar" ) )
1020 void TDEHTMLZoomFactorAction::slotActivated(
int id )
1022 int idx = m_popup->indexOf(
id );
1025 m_part->setZoomFactor(100);
1027 m_part->setZoomFactor(fastZoomSizes[fastZoomSizeCount/2 + (m_direction ? 1 : -1)*idx]);
1030 #include "tdehtml_ext.moc"
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
bool isNull() const
tests if this Node is 0.
static void detailedSorry(TQWidget *parent, const TQString &text, const TQString &details, const TQString &caption=TQString::null, int options=Notify)
static int warningContinueCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
void addDragObject(TQDragObject *dragObject)
void enableAction(const char *name, bool enabled)
void openURLRequest(const KURL &url, const KParts::URLArgs &args=KParts::URLArgs())
static TQString csqueeze(const TQString &str, uint maxlen=40)
TQDataStream * dataStream()
void setPath(const TQString &path)
void setPass(const TQString &_txt)
TQString protocol() const
TQString fileName(bool _ignore_trailing_slash_in_path=true) const
TQString url(int _trailing=0, int encoding_hint=0) const
virtual TDEInstance * instance() const
virtual TDEActionCollection * actionCollection() const
virtual TDEAction * action(int index) const
virtual void setEnabled(bool enable)
virtual void setText(const TQString &text)
virtual int plug(TQWidget *widget, int index=-1)
void saveData(long id, TQDataStream *str)
Save the data of cache entry id to the datastream str.
static TDEHTMLPageCache * self()
static "constructor".
This class is tdehtml's main class.
TQStringList frameNames() const
Returns a list of names of all frame (including iframe) objects of the current document.
TDEHTMLPart * findFrameParent(KParts::ReadOnlyPart *callingPart, const TQString &f, tdehtml::ChildFrame **childFrame=0)
Recursively finds the part containing the frame with name f and checks if it is accessible by calling...
KParts::BrowserExtension * browserExtension() const
Returns a pointer to the KParts::BrowserExtension.
TDEHTMLView * view() const
Returns a pointer to the HTML document's view.
virtual void saveState(TQDataStream &stream)
Saves the TDEHTMLPart's complete state (including child frame objects) to the provided TQDataStream.
bool hasSelection() const
Has the user selected anything?
TQString selectedTextAsHTML() const
Return the text the user has marked.
virtual TQString selectedText() const
Returns the text the user has marked.
DOM::Node nodeUnderMouse() const
Returns the Node currently under the mouse.
TDEHTMLPart * parentPart()
Returns a pointer to the parent TDEHTMLPart if the part is a frame in an HTML frameset.
virtual void restoreState(TQDataStream &stream)
Restores the TDEHTMLPart's previously saved state (including child frame objects) from the provided T...
virtual void setVScrollBarMode(ScrollBarMode mode)
Sets verticals scrollbar mode.
void print()
Prints the HTML document.
static TQString quote(const TQString &arg)
static TQString findExe(const TQString &appname, const TQString &pathstr=TQString::null, bool ignoreExecBit=false)
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
TQString locate(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())
TDEAction * copy(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const TDEShortcut & copy()
TQString name(StdAccel id)
const TDEShortcut & cut()
const TDEShortcut & print()
void setNewTab(bool newTab)
TQMap< TQString, TQString > & metaData()