Skip to content

Commit

Permalink
Add hotkeys for CHistoryTreeControl context menu items
Browse files Browse the repository at this point in the history
Delete closed file.coffee hosting
  • Loading branch information
zenden2k committed Jun 21, 2024
1 parent 644e91a commit 66d746e
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 48 deletions.
Binary file removed Data/Favicons/file.coffee.ico
Binary file not shown.
22 changes: 0 additions & 22 deletions Data/Scripts/file.coffee.nut

This file was deleted.

5 changes: 0 additions & 5 deletions Data/servers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,6 @@
</Actions>
<Result DownloadUrlTemplate="stub" />
</Server3>
<Server Name="file.coffee" Authorize="0" FileHost="1" Plugin="file.coffee">
<Actions>
</Actions>
<Result ImageUrlTemplate="stub" />
</Server>
<Server Name="upload.ee" Authorize="0" FileHost="1" Plugin="upload.ee" MaxFileSize="104857600" WebsiteUrl="https://www.upload.ee"
RegistrationUrl="https://www.upload.ee/register.html">
<Actions>
Expand Down
8 changes: 8 additions & 0 deletions Source/Gui/Controls/HistoryTreeControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,14 @@ LRESULT CHistoryTreeControl::OnDblClick(UINT uMsg, WPARAM wParam, LPARAM lParam,
return CCustomTreeControlImpl<CHistoryTreeControl>::OnDblClick(uMsg, wParam, lParam, bHandled);
}

LRESULT CHistoryTreeControl::OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if (wParam != VK_TAB && wParam != VK_ESCAPE) {
return DLGC_WANTALLKEYS;
}
return 0;
}

HBITMAP CHistoryTreeControl::GetItemThumbnail(HistoryTreeItem* item)
{
if(item->thumbnail!=0)
Expand Down
6 changes: 4 additions & 2 deletions Source/Gui/Controls/HistoryTreeControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ class CHistoryTreeControl :
public:
CHistoryTreeControl(std::shared_ptr<INetworkClientFactory> factory);
~CHistoryTreeControl();
DECLARE_WND_SUPERCLASS(_T("CHistoryTreeControl"), CListViewCtrl::GetWndClassName())
//DECLARE_WND_SUPERCLASS(_T("CHistoryTreeControl"), CListBox/**/CListViewCtrl*/::GetWndClassName())

BEGIN_MSG_MAP(CHistoryTreeControl)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_GETDLGCODE, OnGetDlgCode)
CHAIN_MSG_MAP(CCustomTreeControlImpl<CHistoryTreeControl>)
END_MSG_MAP()

Expand All @@ -65,7 +66,8 @@ class CHistoryTreeControl :
DWORD OnSubItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW /*lpNMCustomDraw*/);
bool LoadThumbnail(HistoryTreeItem* ItemID);
LRESULT OnDblClick(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) override;

LRESULT OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnGetDlgCode(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
void setDownloadingEnabled(bool enabled);
bool m_bIsRunning;
bool downloading_enabled_;
Expand Down
66 changes: 48 additions & 18 deletions Source/Gui/Dialogs/HistoryWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,35 +151,47 @@ void CHistoryWindow::Show()
LRESULT CHistoryWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
HWND hwnd = reinterpret_cast<HWND>(wParam);
POINT ClientPoint, ScreenPoint;
POINT clientPoint, screenPoint;

if(hwnd != GetDlgItem(IDC_HISTORYTREE)) return 0;

TreeItem* item = m_treeView.selectedItem();
if (!item) return 0;

TreeItem* item{};
int itemIndex = -1;
if(lParam == -1)
{
ClientPoint.x = 0;
ClientPoint.y = 0;
int itemIndex = m_treeView.GetCurSel();
clientPoint.x = 0;
clientPoint.y = 0;
itemIndex = m_treeView.GetCurSel();
if (itemIndex >= 0) {
CRect rc;
if (m_treeView.GetItemRect(itemIndex, &rc) != LB_ERR) {
ClientPoint = rc.CenterPoint();
clientPoint = rc.CenterPoint();
}
}

ScreenPoint = ClientPoint;
::ClientToScreen(hwnd, &ScreenPoint);
screenPoint = clientPoint;
::ClientToScreen(hwnd, &screenPoint);
item = m_treeView.selectedItem();
}
else
{
ScreenPoint.x = GET_X_LPARAM(lParam);
ScreenPoint.y = GET_Y_LPARAM(lParam);
ClientPoint = ScreenPoint;
::ScreenToClient(hwnd, &ClientPoint);
screenPoint.x = GET_X_LPARAM(lParam);
screenPoint.y = GET_Y_LPARAM(lParam);

clientPoint = screenPoint;
::ScreenToClient(hwnd, &clientPoint);
BOOL outside = FALSE;
itemIndex = m_treeView.ItemFromPoint(clientPoint, outside);
if (outside) {
return 0;
}

item = m_treeView.GetItem(itemIndex);
}

if (!item) {
return 0;
}

bool isSessionItem = item->level()==0;

HistoryItem* historyItem = CHistoryTreeControl::getItemData(item);
Expand All @@ -189,7 +201,7 @@ LRESULT CHistoryWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, B
{
menu.AppendMenu(MF_STRING, ID_OPENINBROWSER, TR("Open in Web Browser"));
menu.SetMenuDefaultItem(ID_OPENINBROWSER, FALSE);
menu.AppendMenu(MF_STRING, ID_COPYTOCLIPBOARD, TR("Copy URL"));
menu.AppendMenu(MF_STRING, ID_COPYTOCLIPBOARD, TR("Copy URL") + CString(_T("\tCtrl+C")));
}
menu.AppendMenu(MF_STRING, ID_VIEWBBCODE, TR("View BBCode/HTML codes"));
if(!isSessionItem)
Expand All @@ -205,11 +217,11 @@ LRESULT CHistoryWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, B
}
if (!historyItem->deleteUrl.empty())
{
menu.AppendMenu(MF_STRING, ID_DELETEFILEONSERVER, TR("Delete file from server"));
menu.AppendMenu(MF_STRING, ID_DELETEFILEONSERVER, TR("Delete file from server")+CString(_T("\tDelete")));
}
}

menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON, ScreenPoint.x, ScreenPoint.y, m_hWnd);
menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON, screenPoint.x, screenPoint.y, m_hWnd);
return 0;
}

Expand Down Expand Up @@ -500,6 +512,24 @@ LRESULT CHistoryWindow::OnClearFilters(WORD wNotifyCode, WORD wID, HWND hWndCtl,
return 0;
}

LRESULT CHistoryWindow::OnHistoryTreeVkeyToItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x80) != 0;
bool isShiftPressed = (GetKeyState(VK_SHIFT) & 0x80) != 0;
bool isMenuPressed = (GetKeyState(VK_MENU) & 0x80) != 0;
WORD vKey = LOWORD(wParam);
if (vKey == VK_DELETE && !isCtrlPressed && !isShiftPressed && !isMenuPressed) {
SendMessage(WM_COMMAND, MAKEWPARAM(ID_DELETEFILEONSERVER, BN_CLICKED), reinterpret_cast<LPARAM>(m_hWnd));
}
else if (vKey == _T('C') && isCtrlPressed && !isShiftPressed && !isMenuPressed) {
SendMessage(WM_COMMAND, MAKEWPARAM(ID_COPYTOCLIPBOARD, BN_CLICKED), reinterpret_cast<LPARAM>(m_hWnd));
}
else if (vKey == VK_RETURN && !isCtrlPressed && !isShiftPressed && !isMenuPressed) {
SendMessage(WM_COMMAND, MAKEWPARAM(ID_OPENINBROWSER, BN_CLICKED), reinterpret_cast<LPARAM>(m_hWnd));
}
return -1;
}

void CHistoryWindow::initSearchForm() {
using namespace boost::gregorian;
date today = day_clock::local_day();
Expand Down
4 changes: 4 additions & 0 deletions Source/Gui/Dialogs/HistoryWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ constexpr int ID_EDITFILEONSERVER = ID_OPENINBROWSER + 4;
constexpr int ID_DELETEFILEONSERVER = ID_OPENINBROWSER + 5;
constexpr int WM_MY_OPENHISTORYFILE = WM_USER + 101;


class CHistoryWindow : public CCustomDialogIndirectImpl<CHistoryWindow>,
public CDialogResize <CHistoryWindow>,
public CWinDataExchange <CHistoryWindow>,
Expand All @@ -57,6 +58,7 @@ class CHistoryWindow : public CCustomDialogIndirectImpl<CHistoryWindow>,
COMMAND_HANDLER(IDCANCEL, BN_CLICKED, OnClickedCancel)
MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
MESSAGE_HANDLER(WM_MY_OPENHISTORYFILE, OnWmOpenHistoryFile)
MESSAGE_HANDLER(WM_VKEYTOITEM, OnHistoryTreeVkeyToItem)
COMMAND_ID_HANDLER(IDOK, OnOk)
COMMAND_ID_HANDLER(ID_OPENINBROWSER, OnOpenInBrowser)
COMMAND_ID_HANDLER(ID_COPYTOCLIPBOARD, OnCopyToClipboard)
Expand Down Expand Up @@ -107,6 +109,8 @@ class CHistoryWindow : public CCustomDialogIndirectImpl<CHistoryWindow>,
LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnDateFromCheckboxClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnClearFilters(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnHistoryTreeVkeyToItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

void Show();
void FillList(CHistoryReader* mgr);
CHistoryTreeControl m_treeView;
Expand Down
2 changes: 1 addition & 1 deletion Source/Image Uploader.rc
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "#",IDC_ANIMATIONSTATIC,379,3,23,17
CONTROL "Check1",IDC_DOWNLOADTHUMBS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,9,151,10
LISTBOX IDC_HISTORYTREE,4,26,398,224,LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LISTBOX IDC_HISTORYTREE,4,26,398,224,LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT | LBS_WANTKEYBOARDINPUT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "#Filters",IDC_FILTERSGROUPBOX,4,253,398,63,0,WS_EX_TRANSPARENT
CONTROL "#Date from:",IDC_DATEFROMCHECKBOX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,264,81,10
CONTROL "",IDC_DATEFROMPICKER,"SysDateTimePick32",DTS_RIGHTALIGN | WS_TABSTOP,97,261,100,15
Expand Down

0 comments on commit 66d746e

Please sign in to comment.