-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/94 mail ui #95
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Created by Leonard Geier on 15.06.18. | ||
// | ||
|
||
#include <iostream> | ||
#include "mailDialog.hpp" | ||
|
||
MailDialog::MailDialog() | ||
: QDialog() | ||
, m_title("<font size=\"6\">Bitte gib deine E-Mail an:</font>") | ||
, m_buttonOk("OK") | ||
, m_buttonCancel("Cancel") | ||
, m_input() | ||
, m_layout() { | ||
|
||
QObject::connect(&m_buttonOk, &QPushButton::clicked, [=](){ | ||
emit enteredMail(this->m_input.text()); | ||
this->done(0); | ||
}); | ||
QObject::connect(&m_buttonOk, &QPushButton::clicked, [=](){ | ||
this->done(1); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To close the dialog, please add |
||
m_layout.addWidget(&m_title, 0, 0, 1, 10); | ||
m_layout.addWidget(&m_input, 1, 0, 1, 10); | ||
m_layout.addWidget(&m_buttonOk, 2, 0, 1, 1); | ||
m_layout.addWidget(&m_buttonCancel, 2, 1, 1, 1); | ||
this->setLayout(&m_layout); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Created by Leonard Geier on 15.06.18. | ||
// | ||
|
||
#ifndef SNAILSNAP_MAILDIALOG_H | ||
#define SNAILSNAP_MAILDIALOG_H | ||
|
||
|
||
#include <QDialog> | ||
#include <QPushButton> | ||
#include <QGridLayout> | ||
#include <QLabel> | ||
#include <QLineEdit> | ||
|
||
class MailDialog : public QDialog { | ||
|
||
Q_OBJECT | ||
|
||
public: | ||
MailDialog(); | ||
|
||
private: | ||
QLabel m_title; | ||
QLineEdit m_input; | ||
QPushButton m_buttonOk; | ||
QPushButton m_buttonCancel; | ||
|
||
QGridLayout m_layout; | ||
|
||
signals: | ||
void enteredMail(QString address); | ||
}; | ||
|
||
|
||
#endif //SNAILSNAP_MAILDIALOG_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ MainWindow::MainWindow(QWidget *parent, bool useCam, QString outputPath, | |
, m_maxNumOfMolluscs(maxNumOfMolluscs) | ||
, m_data(data) | ||
, m_mailClient(MailClient::fromCredentials("resources/credentials.txt")) | ||
, m_mailDialog() | ||
{ | ||
m_molluscPalette->loadData(data); | ||
|
||
|
@@ -70,6 +71,17 @@ MainWindow::MainWindow(QWidget *parent, bool useCam, QString outputPath, | |
this->showDia(); | ||
|
||
initializeSidebar(); | ||
|
||
QObject::connect(&m_mailDialog, &MailDialog::enteredMail, [=](QString text){ | ||
std::cout << "sdfsdf\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove |
||
if (!text.isEmpty()) { | ||
if (!text.contains("@") || !text.contains(".")) { | ||
//TODO: show user? | ||
return; | ||
} | ||
m_mailClient.sendImage(text, *m_result); | ||
} | ||
}); | ||
} | ||
|
||
MainWindow::~MainWindow() = default; | ||
|
@@ -302,18 +314,19 @@ void MainWindow::stopDia() | |
} | ||
|
||
void MainWindow::shareButtonClick() { | ||
bool ok; | ||
QString text = QInputDialog::getText(this, tr("Schneckenpost"), | ||
tr("Sende dir das Bild an deine Mailadresse:"), QLineEdit::Normal, | ||
"", &ok); | ||
std::string adr = text.toStdString(); | ||
if (ok && !text.isEmpty()) { | ||
if (!text.contains("@") || !text.contains(".")) { | ||
//TODO: show user? | ||
return; | ||
} | ||
m_mailClient.sendImage(text, *m_result); | ||
} | ||
// bool ok; | ||
m_mailDialog.exec(); | ||
// QString text = QInputDialog::getText(this, tr("Schneckenpost"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is that commented out and not removed? |
||
// tr("Sende dir das Bild an deine Mailadresse:"), QLineEdit::Normal, | ||
// "", &ok); | ||
// std::string adr = text.toStdString(); | ||
// if (ok && !text.isEmpty()) { | ||
// if (!text.contains("@") || !text.contains(".")) { | ||
// //TODO: show user? | ||
// return; | ||
// } | ||
// m_mailClient.sendImage(text, *m_result); | ||
// } | ||
} | ||
|
||
void MainWindow::sendMail() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For user experience: First close the mail window and then send the mail?
QObject::connect(&m_buttonOk, &QPushButton::clicked, [=](){ this->close(); emit enteredMail(this->m_input.text()); });