diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-09 08:52:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-09 08:52:03 -0500 |
| commit | 1f1f99f253f981ae3d11e9df177a144d00dbce0e (patch) | |
| tree | 01d38125329508f5628f9221f797e303180c8fc3 /src/envshell.h | |
| parent | 718c2a56f91f824c5eab69d8cc16294f77243370 (diff) | |
| parent | 3a80685189967fbf4cfa002ac2b8a4fa421306ca (diff) | |
Merge pull request #994 from isanae/generic-file-list
New file tree
Diffstat (limited to 'src/envshell.h')
| -rw-r--r-- | src/envshell.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/envshell.h b/src/envshell.h new file mode 100644 index 00000000..f9245a37 --- /dev/null +++ b/src/envshell.h @@ -0,0 +1,86 @@ +#ifndef ENV_SHELL_H +#define ENV_SHELL_H + +#include "env.h" +#include <QFileInfo> +#include <QPoint> + +namespace env +{ + +class ShellMenu +{ +public: + ShellMenu(QMainWindow* mw); + + // noncopyable + ShellMenu(const ShellMenu&) = delete; + ShellMenu& operator=(const ShellMenu&) = delete; + ShellMenu(ShellMenu&&) = default; + ShellMenu& operator=(ShellMenu&&) = default; + + void addFile(QFileInfo fi); + int fileCount() const; + + void exec(const QPoint& pos); + HMENU getMenu(); + bool wndProc(HWND hwnd, UINT m, WPARAM wp, LPARAM lp, LRESULT* out); + void invoke(const QPoint& p, int cmd); + +private: + QMainWindow* m_mw; + std::vector<QFileInfo> m_files; + COMPtr<IContextMenu> m_cm; + COMPtr<IContextMenu2> m_cm2; + COMPtr<IContextMenu3> m_cm3; + HMenuPtr m_menu; + + void create(); + + std::vector<LPCITEMIDLIST> createIdls(const std::vector<QFileInfo>& files); + COMPtr<IShellItemArray> createItemArray(std::vector<LPCITEMIDLIST>& idls); + + void createContextMenu(IShellItemArray* array); + void createPopupMenu(IContextMenu* cm); + + COMPtr<IShellItem> createShellItem(const std::wstring& path); + COMPtr<IPersistIDList> getPersistIDList(IShellItem* item); + CoTaskMemPtr<LPITEMIDLIST> getIDList(IPersistIDList* pidlist); + HMenuPtr createDummyMenu(const QString& what); + + void onMenuSelect( + HWND hwnd, HMENU hmenu, int item, HMENU hmenuPopup, UINT flags); +}; + + +class ShellMenuCollection +{ +public: + ShellMenuCollection(QMainWindow* mw); + + void addDetails(QString s); + void add(QString name, ShellMenu m); + + void exec(const QPoint& pos); + +private: + struct MenuInfo + { + QString name; + ShellMenu menu; + }; + + QMainWindow* m_mw; + std::vector<QString> m_details; + std::vector<MenuInfo> m_menus; + MenuInfo* m_active; + + bool wndProc(HWND hwnd, UINT m, WPARAM wp, LPARAM lp, LRESULT* out); + + void onMenuSelect( + HWND hwnd, HMENU hmenu, int item, HMENU hmenuPopup, UINT flags); +}; + +} // namespace + +#endif // ENV_SHELL_H |
