/*protected*/ void TabbedTableItem::addToBottomBox(QWidget* comp)
{
 QHBoxLayout* bottomBoxLayout;
 if(bottomBox->layout() == nullptr)
 {
  bottomBox->setLayout(bottomBoxLayout = new QHBoxLayout);
 }
 else
  bottomBoxLayout = (QHBoxLayout*)bottomBox->layout();
 try
 {
  bottomBoxLayout->addStrut(bottomStrutWidth);
  ++bottomBoxIndex;
  bottomBoxLayout->insertWidget(bottomBoxIndex, comp);
  ++bottomBoxIndex;
 }
 catch (IllegalArgumentException ex)
 {
  // log.error (ex.getLocalizedMessage(), ex);
 }
}
Пример #2
0
InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent, const char *name, bool modal, WFlags f):QDialog(parent, name, modal, f)
{
	type = newtype;
	QHBoxLayout *layout = new QHBoxLayout(this);
	layout->addStrut(32);
	QLabel *label = new QLabel(labelString, this, "label");
	setCaption(title);
	int x, y;

	layout->addSpacing(5);
	layout->addWidget(label);
	layout->addSpacing(5);

	switch(type)
	{
	case 0:
		lineEdit = new QLineEdit(this, "line edit");
		layout->addWidget(lineEdit);
		break;
	case 1:
		comboBox = new QComboBox(edit, this, "combo box");
		layout->addWidget(comboBox);
		if(!filename.isNull())
		{
			QFile file(filename);
			if (file.open(IO_ReadOnly))
			{
				QTextStream stream(&file);
				QString string = stream.read();

				comboBox->insertStringList(QStringList::split('\n', string));
			}
		}
		else
		{
			QFile file;
			file.open(IO_ReadOnly, 0);
			QTextStream stream(&file);
			QString string = stream.read();

			comboBox->insertStringList(QStringList::split('\n', string));
		}
		break;
	case 2:
		listBox = new QListBox(this, "list box");
		listBox->setSelectionMode(QListBox::Multi);
		layout->addWidget(listBox);
		if(!filename.isNull())
		{
			QFile file(filename);
			if (file.open(IO_ReadOnly))
			{
				QTextStream stream(&file);
				QString string = stream.read();

				listBox->insertStringList(QStringList::split('\n', string));
			}
		}
		else
		{
			QFile file;
			file.open(IO_ReadOnly, 0);
			QTextStream stream(&file);
			QString string = stream.read();

			listBox->insertStringList(QStringList::split('\n', string));
		}
		break;
	case 3:
		lineEdit = new QLineEdit(this, "line edit");
		lineEdit->setEchoMode(QLineEdit::Password);
		layout->addWidget(lineEdit);
		break;
	}
	layout->addSpacing(5);

	x=(w/2)-(width()/2);
	y=(h/2)-(height()/2);

	move(x,y);
}
Пример #3
0
KAstTopLevel::KAstTopLevel( QWidget *parent)
    : QMainWindow(parent)
{
    QWidget *border = new QWidget( this );

    QPalette palette;
    palette.setColor(border->backgroundRole(), Qt::black);
    border->setPalette(palette);

    setCentralWidget( border );

    QVBoxLayout *borderLayout = new QVBoxLayout( border );
    borderLayout->addStretch( 1 );

    QWidget *mainWin = new QWidget( border );
#if defined(Q_WS_MAEMO_5)
    mainWin->setFixedSize(800, 430);
#elif defined(Q_OS_SYMBIAN)
    mainWin->setFixedSize(640, 340);
#else
    mainWin->setFixedSize(640, 480);
#endif
    borderLayout->addWidget( mainWin, 0, Qt::AlignHCenter );

    borderLayout->addStretch( 1 );

    view = new KAsteroidsView( mainWin );
    view->setFocusPolicy( Qt::StrongFocus );
    connect( view, SIGNAL(shipKilled()), SLOT(slotShipKilled()) );
    connect( view, SIGNAL(rockHit(int)), SLOT(slotRockHit(int)) );
    connect( view, SIGNAL(rocksRemoved()), SLOT(slotRocksRemoved()) );
    connect( view, SIGNAL(updateVitals()), SLOT(slotUpdateVitals()) );

    QVBoxLayout *vb = new QVBoxLayout( mainWin );
    QHBoxLayout *hb = new QHBoxLayout;
    QHBoxLayout *hbd = new QHBoxLayout;
    vb->addLayout( hb );

#if defined(Q_OS_SYMBIAN)
    QFont labelFont( "helvetica", 8 );
#else
    QFont labelFont( "helvetica", 24 );
#endif

    QPalette pal(Qt::darkGreen, Qt::black, QColor( 128, 128, 128 ), QColor( 64, 64, 64 ), Qt::black, Qt::darkGreen, Qt::black);

    mainWin->setPalette( pal );

    hb->addSpacing( 10 );

    QLabel *label;
    label = new QLabel( tr("Score"), mainWin );
    label->setFont( labelFont );
    label->setPalette( pal );
    label->setFixedWidth( label->sizeHint().width() );
    hb->addWidget( label );

    scoreLCD = new QLCDNumber( 6, mainWin );
    scoreLCD->setFrameStyle( QFrame::NoFrame );
    scoreLCD->setSegmentStyle( QLCDNumber::Flat );
    scoreLCD->setFixedWidth( 150 );
    scoreLCD->setPalette( pal );
    hb->addWidget( scoreLCD );
    hb->addStretch( 10 );

    label = new QLabel( tr("Level"), mainWin );
    label->setFont( labelFont );
    label->setPalette( pal );
    label->setFixedWidth( label->sizeHint().width() );
    hb->addWidget( label );

    levelLCD = new QLCDNumber( 2, mainWin );
    levelLCD->setFrameStyle( QFrame::NoFrame );
    levelLCD->setSegmentStyle( QLCDNumber::Flat );
    levelLCD->setFixedWidth( 70 );
    levelLCD->setPalette( pal );
    hb->addWidget( levelLCD );
    hb->addStretch( 10 );

    label = new QLabel( tr("Ships"), mainWin );
    label->setFont( labelFont );
    label->setFixedWidth( label->sizeHint().width() );
    label->setPalette( pal );
    hb->addWidget( label );

    shipsLCD = new QLCDNumber( 1, mainWin );
    shipsLCD->setFrameStyle( QFrame::NoFrame );
    shipsLCD->setSegmentStyle( QLCDNumber::Flat );
    shipsLCD->setFixedWidth( 40 );
    shipsLCD->setPalette( pal );
    hb->addWidget( shipsLCD );

    hb->addStrut( 30 );

    vb->addWidget( view, 10 );

// -- bottom layout:
    vb->addLayout( hbd );

#if defined(Q_OS_SYMBIAN)
    QFont smallFont( "helvetica", 6 );
#else
    QFont smallFont( "helvetica", 14 );
#endif
    hbd->addSpacing( 10 );

    QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/";
/*
    label = new QLabel( tr( "T" ), mainWin );
    label->setFont( smallFont );
    label->setFixedWidth( label->sizeHint().width() );
    label->setPalette( pal );
    hbd->addWidget( label );

    teleportsLCD = new QLCDNumber( 1, mainWin );
    teleportsLCD->setFrameStyle( QFrame::NoFrame );
    teleportsLCD->setSegmentStyle( QLCDNumber::Flat );
    teleportsLCD->setPalette( pal );
    teleportsLCD->setFixedHeight( 20 );
    hbd->addWidget( teleportsLCD );

    hbd->addSpacing( 10 );
*/
    QPixmap pm( sprites_prefix + "powerups/brake.png" );
    label = new QLabel( mainWin );
    label->setPixmap( pm );
    label->setFixedWidth( label->sizeHint().width() );
    label->setPalette( pal );
    hbd->addWidget( label );

    brakesLCD = new QLCDNumber( 1, mainWin );
    brakesLCD->setFrameStyle( QFrame::NoFrame );
    brakesLCD->setSegmentStyle( QLCDNumber::Flat );
    brakesLCD->setPalette( pal );
    brakesLCD->setFixedHeight( 20 );
    hbd->addWidget( brakesLCD );

    hbd->addSpacing( 10 );

    pm.load( sprites_prefix + "powerups/shield.png" );
    label = new QLabel( mainWin );
    label->setPixmap( pm );
    label->setFixedWidth( label->sizeHint().width() );
    label->setPalette( pal );
    hbd->addWidget( label );

    shieldLCD = new QLCDNumber( 1, mainWin );
    shieldLCD->setFrameStyle( QFrame::NoFrame );
    shieldLCD->setSegmentStyle( QLCDNumber::Flat );
    shieldLCD->setPalette( pal );
    shieldLCD->setFixedHeight( 20 );
    hbd->addWidget( shieldLCD );

    hbd->addSpacing( 10 );

    pm.load( sprites_prefix + "powerups/shoot.png" );
    label = new QLabel( mainWin );
    label->setPixmap( pm );
    label->setFixedWidth( label->sizeHint().width() );
    label->setPalette( pal );
    hbd->addWidget( label );

    shootLCD = new QLCDNumber( 1, mainWin );
    shootLCD->setFrameStyle( QFrame::NoFrame );
    shootLCD->setSegmentStyle( QLCDNumber::Flat );
    shootLCD->setPalette( pal );
    shootLCD->setFixedHeight( 20 );
    hbd->addWidget( shootLCD );

    hbd->addStretch( 1 );

    label = new QLabel( tr( "Fuel" ), mainWin );
    label->setFont( smallFont );
    label->setFixedWidth( label->sizeHint().width() + 10 );
    label->setPalette( pal );
    hbd->addWidget( label );

    powerMeter = new KALedMeter( mainWin );
    powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain );
    powerMeter->setRange( MAX_POWER_LEVEL );
    powerMeter->addColorRange( 10, Qt::darkRed );
    powerMeter->addColorRange( 20, QColor(160, 96, 0) );
    powerMeter->addColorRange( 70, Qt::darkGreen );
    powerMeter->setCount( 40 );
    powerMeter->setPalette( pal );
    powerMeter->setFixedSize( 200, 12 );
    hbd->addWidget( powerMeter );

    shipsRemain = 3;
    showHiscores = FALSE;

    actions.insert( Qt::Key_Up, Thrust );
    actions.insert( Qt::Key_Left, RotateLeft );
    actions.insert( Qt::Key_Right, RotateRight );
    actions.insert( Qt::Key_Space, Shoot );
    actions.insert( Qt::Key_Z, Teleport );
    actions.insert( Qt::Key_X, Brake );
    actions.insert( Qt::Key_S, Shield );
    actions.insert( Qt::Key_P, Pause );
    actions.insert( Qt::Key_L, Launch );
    actions.insert( Qt::Key_N, NewGame );

#if defined(Q_OS_SYMBIAN)
    actions.insert( 122, Teleport );
    actions.insert( 120, Brake );
    actions.insert( 115, Shield );
    actions.insert( 112, Pause );
    actions.insert( 108, Launch );
    actions.insert( 110, NewGame );
#endif

    view->showText( tr( "Press N to start playing" ), Qt::yellow );
}