QWidget * ToolBar::createActionWidget(QAction *before, ToolBarAction &action) { if (action.actionName.startsWith(QLatin1String("__separator"))) return createSeparator(before, action); else if (action.actionName.startsWith(QLatin1String("__spacer"))) return createSpacer(before, action); else return createPushButton(before, action); }
BtFindWidget::BtFindWidget(QWidget* parent) : QWidget(parent) { createLayout(); createToolButton(CResMgr::findWidget::icon_close(), "", SLOT(hide())); createTextEditor(); createToolButton(CResMgr::findWidget::icon_previous(), tr("Previous"), SLOT(findPrevious())); createToolButton(CResMgr::findWidget::icon_next(), tr("Next"), SLOT(findNext())); createCaseCheckBox(); createSpacer(); setFocusProxy(m_textEditor); }
void LoginSheet::createCentralWidget() { QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical, centralWidget()); mainLayout->setContentsMargins(0,0,0,0); mainLayout->setSpacing(0); //% "Connect to Service" MLabel *label = new MLabel(qtTrId("xx_wg_sheets_connect_service")); label->setStyleName("CommonTitle"); label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); mainLayout->addItem(label); mainLayout->addItem(createSpacer()); //% "Username:"******"xx_wg_sheets_username")); label->setStyleName("CommonFieldLabel"); mainLayout->addItem(label); userNameTextEdit = new MTextEdit; userNameTextEdit->setStyleName("CommonSingleInputFieldLabeled"); mainLayout->addItem(userNameTextEdit); mainLayout->addItem(createSpacer()); //% "Password:"******"xx_wg_sheets_password")); label->setStyleName("CommonFieldLabel"); mainLayout->addItem(label); MTextEdit *textEdit = new MTextEdit; textEdit->setStyleName("CommonSingleInputFieldLabeled"); textEdit->setEchoMode(MTextEditModel::Password); mainLayout->addItem(textEdit); mainLayout->addStretch(); }
void Kolf::closeGame() { if (game) { if (game->askSave(true)) return; game->pause(); } filename = QString::null; editingEnded(); delete game; game = 0; loadedGame = QString::null; editingAction->setChecked(false); setEditingEnabled(false); endAction->setEnabled(false); aboutAction->setEnabled(false); highScoreAction->setEnabled(false); printAction->setEnabled(false); saveAction->setEnabled(false); saveAsAction->setEnabled(false); saveGameAction->setEnabled(false); saveGameAsAction->setEnabled(false); setHoleMovementEnabled(false); setHoleOtherEnabled(false); clearHoleAction->setEnabled(false); newHoleAction->setEnabled(false); newAction->setEnabled(true); loadGameAction->setEnabled(true); tutorialAction->setEnabled(true); titleChanged(QString::null); updateModified(false); QTimer::singleShot(100, this, SLOT(createSpacer())); }
void TimelineToolBar::createLeftControls() { auto addActionToGroup = [&](QAction *action) { addAction(action); m_grp << action; }; auto addWidgetToGroup = [&](QWidget *widget) { addWidget(widget); m_grp << widget; }; auto addSpacingToGroup = [&](int width) { auto *widget = new QWidget; widget->setFixedWidth(width); addWidget(widget); m_grp << widget; }; addSpacingToGroup(5); auto *settingsAction = createAction(TimelineConstants::C_SETTINGS, TimelineIcons::ANIMATION.icon(), tr("Timeline Settings"), QKeySequence(Qt::Key_S)); connect(settingsAction, &QAction::triggered, this, &TimelineToolBar::settingDialogClicked); addActionToGroup(settingsAction); addWidgetToGroup(createSpacer()); m_timelineLabel = new QLabel(this); m_timelineLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); addWidgetToGroup(m_timelineLabel); }
/** * Create screen's UI. */ void LoadingScreen::createUI() { // Create and add main layout to the screen. mMainLayout = new NativeUI::VerticalLayout(); this->setMainWidget(mMainLayout); // Add spacer. mMainLayout->addChild(new NativeUI::VerticalLayout); // Add ActivityIndicatior. NativeUI::ActivityIndicator* activityIndicator = new NativeUI::ActivityIndicator(); mMainLayout->addChild(activityIndicator); if (isWindowsPhone()) { // For WP7 platform add an Label widget. NativeUI::Label* loading = new NativeUI::Label(LOADING_LABEL_TEXT); loading->setTextHorizontalAlignment(MAW_ALIGNMENT_CENTER); loading->fillSpaceHorizontally(); mMainLayout->addChild(loading); mMainLayout->addChild(createSpacer(SPACER_HEIGHT)); activityIndicator->fillSpaceHorizontally(); } else { mMainLayout->setChildHorizontalAlignment(MAW_ALIGNMENT_CENTER); } // Add spacer. mMainLayout->addChild(new NativeUI::VerticalLayout); // Show the ActivityIndicator. activityIndicator->show(); }
void Ut_MGridLayoutPolicy::testHeightForWidthInSubLayout() { QFETCH(bool, useMLayout); QFETCH(bool, useInnerMLayout); QFETCH(bool, putInnerWidgetInWidget); QGraphicsWidget *form = new QGraphicsWidget; MGridLayoutPolicy *mpolicy = NULL; QGraphicsGridLayout *qlayout = NULL; if (useMLayout) { MLayout *mlayout = new MLayout(form); mlayout->setContentsMargins(0, 0, 0, 0); mpolicy = new MGridLayoutPolicy(mlayout); mpolicy->setSpacing(0); } else { qlayout = new QGraphicsGridLayout(form); qlayout->setContentsMargins(0, 0, 0, 0); qlayout->setSpacing(0); } QGraphicsWidget *topSpacer = createSpacer(); QGraphicsWidget *leftSpacer = createSpacer(); QGraphicsWidget *rightSpacer = createSpacer(); leftSpacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); rightSpacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); QGraphicsWidget *square = new SquareWidget; QGraphicsLayout *innerLayout = NULL; if (useInnerMLayout) { innerLayout = new MLayout(); MLinearLayoutPolicy *policy = new MLinearLayoutPolicy(static_cast<MLayout *>(innerLayout), Qt::Horizontal); policy->addItem(square); } else { innerLayout = new QGraphicsLinearLayout(Qt::Horizontal); static_cast<QGraphicsLinearLayout *>(innerLayout)->addItem(square); } innerLayout->setContentsMargins(0,0,0,0); QGraphicsLayoutItem *innerItem; if (putInnerWidgetInWidget) { QGraphicsWidget *innerWidget = new QGraphicsWidget; innerWidget->setLayout(innerLayout); innerItem = innerWidget; } else { innerItem = innerLayout; } if (useMLayout) { mpolicy->addItem(topSpacer, 0, 1); mpolicy->addItem(leftSpacer, 1, 0); mpolicy->addItem(rightSpacer, 1, 2); mpolicy->addItem(innerItem, 1, 1); } else { qlayout->addItem(topSpacer, 0, 1); qlayout->addItem(leftSpacer, 1, 0); qlayout->addItem(rightSpacer, 1, 2); qlayout->addItem(innerItem, 1, 1); } QCOMPARE(form->preferredSize(), QSizeF(500,500)); QCOMPARE(form->effectiveSizeHint(Qt::PreferredSize, QSizeF(100,-1)), QSizeF(100,100)); delete form; }
void TimelineToolBar::createRightControls() { auto *spacer = createSpacer(); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); addWidget(spacer); addSeparator(); m_firstFrame = createToolBarLineEdit(this); addWidget(m_firstFrame); auto emitStartChanged = [this]() { emit startFrameChanged(m_firstFrame->text().toInt()); }; connect(m_firstFrame, &QLineEdit::editingFinished, emitStartChanged); addSeparator(); addSpacing(10); auto *zoomOut = createAction(TimelineConstants::C_ZOOM_OUT, TimelineIcons::ZOOM_SMALL.icon(), tr("Zoom Out"), QKeySequence(QKeySequence::ZoomOut)); connect(zoomOut, &QAction::triggered, [this]() { m_scale->setValue(m_scale->value() - m_scale->pageStep()); }); addAction(zoomOut); addSpacing(10); m_scale = new QSlider(this); m_scale->setOrientation(Qt::Horizontal); m_scale->setMaximumWidth(200); m_scale->setMinimumWidth(100); m_scale->setMinimum(0); m_scale->setMaximum(100); m_scale->setValue(0); connect(m_scale, &QSlider::valueChanged, this, &TimelineToolBar::scaleFactorChanged); addWidget(m_scale); addSpacing(10); auto *zoomIn = createAction(TimelineConstants::C_ZOOM_IN, TimelineIcons::ZOOM_BIG.icon(), tr("Zoom In"), QKeySequence(QKeySequence::ZoomIn)); connect(zoomIn, &QAction::triggered, [this]() { m_scale->setValue(m_scale->value() + m_scale->pageStep()); }); addAction(zoomIn); addSpacing(10); addSeparator(); m_lastFrame = createToolBarLineEdit(this); addWidget(m_lastFrame); auto emitEndChanged = [this]() { emit endFrameChanged(m_lastFrame->text().toInt()); }; connect(m_lastFrame, &QLineEdit::editingFinished, emitEndChanged); addSeparator(); m_stateLabel = new QLabel(this); m_stateLabel->setFixedWidth(80); m_stateLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); addWidget(m_stateLabel); }
/** * 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); }
/** * Create the layout with checkable categories. * It is parented by the main layout. * For the moment, there are only 6 available categories. * ( These could be expanded also by new user categories.) * @return The layout that contains the categories. */ MAWidgetHandle HomeScreen::createCategoriesLayout() { // Add a layout for categories. MAWidgetHandle categoriesLayout = maWidgetCreate(MAW_VERTICAL_LAYOUT); // Set layout's size. setWidgetSize( categoriesLayout, MAW_CONSTANT_FILL_AVAILABLE_SPACE, mScreenHeight/3); //or MAW_CONSTANT_WRAP_CONTENT // Add a horizontal line. MAWidgetHandle line1 = createSpacer(mScreenWidth,BREAKLINE_HEIGHT); setWidgetProperty( line1, MAW_WIDGET_BACKGROUND_COLOR, DARK_GREY, 16); MAWidgetHandle label = createLabel( MAW_CONSTANT_FILL_AVAILABLE_SPACE, " Categories ", BLUE, mFontSize); maWidgetSetProperty( label, MAW_LABEL_TEXT_HORIZONTAL_ALIGNMENT, MAW_ALIGNMENT_LEFT); maWidgetAddChild(categoriesLayout, label); // Add another horizontal line. MAWidgetHandle line2 = createSpacer(mScreenWidth,BREAKLINE_HEIGHT); setWidgetProperty(line2, MAW_WIDGET_BACKGROUND_COLOR, DARK_GREY, 16); maWidgetAddChild(categoriesLayout, line2); // Available categories: // All ( enabled by default), Nature, Sports, Movies, News, Science. mCategoriesStrings.clear(); mCategoriesStrings.add(CATEGORY_ALL); mCategoriesStrings.add(CATEGORY_NATURE); mCategoriesStrings.add(CATEGORY_SPORTS); mCategoriesStrings.add(CATEGORY_NEWS); mCategoriesStrings.add(CATEGORY_MOVIES); mCategoriesStrings.add(CATEGORY_SCIENCE); setWidgetProperty( categoriesLayout, MAW_WIDGET_BACKGROUND_COLOR, DARK_WHITE, 16); int index(-1); // Each category has a check box and label. for (int i=0; i < mCategoriesStrings.size() / 2; i++) { // Arrange 2 categories per row. MAWidgetHandle categoryLayout = maWidgetCreate(MAW_HORIZONTAL_LAYOUT); // Set layout's size. setWidgetSize( categoryLayout,mScreenWidth, MAW_CONSTANT_FILL_AVAILABLE_SPACE); MAWidgetHandle checkBox1 = createCheckBox(); // By default, the first category (All) is checked, // so all of them are checked also. maWidgetSetProperty(checkBox1,MAW_CHECK_BOX_CHECKED,"true"); // We hold the array of check boxes, so we can construct // the request url based on the chosen categories. mCategoryBoxes.add(checkBox1); maWidgetAddChild(categoryLayout, checkBox1); index++; MAWidgetHandle label1 = createLabel( MAW_CONSTANT_FILL_AVAILABLE_SPACE, mCategoriesStrings[index].c_str(), BLUE, mFontSize ); // Arrange the text to the left. maWidgetSetProperty( label1, MAW_LABEL_TEXT_HORIZONTAL_ALIGNMENT, MAW_ALIGNMENT_LEFT); maWidgetAddChild(categoryLayout, label1); // Add another check box & label, on the same row. MAWidgetHandle checkBox2 = createCheckBox(); // By default, the first category (All) is checked, // so all of them are checked also. maWidgetSetProperty(checkBox2,MAW_CHECK_BOX_CHECKED,"true"); // We hold the array of check boxes, so we can construct // the request url based on the chosen categories. mCategoryBoxes.add(checkBox2); maWidgetAddChild(categoryLayout, checkBox2); index++; MAWidgetHandle label2 = createLabel( MAW_CONSTANT_FILL_AVAILABLE_SPACE, mCategoriesStrings[index].c_str(), BLUE, mFontSize ); // Arrange the text to the left. maWidgetSetProperty( label2, MAW_LABEL_TEXT_HORIZONTAL_ALIGNMENT, MAW_ALIGNMENT_LEFT); maWidgetAddChild(categoryLayout, label2); // Add this layout to the main vertical layout. maWidgetAddChild(categoriesLayout, categoryLayout); } // Add another horizontal line. MAWidgetHandle line3 = createSpacer(mScreenWidth,BREAKLINE_HEIGHT); setWidgetProperty(line3, MAW_WIDGET_BACKGROUND_COLOR, DARK_GREY, 16); maWidgetAddChild(categoriesLayout, line3); return categoriesLayout; }
/** * Create all the widgets in the UI. * The start button, count down label, flickering label, * weapon buttons, rival weapon, spacer, score label, * exit button. */ MAWidgetHandle NativeScreen::createMainLayout() { // Create the main layout (the main widget that holds the other widgets). MAWidgetHandle mainLayout = maWidgetCreate(MAW_VERTICAL_LAYOUT); // Set the size for this widget. setWidgetProperty(mainLayout, MAW_WIDGET_WIDTH, MAW_CONSTANT_FILL_AVAILABLE_SPACE); setWidgetProperty(mainLayout, MAW_WIDGET_HEIGHT, MAW_CONSTANT_FILL_AVAILABLE_SPACE); // All the child widgets of the mainLayout will be centered. maWidgetSetProperty( mainLayout, MAW_VERTICAL_LAYOUT_CHILD_HORIZONTAL_ALIGNMENT, MAW_ALIGNMENT_CENTER); maWidgetSetProperty( mainLayout, MAW_VERTICAL_LAYOUT_CHILD_VERTICAL_ALIGNMENT, MAW_ALIGNMENT_CENTER); // Set a background color for the main layout. setWidgetProperty(mainLayout, MAW_WIDGET_BACKGROUND_COLOR, SEA_GREEN, 16); // Add some space before the list view. maWidgetAddChild( mainLayout, createSpacer(mScreenWidth, 10, BLUE)); mLabel = maWidgetCreate(MAW_LABEL); setLabelText(mLabel, "No image selected"); maWidgetAddChild(mainLayout, mLabel); mButton = createButton("Select image", MAW_CONSTANT_WRAP_CONTENT, MAW_CONSTANT_WRAP_CONTENT); maWidgetAddChild(mainLayout, mButton); // we need to create the event return type setting ui mEventReturnTypeHorizontalLayout = maWidgetCreate(MAW_HORIZONTAL_LAYOUT); char buffer[BUF_SIZE]; sprintf(buffer, "%d", MAW_CONSTANT_FILL_AVAILABLE_SPACE); maWidgetSetProperty(mEventReturnTypeHorizontalLayout, MAW_WIDGET_WIDTH, buffer); mEventReturnTypeCheckbox = maWidgetCreate(MAW_CHECK_BOX); maWidgetSetProperty(mEventReturnTypeCheckbox, MAW_CHECK_BOX_CHECKED, "false"); mEventReturnTypeLabel = maWidgetCreate(MAW_LABEL); maWidgetSetProperty(mEventReturnTypeLabel, MAW_LABEL_TEXT, "Return image data with the event"); maWidgetAddChild(mEventReturnTypeHorizontalLayout, mEventReturnTypeCheckbox); maWidgetAddChild(mEventReturnTypeHorizontalLayout, mEventReturnTypeLabel); maWidgetAddChild(mainLayout, mEventReturnTypeHorizontalLayout); mPreview = maWidgetCreate(MAW_IMAGE); maWidgetSetProperty(mPreview, MAW_WIDGET_WIDTH, "-1"); maWidgetSetProperty(mPreview, MAW_WIDGET_HEIGHT, "-1"); // char buffer[256]; // sprintf(buffer, "%d", RES_IMAGE_START); // maWidgetSetProperty(mPreview, MAW_IMAGE_IMAGE, buffer); maWidgetSetProperty(mPreview, MAW_IMAGE_SCALE_MODE, "scalePreserveAspect"); maWidgetAddChild(mainLayout, mPreview); maWidgetAddChild( mainLayout, createSpacer(mScreenWidth, mScreenHeight/50, BLUE)); // Exit button in a horizontal layout. MAWidgetHandle bottomMenu = maWidgetCreate(MAW_HORIZONTAL_LAYOUT); setWidgetProperty(bottomMenu, MAW_WIDGET_WIDTH, mScreenWidth); setWidgetProperty(bottomMenu, MAW_WIDGET_HEIGHT, MAW_CONSTANT_FILL_AVAILABLE_SPACE); // Set the bottom button to half the available width. mExitButton = createButton(" Exit ", mScreenWidth/2, MAW_CONSTANT_WRAP_CONTENT ); maWidgetSetProperty(mExitButton, MAW_WIDGET_BACKGROUND_GRADIENT, "0xC1FFC1,0x9BCD9B"); maWidgetAddChild(bottomMenu,mExitButton); maWidgetAddChild(mainLayout,bottomMenu); return mainLayout; }
KgColors::KgColors(bool first, QWidget* parent) : KonfiguratorPage(first, parent), offset(0), activeTabIdx(-1), inactiveTabIdx(-1), #ifdef SYNCHRONIZER_ENABLED synchronizerTabIdx(-1), #endif otherTabIdx(-1) { QWidget *innerWidget = new QFrame(this); setWidget(innerWidget); setWidgetResizable(true); QGridLayout *kgColorsLayout = new QGridLayout(innerWidget); kgColorsLayout->setSpacing(6); // -------------------------- GENERAL GROUPBOX ---------------------------------- QGroupBox *generalGrp = createFrame(i18n("General"), innerWidget); QGridLayout *generalGrid = createGridLayout(generalGrp); generalGrid->setSpacing(0); generalGrid->setContentsMargins(5, 5, 5, 5); KONFIGURATOR_CHECKBOX_PARAM generalSettings[] = // cfg_class cfg_name default text restart tooltip {{"Colors", "KDE Default", _KDEDefaultColors, i18n("Use the default KDE colors"), false, "<p><img src='toolbar|kcontrol'></p>" + i18n("<p>Use KDE's global color configuration.</p><p><i>KDE System Settings -> Application Appearance -> Colors</i></p>") }, {"Colors", "Enable Alternate Background", _AlternateBackground, i18n("Use alternate background color"), false, i18n("<p>The <b>background color</b> and the <b>alternate background</b> color alternates line by line.</p><p>When you don't use the <i>KDE default colors</i>, you can configure the alternate colors in the <i>colors</i> box.</p>") }, {"Colors", "Show Current Item Always", _ShowCurrentItemAlways, i18n("Show current item even if not focused"), false, i18n("<p>Shows the last cursor position in the non active list panel.</p><p>This option is only available when you don't use the <i>KDE default colors</i>.</p>") }, {"Colors", "Dim Inactive Colors", _DimInactiveColors, i18n("Dim the colors of the inactive panel"), false, i18n("<p>The colors of the inactive panel are calculated by a dim color and a dim factor.</p>") } }; generals = createCheckBoxGroup(0, 2, generalSettings, sizeof(generalSettings) / sizeof(generalSettings[0]), generalGrp); generalGrid->addWidget(generals, 1, 0); generals->layout()->setSpacing(5); connect(generals->find("KDE Default"), SIGNAL(stateChanged(int)), this, SLOT(slotDisable())); connect(generals->find("Show Current Item Always"), SIGNAL(stateChanged(int)), this, SLOT(slotDisable())); connect(generals->find("Dim Inactive Colors"), SIGNAL(stateChanged(int)), this, SLOT(slotDisable())); kgColorsLayout->addWidget(generalGrp, 0 , 0, 1, 3); QWidget *hboxWidget = new QWidget(innerWidget); QHBoxLayout *hbox = new QHBoxLayout(hboxWidget); // -------------------------- COLORS GROUPBOX ---------------------------------- QGroupBox *colorsFrameGrp = createFrame(i18n("Colors"), hboxWidget); QGridLayout *colorsFrameGrid = createGridLayout(colorsFrameGrp); colorsFrameGrid->setSpacing(0); colorsFrameGrid->setContentsMargins(3, 3, 3, 3); colorTabWidget = new QTabWidget(colorsFrameGrp); colorsGrp = new QWidget(colorTabWidget); activeTabIdx = colorTabWidget->addTab(colorsGrp, i18n("Active")); colorsGrid = new QGridLayout(colorsGrp); colorsGrid->setSpacing(0); colorsGrid->setContentsMargins(2, 2, 2, 2); ADDITIONAL_COLOR transparent = { i18n("Transparent"), Qt::white, "transparent" }; QPalette p = QGuiApplication::palette(); addColorSelector("Foreground", i18n("Foreground:"), p.color(QPalette::Active, QPalette::Text)); addColorSelector("Directory Foreground", i18n("Directory foreground:"), getColorSelector("Foreground")->getColor(), i18n("Same as foreground")); addColorSelector("Executable Foreground", i18n("Executable foreground:"), getColorSelector("Foreground")->getColor(), i18n("Same as foreground")); addColorSelector("Symlink Foreground", i18n("Symbolic link foreground:"), getColorSelector("Foreground")->getColor(), i18n("Same as foreground")); addColorSelector("Invalid Symlink Foreground", i18n("Invalid symlink foreground:"), getColorSelector("Foreground")->getColor(), i18n("Same as foreground")); addColorSelector("Background", i18n("Background:"), p.color(QPalette::Active, QPalette::Base)); ADDITIONAL_COLOR sameAsBckgnd = { i18n("Same as background"), getColorSelector("Background")->getColor(), "Background" }; addColorSelector("Alternate Background", i18n("Alternate background:"), p.color(QPalette::Active, QPalette::AlternateBase), "", &sameAsBckgnd, 1); addColorSelector("Marked Foreground", i18n("Selected foreground:"), p.color(QPalette::Active, QPalette::HighlightedText), "", &transparent, 1); addColorSelector("Marked Background", i18n("Selected background:"), p.color(QPalette::Active, QPalette::Highlight), "", &sameAsBckgnd, 1); ADDITIONAL_COLOR sameAsAltern = { i18n("Same as alt. background"), getColorSelector("Alternate Background")->getColor(), "Alternate Background" }; addColorSelector("Alternate Marked Background", i18n("Alternate selected background:"), getColorSelector("Marked Background")->getColor(), i18n("Same as selected background"), &sameAsAltern, 1); addColorSelector("Current Foreground", i18n("Current foreground:"), Qt::white, i18n("Not used")); ADDITIONAL_COLOR sameAsMarkedForegnd = { i18n("Same as selected foreground"), getColorSelector("Marked Foreground")->getColor(), "Marked Foreground" }; addColorSelector("Marked Current Foreground", i18n("Selected current foreground:"), Qt::white, i18n("Not used"), &sameAsMarkedForegnd, 1); addColorSelector("Current Background", i18n("Current background:"), Qt::white, i18n("Not used"), &sameAsBckgnd, 1); colorsGrid->addWidget(createSpacer(colorsGrp), itemList.count() - offset, 1); connect(getColorSelector("Foreground"), SIGNAL(colorChanged()), this, SLOT(slotForegroundChanged())); connect(getColorSelector("Background"), SIGNAL(colorChanged()), this, SLOT(slotBackgroundChanged())); connect(getColorSelector("Alternate Background"), SIGNAL(colorChanged()), this, SLOT(slotAltBackgroundChanged())); connect(getColorSelector("Marked Background"), SIGNAL(colorChanged()), this, SLOT(slotMarkedBackgroundChanged())); inactiveColorStack = new QStackedWidget(colorTabWidget); inactiveTabIdx = colorTabWidget->addTab(inactiveColorStack, i18n("Inactive")); colorsGrp = normalInactiveWidget = new QWidget(inactiveColorStack); colorsGrid = new QGridLayout(normalInactiveWidget); colorsGrid->setSpacing(0); colorsGrid->setContentsMargins(2, 2, 2, 2); offset = endOfActiveColors = itemList.count(); addColorSelector("Inactive Foreground", i18n("Foreground:"), getColorSelector("Foreground")->getColor(), i18n("Same as active")); ADDITIONAL_COLOR sameAsInactForegnd = { i18n("Same as foreground"), getColorSelector("Inactive Foreground")->getColor(), "Inactive Foreground" }; addColorSelector("Inactive Directory Foreground", i18n("Directory foreground:"), getColorSelector("Directory Foreground")->getColor(), i18n("Same as active"), &sameAsInactForegnd, 1); addColorSelector("Inactive Executable Foreground", i18n("Executable foreground:"), getColorSelector("Executable Foreground")->getColor(), i18n("Same as active"), &sameAsInactForegnd, 1); addColorSelector("Inactive Symlink Foreground", i18n("Symbolic link foreground:"), getColorSelector("Symlink Foreground")->getColor(), i18n("Same as active"), &sameAsInactForegnd, 1); addColorSelector("Inactive Invalid Symlink Foreground", i18n("Invalid symlink foreground:"), getColorSelector("Invalid Symlink Foreground")->getColor(), i18n("Same as active"), &sameAsInactForegnd, 1); addColorSelector("Inactive Background", i18n("Background:"), getColorSelector("Background")->getColor(), i18n("Same as active")); ADDITIONAL_COLOR sameAsInactBckgnd = { i18n("Same as background"), getColorSelector("Inactive Background")->getColor(), "Inactive Background" }; addColorSelector("Inactive Alternate Background", i18n("Alternate background:"), getColorSelector("Alternate Background")->getColor(), i18n("Same as active"), &sameAsInactBckgnd, 1); addColorSelector("Inactive Marked Foreground", i18n("Selected foreground:"), getColorSelector("Marked Foreground")->getColor(), i18n("Same as active"), &transparent, 1); addColorSelector("Inactive Marked Background", i18n("Selected background:"), getColorSelector("Marked Background")->getColor(), i18n("Same as active"), &sameAsInactBckgnd, 1); ADDITIONAL_COLOR sameAsInactAltern[] = {{ i18n("Same as alt. background"), getColorSelector("Inactive Alternate Background")->getColor(), "Inactive Alternate Background" }, { i18n("Same as selected background"), getColorSelector("Inactive Marked Background")->getColor(), "Inactive Marked Background" } }; addColorSelector("Inactive Alternate Marked Background", i18n("Alternate selected background:"), getColorSelector("Alternate Marked Background")->getColor(), i18n("Same as active"), sameAsInactAltern, 2); addColorSelector("Inactive Current Foreground", i18n("Current foreground:"), getColorSelector("Current Foreground")->getColor(), i18n("Same as active")); ADDITIONAL_COLOR sameAsInactMarkedForegnd = { i18n("Same as selected foreground"), getColorSelector("Inactive Marked Foreground")->getColor(), "Inactive Marked Foreground" }; addColorSelector("Inactive Marked Current Foreground", i18n("Selected current foreground:"), getColorSelector("Marked Current Foreground")->getColor(), i18n("Same as active"), &sameAsInactMarkedForegnd, 1); addColorSelector("Inactive Current Background", i18n("Current background:"), getColorSelector("Current Background")->getColor(), i18n("Same as active"), &sameAsInactBckgnd, 1); colorsGrid->addWidget(createSpacer(normalInactiveWidget), itemList.count() - offset, 1); connect(getColorSelector("Inactive Foreground"), SIGNAL(colorChanged()), this, SLOT(slotInactiveForegroundChanged())); connect(getColorSelector("Inactive Background"), SIGNAL(colorChanged()), this, SLOT(slotInactiveBackgroundChanged())); connect(getColorSelector("Inactive Alternate Background"), SIGNAL(colorChanged()), this, SLOT(slotInactiveAltBackgroundChanged())); connect(getColorSelector("Inactive Marked Background"), SIGNAL(colorChanged()), this, SLOT(slotInactiveMarkedBackgroundChanged())); offset = endOfPanelColors = itemList.count(); inactiveColorStack->addWidget(normalInactiveWidget); colorsGrp = dimmedInactiveWidget = new QWidget(inactiveColorStack); colorsGrid = new QGridLayout(dimmedInactiveWidget); colorsGrid->setSpacing(0); colorsGrid->setContentsMargins(2, 2, 2, 2); addColorSelector("Dim Target Color", i18n("Dim target color:"), Qt::black); int index = itemList.count() - offset; labelList.append(addLabel(colorsGrid, index, 0, i18n("Dim factor:"), colorsGrp)); dimFactor = createSpinBox("Colors", "Dim Factor", 80, 0, 100, colorsGrp); dimFactor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); colorsGrid->addWidget(dimFactor, index++, 1); colorsGrid->addWidget(createSpacer(dimmedInactiveWidget), itemList.count() + 1 - offset, 1); inactiveColorStack->addWidget(dimmedInactiveWidget); inactiveColorStack->setCurrentWidget(normalInactiveWidget); ADDITIONAL_COLOR KDEDefaultBase = { i18n("KDE default"), p.color(QPalette::Active, QPalette::Base), "KDE default" }; ADDITIONAL_COLOR KDEDefaultFore = { i18n("KDE default"), p.color(QPalette::Active, QPalette::Text), "KDE default" }; #ifdef SYNCHRONIZER_ENABLED colorsGrp = new QWidget(colorTabWidget); synchronizerTabIdx = colorTabWidget->addTab(colorsGrp, i18n("Synchronizer")); colorsGrid = new QGridLayout(colorsGrp); colorsGrid->setSpacing(0); colorsGrid->setContentsMargins(2, 2, 2, 2); offset = endOfPanelColors = itemList.count(); addColorSelector("Synchronizer Equals Foreground", i18n("Equals foreground:"), Qt::black, QString(), &KDEDefaultFore, 1); addColorSelector("Synchronizer Equals Background", i18n("Equals background:"), p.color(QPalette::Active, QPalette::Base), QString(), &KDEDefaultBase, 1); addColorSelector("Synchronizer Differs Foreground", i18n("Differing foreground:"), Qt::red, QString(), &KDEDefaultFore, 1); addColorSelector("Synchronizer Differs Background", i18n("Differing background:"), p.color(QPalette::Active, QPalette::Base), QString(), &KDEDefaultBase, 1); addColorSelector("Synchronizer LeftCopy Foreground", i18n("Copy to left foreground:"), Qt::blue, QString(), &KDEDefaultFore, 1); addColorSelector("Synchronizer LeftCopy Background", i18n("Copy to left background:"), p.color(QPalette::Active, QPalette::Base), QString(), &KDEDefaultBase, 1); addColorSelector("Synchronizer RightCopy Foreground", i18n("Copy to right foreground:"), Qt::darkGreen, QString(), &KDEDefaultFore, 1); addColorSelector("Synchronizer RightCopy Background", i18n("Copy to right background:"), p.color(QPalette::Active, QPalette::Base), QString(), &KDEDefaultBase, 1); addColorSelector("Synchronizer Delete Foreground", i18n("Delete foreground:"), Qt::white, QString(), &KDEDefaultFore, 1); addColorSelector("Synchronizer Delete Background", i18n("Delete background:"), Qt::red, QString(), &KDEDefaultBase, 1); colorsGrid->addWidget(createSpacer(colorsGrp), itemList.count() - offset, 1); #endif colorsGrp = new QWidget(colorTabWidget); otherTabIdx = colorTabWidget->addTab(colorsGrp, i18n("Other")); colorsGrid = new QGridLayout(colorsGrp); colorsGrid->setSpacing(0); colorsGrid->setContentsMargins(2, 2, 2, 2); offset = endOfPanelColors = itemList.count(); addColorSelector("Quicksearch Match Foreground", i18n("Quicksearch, match foreground:"), Qt::black, QString(), &KDEDefaultFore, 1); addColorSelector("Quicksearch Match Background", i18n("Quicksearch, match background:"), QColor(192, 255, 192), QString(), &KDEDefaultBase, 1); addColorSelector("Quicksearch Non-match Foreground", i18n("Quicksearch, non-match foreground:"), Qt::black, QString(), &KDEDefaultFore, 1); addColorSelector("Quicksearch Non-match Background", i18n("Quicksearch, non-match background:"), QColor(255, 192, 192), QString(), &KDEDefaultBase, 1); ADDITIONAL_COLOR KDEDefaultWindowFore = { i18n("KDE default"), p.color(QPalette::Active, QPalette::WindowText), "KDE default" }; ADDITIONAL_COLOR KDEDefaultWindowBack = { i18n("KDE default"), p.color(QPalette::Active, QPalette::Window), "KDE default" }; addColorSelector("Statusbar Foreground Active", i18n("Statusbar, active foreground:"), p.color(QPalette::Active, QPalette::HighlightedText), QString(), &KDEDefaultWindowFore, 1); addColorSelector("Statusbar Background Active", i18n("Statusbar, active background:"), p.color(QPalette::Active, QPalette::Highlight), QString(), &KDEDefaultWindowBack, 1); addColorSelector("Statusbar Foreground Inactive", i18n("Statusbar, inactive foreground:"), p.color(QPalette::Inactive, QPalette::Text), QString(), &KDEDefaultWindowFore, 1); addColorSelector("Statusbar Background Inactive", i18n("Statusbar, inactive background:"), p.color(QPalette::Inactive, QPalette::Base), QString(), &KDEDefaultWindowBack, 1); colorsGrid->addWidget(createSpacer(colorsGrp), itemList.count() - offset, 1); colorsFrameGrid->addWidget(colorTabWidget, 0, 0); hbox->addWidget(colorsFrameGrp); // -------------------------- PREVIEW GROUPBOX ---------------------------------- previewGrp = createFrame(i18n("Preview"), hboxWidget); previewGrid = createGridLayout(previewGrp); preview = new KrTreeWidget(previewGrp); preview->setBackgroundRole(QPalette::Window); preview->setAutoFillBackground(true); QStringList labels; labels << i18n("Colors"); preview->setHeaderLabels(labels); preview->header()->setSortIndicatorShown(false); preview->setSortingEnabled(false); preview->setEnabled(false); previewGrid->addWidget(preview, 0 , 0); hbox->addWidget(previewGrp); connect(generals->find("Enable Alternate Background"), SIGNAL(stateChanged(int)), this, SLOT(generatePreview())); connect(colorTabWidget, SIGNAL(currentChanged(int)), this, SLOT(generatePreview())); connect(dimFactor, SIGNAL(valueChanged(int)), this, SLOT(generatePreview())); kgColorsLayout->addWidget(hboxWidget, 1 , 0, 1, 3); importBtn = new QPushButton(i18n("Import color-scheme"), innerWidget); kgColorsLayout->addWidget(importBtn, 2, 0); exportBtn = new QPushButton(i18n("Export color-scheme"), innerWidget); kgColorsLayout->addWidget(exportBtn, 2, 1); kgColorsLayout->addWidget(createSpacer(innerWidget), 2, 2); connect(importBtn, SIGNAL(clicked()), this, SLOT(slotImportColors())); connect(exportBtn, SIGNAL(clicked()), this, SLOT(slotExportColors())); slotDisable(); }
void WBoxLayout::insertStretch(int index, int stretch) { WWidget *spacer = createSpacer(WLength(0)); insertItem(index, new WWidgetItem(spacer), stretch, 0); }
void WBoxLayout::insertSpacing(int index, const WLength& size) { WWidget *spacer = createSpacer(size); insertItem(index, new WWidgetItem(spacer), 0, 0); }