Browse Source

added option to maintain search view

sabrogden 4 years ago
parent
commit
50d0b6aced
5 changed files with 60 additions and 3 deletions
  1. 14 0
      AdvGeneral.cpp
  2. 1 1
      Clip.cpp
  3. 12 0
      Options.cpp
  4. 4 0
      Options.h
  5. 29 2
      QPasteWnd.cpp

+ 14 - 0
AdvGeneral.cpp

@@ -130,6 +130,7 @@ END_MESSAGE_MAP()
 #define SETTING_EDITOR_FONT_SIZE 79
 #define SETTING_MOVE_SELECTION_ON_OPEN_HOTKEY 80
 #define SETTING_ALOW_BACK_TO_BACK_DUPLICATES 81
+#define SETTING_MAINTAIN_SEARCH_VIEW 82
 
 BOOL CAdvGeneral::OnInitDialog()
 {
@@ -195,6 +196,8 @@ BOOL CAdvGeneral::OnInitDialog()
 	AddTrueFalse(pGroupTest, _T("Hide Ditto on Hot Key if Ditto is Visible"), CGetSetOptions::GetHideDittoOnHotKeyIfAlreadyShown(), SETTING_HIDE_ON_HOTKEY_IF_VISIBLE);
 	pGroupTest->AddSubItem( new CMFCPropertyGridProperty(_T("Maximum Clip Size in Bytes (0 for no limit)"), g_Opt.m_lMaxClipSizeInBytes, _T(""), SETTING_MAX_CLIP_SIZE));
 	
+	AddTrueFalse(pGroupTest, _T("Maintain Search View"), CGetSetOptions::GetMaintainSearchView(), SETTING_MAINTAIN_SEARCH_VIEW);
+
 	AddTrueFalse(pGroupTest, _T("Move Selection On Open Hot Key"), CGetSetOptions::GetMoveSelectionOnOpenHotkey(), SETTING_MOVE_SELECTION_ON_OPEN_HOTKEY);
 	
 	pGroupTest->AddSubItem( new CMFCPropertyGridProperty(_T("Multi-Paste clip separator ([LF] = line feed)"), g_Opt.GetMultiPasteSeparator(false), _T(""), SETTING_CLIP_SEPARATOR));
@@ -823,6 +826,17 @@ void CAdvGeneral::OnBnClickedOk()
 					CGetSetOptions::SetMoveSelectionOnOpenHotkey(val);
 				}
 				break;
+			case SETTING_MAINTAIN_SEARCH_VIEW:
+				if (pNewValue->lVal != pOrigValue->lVal)
+				{
+					BOOL val = false;
+					if (wcscmp(pNewValue->bstrVal, L"True") == 0)
+					{
+						val = true;
+					}
+					CGetSetOptions::SetMaintainSearchView(val);
+				}
+				break;
 			}
 		}
 	}

+ 1 - 1
Clip.cpp

@@ -438,7 +438,7 @@ int CClip::LoadFromClipboard(CClipTypes* pClipTypes, bool checkClipboardIgnore,
 		if (bIsDescSet)
 		{
 			checkedRegEx = true;
-			std::wstring stringData(this->m_Desc);
+			std::wstring stringData(this->m_Desc); 
 			if (g_Opt.m_regexHelper.TextMatchFilters(activeApp, stringData))
 			{
 				return -1;

+ 12 - 0
Options.cpp

@@ -78,6 +78,7 @@ int CGetSetOptions::m_firstTenHotKeysStart = 1;
 int CGetSetOptions::m_firstTenHotKeysFontSize = 5;
 BOOL CGetSetOptions::m_moveSelectionOnOpenHotkey = TRUE;
 BOOL CGetSetOptions::m_allowBackToBackDuplicates = FALSE;
+BOOL CGetSetOptions::m_maintainSearchView = FALSE;
 
 CGetSetOptions::CGetSetOptions()
 {
@@ -2896,4 +2897,15 @@ void CGetSetOptions::SetAllowBackToBackDuplicates(BOOL val)
 {
 	m_allowBackToBackDuplicates = val;
 	SetProfileLong("AllowBackToBackDuplicates", val);
+}
+
+BOOL CGetSetOptions::GetMaintainSearchView()
+{
+	return GetProfileLong("MaintainSearchView", FALSE);
+}
+
+void CGetSetOptions::SetMaintainSearchView(BOOL val)
+{
+	m_maintainSearchView = val;
+	SetProfileLong("MaintainSearchView", val);
 }

+ 4 - 0
Options.h

@@ -651,6 +651,10 @@ public:
 	static BOOL GetAllowBackToBackDuplicates();
 	static void SetAllowBackToBackDuplicates(BOOL val);
 
+	static BOOL m_maintainSearchView;
+	static BOOL GetMaintainSearchView();
+	static void SetMaintainSearchView(BOOL val);
+
 
 };
 

+ 29 - 2
QPasteWnd.cpp

@@ -739,7 +739,14 @@ void CQPasteWnd::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
 
 		if (!g_Opt.m_bShowPersistent)
 		{
-			HideQPasteWindow(false);
+			bool clearSearch = true;
+			if (g_Opt.m_maintainSearchView &&
+				m_strSearch != _T(""))
+			{
+				Log(_T("Currently searching for something and setting to maintain search view is enabled, not refreshing"));
+				clearSearch = false;
+			}
+			HideQPasteWindow(false, clearSearch);
 		}
 		else if (g_Opt.GetAutoHide())
 		{
@@ -1148,6 +1155,13 @@ LRESULT CQPasteWnd::OnListEnd(WPARAM wParam, LPARAM lParam)
 
 LRESULT CQPasteWnd::OnReloadClipAfterPaste(WPARAM wParam, LPARAM lParam)
 {
+	if (g_Opt.m_maintainSearchView &&
+		m_strSearch != _T(""))
+	{
+		Log(_T("Currently searching for something and setting to maintain search view is enabled, not refreshing clip order"));
+		return FALSE;
+	}
+
 	DWORD startTick = GetTickCount();
 
 	BOOL foundClip = FALSE;
@@ -1213,6 +1227,13 @@ LRESULT CQPasteWnd::OnReloadClipAfterPaste(WPARAM wParam, LPARAM lParam)
 
 LRESULT CQPasteWnd::OnRefreshView(WPARAM wParam, LPARAM lParam)
 {
+	if (g_Opt.m_maintainSearchView &&
+		m_strSearch != _T(""))
+	{
+		Log(_T("Currently searching for something and setting to maintain search view is enabled, not refreshing"));
+		return FALSE;
+	}
+
 	MSG msg;
 	// remove all additional refresh view messages from the queue
 	while (::PeekMessage(&msg, m_hWnd, WM_REFRESH_VIEW, WM_REFRESH_VIEW, PM_REMOVE)) {}
@@ -7557,7 +7578,13 @@ bool CQPasteWnd::DoActionSlugify()
 
 bool CQPasteWnd::DoRefreshList()
 {
-	FillList(_T(""));
+	theApp.m_FocusID = -1;
+
+	CString csText;
+	m_search.GetWindowText(csText);
+
+	FillList(csText);
+	
 	return true;
 }