Beispiel #1
0
void KviTopicWidget::switchMode()
{
	int iMaxLen=-1;
	QObject * w = parent();
	QString szModes;
	bool bCanEdit = true;
	while(w)
	{
		if(w->inherits("KviChannelWindow"))
		{
			KviChannelWindow *chan = ((KviChannelWindow *)w);
			iMaxLen = chan->connection()->serverInfo()->maxTopicLen();
			chan->getChannelModeString(szModes);
			if(chan->plainChannelMode().contains('t') &&
				!( chan->isMeHalfOp(true) ||
					chan->connection()->userInfo()->hasUserMode('o') ||
					chan->connection()->userInfo()->hasUserMode('O')
				)
			)
			{
				bCanEdit=false;
			}
			break;
		}
		w = w->parent();
	}
	if(m_pInput == 0)
	{
		m_pInput = new KviInputEditor(this,m_pKviChannelWindow);
		m_pInput->setObjectName("topicw_inputeditor");
		m_pInput->setReadOnly(!bCanEdit);
		if(iMaxLen>0)
			m_pInput->setMaxBufferSize(iMaxLen);
		m_pInput->setGeometry(0,0,width() - (height() << 2)+height(),height());
		m_pInput->setText(m_szTopic);
		connect(m_pInput,SIGNAL(enterPressed()),this,SLOT(acceptClicked()));
		connect(m_pInput,SIGNAL(escapePressed()),this,SLOT(discardClicked()));
		m_pInput->installEventFilter(this);

		m_pHistory = new QPushButton(this);
		m_pHistory->setObjectName("topicw_historybutton");
		m_pHistory->setIcon(QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::History))));
		m_pHistory->setGeometry(width() - (height() << 2)+height(),0,height(),height());
		KviTalToolTip::add(m_pHistory,__tr2qs("History"));
		m_pHistory->show();
		connect(m_pHistory,SIGNAL(clicked()),this,SLOT(historyClicked()));

		m_pAccept = new QPushButton(this);
		m_pAccept->setObjectName("topicw_acceptbutton");
		m_pAccept->setIcon(QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept))));
		m_pAccept->setGeometry(width() - (height() << 1),0,height(),height());
		m_pAccept->setEnabled(bCanEdit);
		m_pAccept->show();
		KviTalToolTip::add(m_pAccept,__tr2qs("Commit changes"));
		connect(m_pAccept,SIGNAL(clicked()),this,SLOT(acceptClicked()));

		m_pDiscard = new QPushButton(this);
		m_pDiscard->setObjectName("topicw_discardbutton");
		m_pDiscard->setIcon(QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Discard))));
		m_pDiscard->setGeometry(width() - height(),0,height(),height());
		KviTalToolTip::add(m_pDiscard,__tr2qs("Discard changes"));
		m_pDiscard->show();
		connect(m_pDiscard,SIGNAL(clicked()),this,SLOT(discardClicked()));

		m_pInput->home();
		m_pInput->show();
		m_pInput->setFocus();

		m_pLabel->hide();
	} else {
		deactivate();
	}
}
Beispiel #2
0
// define E1Dialer
E1Dialer::E1Dialer( E1Button *b, QWidget* parent, Qt::WFlags f )
    : QWidget( parent, f | Qt::FramelessWindowHint ), m_textButton(b), m_activeCallCount(0)
{
    QVBoxLayout* vlayout = new QVBoxLayout( this );
    vlayout->setSpacing( 7 );
    vlayout->setMargin( 7 );

    // dialer interface

    // callhistory, input, backspace
    QHBoxLayout* hlayout1 = new QHBoxLayout();
    vlayout->addLayout( hlayout1 );
    hlayout1->setSpacing( 10 );
    hlayout1->setMargin( 0 );

    E1Bar * historyBar = new E1Bar(this);
    QPalette pal = palette();
    pal.setColor(QPalette::Highlight, QColor(255, 126, 0));
    historyBar->setPalette(pal);
    historyBar->setFixedSize(30, 20);
    historyBar->setBorder(E1Bar::ButtonBorder);
    E1Button *historyButton = new E1Button;
    historyButton->setPixmap(QPixmap(":image/samples/e1_callhistory"));
    historyBar->addItem(historyButton);
    connect(historyButton, SIGNAL(clicked()), this, SLOT(historyClicked()));
    hlayout1->addWidget( historyBar );

    m_input = new QLineEdit( this );
    m_input->setStyle( new QWindowsStyle );
    m_input->setFixedSize( 152, 24 );
    hlayout1->addWidget( m_input );
    connect( m_input, SIGNAL(textChanged(QString)), this, SLOT(numberChanged(QString)) );

    E1Bar * backspaceBar = new E1Bar(this);
    backspaceBar->setPalette(pal);
    backspaceBar->setFixedSize(30, 20);
    backspaceBar->setBorder(E1Bar::ButtonBorder);
    E1Button *backspaceButton = new E1Button;
    backspaceButton->setPixmap(QPixmap(":image/samples/e1_erase"));
    backspaceBar->addItem(backspaceButton);
    connect(backspaceButton, SIGNAL(clicked()), this, SLOT(eraseClicked()));
    hlayout1->addWidget( backspaceBar );

    QHBoxLayout* sideLayout = new QHBoxLayout;
    sideLayout->setMargin( 0 );
    sideLayout->setSpacing( 0 );
    vlayout->addLayout( sideLayout );

    QVBoxLayout* buttonLayout = new QVBoxLayout;
    buttonLayout->setMargin(0);
    buttonLayout->setSpacing(15);
    sideLayout->addLayout( buttonLayout );

    m_callscreenBar = new E1Bar(this);
    m_callscreenBar->setVisible( false );
    m_callscreenBar->setBorder(E1Bar::ButtonBorder);
    E1Button *callscreen = new E1Button;
    callscreen->setFlag(E1Button::Expanding);
    callscreen->setPixmap(QPixmap(":image/samples/e1_dialer"));
    m_callscreenBar->addItem(callscreen);
    m_callscreenBar->setFixedSize(32, 96);
    sideLayout->addWidget(m_callscreenBar);
    QObject::connect(callscreen, SIGNAL(clicked()), this, SIGNAL(toCallScreen()));
    connect(DialerControl::instance(), SIGNAL(activeCount(int)), this, SLOT(activeCallCount(int)));

    // 1, 2, 3
    QHBoxLayout* hlayout2 = new QHBoxLayout();
    buttonLayout->addLayout( hlayout2 );
    hlayout2->setSpacing( 10 );
    hlayout2->setMargin( 0 );

    E1DialerButton* button = new E1DialerButton( this );
    button->setText( "1" );
    button->setFgPixmap( QPixmap(":image/samples/1" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout2->addWidget( button );
    hlayout2->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "2" );
    button->setFgPixmap( QPixmap(":image/samples/2" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout2->addWidget( button );
    hlayout2->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "3" );
    button->setFgPixmap( QPixmap(":image/samples/3" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout2->addWidget( button );

    // 4, 5, 6
    QHBoxLayout* hlayout3 = new QHBoxLayout();
    buttonLayout->addLayout( hlayout3 );
    hlayout3->setSpacing( 10 );
    hlayout3->setMargin( 0 );

    button = new E1DialerButton( this );
    button->setText( "4" );
    button->setFgPixmap( QPixmap(":image/samples/4" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout3->addWidget( button );
    hlayout3->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "5" );
    button->setFgPixmap( QPixmap(":image/samples/5" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout3->addWidget( button );
    hlayout3->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "6" );
    button->setFgPixmap( QPixmap(":image/samples/6" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout3->addWidget( button );

    // 7, 8, 9
    QHBoxLayout* hlayout4 = new QHBoxLayout();
    buttonLayout->addLayout( hlayout4 );
    hlayout4->setSpacing( 10 );
    hlayout4->setMargin( 0 );

    button = new E1DialerButton( this );
    button->setText( "7" );
    button->setFgPixmap( QPixmap(":image/samples/7" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout4->addWidget( button );
    hlayout4->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "8" );
    button->setFgPixmap( QPixmap(":image/samples/8" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout4->addWidget( button );
    hlayout4->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "9" );
    button->setFgPixmap( QPixmap(":image/samples/9" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout4->addWidget( button );

    // *, 0, hash
    QHBoxLayout* hlayout5 = new QHBoxLayout();
    buttonLayout->addLayout( hlayout5 );
    hlayout5->setSpacing( 10 );
    hlayout5->setMargin( 0 );

    button = new E1DialerButton( this );
    button->setText( "*" );
    button->setFgPixmap( QPixmap(":image/samples/star" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout5->addWidget( button );
    hlayout5->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "0" );
    button->setFgPixmap( QPixmap(":image/samples/0" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout5->addWidget( button );
    hlayout5->addSpacing( 7 );

    button = new E1DialerButton( this );
    button->setText( "#" );
    button->setFgPixmap( QPixmap(":image/samples/hash" ) );
    connect( button, SIGNAL(clicked(QString)), this, SLOT(buttonClicked(QString)) );
    hlayout5->addWidget( button );

    connect( m_textButton, SIGNAL(clicked()), this, SLOT(textButtonClicked()) );
}