Skip to content

Commit

Permalink
Update for the UI designer
Browse files Browse the repository at this point in the history
Make the newly added widgets visible.
  • Loading branch information
lslezak committed Sep 13, 2016
1 parent 99c64a2 commit 3e71a5e
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/YQWidgetFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ YQWidgetFactory::~YQWidgetFactory()
}


// A helper method to ensure a newly added widget is visible when added
// to an already visible parent. The widgets in the dialogs are show()ed in
// the waitForEvent() call, any widgets added later are hidden :-(
// To make possible adding the widgets in the spy dialog we need to show()
// them explicitly if the parent is already visible.
void inherit_visibility(YWidget *parent, QWidget *qwidget)
{
QWidget *qparent = dynamic_cast<QWidget *>(parent);

if (qparent && qwidget && qparent->isVisible())
{
qwidget->show();
}
}


//
Expand Down Expand Up @@ -76,6 +90,8 @@ YQWidgetFactory::createLayoutBox( YWidget * parent, YUIDimension dim )
YQLayoutBox * layoutBox = new YQLayoutBox( parent, dim );
YUI_CHECK_NEW( layoutBox );

inherit_visibility(parent, layoutBox);

return layoutBox;
}

Expand All @@ -86,6 +102,8 @@ YQWidgetFactory::createButtonBox( YWidget * parent )
YQButtonBox * buttonBox = new YQButtonBox( parent );
YUI_CHECK_NEW( buttonBox );

inherit_visibility(parent, buttonBox);

return buttonBox;
}

Expand All @@ -101,6 +119,7 @@ YQWidgetFactory::createPushButton( YWidget * parent, const std::string & label )
YQPushButton * pushButton = new YQPushButton( parent, label );
YUI_CHECK_NEW( pushButton );

inherit_visibility(parent, pushButton);
return pushButton;
}

Expand All @@ -115,6 +134,8 @@ YQWidgetFactory::createLabel( YWidget * parent,
YQLabel * label = new YQLabel( parent, text, isHeading, isOutputField );
YUI_CHECK_NEW( label );

inherit_visibility(parent, label);

return label;
}

Expand All @@ -126,6 +147,8 @@ YQWidgetFactory::createInputField( YWidget * parent, const std::string & label,
YQInputField * inputField = new YQInputField( parent, label, passwordMode );
YUI_CHECK_NEW( inputField );

inherit_visibility(parent, inputField);

return inputField;
}

Expand All @@ -137,6 +160,8 @@ YQWidgetFactory::createCheckBox( YWidget * parent, const std::string & label, bo
YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
YUI_CHECK_NEW( checkBox );

inherit_visibility(parent, checkBox);

return checkBox;
}

Expand All @@ -155,6 +180,8 @@ YQWidgetFactory::createRadioButton( YWidget * parent, const std::string & label,
if ( radioButton->buttonGroup() )
radioButton->buttonGroup()->addRadioButton( radioButton );

inherit_visibility(parent, radioButton);

return radioButton;
}

Expand All @@ -166,6 +193,8 @@ YQWidgetFactory::createComboBox( YWidget * parent, const std::string & label, bo
YQComboBox * comboBox = new YQComboBox( parent, label, editable );
YUI_CHECK_NEW( comboBox );

inherit_visibility(parent, comboBox);

return comboBox;
}

Expand All @@ -177,6 +206,8 @@ YQWidgetFactory::createSelectionBox( YWidget * parent, const std::string & label
YQSelectionBox * selectionBox = new YQSelectionBox( parent, label );
YUI_CHECK_NEW( selectionBox );

inherit_visibility(parent, selectionBox);

return selectionBox;
}

Expand All @@ -188,6 +219,8 @@ YQWidgetFactory::createTree( YWidget * parent, const std::string & label, bool m
YQTree * tree = new YQTree( parent, label, multiselection, recursiveselection );
YUI_CHECK_NEW( tree );

inherit_visibility(parent, tree);

return tree;
}

Expand All @@ -199,6 +232,8 @@ YQWidgetFactory::createTable( YWidget * parent, YTableHeader * header, bool mult
YQTable * table = new YQTable( parent, header, multiSelection );
YUI_CHECK_NEW( table );

inherit_visibility(parent, table);

return table;
}

Expand All @@ -210,6 +245,8 @@ YQWidgetFactory::createProgressBar( YWidget * parent, const std::string & label,
YQProgressBar * progressBar = new YQProgressBar( parent, label, maxValue );
YUI_CHECK_NEW( progressBar );

inherit_visibility(parent, progressBar);

return progressBar;
}

Expand All @@ -221,6 +258,8 @@ YQWidgetFactory::createRichText( YWidget * parent, const std::string & text, boo
YQRichText * richText = new YQRichText( parent, text, plainTextMode );
YUI_CHECK_NEW( richText );

inherit_visibility(parent, richText);

return richText;
}

Expand All @@ -231,6 +270,8 @@ YQWidgetFactory::createBusyIndicator( YWidget * parent, const std::string & labe
YQBusyIndicator * busyIndicator = new YQBusyIndicator( parent, label, maxValue );
YUI_CHECK_NEW( busyIndicator );

inherit_visibility(parent, busyIndicator);

return busyIndicator;
}

Expand All @@ -247,6 +288,8 @@ YQWidgetFactory::createIntField( YWidget * parent, const std::string & label, in
YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
YUI_CHECK_NEW( intField );

inherit_visibility(parent, intField);

return intField;
}

Expand All @@ -258,6 +301,8 @@ YQWidgetFactory::createMenuButton( YWidget * parent, const std::string & label )
YQMenuButton * menuButton = new YQMenuButton( parent, label );
YUI_CHECK_NEW( menuButton );

inherit_visibility(parent, menuButton);

return menuButton;
}

Expand All @@ -269,6 +314,8 @@ YQWidgetFactory::createMultiLineEdit( YWidget * parent, const std::string & labe
YQMultiLineEdit * multiLineEdit = new YQMultiLineEdit( parent, label );
YUI_CHECK_NEW( multiLineEdit );

inherit_visibility(parent, multiLineEdit);

return multiLineEdit;
}

Expand All @@ -280,6 +327,8 @@ YQWidgetFactory::createImage( YWidget * parent, const std::string & imageFileNam
YQImage * image = new YQImage( parent, imageFileName, animated );
YUI_CHECK_NEW( image );

inherit_visibility(parent, image);

return image;
}

Expand All @@ -290,6 +339,8 @@ YQWidgetFactory::createLogView( YWidget * parent, const std::string & label, int
YQLogView * logView = new YQLogView( parent, label, visibleLines, storedLines );
YUI_CHECK_NEW( logView );

inherit_visibility(parent, logView);

return logView;
}

Expand All @@ -301,6 +352,8 @@ YQWidgetFactory::createMultiSelectionBox( YWidget * parent, const std::string &
YQMultiSelectionBox * multiSelectionBox = new YQMultiSelectionBox( parent, label );
YUI_CHECK_NEW( multiSelectionBox );

inherit_visibility(parent, multiSelectionBox);

return multiSelectionBox;
}

Expand Down Expand Up @@ -335,6 +388,8 @@ YQWidgetFactory::createSpacing( YWidget * parent, YUIDimension dim, bool stretch
YQSpacing * spacing = new YQSpacing( parent, dim, stretchable, size );
YUI_CHECK_NEW( spacing );

inherit_visibility(parent, spacing);

return spacing;
}

Expand All @@ -345,6 +400,8 @@ YQWidgetFactory::createEmpty( YWidget * parent )
YQEmpty * empty = new YQEmpty( parent );
YUI_CHECK_NEW( empty );

inherit_visibility(parent, empty);

return empty;
}

Expand All @@ -358,6 +415,8 @@ YQWidgetFactory::createAlignment( YWidget * parent,
YQAlignment * alignment = new YQAlignment( parent, horAlignment, vertAlignment );
YUI_CHECK_NEW( alignment );

inherit_visibility(parent, alignment);

return alignment;
}

Expand All @@ -368,6 +427,8 @@ YQWidgetFactory::createSquash( YWidget * parent, bool horSquash, bool vertSquash
YQSquash * squash = new YQSquash( parent, horSquash, vertSquash );
YUI_CHECK_NEW( squash );

inherit_visibility(parent, squash);

return squash;
}

Expand All @@ -379,6 +440,8 @@ YQWidgetFactory::createFrame( YWidget * parent, const std::string & label )
YQFrame * frame = new YQFrame( parent, label );
YUI_CHECK_NEW( frame );

inherit_visibility(parent, frame);

return frame;
}

Expand All @@ -390,6 +453,8 @@ YQWidgetFactory::createCheckBoxFrame( YWidget * parent, const std::string & labe
YQCheckBoxFrame * checkBoxFrame = new YQCheckBoxFrame( parent, label, checked );
YUI_CHECK_NEW( checkBoxFrame );

inherit_visibility(parent, checkBoxFrame);

return checkBoxFrame;
}

Expand All @@ -401,6 +466,8 @@ YQWidgetFactory::createRadioButtonGroup( YWidget * parent )
YQRadioButtonGroup * radioButtonGroup = new YQRadioButtonGroup( parent );
YUI_CHECK_NEW( radioButtonGroup );

inherit_visibility(parent, radioButtonGroup);

return radioButtonGroup;
}

Expand All @@ -412,6 +479,8 @@ YQWidgetFactory::createReplacePoint( YWidget * parent )
YQReplacePoint * replacePoint = new YQReplacePoint( parent );
YUI_CHECK_NEW( replacePoint );

inherit_visibility(parent, replacePoint);

return replacePoint;
}

Expand Down

0 comments on commit 3e71a5e

Please sign in to comment.