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

View File

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