#include <kkeydialog.h>
#include <kaccel.h>
#include <kio/netaccess.h>
+#include <kuserprofile.h>
#include <kfiledialog.h>
#include <kconfig.h>
#include <kurl.h>
actionCollection(),
"threadtab_closetab" );
new KAction( i18n( "&Reload subject list"),
- KStdAccel::reload(),
+ KShortcut(Qt::CTRL | Qt::Key_F5),
m_subjectTab,
SLOT( reloadSubjectList() ),
actionCollection(),
m_boardListAction->setChecked( FALSE );
}
-void KitaMainWindow::slotOpenURLRequest( const KURL& url, const KParts::URLArgs& )
+void KitaMainWindow::slotOpenURLRequest( const KURL& url, const KParts::URLArgs& args )
{
+ kdDebug() << QString( "Requested OpenURL: \"%1\"" ).arg( url.url() ) << endl;
+ kdDebug() << QString( "content type: \"%1\"" ).arg( args.contentType() ) << endl;
+ kdDebug() << QString( "service type: \"%1\"" ).arg( args.serviceType ) << endl;
+ kdDebug() << QString( "NewTab: %1, reload: %2" )
+ .arg( args.newTab() ? "yes" : "no" )
+ .arg( args.reload ? "yes" : "no" ) << endl;
+ QString mimetype = KIO::NetAccess::mimetype( url, this );
+ kdDebug() << QString( "queried MIME type: \"%1\"" ).arg( mimetype ) << endl;
+ if ( mimetype.startsWith( "image/" ) ) {
+ KService::Ptr service = KServiceTypeProfile::preferredService( mimetype, "KParts/ReadOnlyPart" );
+ if ( service ) {
+ QString libName = QFile::encodeName( service->library() );
+ m_threadTab->showAlternativeView( url, libName, mimetype );
+ return;
+ }
+ }
QRegExp regexp( "http://([^/]*)/([^/]*)/dat/(.*)\\.dat" );
if ( regexp.search( url.url() ) == -1 ) {
new KRun( url );
}
}
-void KitaMainWindow::switchSubjectView( const QString& datURL, bool newTab)
+void KitaMainWindow::switchSubjectView( const QString&, bool )
{
if ( m_subjectListAction->isChecked() )
m_subjectDock->makeDockVisible();
}
-void KitaMainWindow::switchThreadView( const QString& datURL, bool newtab )
+void KitaMainWindow::switchThreadView( const QString&, bool )
{
m_mainDock->makeDockVisible();
}
: QTabWidget( parent, name, f )
{
setTabBar( new KitaThreadTabBar( this ) );
- connect( tabBar(), SIGNAL( deleteMenuSelected( KitaThreadView* ) ),
- SLOT( deleteView( KitaThreadView* ) ) );
+ connect( tabBar(), SIGNAL( deleteMenuSelected( QWidget* ) ),
+ SLOT( deleteView( QWidget* ) ) );
m_manager = new KParts::PartManager( topLevelWidget(), this, "KitaPartManager" );
}
KitaThreadTabWidget::~KitaThreadTabWidget()
-{}
+{
+ delete m_manager;
+}
void KitaThreadTabWidget::showThread( const QString& datURL, bool withNewTab )
{
return view;
}
+void KitaThreadTabWidget::showAlternativeView( const KURL& url, const QString& libName, const QString& mimetype )
+{
+ KLibFactory *factory = KLibLoader::self()->factory( libName );
+ if ( !factory ) {
+ QMessageBox::critical( parentWidget(), i18n( " Load Error" ),
+ QString( i18n( "can't load %1.") ).arg( libName ) );
+ return;
+ }
+ if ( factory->inherits( "KParts::Factory" ) ) {
+ KParts::Part *part = static_cast<KParts::Factory*>(factory)->createPart( this );
+ m_manager->addPart( part );
+ addTab( part->widget(), getTabLabel( url.url() ) );
+ showPage( part->widget() );
+ setTabToolTip( currentPage(), url.url() );
+ KParts::BrowserExtension *ext = KParts::BrowserExtension::childObject( part );
+ if ( ext ) {
+ KParts::URLArgs arg( false, 0, 0, mimetype );
+ ext->setURLArgs( arg );
+ }
+ static_cast<KParts::ReadOnlyPart*>(part)->openURL( url );
+ }
+}
+
void KitaThreadTabWidget::connectSignals( KitaThreadView* view )
{
Kita::SignalCollection* signalCollection = Kita::SignalCollection::getInstance();
return NULL;
}
-void KitaThreadTabWidget::deleteView( KitaThreadView* view )
+void KitaThreadTabWidget::deleteView( QWidget* v )
{
- kdDebug() << "deleteView(" << static_cast<void*>( view ) << ")" << endl;
+ kdDebug() << "deleteView(" << static_cast<void*>( v ) << ")" << endl;
- removePage( view );
- m_viewList.remove( view );
+ removePage( v );
+ m_viewList.remove( static_cast<KitaThreadView*>(v) );
- m_manager->removePart( findPartFromView( view ) );
- delete view;
+ m_manager->removePart( findPartFromView( v ) );
+ delete v;
- if ( count() == 0 ) {
+ if ( m_viewList.count() == 0 ) {
KitaThreadView * view = createView();
if ( view ) {
popup.insertItem( i18n( "Copy title and URL" ), ID_Copy_Title_URL );
popup.insertItem( i18n( "Close this tab" ), ID_Close );
- QTabWidget* parent = static_cast<QTabWidget*>( parentWidget() );
- KitaThreadView* threadView = static_cast<KitaThreadView*>( parent->currentPage() );
+ KitaThreadTabWidget* parent = static_cast<KitaThreadTabWidget*>( parentWidget() );
+ KParts::ReadOnlyPart* view = static_cast<KParts::ReadOnlyPart*>( parent->findPartFromView( parent->currentPage() ) );
QClipboard* clipboard = QApplication::clipboard();
+ KitaThreadView *threadView = NULL;
+
+ if ( view->className() != "KitaThreadPart" ) {
+ popup.setItemEnabled( ID_Copy_Title_URL, FALSE );
+ threadView = static_cast<KitaThreadView*>( parent->currentPage() );
+ }
switch ( popup.exec( e->globalPos() ) ) {
case ID_Browser_Open:
- KRun::runURL( threadView->threadURL(), "text/html" );
+ KRun( view->url() );
break;
case ID_Copy_Title_URL:
- clipboard->setText( threadView->threadName() + "\n" + threadView->threadURL().url() );
+ if ( threadView )
+ clipboard->setText( threadView->threadName() + "\n" + threadView->threadURL().url() );
break;
case ID_Close:
- emit deleteMenuSelected( threadView );
+ emit deleteMenuSelected( view->widget() );
break;
default:
break;
void KitaThreadTabWidget::slotCurrentChanged( QWidget * w )
{
- KitaThreadView* view = static_cast<KitaThreadView *>( w );
- view->showStatusBar( "" );
- m_manager->setActivePart( findPartFromView( view ) );
+ m_manager->setActivePart( findPartFromView( w ) );
}
const QString KitaThreadTabWidget::getTabLabel( const QString &name )