diff options
author | mio <[email protected]> | 2024-08-27 15:00:04 +1000 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2024-08-31 19:18:40 +0900 |
commit | 9f6a25bcf436e7d597b6f31e9a0b2c16cc4828f9 (patch) | |
tree | ead634d4a7689ef25b8850f72a8e0e9ee390b8d2 | |
parent | 5394e874c37b53db0ca75c119d2a8e4612750f19 (diff) | |
download | codeine-9f6a25bcf436e7d597b6f31e9a0b2c16cc4828f9.tar.gz codeine-9f6a25bcf436e7d597b6f31e9a0b2c16cc4828f9.zip |
Improve the layout of XineConfigDialog
Properly display the description of each of the settings. Also,
reorganize the layout so that it uses layouts rather than VBox/HBox.
The TabWidget class has been removed in favour of the standard
TQTabWidget class, as the different behaviour doesn't make a notable
visual difference.
Signed-off-by: mio <[email protected]>
(cherry picked from commit 11c0638baf9ae1623fec00107bb9d065d3ecb88b)
-rw-r--r-- | src/app/xineConfig.cpp | 124 |
1 files changed, 50 insertions, 74 deletions
diff --git a/src/app/xineConfig.cpp b/src/app/xineConfig.cpp index b44c9bc..414b33c 100644 --- a/src/app/xineConfig.cpp +++ b/src/app/xineConfig.cpp @@ -38,22 +38,6 @@ namespace Codeine } } - -class TabWidget : public TQTabWidget -{ -public: - TabWidget( TQWidget *parent ) : TQTabWidget( parent ) {} - - virtual TQSize sizeHint() const - { - // TQt gives a stupid default sizeHint for this widget - return TQSize( - reinterpret_cast<TQWidget*>(tabBar())->sizeHint().width() + 5, - TQTabWidget::sizeHint().height() ); - } -}; - - ///@class XineConfigDialog XineConfigDialog::XineConfigDialog( xine_t *xine, TQWidget *parent ) @@ -68,32 +52,26 @@ XineConfigDialog::XineConfigDialog( xine_t *xine, TQWidget *parent ) DEBUG_BLOCK s_instance = this; - const int METRIC = fontMetrics().width( 'x' ); - const int METRIC_3B2 = (3*METRIC)/2; - TQVBox *box = new TQVBox( this ); - box->setSpacing( METRIC ); - setMainWidget( box ); + TQWidget *page = new TQWidget(this); + setMainWidget(page); + TQVBoxLayout *topLayout = new TQVBoxLayout(page, 0, spacingHint()); { - TQHBox *hbox = new TQHBox( box ); - hbox->setSpacing( METRIC_3B2 ); - hbox->setMargin( METRIC_3B2 ); - TQPixmap info = kapp->iconLoader()->loadIcon( "messagebox_info", TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState, nullptr, true ); - TQLabel *label = new TQLabel( hbox ); - label->setPixmap( info ); - label->setSizePolicy( TQSizePolicy::Maximum, TQSizePolicy::Maximum ); - label = new TQLabel( i18n( - "xine's defaults are usually sensible and should not require modification. " - "However, full configurability is provided for your pleasure ;-)." ), hbox ); - label->setAlignment( TQLabel::WordBreak | TQLabel::AlignVCenter ); + TQHBoxLayout *infoLayout = new TQHBoxLayout(topLayout, spacingHint()); + TQPixmap info = kapp->iconLoader()->loadIcon("messagebox_info", TDEIcon::NoGroup, TDEIcon::SizeMedium, TDEIcon::DefaultState, nullptr, true); + TQLabel *label = new TQLabel(page); + label->setPixmap(info); + label->setSizePolicy(TQSizePolicy::Maximum, TQSizePolicy::Maximum); + infoLayout->addWidget(label); + label = new TQLabel(i18n( + "Xine's defaults are usually sensible and should not require modification. " + "However, full configurability is provided for your pleasure ;-)"), page); + label->setAlignment(TQLabel::WordBreak | TQLabel::AlignVCenter); + infoLayout->addWidget(label); } - //FIXME after many hours I have discovered that this - // widget somehow sets the minSize of this widget to 0,0 - // whenever you resize the widget. WTF? - TabWidget *tabs = new TabWidget( box ); - + TQTabWidget *tabs = new TQTabWidget(page); class XineConfigEntryIterator { xine_t *m_xine; @@ -105,53 +83,51 @@ XineConfigDialog::XineConfigDialog( xine_t *xine, TQWidget *parent ) inline xine_cfg_entry_t *operator*() { return m_valid ? &m_entry : nullptr; } }; - TQGridLayout *grid = nullptr; - TQString currentPage; + TQString currentPageName; TQScrollView *view = nullptr; - parent = nullptr; + TQWidget *scrollWidget = nullptr; - for( XineConfigEntryIterator it( m_xine ); *it; ++it ) + for (XineConfigEntryIterator it(m_xine); *it; ++it) { - const TQString pageName = TQString::fromUtf8( (*it)->key ).section( '.', 0, 0 ); + const TQString pageName = TQString::fromUtf8((*it)->key).section('.', 0, 0); - if( (TQStringList() << "ui" << "effects" << "subtitles").contains( pageName ) ) + if ((TQStringList() << "ui" << "effects" << "subtitles").contains(pageName)) { continue; + } - if( pageName != currentPage ) { - if( view ) - //NOTE won't be executed for last tab - view->viewport()->setMinimumWidth( grid->sizeHint().width() ); // seems necessary - - TQString pageTitle = pageName; - pageTitle[0] = pageTitle[0].upper(); - - tabs->addTab( view = new TQScrollView, pageTitle ); - view->setResizePolicy( TQScrollView::AutoOneFit ); - view->setHScrollBarMode( TQScrollView::AlwaysOff ); - view->setFrameShape( TQFrame::NoFrame ); - view->addChild( parent = new TQWidget( view->viewport() ) ); - - TQBoxLayout *layout = new TQVBoxLayout( parent, /*margin*/METRIC_3B2, /*spacing*/0 ); - - parent = new TQFrame( parent ); - static_cast<TQFrame*>(parent)->setFrameStyle( TQFrame::Panel | TQFrame::Raised ); - static_cast<TQFrame*>(parent)->setLineWidth( 2 ); - grid = new TQGridLayout( parent, /*rows*/0, /*cols*/2, /*margin*/20, /*spacing*/int(METRIC*2.5) ); - grid->setColStretch( 0, 3 ); - grid->setColStretch( 1, 2 ); - - layout->addWidget( parent, 0 ); - layout->addStretch( 1 ); - - currentPage = pageName; + if (pageName != currentPageName) { + currentPageName = pageName; + + TQString tabTitle = pageName; + tabTitle[0] = tabTitle[0].upper(); + + view = new TQScrollView(page); + view->setHScrollBarMode(TQScrollView::ScrollBarMode::AlwaysOff); + // TODO: It would be nice to leave VScrollBarMode on Auto, but + // there seems to be an issue when calculating the layout size. + // https://mirror.git.trinitydesktop.org/gitea/TDE/codeine/pulls/18 + view->setVScrollBarMode(TQScrollView::ScrollBarMode::AlwaysOn); + view->setResizePolicy(TQScrollView::AutoOneFit); + view->setFrameShape(TQFrame::NoFrame); + tabs->addTab(view, tabTitle); + + scrollWidget = new TQWidget(view->viewport()); + view->addChild(scrollWidget); + + grid = new TQGridLayout(scrollWidget, 0, 2, marginHint(), spacingHint()); + grid->setColStretch(0, 3); + grid->setColStretch(1, 2); + grid->setAlignment(TQt::AlignTop | TQt::AlignAuto); } - m_entrys.append( new XineConfigEntry( parent, grid, *it ) ); + m_entrys.append(new XineConfigEntry(scrollWidget, grid, *it)); } - //finishing touches - m_entrys.setAutoDelete( true ); + // finishing touches + m_entrys.setAutoDelete(true); + topLayout->addWidget(tabs, 1); + enableButton( Ok, false ); enableButton( User1, false ); @@ -261,7 +237,7 @@ XineConfigEntry::XineConfigEntry( TQWidget *parent, TQGridLayout *grid, xine_cfg TQToolTip::add( w, tip ); TQToolTip::add( description, tip ); -// grid->addWidget( description, row, 0, TQt::AlignVCenter ); + grid->addWidget( description, row, 0, TQt::AlignVCenter ); grid->addWidget( w, row, 1, TQt::AlignTop ); } |