⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evachatview.cpp

📁 linux下的eva源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			if ( iconPath.isEmpty() )				icon = SmallIcon("find");			else				icon = QPixmap( iconPath );				name = service->name();		} else {			icon = SmallIcon("google");			name = "Google";		}				action = new KAction( i18n( "Search '%1' at %2" ).arg( selectedText ).arg( name ), icon, 0, this,				SLOT( searchProvider() ), actionCollection(), "searchProvider" );		action->plug(menu);		// favorite search providers		QStringList favoriteEngines;		favoriteEngines = config.readListEntry("FavoriteSearchEngines"); // for KDE 3.2 API compatibility		if(favoriteEngines.isEmpty())			favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia";				if ( !favoriteEngines.isEmpty()) {			KActionMenu* providerList = new KActionMenu( i18n( "Search '%1' At" ).arg( selectedText ), actionCollection(), "searchProviderList" );						QStringList::ConstIterator it = favoriteEngines.begin();			for ( ; it != favoriteEngines.end(); ++it ) {				if (*it==defaultEngine)					continue;				service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(*it));				if (!service)					continue;				const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + keywordDelimiter;				data.setData( searchProviderPrefix + "some keyword" );							if ( KURIFilter::self()->filterURI(data, list) ) {					QString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");					if ( iconPath.isEmpty() )						icon = SmallIcon("find");					else						icon = QPixmap( iconPath );					name = service->name();								providerList->insert( new KAction( name, icon, 0, this,							SLOT( searchProvider() ), actionCollection(), QString( "searchProvider" + searchProviderPrefix ).latin1() ) );				}			}			providerList->plug(menu);		}		if ( selectedText.contains("://") && KURL(selectedText).isValid() ) {			action = new KAction( i18n( "Open '%1'" ).arg( selectedText ), "window_new", 0,							this, SLOT( openSelection() ), actionCollection(), "openSelection" );			action->plug(menu);		}	}	if ( !url.isEmpty() ) {		if (url.protocol() == "mailto")	{			action = new KAction( i18n( "Copy Email Address" ), 0, this, SLOT( slotCopyLinkLocation() ),					actionCollection(), "copylinklocation" );			action->plug(menu);		} else {			action = new KAction( i18n( "Copy &Link Address" ), 0, this, SLOT( slotCopyLinkLocation() ),					actionCollection(), "copylinklocation" );			action->plug(menu);		}	}	if (isImage)	{#ifndef QT_NO_MIMECLIPBOARD		action = (new KAction( i18n( "Copy Image" ), 0, this, SLOT( slotCopyImage() ),				actionCollection(), "copyimage" ));		action->plug(menu);#endif		action = new KAction( i18n( "Save Image As..." ), 0, this, SLOT( slotSaveImageAs() ),				actionCollection(), "saveimageas" );		action->plug(menu);		action = new KAction( i18n( "Save As Custom Smiley"), 0, this, SLOT( slotSaveAsCustomSmiley() ),				actionCollection(), "saveascustomsmiley" );		action->plug(menu);	}		if(menu->count()) menu->popup(point);}void EvaChatView::copy( ){	if(hasSelection()){		QString text = selectedText();		text.replace(QChar(0xa0), ' ');		QApplication::clipboard()->setText( text, QClipboard::Clipboard );		QApplication::clipboard()->setText( text, QClipboard::Selection );	}}void EvaChatView::searchProvider(){	// action name is of form "previewProvider[<searchproviderprefix>:]"	const QString searchProviderPrefix = QString( sender()->name() ).mid( 14 );		KURIFilterData data;	QStringList list;	data.setData( searchProviderPrefix + this->selectedText() );	list << "kurisearchfilter" << "kuriikwsfilter";		if( !KURIFilter::self()->filterURI(data, list) )	{	KDesktopFile file("searchproviders/google.desktop", true, "services");	data.setData(file.readEntry("Query").replace("\\{@}", this->selectedText()));	}		KParts::URLArgs args;	args.frameName = "_blank";		emit slotLinkClicked( data.uri(), args );}void EvaChatView::openSelection(){	KParts::URLArgs args;	args.frameName = "_blank";		emit slotLinkClicked( d->m_url, args );}void EvaChatView::slotCopyLinkLocation(){	KURL safeURL(d->m_url);	safeURL.setPass(QString::null);#ifndef QT_NO_MIMECLIPBOARD	// Set it in both the mouse selection and in the clipboard	KURL::List lst;	lst.append( safeURL );	QApplication::clipboard()->setData( new KURLDrag( lst ), QClipboard::Clipboard );	QApplication::clipboard()->setData( new KURLDrag( lst ), QClipboard::Selection );#else	QApplication::clipboard()->setText( safeURL.url() ); #endif}void EvaChatView::slotCopyImage(){#ifndef QT_NO_MIMECLIPBOARD	KURL safeURL(d->m_imageURL);	safeURL.setPass(QString::null);		KURL::List lst;	lst.append( safeURL );	KMultipleDrag *drag = new KMultipleDrag(view(), "Image");	drag->addDragObject( new QImageDrag(d->m_imageURL.path()) );	drag->addDragObject( new KURLDrag(lst, view(), "Image URL") );		// Set it in both the mouse selection and in the clipboard	QApplication::clipboard()->setData( drag, QClipboard::Clipboard );	QApplication::clipboard()->setData( new KURLDrag(lst), QClipboard::Selection );#else	// do nothing#endif}void EvaChatView::slotSaveImageAs(){	QString name = QString::fromLatin1("index.html");;	if ( !d->m_suggestedFilename.isEmpty() )		name = d->m_suggestedFilename;	else if ( !d->m_imageURL.fileName().isEmpty() )		name = d->m_imageURL.fileName();	KURL destURL;	int query;	do {		query = KMessageBox::Yes;		destURL = KFileDialog::getSaveURL( QDir::homeDirPath() + "/" + name, QString::null, 0, i18n( "Save Image As" ) );		if( destURL.isLocalFile() ) {			QFileInfo info( destURL.path() );			if( info.exists() ) {				// TODO: use KIO::RenameDlg (shows more information)				query = KMessageBox::warningContinueCancel( 0, i18n( "A file named \"%1\" already exists. " "Are you sure you want to overwrite it?" ).arg( info.fileName() ), i18n( "Overwrite File?" ), i18n( "Overwrite" ) );			}		}	} while ( query == KMessageBox::Cancel );		if ( destURL.isValid() )		KIO::file_copy(d->m_imageURL, destURL, -1, true /*overwrite*/);}void EvaChatView::slotSaveAsCustomSmiley(){	emit saveAsCustomSmiley(d->m_imageURL.path());}// it seems this method doesn't do the jobvoid EvaChatView::startDrag( ){	QDragObject *d = new QTextDrag(selectedText(), view());	d->dragCopy();}// void EvaChatView::slotSelectionChanged( )// {// //	copyAction->setEnabled( hasSelection() );// }void EvaChatView::showInfomation( const QString & info ){	QString picPath = "<img src = \"" + EvaMain::images->getIconFullPath("MSG_INFO") + "\">";	QString msg = wrapFontAttributes(Qt::gray, 9, false, false, false, info);	updateContents("&nbsp;" + picPath + "&nbsp;" + msg );	showContents();}void EvaChatView::showFileNotification( const QString & who, const QString & filename, 			const int size, const unsigned int session, const bool isSend ){	QString strSession = QString::number(session);	QString picPath = "<img src = \"" + EvaMain::images->getIconFullPath("MSG_INFO") + "\">";	QString acceptLink = "<a href=\""+ protocolAccept + "_" + strSession + "\">" + i18n("Accept") + "</a>";	QString saveAsLink = "<a href=\""+ protocolSaveAs + "_" + strSession + "\">" + i18n("Save As") + "</a>";        QString rejectLink = "<a href=\""+ protocolCancel + "_" + strSession + "\">" + i18n("Reject") + "</a>";	QString cancelLink = "<a href=\""+ protocolCancel + "_" + strSession + "\">" + i18n("Cancel") + "</a>";	QString fileSize = (size<0x400)?(QString::number(size) + "B"):			((size<0x100000)?(QString::number(size/0x400) + "KB") :			((size<0x40000000)?(QString::number(size/0x100000) + "MB"):			(QString::number(size/0x40000000) + "GB") ) );	QString fileInfo = filename + "(" + fileSize + ")";        QString txt;	if(isSend){		txt = i18n("Waiting for %1 accepting file \"%2\". Please wait or %3.")				.arg(who).arg(fileInfo).arg(cancelLink);	}else{		txt = i18n("%1 wants to send you a file \"%2\", you can %3, %4 or %5.")				.arg(who).arg(fileInfo).arg(acceptLink).arg(saveAsLink).arg(rejectLink);	}	QString msg = wrapFontAttributes(Qt::gray, 9, false, false, false, txt);	updateContents("&nbsp;" + picPath + "&nbsp;" + msg );	showContents();}void EvaChatView::updateContents( const QString & contents ){	QString newMsg = contents;	newMsg.replace("&nbsp;", "&nbsp; ");	buffer += (newMsg + "<br>");}void EvaChatView::showContents(){	bool needScroll =  ( view()->contentsHeight() == (view()->contentsY() +view()->visibleHeight()) );	begin();	write(buffer);	write("</body>");	end();	if(needScroll){		QTimer::singleShot(SCROLL_DELAY, this, SLOT(slotScrollToBottom()));	}}void EvaChatView::askResumeMode( const QString filename, const unsigned int session ){	QString strSession = QString::number(session);	QString picPath = "<img src = \"" + EvaMain::images->getIconFullPath("MSG_INFO") + "\">";	QString resumeLink = "<a href=\""+ protocolResume + "_" + strSession + "\">" + 			i18n("resume") + "</a>";	QString restartLink = "<a href=\""+ protocolNewOne + "_" + strSession + "\">" + 			i18n("start") + "</a>";	QString txt = i18n("Cached information of \"%1\" has been found, you can %2 the last download or ignore the last cached download information and %3 a new download.").arg(filename).arg(resumeLink).arg(restartLink);	QString msg = wrapFontAttributes(Qt::gray, 9, false, false, false, txt);	updateContents("&nbsp;" + picPath + "&nbsp;" + msg );	showContents();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -