Example #1
0
int PMComboAction::plug( QWidget* w, int index )
{
    if( !w->inherits( "KToolBar" ) )
        return -1;

    KToolBar* toolBar = ( KToolBar* ) w;

    int id = KAction::getToolButtonID( );

    QComboBox* comboBox = new PMComboBox( toolBar );
    if( m_minWidth > 0 )
        comboBox->setMinimumWidth( m_minWidth );
    if( m_maxWidth > 0 )
        comboBox->setMaximumWidth( m_maxWidth );

    toolBar->insertWidget( id, m_minWidth > 0 ? m_minWidth : 300,
                           comboBox, index );
    connect( comboBox, SIGNAL( activated( int ) ), m_receiver, m_member );

    addContainer( toolBar, id );

    connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) );

    //toolBar->setItemAutoSized( id, true );

    m_combo = comboBox;

    emit plugged( );

    QWhatsThis::add( comboBox, whatsThis( ) );

    return containerCount( ) - 1;
}
Example #2
0
int TKAction::plug(QWidget* widget, int index)
{
  if ( widget->inherits("KToolBar") ) {
    KToolBar* bar = static_cast<KToolBar*>(widget);
    int id_ = KAction::getToolButtonID();
    KInstance *instance;

    if ( parentCollection() )
      instance = parentCollection()->instance();
    else
      instance = KGlobal::instance();

    TKToolBarButton* b = new TKToolBarButton(icon(),plainText(),bar,name(),instance);
    // we don't need clicked() and buttonClicked(), do we?
    // connect(b,SIGNAL(clicked()),SLOT(slotActivated()));
    b->setIconMode(m_imode);
    initToolBarButton(b);

    bar->insertWidget( id_, 100, b, index );
    addContainer(bar,id_);
    connect( bar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );

    return containerCount() - 1;
  }
  return KAction::plug(widget,index);
}
Example #3
0
int PMSpinBoxAction::plug( QWidget* w, int index )
{
    if( !w->inherits( "KToolBar" ) )
        return -1;

    KToolBar* toolBar = ( KToolBar* ) w;

    int id = KAction::getToolButtonID( );

    QSpinBox* spinBox = new QSpinBox( -1000, 1000, 1, w );
    toolBar->insertWidget( id, 70, spinBox, index );

    connect( spinBox, SIGNAL( valueChanged( int ) ), m_receiver, m_member );

    addContainer( toolBar, id );

    connect( toolBar, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) );
    //toolBar->setItemAutoSized( id, false );

    m_spinBox = spinBox;

    emit plugged( );

    QWhatsThis::add( spinBox, whatsThis( ) );

    return containerCount( ) - 1;
}
VariableWidgetEditor::VariableWidgetEditor( QWidget* a_pWidget, const char* valueChangedSignal, reflection::Type* a_pValueType) 
    : m_pWidget(a_pWidget)
    , m_pValueType(a_pValueType)
    , m_pVariableNode(nullptr)
{
    connect(m_pWidget, valueChangedSignal, this, SIGNAL(valueChanged()));
    connect(m_pWidget, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
    connect(&m_OpenTimer, SIGNAL(timeout()), this, SLOT(opened()));
    m_OpenTimer.setSingleShot(true);
    m_OpenTimer.start(0);
}
Example #5
0
void KAction::insertKAccel( KAccel* kaccel )
{
  //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl;
  if ( !kaccel->actions().actionPtr( name() ) ) {
    if( updateKAccelShortcut( kaccel ) ) {
      d->m_kaccelList.append( kaccel );
      connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
    }
  }
  else
    kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis
}
Example #6
0
void KAction::removeKAccel( KAccel* kaccel )
{
  //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl;
  QValueList<KAccel*> & accelList = d->m_kaccelList;
  QValueList<KAccel*>::iterator itr = accelList.begin();
  const QValueList<KAccel*>::iterator itrEnd = accelList.end();

  for( ; itr != itrEnd; ++itr) {
    if( (*itr) == kaccel ) {
      kaccel->remove( name() );
      accelList.remove( itr );
      disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
      break;
    }
  }
}
Example #7
0
int PMLabelAction::plug( QWidget *widget, int index )
{
    //do not call the previous implementation here

    if( widget->inherits( "KToolBar" ) )
    {
        KToolBar* tb = ( KToolBar* ) widget;

        int id = KAction::getToolButtonID( );

        m_button = new PMToolBarLabel( text( ), widget );
        tb->insertWidget( id, m_button->width( ), m_button, index );

        addContainer( tb, id );

        connect( tb, SIGNAL( destroyed( ) ), this, SLOT( slotDestroyed( ) ) );

        return containerCount( ) - 1;
    }

    return -1;
}
Example #8
0
int TKBaseSelectAction::plug(QWidget* widget, int index)
{
  if ( widget->inherits("KToolBar") )
  {
    KToolBar* bar = static_cast<KToolBar*>( widget );
    int id_ = KAction::getToolButtonID();

    TKComboBox* cb = new TKComboBox(m_editable,bar);
    initComboBox(cb);
    cb->setMinimumWidth( cb->sizeHint().width() );
    QWidget* base = createLayout(bar,cb);

    bar->insertWidget( id_, 100, base, index );
    addContainer( bar, id_ );

    connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );

    setCurrentItem(currentItem());

    return containerCount() - 1;
  }
  return -1;
}
Example #9
0
	void Konsole::spawn()
	{
		KILE_DEBUG_MAIN << "void Konsole::spawn()";

		KPluginFactory *factory = Q_NULLPTR;
		KService::Ptr service = KService::serviceByDesktopName("konsolepart");
		if(!service) {
			KILE_DEBUG_MAIN << "No service for konsolepart";
			return;
		}

		factory = KPluginLoader(service->library()).factory();
		if(!factory) {
			KILE_DEBUG_MAIN << "No factory for konsolepart";
			return;
		}

		// the catalog for translations is added by the Konsole part constructor already
		m_part = static_cast<KParts::ReadOnlyPart*>(factory->create<QObject>(this, this));
		if(!m_part) {
			return;
		}

		if(!qobject_cast<TerminalInterface*>(m_part)){
			KILE_DEBUG_MAIN << "Did not find the TerminalInterface";
			delete m_part;
			m_part = Q_NULLPTR;
			return;
		}

		layout()->addWidget(m_part->widget());
		setFocusProxy(m_part->widget());
		connect(m_part, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));

		// necessary as older versions of Konsole (4.5) might not show a proper prompt otherwise
		qobject_cast<TerminalInterface*>(m_part)->showShellInDir(QDir::currentPath());
	}
Example #10
0
int KAction::plug( QWidget *w, int index )
{
  //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl;
  if (!w ) {
	kdWarning(129) << "KAction::plug called with 0 argument\n";
 	return -1;
  }

  // Ellis: print warning if there is a shortcut, but no KAccel available (often due to no widget available in the actioncollection)
  // David: Well, it doesn't matter much, things still work (e.g. Undo in koffice) via QAccel.
  // We should probably re-enable the warning for things that only KAccel can do, though - e.g. WIN key (mapped to Meta).
#if 0 //ndef NDEBUG
  KAccel* kaccel = kaccelCurrent();
  if( !d->m_cut.isNull() && !kaccel ) {
    kdDebug(129) << "KAction::plug(): has no KAccel object; this = " << this << " name = " << name() << " parentCollection = " << m_parentCollection << endl; // ellis
  }
#endif

  // Check if action is permitted
  if (kapp && !kapp->authorizeKAction(name()))
    return -1;

  plugShortcut();

  if ( ::qt_cast<QPopupMenu *>( w ) )
  {
    QPopupMenu* menu = static_cast<QPopupMenu*>( w );
    int id;
    // Don't insert shortcut into menu if it's already in a KAccel object.
    int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt();

    if ( d->hasIcon() )
    {
        KInstance *instance;
        if ( m_parentCollection )
          instance = m_parentCollection->instance();
        else
          instance = KGlobal::instance();
        id = menu->insertItem( d->iconSet( KIcon::Small, 0, instance ), d->text(), this,//dsweet
                                 SLOT( slotPopupActivated() ), keyQt,
                                 -1, index );
    }
    else
        id = menu->insertItem( d->text(), this,
                               SLOT( slotPopupActivated() ),
                               keyQt, -1, index );

    // If the shortcut is already in a KAccel object, then
    //  we need to set the menu item's shortcut text.
    if ( d->m_kaccelList.count() || d->m_kaccel )
        updateShortcut( menu, id );

    // call setItemEnabled only if the item really should be disabled,
    // because that method is slow and the item is per default enabled
    if ( !d->isEnabled() )
        menu->setItemEnabled( id, false );

    if ( !d->whatsThis().isEmpty() )
        menu->setWhatsThis( id, whatsThisWithIcon() );

    addContainer( menu, id );
    connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );

    if ( m_parentCollection )
      m_parentCollection->connectHighlight( menu, this );

    return d->m_containers.count() - 1;
  }
  else if ( ::qt_cast<KToolBar *>( w ) )
  {
    KToolBar *bar = static_cast<KToolBar *>( w );

    int id_ = getToolButtonID();
    KInstance *instance;
    if ( m_parentCollection )
      instance = m_parentCollection->instance();
    else
      instance = KGlobal::instance();

    if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly
    {
        bar->insertButton( iconSet().pixmap(), id_, SIGNAL( buttonClicked(int, Qt::ButtonState) ), this,
                           SLOT( slotButtonClicked(int, Qt::ButtonState) ),
                           d->isEnabled(), d->plainText(), index );
    }
    else
    {