Browse Source

Add theme preview to options dialog

A 'Preview' button next to the theme selection, allows to preview the selected theme in the Ditto window.
Also updates the Ditto window live when the dropdown theme selection changes.
Schmurtz 1 month ago
parent
commit
1697bb4c7f
4 changed files with 64 additions and 1 deletions
  1. 2 1
      CP_Main.rc
  2. 1 0
      resource.h
  3. 58 0
      src/OptionsGeneral.cpp
  4. 3 0
      src/OptionsGeneral.h

+ 2 - 1
CP_Main.rc

@@ -909,7 +909,8 @@ BEGIN
     GROUPBOX        "Accepted Copy Applications (separate by ;)",IDC_STATIC_APP_SEP_DESC,7,178,361,55
     GROUPBOX        "Accepted Copy Applications (separate by ;)",IDC_STATIC_APP_SEP_DESC,7,178,361,55
     PUSHBUTTON      "Advanced",IDC_BUTTON_ADVANCED,318,256,50,14
     PUSHBUTTON      "Advanced",IDC_BUTTON_ADVANCED,318,256,50,14
     COMBOBOX        IDC_COMBO_THEME,67,82,130,95,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
     COMBOBOX        IDC_COMBO_THEME,67,82,130,95,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
-    PUSHBUTTON      "About Theme",IDC_BUTTON_THEME,207,82,106,14
+    PUSHBUTTON      "Preview",IDC_BUTTON_PREVIEW_THEME,207,82,50,14
+    PUSHBUTTON      "About Theme",IDC_BUTTON_THEME,263,82,50,14
     PUSHBUTTON      "Font",IDC_BUTTON_FONT,67,125,130,14
     PUSHBUTTON      "Font",IDC_BUTTON_FONT,67,125,130,14
     PUSHBUTTON      "Default Font",IDC_BUTTON_DEFAULT_FAULT,207,125,106,14
     PUSHBUTTON      "Default Font",IDC_BUTTON_DEFAULT_FAULT,207,125,106,14
     LTEXT           "Theme",IDC_STATIC_THEME,9,82,36,12,SS_CENTERIMAGE
     LTEXT           "Theme",IDC_STATIC_THEME,9,82,36,12,SS_CENTERIMAGE

+ 1 - 0
resource.h

@@ -649,6 +649,7 @@
 #define IDC_MFCLINK2                    2172
 #define IDC_MFCLINK2                    2172
 #define IDC_EDIT_ACTIVE_APP             2173
 #define IDC_EDIT_ACTIVE_APP             2173
 #define IDC_CHECK_DO_NOT_HIDE_ON_DEACTIVATE 2174
 #define IDC_CHECK_DO_NOT_HIDE_ON_DEACTIVATE 2174
+#define IDC_BUTTON_PREVIEW_THEME        2175
 #define IDC_EDIT_ADV_FILTER             5001
 #define IDC_EDIT_ADV_FILTER             5001
 #define IDC_NEXT_MATCH_BUTTON           5002
 #define IDC_NEXT_MATCH_BUTTON           5002
 #define ID_FIRST_OPTION                 32771
 #define ID_FIRST_OPTION                 32771

+ 58 - 0
src/OptionsGeneral.cpp

@@ -74,6 +74,8 @@ BEGIN_MESSAGE_MAP(COptionsGeneral, CPropertyPage)
 	ON_BN_CLICKED(IDC_BUTTON_ADVANCED, &COptionsGeneral::OnBnClickedButtonAdvanced)
 	ON_BN_CLICKED(IDC_BUTTON_ADVANCED, &COptionsGeneral::OnBnClickedButtonAdvanced)
 	ON_WM_CTLCOLOR()
 	ON_WM_CTLCOLOR()
 	ON_BN_CLICKED(IDC_BUTTON_THEME, &COptionsGeneral::OnBnClickedButtonTheme)
 	ON_BN_CLICKED(IDC_BUTTON_THEME, &COptionsGeneral::OnBnClickedButtonTheme)
+	ON_BN_CLICKED(IDC_BUTTON_PREVIEW_THEME, &COptionsGeneral::OnBnClickedButtonPreviewTheme)
+	ON_CBN_SELCHANGE(IDC_COMBO_THEME, &COptionsGeneral::OnCbnSelchangeComboTheme)
 	ON_BN_CLICKED(IDC_BUTTON_DEFAULT_FAULT, &COptionsGeneral::OnBnClickedButtonDefaultFault)
 	ON_BN_CLICKED(IDC_BUTTON_DEFAULT_FAULT, &COptionsGeneral::OnBnClickedButtonDefaultFault)
 	ON_BN_CLICKED(IDC_BUTTON_FONT, &COptionsGeneral::OnBnClickedButtonFont)
 	ON_BN_CLICKED(IDC_BUTTON_FONT, &COptionsGeneral::OnBnClickedButtonFont)
 	ON_EN_CHANGE(IDC_PATH, &COptionsGeneral::OnEnChangePath)
 	ON_EN_CHANGE(IDC_PATH, &COptionsGeneral::OnEnChangePath)
@@ -679,3 +681,59 @@ void COptionsGeneral::OnClickedExpireEntries()
 		m_eExpireAfter.EnableWindow(FALSE);
 		m_eExpireAfter.EnableWindow(FALSE);
 	}
 	}
 }
 }
+
+void COptionsGeneral::OnBnClickedButtonPreviewTheme()
+{
+	ApplySelectedThemeToPreview();
+	
+	// Show the Ditto window next to the options dialog
+	if (theApp.m_pMainFrame != NULL)
+	{
+		CQPasteWnd* pPasteWnd = theApp.m_pMainFrame->m_quickPaste.m_pwndPaste;
+		
+		// If window already exists, just show it and refresh
+		if (pPasteWnd != NULL && IsWindow(pPasteWnd->m_hWnd))
+		{
+			pPasteWnd->ShowWindow(SW_SHOW);
+			pPasteWnd->SetForegroundWindow();
+			pPasteWnd->Invalidate();
+			pPasteWnd->UpdateWindow();
+		}
+		else
+		{
+			// Window doesn't exist, create and show it
+			theApp.m_pMainFrame->m_quickPaste.ShowQPasteWnd(theApp.m_pMainFrame, true, false, TRUE);
+		}
+	}
+}
+
+void COptionsGeneral::OnCbnSelchangeComboTheme()
+{
+	// If the Ditto window is currently visible, update the theme live
+	if (theApp.m_pMainFrame != NULL && theApp.m_pMainFrame->m_quickPaste.IsWindowVisibleEx())
+	{
+		ApplySelectedThemeToPreview();
+		
+		// Refresh the window to apply the new theme
+		if (theApp.m_pMainFrame->m_quickPaste.m_pwndPaste != NULL)
+		{
+			theApp.m_pMainFrame->m_quickPaste.m_pwndPaste->Invalidate();
+			theApp.m_pMainFrame->m_quickPaste.m_pwndPaste->UpdateWindow();
+		}
+	}
+}
+
+void COptionsGeneral::ApplySelectedThemeToPreview()
+{
+	CString csTheme = _T("");
+	if (m_cbTheme.GetCurSel() >= 0)
+	{
+		if (m_cbTheme.GetItemData(m_cbTheme.GetCurSel()) == 1)
+		{
+			m_cbTheme.GetLBText(m_cbTheme.GetCurSel(), csTheme);
+		}
+	}
+	
+	// Load the selected theme
+	CGetSetOptions::m_Theme.Load(csTheme, false, true);
+}

+ 3 - 0
src/OptionsGeneral.h

@@ -88,6 +88,9 @@ public:
 	afx_msg void OnBnClickedButtonAdvanced();
 	afx_msg void OnBnClickedButtonAdvanced();
 	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
 	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
 	afx_msg void OnBnClickedButtonTheme();
 	afx_msg void OnBnClickedButtonTheme();
+	afx_msg void OnBnClickedButtonPreviewTheme();
+	afx_msg void OnCbnSelchangeComboTheme();
+	void ApplySelectedThemeToPreview();
 	afx_msg void OnBnClickedButtonDefaultFault();
 	afx_msg void OnBnClickedButtonDefaultFault();
 	afx_msg void OnBnClickedButtonFont();
 	afx_msg void OnBnClickedButtonFont();
 	CComboBox m_cbTheme;
 	CComboBox m_cbTheme;