mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Properly manage additional questions in SourceTreePopupWidget.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
||||||
* Copyright 2012 Teo Mrnjavac <teo@kde.org>
|
* Copyright 2012-2014 Teo Mrnjavac <teo@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -88,6 +88,12 @@ SourceTreePopupDialog::SourceTreePopupDialog()
|
|||||||
TomahawkStyle::BORDER_LINE.name() + "; }" );
|
TomahawkStyle::BORDER_LINE.name() + "; }" );
|
||||||
m_layout->addWidget( m_separatorLine );
|
m_layout->addWidget( m_separatorLine );
|
||||||
m_layout->addWidget( m_label );
|
m_layout->addWidget( m_label );
|
||||||
|
QHBoxLayout* questionsSpacerLayout = new QHBoxLayout;
|
||||||
|
m_layout->addLayout( questionsSpacerLayout );
|
||||||
|
m_questionsLayout = new QVBoxLayout;
|
||||||
|
questionsSpacerLayout->addStretch( 1 );
|
||||||
|
questionsSpacerLayout->addLayout( m_questionsLayout );
|
||||||
|
TomahawkUtils::unmarginLayout( questionsSpacerLayout );
|
||||||
m_layout->addWidget( m_buttons );
|
m_layout->addWidget( m_buttons );
|
||||||
setContentsMargins( contentsMargins().left() + 12,
|
setContentsMargins( contentsMargins().left() + 12,
|
||||||
contentsMargins().top() + 8,
|
contentsMargins().top() + 8,
|
||||||
@@ -155,25 +161,22 @@ SourceTreePopupDialog::setOkButtonText( const QString& text )
|
|||||||
void
|
void
|
||||||
SourceTreePopupDialog::setExtraQuestions( const Tomahawk::PlaylistDeleteQuestions& questions )
|
SourceTreePopupDialog::setExtraQuestions( const Tomahawk::PlaylistDeleteQuestions& questions )
|
||||||
{
|
{
|
||||||
|
//First we clear
|
||||||
|
clearQuestionWidgets();
|
||||||
|
|
||||||
m_questions = questions;
|
m_questions = questions;
|
||||||
|
|
||||||
int baseHeight = 80;
|
int baseHeight = 80;
|
||||||
int idx = m_layout->indexOf( m_label ) + 1;
|
|
||||||
foreach ( const Tomahawk::PlaylistDeleteQuestion& question, m_questions )
|
foreach ( const Tomahawk::PlaylistDeleteQuestion& question, m_questions )
|
||||||
{
|
{
|
||||||
QCheckBox* cb = new QCheckBox( question.first, this );
|
QCheckBox* cb = new QCheckBox( question.first, this );
|
||||||
cb->setLayoutDirection( Qt::RightToLeft );
|
cb->setLayoutDirection( Qt::RightToLeft );
|
||||||
cb->setProperty( "data", question.second );
|
cb->setProperty( "data", question.second );
|
||||||
|
|
||||||
QHBoxLayout* h = new QHBoxLayout;
|
m_questionsLayout->addWidget( cb );
|
||||||
h->addStretch( 1 );
|
|
||||||
h->addWidget( cb );
|
|
||||||
// m_layout->insertLayout( h, cb, 0 );
|
|
||||||
m_layout->insertLayout( idx, h, 0 );
|
|
||||||
|
|
||||||
m_questionCheckboxes << cb;
|
m_questionCheckboxes << cb;
|
||||||
idx++;
|
baseHeight += cb->height() + m_questionsLayout->spacing();
|
||||||
baseHeight += cb->height() + m_layout->spacing();
|
|
||||||
}
|
}
|
||||||
setFixedHeight( baseHeight );
|
setFixedHeight( baseHeight );
|
||||||
}
|
}
|
||||||
@@ -233,6 +236,15 @@ SourceTreePopupDialog::showEvent( QShowEvent* )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreePopupDialog::hideEvent( QHideEvent* e )
|
||||||
|
{
|
||||||
|
clearQuestionWidgets();
|
||||||
|
|
||||||
|
QWidget::hideEvent( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SourceTreePopupDialog::onAccepted()
|
SourceTreePopupDialog::onAccepted()
|
||||||
{
|
{
|
||||||
@@ -264,3 +276,15 @@ SourceTreePopupDialog::calculateResults()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SourceTreePopupDialog::clearQuestionWidgets()
|
||||||
|
{
|
||||||
|
while ( QLayoutItem* item = m_questionsLayout->takeAt( 0 ) )
|
||||||
|
if ( QWidget* widget = item->widget() )
|
||||||
|
delete widget;
|
||||||
|
m_questionCheckboxes.clear();
|
||||||
|
|
||||||
|
setFixedHeight( 80 );
|
||||||
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
|
||||||
|
* Copyright 2014 Teo Mrnjavac <teo@kde.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -59,6 +60,7 @@ protected:
|
|||||||
virtual void paintEvent( QPaintEvent* );
|
virtual void paintEvent( QPaintEvent* );
|
||||||
virtual void focusOutEvent( QFocusEvent* );
|
virtual void focusOutEvent( QFocusEvent* );
|
||||||
virtual void showEvent( QShowEvent* );
|
virtual void showEvent( QShowEvent* );
|
||||||
|
virtual void hideEvent( QHideEvent* );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onAccepted();
|
void onAccepted();
|
||||||
@@ -66,8 +68,10 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void calculateResults();
|
void calculateResults();
|
||||||
|
void clearQuestionWidgets();
|
||||||
|
|
||||||
QVBoxLayout* m_layout;
|
QVBoxLayout* m_layout;
|
||||||
|
QVBoxLayout* m_questionsLayout;
|
||||||
QList< QCheckBox* > m_questionCheckboxes;
|
QList< QCheckBox* > m_questionCheckboxes;
|
||||||
|
|
||||||
bool m_result;
|
bool m_result;
|
||||||
|
Reference in New Issue
Block a user