QTfrontend/mapContainer.cpp
changeset 1802 dd148e2506e2
parent 1797 fedd8649fdd9
child 1810 4059cafd1da7
equal deleted inserted replaced
1801:bc0c5c21376e 1802:dd148e2506e2
    88 	mainLayout.addWidget(chooseMap, 1, 1);
    88 	mainLayout.addWidget(chooseMap, 1, 1);
    89 
    89 
    90 	QLabel * lblMap = new QLabel(tr("Map"), this);
    90 	QLabel * lblMap = new QLabel(tr("Map"), this);
    91 	mainLayout.addWidget(lblMap, 1, 0);
    91 	mainLayout.addWidget(lblMap, 1, 0);
    92 
    92 
       
    93 	lblFilter = new QLabel(tr("Filter"), this);
       
    94 	mainLayout.addWidget(lblFilter, 2, 0);
       
    95 
       
    96 	CB_TemplateFilter = new QComboBox(this);
       
    97     CB_TemplateFilter->addItem(tr("All"), 0);
       
    98     CB_TemplateFilter->addItem(tr("Small"), 1);
       
    99     CB_TemplateFilter->addItem(tr("Medium"), 2);
       
   100     CB_TemplateFilter->addItem(tr("Large"), 3);
       
   101     CB_TemplateFilter->addItem(tr("Cavern"), 4);
       
   102     CB_TemplateFilter->addItem(tr("Wacky"), 5);
       
   103 	mainLayout.addWidget(CB_TemplateFilter, 2, 1);
       
   104 
       
   105 	connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int)));
       
   106 
    93 	gbThemes = new IconedGroupBox(this);
   107 	gbThemes = new IconedGroupBox(this);
    94 	gbThemes->setTitleTextPadding(60);
   108 	gbThemes->setTitleTextPadding(60);
    95 	gbThemes->setTitle(tr("Themes"));
   109 	gbThemes->setTitle(tr("Themes"));
    96 
   110 
    97 	//gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon
   111 	//gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon
    98 	mainLayout.addWidget(gbThemes, 0, 2, 2, 1);
   112 	mainLayout.addWidget(gbThemes, 0, 2, 3, 1);
    99 	
   113 	
   100 	QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes);
   114 	QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes);
   101 	gbTLayout->setContentsMargins(0, 0, 0 ,0);
   115 	gbTLayout->setContentsMargins(0, 0, 0 ,0);
   102 	gbTLayout->setSpacing(0);
   116 	gbTLayout->setSpacing(0);
   103 	lwThemes = new QListWidget(this);
   117 	lwThemes = new QListWidget(this);
   108 		lwi->setText(Themes->at(i));
   122 		lwi->setText(Themes->at(i));
   109 		lwi->setTextAlignment(Qt::AlignHCenter);
   123 		lwi->setTextAlignment(Qt::AlignHCenter);
   110 		lwThemes->addItem(lwi);
   124 		lwThemes->addItem(lwi);
   111 	}
   125 	}
   112 	connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int)));
   126 	connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int)));
   113 	
   127 
       
   128     // override default style to tighten up theme scroller
       
   129 	lwThemes->setStyleSheet(QString(
       
   130 		"QListWidget{"
       
   131 			"border: solid;"
       
   132 			"border-width: 0px;"
       
   133 			"border-radius: 0px;"
       
   134 			"border-color: transparent;"
       
   135 			"background-color: #0d0544;"
       
   136 			"color: #ffcc00;"
       
   137 			"font: bold 14px;"
       
   138 			"}"
       
   139 		)
       
   140 	);
       
   141  
   114 	gbTLayout->addWidget(lwThemes);
   142 	gbTLayout->addWidget(lwThemes);
   115 	lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
   143 	lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
   116 	
   144 	
   117 	mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
   145 	mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
   118 
   146 
   149 void HWMapContainer::mapChanged(int index)
   177 void HWMapContainer::mapChanged(int index)
   150 {
   178 {
   151 	if(!index) {
   179 	if(!index) {
   152 		changeImage();
   180 		changeImage();
   153 		gbThemes->show();
   181 		gbThemes->show();
       
   182         lblFilter->show();
       
   183         CB_TemplateFilter->show();
   154 		emit mapChanged("+rnd+");
   184 		emit mapChanged("+rnd+");
   155 		emit themeChanged(chooseMap->itemData(0).toString());
   185 		emit themeChanged(chooseMap->itemData(0).toString());
   156 	} else
   186 	} else
   157 	{
   187 	{
   158 		loadMap(index);
   188 		loadMap(index);
   159 		gbThemes->hide();
   189 		gbThemes->hide();
       
   190         lblFilter->hide();
       
   191         CB_TemplateFilter->hide();
   160 		emit mapChanged(chooseMap->currentText());
   192 		emit mapChanged(chooseMap->currentText());
   161 	}
   193 	}
   162 }
   194 }
   163 
   195 
   164 void HWMapContainer::loadMap(int index)
   196 void HWMapContainer::loadMap(int index)
   197 void HWMapContainer::changeImage()
   229 void HWMapContainer::changeImage()
   198 {
   230 {
   199 	pMap = new HWMap();
   231 	pMap = new HWMap();
   200 	connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   232 	connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   201 	connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int)));
   233 	connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int)));
   202 	pMap->getImage(m_seed.toStdString(), templateFilter);
   234 	pMap->getImage(m_seed.toStdString(), getTemplateFilter());
   203 }
   235 }
   204 
   236 
   205 void HWMapContainer::themeSelected(int currentRow)
   237 void HWMapContainer::themeSelected(int currentRow)
   206 {
   238 {
   207 	QString theme = Themes->at(currentRow);
   239 	QString theme = Themes->at(currentRow);
   230 }
   262 }
   231 
   263 
   232 int HWMapContainer::getCurrentHHLimit() const
   264 int HWMapContainer::getCurrentHHLimit() const
   233 {
   265 {
   234 	return hhLimit;
   266 	return hhLimit;
       
   267 }
       
   268 
       
   269 quint32 HWMapContainer::getTemplateFilter() const
       
   270 {
       
   271 	return CB_TemplateFilter->itemData(CB_TemplateFilter->currentIndex()).toInt();
   235 }
   272 }
   236 
   273 
   237 void HWMapContainer::resizeEvent ( QResizeEvent * event )
   274 void HWMapContainer::resizeEvent ( QResizeEvent * event )
   238 {
   275 {
   239   //imageButt->setIconSize(imageButt->size());
   276   //imageButt->setIconSize(imageButt->size());
   286 	lwThemes->setCurrentRow(themeNum);
   323 	lwThemes->setCurrentRow(themeNum);
   287 }
   324 }
   288 
   325 
   289 void HWMapContainer::setTemplateFilter(int filter)
   326 void HWMapContainer::setTemplateFilter(int filter)
   290 {
   327 {
   291    templateFilter = filter;   
   328 	CB_TemplateFilter->setCurrentIndex(filter);
   292 }
   329 }
       
   330 
       
   331 void HWMapContainer::templateFilterChanged(int filter)
       
   332 {
       
   333     changeImage();
       
   334 	emit newTemplateFilter(filter);
       
   335 }
       
   336