Exemplo n.º 1
0
EmojiWidget::EmojiWidget(EmojiManager *emojiManager, QWidget *parent) :
    QFrame(parent),
    emojiManager(emojiManager)
{

    Q_ASSERT(emojiManager);

    mainLayout = new QVBoxLayout();
    mainLayout->setContentsMargins(0, 0, 0, 0);

    auto categoriesLayout = createCategoriesLayout();
    mainLayout->addLayout(categoriesLayout);
    mainLayout->setAlignment(categoriesLayout, Qt::AlignTop);

    scrollArea = new QScrollArea();
    scrollArea->setSizeAdjustPolicy(QScrollArea::AdjustToContents);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    scrollArea->setWidgetResizable(true);
    scrollArea->setWidget(new QWidget(this));
    uint preferredHeight = EmojiWidget::BUTTONS_SIZE * 3; // 3 rows
    scrollArea->setMaximumHeight(preferredHeight);
    scrollArea->setMinimumHeight(preferredHeight);
    scrollArea->setFrameStyle(QFrame::NoFrame);
    scrollArea->widget()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);

    mainLayout->addWidget(scrollArea, 1, Qt::AlignTop);

    setLayout(mainLayout);

    recentButton->setEnabled(emojiManager->hasRecents());

}
Exemplo n.º 2
0
/**
 * Lay out the widgets (portrait mode).
 */
void HomeScreen::setupUI()
{
	// Get the handle to the main layout and the screen.
	mMainLayout = getMainLayout();
	mScreen = getScreen();
	mLabel = getTopLabel();
	mSearchButton = getTopButtonRight();
	// We do not need a Back button in this screen,
	// so we can dismiss it.
	MAWidgetHandle backBtn = getTopButtonLeft();
	maWidgetDestroy(backBtn);

	// The creation of the main layout is already done in the base class
	// constructor, called at derived object creation.
	// So, we can use  a handle for the main layout at any point.

	// Set the text for the button widget in the top layout.
	setButtonText(mSearchButton, " NEXT ");

	// Add a label before the Progress bar.
	mProgressLabel = createLabel(
			mScreenWidth,
			" Please wait...",
			DARK_GREY,
			mFontSize );
	// Show it only after Search is pressed.
	maWidgetSetProperty(mProgressLabel,MAW_WIDGET_VISIBLE, "false");
	maWidgetAddChild(mMainLayout, mProgressLabel);

	// Create a progress bar for the Search action.
	mProgressBar = createProgressBar();

	// Set the range of the progress bar from 0..100
	setWidgetProperty(
		mProgressBar, MAW_PROGRESS_BAR_MAX, PROGRESS_BAR_MAX_VALUE);
	// Set the progress value to 0.
	setWidgetProperty(
		mProgressBar, MAW_PROGRESS_BAR_PROGRESS, 0);
	// Hide the widget at first, and display it when a Search is being performed.
	maWidgetSetProperty(
		mProgressBar, MAW_WIDGET_VISIBLE, "false");

	maWidgetAddChild(mMainLayout, mProgressBar);

	// Next, fill the remaining space with an edit box and
	// some check boxes for the categories.
	MAWidgetHandle hintLabel = createLabel(
			mScreenWidth,
			MESSAGE_EDITBOX_HINT.c_str(),
			BLUE,
			mFontSize);
	maWidgetSetProperty(
		hintLabel,MAW_LABEL_TEXT_HORIZONTAL_ALIGNMENT,MAW_ALIGNMENT_LEFT);
	maWidgetAddChild(mMainLayout, hintLabel);

	// Add only one edit box.
	mEditBox = createEditBox(mScreenWidth, MAW_CONSTANT_WRAP_CONTENT);
	maWidgetAddChild(mMainLayout, mEditBox);

	// Add a small spacer before the categories.
	maWidgetAddChild(mMainLayout, createSpacer(mScreenWidth, mPaddingSize));

	// Add the layout with checkable categories.
	maWidgetAddChild( mMainLayout, createCategoriesLayout());

	// Add a label for the slider.
	MAWidgetHandle sliderLabel = createLabel(
			mScreenWidth,
			" Please select the results limit. ",
			BLUE,mFontSize);
	maWidgetAddChild(mMainLayout, sliderLabel);

	// Create a slider control for selecting the desired number of results.
	mSlider = createSlider();
	setWidgetProperty(mSlider, MAW_SLIDER_MAX, SLIDER_MAX_VALUE);
	// Set the current slider value to 10.
	setWidgetProperty(mSlider, MAW_SLIDER_VALUE, 10);
	maWidgetAddChild(mMainLayout, mSlider);

	// Add two labels with minimum and maximum value of the slider.
	MAWidgetHandle valuesLayout = maWidgetCreate(MAW_HORIZONTAL_LAYOUT);
	MAWidgetHandle minValue = createLabel(
			mScreenWidth / 2,
			 " 0 ",
			 DARK_GREY,
			 mFontSize);
	maWidgetSetProperty(minValue, MAW_LABEL_TEXT_HORIZONTAL_ALIGNMENT,
			MAW_ALIGNMENT_LEFT);
	maWidgetAddChild(valuesLayout, minValue);

	MAWidgetHandle maxValue = createLabel(
			mScreenWidth / 2,
			"", DARK_GREY,
			mFontSize);
	setWidgetProperty(maxValue, MAW_LABEL_TEXT, SLIDER_MAX_VALUE);
	maWidgetSetProperty(maxValue, MAW_LABEL_TEXT_HORIZONTAL_ALIGNMENT,
			MAW_ALIGNMENT_RIGHT);
	maWidgetAddChild(valuesLayout, maxValue);

	// Add this layout to the main one.
	maWidgetAddChild(mMainLayout, valuesLayout);
}