mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:17:36 +00:00
LibGUI: Add a ClipboardClient for GUI::Clipboard
Anyone who inherits from `GUI::Clipboard::ClipboardClient` will receive clipboard notifications via `clipboard_content_did_change()`. Update ClipboardHistoryModel, TextEditor and TerminalWidget to inherit from this class.
This commit is contained in:
parent
95f393ebcd
commit
0c53c2dfa2
8 changed files with 106 additions and 72 deletions
|
@ -143,10 +143,6 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co
|
|||
m_context_menu->add_separator();
|
||||
m_context_menu->add_action(clear_including_history_action());
|
||||
|
||||
GUI::Clipboard::the().on_change = [this](const String&) {
|
||||
update_paste_action();
|
||||
};
|
||||
|
||||
update_copy_action();
|
||||
update_paste_action();
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibCore/ElapsedTimer.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/Frame.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
@ -22,7 +23,8 @@ namespace VT {
|
|||
|
||||
class TerminalWidget final
|
||||
: public GUI::Frame
|
||||
, public VT::TerminalClient {
|
||||
, public VT::TerminalClient
|
||||
, public GUI::Clipboard::ClipboardClient {
|
||||
C_OBJECT(TerminalWidget);
|
||||
|
||||
public:
|
||||
|
@ -123,6 +125,9 @@ private:
|
|||
virtual void emit(const u8*, size_t) override;
|
||||
virtual void set_cursor_style(CursorStyle) override;
|
||||
|
||||
// ^GUI::Clipboard::ClipboardClient
|
||||
virtual void clipboard_content_did_change(const String&) override { update_paste_action(); }
|
||||
|
||||
void set_logical_focus(bool);
|
||||
|
||||
void send_non_user_input(const ReadonlyBytes&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue