Coalesce three radios into a dropdown.
authorCarl Hetherington <cth@carlh.net>
Sun, 29 Dec 2024 14:54:14 +0000 (15:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 1 Jan 2025 00:54:38 +0000 (01:54 +0100)
src/wx/kdm_output_panel.cc
src/wx/kdm_output_panel.h
src/wx/short_kdm_output_panel.cc
src/wx/tall_kdm_output_panel.cc

index 30660c6af5dff8315373d2e59b67a6a7ddd09856..f86808a701d850b5db2435af74a0b27359c0e6de 100644 (file)
@@ -22,6 +22,7 @@
 #include "check_box.h"
 #include "confirm_kdm_email_dialog.h"
 #include "dcpomatic_button.h"
+#include "dcpomatic_choice.h"
 #include "extra_kdm_email_dialog.h"
 #include "kdm_advanced_dialog.h"
 #include "kdm_choice.h"
@@ -89,22 +90,23 @@ KDMOutputPanel::create_destination_widgets(wxWindow* parent)
                _folder->SetPath(wxStandardPaths::Get().GetDocumentsDir());
        }
 
-       _write_flat = new wxRadioButton(parent, wxID_ANY, _("Write all KDMs to the same folder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
-       _write_folder = new wxRadioButton(parent, wxID_ANY, _("Write a folder for each cinema's KDMs"));
-       _write_zip = new wxRadioButton(parent, wxID_ANY, _("Write a ZIP file for each cinema's KDMs"));
+       _write_collect = new Choice(parent);
+       _write_collect->add_entry(_("Write all KDMs to the same folder"));
+       _write_collect->add_entry(_("Write a folder for each cinema's KDMs"));
+       _write_collect->add_entry(_("Write a ZIP file for each cinema's KDMs"));
 
        _email = new CheckBox(parent, _("Send by email"));
        _add_email_addresses = new wxButton(parent, wxID_ANY, _("Set additional email addresses..."));
 
        switch (Config::instance()->last_kdm_write_type().get_value_or(Config::KDM_WRITE_FLAT)) {
        case Config::KDM_WRITE_FLAT:
-               _write_flat->SetValue(true);
+               _write_collect->set(0);
                break;
        case Config::KDM_WRITE_FOLDER:
-               _write_folder->SetValue(true);
+               _write_collect->set(1);
                break;
        case Config::KDM_WRITE_ZIP:
-               _write_zip->SetValue(true);
+               _write_collect->set(2);
                break;
        }
 
@@ -114,9 +116,7 @@ KDMOutputPanel::create_destination_widgets(wxWindow* parent)
        _write_to->bind(&KDMOutputPanel::write_to_changed, this);
        _email->bind(&KDMOutputPanel::email_changed, this);
        _add_email_addresses->Bind(wxEVT_BUTTON, boost::bind(&KDMOutputPanel::add_email_addresses_clicked, this));
-       _write_flat->Bind   (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
-       _write_folder->Bind (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
-       _write_zip->Bind    (wxEVT_RADIOBUTTON, boost::bind (&KDMOutputPanel::kdm_write_type_changed, this));
+       _write_collect->bind(&KDMOutputPanel::kdm_write_type_changed, this);
 }
 
 
@@ -176,9 +176,7 @@ KDMOutputPanel::setup_sensitivity ()
 {
        bool const write = _write_to->GetValue ();
        _folder->Enable (write);
-       _write_flat->Enable (write);
-       _write_folder->Enable (write);
-       _write_zip->Enable (write);
+       _write_collect->Enable(write);
 }
 
 
@@ -196,12 +194,16 @@ KDMOutputPanel::advanced_clicked ()
 void
 KDMOutputPanel::kdm_write_type_changed ()
 {
-       if (_write_flat->GetValue()) {
-               Config::instance()->set_last_kdm_write_type (Config::KDM_WRITE_FLAT);
-       } else if (_write_folder->GetValue()) {
-               Config::instance()->set_last_kdm_write_type (Config::KDM_WRITE_FOLDER);
-       } else if (_write_zip->GetValue()) {
-               Config::instance()->set_last_kdm_write_type (Config::KDM_WRITE_ZIP);
+       switch (_write_collect->get().get_value_or(0)) {
+       case 0:
+               Config::instance()->set_last_kdm_write_type(Config::KDM_WRITE_FLAT);
+               break;
+       case 1:
+               Config::instance()->set_last_kdm_write_type(Config::KDM_WRITE_FOLDER);
+               break;
+       case 2:
+               Config::instance()->set_last_kdm_write_type(Config::KDM_WRITE_ZIP);
+               break;
        }
 }
 
@@ -265,14 +267,16 @@ KDMOutputPanel::make (
        try {
 
                if (_write_to->GetValue()) {
-                       if (_write_flat->GetValue()) {
+                       switch (_write_collect->get().get_value_or(0)) {
+                       case 0:
                                written = write_files (
                                        kdms,
                                        directory(),
                                        _filename_format->get(),
                                        confirm_overwrite
                                        );
-                       } else if (_write_folder->GetValue()) {
+                               break;
+                       case 1:
                                written = write_directories (
                                        collect (kdms),
                                        directory(),
@@ -280,7 +284,8 @@ KDMOutputPanel::make (
                                        _filename_format->get(),
                                        confirm_overwrite
                                        );
-                       } else if (_write_zip->GetValue()) {
+                               break;
+                       case 2:
                                written = write_zip_files (
                                        collect (kdms),
                                        directory(),
@@ -288,6 +293,7 @@ KDMOutputPanel::make (
                                        _filename_format->get(),
                                        confirm_overwrite
                                        );
+                               break;
                        }
                }
 
index 84cfdecd7e6317c6abed32107a913e2b300901fd..848b15722abed423ca48dc03804595edd5af778d 100644 (file)
@@ -34,6 +34,7 @@ LIBDCP_ENABLE_WARNINGS
 
 
 class CheckBox;
+class Choice;
 class DirPickerCtrl;
 class Job;
 class KDMChoice;
@@ -89,9 +90,7 @@ protected:
 #else
        wxDirPickerCtrl* _folder;
 #endif
-       wxRadioButton* _write_flat;
-       wxRadioButton* _write_folder;
-       wxRadioButton* _write_zip;
+       Choice* _write_collect;
        wxButton* _advanced;
        CheckBox* _email;
        wxButton* _add_email_addresses;
index 5a0fb2504aec248eaac965bfc942ce2bc2fd5518..7e06923197077605e6b1a92047c07fb6dc8a6deb 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "check_box.h"
+#include "dcpomatic_choice.h"
 #include "kdm_choice.h"
 #include "name_format_editor.h"
 #include "short_kdm_output_panel.h"
@@ -68,15 +69,11 @@ ShortKDMOutputPanel::fill_destination_panel(wxPanel* panel)
        auto table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, 0);
        table->AddGrowableCol(1);
 
-       table->Add(_write_to, 1, wxEXPAND);
+       table->Add(_write_to, 1, wxEXPAND | wxLEFT);
        table->Add(_folder, 1, wxEXPAND);
 
-       auto write_options = new wxBoxSizer(wxVERTICAL);
-       write_options->Add(_write_flat, 1, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       write_options->Add(_write_folder, 1, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       write_options->Add(_write_zip, 1, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       table->AddSpacer(0);
-       table->Add(write_options);
+       add_label_to_sizer(table, panel, _("Collection"), true, 0, wxALIGN_CENTRE_VERTICAL | wxLEFT | wxRIGHT);
+       table->Add(_write_collect, 1, wxEXPAND);
 
        table->Add(_email, 1, wxEXPAND);
        table->Add(_add_email_addresses);
index d34c5460d66b67d0758830eb86461eee8c2d2f71..5d4c5c661f76c30fbed01bcac77aa1d789ccd578 100644 (file)
@@ -22,6 +22,7 @@
 #include "check_box.h"
 #include "confirm_kdm_email_dialog.h"
 #include "dcpomatic_button.h"
+#include "dcpomatic_choice.h"
 #include "extra_kdm_email_dialog.h"
 #include "kdm_advanced_dialog.h"
 #include "kdm_choice.h"
@@ -93,15 +94,11 @@ TallKDMOutputPanel::TallKDMOutputPanel(wxWindow* parent)
        table->Add (align, 0, wxTOP | wxRIGHT | wxALIGN_TOP, DCPOMATIC_SIZER_GAP);
 #endif
        table->Add (_filename_format->panel(), 1, wxEXPAND);
-       table->Add (_write_to, 1, wxEXPAND);
+       table->Add (_write_to, 1, wxEXPAND | wxLEFT);
        table->Add (_folder, 1, wxEXPAND);
 
-       auto write_options = new wxBoxSizer(wxVERTICAL);
-       write_options->Add (_write_flat, 1, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       write_options->Add (_write_folder, 1, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       write_options->Add (_write_zip, 1, wxTOP | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       table->AddSpacer (0);
-       table->Add (write_options);
+       add_label_to_sizer(table, this, _("Collection"), true, 0, wxALIGN_CENTRE_VERTICAL | wxLEFT | wxRIGHT);
+       table->Add(_write_collect, 1, wxEXPAND);
 
        table->Add (_email, 1, wxEXPAND);
        table->Add (_add_email_addresses);