QTfrontend/mapContainer.cpp
changeset 4557 4004bef2aa9d
parent 4550 d300ea498486
child 4560 5d6c7f88db73
equal deleted inserted replaced
4555:85150dfb5959 4557:4004bef2aa9d
    49     mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
    49     mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin),
    50         1,
    50         1,
    51         QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin),
    51         QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin),
    52         QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
    52         QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
    53 
    53 
    54     imageButt = new QPushButton(this);
    54     QWidget* mapWidget = new QWidget(this);
       
    55     mainLayout.addWidget(mapWidget, 0, 0, Qt::AlignHCenter);
       
    56 
       
    57     QGridLayout* mapLayout = new QGridLayout(mapWidget);
       
    58     mapLayout->setMargin(0);
       
    59 
       
    60     imageButt = new QPushButton(mapWidget);
    55     imageButt->setObjectName("imageButt");
    61     imageButt->setObjectName("imageButt");
    56     imageButt->setFixedSize(256 + 6, 128 + 6);
    62     imageButt->setFixedSize(256 + 6, 128 + 6);
    57     imageButt->setFlat(true);
    63     imageButt->setFlat(true);
    58     imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
    64     imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum);
    59     mainLayout.addWidget(imageButt, 0, 0, 1, 2);
    65     mapLayout->addWidget(imageButt, 0, 0, 1, 2);
    60     //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
    66     //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed()));
    61     //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme()));
    67     //connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme()));
    62     connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap()));
    68     connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap()));
    63 
    69 
    64     chooseMap = new QComboBox(this);
    70     chooseMap = new QComboBox(mapWidget);
    65     chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    71     chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    66     chooseMap->addItem(
    72     chooseMap->addItem(
    67 // FIXME - need real icons. Disabling until then
    73 // FIXME - need real icons. Disabling until then
    68 //QIcon(":/res/mapRandom.png"), 
    74 //QIcon(":/res/mapRandom.png"), 
    69 QComboBox::tr("generated map..."));
    75 QComboBox::tr("generated map..."));
   133         }
   139         }
   134     }
   140     }
   135     chooseMap->insertSeparator(missionindex); // separator between missions and maps
   141     chooseMap->insertSeparator(missionindex); // separator between missions and maps
   136 
   142 
   137     connect(chooseMap, SIGNAL(currentIndexChanged(int)), this, SLOT(mapChanged(int)));
   143     connect(chooseMap, SIGNAL(currentIndexChanged(int)), this, SLOT(mapChanged(int)));
   138     mainLayout.addWidget(chooseMap, 1, 1);
   144     mapLayout->addWidget(chooseMap, 1, 1);
   139 
   145 
   140     QLabel * lblMap = new QLabel(tr("Map"), this);
   146     QLabel * lblMap = new QLabel(tr("Map"), mapWidget);
   141     mainLayout.addWidget(lblMap, 1, 0);
   147     mapLayout->addWidget(lblMap, 1, 0);
   142 
   148 
   143     lblFilter = new QLabel(tr("Filter"), this);
   149     lblFilter = new QLabel(tr("Filter"), mapWidget);
   144     mainLayout.addWidget(lblFilter, 2, 0);
   150     mapLayout->addWidget(lblFilter, 2, 0);
   145 
   151 
   146     CB_TemplateFilter = new QComboBox(this);
   152     CB_TemplateFilter = new QComboBox(mapWidget);
   147     CB_TemplateFilter->addItem(tr("All"), 0);
   153     CB_TemplateFilter->addItem(tr("All"), 0);
   148     CB_TemplateFilter->addItem(tr("Small"), 1);
   154     CB_TemplateFilter->addItem(tr("Small"), 1);
   149     CB_TemplateFilter->addItem(tr("Medium"), 2);
   155     CB_TemplateFilter->addItem(tr("Medium"), 2);
   150     CB_TemplateFilter->addItem(tr("Large"), 3);
   156     CB_TemplateFilter->addItem(tr("Large"), 3);
   151     CB_TemplateFilter->addItem(tr("Cavern"), 4);
   157     CB_TemplateFilter->addItem(tr("Cavern"), 4);
   152     CB_TemplateFilter->addItem(tr("Wacky"), 5);
   158     CB_TemplateFilter->addItem(tr("Wacky"), 5);
   153     mainLayout.addWidget(CB_TemplateFilter, 2, 1);
   159     mapLayout->addWidget(CB_TemplateFilter, 2, 1);
   154 
   160 
   155     connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int)));
   161     connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int)));
   156 
   162 
   157     maze_size_label = new QLabel(tr("Type"), this);
   163     maze_size_label = new QLabel(tr("Type"), mapWidget);
   158     mainLayout.addWidget(maze_size_label, 2, 0);
   164     mainLayout.addWidget(maze_size_label, 2, 0);
   159     maze_size_label->hide();
   165     maze_size_label->hide();
   160     maze_size_selection = new QComboBox(this);
   166     maze_size_selection = new QComboBox(mapWidget);
   161     maze_size_selection->addItem(tr("Small tunnels"), 0);
   167     maze_size_selection->addItem(tr("Small tunnels"), 0);
   162     maze_size_selection->addItem(tr("Medium tunnels"), 1);
   168     maze_size_selection->addItem(tr("Medium tunnels"), 1);
   163     maze_size_selection->addItem(tr("Large tunnels"), 2);
   169     maze_size_selection->addItem(tr("Large tunnels"), 2);
   164     maze_size_selection->addItem(tr("Small floating islands"), 3);
   170     maze_size_selection->addItem(tr("Small floating islands"), 3);
   165     maze_size_selection->addItem(tr("Medium floating islands"), 4);
   171     maze_size_selection->addItem(tr("Medium floating islands"), 4);
   166     maze_size_selection->addItem(tr("Large floating islands"), 5);
   172     maze_size_selection->addItem(tr("Large floating islands"), 5);
   167     maze_size_selection->setCurrentIndex(1);
   173     maze_size_selection->setCurrentIndex(1);
   168     maze_size = 1;
   174     maze_size = 1;
   169     mainLayout.addWidget(maze_size_selection, 2, 1);
   175     mapLayout->addWidget(maze_size_selection, 2, 1);
   170     maze_size_selection->hide();
   176     maze_size_selection->hide();
   171     connect(maze_size_selection, SIGNAL(currentIndexChanged(int)), this, SLOT(setMaze_size(int)));
   177     connect(maze_size_selection, SIGNAL(currentIndexChanged(int)), this, SLOT(setMaze_size(int)));
   172 
   178 
   173     gbThemes = new IconedGroupBox(this);
   179     gbThemes = new IconedGroupBox(mapWidget);
   174     gbThemes->setTitleTextPadding(60);
   180     gbThemes->setTitleTextPadding(60);
   175     gbThemes->setContentTopPadding(6);
   181     gbThemes->setContentTopPadding(6);
   176     gbThemes->setTitle(tr("Themes"));
   182     gbThemes->setTitle(tr("Themes"));
   177 
   183 
   178     //gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon
   184     //gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon
   179     mainLayout.addWidget(gbThemes, 0, 2, 3, 2);
   185     mapLayout->addWidget(gbThemes, 0, 2, 3, 1);
   180 
   186 
   181     QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes);
   187     QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes);
   182     gbTLayout->setContentsMargins(0, 0, 0 ,0);
   188     gbTLayout->setContentsMargins(0, 0, 0 ,0);
   183     gbTLayout->setSpacing(0);
   189     gbTLayout->setSpacing(0);
   184     lwThemes = new QListWidget(this);
   190     lwThemes = new QListWidget(mapWidget);
   185     lwThemes->setMinimumHeight(30);
   191     lwThemes->setMinimumHeight(30);
   186     lwThemes->setFixedWidth(140);
   192     lwThemes->setFixedWidth(140);
   187     for (int i = 0; i < Themes->size(); ++i) {
   193     for (int i = 0; i < Themes->size(); ++i) {
   188         QListWidgetItem * lwi = new QListWidgetItem();
   194         QListWidgetItem * lwi = new QListWidgetItem();
   189         lwi->setText(Themes->at(i));
   195         lwi->setText(Themes->at(i));
   208     );
   214     );
   209 
   215 
   210     gbTLayout->addWidget(lwThemes);
   216     gbTLayout->addWidget(lwThemes);
   211     lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
   217     lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
   212 
   218 
   213     QLabel* seedLabel = new QLabel(tr("Seed"), this);
   219     mapLayout->setSizeConstraint(QLayout::SetFixedSize);
   214     mainLayout.addWidget(seedLabel, 3, 0);
   220 
   215     seedEdit = new QLineEdit(this);
   221     QWidget* seedWidget = new QWidget(this);
       
   222     mainLayout.addWidget(seedWidget, 1, 0);
       
   223 
       
   224     QGridLayout* seedLayout = new QGridLayout(seedWidget);
       
   225     seedLayout->setMargin(0);
       
   226 
       
   227     QLabel* seedLabel = new QLabel(tr("Seed"), seedWidget);
       
   228     seedLayout->addWidget(seedLabel, 3, 0);
       
   229     seedEdit = new QLineEdit(seedWidget);
       
   230     seedEdit->setMaxLength(54);
   216     connect(seedEdit, SIGNAL(returnPressed()), this, SLOT(seedEdited()));
   231     connect(seedEdit, SIGNAL(returnPressed()), this, SLOT(seedEdited()));
   217     mainLayout.addWidget(seedEdit, 3, 1, 1, 2);
   232     seedLayout->addWidget(seedEdit, 3, 1);
   218     seedSet = new QPushButton(this);
   233     seedLayout->setColumnStretch(1, 5);
       
   234     seedSet = new QPushButton(seedWidget);
   219     seedSet->setText(QPushButton::tr("Set"));
   235     seedSet->setText(QPushButton::tr("Set"));
   220     connect(seedSet, SIGNAL(clicked()), this, SLOT(seedEdited()));
   236     connect(seedSet, SIGNAL(clicked()), this, SLOT(seedEdited()));
   221     mainLayout.addWidget(seedSet, 3, 3);
   237     seedLayout->setColumnStretch(2, 1);
   222 
   238     seedLayout->addWidget(seedSet, 3, 2);
   223     mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize
       
   224 
   239 
   225     setRandomSeed();
   240     setRandomSeed();
   226     setRandomTheme();
   241     setRandomTheme();
   227 }
   242 }
   228 
   243 
   554     return drawMapScene.encode();
   569     return drawMapScene.encode();
   555 }
   570 }
   556 
   571 
   557 void HWMapContainer::seedEdited()
   572 void HWMapContainer::seedEdited()
   558 {
   573 {
   559     if (seedEdit->text().isEmpty() || seedEdit->text().size() > 54)
   574     if (seedEdit->text().isEmpty())
   560         seedEdit->setText(m_seed);
   575         seedEdit->setText(m_seed);
   561     else
   576     else
   562     {
   577     {
   563         setSeed(seedEdit->text());
   578         setSeed(seedEdit->text());
   564         emit seedChanged(seedEdit->text());
   579         emit seedChanged(seedEdit->text());