tahoma2d/toonz/sources/toonzfarm/tfarmclient/filebrowserpopup.h

58 lines
1.4 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef FILEBROWSERPOPUP_INCLUDED
#define FILEBROWSERPOPUP_INCLUDED
#include "tw/popup.h"
#include "tfilepath.h"
//-------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class TGenericFileBrowserPopupAction {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
virtual ~TGenericFileBrowserPopupAction() {}
virtual void sendCommand(const TFilePath &) = 0;
2016-03-19 06:57:51 +13:00
};
//-------------------------------------------------------------------
template <class T>
2016-06-15 18:43:10 +12:00
class TFileBrowserPopupAction : public TGenericFileBrowserPopupAction {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
typedef void (T::*Method)(const TFilePath &);
TFileBrowserPopupAction(T *target, Method method)
: m_target(target), m_method(method) {}
void sendCommand(const TFilePath &fp) { (m_target->*m_method)(fp); }
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
T *m_target;
Method m_method;
2016-03-19 06:57:51 +13:00
};
//------------------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class FileBrowserPopup : public TPopup {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FileBrowserPopup(TWidget *parent);
FileBrowserPopup(TWidget *parent, const vector<string> &fileTypes);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
~FileBrowserPopup();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void configureNotify(const TDimension &d);
TDimension getPreferredSize() const;
void draw();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setCurrentDir(const TFilePath &dirPath);
void setFilter(const vector<string> &fileTypes);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setOkAction(TGenericFileBrowserPopupAction *action);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void popup(const TPoint &p);
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
class Data;
Data *m_data;
2016-03-19 06:57:51 +13:00
};
#endif