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 = \
ui/sprefs_subtitles.h \
ui/sprefs_video.h \
ui/streampanel.h \
ui/messages_panel.h \
ui/sout.h
DEPS_res = \
......@@ -356,6 +357,7 @@ EXTRA_DIST += \
ui/sprefs_subtitles.ui \
ui/sprefs_video.ui \
ui/streampanel.ui \
ui/messages_panel.ui \
ui/sout.ui \
ui/vlm.ui \
$(DEPS_res)
......
......@@ -76,90 +76,39 @@ MessagesDialog::MessagesDialog( intf_thread_t *_p_intf)
setWindowTitle( qtr( "Messages" ) );
setWindowRole( "vlc-messages" );
/* General widgets */
QGridLayout *mainLayout = new QGridLayout( this );
mainTab = new QTabWidget( this );
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" ) );
/* Build Ui */
ui.setupUi( this );
updateTree();
/* Modules tree */
QWidget *treeWidget = new QWidget;
QGridLayout *treeLayout = new QGridLayout( treeWidget );
modulesTree = new QTreeWidget();
modulesTree->header()->hide();
treeLayout->addWidget( modulesTree, 0, 0, 1, 0 );
mainTab->addTab( treeWidget, qtr( "Modules tree" ) );
ui.modulesTree->header()->hide();
/* Buttons and general layout */
QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
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 );
ui.saveLogButton->setToolTip( qtr( "Saves all the displayed logs to a file" ) );
verbosityLabel = new QLabel( qtr( "Verbosity Level" ) );
ui.verbosityBox->setValue( var_InheritInteger( p_intf, "verbose" ) );
vbobjectsEdit = new QLineEdit();
vbobjectsEdit->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
vbobjectsEdit->setText(config_GetPsz( p_intf, "verbose-objects"));
vbobjectsEdit->setToolTip( "verbose-objects usage: \n"
ui.vbobjectsEdit->setText(config_GetPsz( p_intf, "verbose-objects"));
ui.vbobjectsEdit->setToolTip( "verbose-objects usage: \n"
"--verbose-objects=+printthatobject,-dontprintthatone\n"
"(keyword 'all' to applies to all objects)");
vbobjectsLabel = new QLabel( qtr( "Filter:" ) );
mainLayout->addWidget( mainTab, 0, 0, 1, 0 );
mainLayout->addWidget( verbosityLabel, 1, 0, 1, 1 );
mainLayout->addWidget( verbosityBox, 1, 1 );
mainLayout->addWidget( vbobjectsLabel, 1, 2, 1, 1 );
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 ),
BUTTONACT( ui.clearButton, clear() );
BUTTONACT( ui.updateButton, updateTree() );
BUTTONACT( ui.saveLogButton, save() );
CONNECT( ui.vbobjectsEdit, editingFinished(), this, updateConfig());
CONNECT( ui.bottomButtonsBox, rejected(), this, hide() );
CONNECT( ui.verbosityBox, valueChanged( int ),
this, changeVerbosity( int ) );
/* General action */
readSettings( "Messages", QSize( 600, 450 ) );
/* Hook up to LibVLC messaging */
cbData = new msg_cb_data_t;
cbData->self = this;
sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, cbData );
changeVerbosity( verbosityBox->value() );
changeVerbosity( ui.verbosityBox->value() );
}
MessagesDialog::~MessagesDialog()
......@@ -174,42 +123,17 @@ void MessagesDialog::changeVerbosity( int 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()
{
config_PutPsz(p_intf, "verbose-objects", qtu(vbobjectsEdit->text()));
config_PutPsz(p_intf, "verbose-objects", qtu(ui.vbobjectsEdit->text()));
//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,
so disable all by default and enable those that user wants */
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;
while( (psz_object = strsep( &iter, "," )) )
{
......@@ -232,6 +156,7 @@ void MessagesDialog::updateConfig()
void MessagesDialog::sinkMessage( msg_item_t *item )
{
QTextEdit *messages = ui.messages;
/* Only scroll if the viewport is at the end.
Don't bug user by auto-changing/loosing viewport on insert(). */
bool b_autoscroll = ( messages->verticalScrollBar()->value()
......@@ -288,17 +213,9 @@ void MessagesDialog::customEvent( QEvent *event )
sinkMessage( msge->msg );
}
void MessagesDialog::clearOrUpdate()
{
if( mainTab->currentIndex() )
updateTree();
else
clear();
}
void MessagesDialog::clear()
{
messages->clear();
ui.messages->clear();
}
bool MessagesDialog::save()
......@@ -320,7 +237,7 @@ bool MessagesDialog::save()
}
QTextStream out( &file );
out << messages->toPlainText() << "\n";
out << ui.messages->toPlainText() << "\n";
return true;
}
......@@ -335,7 +252,7 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
if( parentItem )
item = new QTreeWidgetItem( parentItem );
else
item = new QTreeWidgetItem( modulesTree );
item = new QTreeWidgetItem( ui.modulesTree );
char *name = vlc_object_get_name( p_obj );
if( name != NULL )
......@@ -359,7 +276,7 @@ void MessagesDialog::buildTree( QTreeWidgetItem *parentItem,
void MessagesDialog::updateTree()
{
modulesTree->clear();
ui.modulesTree->clear();
buildTree( NULL, VLC_OBJECT( p_intf->p_libvlc ) );
}
......
......@@ -26,6 +26,7 @@
#include "util/qvlcframe.hpp"
#include "util/singleton.hpp"
#include "ui/messages_panel.h"
class QTabWidget;
class QPushButton;
......@@ -44,15 +45,7 @@ private:
MessagesDialog( intf_thread_t * );
virtual ~MessagesDialog();
QTabWidget *mainTab;
QSpinBox *verbosityBox;
QLabel *verbosityLabel;
QTextEdit *messages;
QTreeWidget *modulesTree;
QPushButton *clearUpdateButton;
QPushButton *saveLogButton;
QLineEdit *vbobjectsEdit;
QLabel *vbobjectsLabel;
Ui::messagesPanelWidget ui;
msg_subscription_t *sub;
msg_cb_data_t *cbData;
static void sinkMessage( msg_cb_data_t *, msg_item_t *, unsigned );
......@@ -60,14 +53,12 @@ private:
void sinkMessage( msg_item_t *item );
private slots:
void updateTab( int );
void clearOrUpdate();
bool save();
void updateConfig();
void changeVerbosity( int );
private:
void clear();
void updateTree();
private:
void buildTree( QTreeWidgetItem *, vlc_object_t * );
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