1
0

prefs.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #include "main.h"
  2. #include "..\..\General\gen_ml/config.h"
  3. #include "resource.h"
  4. void hideShowRecentItemsCheckboxes(HWND hwndDlg)
  5. {
  6. int enabled = IsDlgButtonChecked(hwndDlg, IDC_CHECK1);
  7. int wait_secs = !!g_config->ReadInt(L"recent_wait_secs",0);
  8. int wait_percent = !!g_config->ReadInt(L"recent_wait_percent",0);
  9. int wait_end = !!g_config->ReadInt(L"recent_wait_end",0);
  10. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK2), enabled);
  11. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK3), enabled);
  12. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK4), enabled);
  13. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK5), enabled);
  14. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK6), enabled);
  15. EnableWindow(GetDlgItem(hwndDlg, IDC_CHECK7), enabled);
  16. EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT1), enabled && !!g_config->ReadInt(L"recent_limitd",1));
  17. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC1), enabled);
  18. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC3), enabled);
  19. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC4), enabled);
  20. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC5), enabled);
  21. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC6), enabled);
  22. EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT2), enabled && wait_secs);
  23. EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT3), enabled && wait_percent);
  24. EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC7), enabled && !(wait_end && !wait_secs && !wait_percent));
  25. EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO1), enabled && !(wait_end && !wait_secs && !wait_percent));
  26. }
  27. BOOL CALLBACK PrefsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  28. {
  29. static int need_ref;
  30. switch (uMsg)
  31. {
  32. case WM_INITDIALOG:
  33. {
  34. CheckDlgButton(hwndDlg,IDC_CHECK2,(g_config->ReadInt(L"recent_track",1)&1)?BST_CHECKED:0);
  35. CheckDlgButton(hwndDlg,IDC_CHECK3,(g_config->ReadInt(L"recent_track",1)&2)?0:BST_CHECKED);
  36. CheckDlgButton(hwndDlg,IDC_CHECK1,!!g_config->ReadInt(L"showrecentitems",1));
  37. CheckDlgButton(hwndDlg,IDC_CHECK4,!!g_config->ReadInt(L"recent_limitd",1));
  38. CheckDlgButton(hwndDlg,IDC_CHECK5,!!g_config->ReadInt(L"recent_wait_secs",0));
  39. CheckDlgButton(hwndDlg,IDC_CHECK6,!!g_config->ReadInt(L"recent_wait_percent",0));
  40. CheckDlgButton(hwndDlg,IDC_CHECK7,!!g_config->ReadInt(L"recent_wait_end",0));
  41. int item = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)WASABI_API_LNGSTRINGW(IDS_DISABLED));
  42. SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_SETITEMDATA,item,0);
  43. item = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)WASABI_API_LNGSTRINGW(IDS_PODCAST_ONLY));
  44. SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_SETITEMDATA,item,1);
  45. item = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)WASABI_API_LNGSTRINGW(IDS_ANY_APPLICABLE));
  46. SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_SETITEMDATA,item,2);
  47. SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_SETCURSEL,g_config->ReadInt(L"resumeplayback",0),0);
  48. SetDlgItemInt(hwndDlg,IDC_EDIT1,g_config->ReadInt(L"recent_limitnd",30),FALSE);
  49. SetDlgItemInt(hwndDlg,IDC_EDIT2,g_config->ReadInt(L"recent_wait_secs_lim",5),FALSE);
  50. SetDlgItemInt(hwndDlg,IDC_EDIT3,g_config->ReadInt(L"recent_wait_percent_lim",50),FALSE);
  51. need_ref=0;
  52. hideShowRecentItemsCheckboxes(hwndDlg);
  53. break;
  54. }
  55. case WM_COMMAND:
  56. switch(LOWORD(wParam))
  57. {
  58. case IDC_CHECK1:
  59. {
  60. int a=!!IsDlgButtonChecked(hwndDlg,IDC_CHECK1);
  61. g_config->WriteInt(L"showrecentitems",a);
  62. if (a) history_init();
  63. else history_quit();
  64. hideShowRecentItemsCheckboxes(hwndDlg);
  65. }
  66. break;
  67. case IDC_EDIT1:
  68. if (HIWORD(wParam) == EN_CHANGE)
  69. {
  70. BOOL t;
  71. int v=GetDlgItemInt(hwndDlg,IDC_EDIT1,&t,FALSE);
  72. if (t) g_config->WriteInt(L"recent_limitnd",v);
  73. need_ref++;
  74. }
  75. break;
  76. case IDC_CHECK4:
  77. g_config->WriteInt(L"recent_limitd",!!IsDlgButtonChecked(hwndDlg,IDC_CHECK4));
  78. EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT1),!!g_config->ReadInt(L"recent_limitd",1));
  79. need_ref++;
  80. break;
  81. case IDC_CHECK2:
  82. case IDC_CHECK3:
  83. g_config->WriteInt(L"recent_track",(IsDlgButtonChecked(hwndDlg,IDC_CHECK2)?1:0) | (IsDlgButtonChecked(hwndDlg,IDC_CHECK3)?0:2));
  84. break;
  85. case IDC_CHECK5:
  86. g_config->WriteInt(L"recent_wait_secs",!!IsDlgButtonChecked(hwndDlg,IDC_CHECK5));
  87. hideShowRecentItemsCheckboxes(hwndDlg);
  88. break;
  89. case IDC_CHECK6:
  90. g_config->WriteInt(L"recent_wait_percent",!!IsDlgButtonChecked(hwndDlg,IDC_CHECK6));
  91. hideShowRecentItemsCheckboxes(hwndDlg);
  92. break;
  93. case IDC_CHECK7:
  94. g_config->WriteInt(L"recent_wait_end",!!IsDlgButtonChecked(hwndDlg,IDC_CHECK7));
  95. hideShowRecentItemsCheckboxes(hwndDlg);
  96. break;
  97. case IDC_COMBO1:
  98. if (HIWORD(wParam) == CBN_SELCHANGE)
  99. {
  100. int item = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_GETCURSEL,0,0);
  101. if (item != CB_ERR)
  102. {
  103. g_config->WriteInt(L"resumeplayback", (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO1,CB_GETITEMDATA,item,0));
  104. }
  105. }
  106. break;
  107. case IDC_EDIT2:
  108. if (HIWORD(wParam) == EN_CHANGE)
  109. {
  110. BOOL t;
  111. int v=GetDlgItemInt(hwndDlg,IDC_EDIT2,&t,FALSE);
  112. if (t)
  113. {
  114. if(v < 0)
  115. {
  116. v = 1;
  117. SetDlgItemInt(hwndDlg, IDC_EDIT2, v, 0);
  118. }
  119. g_config->WriteInt(L"recent_wait_secs_lim",v);
  120. }
  121. need_ref++;
  122. }
  123. break;
  124. case IDC_EDIT3:
  125. if (HIWORD(wParam) == EN_CHANGE)
  126. {
  127. BOOL t;
  128. int v=GetDlgItemInt(hwndDlg,IDC_EDIT3,&t,FALSE);
  129. if(t)
  130. {
  131. int tweaked = 0;
  132. if(v > 99){
  133. v = 99;
  134. tweaked = 1;
  135. }
  136. else if(v < 1)
  137. {
  138. v = 1;
  139. tweaked = 1;
  140. }
  141. if(tweaked)
  142. {
  143. SetDlgItemInt(hwndDlg, IDC_EDIT3, v, 0);
  144. }
  145. g_config->WriteInt(L"recent_wait_percent_lim",v);
  146. }
  147. need_ref++;
  148. }
  149. break;
  150. };
  151. break;
  152. case WM_DESTROY:
  153. if (need_ref)
  154. {
  155. g_config->WriteInt(L"recent_limitlt",0); // make sure it gets refreshed
  156. // TODO: only do this if the history view is open
  157. PostMessage(plugin.hwndLibraryParent,WM_USER+30,0,0);
  158. }
  159. break;
  160. }
  161. return 0;
  162. }