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, itemPath, type]() {
49  return setupThumbnail(itemPath, type);
50  });
51  m_thumbnailLoaderWatcher.setFuture(thumbnailFuture);
52  }
TaskItemWidget * q
Definition: taskitemwidget.cpp:161
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:125
QFutureWatcher< QImage > m_thumbnailLoaderWatcher
Definition: taskitemwidget.cpp:167
std::unique_ptr< Ui::TaskItemWidget > ui
Definition: taskitemwidget.cpp:162
const std::function< void(const QString &)> m_openItemCb
Definition: taskitemwidget.cpp:165
const QString m_taskItemId
Definition: taskitemwidget.cpp:163
const std::function< void(const QString &)> m_removeItemCb
Definition: taskitemwidget.cpp:166
Type
Definition: recentitem.h:16
const QString m_taskItemDisplayName
Definition: taskitemwidget.cpp:164
geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::~TaskItemWidgetImpl ( )
inline
55  {
56  }

Member Function Documentation

void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::onContextMenuEvent ( QContextMenuEvent *  e)
inline
59  {
60  QMenu itemContextMenu;
61 
62  QAction openAction(tr("Open", "Text on a menu item the user presses to open a file/image"));
63  itemContextMenu.addAction(&openAction);
64  connect(&openAction, &QAction::triggered, [this]() {
66  });
67 
68  QAction openInDefaultViewer(tr("Open in viewer", "Text on a menu item the user presses to open an image/piece of media in a viewer"));
69  itemContextMenu.addAction(&openInDefaultViewer);
70  connect(&openInDefaultViewer, &QAction::triggered, [this]() {
72  });
73 
74  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"));
75  itemContextMenu.addAction(&revealInDefaultExplorer);
76  connect(&revealInDefaultExplorer, &QAction::triggered, [this]() {
78  });
79 
80  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"));
81  itemContextMenu.addAction(&copyToClipboard);
82  connect(&copyToClipboard, &QAction::triggered, [this]() {
84  });
85 
86  QAction removalAction(tr("Remove from list", "Text on a menu item the user presses to remove an item from a list of items"));
87  itemContextMenu.addAction(&removalAction);
88  connect(&removalAction, &QAction::triggered, [this]() {
90  });
91 
92  itemContextMenu.exec(e->globalPos());
93  }
bool openInDefaultApplication(const std::string &path)
openInDefaultApplication Opens the given path in the default application.
Definition: util.cpp:219
bool revealInDefaultApplication(const std::string &path)
revealInDefaultApplication Reveals the given path in the parent folder (or path with the filename tri...
Definition: util.cpp:224
const std::function< void(const QString &)> m_openItemCb
Definition: taskitemwidget.cpp:165
const QString m_taskItemId
Definition: taskitemwidget.cpp:163
const std::function< void(const QString &)> m_removeItemCb
Definition: taskitemwidget.cpp:166
void setGlobalClipboardText(const std::string &text)
setClipboardText Sets the global system clipboard text.
Definition: util.cpp:240

Here is the call graph for this function:

void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::onKeyPressEvent ( QKeyEvent *  e)
inline
105  {
106  if(e->key() != Qt::Key_Return && e->key() != Qt::Key_Enter) {
107  return;
108  }
109 
111  }
const std::function< void(const QString &)> m_openItemCb
Definition: taskitemwidget.cpp:165
const QString m_taskItemId
Definition: taskitemwidget.cpp:163
void geometrize::dialog::TaskItemWidget::TaskItemWidgetImpl::onLanguageChange ( )
inline
114  {
115  ui->retranslateUi(q);
116  populateUi();
117  }
TaskItemWidget * q
Definition: taskitemwidget.cpp:161
std::unique_ptr< Ui::TaskItemWidget > ui
Definition: taskitemwidget.cpp:162
void populateUi()
Definition: taskitemwidget.cpp:120

Here is the call graph for this function:

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

Here is the caller graph for this function:

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

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: