Ticket #1518: filezilla_3_rc1_save_position.patch

File filezilla_3_rc1_save_position.patch, 4.8 KB (added by tommywu, 13 years ago)

patch to remember UI position

  • src/interface/Mainfrm.cpp

    diff -Nur Filezilla3/src/interface/Mainfrm.cpp Filezilla3.patch/src/interface/Mainfrm.cpp
    old new  
    2929#include "export.h"
    3030#include "import.h"
    3131#include "recursive_operation.h"
     32#include <wx/tokenzr.h>
    3233
    3334#ifndef __WXMSW__
    3435#include "resources/filezilla.xpm"
     
    189190
    190191    m_pLocalSplitter = new wxSplitterWindow(m_pViewSplitter, -1, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER  | wxSP_LIVE_UPDATE);
    191192    m_pLocalSplitter->SetMinimumPaneSize(20);
    192     m_pLocalSplitter->SetSashGravity(0.7);
     193    m_pLocalSplitter->SetSashGravity(0.0);
    193194
    194195    m_pRemoteSplitter = new wxSplitterWindow(m_pViewSplitter, -1, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER  | wxSP_LIVE_UPDATE);
    195196    m_pRemoteSplitter->SetMinimumPaneSize(20);
    196     m_pRemoteSplitter->SetSashGravity(0.7);
     197    m_pRemoteSplitter->SetSashGravity(0.0);
    197198
    198199    m_pStatusView = new CStatusView(m_pTopSplitter, -1);
    199200    m_pQueuePane = new CQueue(m_pBottomSplitter, this, m_pAsyncRequestQueue);
     
    275276
    276277    Layout();
    277278
     279    // is_maximized win_x win_y win_width win_height top_pos bottom_height view_pos view_height_width local_pos remote_pos
     280    wxString posString = COptions::Get()->GetOption(OPTION_WINDOW_POSITION);
     281    wxStringTokenizer tokens(posString, _T(" "));
     282    int count = tokens.CountTokens();
     283    if (count == 11) {
     284        unsigned long * aPosValues = new unsigned long[count];
     285        for (int i = 0; i < count; i++) {
     286            wxString token = tokens.GetNextToken();
     287            token.ToULong(aPosValues + i);
     288        }
     289
     290        m_pTopSplitter->SetSashPosition(aPosValues[5]);
     291
     292        int x, y;
     293        m_pBottomSplitter->GetClientSize(&x, &y);
     294        y -= aPosValues[6];
     295        if (y < 100) y = 100;
     296        m_pBottomSplitter->SetSashPosition(y);
     297
     298        m_ViewSplitterSashPos = (float)aPosValues[7]/aPosValues[8];
     299        m_pViewSplitter->SetSashPosition(aPosValues[7]);
     300
     301        if (aPosValues[0])
     302            Maximize();
     303        else {
     304            Move(aPosValues[1], aPosValues[2]);
     305            SetClientSize(aPosValues[3], aPosValues[4]);
     306        }
     307
     308        m_pLocalSplitter->SetSashPosition(aPosValues[9]);
     309        m_pRemoteSplitter->SetSashPosition(aPosValues[10]);
     310        delete [] aPosValues;
     311    }
     312
    278313    wxString localDir = COptions::Get()->GetOption(OPTION_LASTLOCALDIR);
    279314    if (!m_pState->SetLocalDir(localDir))
    280315        m_pState->SetLocalDir(_T("/"));
     
    750785
    751786void CMainFrame::OnClose(wxCloseEvent &event)
    752787{
     788    wxString posString;
     789    // is_maximized
     790    posString += wxString::Format(_T("%d "), IsMaximized() ? 1 : 0);
     791    int x, y;
     792    // pos_x pos_y
     793    GetPosition(&x, &y);
     794    posString += wxString::Format(_T("%d %d "), x, y);
     795    // pos_width pos_height
     796    GetClientSize(&x, &y);
     797    posString += wxString::Format(_T("%d %d "), x, y);
     798    // top_pos
     799    posString += wxString::Format(_T("%d "), m_pTopSplitter->GetSashPosition());
     800    // bottom_height
     801    m_pBottomSplitter->GetClientSize(&x, &y);
     802    posString += wxString::Format(_T("%d "), y - m_pBottomSplitter->GetSashPosition());
     803    // view_pos
     804    posString += wxString::Format(_T("%d "), m_pViewSplitter->GetSashPosition());
     805    // view_height_width
     806    m_pViewSplitter->GetClientSize(&x, &y);
     807    if (COptions::Get()->GetOptionVal(OPTION_FILEPANE_LAYOUT) != 1)
     808        posString += wxString::Format(_T("%d "), x);
     809    else
     810        posString += wxString::Format(_T("%d "), y);
     811    // local_pos
     812    posString += wxString::Format(_T("%d "), m_pLocalSplitter->GetSashPosition());
     813    // remote_pos
     814    posString += wxString::Format(_T("%d "), m_pRemoteSplitter->GetSashPosition());
     815    COptions::Get()->SetOption(OPTION_WINDOW_POSITION, posString);
     816
    753817    Show(false);
    754818    m_bQuit = true;
    755819    delete m_pSendLed;
  • src/interface/Options.cpp

    diff -Nur Filezilla3/src/interface/Options.cpp Filezilla3.patch/src/interface/Options.cpp
    old new  
    8181    { "Queue successful autoclear", number, _T("0") },
    8282    { "Queue column widths", string, _T("") },
    8383    { "Local filelist colwidths", string, _T("") },
    84     { "Remote filelist colwidths", string, _T("") }
     84    { "Remote filelist colwidths", string, _T("") },
     85    { "Window position and size", string, _T("") }
    8586};
    8687
    8788COptions::COptions()
  • src/interface/Options.h

    diff -Nur Filezilla3/src/interface/Options.h Filezilla3.patch/src/interface/Options.h
    old new  
    3535    OPTION_QUEUE_COLUMN_WIDTHS,
    3636    OPTION_LOCALFILELIST_COLUMN_WIDTHS,
    3737    OPTION_REMOTEFILELIST_COLUMN_WIDTHS,
     38    OPTION_WINDOW_POSITION,
    3839
    3940    // Has to be last element
    4041    OPTIONS_NUM