QTfrontend/ui/widget/mapContainer.cpp
changeset 8475 f605bc59c603
parent 8467 dc53b4b66fa0
child 8619 253750e192e7
equal deleted inserted replaced
8473:555235e90010 8475:f605bc59c603
   248 
   248 
   249     mainLayout.addLayout(twoColumnLayout, 0);
   249     mainLayout.addLayout(twoColumnLayout, 0);
   250 
   250 
   251     /* Set defaults */
   251     /* Set defaults */
   252 
   252 
   253     setRandomTheme();
       
   254     setRandomSeed();
   253     setRandomSeed();
   255     setMazeSize(0);
   254     setMazeSize(0);
   256     setTemplateFilter(0);
   255     setTemplateFilter(0);
   257     staticMapChanged(m_staticMapModel->index(0, 0));
   256     staticMapChanged(m_staticMapModel->index(0, 0));
   258     missionMapChanged(m_missionMapModel->index(0, 0));
   257     missionMapChanged(m_missionMapModel->index(0, 0));
   259     updateTheme(m_themeModel->index(0, 0));
       
   260     changeMapType(MapModel::GeneratedMap);
   258     changeMapType(MapModel::GeneratedMap);
       
   259     setRandomTheme();
   261 }
   260 }
   262 
   261 
   263 void HWMapContainer::setImage(const QImage newImage)
   262 void HWMapContainer::setImage(const QImage newImage)
   264 {
   263 {
   265     QPixmap px(m_previewSize);
   264     QPixmap px(m_previewSize);
   451         intSetMap(map);
   450         intSetMap(map);
   452 }
   451 }
   453 
   452 
   454 void HWMapContainer::setTheme(const QString & theme)
   453 void HWMapContainer::setTheme(const QString & theme)
   455 {
   454 {
   456     QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), Qt::DisplayRole, theme);
   455     QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), ThemeModel::ActualNameRole, theme);
   457 
   456 
   458     if(mdl.size())
   457     if(mdl.size())
   459         updateTheme(mdl.at(0));
   458         updateTheme(mdl.at(0));
   460     else
   459     else
   461         intSetIconlessTheme(theme);
   460         intSetIconlessTheme(theme);
   490 void HWMapContainer::setRandomTheme()
   489 void HWMapContainer::setRandomTheme()
   491 {
   490 {
   492     if(!m_themeModel->rowCount()) return;
   491     if(!m_themeModel->rowCount()) return;
   493     quint32 themeNum = rand() % m_themeModel->rowCount();
   492     quint32 themeNum = rand() % m_themeModel->rowCount();
   494     updateTheme(m_themeModel->index(themeNum));
   493     updateTheme(m_themeModel->index(themeNum));
       
   494     qDebug() << "RANDOM THEME:" << themeNum;
   495 }
   495 }
   496 
   496 
   497 void HWMapContainer::intSetTemplateFilter(int filter)
   497 void HWMapContainer::intSetTemplateFilter(int filter)
   498 {
   498 {
   499     generationStyles->setCurrentRow(filter);
   499     generationStyles->setCurrentRow(filter);
   774     repaint();
   774     repaint();
   775 }
   775 }
   776 
   776 
   777 void HWMapContainer::showThemePrompt()
   777 void HWMapContainer::showThemePrompt()
   778 {
   778 {
   779     ThemePrompt prompt(this);
   779     ThemePrompt prompt(m_themeID, this);
   780     int theme = prompt.exec() - 1; // Since 0 means canceled, so all indexes are +1'd
   780     int theme = prompt.exec() - 1; // Since 0 means canceled, so all indexes are +1'd
   781     if (theme < 0) return;
   781     if (theme < 0) return;
   782 
   782 
   783     QModelIndex current = m_themeModel->index(theme, 0);
   783     QModelIndex current = m_themeModel->index(theme, 0);
   784     updateTheme(current);
   784     updateTheme(current);
   785     emit themeChanged(m_theme);
   785     emit themeChanged(m_theme);
   786 }
   786 }
   787 
   787 
   788 void HWMapContainer::updateTheme(const QModelIndex & current)
   788 void HWMapContainer::updateTheme(const QModelIndex & current)
   789 {
   789 {
   790     m_theme = selectedTheme = current.data().toString();
   790     m_theme = selectedTheme = current.data(ThemeModel::ActualNameRole).toString();
   791     QIcon icon = qVariantValue<QIcon>(current.data(Qt::UserRole));
   791     m_themeID = current.row();
       
   792     QIcon icon = qVariantValue<QIcon>(current.data(Qt::DecorationRole));
   792     QSize iconSize = icon.actualSize(QSize(65535, 65535));
   793     QSize iconSize = icon.actualSize(QSize(65535, 65535));
   793     btnTheme->setFixedHeight(64);
   794     btnTheme->setFixedHeight(64);
   794     btnTheme->setIconSize(iconSize);
   795     btnTheme->setIconSize(iconSize);
   795     btnTheme->setIcon(icon);
   796     btnTheme->setIcon(icon);
   796     btnTheme->setText(tr("Theme: ") + current.data(Qt::DisplayRole).toString());
   797     btnTheme->setText(tr("Theme: ") + current.data(Qt::DisplayRole).toString());