QTfrontend/mapContainer.cpp
changeset 1318 18da1c5e960d
parent 1248 8c77eec56bf4
child 1333 b0b0510eb82d
equal deleted inserted replaced
1317:13cf8c5a7428 1318:18da1c5e960d
    48   imageButt->setFixedSize(256 + 6, 128 + 6);
    48   imageButt->setFixedSize(256 + 6, 128 + 6);
    49   imageButt->setFlat(true);
    49   imageButt->setFlat(true);
    50   imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
    50   imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
    51   mainLayout.addWidget(imageButt, 0, 0, 1, 2);
    51   mainLayout.addWidget(imageButt, 0, 0, 1, 2);
    52   connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
    52   connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
       
    53   connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme()));
    53 
    54 
    54   chooseMap = new QComboBox(this);
    55   chooseMap = new QComboBox(this);
    55   chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    56   chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    56   chooseMap->addItem(QComboBox::tr("generated map..."));
    57   chooseMap->addItem(QComboBox::tr("generated map..."));
    57   chooseMap->addItems(*mapList);
    58   chooseMap->addItems(*mapList);
    86 	lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
    87 	lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
    87 	
    88 	
    88   mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
    89   mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
    89 
    90 
    90   setRandomSeed();
    91   setRandomSeed();
       
    92   setRandomTheme();
    91 }
    93 }
    92 
    94 
    93 void HWMapContainer::setImage(const QImage newImage)
    95 void HWMapContainer::setImage(const QImage newImage)
    94 {
    96 {
    95   QPixmap px(256, 128);
    97   QPixmap px(256, 128);
   143 void HWMapContainer::changeImage()
   145 void HWMapContainer::changeImage()
   144 {
   146 {
   145 	pMap = new HWMap();
   147 	pMap = new HWMap();
   146 	connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   148 	connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage)));
   147 	pMap->getImage(m_seed.toStdString());
   149 	pMap->getImage(m_seed.toStdString());
   148 
       
   149 	if(!Themes->size()) return;
       
   150 	quint32 themeNum = rand() % Themes->size();
       
   151 	lwThemes->setCurrentRow(themeNum);
       
   152 }
   150 }
   153 
   151 
   154 void HWMapContainer::themeSelected(int currentRow)
   152 void HWMapContainer::themeSelected(int currentRow)
   155 {
   153 {
   156 	theme = Themes->at(currentRow);
   154 	theme = Themes->at(currentRow);
   197 void HWMapContainer::setTheme(const QString & theme)
   195 void HWMapContainer::setTheme(const QString & theme)
   198 {
   196 {
   199 	QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly);
   197 	QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly);
   200 	if(items.size())
   198 	if(items.size())
   201 		lwThemes->setCurrentItem(items.at(0));
   199 		lwThemes->setCurrentItem(items.at(0));
   202 	//this->theme = theme;
       
   203 }
   200 }
   204 
   201 
   205 void HWMapContainer::setRandomSeed()
   202 void HWMapContainer::setRandomSeed()
   206 {
   203 {
   207   m_seed = QUuid::createUuid().toString();
   204   m_seed = QUuid::createUuid().toString();
   208   emit seedChanged(m_seed);
   205   emit seedChanged(m_seed);
   209   changeImage();
   206   changeImage();
   210 }
   207 }
       
   208 
       
   209 void HWMapContainer::setRandomTheme()
       
   210 {
       
   211 	if(!Themes->size()) return;
       
   212 	quint32 themeNum = rand() % Themes->size();
       
   213 	lwThemes->setCurrentRow(themeNum);
       
   214 }