summaryrefslogtreecommitdiffstats
path: root/src/qpushbuttonwithclipboard.cpp
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2016-12-13 00:05:58 +0100
committerAnne Jan Brouwer <brouwer@annejan.com>2016-12-13 00:05:58 +0100
commit109958c1a14bbfab79bb30e72f2a706bcada4c60 (patch)
tree26de8388b1587c962a039c42efc93361a70f09c8 /src/qpushbuttonwithclipboard.cpp
parent641598e971bda056aea618bb67c8ab88e7b9da26 (diff)
Moved sources to src
Diffstat (limited to 'src/qpushbuttonwithclipboard.cpp')
-rw-r--r--src/qpushbuttonwithclipboard.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/qpushbuttonwithclipboard.cpp b/src/qpushbuttonwithclipboard.cpp
new file mode 100644
index 00000000..c440bcd0
--- /dev/null
+++ b/src/qpushbuttonwithclipboard.cpp
@@ -0,0 +1,54 @@
+#include "qpushbuttonwithclipboard.h"
+#include <QTimer>
+
+/**
+ * @brief QPushButtonWithClipboard::QPushButtonWithClipboard
+ * basic constructor
+ * @param textToCopy
+ * the text to paste into the clipboard
+ * @param text
+ * the text for the label to display
+ * @param parent
+ * the parent window
+ */
+QPushButtonWithClipboard::QPushButtonWithClipboard(const QString &textToCopy,
+ QWidget *parent)
+ : QPushButton(parent), textToCopy(textToCopy),
+ iconEdit(QIcon::fromTheme("edit-copy", QIcon(":/icons/edit-copy.svg"))),
+ iconEditPushed(
+ QIcon::fromTheme("document-new", QIcon(":/icons/document-new.svg"))) {
+ setIcon(iconEdit);
+ connect(this, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));
+}
+
+/**
+ * @brief QPushButtonWithClipboard::getTextToCopy returns the text of
+ * associated text field
+ * @return QString textToCopy
+ */
+QString QPushButtonWithClipboard::getTextToCopy() const { return textToCopy; }
+
+/**
+ * @brief QPushButtonWithClipboard::setTextToCopy sets text from associated
+ * text field
+ * @param QString value
+ */
+void QPushButtonWithClipboard::setTextToCopy(const QString &value) {
+ textToCopy = value;
+}
+
+/**
+ * @brief QPushButtonWithClipboard::buttonClicked handles clicked event by
+ * emitting clicked(QString) with string provided to constructor
+ */
+void QPushButtonWithClipboard::buttonClicked(bool) {
+ setIcon(iconEditPushed);
+ QTimer::singleShot(500, this, SLOT(changeIconDefault()));
+ emit clicked(textToCopy);
+}
+
+/**
+ * @brief QPushButtonWithClipboard::changeIconDefault change the icon back to
+ * the default copy icon
+ */
+void QPushButtonWithClipboard::changeIconDefault() { this->setIcon(iconEdit); }