1 /**************************************************************************
5 Copyright (c) Arto Hyvättinen 2010
7 This file is part of Chess Clock software.
9 Chess Clock is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Chess Clock is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
20 **************************************************************************/
22 #include "startwidget.h"
23 #include "timecontrol.h"
25 #include <QVBoxLayout>
26 #include <QHBoxLayout>
27 #include <QApplication>
30 #include <QListWidgetItem>
32 StartWidget::StartWidget(QWidget *parent) :
35 QLabel* titleLabel = new QLabel( qApp->applicationName() );
36 titleLabel->setFont(QFont("Helvetica",32,QFont::Bold));
38 QLabel* copyLabel = new QLabel( tr("© Arto Hyvättinen 2010<br>Free software GPL3"));
39 copyLabel->setTextFormat(Qt::RichText);
40 copyLabel->setWordWrap(true);
42 QLabel* logoLabel = new QLabel;
43 logoLabel->setPixmap( QPixmap(":/rc/pic/logo.png"));
45 QLabel* introLabel = new QLabel( tr("Select game mode"));
46 introLabel->setWordWrap(true);
48 QVBoxLayout* leftLayout = new QVBoxLayout;
49 leftLayout->addWidget(titleLabel);
50 leftLayout->addWidget(logoLabel);
51 leftLayout->addWidget(copyLabel);
53 modeSelect_ = new QListWidget();
54 modeSelect_->setViewMode(QListView::ListMode);
55 modeSelect_->setMovement(QListView::Static);
56 modeSelect_->setSelectionMode(QAbstractItemView::NoSelection);
57 modeSelect_->setIconSize(QSize(40,40 ));
59 connect( modeSelect_, SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(selectControl(QListWidgetItem*)));
61 QVBoxLayout* rightLayout = new QVBoxLayout;
62 rightLayout->addWidget(introLabel);
63 rightLayout->addWidget(modeSelect_);
65 QHBoxLayout* layout = new QHBoxLayout;
66 layout->addLayout(leftLayout);
67 layout->addLayout(rightLayout);
73 void StartWidget::addTimeControl(TimeControl *tc)
75 timeControls_.append(tc);
76 QListWidgetItem* item = new QListWidgetItem(modeSelect_);
77 item->setText( tc->getName());
78 item->setIcon( tc->getIcon());
79 // Store index to UserRole
80 item->setData(Qt::UserRole, timeControls_.size()-1);
84 void StartWidget::selectControl(QListWidgetItem *item)
86 int index=item->data(Qt::UserRole).toInt();
87 TimeControl* tc=timeControls_.at(index);