Commit 4f0c843d authored by Francois Cartegnie's avatar Francois Cartegnie Committed by Jean-Baptiste Kempf

Qt: simplifiy/rebase messages on QtCreator. Fix Ui Logic

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent fe65deaa
...@@ -85,6 +85,7 @@ nodist_SOURCES_qt4 = \ ...@@ -85,6 +85,7 @@ nodist_SOURCES_qt4 = \
ui/sprefs_subtitles.h \ ui/sprefs_subtitles.h \
ui/sprefs_video.h \ ui/sprefs_video.h \
ui/streampanel.h \ ui/streampanel.h \
ui/messages_panel.h \
ui/sout.h ui/sout.h
DEPS_res = \ DEPS_res = \
...@@ -356,6 +357,7 @@ EXTRA_DIST += \ ...@@ -356,6 +357,7 @@ EXTRA_DIST += \
ui/sprefs_subtitles.ui \ ui/sprefs_subtitles.ui \
ui/sprefs_video.ui \ ui/sprefs_video.ui \
ui/streampanel.ui \ ui/streampanel.ui \
ui/messages_panel.ui \
ui/sout.ui \ ui/sout.ui \
ui/vlm.ui \ ui/vlm.ui \
$(DEPS_res) $(DEPS_res)
......
...@@ -76,90 +76,39 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf) ...@@ -76,90 +76,39 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
setWindowTitle( qtr( "Messages" ) ); setWindowTitle( qtr( "Messages" ) );
setWindowRole( "vlc-messages" ); setWindowRole( "vlc-messages" );
/* General widgets */ /* Build Ui */
QGridLayout *mainLayout = new QGridLayout( this ); ui.setupUi( this );
mainTab = new QTabWidget( this ); updateTree();
mainTab->setTabPosition( QTabWidget::North );
/* Messages */
QWidget *msgWidget = new QWidget;
QGridLayout *msgLayout = new QGridLayout( msgWidget );
messages = new QTextEdit();
messages->setReadOnly( true );
messages->setGeometry( 0, 0, 440, 600 );
messages->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
messages->setTextInteractionFlags( Qt::TextSelectableByMouse );
msgLayout->addWidget( messages, 0, 0, 1, 0 );
mainTab->addTab( msgWidget, qtr( "Messages" ) );
/* Modules tree */ /* Modules tree */
QWidget *treeWidget = new QWidget; ui.modulesTree->header()->hide();
QGridLayout *treeLayout = new QGridLayout( treeWidget );
modulesTree = new QTreeWidget();
modulesTree->header()->hide();
treeLayout->addWidget( modulesTree, 0, 0, 1, 0 );
mainTab->addTab( treeWidget, qtr( "Modules tree" ) );
/* Buttons and general layout */ /* Buttons and general layout */
QPushButton *closeButton = new QPushButton( qtr( "&Close" ) ); ui.saveLogButton->setToolTip( qtr( "Saves all the displayed logs to a file" ) );
closeButton->setDefault( true );
clearUpdateButton = new QPushButton( qtr( "C&lear" ) );
saveLogButton = new QPushButton( qtr( "&Save as..." ) );
saveLogButton->setToolTip( qtr( "Saves all the displayed logs to a file" ) );
verbosityBox = new QSpinBox();
verbosityBox->setRange( 0, 2 );
verbosityBox->setValue( var_InheritInteger( p_intf, "verbose" ) );
verbosityBox->setWrapping( true );
verbosityBox->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
verbosityLabel = new QLabel( qtr( "Verbosity Level" ) ); ui.verbosityBox->setValue( var_InheritInteger( p_intf, "verbose" ) );
vbobjectsEdit = new QLineEdit(); ui.vbobjectsEdit->setText(config_GetPsz( p_intf, "verbose-objects"));
ui.vbobjectsEdit->setToolTip( "verbose-objects usage: \n"
vbobjectsEdit->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
vbobjectsEdit->setText(config_GetPsz( p_intf, "verbose-objects"));
vbobjectsEdit->setToolTip( "verbose-objects usage: \n"
"--verbose-objects=+printthatobject,-dontprintthatone\n" "--verbose-objects=+printthatobject,-dontprintthatone\n"
"(keyword 'all' to applies to all objects)"); "(keyword 'all' to applies to all objects)");
vbobjectsLabel = new QLabel( qtr( "Filter:" ) ); BUTTONACT( ui.clearButton, clear() );
BUTTONACT( ui.updateButton, updateTree() );
mainLayout->addWidget( mainTab, 0, 0, 1, 0 ); BUTTONACT( ui.saveLogButton, save() );
mainLayout->addWidget( verbosityLabel, 1, 0, 1, 1 ); CONNECT( ui.vbobjectsEdit, editingFinished(), this, updateConfig());
mainLayout->addWidget( verbosityBox, 1, 1 ); CONNECT( ui.bottomButtonsBox, rejected(), this, hide() );
mainLayout->addWidget( vbobjectsLabel, 1, 2, 1, 1 ); CONNECT( ui.verbosityBox, valueChanged( int ),
mainLayout->addWidget( vbobjectsEdit, 1, 3 );
mainLayout->setColumnStretch( 4, 10 );
mainLayout->addWidget( saveLogButton, 1, 5 );
mainLayout->addWidget( clearUpdateButton, 1, 6 );
mainLayout->addWidget( closeButton, 1, 7 );
BUTTONACT( closeButton, hide() );
BUTTONACT( clearUpdateButton, clearOrUpdate() );
BUTTONACT( saveLogButton, save() );
CONNECT( mainTab, currentChanged( int ),
this, updateTab( int ) );
CONNECT(vbobjectsEdit, editingFinished(), this, updateConfig());
CONNECT( verbosityBox, valueChanged( int ),
this, changeVerbosity( int ) ); this, changeVerbosity( int ) );
/* General action */ /* General action */
readSettings( "Messages", QSize( 600, 450 ) ); readSettings( "Messages", QSize( 600, 450 ) );
/* Hook up to LibVLC messaging */ /* Hook up to LibVLC messaging */
cbData = new msg_cb_data_t; cbData = new msg_cb_data_t;
cbData->self = this; cbData->self = this;
sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, cbData ); sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, cbData );
changeVerbosity( verbosityBox->value() ); changeVerbosity( ui.verbosityBox->value() );
} }
MessagesDialog::~MessagesDialog() MessagesDialog::~MessagesDialog()
...@@ -174,42 +123,17 @@ void MessagesDialog::changeVerbosity( int verbosity ) ...@@ -174,42 +123,17 @@ void MessagesDialog::changeVerbosity( int verbosity )
msg_SubscriptionSetVerbosity( sub , verbosity ); msg_SubscriptionSetVerbosity( sub , verbosity );
} }
void MessagesDialog::updateTab( int index )
{
/* Second tab : modules tree */
if( index == 1 )
{
verbosityLabel->hide();
verbosityBox->hide();
vbobjectsLabel->hide();
vbobjectsEdit->hide();
clearUpdateButton->setText( qtr( "&Update" ) );
saveLogButton->hide();
updateTree();
}
/* First tab : messages */
else
{
verbosityLabel->show();
verbosityBox->show();
vbobjectsLabel->show();
vbobjectsEdit->show();
clearUpdateButton->setText( qtr( "&Clear" ) );
saveLogButton->show();
}
}
void MessagesDialog::updateConfig() void MessagesDialog::updateConfig()
{ {
config_PutPsz(p_intf, "verbose-objects", qtu(vbobjectsEdit->text())); config_PutPsz(p_intf, "verbose-objects", qtu(ui.vbobjectsEdit->text()));
//vbobjectsEdit->setText("vbEdit changed!"); //vbobjectsEdit->setText("vbEdit changed!");
if( !vbobjectsEdit->text().isEmpty() ) if( !ui.vbobjectsEdit->text().isEmpty() )
{ {
/* if user sets filter, go with the idea that user just wants that to be shown, /* if user sets filter, go with the idea that user just wants that to be shown,
so disable all by default and enable those that user wants */ so disable all by default and enable those that user wants */
msg_DisableObjectPrinting( p_intf, "all"); msg_DisableObjectPrinting( p_intf, "all");
char * psz_verbose_objects = strdup(qtu(vbobjectsEdit->text())); char * psz_verbose_objects = strdup(qtu(ui.vbobjectsEdit->text()));
char * psz_object, * iter = psz_verbose_objects; char * psz_object, * iter = psz_verbose_objects;
while( (psz_object = strsep( &iter, "," )) ) while( (psz_object = strsep( &iter, "," )) )
{ {
...@@ -232,6 +156,7 @@ void MessagesDialog::updateConfig() ...@@ -232,6 +156,7 @@ void MessagesDialog::updateConfig()
void MessagesDialog::sinkMessage( msg_item_t *item ) void MessagesDialog::sinkMessage( msg_item_t *item )
{ {
QTextEdit *messages = ui.messages;
/* Only scroll if the viewport is at the end. /* Only scroll if the viewport is at the end.
Don't bug user by auto-changing/loosing viewport on insert(). */ Don't bug user by auto-changing/loosing viewport on insert(). */
bool b_autoscroll = ( messages->verticalScrollBar()->value() bool b_autoscroll = ( messages->verticalScrollBar()->value()
...@@ -288,17 +213,9 @@ void MessagesDialog::customEvent( QEvent *event ) ...@@ -288,17 +213,9 @@ void MessagesDialog::customEvent( QEvent *event )
sinkMessage( msge->msg ); sinkMessage( msge->msg );
} }
void MessagesDialog::clearOrUpdate()
{
if( mainTab->currentIndex() )
updateTree();
else
clear();
}
void MessagesDialog::clear() void MessagesDialog::clear()
{ {
messages->clear(); ui.messages->clear();
} }
bool MessagesDialog::save() bool MessagesDialog::save()
...@@ -320,7 +237,7 @@ bool MessagesDialog::save() ...@@ -320,7 +237,7 @@ bool MessagesDialog::save()
} }
QTextStream out( &file ); QTextStream out( &file );
out << messages->toPlainText() << "\n"; out << ui.messages->toPlainText() << "\n";
return true; return true;
} }
...@@ -335,7 +252,7 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem, ...@@ -335,7 +252,7 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
if( parentItem ) if( parentItem )
item = new QTreeWidgetItem( parentItem ); item = new QTreeWidgetItem( parentItem );
else else
item = new QTreeWidgetItem( modulesTree ); item = new QTreeWidgetItem( ui.modulesTree );
char *name = vlc_object_get_name( p_obj ); char *name = vlc_object_get_name( p_obj );
if( name != NULL ) if( name != NULL )
...@@ -359,7 +276,7 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem, ...@@ -359,7 +276,7 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
void MessagesDialog::updateTree() void MessagesDialog::updateTree()
{ {
modulesTree->clear(); ui.modulesTree->clear();
buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) ); buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) );
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/singleton.hpp" #include "util/singleton.hpp"
#include "ui/messages_panel.h"
class QTabWidget; class QTabWidget;
class QPushButton; class QPushButton;
...@@ -44,15 +45,7 @@ private: ...@@ -44,15 +45,7 @@ private:
MessagesDialog( intf_thread_t * ); MessagesDialog( intf_thread_t * );
virtual ~MessagesDialog(); virtual ~MessagesDialog();
QTabWidget *mainTab; Ui::messagesPanelWidget ui;
QSpinBox *verbosityBox;
QLabel *verbosityLabel;
QTextEdit *messages;
QTreeWidget *modulesTree;
QPushButton *clearUpdateButton;
QPushButton *saveLogButton;
QLineEdit *vbobjectsEdit;
QLabel *vbobjectsLabel;
msg_subscription_t *sub; msg_subscription_t *sub;
msg_cb_data_t *cbData; msg_cb_data_t *cbData;
static void sinkMessage( msg_cb_data_t *, msg_item_t *, unsigned ); static void sinkMessage( msg_cb_data_t *, msg_item_t *, unsigned );
...@@ -60,14 +53,12 @@ private: ...@@ -60,14 +53,12 @@ private:
void sinkMessage( msg_item_t *item ); void sinkMessage( msg_item_t *item );
private slots: private slots:
void updateTab( int );
void clearOrUpdate();
bool save(); bool save();
void updateConfig(); void updateConfig();
void changeVerbosity( int ); void changeVerbosity( int );
private:
void clear(); void clear();
void updateTree(); void updateTree();
private:
void buildTree( QTreeWidgetItem *, vlc_object_t * ); void buildTree( QTreeWidgetItem *, vlc_object_t * );
friend class Singleton<MessagesDialog>; friend class Singleton<MessagesDialog>;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>messagesPanelWidget</class>
<widget class="QWidget" name="messagesPanelWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>570</width>
<height>440</height>
</rect>
</property>
<property name="windowTitle">
<string>Messages</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="mainTab">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Messages</string>
</attribute>
<layout class="QGridLayout" name="msgLayout">
<item row="0" column="0" colspan="6">
<widget class="QTextEdit" name="messages">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Verbosity:</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="clearButton">
<property name="text">
<string>&amp;Clear</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="verbosityBox">
<property name="wrapping">
<bool>true</bool>
</property>
<property name="maximum">
<number>2</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Filter:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="vbobjectsEdit"/>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="saveLogButton">
<property name="text">
<string>&amp;Save as...</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Modules Tree</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTreeWidget" name="modulesTree">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="updateButton">
<property name="text">
<string>&amp;Update</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="bottomButtonsBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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