mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
Spreadsheet: Change paste action's enabled state on clipboard change
Previously, the paste action was always enabled and always assumed that anything was selected, which led to a crash by clicking the paste action right after the application startup. This patch will automatically enable/disable the paste action depending on whether a selection exists (it usually does, except on the app launch and after adding a new tab) and if the clipboard mime type is a text/ group. So no, you can't paste an image into the app anymore, even though this mostly froze the app before...
This commit is contained in:
parent
7ba2e5e3e7
commit
35934acbd3
2 changed files with 17 additions and 1 deletions
|
@ -9,12 +9,15 @@
|
|||
#include "SpreadsheetView.h"
|
||||
#include "Workbook.h"
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/TabWidget.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
namespace Spreadsheet {
|
||||
|
||||
class SpreadsheetWidget final : public GUI::Widget {
|
||||
class SpreadsheetWidget final
|
||||
: public GUI::Widget
|
||||
, public GUI::Clipboard::ClipboardClient {
|
||||
C_OBJECT(SpreadsheetWidget);
|
||||
|
||||
public:
|
||||
|
@ -49,8 +52,12 @@ public:
|
|||
auto& undo_stack() { return m_undo_stack; }
|
||||
|
||||
private:
|
||||
// ^GUI::Widget
|
||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
|
||||
// ^GUI::Clipboard::ClipboardClient
|
||||
virtual void clipboard_content_did_change(String const& mime_type) override;
|
||||
|
||||
explicit SpreadsheetWidget(GUI::Window& window, NonnullRefPtrVector<Sheet>&& sheets = {}, bool should_add_sheet_if_empty = true);
|
||||
|
||||
void setup_tabs(NonnullRefPtrVector<Sheet> new_sheets);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue