Skip to content

Commit

Permalink
fix(moneymanagerex#6332): add copy to clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
whalley committed Nov 30, 2023
1 parent 6356895 commit ae6b876
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 13 deletions.
12 changes: 6 additions & 6 deletions 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
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 7 additions & 5 deletions 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
Expand All @@ -22,6 +23,7 @@
#include <wx/dialog.h>
#include <wx/notebook.h>
#include "defs.h"
#include "util.h"

class wxHtmlWindow;

Expand Down Expand Up @@ -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;

};

Expand Down
36 changes: 35 additions & 1 deletion 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
Expand Down Expand Up @@ -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();
}
}
}
17 changes: 16 additions & 1 deletion 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
Expand All @@ -22,6 +22,7 @@

#include "defs.h"
#include "reports/reportbase.h"
#include <wx/clipbrd.h>
#include <wx/valnum.h>
#include <map>
#include <curl/curl.h>
Expand Down Expand Up @@ -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);
};

0 comments on commit ae6b876

Please sign in to comment.