// To show how a nine-sliced image is scaled, we provide the possibility to // alter the text between two different lengths. This will cause the text // area to change size and consequently the image to change size. Container *NineSliceRecipe::createControlPanel() { bool connectResult; Q_UNUSED(connectResult); Container *controlPanel = Container::create(); controlPanel->setVerticalAlignment(VerticalAlignment::Bottom); RadioGroup *ninesliceOptions = new RadioGroup(); Option *fastRecipe = new Option(); fastRecipe->setText("Five Minutes"); fastRecipe->setObjectName("fast"); Option *slowRecipe = new Option(); slowRecipe->setText("Two Hours"); slowRecipe->setObjectName("slow"); ninesliceOptions->add(fastRecipe); ninesliceOptions->add(slowRecipe); connectResult = connect(ninesliceOptions, SIGNAL(selectedIndexChanged(int)), this, SLOT(selectedRecipeChanged(int))); Q_ASSERT(connectResult); ninesliceOptions->setSelectedIndex(1); controlPanel->add(new Divider()); controlPanel->add(ninesliceOptions); return controlPanel; }
SelectionRecipe::SelectionRecipe(Container * parent) : CustomControl(parent) { Container *recipeContainer = new Container(); StackLayout *recipeLayout = new StackLayout(); recipeLayout->setLeftPadding(80); recipeLayout->setRightPadding(80); recipeContainer->setLayout(recipeLayout); Container *checkBoxContainer = new Container(); Label *typeLabel = new Label(); typeLabel->setText("Olive Type"); typeLabel->textStyle()->setBase(SystemDefaults::TextStyles::titleText()); typeLabel->textStyle()->setFontWeight(FontWeight::Bold); typeLabel->setBottomMargin(0); checkBoxContainer->add(typeLabel); // Since we want the CheckBox Control to also have a colored box to represent the // selection of which olives should be in the mix a CustomControl is used, see SelectionCheckBox.cpp. SelectionCheckBox *limonCello = new SelectionCheckBox(); limonCello->setOliveColor(QVariant::fromValue<Color>(Color::fromARGB(0xff808000))); limonCello->setTitle("Limoncello"); limonCello->setLayoutProperties( StackLayoutProperties::create().horizontal(HorizontalAlignment::Fill)); SelectionCheckBox *greek = new SelectionCheckBox(); greek->setOliveColor(QVariant::fromValue<Color>(Color::fromARGB(0xff698B22))); greek->setTitle("Greek"); SelectionCheckBox *kalamata = new SelectionCheckBox(); kalamata->setOliveColor(QVariant::fromValue<Color>(Color::fromARGB(0xff733D1A))); kalamata->setTitle("Kalamata"); checkBoxContainer->add(limonCello); checkBoxContainer->add(greek); checkBoxContainer->add(kalamata); // The two menu selections are separated by a Divider. Divider *divider = new Divider(); divider->setBottomMargin(60); Label *fillingLabel = new Label(); fillingLabel->setText("Filling"); fillingLabel->textStyle()->setBase(SystemDefaults::TextStyles::titleText()); fillingLabel->textStyle()->setFontWeight(FontWeight::Bold); fillingLabel->setBottomMargin(9); // The RadioGroup is a Control that one use if only one option can // be selected at the time. RadioGroupOptions are added to the Control // and by listening for the onSelectedOptionChanged signal its possible // to keep track of what the current selection is. RadioGroup *radioGroup = new RadioGroup(); radioGroup->setDividersVisible(false); Option *stoneOption = new Option(); stoneOption->setText("Stone"); Option *pimentoOption = new Option(); pimentoOption->setText("Pimento"); radioGroup->add(stoneOption); radioGroup->add(pimentoOption); // We listen for changes in selected options on the RadioGroup. connect(radioGroup, SIGNAL(selectedIndexChanged(int)), this, SLOT(fillingSelectedOptionChanged(int))); // Add the controls. recipeContainer->add(checkBoxContainer); recipeContainer->add(divider); recipeContainer->add(fillingLabel); recipeContainer->add(radioGroup); setRoot(recipeContainer); }