// Constructor AboutWindow::AboutWindow(QWidget *parent) : QDialog(parent) { QGridLayout* layout = new QGridLayout( this ); // Make the graphics view fixed size QGraphicsView* graphicsView = new QGraphicsView; graphicsView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); graphicsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); graphicsView->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); // Make the version text bold QLabel* appVersion = new QLabel( "Cache Simulator, Version 0.0.2" ); QFont font; font.setPointSize( 10 ); font.setBold( true ); font.setWeight( 75 ); appVersion->setFont( font ); QLabel* descrip = new QLabel( HELP_TEXT ); descrip->setWordWrap( true ); QSpacerItem* vSpace = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ); // Add widgets to the layout layout->addWidget( graphicsView, 0, 0, 2, 1 ); layout->addWidget( appVersion, 0, 2, 1, 1 ); layout->addWidget( descrip, 1, 2, 1, 1 ); layout->addItem( vSpace, 1, 1, 1, 1 ); // Position a picture of Dr. Plassmann's head over his shoulders _plassHead = new QGraphicsPixmapItem; _plassHead->setPixmap( QPixmap("PlassHead.png") ); _plassHead->setTransformOriginPoint( _plassHead->pixmap().width()/2, _plassHead->pixmap().height()/2 ); _plassHead->setPos( 30, 8 ); _angle = 0; // Tell the view which scene to show QGraphicsScene* scene = new QGraphicsScene; scene->addPixmap( QPixmap("PlassGround.png") ); scene->addItem( _plassHead ); graphicsView->setScene( scene ); // Set a timer to rotate Dr. Plassmann's head every 20 ms _rotateTimer = new QTimer( this ); connect( _rotateTimer, SIGNAL(timeout()), this, SLOT(rotateHead()) ); _angle = 720; _rotateTimer->start( 20 ); // Do not allow resizing setFixedSize( this->sizeHint() ); }
void PieceAppearanceWidget::setupUI() { QLayout * lay = new QGridLayout( this ); lay->setSpacing(0); lay->setContentsMargins(0,0,0,0); QGraphicsView * v = this->impl->gv = //new QGraphicsView( impl->gs.scene() ) new QBoardView( impl->gs ) ; v->setTransformationAnchor(QGraphicsView::NoAnchor); #if 0 v->setAlignment(Qt::AlignLeft | Qt::AlignTop); v->setInteractive(true); // required to get mouse events to the children v->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); v->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); v->setDragMode(QGraphicsView::RubberBandDrag); v->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); #endif v->setBackgroundBrush(QColor("#abb8fb")); v->viewport()->setObjectName( "PieceAppearanceWidget"); lay->addWidget( v ); QStringList tip; tip << "<html><body>These widgets are appearance templates for game pieces.\n" << "Edit them by right-clicking them.\n" << "Select a template by left-clicking it. " << "QBoard will use the selected template as the default look\n" << "for newly-added pieces which are loaded from image files.\n" << "This list will be saved automatically when QBoard exits,\n" << "and loaded when QBoard starts up.</body></html>" ; impl->gv->setToolTip( tip.join("") ); }