📄 syncsettings.cpp
字号:
}
#endif
}
void CSyncSettings::OnOK(){
ClientSettings* cs = getRegConfig();
BOOL dirtyFlag=FALSE;
if(checkStartSync()){
CDialog::OnOK();
}
if( (checkContacts.GetCheck() == BST_UNCHECKED)){
// save 'none'
if(strcmp(cs->getConfigSourcesParameter("contact","sync"),"none")!=0){
cs->setConfigSourcesParameter("contact", "sync","none");
dirtyFlag=TRUE;
}
}
else{
if( ( ~advanced | ADVANCED_CONTACTS) &&
(!strcmp(cs->getConfigSourcesParameter("contact", "sync"),"none")) )
{
// save 'two-way'
if(strcmp(cs->getConfigSourcesParameter("contact","sync"),"two-way")!=0){
cs->setConfigSourcesParameter("contact", "sync","two-way");
dirtyFlag=TRUE;
}
}
}
if( (checkCalendar.GetCheck() == BST_UNCHECKED))
{
// save 'none'
if(strcmp(cs->getConfigSourcesParameter("calendar","sync"),"none")!=0){
cs->setConfigSourcesParameter("calendar", "sync","none");
dirtyFlag=TRUE;
}
}
else
{
if( (! (advanced & ADVANCED_CALENDAR)) &&
(!strcmp(cs->getConfigSourcesParameter("calendar", "sync"),"none")) )
{
// save 'two-way'
if(strcmp(cs->getConfigSourcesParameter("calendar","sync"),"two-way")!=0){
cs->setConfigSourcesParameter("calendar", "sync","two-way");
dirtyFlag=TRUE;
}
}
}
if((checkTasks.GetCheck() == BST_UNCHECKED))
{
// save 'none'
if(strcmp(cs->getConfigSourcesParameter("task","sync"),"none")!=0){
cs->setConfigSourcesParameter("task", "sync","none");
dirtyFlag=TRUE;
}
}
else
{
if( (! (advanced & ADVANCED_TASKS)) &&
(!strcmp(cs->getConfigSourcesParameter("task", "sync"),"none")) )
{
// save 'two-way'
if(strcmp(cs->getConfigSourcesParameter("task","sync"),"two-way")!=0){
cs->setConfigSourcesParameter("task", "sync","two-way");
dirtyFlag=TRUE;
}
}
}
if( (checkMail.GetCheck() == BST_UNCHECKED || !doesFunambolAccountExist()))
{
// save 'none'
if(strcmp(cs->getConfigSourcesParameter("mail","sync"),"none")!=0){
cs->setConfigSourcesParameter("mail", "sync","none");
dirtyFlag=TRUE;
}
}
else
{
// There's no (! (advanced & ADVANCED_MAIL)) condition in this if because
// in the mail advance settings there's no a sync type setting to set
if( (!strcmp(cs->getConfigSourcesParameter("mail", "sync"),"none")) )
{
// save 'two-way'
if(strcmp(cs->getConfigSourcesParameter("mail","sync"),"two-way")!=0){
cs->setConfigSourcesParameter("mail", "sync","two-way");
dirtyFlag=TRUE;
}
}
}
if( (checkBriefcase.GetCheck() == BST_UNCHECKED))
{
// save 'none'
if(strcmp(cs->getConfigSourcesParameter("briefcase","sync"),"none")!=0){
cs->setConfigSourcesParameter("briefcase", "sync","none");
dirtyFlag=TRUE;
}
}
else
{
if( (! (advanced & ADVANCED_BRIEFCASE)) &&
(!strcmp(cs->getConfigSourcesParameter("briefcase", "sync"),"none")) )
{
// save 'two-way'
if(strcmp(cs->getConfigSourcesParameter("briefcase","sync"),"two-way")!=0){
cs->setConfigSourcesParameter("briefcase", "sync","two-way");
dirtyFlag=TRUE;
}
}
}
#if defined(WIN32_PLATFORM_PSPC)
if( (checkNotes.GetCheck() == BST_UNCHECKED))
{
// save 'none'
if(strcmp(cs->getConfigSourcesParameter("note","sync"),"none")!=0){
cs->setConfigSourcesParameter("note", "sync","none");
dirtyFlag=TRUE;
}
}
else
{
if( (! (advanced & ADVANCED_NOTES)) &&
(!strcmp(cs->getConfigSourcesParameter("note", "sync"),"none")) )
{
// save 'two-way'
if(strcmp(cs->getConfigSourcesParameter("note","sync"),"two-way")!=0){
cs->setConfigSourcesParameter("note", "sync","two-way");
dirtyFlag=TRUE;
}
}
}
#endif
//getRegConfig()->setDirty(CS_DIRTY_SOURCE_ALL);
if(dirtyFlag){
getRegConfig()->setDirty(CS_DIRTY_SOURCE_ENABLED);
getRegConfig()->saveDirty();
}
CDialog::OnOK();
}
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CSyncSettings::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/){
int resId;
BOOL showScroll = FALSE;
switch(DRA::GetDisplayMode())
{
case DRA::Landscape:
resId = IDD_UI_SYNC_WIDE;
showScroll = TRUE;
break;
case DRA::Portrait:
resId = IDD_UI_SYNC; break;
showScroll = FALSE;
case DRA::Square:
resId = IDD_UI_SYNC_SQUARE; break;
showScroll = TRUE;
default:
resId = IDD_UI_SYNC; break;
showScroll = FALSE;
};
DRA::RelayoutDialog( AfxGetInstanceHandle(), this->m_hWnd, MAKEINTRESOURCE(resId));
LoadStringResources();
}
#endif
void CSyncSettings::OnClickedSyncButtonMail(){
source = "mail";
showAdvanced();
}
void CSyncSettings::OnClickedSyncButtonCalendar(){
source = "calendar";
showAdvanced();
}
void CSyncSettings::OnClickedSyncButtonContacts(){
source = "contacts";
showAdvanced();
}
void CSyncSettings::OnClickedSyncButtonTasks(){
source = "tasks";
showAdvanced();
}
void CSyncSettings::OnClickedSyncButtonBriefcase(){
source = "briefcase";
showAdvanced();
}
#if defined(WIN32_PLATFORM_PSPC)
void CSyncSettings::OnBnClickedSyncNotes(){
if(checkNotes.GetCheck() == BST_UNCHECKED)
butNotes.EnableWindow(FALSE);
else
butNotes.EnableWindow(TRUE);
if(checkNotes.GetCheck() == BST_CHECKED) {
source=TEXT("note");
}
}
void CSyncSettings::OnClickedSyncButtonNotes(){
source = "note";
showAdvanced();
}
#endif
void CSyncSettings::LoadStringResources(){
CString s1;
// load strings
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_EMAIL); SetDlgItemText(IDC_SYNC_MAIL, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CONTACTS); SetDlgItemText(IDC_SYNC_CONTACTS, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CALENDAR); SetDlgItemText(IDC_SYNC_CALENDAR,s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TASKS); SetDlgItemText(IDC_SYNC_TASKS, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_BRIEFCASE); SetDlgItemText(IDC_SYNC_BRIEFCASE, s1);
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_NOTES); SetDlgItemText(IDC_SYNC_NOTES, s1);
#endif
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SYNC_ITEMS); SetDlgItemText(IDC_SYNC_STATIC_ITEMS, s1);
}
#if defined(WIN32_PLATFORM_PSPC)
void CSyncSettings::OnBnSetfocusSyncNotes(){
if(checkNotes.GetCheck() == BST_CHECKED) {
source=TEXT("note");
}
}
#endif
// user clicked 'Advanced Settings' link
void CSyncSettings::OnBnClickedSyncLinkAdvanced(){
CSyncSettingsAdvanced wndSyncAdvanced;
INT_PTR result = wndSyncAdvanced.DoModal();
}
// capture pressing of 'Advanced' link
BOOL CSyncSettings::PreTranslateMessage(MSG* pMsg){
bool bProcessed =false;
if(pMsg->message == WM_KEYDOWN){
if(pMsg->wParam == VK_RETURN){
if(processKeyEvents(pMsg->wParam)){
bProcessed = true;
}
};
// left/right/down arrow keys
if( (pMsg->wParam == VK_LEFT) || (pMsg->wParam == VK_RIGHT) ||
(pMsg->wParam == VK_DOWN) || (pMsg->wParam == VK_UP)){
if(processKeyEvents(pMsg->wParam)){
bProcessed = true;
}
};
};
if(bProcessed){
return TRUE;
}
else{
return CDialog::PreTranslateMessage(pMsg);
}
}
void CSyncSettings::OnBnSetfocusSyncLinkAdvanced(){
}
/*bool CSyncSettings::isFocusOnSourceCheckbox(){
HWND wndFocus = GetFocus()->GetSafeHwnd();
bool hasFocus = false;
if( (wndFocus == checkMail.GetSafeHwnd()) || (wndFocus == checkContacts.GetSafeHwnd()) ||
(wndFocus == checkCalendar.GetSafeHwnd()) || (wndFocus == checkTasks.GetSafeHwnd()) ||
(wndFocus == checkBriefcase.GetSafeHwnd()) ){
hasFocus = true;
}
#if defined(WIN32_PLATFORM_PSPC)
if(wndFocus == checkNotes.GetSafeHwnd()){
hasFocus = true;
}
#endif
return hasFocus;
}*/
bool CSyncSettings::processKeyEvents(WPARAM key){
bool bProcessed = false;
HWND wndFocus = GetFocus()->GetSafeHwnd();
if(key == VK_RETURN){
if(wndFocus == butMail.GetSafeHwnd()){
OnClickedSyncButtonMail();
return true;
};
if(wndFocus == butContacts.GetSafeHwnd()){
OnClickedSyncButtonContacts();
return true;
};
if(wndFocus == butCalendar.GetSafeHwnd()){
OnClickedSyncButtonCalendar();
return true;
};
if(wndFocus == butTasks.GetSafeHwnd()){
OnClickedSyncButtonTasks();
return true;
};
if(wndFocus == butBriefcase.GetSafeHwnd()){
OnClickedSyncButtonBriefcase();
return true;
};
if(wndFocus == linkAdvanced.GetSafeHwnd()){
OnBnClickedSyncLinkAdvanced();
return true;
};
#if defined(WIN32_PLATFORM_PSPC)
if(wndFocus == butNotes.GetSafeHwnd()){
OnClickedSyncButtonNotes();
return true;
};
#endif
}
if( (key == VK_LEFT) || (key == VK_RIGHT) ){
if(wndFocus == checkMail.GetSafeHwnd()){
butMail.SetFocus();
return true;
};
if(wndFocus == checkContacts.GetSafeHwnd()){
butContacts.SetFocus();
return true;
};
if(wndFocus == checkCalendar.GetSafeHwnd()){
butCalendar.SetFocus();
return true;
};
if(wndFocus == checkTasks.GetSafeHwnd()){
butTasks.SetFocus();
return true;
};
#if defined(WIN32_PLATFORM_PSPC)
if(wndFocus == checkNotes.GetSafeHwnd()){
butNotes.SetFocus();
return true;
};
#endif
if(wndFocus == checkBriefcase.GetSafeHwnd()){
butBriefcase.SetFocus();
return true;
};
if(wndFocus == butMail.GetSafeHwnd()){
checkMail.SetFocus();
return true;
};
if(wndFocus == butContacts.GetSafeHwnd()){
checkContacts.SetFocus();
return true;
};
if(wndFocus == butCalendar.GetSafeHwnd()){
checkCalendar.SetFocus();
return true;
};
if(wndFocus == butTasks.GetSafeHwnd()){
checkTasks.SetFocus();
return true;
};
#if defined(WIN32_PLATFORM_PSPC)
if(wndFocus == butNotes.GetSafeHwnd()){
checkNotes.SetFocus();
return true;
};
#endif
if(wndFocus == butBriefcase.GetSafeHwnd()){
checkBriefcase.SetFocus();
return true;
};
}
if(key == VK_DOWN){
if(checkBriefcase.IsWindowEnabled()){
if(wndFocus == checkBriefcase.GetSafeHwnd()){
linkAdvanced.SetFocus();
return true;
}
}
else{
// for portal last source is Tasks
if(wndFocus == checkTasks.GetSafeHwnd()){
linkAdvanced.SetFocus();
return true;
}
}
}
if(key == VK_UP){
if(wndFocus == linkAdvanced.GetSafeHwnd()){
if(checkBriefcase.IsWindowEnabled()){
checkBriefcase.SetFocus();
}
else{
checkTasks.SetFocus();
}
return true;
}
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -