41 QGroupBox(parent) |
42 QGroupBox(parent) |
42 , mainLayout(this) |
43 , mainLayout(this) |
43 , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}") |
44 , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}") |
44 { |
45 { |
45 mainLayout.setMargin(0); |
46 mainLayout.setMargin(0); |
46 |
47 setMinimumHeight(310); |
47 pMapContainer = new HWMapContainer(this); |
48 setMaximumHeight(447); |
48 mainLayout.addWidget(pMapContainer, 0, 0, Qt::AlignHCenter | Qt::AlignTop); |
49 setMinimumWidth(470); |
49 pMapContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
50 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
50 pMapContainer->setFixedSize(460, 275); |
51 |
51 |
52 // Easy containers for the map/game options in either stacked or tabbed mode |
52 IconedGroupBox *GBoxOptions = new IconedGroupBox(this); |
53 |
53 m_childWidgets << GBoxOptions; |
54 mapContainerFree = new QWidget(); |
54 GBoxOptions->setFixedWidth(pMapContainer->width()); |
55 mapContainerTabbed = new QWidget(); |
55 GBoxOptions->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
56 optionsContainerFree = new QWidget(); |
56 mainLayout.addWidget(GBoxOptions, 1, 0); |
57 optionsContainerTabbed = new QWidget(); |
57 |
58 tabbed = false; |
58 QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions); |
59 |
59 |
60 // Container for when in tabbed mode |
60 GBoxOptions->setTitle(tr("Game Options")); |
61 |
61 GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), GBoxOptions), 1, 0); |
62 tabs = new QTabWidget(this); |
62 |
63 tabs->setFixedWidth(470); |
63 Scripts = new QComboBox(GBoxOptions); |
64 tabs->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
|
65 tabs->addTab(mapContainerTabbed, tr("Map")); |
|
66 tabs->addTab(optionsContainerTabbed, tr("Game options")); |
|
67 tabs->setObjectName("gameCfgWidgetTabs"); |
|
68 mainLayout.addWidget(tabs, 1); |
|
69 tabs->setVisible(false); |
|
70 |
|
71 // Container for when in stacked mode |
|
72 |
|
73 StackContainer = new QWidget(); |
|
74 StackContainer->setObjectName("gameStackContainer"); |
|
75 mainLayout.addWidget(StackContainer, 1); |
|
76 QVBoxLayout * stackLayout = new QVBoxLayout(StackContainer); |
|
77 |
|
78 // Map options |
|
79 |
|
80 pMapContainer = new HWMapContainer(mapContainerFree); |
|
81 stackLayout->addWidget(mapContainerFree, 0, Qt::AlignHCenter); |
|
82 pMapContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
83 pMapContainer->setFixedSize(width() - 14, 278); |
|
84 mapContainerFree->setFixedSize(pMapContainer->width(), pMapContainer->height()); |
|
85 |
|
86 // Horizontal divider |
|
87 |
|
88 QFrame * divider = new QFrame(); |
|
89 divider->setFrameShape(QFrame::HLine); |
|
90 divider->setFrameShadow(QFrame::Plain); |
|
91 stackLayout->addWidget(divider, 0, Qt::AlignBottom); |
|
92 //stackLayout->setRowMinimumHeight(1, 10); |
|
93 |
|
94 // Game options |
|
95 |
|
96 optionsContainerTabbed->setContentsMargins(0, 0, 0, 0); |
|
97 optionsContainerFree->setFixedSize(width() - 14, 140); |
|
98 stackLayout->addWidget(optionsContainerFree, 0, Qt::AlignHCenter); |
|
99 |
|
100 OptionsInnerContainer = new QWidget(optionsContainerFree); |
|
101 m_childWidgets << OptionsInnerContainer; |
|
102 OptionsInnerContainer->setFixedSize(optionsContainerFree->width(), optionsContainerFree->height()); |
|
103 OptionsInnerContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
|
104 GBoxOptionsLayout = new QGridLayout(OptionsInnerContainer); |
|
105 |
|
106 GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Style"), this), 1, 0); |
|
107 |
|
108 Scripts = new QComboBox(this); |
64 GBoxOptionsLayout->addWidget(Scripts, 1, 1); |
109 GBoxOptionsLayout->addWidget(Scripts, 1, 1); |
65 |
110 |
66 Scripts->setModel(DataManager::instance().gameStyleModel()); |
111 Scripts->setModel(DataManager::instance().gameStyleModel()); |
67 m_curScript = Scripts->currentText(); |
112 m_curScript = Scripts->currentText(); |
68 connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int))); |
113 connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int))); |
69 |
114 |
70 QWidget *SchemeWidget = new QWidget(GBoxOptions); |
115 QWidget *SchemeWidget = new QWidget(this); |
71 GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2); |
116 GBoxOptionsLayout->addWidget(SchemeWidget, 2, 0, 1, 2); |
72 |
117 |
73 QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget); |
118 QGridLayout *SchemeWidgetLayout = new QGridLayout(SchemeWidget); |
74 SchemeWidgetLayout->setMargin(0); |
119 SchemeWidgetLayout->setMargin(0); |
75 |
120 |
120 connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); |
165 connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); |
121 connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap())); |
166 connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap())); |
122 connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &))); |
167 connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &))); |
123 |
168 |
124 connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews())); |
169 connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews())); |
|
170 } |
|
171 |
|
172 void GameCFGWidget::setTabbed(bool tabbed) |
|
173 { |
|
174 if (tabbed && !this->tabbed) |
|
175 { // Make tabbed |
|
176 tabs->setCurrentIndex(0); |
|
177 StackContainer->setVisible(false); |
|
178 tabs->setVisible(true); |
|
179 pMapContainer->setParent(mapContainerTabbed); |
|
180 OptionsInnerContainer->setParent(optionsContainerTabbed); |
|
181 pMapContainer->setVisible(true); |
|
182 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
|
183 this->tabbed = true; |
|
184 } |
|
185 else if (!tabbed && this->tabbed) |
|
186 { // Make stacked |
|
187 pMapContainer->setParent(mapContainerFree); |
|
188 OptionsInnerContainer->setParent(optionsContainerFree); |
|
189 tabs->setVisible(false); |
|
190 StackContainer->setVisible(true); |
|
191 pMapContainer->setVisible(true); |
|
192 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
193 this->tabbed = false; |
|
194 } |
125 } |
195 } |
126 |
196 |
127 void GameCFGWidget::jumpToSchemes() |
197 void GameCFGWidget::jumpToSchemes() |
128 { |
198 { |
129 emit goToSchemes(GameSchemes->currentIndex()); |
199 emit goToSchemes(GameSchemes->currentIndex()); |