summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2022-10-16 18:24:27 +0300
committerMavridis Philippe <mavridisf@gmail.com>2022-10-16 18:24:27 +0300
commite82c6d29e2ca0c0f485595c0e6b407431a8e1205 (patch)
treed18e1e44996c8465fbda374309a980c3c6d033e2
parent735fb935f8475b771699a839b2ed5a42d7aff93b (diff)
downloadtwin-style-machbunt-e82c6d29.tar.gz
twin-style-machbunt-e82c6d29.zip
Fix some crashes related to custom button layout handling
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rw-r--r--src/MachBunt.cpp44
1 files changed, 8 insertions, 36 deletions
diff --git a/src/MachBunt.cpp b/src/MachBunt.cpp
index 3af9593..078a4eb 100644
--- a/src/MachBunt.cpp
+++ b/src/MachBunt.cpp
@@ -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);