--- Mainfrm.cpp 2015-12-08 12:21:15.680410265 -0500 +++ Mainfrm_new.cpp 2015-12-08 12:26:26.240327781 -0500 @@ -79,33 +79,32 @@ std::map, wxChar>> keyboardCommands; -#ifdef __WXMAC__ wxTextEntry* GetSpecialTextEntry(wxWindow* w, wxChar cmd) { - if (cmd == 'A' || cmd == 'V') { +#ifdef __WXMAC__ + if( cmd == 'A' || cmd == 'V' ) { wxTextCtrl* text = dynamic_cast(w); - if (text && text->GetWindowStyle() & wxTE_PASSWORD) { + if( text && text->GetWindowStyle() & wxTE_PASSWORD ) { return text; } } - return dynamic_cast(w); -} -#else -wxTextEntry* GetSpecialTextEntry(wxWindow*, wxChar) -{ + wxComboBox* combo = dynamic_cast(w); + if( combo ) { + return combo; + } +#endif return 0; } -#endif bool HandleKeyboardCommand(wxCommandEvent& event, wxWindow& parent) { auto const& it = keyboardCommands.find(event.GetId()); - if (it == keyboardCommands.end()) { + if( it == keyboardCommands.end() ) { return false; } wxTextEntry* e = GetSpecialTextEntry(parent.FindFocus(), it->second.second); - if (e) { + if( e ) { it->second.first(e); } else { @@ -267,7 +266,7 @@ initial_size.y = wxMin(950, screen_size.GetHeight() - 50); Create(NULL, -1, _T("FileZilla"), wxDefaultPosition, initial_size); - SetSizeHints(350, 300); + SetSizeHints(250, 250); #ifdef __WXMSW__ // In order for the --close commandline argument to work, @@ -332,7 +331,7 @@ m_pTopSplitter->SetMinimumPaneSize(50); m_pBottomSplitter = new CSplitterWindowEx(m_pTopSplitter, -1, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_LIVE_UPDATE); - m_pBottomSplitter->SetMinimumPaneSize(20, 70); + m_pBottomSplitter->SetMinimumPaneSize(10, 60); m_pBottomSplitter->SetSashGravity(1.0); const int message_log_position = COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_POSITION); @@ -429,19 +428,10 @@ CAutoAsciiFiles::SettingsChanged(); FixTabOrder(); - - RegisterOption(OPTION_LANGUAGE); - RegisterOption(OPTION_THEME); - RegisterOption(OPTION_THEME_ICONSIZE); - RegisterOption(OPTION_MESSAGELOG_POSITION); - RegisterOption(OPTION_FILEPANE_LAYOUT); - RegisterOption(OPTION_FILEPANE_SWAP); } CMainFrame::~CMainFrame() { - UnregisterAllOptions(); - CPowerManagement::Destroy(); delete m_pStateEventHandler; @@ -667,7 +657,7 @@ CImportDialog dlg(this, m_pQueueView); dlg.Run(); } - else if (event.GetId() == XRCID("ID_MENU_FILE_EDITED")) { + else if (event.GetId() == XRCID("ID_MENU_FILE_EDIOnTED")) { CEditHandlerStatusDialog dlg(this); dlg.ShowModal(); } @@ -1014,17 +1004,24 @@ pState->Disconnect(); } +//this function depends on StopRecursiveOperation(), switched the order of the if statements and edited context of second if block. void CMainFrame::OnCancel(wxCommandEvent&) { + + //get the current state of this prgm CState* pState = CContextManager::Get()->GetCurrentContext(); - if (!pState || pState->m_pCommandQueue->Idle()) - return; - + //send a dialog box to check, if yes, stop the operation if (wxMessageBoxEx(_("Really cancel current operation?"), _T("FileZilla"), wxYES_NO | wxICON_QUESTION) == wxYES) { pState->m_pCommandQueue->Cancel(); pState->GetRecursiveOperationHandler()->StopRecursiveOperation(); } +//if there is no state or state is idle,just stop it anyway, FileZilla might be misbehaving. . . + if (!pState || pState->m_pCommandQueue->Idle()){ + pstate->m_pCommandQueue->Cancel(); + pState->GetRecursiveOperationHandler()-> StopRecursiveOperation(); + return; + } } #ifdef __WXMSW__ @@ -1270,7 +1267,8 @@ CServer server = pState->GetLastServer(); - if (server.GetLogonType() == ASK) { + if (server.GetLogonType() == ASK) + { if (!CLoginManager::Get().GetPassword(server, false)) return; } @@ -1398,7 +1396,6 @@ return; } #endif - (void)e; OpenSiteManager(); } @@ -1422,17 +1419,42 @@ COptions* pOptions = COptions::Get(); + wxString oldTheme = pOptions->GetOption(OPTION_THEME); + wxString oldThemeSize = pOptions->GetOption(OPTION_THEME_ICONSIZE); wxString oldLang = pOptions->GetOption(OPTION_LANGUAGE); int oldShowDebugMenu = pOptions->GetOptionVal(OPTION_DEBUG_MENU) != 0; + bool oldTimestamps = pOptions->GetOptionVal(OPTION_MESSAGELOG_TIMESTAMP) != 0; + int res = dlg.ShowModal(); - if (res != wxID_OK) { + if (res != wxID_OK) + { + UpdateLayout(); return; } + bool newTimestamps = pOptions->GetOptionVal(OPTION_MESSAGELOG_TIMESTAMP) != 0; + + wxString newTheme = pOptions->GetOption(OPTION_THEME); + wxString newThemeSize = pOptions->GetOption(OPTION_THEME_ICONSIZE); wxString newLang = pOptions->GetOption(OPTION_LANGUAGE); + if (oldTheme != newTheme || + oldThemeSize != newThemeSize || + oldLang != newLang) + { + CreateMainToolBar(); + if (m_pToolBar) + m_pToolBar->UpdateToolbarState(); + } + + if (oldLang != newLang || + oldTimestamps != newTimestamps) + { + m_pStatusView->InitDefAttr(); + } + if (oldLang != newLang || oldShowDebugMenu != pOptions->GetOptionVal(OPTION_DEBUG_MENU)) { @@ -1452,34 +1474,42 @@ bool shown; - if (COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_POSITION) == 1) { + if (COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_POSITION) == 1) + { if (!m_pQueueLogSplitter) return; - if (m_pQueueLogSplitter->IsSplit()) { + if (m_pQueueLogSplitter->IsSplit()) + { m_pQueueLogSplitter->Unsplit(m_pStatusView); shown = false; } - else if (m_pStatusView->IsShown()) { + else if (m_pStatusView->IsShown()) + { m_pStatusView->Hide(); m_pBottomSplitter->Unsplit(m_pQueueLogSplitter); shown = false; } - else if (!m_pQueueLogSplitter->IsShown()) { + else if (!m_pQueueLogSplitter->IsShown()) + { m_pQueueLogSplitter->Initialize(m_pStatusView); m_pBottomSplitter->SplitHorizontally(m_pContextControl, m_pQueueLogSplitter); shown = true; } - else { + else + { m_pQueueLogSplitter->SplitVertically(m_pQueuePane, m_pStatusView); shown = true; } } - else { - if (m_pTopSplitter->IsSplit()) { + else + { + if (m_pTopSplitter->IsSplit()) + { m_pTopSplitter->Unsplit(m_pStatusView); shown = false; } - else { + else + { m_pTopSplitter->SplitHorizontally(m_pStatusView, m_pBottomSplitter); shown = true; } @@ -1539,7 +1569,7 @@ COptions::Get()->SetOption(local ? OPTION_SHOW_TREE_LOCAL : OPTION_SHOW_TREE_REMOTE, show); } -void CMainFrame::OnToggleQueueView(wxCommandEvent&) +void CMainFrame::OnToggleQueueView(wxCommandEvent& event) { if (!m_pBottomSplitter) return; @@ -1616,19 +1646,19 @@ } #if FZ_MANUALUPDATECHECK -void CMainFrame::OnCheckForUpdates(wxCommandEvent&) +void CMainFrame::OnCheckForUpdates(wxCommandEvent& event) { - if (!m_pUpdater) { + if( !m_pUpdater ) { return; } update_dialog_timer_.Stop(); - CUpdateDialog dlg(this, *m_pUpdater); + CUpdateDialog dlg( this, *m_pUpdater ); dlg.ShowModal(); update_dialog_timer_.Stop(); } -void CMainFrame::UpdaterStateChanged(UpdaterState s, build const& v) +void CMainFrame::UpdaterStateChanged( UpdaterState s, build const& v ) { #if FZ_AUTOUPDATECHECK if( !m_pMenuBar ) { @@ -1693,12 +1723,15 @@ } #endif -void CMainFrame::UpdateLayout() +void CMainFrame::UpdateLayout(int layout /*=-1*/, int swap /*=-1*/, int messagelog_position /*=-1*/) { - int const layout = COptions::Get()->GetOptionVal(OPTION_FILEPANE_LAYOUT); - int const swap = COptions::Get()->GetOptionVal(OPTION_FILEPANE_SWAP); + if (layout == -1) + layout = COptions::Get()->GetOptionVal(OPTION_FILEPANE_LAYOUT); + if (swap == -1) + swap = COptions::Get()->GetOptionVal(OPTION_FILEPANE_SWAP); - int const messagelog_position = COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_POSITION); + if (messagelog_position == -1) + messagelog_position = COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_POSITION); // First handle changes in message log position as it can make size of the other panes change { @@ -1706,13 +1739,16 @@ wxWindow* parent = m_pStatusView->GetParent(); bool changed; - if (parent == m_pTopSplitter && messagelog_position != 0) { + if (parent == m_pTopSplitter && messagelog_position != 0) + { if (shown) m_pTopSplitter->Unsplit(m_pStatusView); changed = true; } - else if (parent == m_pQueueLogSplitter && messagelog_position != 1) { - if (shown) { + else if (parent == m_pQueueLogSplitter && messagelog_position != 1) + { + if (shown) + { if (m_pQueueLogSplitter->IsSplit()) m_pQueueLogSplitter->Unsplit(m_pStatusView); else @@ -1720,7 +1756,8 @@ } changed = true; } - else if (parent != m_pTopSplitter && parent != m_pQueueLogSplitter && messagelog_position != 2) { + else if (parent != m_pTopSplitter && parent != m_pQueueLogSplitter && messagelog_position != 2) + { m_pQueuePane->RemovePage(3); changed = true; shown = true; @@ -1728,8 +1765,10 @@ else changed = false; - if (changed) { - switch (messagelog_position) { + if (changed) + { + switch (messagelog_position) + { default: m_pStatusView->Reparent(m_pTopSplitter); if (shown) @@ -1923,6 +1962,8 @@ void CMainFrame::CheckChangedSettings() { + UpdateLayout(); + m_pAsyncRequestQueue->RecheckDefaults(); CAutoAsciiFiles::SettingsChanged(); @@ -2142,7 +2183,7 @@ m_pAsyncRequestQueue->TriggerProcessing(); } -void CMainFrame::OnToolbarComparison(wxCommandEvent&) +void CMainFrame::OnToolbarComparison(wxCommandEvent& event) { CState* pState = CContextManager::Get()->GetCurrentContext(); if (!pState) @@ -2251,7 +2292,7 @@ pComparisonManager->CompareListings(); } -void CMainFrame::OnDropdownComparisonHide(wxCommandEvent&) +void CMainFrame::OnDropdownComparisonHide(wxCommandEvent& event) { CState* pState = CContextManager::Get()->GetCurrentContext(); if (!pState) @@ -2343,7 +2384,7 @@ } } -void CMainFrame::OnFilterRightclicked(wxCommandEvent&) +void CMainFrame::OnFilterRightclicked(wxCommandEvent& event) { const bool active = CFilterManager::HasActiveFilters(); @@ -2401,7 +2442,7 @@ } #endif -void CMainFrame::OnSyncBrowse(wxCommandEvent&) +void CMainFrame::OnSyncBrowse(wxCommandEvent& event) { CState* pState = CContextManager::Get()->GetCurrentContext(); if (!pState) @@ -2475,7 +2516,7 @@ } #ifdef __WXGTK__ -void CMainFrame::OnTaskBarClick_Delayed(wxCommandEvent&) +void CMainFrame::OnTaskBarClick_Delayed(wxCommandEvent& event) { m_taskbar_is_uniconizing = false; } @@ -2483,7 +2524,7 @@ #endif -void CMainFrame::OnSearch(wxCommandEvent&) +void CMainFrame::OnSearch(wxCommandEvent& event) { CState* pState = CContextManager::Get()->GetCurrentContext(); if (!pState) @@ -2524,7 +2565,7 @@ } } -void CMainFrame::OnMenuNewTab(wxCommandEvent&) +void CMainFrame::OnMenuNewTab(wxCommandEvent& event) { if (m_pContextControl) m_pContextControl->CreateTab(); @@ -2668,18 +2709,3 @@ wxAcceleratorTable accel(entries.size(), &entries[0]); SetAcceleratorTable(accel); } - -void CMainFrame::OnOptionsChanged(changed_options_t const& options) -{ - if (options.test(OPTION_FILEPANE_LAYOUT) || options.test(OPTION_FILEPANE_SWAP) || options.test(OPTION_MESSAGELOG_POSITION)) { - UpdateLayout(); - } - - bool const language_changed = options.test(OPTION_LANGUAGE); - if (options.test(OPTION_THEME) || options.test(OPTION_THEME_ICONSIZE) || language_changed) { - CreateMainToolBar(); - if (m_pToolBar) { - m_pToolBar->UpdateToolbarState(); - } - } -}