Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl Class Reference
Collaboration diagram for geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl:
Collaboration graph
[legend]

Public Member Functions

 TaskItemWidgetImpl (TaskItemWidget *pQ, const QString &taskItemId, const QString &taskItemDisplayName, const std::function< void(const QString &)> &openItemCb, const std::function< void(const QString &)> &removeItemCb)
 
 ~TaskItemWidgetImpl ()
 
void onContextMenuEvent (QContextMenuEvent *e)
 
void onMouseReleaseEvent (QMouseEvent *e)
 
void onKeyPressEvent (QKeyEvent *e)
 
void onLanguageChange ()
 

Private Member Functions

void populateUi ()
 
QImage setupThumbnail (const QString &, const RecentItem::Type type)
 

Private Attributes

TaskItemWidgetq
 
std::unique_ptr
< Ui::TaskItemWidget > 
ui
 
const QString m_taskItemId
 
const QString m_taskItemDisplayName
 
const std::function< void(const
QString &)> 
m_openItemCb
 
const std::function< void(const
QString &)> 
m_removeItemCb
 
QFutureWatcher< QImage > m_thumbnailLoaderWatcher
 

Constructor & Destructor Documentation

geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::TaskItemWidgetImpl ( TaskItemWidget pQ,
const QString &  taskItemId,
const QString &  taskItemDisplayName,
const std::function< void(const QString &)> &  openItemCb,
const std::function< void(const QString &)> &  removeItemCb 
)
inline
31  :
32  q{pQ}, ui{std::make_unique<Ui::TaskItemWidget>()}, m_taskItemId{taskItemId}, m_taskItemDisplayName{taskItemDisplayName}, m_openItemCb{openItemCb}, m_removeItemCb{removeItemCb}
33  {
34  ui->setupUi(q);
35 
36  ui->itemDisplayName->setText(m_taskItemDisplayName);
37 
38  ui->itemPath->setText(m_taskItemId);
39 
40  q->connect(&m_thumbnailLoaderWatcher, &QFutureWatcher<QImage>::finished, [this]() {
41  const QImage thumbnail{m_thumbnailLoaderWatcher.future().result()};
42  ui->thumbnailIcon->setPixmap(QPixmap::fromImage(thumbnail));
43  });
44 
45  const QString itemPath{m_taskItemId};
46  const RecentItem::Type type{RecentItem::getTypeForKey(itemPath)};
47 
48  QFuture<QImage> thumbnailFuture{QtConcurrent::run(this, &TaskItemWidgetImpl::setupThumbnail, itemPath, type)};
49  m_thumbnailLoaderWatcher.setFuture(thumbnailFuture);
50  }
TaskItemWidget * q
Definition: taskitemwidget.cpp:159
static RecentItem::Type getTypeForKey(const QString &key)
getTypeForKey Gets the recent item type for the given recent item key.
Definition: recentitem.cpp:14
QImage setupThumbnail(const QString &, const RecentItem::Type type)
Definition: taskitemwidget.cpp:123
QFutureWatcher< QImage > m_thumbnailLoaderWatcher
Definition: taskitemwidget.cpp:165
std::unique_ptr< Ui::TaskItemWidget > ui
Definition: taskitemwidget.cpp:160
const std::function< void(const QString &)> m_openItemCb
Definition: taskitemwidget.cpp:163
const QString m_taskItemId
Definition: taskitemwidget.cpp:161
const std::function< void(const QString &)> m_removeItemCb
Definition: taskitemwidget.cpp:164
Type
Definition: recentitem.h:16
const QString m_taskItemDisplayName
Definition: taskitemwidget.cpp:162
geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::~TaskItemWidgetImpl ( )
inline
53  {
54  }

Member Function Documentation

void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::onContextMenuEvent ( QContextMenuEvent *  e)
inline
57  {
58  QMenu itemContextMenu;
59 
60  QAction openAction(tr("Open", "Text on a menu item the user presses to open a file/image"));
61  itemContextMenu.addAction(&openAction);
62  connect(&openAction, &QAction::triggered, [this]() {
64  });
65 
66  QAction openInDefaultViewer(tr("Open in viewer", "Text on a menu item the user presses to open an image/piece of media in a viewer"));
67  itemContextMenu.addAction(&openInDefaultViewer);
68  connect(&openInDefaultViewer, &QAction::triggered, [this]() {
70  });
71 
72  QAction revealInDefaultExplorer(tr("Reveal in file explorer", "Text on a menu item the user presses to open an image/piece of media in a file viewer/explorer"));
73  itemContextMenu.addAction(&revealInDefaultExplorer);
74  connect(&revealInDefaultExplorer, &QAction::triggered, [this]() {
76  });
77 
78  QAction copyToClipboard(tr("Copy file path to clipboard", "Text on a menu item the user selects to copy a file path to the copy-paste clipboard"));
79  itemContextMenu.addAction(&copyToClipboard);
80  connect(&copyToClipboard, &QAction::triggered, [this]() {
82  });
83 
84  QAction removalAction(tr("Remove from list", "Text on a menu item the user presses to remove an item from a list of items"));
85  itemContextMenu.addAction(&removalAction);
86  connect(&removalAction, &QAction::triggered, [this]() {
88  });
89 
90  itemContextMenu.exec(e->globalPos());
91  }
bool openInDefaultApplication(const std::string &path)
openInDefaultApplication Opens the given path in the default application.
Definition: util.cpp:220
bool revealInDefaultApplication(const std::string &path)
revealInDefaultApplication Reveals the given path in the parent folder (or path with the filename tri...
Definition: util.cpp:225
const std::function< void(const QString &)> m_openItemCb
Definition: taskitemwidget.cpp:163
const QString m_taskItemId
Definition: taskitemwidget.cpp:161
const std::function< void(const QString &)> m_removeItemCb
Definition: taskitemwidget.cpp:164
void setGlobalClipboardText(const std::string &text)
setClipboardText Sets the global system clipboard text.
Definition: util.cpp:241

Here is the call graph for this function:

void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::onKeyPressEvent ( QKeyEvent *  e)
inline
103  {
104  if(e->key() != Qt::Key_Return && e->key() != Qt::Key_Enter) {
105  return;
106  }
107 
109  }
const std::function< void(const QString &)> m_openItemCb
Definition: taskitemwidget.cpp:163
const QString m_taskItemId
Definition: taskitemwidget.cpp:161
void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::onLanguageChange ( )
inline
112  {
113  ui->retranslateUi(q);
114  populateUi();
115  }
TaskItemWidget * q
Definition: taskitemwidget.cpp:159
std::unique_ptr< Ui::TaskItemWidget > ui
Definition: taskitemwidget.cpp:160
void populateUi()
Definition: taskitemwidget.cpp:118

Here is the call graph for this function:

void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::onMouseReleaseEvent ( QMouseEvent *  e)
inline
94  {
95  if(e->button() != Qt::LeftButton) {
96  return;
97  }
98 
100  }
const std::function< void(const QString &)> m_openItemCb
Definition: taskitemwidget.cpp:163
const QString m_taskItemId
Definition: taskitemwidget.cpp:161
void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::populateUi ( )
inlineprivate
119  {
120 
121  }

Here is the caller graph for this function:

QImage geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::setupThumbnail ( const QString &  ,
const RecentItem::Type  type 
)
inlineprivate
124  {
125  switch(type) {
127  {
128  const QImage thumbnail(":/icons/image.png");
129  if(!thumbnail.isNull()) {
130  return thumbnail;
131  }
132  break;
133  }
135  {
136  const QImage thumbnail(":/icons/script_go.png");
137  if(!thumbnail.isNull()) {
138  return thumbnail;
139  }
140  break;
141  }
143  {
144  const QImage thumbnail(":/icons/world_link.png");
145  if(!thumbnail.isNull()) {
146  return thumbnail;
147  }
148  break;
149  }
151  {
152  break;
153  }
154  }
155 
156  return QImage(":/icons/error.png");
157  }

Member Data Documentation

const std::function<void(const QString&)> geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::m_openItemCb
private
const std::function<void(const QString&)> geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::m_removeItemCb
private
const QString geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::m_taskItemDisplayName
private
const QString geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::m_taskItemId
private
QFutureWatcher<QImage> geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::m_thumbnailLoaderWatcher
private
TaskItemWidget* geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::q
private
std::unique_ptr<Ui::TaskItemWidget> geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::ui
private

The documentation for this class was generated from the following file: