Implemented tabs context menu

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/24/head
Mavridis Philippe 4 years ago
parent e03731b27e
commit d5e986620c
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -147,16 +147,35 @@ void TabWidget::setTitle( const TQString &title , TQWidget* sender)
void TabWidget::contextMenu(int i, const TQPoint &p) void TabWidget::contextMenu(int i, const TQPoint &p)
{ {
currentItemId = i;
currentItem = page(i); currentItem = page(i);
TDEPopupMenu popup; TDEPopupMenu popup;
int closeTab = popup.insertItem( SmallIcon("tab_remove"), i18n("Close Tab"), this, SLOT( slotCloseTab() ) ); int moveTabLeft = popup.insertItem( SmallIcon("back"), i18n("Move Tab &Left"), this, SLOT(slotMoveTabLeft()) );
if(indexOf(currentItem) == 0) { // you can't detach or close articles tab.. int moveTabRight = popup.insertItem( SmallIcon("forward"), i18n("Move Tab &Right"), this, SLOT(slotMoveTabRight()) );
popup.setItemEnabled(closeTab, false); popup.insertSeparator();
} int closeTab = popup.insertItem( SmallIcon("tab_remove"), i18n("Close Tab"), this, SLOT(slotCloseTab()) );
if(currentItemId == 0)
popup.setItemEnabled(moveTabLeft, false);
if(currentItemId == count() - 1)
popup.setItemEnabled(moveTabRight, false);
popup.exec(p); popup.exec(p);
} }
void TabWidget::slotMoveTabLeft() {
if( currentItemId > 0 )
moveTab(currentItemId, currentItemId-1);
}
void TabWidget::slotMoveTabRight() {
if( currentItemId < count() - 1 )
moveTab(currentItemId, currentItemId+1);
}
void TabWidget::slotCloseTab() void TabWidget::slotCloseTab()
{ {
if(!currentItem) return; if(!currentItem) return;

@ -27,7 +27,7 @@ class TabWidget:public KTabWidget
void addFrame(Frame *f); void addFrame(Frame *f);
Frame *currentFrame(); Frame *currentFrame();
void removeFrame(Frame *f); void removeFrame(Frame *f);
unsigned int tabBarWidthForMaxChars( uint maxLength ); unsigned int tabBarWidthForMaxChars( uint maxLength );
void setTitle( const TQString &title , TQWidget* sender); void setTitle( const TQString &title , TQWidget* sender);
@ -42,6 +42,8 @@ class TabWidget:public KTabWidget
private slots: private slots:
void slotMoveTabLeft();
void slotMoveTabRight();
void slotCloseTab(); void slotCloseTab();
void slotCloseRequest(TQWidget* widget); void slotCloseRequest(TQWidget* widget);
void contextMenu (int item, const TQPoint &p); void contextMenu (int item, const TQPoint &p);
@ -51,6 +53,7 @@ class TabWidget:public KTabWidget
TQPtrDict<Frame> m_frames; TQPtrDict<Frame> m_frames;
unsigned int m_CurrentMaxLength; unsigned int m_CurrentMaxLength;
int currentItemId;
TQWidget* currentItem; TQWidget* currentItem;
}; };

Loading…
Cancel
Save