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("<b>Select game mode →</b>"));
46 introLabel->setWordWrap(true);
48 QVBoxLayout* leftLayout = new QVBoxLayout;
49 leftLayout->addWidget(titleLabel);
50 leftLayout->addWidget(introLabel);
51 leftLayout->addWidget(logoLabel);
52 leftLayout->addWidget(copyLabel);
54 modeSelect_ = new QListWidget();
55 modeSelect_->setViewMode(QListView::ListMode);
56 modeSelect_->setMovement(QListView::Static);
57 modeSelect_->setSelectionMode(QAbstractItemView::NoSelection);
58 modeSelect_->setIconSize(QSize(40,40 ));
60 connect( modeSelect_, SIGNAL(itemClicked(QListWidgetItem*)),this,SLOT(selectControl(QListWidgetItem*)));
62 // QVBoxLayout* rightLayout = new QVBoxLayout;
63 // rightLayout->addWidget(introLabel);
64 // rightLayout->addWidget(modeSelect_);
66 QHBoxLayout* layout = new QHBoxLayout;
67 layout->addLayout(leftLayout);
68 layout->addWidget(modeSelect_);
74 void StartWidget::addTimeControl(TimeControl *tc)
76 timeControls_.append(tc);
77 QListWidgetItem* item = new QListWidgetItem(modeSelect_);
78 item->setText( tc->getName());
79 item->setIcon( tc->getIcon());
80 // Store index to UserRole
81 item->setData(Qt::UserRole, timeControls_.size()-1);
85 void StartWidget::selectControl(QListWidgetItem *item)
87 int index=item->data(Qt::UserRole).toInt();
88 TimeControl* tc=timeControls_.at(index);