QTfrontend/mapContainer.cpp
changeset 1215 0c1c294c0f7e
parent 1214 090f94cd663e
child 1224 0b9fbee5ceda
equal deleted inserted replaced
1214:090f94cd663e 1215:0c1c294c0f7e
    47   imageButt->setFixedSize(256 + 6, 128 + 6);
    47   imageButt->setFixedSize(256 + 6, 128 + 6);
    48   imageButt->setFlat(true);
    48   imageButt->setFlat(true);
    49   imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
    49   imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
    50   mainLayout.addWidget(imageButt, 0, 0, 1, 2);
    50   mainLayout.addWidget(imageButt, 0, 0, 1, 2);
    51   connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
    51   connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
    52   setRandomSeed();
       
    53 
    52 
    54   chooseMap = new QComboBox(this);
    53   chooseMap = new QComboBox(this);
    55   chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    54   chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    56   chooseMap->addItem(QComboBox::tr("generated map..."));
    55   chooseMap->addItem(QComboBox::tr("generated map..."));
    57   chooseMap->addItems(*mapList);
    56   chooseMap->addItems(*mapList);
    74 		QListWidgetItem * lwi = new QListWidgetItem();
    73 		QListWidgetItem * lwi = new QListWidgetItem();
    75 		lwi->setText(Themes->at(i));
    74 		lwi->setText(Themes->at(i));
    76 		lwi->setTextAlignment(Qt::AlignHCenter);
    75 		lwi->setTextAlignment(Qt::AlignHCenter);
    77 		lwThemes->addItem(lwi);
    76 		lwThemes->addItem(lwi);
    78 	}
    77 	}
       
    78 	connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int)));
    79 	
    79 	
    80 	gbTLayout->addWidget(lwThemes);
    80 	gbTLayout->addWidget(lwThemes);
    81 	lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
    81 	lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
    82 	
    82 	
    83   mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
    83   mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
       
    84 
       
    85   setRandomSeed();
    84 }
    86 }
    85 
    87 
    86 void HWMapContainer::setImage(const QImage newImage)
    88 void HWMapContainer::setImage(const QImage newImage)
    87 {
    89 {
    88   QPixmap px(256, 128);
    90   QPixmap px(256, 128);
   139 	connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   141 	connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   140 	pMap->getImage(m_seed.toStdString());
   142 	pMap->getImage(m_seed.toStdString());
   141 
   143 
   142 	if(!Themes->size()) return;
   144 	if(!Themes->size()) return;
   143 	quint32 themeNum = rand() % Themes->size();
   145 	quint32 themeNum = rand() % Themes->size();
   144 	theme = Themes->at(themeNum);
       
   145 	lwThemes->setCurrentRow(themeNum);
   146 	lwThemes->setCurrentRow(themeNum);
       
   147 }
       
   148 
       
   149 void HWMapContainer::themeSelected(int currentRow)
       
   150 {
       
   151 	theme = Themes->at(currentRow);
       
   152 	emit themeChanged(theme);
   146 }
   153 }
   147 
   154 
   148 QString HWMapContainer::getCurrentSeed() const
   155 QString HWMapContainer::getCurrentSeed() const
   149 {
   156 {
   150   return m_seed;
   157   return m_seed;
   181 	}
   188 	}
   182 }
   189 }
   183 
   190 
   184 void HWMapContainer::setTheme(const QString & theme)
   191 void HWMapContainer::setTheme(const QString & theme)
   185 {
   192 {
   186 	this->theme = theme;
   193 	QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly);
       
   194 	if(items.size())
       
   195 		lwThemes->setCurrentItem(items.at(0));
       
   196 	//this->theme = theme;
   187 }
   197 }
   188 
   198 
   189 void HWMapContainer::setRandomSeed()
   199 void HWMapContainer::setRandomSeed()
   190 {
   200 {
   191   m_seed = QUuid::createUuid().toString();
   201   m_seed = QUuid::createUuid().toString();
   192   emit seedChanged(m_seed);
   202   emit seedChanged(m_seed);
   193   changeImage();
   203   changeImage();
   194   emit themeChanged(theme);
   204 }
   195 }