#include "kitathreadview.h"
#include <klibloader.h>
+#include <kpopupmenu.h>
+#include <krun.h>
+
+#include <qclipboard.h>
+#include <qapplication.h>
#define MAX_TABLABEL_LEN 20
KitaThreadTabWidget::KitaThreadTabWidget(QWidget *parent, const char *name, WFlags f)
: QTabWidget(parent, name, f)
{
+ setTabBar( new KitaThreadTabBar( this ) );
+
KLibFactory* factory = KLibLoader::self()->factory( "libkitapart" );
if( ! factory ) {
return;
connect( view, SIGNAL( showThreadCompleted( const KURL& ) ),
this, SIGNAL( showThreadCompleted( const KURL& ) ) );
}
+
+
+KitaThreadTabBar::KitaThreadTabBar( QWidget* parent, const char* name )
+ : QTabBar( parent, name )
+{
+}
+
+KitaThreadTabBar::~KitaThreadTabBar()
+{
+}
+
+void KitaThreadTabBar::contextMenuEvent( QContextMenuEvent* e )
+{
+ KPopupMenu popup( 0 );
+ popup.insertItem( i18n("Open with Web Browser"), 0 );
+ popup.insertItem( i18n("Copy title and URL"), 1 );
+// popup.insertItem( i18n("Close this tab"), 2 );
+
+ QTabWidget* parent = static_cast<QTabWidget*>( parentWidget() );
+ KitaThreadView* threadView = static_cast<KitaThreadView*>( parent->currentPage() );
+ QClipboard* clipboard = QApplication::clipboard();
+
+ switch( popup.exec( e->globalPos() ) ) {
+ case 0:
+ KRun::runURL( threadView->threadURL(), "text/html" );
+ break;
+ case 1:
+ clipboard->setText( threadView->threadName() + "\n" + threadView->threadURL().url() );
+ break;
+ default:
+ break;
+ }
+
+ qDebug("currentPage = %s", static_cast<const char *>( tab( currentTab() )->text().local8Bit() ) );
+}
#define KITATHREADTABWIDGET_H
#include <qtabwidget.h>
+#include <qtabbar.h>
#include <kparts/browserextension.h>
class KitaThreadPart;
void showThreadCompleted( const KURL& threadUrl );
};
+class KitaThreadTabBar : public QTabBar
+{
+ Q_OBJECT
+
+public:
+ KitaThreadTabBar( QWidget* parent = 0, const char* name = 0 );
+ ~KitaThreadTabBar();
+
+protected:
+ virtual void contextMenuEvent( QContextMenuEvent* e );
+};
+
#endif