diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp index a4f2b8757c..4eecac4110 100644 --- a/src/aboutdialog.cpp +++ b/src/aboutdialog.cpp @@ -1,7 +1,7 @@ /******************************************************* Copyright (C) 2006 Madhan Kanagavel Copyright (C) 2012 - 2021 Nikolay Akimov - Copyright (C) 2021 Mark Whalley (mark@ipx.co.uk) + Copyright (C) 2021,2024 Mark Whalley (mark@ipx.co.uk) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -202,27 +202,27 @@ void mmAboutDialog::createControls(int tabToOpenNo) wxBoxSizer *privacySizer = new wxBoxSizer(wxVERTICAL); privacyTab->SetSizer(privacySizer); - aboutText_ = new wxHtmlWindow(aboutTab + aboutText_ = new mmHtmlWindow(aboutTab , wxID_ANY, wxDefaultPosition, wxDefaultSize , wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL); aboutSizer->Add(aboutText_, g_flagsExpand); - authorsText_ = new wxHtmlWindow(authorsTab + authorsText_ = new mmHtmlWindow(authorsTab , wxID_ANY, wxDefaultPosition, wxDefaultSize , wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL); authorsSizer->Add(authorsText_, g_flagsExpand); - sponsorsText_ = new wxHtmlWindow(sponsorsTab + sponsorsText_ = new mmHtmlWindow(sponsorsTab , wxID_ANY, wxDefaultPosition, wxDefaultSize , wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL); sponsorsSizer->Add(sponsorsText_, g_flagsExpand); - licenseText_ = new wxHtmlWindow(licenseTab + licenseText_ = new mmHtmlWindow(licenseTab , wxID_ANY, wxDefaultPosition, wxDefaultSize , wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL); licenseSizer->Add(licenseText_, g_flagsExpand); - privacyText_ = new wxHtmlWindow(privacyTab + privacyText_ = new mmHtmlWindow(privacyTab , wxID_ANY, wxDefaultPosition, wxDefaultSize , wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER | wxHSCROLL | wxVSCROLL); privacySizer->Add(privacyText_, g_flagsExpand); diff --git a/src/aboutdialog.h b/src/aboutdialog.h index fd1c3804e8..f481fc3e80 100644 --- a/src/aboutdialog.h +++ b/src/aboutdialog.h @@ -1,5 +1,6 @@ /******************************************************* Copyright (C) 2006 Madhan Kanagavel + Copyright (C) 2024 Mark Whalley (mark@ipx.co.uk) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +23,7 @@ #include #include #include "defs.h" +#include "util.h" class wxHtmlWindow; @@ -50,11 +52,11 @@ class mmAboutDialog : public wxDialog void handleLink(wxHtmlLinkEvent& event); wxCheckBox* m_send_data = nullptr; - wxHtmlWindow* aboutText_ = nullptr; - wxHtmlWindow* authorsText_ = nullptr; - wxHtmlWindow* sponsorsText_ = nullptr; - wxHtmlWindow* licenseText_ = nullptr; - wxHtmlWindow* privacyText_ = nullptr; + mmHtmlWindow* aboutText_ = nullptr; + mmHtmlWindow* authorsText_ = nullptr; + mmHtmlWindow* sponsorsText_ = nullptr; + mmHtmlWindow* licenseText_ = nullptr; + mmHtmlWindow* privacyText_ = nullptr; }; diff --git a/src/util.cpp b/src/util.cpp index 05e97e8d1b..e5c7fee525 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,7 +1,7 @@ /******************************************************* Copyright (C) 2006 Madhan Kanagavel Copyright (C) 2013-2022 Nikolay Akimov - Copyright (C) 2021-2022 Mark Whalley (mark@ipx.co.uk) + Copyright (C) 2021-2024 Mark Whalley (mark@ipx.co.uk) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1926,3 +1926,37 @@ bool isValidURI(const wxString validate) return false; } + +// +// mmHtmlWindow just adds a right click menu to save text to the system clipboard +// + +mmHtmlWindow::mmHtmlWindow( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size + , long style, const wxString &name) + : wxHtmlWindow(parent, id, pos, size, style, name) +{ + this->Bind(wxEVT_RIGHT_DOWN, &mmHtmlWindow::OnMouseRightClick, this); + this->Bind(wxEVT_MENU, &mmHtmlWindow::OnMenuSelected, this); +} + +void mmHtmlWindow::OnMouseRightClick(wxMouseEvent& event) +{ + wxMenu menu; + int id = wxID_LOWEST; + menu.Append(wxID_LOWEST + 1, _("Copy all text to clipboard")); + PopupMenu(&menu); + +} + +void mmHtmlWindow::OnMenuSelected(wxCommandEvent& event) +{ + int i = event.GetId() - wxID_LOWEST; + if (i == 1) // There is only one anyway + { + if (wxTheClipboard->Open()) + { + wxTheClipboard->SetData(new wxTextDataObject(this->ToText())); + wxTheClipboard->Close(); + } + } +} \ No newline at end of file diff --git a/src/util.h b/src/util.h index 6a9c6b12c7..67eb060bcf 100644 --- a/src/util.h +++ b/src/util.h @@ -1,7 +1,7 @@ /******************************************************* Copyright (C) 2006 Madhan Kanagavel Copyright (C) 2013-2022 Nikolay Akimov - Copyright (C) 2021 Mark Whalley (mark@ipx.co.uk) + Copyright (C) 2021,2024 Mark Whalley (mark@ipx.co.uk) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "defs.h" #include "reports/reportbase.h" +#include #include #include #include @@ -289,3 +290,17 @@ void mmSetSize(wxWindow* w); void mmFontSize(wxWindow* widget); bool isValidURI(const wxString validate); + +class mmHtmlWindow : public wxHtmlWindow +{ +public: + mmHtmlWindow (wxWindow *parent + , wxWindowID id=wxID_ANY + , const wxPoint &pos=wxDefaultPosition + , const wxSize &size=wxDefaultSize + , long style=wxHW_DEFAULT_STYLE + , const wxString &name="htmlWindow"); +private: + void OnMouseRightClick(wxMouseEvent& event); + void OnMenuSelected(wxCommandEvent& event); +};