"Fossies" - the Fresh Open Source Software Archive

Member "filezilla-3.48.1/src/interface/settings/optionspage_interface.cpp" (7 May 2020, 5954 Bytes) of package /linux/misc/FileZilla_3.48.1_src.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "optionspage_interface.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.48.0_vs_3.48.1.

    1 #include <filezilla.h>
    2 #include "../Options.h"
    3 #include "settingsdialog.h"
    4 #include "optionspage_interface.h"
    5 #include "../Mainfrm.h"
    6 #include "../power_management.h"
    7 #include "../xrc_helper.h"
    8 #include <libfilezilla/util.hpp>
    9 
   10 #include <wx/statbox.h>
   11 
   12 BEGIN_EVENT_TABLE(COptionsPageInterface, COptionsPage)
   13 EVT_CHECKBOX(XRCID("ID_FILEPANESWAP"), COptionsPageInterface::OnLayoutChange)
   14 EVT_CHOICE(XRCID("ID_FILEPANELAYOUT"), COptionsPageInterface::OnLayoutChange)
   15 EVT_CHOICE(XRCID("ID_MESSAGELOGPOS"), COptionsPageInterface::OnLayoutChange)
   16 END_EVENT_TABLE()
   17 
   18 bool COptionsPageInterface::LoadPage()
   19 {
   20     bool failure = false;
   21 
   22     SetCheckFromOption(XRCID("ID_FILEPANESWAP"), OPTION_FILEPANE_SWAP, failure);
   23     SetChoice(XRCID("ID_FILEPANELAYOUT"), m_pOptions->GetOptionVal(OPTION_FILEPANE_LAYOUT), failure);
   24 
   25     SetChoice(XRCID("ID_MESSAGELOGPOS"), m_pOptions->GetOptionVal(OPTION_MESSAGELOG_POSITION), failure);
   26 
   27 #ifndef __WXMAC__
   28     SetCheckFromOption(XRCID("ID_MINIMIZE_TRAY"), OPTION_MINIMIZE_TRAY, failure);
   29 #endif
   30 
   31     SetCheckFromOption(XRCID("ID_PREVENT_IDLESLEEP"), OPTION_PREVENT_IDLESLEEP, failure);
   32 
   33     SetCheckFromOption(XRCID("ID_SPEED_DISPLAY"), OPTION_SPEED_DISPLAY, failure);
   34 
   35     if (!CPowerManagement::IsSupported()) {
   36         XRCCTRL(*this, "ID_PREVENT_IDLESLEEP", wxCheckBox)->Hide();
   37     }
   38 
   39     int const startupAction = m_pOptions->GetOptionVal(OPTION_STARTUP_ACTION);
   40     switch (startupAction) {
   41     default:
   42         xrc_call(*this, "ID_INTERFACE_STARTUP_NORMAL", &wxRadioButton::SetValue, true);
   43         break;
   44     case 1:
   45         xrc_call(*this, "ID_INTERFACE_STARTUP_SITEMANAGER", &wxRadioButton::SetValue, true);
   46         break;
   47     case 2:
   48         xrc_call(*this, "ID_INTERFACE_STARTUP_RESTORE", &wxRadioButton::SetValue, true);
   49         break;
   50     }
   51 
   52     int action = m_pOptions->GetOptionVal(OPTION_ALREADYCONNECTED_CHOICE);
   53     if (action & 2) {
   54         action = 1 + (action & 1);
   55     }
   56     else {
   57         action = 0;
   58     }
   59     SetChoice(XRCID("ID_NEWCONN_ACTION"), action, failure);
   60 
   61     m_pOwner->RememberOldValue(OPTION_MESSAGELOG_POSITION);
   62     m_pOwner->RememberOldValue(OPTION_FILEPANE_LAYOUT);
   63     m_pOwner->RememberOldValue(OPTION_FILEPANE_SWAP);
   64 
   65     return !failure;
   66 }
   67 
   68 bool COptionsPageInterface::SavePage()
   69 {
   70     SetOptionFromCheck(XRCID("ID_FILEPANESWAP"), OPTION_FILEPANE_SWAP);
   71     m_pOptions->SetOption(OPTION_FILEPANE_LAYOUT, GetChoice(XRCID("ID_FILEPANELAYOUT")));
   72 
   73     m_pOptions->SetOption(OPTION_MESSAGELOG_POSITION, GetChoice(XRCID("ID_MESSAGELOGPOS")));
   74 
   75 #ifndef __WXMAC__
   76     SetOptionFromCheck(XRCID("ID_MINIMIZE_TRAY"), OPTION_MINIMIZE_TRAY);
   77 #endif
   78 
   79     SetOptionFromCheck(XRCID("ID_PREVENT_IDLESLEEP"), OPTION_PREVENT_IDLESLEEP);
   80 
   81     SetOptionFromCheck(XRCID("ID_SPEED_DISPLAY"), OPTION_SPEED_DISPLAY);
   82 
   83     int startupAction = 0;
   84     if (xrc_call(*this, "ID_INTERFACE_STARTUP_SITEMANAGER", &wxRadioButton::GetValue)) {
   85         startupAction = 1;
   86     }
   87     else if (xrc_call(*this, "ID_INTERFACE_STARTUP_RESTORE", &wxRadioButton::GetValue)) {
   88         startupAction = 2;
   89     }
   90     m_pOptions->SetOption(OPTION_STARTUP_ACTION, startupAction);
   91 
   92     int action = GetChoice(XRCID("ID_NEWCONN_ACTION"));
   93     if (!action) {
   94         action = m_pOptions->GetOptionVal(OPTION_ALREADYCONNECTED_CHOICE) & 1;
   95     }
   96     else {
   97         action += 1;
   98     }
   99     m_pOptions->SetOption(OPTION_ALREADYCONNECTED_CHOICE, action);
  100 
  101     return true;
  102 }
  103 
  104 void COptionsPageInterface::OnLayoutChange(wxCommandEvent&)
  105 {
  106     m_pOptions->SetOption(OPTION_FILEPANE_LAYOUT, GetChoice(XRCID("ID_FILEPANELAYOUT")));
  107     m_pOptions->SetOption(OPTION_FILEPANE_SWAP, GetCheck(XRCID("ID_FILEPANESWAP")) ? 1 : 0);
  108     m_pOptions->SetOption(OPTION_MESSAGELOG_POSITION, GetChoice(XRCID("ID_MESSAGELOGPOS")));
  109 }
  110 
  111 bool COptionsPageInterface::CreateControls(wxWindow* parent)
  112 {
  113     auto const& lay = m_pOwner->layout();
  114 
  115     Create(parent);
  116     auto main = lay.createFlex(1);
  117     main->AddGrowableCol(0);
  118     SetSizer(main);
  119 
  120     {
  121         auto [box, inner] = lay.createStatBox(main, _("Layout"), 1);
  122 
  123         auto rows = lay.createFlex(2);
  124         inner->Add(rows);
  125         rows->Add(new wxStaticText(box, -1, _("&Layout of file and directory panes:")), lay.valign);
  126         auto choice = new wxChoice(box, XRCID("ID_FILEPANELAYOUT"));
  127         choice->Append(_("Classic"));
  128         choice->Append(_("Explorer"));
  129         choice->Append(_("Widescreen"));
  130         choice->Append(_("Blackboard"));
  131         rows->Add(choice, lay.valign);
  132         rows->Add(new wxStaticText(box, -1, _("Message log positio&n:")), lay.valign);
  133         choice = new wxChoice(box, XRCID("ID_MESSAGELOGPOS"));
  134         choice->Append(_("Above the file lists"));
  135         choice->Append(_("Next to the transfer queue"));
  136         choice->Append(_("As tab in the transfer queue pane"));
  137         rows->Add(choice, lay.valign);
  138         inner->Add(new wxCheckBox(box, XRCID("ID_FILEPANESWAP"), _("&Swap local and remote panes")));
  139     }
  140 
  141     {
  142         auto [box, inner] = lay.createStatBox(main, _("Behaviour"), 1);
  143         
  144 #ifndef __WXMAC__
  145         inner->Add(new wxCheckBox(box, XRCID("ID_MINIMIZE_TRAY"), _("&Minimize to tray")));
  146 #endif
  147         inner->Add(new wxCheckBox(box, XRCID("ID_PREVENT_IDLESLEEP"), _("P&revent system from entering idle sleep during transfers and other operations")));
  148         inner->AddSpacer(0);
  149         inner->Add(new wxStaticText(box, -1, _("On startup of FileZilla:")));
  150         inner->Add(new wxRadioButton(box, XRCID("ID_INTERFACE_STARTUP_NORMAL"), _("S&tart normally"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP));
  151         inner->Add(new wxRadioButton(box, XRCID("ID_INTERFACE_STARTUP_SITEMANAGER"), _("S&how the Site Manager on startup")));
  152         inner->Add(new wxRadioButton(box, XRCID("ID_INTERFACE_STARTUP_RESTORE"), _("Restore ta&bs and reconnect")));
  153         inner->AddSpacer(0);
  154         inner->Add(new wxStaticText(box, -1, _("When st&arting a new connection while already connected:")));
  155         auto choice = new wxChoice(box, XRCID("ID_NEWCONN_ACTION"));
  156         choice->Append(_("Ask for action"));
  157         choice->Append(_("Connect in new tab"));
  158         choice->Append(_("Connect in current tab"));
  159         inner->Add(choice);
  160     }
  161 
  162     {
  163         auto [box, inner] = lay.createStatBox(main, _("Transfer Queue"), 1);
  164         inner->Add(new wxCheckBox(box, XRCID("ID_SPEED_DISPLAY"), _("&Display momentary transfer speed instead of average speed")));
  165     }
  166 
  167     return true;
  168 }