mirror of https://github.com/BOINC/boinc.git
MGR: In Advanced Preferences dialog:
- Change legends at top of dialog to indicate whether using local or web-based prefs. - Change "Clear" button to "Use web prefs" and hide it if already using web-based prefs. - Add hyperlink to source of current web-based-prefs.
This commit is contained in:
parent
65448baaa3
commit
939777a757
|
@ -940,7 +940,7 @@ void CDlgAdvPreferences::OnClear(wxCommandEvent& ev) {
|
|||
|
||||
bool CDlgAdvPreferences::ConfirmClear() {
|
||||
int res = wxGetApp().SafeMessageBox(_(
|
||||
"Do you really want to clear all local preferences?\n(This will not affect exclusive applications.)"),
|
||||
"Do you really want to discard all local preferences and return to using web-based preferences?"),
|
||||
_("Confirmation"),wxCENTER | wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT,this);
|
||||
|
||||
return res==wxYES;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "parse.h"
|
||||
#include "LogBOINC.h"
|
||||
#include "BOINCGUIApp.h"
|
||||
#include "MainDocument.h"
|
||||
#include "SkinManager.h"
|
||||
|
||||
#include "DlgAdvPreferencesBase.h"
|
||||
|
@ -63,12 +64,60 @@ CDlgAdvPreferencesBase::CDlgAdvPreferencesBase( wxWindow* parent, int id, wxStri
|
|||
|
||||
topControlsSizer->Add( m_bmpWarning, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0 );
|
||||
|
||||
wxBoxSizer* legendSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
bool usingLocalPrefs = doesLocalPrefsFileExist();
|
||||
if (usingLocalPrefs) {
|
||||
legendSizer->Add(
|
||||
new wxStaticText( topControlsStaticBox, ID_DEFAULT,
|
||||
_("This computer is using local preferences.\n"
|
||||
"Click \"Use web prefs\" if you want to use web-based preferences from:"
|
||||
), wxDefaultPosition, wxDefaultSize, 0 ),
|
||||
0, wxALL, 1
|
||||
);
|
||||
} else {
|
||||
legendSizer->Add(
|
||||
new wxStaticText( topControlsStaticBox, ID_DEFAULT,
|
||||
_("This computer is using web-based preferences from:"),
|
||||
wxDefaultPosition, wxDefaultSize, 0 ),
|
||||
0, wxALL, 1
|
||||
);
|
||||
}
|
||||
|
||||
legendSizer->Add(
|
||||
new wxHyperlinkCtrl(
|
||||
topControlsStaticBox, wxID_ANY, *web_prefs_url, *web_prefs_url,
|
||||
wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE
|
||||
),
|
||||
0, wxLEFT, 5
|
||||
);
|
||||
|
||||
if (!usingLocalPrefs) {
|
||||
legendSizer->Add(
|
||||
new wxStaticText( topControlsStaticBox, ID_DEFAULT,
|
||||
_("Click OK if you want to edit preferences locally.\n"
|
||||
"(Changes to web-based preferences won't affect this computer)."
|
||||
), wxDefaultPosition, wxDefaultSize, 0 ),
|
||||
0, wxALL, 1
|
||||
);
|
||||
}
|
||||
|
||||
topControlsSizer->Add( legendSizer, 1, wxALL, 1 );
|
||||
|
||||
#if 0
|
||||
wxStaticText* staticText321 = new wxStaticText( topControlsStaticBox, ID_DEFAULT, _("This dialog controls preferences for this computer only.\nClick OK to set preferences.\nClick Clear to restore web-based settings."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
topControlsSizer->Add( staticText321, 1, wxALL, 1 );
|
||||
|
||||
m_btnClear = new wxButton( topControlsStaticBox, ID_BTN_CLEAR, _("Clear"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_btnClear->SetToolTip( _("clear all local preferences and close the dialog") );
|
||||
#endif
|
||||
|
||||
m_btnClear = new wxButton( topControlsStaticBox, ID_BTN_CLEAR, _("Use web prefs"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_btnClear->SetToolTip( _("restore web-based preferences and close the dialog") );
|
||||
if (!usingLocalPrefs) {
|
||||
m_btnClear->Hide();
|
||||
}
|
||||
|
||||
topControlsSizer->Add( m_btnClear, 0, wxALIGN_BOTTOM|wxALL, 4 );
|
||||
|
||||
dialogSizer->Add( topControlsSizer, 0, wxALL|wxEXPAND, 1 );
|
||||
|
@ -742,3 +791,31 @@ wxSize CDlgAdvPreferencesBase::getTextCtrlSize(wxString maxText) {
|
|||
sz.y = wxDefaultCoord;
|
||||
return sz;
|
||||
}
|
||||
|
||||
bool CDlgAdvPreferencesBase::doesLocalPrefsFileExist() {
|
||||
std::string s;
|
||||
int retval;
|
||||
bool local_prefs_found = false;
|
||||
MIOFILE mf;
|
||||
bool found_venue;
|
||||
GLOBAL_PREFS web_prefs;
|
||||
GLOBAL_PREFS_MASK mask;
|
||||
CMainDocument* pDoc = wxGetApp().GetDocument();
|
||||
|
||||
wxASSERT(pDoc);
|
||||
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
||||
|
||||
retval = pDoc->rpc.get_global_prefs_override(s);
|
||||
local_prefs_found = (retval == BOINC_SUCCESS);
|
||||
|
||||
s.clear();
|
||||
web_prefs.init();
|
||||
|
||||
retval = pDoc->rpc.get_global_prefs_file(s);
|
||||
mf.init_buf_read(s.c_str());
|
||||
XML_PARSER xp(&mf);
|
||||
web_prefs.parse(xp, "", found_venue, mask);
|
||||
web_prefs_url = new wxString(web_prefs.source_project);
|
||||
|
||||
return local_prefs_found;
|
||||
}
|
||||
|
|
|
@ -183,6 +183,8 @@ protected:
|
|||
wxButton* m_btnOK;
|
||||
wxButton* m_btnCancel;
|
||||
wxButton* m_btnHelp;
|
||||
|
||||
wxString *web_prefs_url;
|
||||
|
||||
public:
|
||||
CDlgAdvPreferencesBase( wxWindow* parent, int id = -1, wxString title = wxT(""), wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize, int style = wxDEFAULT_DIALOG_STYLE );
|
||||
|
@ -192,6 +194,7 @@ private:
|
|||
wxPanel* createNetworkTab(wxNotebook* notebook);
|
||||
wxPanel* createDiskAndMemoryTab(wxNotebook* notebook);
|
||||
wxSize getTextCtrlSize(wxString maxText);
|
||||
bool doesLocalPrefsFileExist();
|
||||
};
|
||||
|
||||
#endif //__DlgAdvPreferencesBase__
|
||||
|
|
Loading…
Reference in New Issue