Пример #1
0
void Test::rightPopupActivated(int item)
{
  switch (item) {
    case 0: if ( mWidget->count() >1) {
              mWidget->removePage( mWidget->page(0) );
            }
            break;
    case 1: removeCurrentTab();
            break;
    case 2: int count = mWidget->count();
            if (count>1) {
              mWidget->removePage( mWidget->page(count-1) );
            }
  }
}
Пример #2
0
void Test::rightPopupActivated(QAction *action)
{
  switch (mRightPopup->actions().indexOf(action)) {
    case 0: removeCurrentTab();
            break;
    case 2: if ( mWidget->count() >1) {
              mWidget->removeTab( 0 );
            }
            break;
    case 3: int count = mWidget->count();
            if (count>1) {
              mWidget->removeTab( count-1 );
            }
            break;
  }
}
Пример #3
0
void Test::toggleRightButton(bool state)
{
if (state) {
    if ( !mRightWidget) {
      mRightWidget = new QToolButton( mWidget );
      QObject::connect( mRightWidget, SIGNAL( clicked() ), SLOT( removeCurrentTab() ) );
      mRightWidget->setIconSet( SmallIcon( "tab_remove" ) );
      mRightWidget->setTextLabel("Close");
      mRightWidget->setTextPosition(QToolButton::Right);
      mRightWidget->adjustSize();
    //mRightButton->setGeometry( 0, 0, h, h );
      mRightWidget->setPopup(mRightPopup);
      mWidget->setCornerWidget( mRightWidget, TopRight );
    }
    mRightWidget->show();
  }
  else
    mRightWidget->hide();
}
Пример #4
0
void Test::toggleRightButton(bool state)
{
if (state) {
    if ( !mRightWidget) {
      mRightWidget = new QToolButton( mWidget );
      QObject::connect( mRightWidget, SIGNAL(clicked()), SLOT(removeCurrentTab()) );
      mRightWidget->setIcon( SmallIcon( "tab-close" ) );
      mRightWidget->setText("Close");
      mRightWidget->setToolTip("Close");
      mRightWidget->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
      mRightWidget->adjustSize();
    //mRightButton->setGeometry( 0, 0, h, h );
      mRightWidget->setMenu(mRightPopup);
      mWidget->setCornerWidget( mRightWidget, Qt::TopRightCorner );
    }
    mRightWidget->show();
  }
  else
    mRightWidget->hide();
}
Пример #5
0
Test::Test( QWidget* parent )
  :KVBox( parent ), mChange(0), mLeftWidget(0), mRightWidget(0),
  mLeftPopup(0), mRightPopup(0), mTabbarContextPopup(0), mContextPopup(0)

{
  resize( 600,300 );

  mWidget = new KTabWidget( this );
  mWidget->addTab( new QLabel( "Testlabel 1", 0 ), "&One" );
  mWidget->addTab( new QLabel( "Testlabel 2", 0 ), "Two" );
  mWidget->addTab( new QWidget(), SmallIcon( "konsole" ), "Three" );
  mWidget->addTab( new QWidget(), "Four" );
  mWidget->setTabTextColor( 0, Qt::red );
  mWidget->setTabTextColor( 1, Qt::blue );
  mWidget->setUsesScrollButtons( false ); // corresponding checkbox is unchecked by default

  connect( mWidget, SIGNAL(currentChanged(QWidget*)), SLOT(currentChanged(QWidget*)) );
  connect( mWidget, SIGNAL(contextMenu(QWidget*,QPoint)), SLOT(contextMenu(QWidget*,QPoint)));
  connect( mWidget, SIGNAL(contextMenu(QPoint)), SLOT(tabbarContextMenu(QPoint)));
  connect( mWidget, SIGNAL(mouseDoubleClick(QWidget*)), SLOT(mouseDoubleClick(QWidget*)));
  connect( mWidget, SIGNAL(mouseMiddleClick()), SLOT(addTab()));
  connect( mWidget, SIGNAL(mouseMiddleClick(QWidget*)), SLOT(mouseMiddleClick(QWidget*)));
  connect( mWidget, SIGNAL(closeRequest(QWidget*)), SLOT(mouseMiddleClick(QWidget*)));
  connect( mWidget, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), SLOT(testCanDecode(const QDragMoveEvent*,bool&)));
  connect( mWidget, SIGNAL(receivedDropEvent(QDropEvent*)), SLOT(receivedDropEvent(QDropEvent*)));
  connect( mWidget, SIGNAL(receivedDropEvent(QWidget*,QDropEvent*)), SLOT(receivedDropEvent(QWidget*,QDropEvent*)));
  connect( mWidget, SIGNAL(initiateDrag(QWidget*)), SLOT(initiateDrag(QWidget*)));
  connect( mWidget, SIGNAL(movedTab(int,int)), SLOT(movedTab(int,int)));
  mWidget->setMovable( true );

  QWidget * grid = new QWidget(this);
  QGridLayout * gridlayout = new QGridLayout( grid );

  QPushButton * addTab = new QPushButton( "Add Tab", grid );
  gridlayout->addWidget( addTab, 0, 0 );
  connect( addTab, SIGNAL(clicked()), SLOT(addTab()) );

  QPushButton * removeTab = new QPushButton( "Remove Current Tab", grid );
  gridlayout->addWidget( removeTab, 0, 1 );
  connect( removeTab, SIGNAL(clicked()), SLOT(removeCurrentTab()) );

  mLeftButton = new QCheckBox( "Show left button", grid );
  gridlayout->addWidget( mLeftButton, 1, 0 );
  connect( mLeftButton, SIGNAL(toggled(bool)), SLOT(toggleLeftButton(bool)) );
  mLeftButton->setChecked(true);

  QCheckBox * leftPopup = new QCheckBox( "Enable left popup", grid );
  gridlayout->addWidget( leftPopup, 2, 0 );
  connect( leftPopup, SIGNAL(toggled(bool)), SLOT(toggleLeftPopup(bool)) );
  leftPopup->setChecked(true);

  mRightButton = new QCheckBox( "Show right button", grid );
  gridlayout->addWidget( mRightButton, 1, 1 );
  connect( mRightButton, SIGNAL(toggled(bool)), SLOT(toggleRightButton(bool)) );
  mRightButton->setChecked(true);

  QCheckBox * rightPopup = new QCheckBox( "Enable right popup", grid );
  gridlayout->addWidget( rightPopup, 2, 1 );
  connect( rightPopup, SIGNAL(toggled(bool)), SLOT(toggleRightPopup(bool)) );
  rightPopup->setChecked(true);

  mTabsBottom = new QCheckBox( "Show tabs at bottom", grid );
  gridlayout->addWidget( mTabsBottom, 3, 0 );
  connect( mTabsBottom, SIGNAL(toggled(bool)), SLOT(toggleTabPosition(bool)) );

  QCheckBox * tabshape = new QCheckBox( "Triangular tab shape", grid );
  gridlayout->addWidget( tabshape, 3, 1 );
  connect( tabshape, SIGNAL(toggled(bool)), SLOT(toggleTabShape(bool)) );

  QCheckBox *tabClose = new QCheckBox( "Close button on icon hover", grid );
  gridlayout->addWidget( tabClose, 4, 0 );
  connect( tabClose, SIGNAL(toggled(bool)), SLOT(toggleCloseButtons(bool)) );
  tabClose->setChecked(true);

  QCheckBox * showlabels = new QCheckBox( "Show labels", grid );
  gridlayout->addWidget( showlabels, 4, 1 );
  connect( showlabels, SIGNAL(toggled(bool)), this, SLOT(toggleLabels(bool)) );

  QCheckBox * elideText = new QCheckBox( "Elide text", grid );
  gridlayout->addWidget( elideText, 5, 0 );
  connect( elideText, SIGNAL(toggled(bool)), this, SLOT(toggleEliding(bool)) );

  QCheckBox * scrollButtons = new QCheckBox( "Enable scroll buttons", grid );
  gridlayout->addWidget( scrollButtons, 5, 1 );
  connect( scrollButtons, SIGNAL(toggled(bool)), this, SLOT(toggleScrollButtons(bool)) );
}
Пример #6
0
Test::Test( QWidget* parent, const char *name )
  :QVBox( parent, name ), mChange(0), mLeftWidget(0), mRightWidget(0),
  mLeftPopup( false ), mRightPopup( false ), mTabbarContextPopup( false ), mContextPopup( false )

{
  resize( 600,300 );

  mWidget = new KTabWidget( this );
  mWidget->addTab( new QLabel( "Testlabel 1", mWidget ), "One" );
  mWidget->addTab( new QLabel( "Testlabel 2", mWidget ), "Two" );
  mWidget->addTab( new QWidget( mWidget), SmallIcon( "konsole" ), "Three" );
  mWidget->addTab( new QWidget( mWidget), "Four" );
  mWidget->setTabColor( mWidget->page(0), Qt::red );
  mWidget->setTabColor( mWidget->page(1), Qt::blue );

  connect( mWidget, SIGNAL( currentChanged( QWidget * ) ), SLOT( currentChanged( QWidget * ) ) );
  connect( mWidget, SIGNAL( contextMenu( QWidget *, const QPoint & )), SLOT(contextMenu( QWidget *, const QPoint & )));
  connect( mWidget, SIGNAL( contextMenu( const QPoint & )), SLOT(tabbarContextMenu( const QPoint & )));
  connect( mWidget, SIGNAL( mouseDoubleClick( QWidget * )), SLOT(mouseDoubleClick( QWidget * )));
  connect( mWidget, SIGNAL( mouseMiddleClick() ), SLOT(addTab() ));
  connect( mWidget, SIGNAL( mouseMiddleClick( QWidget * )), SLOT(mouseMiddleClick( QWidget * )));
  connect( mWidget, SIGNAL( closeRequest( QWidget * )), SLOT(mouseMiddleClick( QWidget * )));
  connect( mWidget, SIGNAL( testCanDecode(const QDragMoveEvent *, bool & )), SLOT(testCanDecode(const QDragMoveEvent *, bool & )));
  connect( mWidget, SIGNAL( receivedDropEvent( QDropEvent * )), SLOT(receivedDropEvent( QDropEvent * )));
  connect( mWidget, SIGNAL( receivedDropEvent( QWidget *, QDropEvent * )), SLOT(receivedDropEvent( QWidget *, QDropEvent * )));
  connect( mWidget, SIGNAL( initiateDrag( QWidget * )), SLOT(initiateDrag( QWidget * )));
  connect( mWidget, SIGNAL( movedTab( int, int )), SLOT(movedTab( int, int )));
  mWidget->setTabReorderingEnabled( true );

  QWidget * grid = new QWidget(this);
  QGridLayout * gridlayout = new QGridLayout( grid, 5, 2 );

  QPushButton * addTab = new QPushButton( "Add Tab", grid );
  gridlayout->addWidget( addTab, 0, 0 );
  connect( addTab, SIGNAL( clicked() ), SLOT( addTab() ) );

  QPushButton * removeTab = new QPushButton( "Remove Current Tab", grid );
  gridlayout->addWidget( removeTab, 0, 1 );
  connect( removeTab, SIGNAL( clicked() ), SLOT( removeCurrentTab() ) );

  mLeftButton = new QCheckBox( "Show left button", grid );
  gridlayout->addWidget( mLeftButton, 1, 0 );
  connect( mLeftButton, SIGNAL( toggled(bool) ), SLOT( toggleLeftButton(bool) ) );
  mLeftButton->setChecked(true);

  QCheckBox * leftPopup = new QCheckBox( "Enable left popup", grid );
  gridlayout->addWidget( leftPopup, 2, 0 );
  connect( leftPopup, SIGNAL( toggled(bool) ), SLOT( toggleLeftPopup(bool) ) );
  leftPopup->setChecked(true);

  mRightButton = new QCheckBox( "Show right button", grid );
  gridlayout->addWidget( mRightButton, 1, 1 );
  connect( mRightButton, SIGNAL( toggled(bool) ), SLOT( toggleRightButton(bool) ) );
  mRightButton->setChecked(true);

  QCheckBox * rightPopup = new QCheckBox( "Enable right popup", grid );
  gridlayout->addWidget( rightPopup, 2, 1 );
  connect( rightPopup, SIGNAL( toggled(bool) ), SLOT( toggleRightPopup(bool) ) );
  rightPopup->setChecked(true);

  mTabsBottom = new QCheckBox( "Show tabs at bottom", grid );
  gridlayout->addWidget( mTabsBottom, 3, 0 );
  connect( mTabsBottom, SIGNAL( toggled(bool) ), SLOT( toggleTabPosition(bool) ) );

  QCheckBox * tabshape = new QCheckBox( "Triangular tab shape", grid );
  gridlayout->addWidget( tabshape, 3, 1 );
  connect( tabshape, SIGNAL( toggled(bool) ), SLOT( toggleTabShape(bool) ) );

  QCheckBox *tabClose = new QCheckBox( "Close button on icon hover", grid );
  gridlayout->addWidget( tabClose, 4, 0 );
  connect( tabClose, SIGNAL( toggled(bool) ), SLOT( toggleCloseButtons(bool) ) );
  tabClose->setChecked(true);

  QCheckBox * showlabels = new QCheckBox( "Show labels", grid );
  gridlayout->addWidget( showlabels, 4, 1 );
  connect( showlabels, SIGNAL( toggled(bool) ), this, SLOT( toggleLabels(bool) ) );
}