|
|
|
@ -244,42 +244,39 @@ SPrefsCatList::SPrefsCatList( qt_intf_t *_p_intf, QWidget *_parent ) : |
|
|
|
See QT bugs 131 & 816 and QAbstractButton's source code. */ |
|
|
|
QSignalMapper *mapper = new QSignalMapper( layout ); |
|
|
|
connect( mapper, QSIGNALMAPPER_MAPPEDINT_SIGNAL, this, &SPrefsCatList::switchPanel ); |
|
|
|
|
|
|
|
QPixmap scaled; |
|
|
|
qreal dpr = devicePixelRatioF(); |
|
|
|
|
|
|
|
#define ADD_CATEGORY( button, label, ltooltip, icon, numb ) \ |
|
|
|
QToolButton * button = new QToolButton( this ); \ |
|
|
|
/* Scale icon to non native size outside of toolbutton to avoid widget size */\ |
|
|
|
/* computation using native size */\ |
|
|
|
scaled = QPixmap( icon )\ |
|
|
|
.scaledToHeight( ICON_HEIGHT * dpr, Qt::SmoothTransformation );\ |
|
|
|
scaled.setDevicePixelRatio( dpr ); \ |
|
|
|
button->setIcon( scaled ); \ |
|
|
|
button->setText( label ); \ |
|
|
|
button->setToolTip( ltooltip ); \ |
|
|
|
button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); \ |
|
|
|
button->setIconSize( QSize( ICON_WIDTH, ICON_HEIGHT ) ); \ |
|
|
|
button->setMinimumWidth( 40 + ICON_WIDTH );\ |
|
|
|
button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); \ |
|
|
|
button->setAutoRaise( true ); \ |
|
|
|
button->setCheckable( true ); \ |
|
|
|
button->setAutoExclusive( true ); \ |
|
|
|
connect( button, &QToolButton::clicked, mapper, QOverload<>::of(&QSignalMapper::map) ); \ |
|
|
|
mapper->setMapping( button, numb ); \ |
|
|
|
layout->addWidget( button ); |
|
|
|
|
|
|
|
ADD_CATEGORY( SPrefsInterface, qfut(INTF_TITLE), qfut(INTF_TOOLTIP), ":/prefsmenu/spref_interface.png" , 0 ); |
|
|
|
ADD_CATEGORY( SPrefsAudio, qfut(AUDIO_TITLE), qfut(AUDIO_TOOLTIP), ":/prefsmenu/spref_audio.png", 1 ); |
|
|
|
ADD_CATEGORY( SPrefsVideo, qfut(VIDEO_TITLE), qfut(VIDEO_TOOLTIP), ":/prefsmenu/spref_video.png", 2 ); |
|
|
|
ADD_CATEGORY( SPrefsSubtitles, qfut(SUBPIC_TITLE), qfut(SUBPIC_TOOLTIP), ":/prefsmenu/spref_subtitles.png", 3 ); |
|
|
|
ADD_CATEGORY( SPrefsInputAndCodecs, qfut(INPUT_TITLE), qfut(INPUT_TOOLTIP), ":/prefsmenu/spref_input.png", 4 ); |
|
|
|
ADD_CATEGORY( SPrefsHotkeys, qfut(HOTKEYS_TITLE), qfut(HOTKEYS_TOOLTIP), ":/prefsmenu/spref_hotkeys.png", 5 ); |
|
|
|
ADD_CATEGORY( SPrefsMediaLibrary, qfut(ML_TITLE), qfut(ML_TOOLTIP), ":/prefsmenu/spref_medialibrary.png", 6 ); |
|
|
|
|
|
|
|
#undef ADD_CATEGORY |
|
|
|
|
|
|
|
SPrefsInterface->setChecked( true ); |
|
|
|
auto addCategory = [&]( QString label, QString ltooltip, QString icon, int numb) { |
|
|
|
QToolButton * button = new QToolButton( this ); |
|
|
|
/* Scale icon to non native size outside of toolbutton to avoid widget size */ |
|
|
|
/* computation using native size */ |
|
|
|
QPixmap scaled = QPixmap( icon ) |
|
|
|
.scaledToHeight( ICON_HEIGHT * dpr, Qt::SmoothTransformation ); |
|
|
|
scaled.setDevicePixelRatio( dpr ); |
|
|
|
button->setIcon( scaled ); |
|
|
|
button->setText( label ); |
|
|
|
button->setToolTip( ltooltip ); |
|
|
|
button->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); |
|
|
|
button->setIconSize( QSize( ICON_WIDTH, ICON_HEIGHT ) ); |
|
|
|
button->setMinimumWidth( 40 + ICON_WIDTH ); |
|
|
|
button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); |
|
|
|
button->setAutoRaise( true ); |
|
|
|
button->setCheckable( true ); |
|
|
|
button->setAutoExclusive( true ); |
|
|
|
connect( button, &QToolButton::clicked, mapper, QOverload<>::of(&QSignalMapper::map) ); |
|
|
|
mapper->setMapping( button, numb ); |
|
|
|
layout->addWidget( button ); |
|
|
|
}; |
|
|
|
|
|
|
|
addCategory( qfut(INTF_TITLE), qfut(INTF_TOOLTIP), ":/prefsmenu/spref_interface.png" , 0 ); |
|
|
|
addCategory( qfut(AUDIO_TITLE), qfut(AUDIO_TOOLTIP), ":/prefsmenu/spref_audio.png", 1 ); |
|
|
|
addCategory( qfut(VIDEO_TITLE), qfut(VIDEO_TOOLTIP), ":/prefsmenu/spref_video.png", 2 ); |
|
|
|
addCategory( qfut(SUBPIC_TITLE), qfut(SUBPIC_TOOLTIP), ":/prefsmenu/spref_subtitles.png", 3 ); |
|
|
|
addCategory( qfut(INPUT_TITLE), qfut(INPUT_TOOLTIP), ":/prefsmenu/spref_input.png", 4 ); |
|
|
|
addCategory( qfut(HOTKEYS_TITLE), qfut(HOTKEYS_TOOLTIP), ":/prefsmenu/spref_hotkeys.png", 5 ); |
|
|
|
addCategory( qfut(ML_TITLE), qfut(ML_TOOLTIP), ":/prefsmenu/spref_medialibrary.png", 6 ); |
|
|
|
|
|
|
|
qobject_cast<QToolButton*>(mapper->mapping(0))->setChecked(true); |
|
|
|
layout->setContentsMargins(0, 0, 0, 0); |
|
|
|
layout->setSpacing( 1 ); |
|
|
|
|
|
|
|
|