示例#1
0
void KActionSelector::moveItem(QListBoxItem *item)
{
    QListBox *lbFrom = item->listBox();
    QListBox *lbTo;
    if(lbFrom == d->availableListBox)
        lbTo = d->selectedListBox;
    else if(lbFrom == d->selectedListBox)
        lbTo = d->availableListBox;
    else //?! somewhat unlikely...
        return;

    InsertionPolicy p = (lbTo == d->availableListBox) ? d->availableInsertionPolicy : d->selectedInsertionPolicy;

    lbFrom->takeItem(item);
    lbTo->insertItem(item, insertionIndex(lbTo, p));
    lbTo->setFocus();
    lbTo->setCurrentItem(item);

    if(p == Sorted)
        lbTo->sort();
    if(lbTo == d->selectedListBox)
        emit added(item);
    else
        emit removed(item);
}
示例#2
0
void TabDialog::setupTab3()
{
    QVBox *tab3 = new QVBox( this );
    tab3->setMargin( 5 );
    tab3->setSpacing( 5 );
    
    (void)new QLabel( QString( "Open %1 with:" ).arg( filename ), tab3 );

    QListBox *prgs = new QListBox( tab3 );
    for ( unsigned int i = 0; i < 30; i++ ) {
        QString prg = QString( "Application %1" ).arg( i );
        prgs->insertItem( prg );
    }
    prgs->setCurrentItem( 3 );

    (void)new QCheckBox( QString( "Open files with the extension '%1' always with this application" ).arg( fileinfo.extension() ), tab3 );

    addTab( tab3, "Applications" );
}
void MidiManagerView::updateLists()
{
	vector<MidiClientInfo> *clients = manager.clients();
	vector<MidiClientInfo>::iterator i;

// keep selection over updating
	MidiManagerItem *src =
		(MidiManagerItem *)widget->inputsListBox->item(widget->inputsListBox->currentItem());
	MidiManagerItem *dest =
		(MidiManagerItem *)widget->outputsListBox->item(widget->outputsListBox->currentItem());

	long srcID = src?src->info.ID:0;
	long destID = dest?dest->info.ID:0;

// clear everything, and rebuild
	itemMap.clear();
	widget->inputsListBox->clear();
	widget->outputsListBox->clear();
	for(i = clients->begin(); i != clients->end(); i++)
	{
		QListBox *box;
		if(i->direction == mcdPlay)
			box = widget->inputsListBox;
		else
			box = widget->outputsListBox;

		MidiManagerItem *item = new MidiManagerItem(*i);
		itemMap[item->info.ID] = item;
		box->insertItem(item);
	}
	delete clients;

// restore selection
	if(srcID && itemMap[srcID])
		widget->inputsListBox->setSelected(itemMap[srcID],true);
	if(destID && itemMap[destID])
		widget->outputsListBox->setSelected(itemMap[destID],true);
	connectionWidget->repaint();
}
示例#4
0
KScienceSetup::KScienceSetup(  QWidget *parent, const char *name )
	: KDialogBase( parent, name, true, i18n( "Setup Science Screen Saver" ),
	  Ok|Cancel|Help, Ok, true ), saver( 0 )
{
	readSettings();
	initModeInfo();

	QWidget *main = makeMainWidget();

	QHBoxLayout *lt  = new QHBoxLayout( main, 0, spacingHint());
	QVBoxLayout *ltm = new QVBoxLayout;
	lt->addLayout( ltm );
	QVBoxLayout *ltc = new QVBoxLayout;
	lt->addLayout( ltc );

	// mode
	QLabel *label = new QLabel( i18n("Mode:"), main );
	ltm->addWidget( label );

	QListBox *c = new QListBox( main );
	for(int i = 0; i<MAX_MODES; i++)
		c->insertItem( modeInfo[i].name );
	c->setCurrentItem( mode );
	c->setFixedHeight( 5 * c->fontMetrics().height() );
	connect( c, SIGNAL( highlighted( int ) ), SLOT( slotMode( int ) ) );
	ltm->addWidget( c );

	// inverse
	QCheckBox *cbox = checkInverse = new QCheckBox( i18n("Inverse"), main );
	cbox->setEnabled( modeInfo[mode].inverseEnable );
	cbox->setChecked( inverse[mode] );
	connect( cbox, SIGNAL( clicked() ), SLOT( slotInverse() ) );
	ltm->addWidget( cbox );

	// gravity
	cbox = checkGravity = new QCheckBox( i18n("Gravity"), main );
	cbox->setChecked( gravity[mode] );
	connect( cbox, SIGNAL( clicked() ), SLOT( slotGravity() ) );
	ltm->addWidget( cbox );

	// hide background
	cbox = checkHideBG = new QCheckBox( i18n("Hide background"), main );
	cbox->setChecked( hideBG[mode] );
	connect( cbox, SIGNAL( clicked() ), SLOT( slotHideBG() ) );
	ltm->addWidget( cbox );
	ltm->addStretch();

	// size
	label = new QLabel( i18n("Size:"), main );
	ltc->addWidget( label );

	slideSize = new QSlider(9, 50, 5, size[mode], QSlider::Horizontal,
                                main );
	slideSize->setMinimumSize( 90, 20 );
    slideSize->setTickmarks(QSlider::Below);
    slideSize->setTickInterval(5);
	connect( slideSize, SIGNAL( sliderMoved( int ) ),
		SLOT( slotSize( int ) ) );
	connect( slideSize, SIGNAL( sliderPressed() ),
		SLOT( slotSliderPressed() ) );
	connect( slideSize, SIGNAL( sliderReleased() ),
		SLOT( slotSliderReleased() ) );

	ltc->addWidget( slideSize );

	// intensity
	label = new QLabel( i18n("Intensity:"), main );
	ltc->addWidget( label );

	slideIntensity = new QSlider(0, 10, 1, intensity[mode],
                                     QSlider::Horizontal, main );
	slideIntensity->setMinimumSize( 90, 20 );
    slideIntensity->setTickmarks(QSlider::Below);
    slideIntensity->setTickInterval(1);
	connect( slideIntensity, SIGNAL( sliderMoved( int ) ),
		SLOT( slotIntensity( int )) );
	connect( slideIntensity, SIGNAL( sliderPressed() ),
		SLOT( slotSliderPressed() ) );
	connect( slideIntensity, SIGNAL( sliderReleased() ),
		SLOT( slotSliderReleased() ) );
	ltc->addWidget( slideIntensity );

	// speed
	label = new QLabel( i18n("Speed:"), main );
	ltc->addWidget( label );

	slideSpeed = new QSlider(0, SCI_MAX_SPEED, 10, speed[mode],
                             QSlider::Horizontal, main );
	slideSpeed->setMinimumSize( 90, 20 );
    slideSpeed->setTickmarks(QSlider::Below);
    slideSpeed->setTickInterval(10);
	connect( slideSpeed, SIGNAL( sliderMoved( int ) ),
		SLOT( slotSpeed( int ) ) );
	ltc->addWidget( slideSpeed );

	// motion
	label = new QLabel( i18n("Motion:"), main );
	ltc->addWidget( label );

	QHBoxLayout *ltcm = new QHBoxLayout;
	ltc->addLayout( ltcm );

	slideMoveX = new QSlider(0, SCI_MAX_MOVE, 5, moveX[mode],
                                 QSlider::Horizontal, main );
	slideMoveX->setMinimumSize( 40, 20 );
    slideMoveX->setTickmarks(QSlider::Below);
    slideMoveX->setTickInterval(5);
	connect( slideMoveX, SIGNAL( sliderMoved( int ) ),
		SLOT( slotMoveX( int ) ) );
	ltcm->addWidget( slideMoveX );

	slideMoveY = new QSlider(0, SCI_MAX_MOVE, 5, moveY[mode],
                                QSlider::Horizontal, main );
	slideMoveY->setMinimumSize( 40, 20 );
    slideMoveY->setTickmarks(QSlider::Below);
    slideMoveY->setTickInterval(5);
	connect( slideMoveY, SIGNAL( sliderMoved( int ) ),
		SLOT( slotMoveY( int ) ) );
	ltcm->addWidget( slideMoveY );

	ltc->addStretch();

	// preview
	preview = new KPreviewWidget( main );
	preview->setFixedSize( 220, 170 );
	QPixmap p( locate("data", "kscreensaver/pics/kscience.png") );
	if( p.isNull() )
		preview->setBackgroundColor( black );
	else
		preview->setBackgroundPixmap( p );
	preview->show();	// otherwise saver does not get correct size
	lt->addWidget( preview );

	// let the preview window display before creating the saver
	kapp->processEvents();

	saver = new KScienceSaver( preview->winId(), true, !p.isNull() );
	preview->notifySaver( saver );
}
示例#5
0
/////////////////////////////////////////////////////////////////////////////////////////////////
// Trade dialog class
/////////////////////////////////////////////////////////////////////////////////////////////////
TradeDialog::TradeDialog(net::GameState *gamestate, const PlayerState* me, const PlayerState* other, QWidget *parent, const char * name) : QDialog(parent, name, TRUE)
{
	setCaption("Make a trade!");

	QGridLayout *grid = new QGridLayout(this, 4, 2, 5, 10, "grid");

	const Game_Base & base = gamestate->get_base();

	QLabel * lbl = NULL;

	// titles

	lbl = new QLabel("Your inventory", this);
	grid->addWidget( lbl, 0, 0, Qt::AlignCenter );

	lbl = new QLabel( other->get_name() + QString("'s inventory") , this);
	grid->addWidget( lbl , 0, 1, Qt::AlignCenter );

	// buttons

	QPushButton *okbtn = new QPushButton ("Request Trade", this);
	connect( okbtn, SIGNAL(clicked()), SLOT(accept()));
	grid->addWidget( okbtn, 3, 0, Qt::AlignCenter );

	QPushButton *cancelbtn = new QPushButton( "Cancel", this);
	connect(cancelbtn, SIGNAL(clicked()), SLOT(reject()));
	grid->addWidget( cancelbtn, 3, 1, Qt::AlignCenter );

	// money spinboxes

	QHBox * lhbox = new QHBox(this);
	lhbox->setSpacing(5);
	new QLabel("Money:", lhbox);
	_my_spin = new QSpinBox( 0, me->get_money(), 1, lhbox);
	grid->addWidget(lhbox, 2, 0, Qt::AlignCenter );
	
	QHBox * rhbox = new QHBox(this);
	rhbox->setSpacing(5);
	new QLabel("Money:", rhbox);
	_their_spin = new QSpinBox( 0, other->get_money(), 1, rhbox);
	grid->addWidget(rhbox, 2, 1, Qt::AlignCenter );


	net::PropertyList_t::const_iterator it;



	// current player's inventory

	QListBox* llbox = _my_list = new QListBox(this);
	llbox->setSelectionMode( QListBox::Multi );
	llbox->setMinimumHeight(100);

	const net::PropertyList_t & props = me->get_owned_properties();
	for(it = props.begin(); it != props.end(); ++it) {
		net::Property_t id = *it;
		if(id == 255 || id == 254) {
			_my_trans.push_back(id);
			llbox->insertItem( QString("Get out of Jail card - ") + QString::number(id - 253) );
		} else {
			const std::string* name = base.name(id);
			if(name != NULL) {
				_my_trans.push_back(id);
				llbox->insertItem( *name );
			}
		}
	}

	grid->addWidget(llbox, 1, 0, Qt::AlignHCenter | Qt::AlignTop );


	QListBox* rlbox = _their_list = new QListBox(this);
	rlbox->setSelectionMode( QListBox::Multi );
	rlbox->setMinimumHeight(100);

	const net::PropertyList_t tprops = other->get_owned_properties();
	for(it = tprops.begin(); it != tprops.end(); ++it) {
		net::Property_t id = *it;
		if(id == 255 || id == 254) {
			_their_trans.push_back(id);
			rlbox->insertItem( QString("Get out of Jail card - ") + QString::number(id - 253) );
		} else {
			const std::string* name = base.name(id);
			if(name != NULL) {
				_their_trans.push_back(id);
				rlbox->insertItem( *name );
			}
		}
	}


	grid->addWidget(rlbox, 1, 1, Qt::AlignHCenter | Qt::AlignTop );

}