Add clipboard widget with history, search, and image support#666
Add clipboard widget with history, search, and image support#666stylebending wants to merge 1 commit intoamnweb:mainfrom
Conversation
|
Isn't it better to use the official API to access Windows clipboard data in realtime? https://learn.microsoft.com/en-us/windows/win32/dataxchg/clipboard |
Thanks for the suggestion and the link! That makes sense, and I agree that using the official Windows clipboard API is the better approach for real-time access. Would you prefer that I update this PR with the new approach, or close it and open a fresh one once the changes are ready? |
As you wish, your choice. |
|
This is as complete as I could get it, only thing missing is the pinning feature but the Python WinRT package doesn't support clipboard pinning it seems. Sorry for the multiple commits. |
|
I will probably check this this week when I have some free time, but let me know, using WinRT will require having the clipboard enabled in Windows OS, right? |
|
Thanks for the PR @stylebending. Same issue as with your other PR regarding the new validation schema format. It was a necessary change, so please check other widgets to get the general idea. Also Writing Widgets was updated. |
Yes it specifically requires 'Clipboard History' to be toggled On in Windows System Settings. If disabled, the WinRT API won't have a history buffer to pull from, and the widget will default to 'No items match your search.' I can add a small note to the widgets' README/Docs about this if you think it's necessary!
Thanks again for the heads-up! I've updated the validation schema to follow the new Pydantic format, using the other widgets and the updated documentation as a reference. This is ready for another look, let me know if any further tweaks are needed! |
|
Ok, tested.
|
|
Thanks for the review! Here's an update on each point:
For point 1. it seems like there is no Win32/ctypes equivalent for the clipboard history api, the standard Win32 clipboard API can only access the current clipboard, not the history. Since the project already depends on several |
|
wish the clipboard widget existed for yasb. it will be very useful to replace the win+v keyboard shortcut |
|
@stylebending thanks. Yeah, I already included |
45dccd3 to
8668158
Compare
|
@amnweb great! I've removed the note for users about that package in the widget's docs. This should be ready now. About the native Windows clipboard history being weird: I feel like for now, only showing the native Windows clipboard is fine. Later/In the future, I would like to add options to use a separate locally stored clipboard history and an option to choose whether to show the preview in a tooltip (by default) or split the clipboard widget window. |
8668158 to
6582491
Compare
|
Updated! I've replaced the tooltip, and also made it configurable to |
28c33cc to
ec93b76
Compare
Thanks for testing again! I've added textwrap for the tooltip, @amnweb please check this out again whenever you have the spare time. |
ec93b76 to
7e6da4d
Compare
|
@stylebending There are still a few things that need to be better. I think you can remove all the hardcoded spacing from 2026-02-20.20-13-09.mp4 |
7e6da4d to
7f36731
Compare
7f36731 to
b7dd2d4
Compare
|
@amnweb I've processed all those points, please try this out with the new CSS example in the widget's docs. All hardcoded CSS is removed except for the |
|
Thanks, I think you forgot about the default item spacing :D container_layout.setContentsMargins(0, 0, 0, 0)
container_layout.setSpacing(0)
item_layout.setContentsMargins(0, 0, 0, 0)
item_layout.setSpacing(0)
content_layout.setContentsMargins(0, 0, 0, 0)
content_layout.setSpacing(0)You should set everything to 0 so we can allow CSS to handle it as users need. Also, I’m not sure about this delete button. It somehow looks bad when it’s stretched. Maybe we can simply add the copy and delete buttons in the same column without stretching them? Or do you have any idea about this? Edit: What about the thumb? Can we align it to the left like the text as well? |
b7dd2d4 to
4cee556
Compare
|
@amnweb added those margins, thanks! 👍 |
|
OK, I have checked all of this carefully now, and there is one part I do not understand well. What is the reason for subclassing the existing PopupWidget and calling Another problem I found is that when you copy an item, you end up with duplicated items. I am not sure if this is Windows behavior as well, but we are free to promote the existing history entry to the top inside this popup when we copy it, without duplication. There are many things I would like to change here, but let me know if there is any real reason for all of the above. |
This widget just shows Windows clipboard history + I've added search functionality. The duplication is how Windows clipboard works (not something I added/made), you can check by pressing
Those were added because I was told to switch to the custom tooltip in earlier comments, and I noticed while using the widget with that custom tooltip that the tooltip would not close if I started typing in the search field. Feel free to change whatever you want. Edit: Thanks for helping out btw! |





Summary
This PR adds a new clipboard widget to YASB, providing a searchable clipboard history with long text preview and support for both text and images.
Features
Built-in search bar.
Clear history or delete single item.
Preview long text per history item by hovering over it.
Full support for copying and previewing images directly in the history list.
This is my first contribution of this size to a free and open-source project, so any feedback (code, structure, or UX) is very welcome 🙂
Tested with both text and image clipboard content on Windows 11.