Просмотр исходного кода

Improve theme preview and refresh logic

Fix theme preview  & caption bar theme apply
Refactored the theme preview button to ensure the QPaste window is created and visible before applying the selected theme.
Schmurtz 2 недель назад
Родитель
Сommit
400cc1a088
3 измененных файлов с 26 добавлено и 14 удалено
  1. 13 14
      src/OptionsGeneral.cpp
  2. 11 0
      src/QPasteWnd.cpp
  3. 2 0
      src/QPasteWnd.h

+ 13 - 14
src/OptionsGeneral.cpp

@@ -684,26 +684,26 @@ void COptionsGeneral::OnClickedExpireEntries()
 
 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 the window doesn't exist yet, create/show it first (will load persisted theme)
+		if (pPasteWnd == NULL || IsWindow(pPasteWnd->m_hWnd) == FALSE)
+		{
+			theApp.m_pMainFrame->m_quickPaste.ShowQPasteWnd(theApp.m_pMainFrame, true, false, TRUE);
+			pPasteWnd = theApp.m_pMainFrame->m_quickPaste.m_pwndPaste;
+		}
+
+		// Ensure it is visible before applying preview theme
 		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);
 		}
+
+		// Reuse the dropdown-change logic to load/apply the selected theme
+		OnCbnSelchangeComboTheme();
 	}
 }
 
@@ -717,8 +717,7 @@ void COptionsGeneral::OnCbnSelchangeComboTheme()
 		// 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();
+			theApp.m_pMainFrame->m_quickPaste.m_pwndPaste->RefreshThemeColors();
 		}
 	}
 }

+ 11 - 0
src/QPasteWnd.cpp

@@ -7741,6 +7741,17 @@ bool CQPasteWnd::DoActionGmail()
 	return true;
 }
 
+void CQPasteWnd::RefreshThemeColors()
+{
+	// Refresh caption bar colors
+	SetCaptionColorActive(CGetSetOptions::m_bShowPersistent, theApp.GetConnectCV());
+	SetCaptionOn(CGetSetOptions::GetCaptionPos(), true, CGetSetOptions::m_Theme.GetCaptionSize(), CGetSetOptions::m_Theme.GetCaptionFontSize());
+	
+	// Force repaint of the entire window including non-client area
+	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
+	RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_FRAME);
+}
+
 bool CQPasteWnd::DoActionEmailToAttachExport()
 {
 	CWaitCursor wait;

+ 2 - 0
src/QPasteWnd.h

@@ -322,6 +322,8 @@ public:
 	bool OnGlobalHotkyes();
 	
 	void UpdateMenuShortCut(CCmdUI *pCmdUI, DWORD action);
+	// Refresh all theme colors (caption, scrollbars, etc.)
+	void RefreshThemeColors();
 
 	bool ShowProperties(int id, int row);
 	bool DeleteClips(CClipIDs &IDs, ARRAY &Indexs);