Mainwindow: use progresswindow, add option to change database pattern
This commit is contained in:
parent
6c859efdf5
commit
4175c44c22
@ -6,11 +6,13 @@
|
|||||||
#include <gtkmm/scrolledwindow.h>
|
#include <gtkmm/scrolledwindow.h>
|
||||||
#include <gtkmm/textview.h>
|
#include <gtkmm/textview.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "filesystem.hpp"
|
#include "filesystem.hpp"
|
||||||
#include "functions.hpp"
|
#include "functions.hpp"
|
||||||
#include "mainwindow.hpp"
|
#include "mainwindow.hpp"
|
||||||
#include "databasewindow.hpp"
|
#include "databasewindow.hpp"
|
||||||
|
#include "progresswindow.hpp"
|
||||||
#include "tv_rename.hpp"
|
#include "tv_rename.hpp"
|
||||||
|
|
||||||
void MainWindow::chooseFile() {
|
void MainWindow::chooseFile() {
|
||||||
@ -364,6 +366,13 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
|
|||||||
|
|
||||||
submenu->append(*item);
|
submenu->append(*item);
|
||||||
|
|
||||||
|
item = new Gtk::MenuItem();
|
||||||
|
item->set_label("Change pattern");
|
||||||
|
item->signal_activate().connect(
|
||||||
|
sigc::mem_fun( *this, &MainWindow::dbPattern ) );
|
||||||
|
|
||||||
|
submenu->append(*item);
|
||||||
|
|
||||||
std::vector<Gtk::Widget*> left_aligned_widgets = {m_label_show,
|
std::vector<Gtk::Widget*> left_aligned_widgets = {m_label_show,
|
||||||
m_label_language, m_entry_show, m_combo_language, m_label_dir,
|
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_entry_dir, m_label_pattern, m_entry_pattern, m_button_pattern,
|
||||||
@ -482,8 +491,7 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
|
|||||||
sigc::mem_fun( *this, &MainWindow::patternHelp ) );
|
sigc::mem_fun( *this, &MainWindow::patternHelp ) );
|
||||||
|
|
||||||
// show everything except possible shows and items related to them
|
// show everything except possible shows and items related to them
|
||||||
box->show();
|
show_all_children();
|
||||||
box->show_all_children();
|
|
||||||
m_check_linux->set_active( true );
|
m_check_linux->set_active( true );
|
||||||
m_label_possible->hide();
|
m_label_possible->hide();
|
||||||
m_combo_possible->hide();
|
m_combo_possible->hide();
|
||||||
@ -492,7 +500,18 @@ MainWindow::MainWindow( const Glib::RefPtr< Gtk::Application > &ptr )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dbUpdate() {
|
void MainWindow::dbUpdate() {
|
||||||
updateDB( !m_check_linux->get_active() );
|
auto *pw = new ProgressWindow;
|
||||||
|
app->add_window( *pw );
|
||||||
|
auto app_ptr = app;
|
||||||
|
|
||||||
|
pw->signal_hide().connect(
|
||||||
|
[pw, app_ptr](){
|
||||||
|
app_ptr->remove_window( *pw );
|
||||||
|
delete pw;
|
||||||
|
});
|
||||||
|
std::thread t( updateDB, !m_check_linux->get_active(), pw );
|
||||||
|
t.detach();
|
||||||
|
pw->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dbClean() {
|
void MainWindow::dbClean() {
|
||||||
@ -500,7 +519,18 @@ void MainWindow::dbClean() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dbRefresh() {
|
void MainWindow::dbRefresh() {
|
||||||
refreshDB( !m_check_linux->get_active() );
|
auto *pw = new ProgressWindow;
|
||||||
|
app->add_window( *pw );
|
||||||
|
auto app_ptr = app;
|
||||||
|
|
||||||
|
pw->signal_hide().connect(
|
||||||
|
[pw, app_ptr](){
|
||||||
|
app_ptr->remove_window( *pw );
|
||||||
|
delete pw;
|
||||||
|
});
|
||||||
|
std::thread t( refreshDB, !m_check_linux->get_active(), pw );
|
||||||
|
t.detach();
|
||||||
|
pw->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dbAdd() {
|
void MainWindow::dbAdd() {
|
||||||
@ -526,12 +556,26 @@ void MainWindow::dbAdd() {
|
|||||||
|
|
||||||
std::cout << show << " " << language_code << " " << show_id << std::endl;
|
std::cout << show << " " << language_code << " " << show_id << std::endl;
|
||||||
|
|
||||||
addToDB( show, m_entry_dir->get_text(), language_code, show_id,
|
auto *pw = new ProgressWindow;
|
||||||
m_entry_pattern->get_text(), !m_check_linux->get_active(), m_check_dvd->get_active() );
|
app->add_window( *pw );
|
||||||
|
auto app_ptr = app;
|
||||||
|
|
||||||
|
pw->signal_hide().connect(
|
||||||
|
[pw, app_ptr](){
|
||||||
|
app_ptr->remove_window( *pw );
|
||||||
|
delete pw;
|
||||||
|
});
|
||||||
|
|
||||||
|
std::thread t( addToDB, std::ref( show ), m_entry_dir->get_text(),
|
||||||
|
std::ref( language_code ), std::ref( show_id ),
|
||||||
|
m_entry_pattern->get_text(), !m_check_linux->get_active(),
|
||||||
|
m_check_dvd->get_active(), pw );
|
||||||
|
t.detach();
|
||||||
|
pw->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::dbManage() {
|
void MainWindow::dbManage() {
|
||||||
auto *dbWindow = new DatabaseWindow( !m_check_linux->get_active() );
|
auto *dbWindow = new DatabaseWindow( !m_check_linux->get_active(), app );
|
||||||
app->add_window( *dbWindow );
|
app->add_window( *dbWindow );
|
||||||
auto app_ptr = app;
|
auto app_ptr = app;
|
||||||
|
|
||||||
@ -543,3 +587,33 @@ void MainWindow::dbManage() {
|
|||||||
|
|
||||||
dbWindow->show();
|
dbWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::dbPattern() {
|
||||||
|
// Create a custom dialog box for pattern change
|
||||||
|
std::unique_ptr<Gtk::Dialog> dialog( new Gtk::Dialog( "Change pattern", *this ) );
|
||||||
|
dialog->set_default_size( 350, 0 );
|
||||||
|
auto content = dialog->get_content_area();
|
||||||
|
|
||||||
|
auto pattern = getDBPattern();
|
||||||
|
|
||||||
|
std::unique_ptr<Gtk::Entry> pattern_entry( new Gtk::Entry );
|
||||||
|
content->pack_start( *pattern_entry );
|
||||||
|
|
||||||
|
dialog->add_button( "_Cancel", Gtk::RESPONSE_CANCEL );
|
||||||
|
dialog->add_button( "_OK", Gtk::RESPONSE_OK );
|
||||||
|
dialog->show_all_children();
|
||||||
|
|
||||||
|
dialog->signal_response().connect(
|
||||||
|
[&pattern, &pattern_entry]( int response ){
|
||||||
|
if( response == Gtk::RESPONSE_OK )
|
||||||
|
pattern = pattern_entry->get_text();
|
||||||
|
});
|
||||||
|
|
||||||
|
pattern_entry->set_text( pattern );
|
||||||
|
|
||||||
|
auto response = dialog->run();
|
||||||
|
|
||||||
|
if( response == Gtk::RESPONSE_OK ) {
|
||||||
|
changeDBPattern( pattern );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -35,6 +35,7 @@ private:
|
|||||||
void dbRefresh();
|
void dbRefresh();
|
||||||
void dbAdd();
|
void dbAdd();
|
||||||
void dbManage();
|
void dbManage();
|
||||||
|
void dbPattern();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Gtk::Button *m_button_dir = new Gtk::Button();
|
Gtk::Button *m_button_dir = new Gtk::Button();
|
||||||
|
Loading…
Reference in New Issue
Block a user