tv_rename/gtk/seasonwindow.cpp

83 lines
2.0 KiB
C++
Raw Normal View History

2019-01-23 19:46:03 +00:00
#include "seasonwindow.hpp"
2019-06-01 19:54:45 +00:00
#include <string>
2019-01-23 19:46:03 +00:00
2020-04-01 14:07:37 +00:00
#include "../functions.hpp"
#include "../resources_linux.h"
2020-03-12 19:52:23 +00:00
2019-01-23 19:46:03 +00:00
void SeasonWindow::confirm() {
// go through all checkbuttons and save numbers
// of checked boxes into returned vector
// then quit
2019-02-04 16:39:48 +00:00
for ( auto &x : m_checks ) {
if ( x.get_active() ) {
returned.push_back( std::stoi( x.get_label() ) );
2019-01-23 19:46:03 +00:00
}
}
hide();
}
void SeasonWindow::select_all() {
// set all check boxes to checked
2019-02-04 16:39:48 +00:00
for ( auto &x : m_checks ) {
x.set_active( true );
2019-01-23 19:46:03 +00:00
}
}
void SeasonWindow::select_none() {
// set all check boxes to unchecked
2019-02-04 16:39:48 +00:00
for ( auto &x : m_checks ) {
x.set_active( false );
2019-01-23 19:46:03 +00:00
}
}
2019-02-04 16:39:48 +00:00
SeasonWindow::SeasonWindow( const std::vector< int > &seasons,
std::vector< int > &_returned )
: returned( _returned ) {
2020-03-12 19:52:23 +00:00
set_title( _( GUI_WINDOW_SEASON ) );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
set_default_size( 250, 250 );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
add( m_layout );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
size_t x{ 5 }, y{ 25 };
2019-01-23 19:46:03 +00:00
// create a check box for each season
2019-02-04 16:39:48 +00:00
for ( auto &s : seasons ) {
m_checks.emplace_back( std::to_string( s ) );
m_layout.put( m_checks.back(), x, y );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
if ( x == 185 ) {
2019-01-23 19:46:03 +00:00
x = 5;
y += 20;
} else {
x += 60;
}
}
2019-02-04 16:39:48 +00:00
m_layout.put( m_label, 5, 5 );
2020-03-12 19:52:23 +00:00
m_label.set_label( _( SELECT_SEASONS ) );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
m_layout.put( m_confirm, 165, 215 );
m_layout.put( m_all, 130, 175 );
m_layout.put( m_none, 5, 175 );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
m_confirm.set_size_request( 80, 30 );
m_all.set_size_request( 80, 30 );
m_none.set_size_request( 80, 30 );
2019-01-23 19:46:03 +00:00
2020-03-12 19:52:23 +00:00
m_confirm.set_label( _( SELECT ) );
m_all.set_label( _( SELECT_ALL ) );
m_none.set_label( _( SELECT_NONE ) );
2019-01-23 19:46:03 +00:00
2019-02-04 16:39:48 +00:00
m_confirm.signal_clicked().connect(
sigc::mem_fun( *this, &SeasonWindow::confirm ) );
m_all.signal_clicked().connect(
sigc::mem_fun( *this, &SeasonWindow::select_all ) );
m_none.signal_clicked().connect(
sigc::mem_fun( *this, &SeasonWindow::select_none ) );
2019-01-23 19:46:03 +00:00
2020-02-12 10:46:11 +00:00
property_modal().set_value( true );
2019-01-23 19:46:03 +00:00
show_all_children();
}