Commit c3338de6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: profiles for the interface toolbar edition

parent 7ca5ee99
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <QDragEnterEvent> #include <QDragEnterEvent>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QInputDialog>
ToolbarEditDialog *ToolbarEditDialog::instance = NULL; ToolbarEditDialog *ToolbarEditDialog::instance = NULL;
...@@ -134,6 +135,37 @@ ToolbarEditDialog::ToolbarEditDialog( intf_thread_t *_p_intf) ...@@ -134,6 +135,37 @@ ToolbarEditDialog::ToolbarEditDialog( intf_thread_t *_p_intf)
mainLayout->addWidget( FSCToolbarBox, 3, 0, 1, -1 ); mainLayout->addWidget( FSCToolbarBox, 3, 0, 1, -1 );
/* Profile */
QGroupBox *profileBox = new QGroupBox( qtr( "Profile" ), this );
QGridLayout *profileBoxLayout = new QGridLayout( profileBox );
profileCombo = new QComboBox;
QLabel *profileLabel = new QLabel( qtr( "Select profile:" ), this );
QToolButton *newButton = new QToolButton;
newButton->setIcon( QIcon( ":/new" ) );
QToolButton *deleteButton = new QToolButton;
deleteButton->setIcon( QIcon( ":/clear" ) );
deleteButton->setToolTip( qtr( "Delete the current profile" ) );
profileBoxLayout->addWidget( profileLabel, 0, 0 );
profileBoxLayout->addWidget( profileCombo, 0, 1 );
profileBoxLayout->addWidget( newButton, 0, 2 );
profileBoxLayout->addWidget( deleteButton, 0, 3 );
mainLayout->addWidget( profileBox, 4, 0, 1, -1 );
/* Fill combos */
int i_size = getSettings()->beginReadArray( "ToolbarProfiles" );
for( int i = 0; i < i_size; i++ )
{
getSettings()->setArrayIndex(i);
profileCombo->addItem( getSettings()->value( "ProfileName" ).toString(),
getSettings()->value( "Value" ).toString() );
}
getSettings()->endArray();
profileCombo->setCurrentIndex( -1 );
/* Buttons */ /* Buttons */
QDialogButtonBox *okCancel = new QDialogButtonBox; QDialogButtonBox *okCancel = new QDialogButtonBox;
QPushButton *okButton = new QPushButton( qtr( "Cl&ose" ), this ); QPushButton *okButton = new QPushButton( qtr( "Cl&ose" ), this );
...@@ -142,14 +174,62 @@ ToolbarEditDialog::ToolbarEditDialog( intf_thread_t *_p_intf) ...@@ -142,14 +174,62 @@ ToolbarEditDialog::ToolbarEditDialog( intf_thread_t *_p_intf)
okCancel->addButton( okButton, QDialogButtonBox::AcceptRole ); okCancel->addButton( okButton, QDialogButtonBox::AcceptRole );
okCancel->addButton( cancelButton, QDialogButtonBox::RejectRole ); okCancel->addButton( cancelButton, QDialogButtonBox::RejectRole );
BUTTONACT( deleteButton, deleteProfile() );
BUTTONACT( newButton, newProfile() );
CONNECT( profileCombo, currentIndexChanged( int ), this, changeProfile( int ) );
BUTTONACT( okButton, close() ); BUTTONACT( okButton, close() );
BUTTONACT( cancelButton, cancel() ); BUTTONACT( cancelButton, cancel() );
mainLayout->addWidget( okCancel, 4, 2 ); mainLayout->addWidget( okCancel, 5, 2 );
} }
ToolbarEditDialog::~ToolbarEditDialog() ToolbarEditDialog::~ToolbarEditDialog()
{ {
getSettings()->beginWriteArray( "ToolbarProfiles" );
for( int i = 0; i < profileCombo->count(); i++ )
{
getSettings()->setArrayIndex(i);
getSettings()->setValue( "ProfileName", profileCombo->itemText( i ) );
getSettings()->setValue( "Value", profileCombo->itemData( i ) );
}
getSettings()->endArray();
}
void ToolbarEditDialog::newProfile()
{
bool ok;
QString name = QInputDialog::getText( this, qtr( "Profile Name" ),
qtr( "Please enter the new profile name." ), QLineEdit::Normal, 0, &ok );
if( !ok ) return;
QString temp = QString::number( positionCombo->currentIndex() );
temp += "|" + controller1->getValue();
temp += "|" + controller2->getValue();
temp += "|" + controllerA->getValue();
temp += "|" + controller->getValue();
temp += "|" + controllerFSC->getValue();
profileCombo->addItem( name, temp );
profileCombo->setCurrentIndex( profileCombo->count() - 1 );
}
void ToolbarEditDialog::deleteProfile()
{
profileCombo->removeItem( profileCombo->currentIndex() );
}
void ToolbarEditDialog::changeProfile( int i )
{
QStringList qs_list = profileCombo->itemData( i ).toString().split( "|" );
if( qs_list.count() < 6 )
return;
positionCombo->setCurrentIndex( positionCombo->findData( qs_list[0].toInt() ) );
controller1->resetLine( qs_list[1] );
controller2->resetLine( qs_list[2] );
controllerA->resetLine( qs_list[3] );
controller->resetLine( qs_list[4] );
controllerFSC->resetLine( qs_list[5] );
} }
void ToolbarEditDialog::close() void ToolbarEditDialog::close()
...@@ -384,6 +464,21 @@ DroppingController::DroppingController( intf_thread_t *_p_intf, ...@@ -384,6 +464,21 @@ DroppingController::DroppingController( intf_thread_t *_p_intf,
parseAndCreate( line, controlLayout ); parseAndCreate( line, controlLayout );
} }
void DroppingController::resetLine( QString line )
{
hide();
QLayoutItem *child;
int i =0;
while( (child = controlLayout->takeAt( 0 ) ) != 0 )
{
child->widget()->hide();
delete child;
}
parseAndCreate( line, controlLayout );
show();
}
/* Overloading the AbstractController one, because we don't manage the /* Overloading the AbstractController one, because we don't manage the
Spacing items in the same ways */ Spacing items in the same ways */
void DroppingController::createAndAddWidget( QBoxLayout *controlLayout, void DroppingController::createAndAddWidget( QBoxLayout *controlLayout,
......
...@@ -57,6 +57,8 @@ public: ...@@ -57,6 +57,8 @@ public:
instance = new ToolbarEditDialog( p_intf ); instance = new ToolbarEditDialog( p_intf );
return instance; return instance;
} }
static void killInstance()
{ if( instance ) delete instance; instance = NULL;}
virtual ~ToolbarEditDialog(); virtual ~ToolbarEditDialog();
int getOptions() { return flatBox->isChecked() * WIDGET_FLAT + int getOptions() { return flatBox->isChecked() * WIDGET_FLAT +
bigBox->isChecked() * WIDGET_BIG + bigBox->isChecked() * WIDGET_BIG +
...@@ -66,13 +68,16 @@ private: ...@@ -66,13 +68,16 @@ private:
static ToolbarEditDialog *instance; static ToolbarEditDialog *instance;
QCheckBox *flatBox, *bigBox, *shinyBox; QCheckBox *flatBox, *bigBox, *shinyBox;
QComboBox *positionCombo; QComboBox *positionCombo, *profileCombo;
WidgetListing *widgetListing; WidgetListing *widgetListing;
DroppingController *controller1, *controller2, *controllerA; DroppingController *controller1, *controller2, *controllerA;
DroppingController *controllerFSC, *controller; DroppingController *controllerFSC, *controller;
private slots: private slots:
void newProfile();
void deleteProfile();
void changeProfile( int );
void cancel(); void cancel();
void close(); void close();
}; };
...@@ -85,6 +90,7 @@ public: ...@@ -85,6 +90,7 @@ public:
QString getValue(); QString getValue();
virtual ~DroppingController(); virtual ~DroppingController();
void resetLine( QString );
protected: protected:
virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index, virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
buttonType_e i_type, int i_option ); buttonType_e i_type, int i_option );
......
...@@ -80,7 +80,6 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) : ...@@ -80,7 +80,6 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
DialogsProvider::~DialogsProvider() DialogsProvider::~DialogsProvider()
{ {
msg_Dbg( p_intf, "Destroying the Dialog Provider" );
PlaylistDialog::killInstance(); PlaylistDialog::killInstance();
MediaInfoDialog::killInstance(); MediaInfoDialog::killInstance();
MessagesDialog::killInstance(); MessagesDialog::killInstance();
...@@ -90,6 +89,7 @@ DialogsProvider::~DialogsProvider() ...@@ -90,6 +89,7 @@ DialogsProvider::~DialogsProvider()
#ifdef UPDATE_CHECK #ifdef UPDATE_CHECK
UpdateDialog::killInstance(); UpdateDialog::killInstance();
#endif #endif
ToolbarEditDialog::killInstance();
delete menusMapper; delete menusMapper;
delete menusUpdateMapper; delete menusUpdateMapper;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment