Fix some crashes related to custom button layout handling

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/3/head
Mavridis Philippe 2 years ago
parent 735fb935f8
commit e82c6d29e2
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -308,6 +308,7 @@ void MachBunt::reset( unsigned long changed )
int MachBunt::mapButton( const TQChar &c)
{
if (c.isNull()) return -1;
switch (c.latin1())
{
case 'M':
@ -324,7 +325,7 @@ int MachBunt::mapButton( const TQChar &c)
return BtnClose;
}
// something went wrong
tqDebug("unknown Button to map \"%c\"", c.latin1() );
tqDebug("unknown Button to map: %c\n", c.latin1() );
return -1;
}
@ -336,11 +337,14 @@ void MachBunt::doLayout()
titlebar = new TQSpacerItem ( 0, titleHeight, TQSizePolicy::Expanding,
TQSizePolicy::Fixed);
TQBoxLayout *topLayout = new TQBoxLayout(windowLayout, TQBoxLayout::LeftToRight, 0, 0);
#if 1
TQString leftButtons(options()->customButtonPositions() ? options()->titleButtonsLeft() : "M");
TQString rightButtons(options()->customButtonPositions() ? options()->titleButtonsRight() : "HIAX");
bool first_left = true;
for ( unsigned int i = 0; i <options()->titleButtonsLeft().length(); i++)
{
int b = mapButton(options()->titleButtonsLeft()[i]);
int b = mapButton(leftButtons[i]);
if ( b>=0 ){
topLayout->addWidget(button[b], TQt::AlignVCenter);
topLayout->setStretchFactor(button[b], 0);
@ -355,41 +359,10 @@ void MachBunt::doLayout()
topLayout->addItem(titlebar);
#else
topLayout->addWidget(button[BtnMenu], TQt::AlignVCenter);
topLayout->setStretchFactor(button[BtnMenu], 0);
button[BtnMenu]->setFixedSize(titleHeight, titleHeight);
button[BtnMenu]->setPosition( ButtonLeft );
topLayout->addItem(titlebar);
topLayout->addWidget(button[BtnHelp], TQt::AlignVCenter);
topLayout->setStretchFactor(button[BtnHelp], 0);
button[BtnHelp]->setFixedSize(titleHeight, titleHeight);
topLayout->addWidget(button[BtnIconify], TQt::AlignVCenter);
topLayout->setStretchFactor(button[BtnIconify], 0);
button[BtnIconify]->setFixedSize(titleHeight, titleHeight);
topLayout->addWidget(button[BtnMax], TQt::AlignVCenter);
topLayout->setStretchFactor(button[BtnMax], 0);
button[BtnMax]->setFixedSize(titleHeight, titleHeight);
topLayout->addWidget(button[BtnClose], TQt::AlignVCenter);
topLayout->setStretchFactor(button[BtnClose], 0);
button[BtnClose]->setFixedSize(titleHeight, titleHeight);
button[BtnClose]->setPosition( ButtonRight );
if ( !isMinimizable() )
button[BtnIconify]->hide();
if ( !isMaximizable() )
button[BtnMax]->hide();
#endif
#if 1
MachBuntButton* last_right = NULL;
for ( unsigned int i = 0; i <options()->titleButtonsRight().length(); i++)
{
int b = mapButton(options()->titleButtonsRight()[i]);
int b = mapButton(rightButtons[i]);
if ( b>=0 ){
topLayout->addWidget(button[b], TQt::AlignVCenter);
topLayout->setStretchFactor(button[b], 0);
@ -399,7 +372,6 @@ void MachBunt::doLayout()
}
if( last_right )
last_right->setPosition( ButtonRight );
#endif
TQHBoxLayout * midLayout = new TQHBoxLayout(windowLayout, 0, 0);
midLayout->addSpacing(BORDER_LEFT);

Loading…
Cancel
Save