Gui: added dvd check box

This commit is contained in:
zvon 2020-01-16 23:22:21 +01:00
parent 57fc45be61
commit 8da68a5327
2 changed files with 65 additions and 43 deletions

View File

@ -1,5 +1,6 @@
#include <fstream>
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/grid.h>
#include <gtkmm/liststore.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/scrolledwindow.h>
@ -195,12 +196,11 @@ void MainWindow::finishedSelection() {
for ( auto &x : selected ) {
// get renamed files for given season
// TODO dvd
auto renamed_files = getRenamedFiles(
static_cast< Glib::ustring >( ( *iter )[m_columns_show.m_col_show] ),
x, show_id, language_code,
( input_pattern.empty() ? default_pattern : input_pattern ),
!m_check_linux->get_active(), files[x], false );
!m_check_linux->get_active(), files[x], m_check_dvd->get_active() );
if ( renamed_files.empty() )
continue;
@ -291,11 +291,19 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
auto *box = new Gtk::Box(Gtk::ORIENTATION_VERTICAL);
auto *menu = new Gtk::MenuBar();
auto *layout = new Gtk::Layout();
auto *inputs = new Gtk::Grid();
auto *processing = new Gtk::Grid();
auto *buttons = new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL);
add( *box );
box->pack_start(*menu, false, false);
box->pack_start(*layout, true, true);
box->pack_start(*inputs, false, true);
box->pack_start(*processing, false, true);
box->pack_start(*m_check_dvd, false, true);
box->pack_start(*m_label_possible, false, true);
box->pack_start(*m_combo_possible, false, true);
box->pack_start(*buttons, false, true );
box->pack_start(*m_button_quit, false, true );
auto *item = new Gtk::MenuItem();
auto *submenu = new Gtk::Menu();
@ -356,25 +364,52 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
submenu->append(*item);
// set widgets' location
layout->put( *m_label_show, 5, 5 );
layout->put( *m_label_language, 190, 5 );
layout->put( *m_entry_show, 5, 25 );
layout->put( *m_combo_language, 190, 25 );
layout->put( *m_label_dir, 5, 60 );
layout->put( *m_entry_dir, 5, 80 );
layout->put( *m_button_dir, 190, 80 );
layout->put( *m_label_pattern, 5, 115 );
layout->put( *m_entry_pattern, 5, 135 );
layout->put( *m_button_pattern, 190, 135 );
layout->put( *m_check_linux, 95, 169 );
layout->put( *m_button_process, 5, 173 );
layout->put( *m_check_trust, 95, 187 );
layout->put( *m_label_possible, 5, 210 );
layout->put( *m_combo_possible, 5, 230 );
layout->put( *m_button_rename, 5, 270 );
layout->put( *m_button_db_add, 95, 270 );
layout->put( *m_button_quit, 315, 280 );
std::vector<Gtk::Widget*> left_aligned_widgets = {m_label_show,
m_label_language, m_entry_show, m_combo_language, m_label_dir,
m_entry_dir, m_label_pattern, m_entry_pattern, m_button_pattern,
m_button_process, m_check_linux, m_check_trust, m_check_dvd,
m_label_possible, m_combo_possible, m_button_rename,
m_button_db_add, m_button_dir
};
// set widgets' position in boxes
inputs->attach( *m_label_show, 0, 0, 1, 1 );
inputs->attach( *m_label_language, 1, 0, 1, 1);
inputs->attach( *m_entry_show, 0, 1, 1, 1 );
inputs->attach( *m_combo_language, 1, 1, 1, 1 );
inputs->attach( *m_label_dir, 0, 2, 2, 1 );
inputs->attach( *m_entry_dir, 0, 3, 1, 1 );
inputs->attach( *m_button_dir, 1, 3, 1, 1 );
inputs->attach( *m_label_pattern, 0, 4, 2, 1);
inputs->attach( *m_entry_pattern, 0, 5, 1, 1);
inputs->attach( *m_button_pattern, 1, 5, 1, 1);
inputs->set_column_homogeneous( true );
processing->attach( *m_button_process, 0, 0, 1, 2 );
processing->attach( *m_check_linux, 1, 0, 1, 1);
processing->attach( *m_check_trust, 1, 1, 1, 1);
buttons->pack_start( *m_button_rename, false, true );
buttons->pack_start( *m_button_db_add, false, true );
// set widgets alignment and margins
for( auto &x : left_aligned_widgets ) {
x->set_halign( Gtk::ALIGN_START );
x->set_valign( Gtk::ALIGN_CENTER );
x->set_margin_left( 5 );
x->set_margin_top( 5 );
}
m_entry_show->set_halign( Gtk::ALIGN_FILL );
m_entry_dir->set_halign( Gtk::ALIGN_FILL );
m_entry_pattern->set_halign( Gtk::ALIGN_FILL );
m_button_quit->set_halign( Gtk::ALIGN_END );
m_button_quit->set_valign( Gtk::ALIGN_CENTER );
m_button_quit->set_margin_right( 5 );
m_button_quit->set_margin_top( 5 );
m_button_quit->set_margin_bottom( 5 );
// set button texts
m_button_process->set_label( "Process" );
@ -385,6 +420,7 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
m_button_pattern->set_label( "Pattern help" );
m_check_linux->set_label( "Replace windows-illegal characters" );
m_check_trust->set_label( "Don't ask for rename confirmation" );
m_check_dvd->set_label( "Use DVD ordering" );
// set label texts
m_label_show->set_label( "Show:" );
@ -447,24 +483,12 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
// show everything except possible shows and items related to them
box->show();
menu->show();
menu->show_all_children();
layout->show();
m_label_show->show();
m_label_language->show();
m_entry_show->show();
m_entry_dir->show();
m_combo_language->show();
m_button_process->show();
m_button_quit->show();
m_button_dir->show();
m_check_linux->show();
box->show_all_children();
m_check_linux->set_active( true );
m_check_trust->show();
m_button_pattern->show();
m_entry_pattern->show();
m_label_pattern->show();
m_label_dir->show();
m_label_possible->hide();
m_combo_possible->hide();
m_button_rename->hide();
m_button_db_add->hide();
}
void MainWindow::dbUpdate() {
@ -502,9 +526,8 @@ void MainWindow::dbAdd() {
std::cout << show << " " << language_code << " " << show_id << std::endl;
// TODO dvd
addToDB( show, m_entry_dir->get_text(), language_code, show_id,
m_entry_pattern->get_text(), !m_check_linux->get_active(), false );
m_entry_pattern->get_text(), !m_check_linux->get_active(), m_check_dvd->get_active() );
}
void MainWindow::dbManage() {

View File

@ -46,7 +46,6 @@ protected:
Gtk::CheckButton *m_check_linux = new Gtk::CheckButton();
Gtk::CheckButton *m_check_trust = new Gtk::CheckButton();
// TODO add dvd checkbox
Gtk::CheckButton *m_check_dvd = new Gtk::CheckButton();
Gtk::ComboBox *m_combo_language = new Gtk::ComboBox();