summaryrefslogtreecommitdiffstats
path: root/pacman-c++/mainwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pacman-c++/mainwidget.cpp')
-rw-r--r--pacman-c++/mainwidget.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/pacman-c++/mainwidget.cpp b/pacman-c++/mainwidget.cpp
index bdc2da1..b69e0c0 100644
--- a/pacman-c++/mainwidget.cpp
+++ b/pacman-c++/mainwidget.cpp
@@ -9,8 +9,6 @@
9MainWidget::MainWidget(QWidget *parent) 9MainWidget::MainWidget(QWidget *parent)
10: SceneHolder(parent), m_currentKey(0), m_running(false) 10: SceneHolder(parent), m_currentKey(0), m_running(false)
11{ 11{
12 createGui();
13
14 m_color = connectToServer(); 12 m_color = connectToServer();
15 if (m_color == Color::none) 13 if (m_color == Color::none)
16 { 14 {
@@ -24,6 +22,7 @@ MainWidget::MainWidget(QWidget *parent)
24 } 22 }
25 23
26 /* call updateMap after m_color ist set! */ 24 /* call updateMap after m_color ist set! */
25 createGui();
27 updateMap(Util::createDemoMap()); 26 updateMap(Util::createDemoMap());
28 27
29 if (m_socket != NULL) 28 if (m_socket != NULL)
@@ -42,16 +41,14 @@ void MainWidget::createGui()
42{ 41{
43 setFocusPolicy(Qt::StrongFocus); 42 setFocusPolicy(Qt::StrongFocus);
44 43
45 QVBoxLayout *layout = new QVBoxLayout(this); 44 /* first one is always the own score */
46 QHBoxLayout *scoreLayout = new QHBoxLayout(); 45 QHBoxLayout *scoreLayout = new QHBoxLayout();
47
48 for (unsigned int i = 0; Color::order[i] != Color::none ; ++i) 46 for (unsigned int i = 0; Color::order[i] != Color::none ; ++i)
49 { 47 {
50 QGroupBox *scoreBox = new QGroupBox(QString("Spieler %1").arg(i + 1), this); 48 QGroupBox *scoreBox = new QGroupBox(QString("Spieler %1").arg(i + 1), this);
51 scoreBox->setObjectName(QString("actor%1").arg(i + 1)); 49 scoreBox->setObjectName(QString("actor%1").arg(i + 1));
52 scoreBox->setCheckable(true); 50 scoreBox->setCheckable(true);
53 connect(scoreBox, SIGNAL(clicked()), this, SLOT(playerScoreClicked())); 51 connect(scoreBox, SIGNAL(clicked()), this, SLOT(playerScoreClicked()));
54 scoreLayout->addWidget(scoreBox);
55 52
56 QGridLayout *playerLayout = new QGridLayout(); 53 QGridLayout *playerLayout = new QGridLayout();
57 scoreBox->setLayout(playerLayout); 54 scoreBox->setLayout(playerLayout);
@@ -62,17 +59,22 @@ void MainWidget::createGui()
62 playerLayout->addWidget(new QLabel("", this), 0, 1); 59 playerLayout->addWidget(new QLabel("", this), 0, 1);
63 playerLayout->addWidget(new QLabel("", this), 1, 1); 60 playerLayout->addWidget(new QLabel("", this), 1, 1);
64 61
62 if (Color::order[i] == m_color)
63 scoreLayout->insertWidget(0, scoreBox);
64 else
65 scoreLayout->addWidget(scoreBox);
65 m_playerScoreLayouts.append(playerLayout); 66 m_playerScoreLayouts.append(playerLayout);
66 } 67 }
67 68
69 QVBoxLayout *layout = new QVBoxLayout(this);
70 layout->addLayout(scoreLayout);
71
68 QGraphicsView *window = new QGraphicsView(m_scene, this); 72 QGraphicsView *window = new QGraphicsView(m_scene, this);
69 window->setFrameStyle(0); 73 window->setFrameStyle(0);
70 window->setAlignment(Qt::AlignLeft | Qt::AlignTop); 74 window->setAlignment(Qt::AlignLeft | Qt::AlignTop);
71 window->setFixedSize(Constants::map_size_pixel.width, Constants::map_size_pixel.height); 75 window->setFixedSize(Constants::map_size_pixel.width, Constants::map_size_pixel.height);
72 window->setWindowFlags(window->windowFlags() & ~Qt::WindowMaximizeButtonHint); 76 window->setWindowFlags(window->windowFlags() & ~Qt::WindowMaximizeButtonHint);
73 window->setFocusPolicy(Qt::NoFocus); 77 window->setFocusPolicy(Qt::NoFocus);
74
75 layout->addLayout(scoreLayout);
76 layout->addWidget(window); 78 layout->addWidget(window);
77 79
78 QFile css(":/stylesheet"); 80 QFile css(":/stylesheet");