diff --git a/configure.ac b/configure.ac index 4b37c17..e44b1e0 100644 --- a/configure.ac +++ b/configure.ac @@ -128,6 +128,9 @@ AC_CHECK_TOOLS([RCC], [rcc-qt4 rcc]) MOC="" AC_ARG_VAR([MOC], [moc command]) AC_CHECK_TOOLS([MOC], [moc-qt4 moc]) +UIC="" +AC_ARG_VAR([UIC], [uic command]) +AC_CHECK_TOOLS([UIC], [uic-qt4 uic]) dnl Equalizer dnl We assume that Equalizer includes GLEW. If we don't use Equalizer, we need GLEW separately. diff --git a/src/Makefile.am b/src/Makefile.am index 8df35d3..d189e7a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -73,6 +73,7 @@ nodist_bino_SOURCES = \ qt_resources.qrc \ qt_resources-rcc.cpp \ player_qt-moc.cpp \ + player_qt-ui.h \ video_output_qt-moc.cpp \ video_output_color.fs.glsl.h \ video_output_render.fs.glsl.h @@ -120,6 +121,13 @@ rcc_verbose_0 = @echo " RCC " $@; %-rcc.cpp: %.qrc $(rcc_verbose)$(RCC) -o $@ $< +ui_verbose = $(ui_verbose_$(V)) +ui_verbose_ = $(ui_verbose_$(AM_DEFAULT_VERBOSITY)) +ui_verbose_0 = @echo " UIC " $@; + +%-ui.h: %.ui + $(ui_verbose)$(UIC) -o $@ $< + %.glsl.h: %.glsl $(AM_V_GEN)MACRONAME="`echo $< | sed -e s/^.*\\\/// -e s/\\\.glsl$$// -e s/[\\\.-]/_/g | tr [a-z] [A-Z]`_GLSL_STR"; \ (echo "/* GENERATED AUTOMATICALLY FROM $< */"; \ diff --git a/src/player_qt.cpp b/src/player_qt.cpp index 10b1d32..a33921a 100644 --- a/src/player_qt.cpp +++ b/src/player_qt.cpp @@ -137,134 +137,22 @@ void player_qt_internal::move_event() } -in_out_widget::in_out_widget(QSettings *settings, const player_qt_internal *player, QWidget *parent) : - QWidget(parent), _settings(settings), _player(player), _lock(false) -{ - QGridLayout *layout0 = new QGridLayout; - QLabel *video_label = new QLabel(_("Video:")); - video_label->setToolTip(_("

Select the video stream.

")); - layout0->addWidget(video_label, 0, 0); - _video_combobox = new QComboBox(this); - _video_combobox->setToolTip(video_label->toolTip()); - connect(_video_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(video_changed())); - layout0->addWidget(_video_combobox, 0, 1); - QLabel *audio_label = new QLabel(_("Audio:")); - audio_label->setToolTip(_("

Select the audio stream.

")); - layout0->addWidget(audio_label, 0, 2); - _audio_combobox = new QComboBox(this); - _audio_combobox->setToolTip(audio_label->toolTip()); - connect(_audio_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(audio_changed())); - layout0->addWidget(_audio_combobox, 0, 3); - QLabel *subtitle_label = new QLabel(_("Subtitle:")); - subtitle_label->setToolTip(_("

Select the subtitle stream.

")); - layout0->addWidget(subtitle_label, 0, 4); - _subtitle_combobox = new QComboBox(this); - _subtitle_combobox->setToolTip(subtitle_label->toolTip()); - connect(_subtitle_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(subtitle_changed())); - layout0->addWidget(_subtitle_combobox, 0, 5); - layout0->setColumnStretch(1, 1); - layout0->setColumnStretch(3, 1); - layout0->setColumnStretch(5, 1); - - QGridLayout *layout1 = new QGridLayout; - QLabel *input_label = new QLabel(_("Input:")); - input_label->setToolTip(_("

Set the 3D layout of the video stream.

")); - layout1->addWidget(input_label, 0, 0); - _input_combobox = new QComboBox(this); - _input_combobox->setToolTip(input_label->toolTip()); - _input_combobox->addItem(_("2D")); - _input_combobox->addItem(_("Separate streams, left first")); - _input_combobox->addItem(_("Separate streams, right first")); - _input_combobox->addItem(_("Top/bottom")); - _input_combobox->addItem(_("Top/bottom, half height")); - _input_combobox->addItem(_("Bottom/top")); - _input_combobox->addItem(_("Bottom/top, half height")); - _input_combobox->addItem(_("Left/right")); - _input_combobox->addItem(_("Left/right, half width")); - _input_combobox->addItem(_("Right/left")); - _input_combobox->addItem(_("Right/left, half width")); - _input_combobox->addItem(_("Even/odd rows")); - _input_combobox->addItem(_("Odd/even rows")); - connect(_input_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(input_changed())); - layout1->addWidget(_input_combobox, 0, 1); - layout1->setColumnStretch(1, 1); - - QGridLayout *layout2 = new QGridLayout; - QLabel *output_label = new QLabel(_("Output:")); - output_label->setToolTip(_("

Set the 3D output type for your display.

")); - layout2->addWidget(output_label, 0, 0); - _output_combobox = new QComboBox(this); - _output_combobox->setToolTip(output_label->toolTip()); - _output_combobox->addItem(_("Left view")); - _output_combobox->addItem(_("Right view")); - _output_combobox->addItem(_("OpenGL stereo")); - _output_combobox->addItem(_("Top/bottom")); - _output_combobox->addItem(_("Top/bottom, half height")); - _output_combobox->addItem(_("Left/right")); - _output_combobox->addItem(_("Left/right, half width")); - _output_combobox->addItem(_("Even/odd rows")); - _output_combobox->addItem(_("Even/odd columns")); - _output_combobox->addItem(_("Checkerboard pattern")); - _output_combobox->addItem(_("HDMI frame packing mode")); - _output_combobox->addItem(_("Red/cyan glasses, monochrome method")); - _output_combobox->addItem(_("Red/cyan glasses, half-color method")); - _output_combobox->addItem(_("Red/cyan glasses, full-color method")); - _output_combobox->addItem(_("Red/cyan glasses, high-quality Dubois method")); - _output_combobox->addItem(_("Green/magenta glasses, monochrome method")); - _output_combobox->addItem(_("Green/magenta glasses, half-color method")); - _output_combobox->addItem(_("Green/magenta glasses, full-color method")); - _output_combobox->addItem(_("Green/magenta glasses, high-quality Dubois method")); - _output_combobox->addItem(_("Amber/blue glasses, monochrome method")); - _output_combobox->addItem(_("Amber/blue glasses, half-color method")); - _output_combobox->addItem(_("Amber/blue glasses, full-color method")); - _output_combobox->addItem(_("Amber/blue glasses, high-quality Dubois method")); - _output_combobox->addItem(_("Red/green glasses, monochrome method")); - _output_combobox->addItem(_("Red/blue glasses, monochrome method")); - connect(_output_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(output_changed())); - layout2->addWidget(_output_combobox, 0, 1); - layout2->setColumnStretch(1, 1); - _swap_checkbox = new QCheckBox(_("Swap left/right")); - _swap_checkbox->setToolTip(_("

Swap the left and right view. " - "Use this if the 3D effect seems wrong.

")); - connect(_swap_checkbox, SIGNAL(stateChanged(int)), this, SLOT(swap_changed())); - layout2->addWidget(_swap_checkbox, 0, 2); - - QGridLayout *layout = new QGridLayout; - layout->addLayout(layout0, 0, 0); - layout->addLayout(layout1, 1, 0); - layout->addLayout(layout2, 2, 0); - setLayout(layout); - - // Align the labels - int minw = input_label->minimumSizeHint().width(); - if (output_label->minimumSizeHint().width() > minw) - { - minw = output_label->minimumSizeHint().width(); - } - if (video_label->minimumSizeHint().width() > minw) - { - minw = video_label->minimumSizeHint().width(); - } - if (audio_label->minimumSizeHint().width() > minw) - { - minw = audio_label->minimumSizeHint().width(); - } - if (subtitle_label->minimumSizeHint().width() > minw) - { - minw = subtitle_label->minimumSizeHint().width(); - } - input_label->setMinimumSize(QSize(minw, input_label->minimumSizeHint().height())); - output_label->setMinimumSize(QSize(minw, output_label->minimumSizeHint().height())); - video_label->setMinimumSize(QSize(minw, video_label->minimumSizeHint().height())); - audio_label->setMinimumSize(QSize(minw, audio_label->minimumSizeHint().height())); - subtitle_label->setMinimumSize(QSize(minw, subtitle_label->minimumSizeHint().height())); - - _video_combobox->setEnabled(false); - _audio_combobox->setEnabled(false); - _subtitle_combobox->setEnabled(false); - _input_combobox->setEnabled(false); - _output_combobox->setEnabled(false); - _swap_checkbox->setEnabled(false); +in_out_widget::in_out_widget(QSettings* settings, const player_qt_internal* player, Ui::MainWindow* ui) : + _settings(settings), _player(player), _lock(false), _ui(ui) +{ + connect(_ui->video, SIGNAL(currentIndexChanged(int)), this, SLOT(video_changed())); + connect(_ui->audio, SIGNAL(currentIndexChanged(int)), this, SLOT(audio_changed())); + connect(_ui->subtitles, SIGNAL(currentIndexChanged(int)), this, SLOT(subtitle_changed())); + connect(_ui->input, SIGNAL(currentIndexChanged(int)), this, SLOT(input_changed())); + connect(_ui->output, SIGNAL(currentIndexChanged(int)), this, SLOT(output_changed())); + connect(_ui->swap, SIGNAL(stateChanged(int)), this, SLOT(swap_changed())); + + _ui->video->setEnabled(false); + _ui->audio->setEnabled(false); + _ui->subtitles->setEnabled(false); + _ui->input->setEnabled(false); + _ui->output->setEnabled(false); + _ui->swap->setEnabled(false); } in_out_widget::~in_out_widget() @@ -276,28 +164,28 @@ void in_out_widget::set_stereo_layout(video_frame::stereo_layout_t stereo_layout switch (stereo_layout) { case video_frame::mono: - _input_combobox->setCurrentIndex(0); + _ui->input->setCurrentIndex(0); break; case video_frame::separate: - _input_combobox->setCurrentIndex(stereo_layout_swap ? 2 : 1); + _ui->input->setCurrentIndex(stereo_layout_swap ? 2 : 1); break; case video_frame::top_bottom: - _input_combobox->setCurrentIndex(stereo_layout_swap ? 5 : 3); + _ui->input->setCurrentIndex(stereo_layout_swap ? 5 : 3); break; case video_frame::top_bottom_half: - _input_combobox->setCurrentIndex(stereo_layout_swap ? 6 : 4); + _ui->input->setCurrentIndex(stereo_layout_swap ? 6 : 4); break; case video_frame::left_right: - _input_combobox->setCurrentIndex(stereo_layout_swap ? 9: 7); + _ui->input->setCurrentIndex(stereo_layout_swap ? 9: 7); break; case video_frame::left_right_half: - _input_combobox->setCurrentIndex(stereo_layout_swap ? 10 : 8); + _ui->input->setCurrentIndex(stereo_layout_swap ? 10 : 8); break; case video_frame::even_odd_rows: - _input_combobox->setCurrentIndex(stereo_layout_swap ? 12 : 11); + _ui->input->setCurrentIndex(stereo_layout_swap ? 12 : 11); break; } - _video_combobox->setEnabled(stereo_layout != video_frame::separate); + _ui->video->setEnabled(stereo_layout != video_frame::separate); } void in_out_widget::set_stereo_mode(parameters::stereo_mode_t stereo_mode, bool stereo_mode_swap) @@ -306,82 +194,82 @@ void in_out_widget::set_stereo_mode(parameters::stereo_mode_t stereo_mode, bool { default: case parameters::mono_left: - _output_combobox->setCurrentIndex(0); + _ui->output->setCurrentIndex(0); break; case parameters::mono_right: - _output_combobox->setCurrentIndex(1); + _ui->output->setCurrentIndex(1); break; case parameters::stereo: - _output_combobox->setCurrentIndex(2); + _ui->output->setCurrentIndex(2); break; case parameters::top_bottom: - _output_combobox->setCurrentIndex(3); + _ui->output->setCurrentIndex(3); break; case parameters::top_bottom_half: - _output_combobox->setCurrentIndex(4); + _ui->output->setCurrentIndex(4); break; case parameters::left_right: - _output_combobox->setCurrentIndex(5); + _ui->output->setCurrentIndex(5); break; case parameters::left_right_half: - _output_combobox->setCurrentIndex(6); + _ui->output->setCurrentIndex(6); break; case parameters::even_odd_rows: - _output_combobox->setCurrentIndex(7); + _ui->output->setCurrentIndex(7); break; case parameters::even_odd_columns: - _output_combobox->setCurrentIndex(8); + _ui->output->setCurrentIndex(8); break; case parameters::checkerboard: - _output_combobox->setCurrentIndex(9); + _ui->output->setCurrentIndex(9); break; case parameters::hdmi_frame_pack: - _output_combobox->setCurrentIndex(10); + _ui->output->setCurrentIndex(10); break; case parameters::red_cyan_monochrome: - _output_combobox->setCurrentIndex(11); + _ui->output->setCurrentIndex(11); break; case parameters::red_cyan_half_color: - _output_combobox->setCurrentIndex(12); + _ui->output->setCurrentIndex(12); break; case parameters::red_cyan_full_color: - _output_combobox->setCurrentIndex(13); + _ui->output->setCurrentIndex(13); break; case parameters::red_cyan_dubois: - _output_combobox->setCurrentIndex(14); + _ui->output->setCurrentIndex(14); break; case parameters::green_magenta_monochrome: - _output_combobox->setCurrentIndex(15); + _ui->output->setCurrentIndex(15); break; case parameters::green_magenta_half_color: - _output_combobox->setCurrentIndex(16); + _ui->output->setCurrentIndex(16); break; case parameters::green_magenta_full_color: - _output_combobox->setCurrentIndex(17); + _ui->output->setCurrentIndex(17); break; case parameters::green_magenta_dubois: - _output_combobox->setCurrentIndex(18); + _ui->output->setCurrentIndex(18); break; case parameters::amber_blue_monochrome: - _output_combobox->setCurrentIndex(19); + _ui->output->setCurrentIndex(19); break; case parameters::amber_blue_half_color: - _output_combobox->setCurrentIndex(20); + _ui->output->setCurrentIndex(20); break; case parameters::amber_blue_full_color: - _output_combobox->setCurrentIndex(21); + _ui->output->setCurrentIndex(21); break; case parameters::amber_blue_dubois: - _output_combobox->setCurrentIndex(22); + _ui->output->setCurrentIndex(22); break; case parameters::red_green_monochrome: - _output_combobox->setCurrentIndex(23); + _ui->output->setCurrentIndex(23); break; case parameters::red_blue_monochrome: - _output_combobox->setCurrentIndex(24); + _ui->output->setCurrentIndex(24); break; } - _swap_checkbox->setChecked(stereo_mode_swap); + _ui->swap->setChecked(stereo_mode_swap); } void in_out_widget::video_changed() @@ -391,7 +279,7 @@ void in_out_widget::video_changed() video_frame::stereo_layout_t stereo_layout; bool stereo_layout_swap; get_stereo_layout(stereo_layout, stereo_layout_swap); - send_cmd(command::set_video_stream, _video_combobox->currentIndex()); + send_cmd(command::set_video_stream, _ui->video->currentIndex()); } } @@ -399,7 +287,7 @@ void in_out_widget::audio_changed() { if (!_lock) { - send_cmd(command::set_audio_stream, _audio_combobox->currentIndex()); + send_cmd(command::set_audio_stream, _ui->audio->currentIndex()); } } @@ -407,7 +295,7 @@ void in_out_widget::subtitle_changed() { if (!_lock) { - send_cmd(command::set_subtitle_stream, _subtitle_combobox->currentIndex() - 1); + send_cmd(command::set_subtitle_stream, _ui->subtitles->currentIndex() - 1); } } @@ -419,13 +307,13 @@ void in_out_widget::input_changed() if (stereo_layout == video_frame::separate) { _lock = true; - _video_combobox->setCurrentIndex(0); - _video_combobox->setEnabled(false); + _ui->video->setCurrentIndex(0); + _ui->video->setEnabled(false); _lock = false; } else { - _video_combobox->setEnabled(true); + _ui->video->setEnabled(true); } std::ostringstream oss; s11n::save(oss, static_cast(stereo_layout)); @@ -472,48 +360,48 @@ void in_out_widget::swap_changed() void in_out_widget::update(const player_init_data &init_data, bool have_valid_input, bool playing) { _lock = true; - _video_combobox->setEnabled(have_valid_input); - _audio_combobox->setEnabled(have_valid_input); - _subtitle_combobox->setEnabled(have_valid_input); - _input_combobox->setEnabled(have_valid_input); - _output_combobox->setEnabled(have_valid_input); - _swap_checkbox->setEnabled(have_valid_input); - _video_combobox->clear(); - _audio_combobox->clear(); - _subtitle_combobox->clear(); + _ui->video->setEnabled(have_valid_input); + _ui->audio->setEnabled(have_valid_input); + _ui->subtitles->setEnabled(have_valid_input); + _ui->input->setEnabled(have_valid_input); + _ui->output->setEnabled(have_valid_input); + _ui->swap->setEnabled(have_valid_input); + _ui->video->clear(); + _ui->audio->clear(); + _ui->subtitles->clear(); if (have_valid_input) { for (int i = 0; i < _player->get_media_input().video_streams(); i++) { - _video_combobox->addItem(_player->get_media_input().video_stream_name(i).c_str()); + _ui->video->addItem(_player->get_media_input().video_stream_name(i).c_str()); } for (int i = 0; i < _player->get_media_input().audio_streams(); i++) { - _audio_combobox->addItem(_player->get_media_input().audio_stream_name(i).c_str()); + _ui->audio->addItem(_player->get_media_input().audio_stream_name(i).c_str()); } - _subtitle_combobox->addItem(_("Off")); + _ui->subtitles->addItem(_("Off")); for (int i = 0; i < _player->get_media_input().subtitle_streams(); i++) { - _subtitle_combobox->addItem(_player->get_media_input().subtitle_stream_name(i).c_str()); + _ui->subtitles->addItem(_player->get_media_input().subtitle_stream_name(i).c_str()); } - _video_combobox->setCurrentIndex(init_data.video_stream); - _audio_combobox->setCurrentIndex(init_data.audio_stream); - _subtitle_combobox->setCurrentIndex(init_data.subtitle_stream + 1); + _ui->video->setCurrentIndex(init_data.video_stream); + _ui->audio->setCurrentIndex(init_data.audio_stream); + _ui->subtitles->setCurrentIndex(init_data.subtitle_stream + 1); // Disable unsupported input modes - for (int i = 0; i < _input_combobox->count(); i++) + for (int i = 0; i < _ui->input->count(); i++) { - _input_combobox->setCurrentIndex(i); + _ui->input->setCurrentIndex(i); video_frame::stereo_layout_t layout; bool swap; get_stereo_layout(layout, swap); - qobject_cast(_input_combobox->model())->item(i)->setEnabled( + qobject_cast(_ui->input->model())->item(i)->setEnabled( _player->get_media_input().stereo_layout_is_supported(layout, swap)); } // Disable unsupported output modes if (!_player->get_video_output()->supports_stereo()) { set_stereo_mode(parameters::stereo, false); - qobject_cast(_output_combobox->model())->item(_output_combobox->currentIndex())->setEnabled(false); + qobject_cast(_ui->output->model())->item(_ui->output->currentIndex())->setEnabled(false); } set_stereo_layout(init_data.stereo_layout, init_data.stereo_layout_swap); set_stereo_mode(init_data.stereo_mode, init_data.stereo_mode_swap); @@ -527,22 +415,22 @@ void in_out_widget::update(const player_init_data &init_data, bool have_valid_in int in_out_widget::get_video_stream() { - return _video_combobox->currentIndex(); + return _ui->video->currentIndex(); } int in_out_widget::get_audio_stream() { - return _audio_combobox->currentIndex(); + return _ui->audio->currentIndex(); } int in_out_widget::get_subtitle_stream() { - return _subtitle_combobox->currentIndex() - 1; + return _ui->subtitles->currentIndex() - 1; } void in_out_widget::get_stereo_layout(video_frame::stereo_layout_t &stereo_layout, bool &stereo_layout_swap) { - switch (_input_combobox->currentIndex()) + switch (_ui->input->currentIndex()) { case 0: stereo_layout = video_frame::mono; @@ -601,7 +489,7 @@ void in_out_widget::get_stereo_layout(video_frame::stereo_layout_t &stereo_layou void in_out_widget::get_stereo_mode(parameters::stereo_mode_t &stereo_mode, bool &stereo_mode_swap) { - switch (_output_combobox->currentIndex()) + switch (_ui->output->currentIndex()) { case 0: stereo_mode = parameters::mono_left; @@ -679,7 +567,7 @@ void in_out_widget::get_stereo_mode(parameters::stereo_mode_t &stereo_mode, bool stereo_mode = parameters::red_blue_monochrome; break; } - stereo_mode_swap = _swap_checkbox->isChecked(); + stereo_mode_swap = _ui->swap->isChecked(); } void in_out_widget::receive_notification(const notification ¬e) @@ -693,25 +581,25 @@ void in_out_widget::receive_notification(const notification ¬e) case notification::video_stream: s11n::load(current, stream); _lock = true; - _video_combobox->setCurrentIndex(stream); + _ui->video->setCurrentIndex(stream); _lock = false; break; case notification::audio_stream: s11n::load(current, stream); _lock = true; - _audio_combobox->setCurrentIndex(stream); + _ui->audio->setCurrentIndex(stream); _lock = false; break; case notification::subtitle_stream: s11n::load(current, stream); _lock = true; - _subtitle_combobox->setCurrentIndex(stream + 1); + _ui->subtitles->setCurrentIndex(stream + 1); _lock = false; break; case notification::stereo_mode_swap: s11n::load(current, flag); _lock = true; - _swap_checkbox->setChecked(flag); + _ui->swap->setChecked(flag); _lock = false; break; default: @@ -720,85 +608,34 @@ void in_out_widget::receive_notification(const notification ¬e) } -controls_widget::controls_widget(QSettings *settings, QWidget *parent) - : QWidget(parent), _lock(false), _settings(settings), _playing(false) +controls_widget::controls_widget(QSettings* settings, Ui::MainWindow* ui) + : _lock(false), _settings(settings), _playing(false), _ui(ui) { - QGridLayout *layout = new QGridLayout; - _seek_slider = new QSlider(Qt::Horizontal); - _seek_slider->setToolTip(_("

This slider shows the progress during video playback, " - "and can be used to seek in the video.

")); - _seek_slider->setRange(0, 2000); - _seek_slider->setTracking(false); - connect(_seek_slider, SIGNAL(valueChanged(int)), this, SLOT(seek_slider_changed())); - layout->addWidget(_seek_slider, 0, 0, 1, 13); - _play_button = new QPushButton(get_icon("media-playback-start"), ""); - _play_button->setToolTip(_("

Play.

")); - connect(_play_button, SIGNAL(pressed()), this, SLOT(play_pressed())); - layout->addWidget(_play_button, 1, 0); - _pause_button = new QPushButton(get_icon("media-playback-pause"), ""); - _pause_button->setToolTip(_("

Pause.

")); - connect(_pause_button, SIGNAL(pressed()), this, SLOT(pause_pressed())); - layout->addWidget(_pause_button, 1, 1); - _stop_button = new QPushButton(get_icon("media-playback-stop"), ""); - _stop_button->setToolTip(_("

Stop.

")); - connect(_stop_button, SIGNAL(pressed()), this, SLOT(stop_pressed())); - layout->addWidget(_stop_button, 1, 2); - layout->addWidget(new QWidget, 1, 3); - _fullscreen_button = new QPushButton(get_icon("view-fullscreen"), ""); - _fullscreen_button->setToolTip(_("

Switch to fullscreen mode. " - "You can leave fullscreen mode by pressing the f key.

")); - connect(_fullscreen_button, SIGNAL(pressed()), this, SLOT(fullscreen_pressed())); - layout->addWidget(_fullscreen_button, 1, 4); - _center_button = new QPushButton(get_icon("view-restore"), ""); - _center_button->setToolTip(_("

Center the video area on your screen.

")); - connect(_center_button, SIGNAL(pressed()), this, SLOT(center_pressed())); - layout->addWidget(_center_button, 1, 5); - layout->addWidget(new QWidget, 1, 6); - _bbb_button = new QPushButton(get_icon("media-seek-backward"), ""); - _bbb_button->setMinimumWidth(_bbb_button->minimumSizeHint().width() * 6 / 4); - _bbb_button->setToolTip(_("

Seek backward 10 minutes.

")); - connect(_bbb_button, SIGNAL(pressed()), this, SLOT(bbb_pressed())); - layout->addWidget(_bbb_button, 1, 7); - _bb_button = new QPushButton(get_icon("media-seek-backward"), ""); - _bb_button->setMinimumWidth(_bb_button->minimumSizeHint().width() * 5 / 4); - _bb_button->setToolTip(_("

Seek backward 1 minute.

")); - connect(_bb_button, SIGNAL(pressed()), this, SLOT(bb_pressed())); - layout->addWidget(_bb_button, 1, 8); - _b_button = new QPushButton(get_icon("media-seek-backward"), ""); - _b_button->setToolTip(_("

Seek backward 10 seconds.

")); - connect(_b_button, SIGNAL(pressed()), this, SLOT(b_pressed())); - layout->addWidget(_b_button, 1, 9); - _f_button = new QPushButton(get_icon("media-seek-forward"), ""); - _f_button->setToolTip(_("

Seek forward 10 seconds.

")); - connect(_f_button, SIGNAL(pressed()), this, SLOT(f_pressed())); - layout->addWidget(_f_button, 1, 10); - _ff_button = new QPushButton(get_icon("media-seek-forward"), ""); - _ff_button->setMinimumWidth(_ff_button->minimumSizeHint().width() * 5 / 4); - _ff_button->setToolTip(_("

Seek forward 1 minute.

")); - connect(_ff_button, SIGNAL(pressed()), this, SLOT(ff_pressed())); - layout->addWidget(_ff_button, 1, 11); - _fff_button = new QPushButton(get_icon("media-seek-forward"), ""); - _fff_button->setMinimumWidth(_fff_button->minimumSizeHint().width() * 6 / 4); - _fff_button->setToolTip(_("

Seek forward 10 minutes.

")); - connect(_fff_button, SIGNAL(pressed()), this, SLOT(fff_pressed())); - layout->addWidget(_fff_button, 1, 12); - layout->setRowStretch(0, 0); - layout->setColumnStretch(3, 1); - layout->setColumnStretch(6, 1); - setLayout(layout); + connect(_ui->seek, SIGNAL(valueChanged(int)), this, SLOT(seek_slider_changed())); + connect(_ui->play, SIGNAL(pressed()), this, SLOT(play_pressed())); + connect(_ui->pause, SIGNAL(pressed()), this, SLOT(pause_pressed())); + connect(_ui->stop, SIGNAL(pressed()), this, SLOT(stop_pressed())); + connect(_ui->fullscreen, SIGNAL(pressed()), this, SLOT(fullscreen_pressed())); + connect(_ui->center, SIGNAL(pressed()), this, SLOT(center_pressed())); + connect(_ui->bbb, SIGNAL(pressed()), this, SLOT(bbb_pressed())); + connect(_ui->bb, SIGNAL(pressed()), this, SLOT(bb_pressed())); + connect(_ui->b, SIGNAL(pressed()), this, SLOT(b_pressed())); + connect(_ui->f, SIGNAL(pressed()), this, SLOT(f_pressed())); + connect(_ui->ff, SIGNAL(pressed()), this, SLOT(ff_pressed())); + connect(_ui->fff, SIGNAL(pressed()), this, SLOT(fff_pressed())); - _play_button->setEnabled(false); - _pause_button->setEnabled(false); - _stop_button->setEnabled(false); - _fullscreen_button->setEnabled(false); - _center_button->setEnabled(false); - _bbb_button->setEnabled(false); - _bb_button->setEnabled(false); - _b_button->setEnabled(false); - _f_button->setEnabled(false); - _ff_button->setEnabled(false); - _fff_button->setEnabled(false); - _seek_slider->setEnabled(false); + _ui->play->setEnabled(false); + _ui->pause->setEnabled(false); + _ui->stop->setEnabled(false); + _ui->fullscreen->setEnabled(false); + _ui->center->setEnabled(false); + _ui->bbb->setEnabled(false); + _ui->bb->setEnabled(false); + _ui->b->setEnabled(false); + _ui->f->setEnabled(false); + _ui->ff->setEnabled(false); + _ui->fff->setEnabled(false); + _ui->seek->setEnabled(false); } controls_widget::~controls_widget() @@ -871,7 +708,7 @@ void controls_widget::seek_slider_changed() { if (!_lock) { - send_cmd(command::set_pos, static_cast(_seek_slider->value()) / 2000.0f); + send_cmd(command::set_pos, static_cast(_ui->seek->value()) / 2000.0f); } } @@ -884,19 +721,19 @@ void controls_widget::update(const player_init_data &, bool have_valid_input, bo else { _playing = false; - _play_button->setEnabled(false); - _pause_button->setEnabled(false); - _stop_button->setEnabled(false); - _fullscreen_button->setEnabled(false); - _center_button->setEnabled(false); - _bbb_button->setEnabled(false); - _bb_button->setEnabled(false); - _b_button->setEnabled(false); - _f_button->setEnabled(false); - _ff_button->setEnabled(false); - _fff_button->setEnabled(false); - _seek_slider->setEnabled(false); - _seek_slider->setValue(0); + _ui->play->setEnabled(false); + _ui->pause->setEnabled(false); + _ui->stop->setEnabled(false); + _ui->fullscreen->setEnabled(false); + _ui->center->setEnabled(false); + _ui->bbb->setEnabled(false); + _ui->bb->setEnabled(false); + _ui->b->setEnabled(false); + _ui->f->setEnabled(false); + _ui->ff->setEnabled(false); + _ui->fff->setEnabled(false); + _ui->seek->setEnabled(false); + _ui->seek->setValue(0); } } @@ -911,34 +748,34 @@ void controls_widget::receive_notification(const notification ¬e) case notification::play: s11n::load(current, flag); _playing = flag; - _play_button->setEnabled(!flag); - _pause_button->setEnabled(flag); - _stop_button->setEnabled(flag); - _fullscreen_button->setEnabled(flag); - _center_button->setEnabled(flag); - _bbb_button->setEnabled(flag); - _bb_button->setEnabled(flag); - _b_button->setEnabled(flag); - _f_button->setEnabled(flag); - _ff_button->setEnabled(flag); - _fff_button->setEnabled(flag); - _seek_slider->setEnabled(flag); + _ui->play->setEnabled(!flag); + _ui->pause->setEnabled(flag); + _ui->stop->setEnabled(flag); + _ui->fullscreen->setEnabled(flag); + _ui->center->setEnabled(flag); + _ui->bbb->setEnabled(flag); + _ui->bb->setEnabled(flag); + _ui->b->setEnabled(flag); + _ui->f->setEnabled(flag); + _ui->ff->setEnabled(flag); + _ui->fff->setEnabled(flag); + _ui->seek->setEnabled(flag); if (!flag) { - _seek_slider->setValue(0); + _ui->seek->setValue(0); } break; case notification::pause: s11n::load(current, flag); - _play_button->setEnabled(flag); - _pause_button->setEnabled(!flag); + _ui->play->setEnabled(flag); + _ui->pause->setEnabled(!flag); break; case notification::pos: - if (!_seek_slider->isSliderDown()) + if (!_ui->seek->isSliderDown()) { _lock = true; s11n::load(current, value); - _seek_slider->setValue(qRound(value * 2000.0f)); + _ui->seek->setValue(qRound(value * 2000.0f)); _lock = false; } default: @@ -1686,9 +1523,14 @@ main_window::main_window(QSettings *settings, const player_init_data &init_data) _init_data_template(init_data), _stop_request(false) { + // Init UI + _ui.setupUi(this); + _player = new player_qt_internal(_init_data.benchmark, _ui.video_widget); + _in_out_widget = new in_out_widget(_settings, _player, &_ui); + _controls_widget = new controls_widget(_settings, &_ui); + // Application properties setWindowTitle(PACKAGE_NAME); - setWindowIcon(QIcon(":logo/bino_logo_small_64x64.png")); // Load preferences _settings->beginGroup("Session"); @@ -1744,78 +1586,12 @@ main_window::main_window(QSettings *settings, const player_init_data &init_data) _settings->endGroup(); _init_data.params.set_defaults(); - // Central widget, player, and timer - QWidget *central_widget = new QWidget(this); - QGridLayout *layout = new QGridLayout(); - _video_container_widget = new video_container_widget(central_widget); - connect(_video_container_widget, SIGNAL(move_event()), this, SLOT(move_event())); - layout->addWidget(_video_container_widget, 0, 0); - _player = new player_qt_internal(_init_data.benchmark, _video_container_widget); + // Player + connect(_ui.video_widget, SIGNAL(move_event()), this, SLOT(move_event())); + + // Timer _timer = new QTimer(this); connect(_timer, SIGNAL(timeout()), this, SLOT(playloop_step())); - _in_out_widget = new in_out_widget(_settings, _player, central_widget); - layout->addWidget(_in_out_widget, 1, 0); - _controls_widget = new controls_widget(_settings, central_widget); - layout->addWidget(_controls_widget, 2, 0); - layout->setRowStretch(0, 1); - layout->setColumnStretch(0, 1); - central_widget->setLayout(layout); - setCentralWidget(central_widget); - - // Menus - QMenu *file_menu = menuBar()->addMenu(_("&File")); - QAction *file_open_act = new QAction(_("&Open..."), this); - file_open_act->setShortcut(QKeySequence::Open); - file_open_act->setIcon(get_icon("document-open")); - connect(file_open_act, SIGNAL(triggered()), this, SLOT(file_open())); - file_menu->addAction(file_open_act); - QAction *file_open_url_act = new QAction(_("Open &URL..."), this); - file_open_url_act->setIcon(get_icon("document-open")); - connect(file_open_url_act, SIGNAL(triggered()), this, SLOT(file_open_url())); - file_menu->addAction(file_open_url_act); - file_menu->addSeparator(); - QAction *file_quit_act = new QAction(_("&Quit..."), this); - file_quit_act->setShortcut(QKeySequence::Quit); - file_quit_act->setMenuRole(QAction::QuitRole); - file_quit_act->setIcon(get_icon("application-exit")); - connect(file_quit_act, SIGNAL(triggered()), this, SLOT(close())); - file_menu->addAction(file_quit_act); - QMenu *preferences_menu = menuBar()->addMenu(_("&Preferences")); - // note: whenever the preferences menu becomes a preferences panel, don't forget - // to preferences_act->setMenuRole(QAction::PreferencesRole) on the menu item - QAction *preferences_colors_act = new QAction(_("Display &Color Adjustments..."), this); - connect(preferences_colors_act, SIGNAL(triggered()), this, SLOT(preferences_colors())); - preferences_menu->addAction(preferences_colors_act); - QAction *preferences_crosstalk_act = new QAction(_("Display Cross&talk Calibration..."), this); - connect(preferences_crosstalk_act, SIGNAL(triggered()), this, SLOT(preferences_crosstalk())); - preferences_menu->addAction(preferences_crosstalk_act); - preferences_menu->addSeparator(); - QAction *preferences_subtitle_act = new QAction(_("&Subtitle Settings..."), this); - connect(preferences_subtitle_act, SIGNAL(triggered()), this, SLOT(preferences_subtitle())); - preferences_menu->addAction(preferences_subtitle_act); - preferences_menu->addSeparator(); - QAction *preferences_stereoscopic_act = new QAction(_("Stereoscopic Video Settings..."), this); - connect(preferences_stereoscopic_act, SIGNAL(triggered()), this, SLOT(preferences_stereoscopic())); - preferences_menu->addAction(preferences_stereoscopic_act); - QMenu *help_menu = menuBar()->addMenu(_("&Help")); - QAction *help_manual_act = new QAction(_("&Manual..."), this); - help_manual_act->setShortcut(QKeySequence::HelpContents); - help_manual_act->setIcon(get_icon("help-contents")); - connect(help_manual_act, SIGNAL(triggered()), this, SLOT(help_manual())); - help_menu->addAction(help_manual_act); - QAction *help_website_act = new QAction(_("&Website..."), this); - help_website_act->setIcon(get_icon("applications-internet")); - connect(help_website_act, SIGNAL(triggered()), this, SLOT(help_website())); - help_menu->addAction(help_website_act); - QAction *help_keyboard_act = new QAction(_("&Keyboard Shortcuts"), this); - help_keyboard_act->setIcon(get_icon("preferences-desktop-keyboard")); - connect(help_keyboard_act, SIGNAL(triggered()), this, SLOT(help_keyboard())); - help_menu->addAction(help_keyboard_act); - QAction *help_about_act = new QAction(_("&About"), this); - help_about_act->setMenuRole(QAction::AboutRole); - help_about_act->setIcon(get_icon("help-about")); - connect(help_about_act, SIGNAL(triggered()), this, SLOT(help_about())); - help_menu->addAction(help_about_act); // Handle FileOpen events QApplication::instance()->installEventFilter(this); @@ -1917,7 +1693,7 @@ void main_window::receive_notification(const notification ¬e) _in_out_widget->update(_init_data, true, true); _controls_widget->update(_init_data, true, true); // Give the keyboard focus to the video widget - _video_container_widget->setFocus(Qt::OtherFocusReason); + _ui.video_widget->setFocus(Qt::OtherFocusReason); // Start the play loop _timer->start(0); } diff --git a/src/player_qt.h b/src/player_qt.h index f0e0cc6..acb0d01 100644 --- a/src/player_qt.h +++ b/src/player_qt.h @@ -40,6 +40,8 @@ #include "video_output_qt.h" #include "player.h" +//UI file +#include "player_qt-ui.h" class player_qt_internal : public player, public controller { @@ -73,12 +75,7 @@ class in_out_widget : public QWidget, public controller private: QSettings *_settings; const player_qt_internal *_player; - QComboBox *_video_combobox; - QComboBox *_audio_combobox; - QComboBox *_subtitle_combobox; - QComboBox *_input_combobox; - QComboBox *_output_combobox; - QCheckBox *_swap_checkbox; + Ui::MainWindow *_ui; bool _lock; void set_stereo_layout(video_frame::stereo_layout_t stereo_layout, bool stereo_layout_swap); @@ -93,7 +90,7 @@ private slots: void swap_changed(); public: - in_out_widget(QSettings *settings, const player_qt_internal *player, QWidget *parent); + in_out_widget(QSettings *settings, const player_qt_internal *player, Ui::MainWindow *ui); virtual ~in_out_widget(); void update(const player_init_data &init_data, bool have_valid_input, bool playing); @@ -114,18 +111,7 @@ class controls_widget : public QWidget, public controller private: bool _lock; QSettings *_settings; - QPushButton *_play_button; - QPushButton *_pause_button; - QPushButton *_stop_button; - QPushButton *_fullscreen_button; - QPushButton *_center_button; - QPushButton *_bbb_button; - QPushButton *_bb_button; - QPushButton *_b_button; - QPushButton *_f_button; - QPushButton *_ff_button; - QPushButton *_fff_button; - QSlider *_seek_slider; + Ui::MainWindow *_ui; bool _playing; private slots: @@ -143,7 +129,7 @@ private slots: void seek_slider_changed(); public: - controls_widget(QSettings *settings, QWidget *parent); + controls_widget(QSettings *settings, Ui::MainWindow *ui); virtual ~controls_widget(); void update(const player_init_data &init_data, bool have_valid_input, bool playing); @@ -270,8 +256,8 @@ class main_window : public QMainWindow, public controller Q_OBJECT private: + Ui::MainWindow _ui; QSettings *_settings; - video_container_widget *_video_container_widget; in_out_widget *_in_out_widget; controls_widget *_controls_widget; color_dialog *_color_dialog; diff --git a/src/player_qt.ui b/src/player_qt.ui new file mode 100644 index 0000000..6299436 --- /dev/null +++ b/src/player_qt.ui @@ -0,0 +1,1052 @@ + + + MainWindow + + + + 0 + 0 + 641 + 245 + + + + Bino + + + + :/logo/bino_logo_small_64x64.png:/logo/bino_logo_small_64x64.png + + + + + + + + 0 + 0 + + + + + 633 + 67 + + + + + + + + + + + 0 + 0 + + + + <p>Select the video stream.</p> + + + Video: + + + video + + + + + + + + + <p>Select the video stream.</p> + + + + + + + + 0 + 0 + + + + <p>Select the audio stream.</p> + + + Audio: + + + audio + + + + + + + <p>Select the audio stream.</p> + + + + + + + + 0 + 0 + + + + <p>Select the subtitle stream.</p> + + + Subtitles: + + + subtitles + + + + + + + <p>Select the subtitle stream.</p> + + + + + + + + + + 0 + 0 + + + + <p>Set the 3D layout of the video stream.</p> + + + Input: + + + input + + + + + + + <p>Set the 3D layout of the video stream.</p> + + + + 2D + + + + + Separate streams, left first + + + + + Separate streams, right first + + + + + Top/bottom + + + + + Top/bottom, half height + + + + + Bottom/top + + + + + Bottom/top, half height + + + + + Left/right + + + + + Left/right, half width + + + + + Right/left + + + + + Right/left, half width + + + + + Even/odd rows + + + + + Odd/even rows + + + + + + + + + 0 + 0 + + + + <p>Set the 3D output type for your display.</p> + + + Output: + + + output + + + + + + + + + <p>Set the 3D output type for your display.</p> + + + + Left view + + + + + Right view + + + + + OpenGL stereo + + + + + Top/bottom + + + + + Top/bottom, half height + + + + + Left/right + + + + + Left/right, half width + + + + + Even/odd rows + + + + + Even/odd columns + + + + + Checkerboard pattern + + + + + HDMI frame packing mode + + + + + Red/cyan glasses, monochrome method + + + + + Red/cyan glasses, half-color method + + + + + Red/cyan glasses, full-color method + + + + + Red/cyan glasses, high-quality Dubois method + + + + + Green/magenta glasses, monochrome method + + + + + Green/magenta glasses, half-color method + + + + + Green/magenta glasses, full-color method + + + + + Green/magenta glasses, high-quality Dubois method + + + + + Amber/blue glasses, monochrome method + + + + + Amber/blue glasses, half-color method + + + + + Amber/blue glasses, full-color method + + + + + Amber/blue glasses, high-quality Dubois method + + + + + Red/green glasses, monochrome method + + + + + Red/blue glasses, monochrome method + + + + + + + + + 0 + 0 + + + + <p>Swap the left and right view. Use this if the 3D effect seems wrong.</p> + + + Swap left/right + + + + + + + + + + + <p>This slider shows the progress during video playback, and can be used to seek in the video.</p> + + + Qt::Horizontal + + + + + + + + + + 0 + 0 + + + + + 47 + 26 + + + + <p>Play.</p> + + + + + + + :/icons/media-playback-start.png:/icons/media-playback-start.png + + + + + + + + 0 + 0 + + + + + 47 + 26 + + + + <p>Play.</p> + + + + + + + :/icons/media-playback-pause.png:/icons/media-playback-pause.png + + + + + + + + 0 + 0 + + + + + 47 + 26 + + + + <p>Stop.</p> + + + + + + + :/icons/media-playback-stop.png:/icons/media-playback-stop.png + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 47 + 26 + + + + <p>Switch to fullscreen mode. You can leave fullscreen mode by pressing the f key.</p> + + + + + + + :/icons/view-fullscreen.png:/icons/view-fullscreen.png + + + + + + + + 0 + 0 + + + + + 47 + 26 + + + + <p>Center the video area on your screen.</p> + + + + + + + :/icons/view-restore.png:/icons/view-restore.png + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 68 + 26 + + + + <p>Seek backward 10 minutes.</p> + + + + + + + :/icons/media-seek-backward.png:/icons/media-seek-backward.png + + + + + + + + 0 + 0 + + + + + 57 + 26 + + + + <p>Seek backward 1 minute.</p> + + + + + + + :/icons/media-seek-backward.png:/icons/media-seek-backward.png + + + + + + + + 0 + 0 + + + + + 47 + 26 + + + + <p>Seek backward 10 seconds.</p> + + + + + + + :/icons/media-seek-backward.png:/icons/media-seek-backward.png + + + + + + + + 0 + 0 + + + + + 47 + 26 + + + + <p>Seek forward 10 seconds.</p> + + + + + + + :/icons/media-seek-forward.png:/icons/media-seek-forward.png + + + + + + + + 0 + 0 + + + + + 57 + 26 + + + + <p>Seek forward 1 minute.</p> + + + + + + + :/icons/media-seek-forward.png:/icons/media-seek-forward.png + + + + + + + + 0 + 0 + + + + + 68 + 26 + + + + <p>Seek forward 10 minutes.</p> + + + + + + + :/icons/media-seek-forward.png:/icons/media-seek-forward.png + + + + + + + + + + + 0 + 0 + 641 + 21 + + + + + &File + + + + + + + + + &Preferences + + + + + + + + + + + &Help + + + + + + + + + + + + + + :/icons/document-open.png:/icons/document-open.png + + + &Open... + + + Ctrl+O + + + + + + :/icons/document-open.png:/icons/document-open.png + + + Open &URL... + + + + + + :/icons/application-exit.png:/icons/application-exit.png + + + &Quit... + + + Ctrl+Q + + + + + + :/icons/help-contents.png:/icons/help-contents.png + + + &Manual... + + + F1 + + + + + + :/icons/applications-internet.png:/icons/applications-internet.png + + + &Website... + + + + + + :/icons/preferences-desktop-keyboard.png:/icons/preferences-desktop-keyboard.png + + + &Keyboard shortcuts + + + + + + :/icons/help-about.png:/icons/help-about.png + + + &About + + + + + Display &Color Adjustments... + + + + + Display Cross&talk Calibration... + + + + + &Subtitle Settings... + + + + + Stereoscopic Video Settings... + + + + + + video_container_widget + QWidget +
video_output_qt.h
+ 1 +
+
+ + + + + + actionOpen + triggered() + MainWindow + file_open() + + + -1 + -1 + + + 320 + 132 + + + + + actionOpen_URL + triggered() + MainWindow + file_open_url() + + + -1 + -1 + + + 320 + 132 + + + + + actionQuit + triggered() + MainWindow + close() + + + -1 + -1 + + + 320 + 132 + + + + + actionColorAdjustments + triggered() + MainWindow + preferences_colors() + + + -1 + -1 + + + 320 + 132 + + + + + actionCrosstalkCalibration + triggered() + MainWindow + preferences_crosstalk() + + + -1 + -1 + + + 320 + 132 + + + + + actionStereoscopicVideoSettings + triggered() + MainWindow + preferences_stereoscopic() + + + -1 + -1 + + + 320 + 132 + + + + + actionSubtitleSettings + triggered() + MainWindow + preferences_subtitle() + + + -1 + -1 + + + 320 + 132 + + + + + actionAbout + triggered() + MainWindow + help_about() + + + -1 + -1 + + + 320 + 132 + + + + + actionManual + triggered() + MainWindow + help_manual() + + + -1 + -1 + + + 320 + 132 + + + + + actionKeyboard_shortcuts + triggered() + MainWindow + help_keyboard() + + + -1 + -1 + + + 320 + 132 + + + + + actionWebsite + triggered() + MainWindow + help_website() + + + -1 + -1 + + + 320 + 132 + + + + + + move_event() + playloop_step() + file_open() + preferences_colors() + file_open_url() + preferences_crosstalk() + preferences_subtitle() + preferences_stereoscopic() + help_manual() + help_website() + help_keyboard() + help_about() + +