Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ set(sources
${source_dir}/helpers/painter.cpp
${source_dir}/helpers/boundingbox.cpp
${source_dir}/helpers/positionGenerator.cpp
${source_dir}/sidebar.cpp)
${source_dir}/sidebar.cpp
${source_dir}/mailDialog.cpp)

set(headers
${source_dir}/mosaic.hpp
Expand All @@ -81,7 +82,8 @@ set(headers
${source_dir}/helpers/painter.hpp
${source_dir}/helpers/boundingbox.hpp
${source_dir}/helpers/positionGenerator.hpp
${source_dir}/sidebar.hpp)
${source_dir}/sidebar.hpp
${source_dir}/mailDialog.hpp)

# target and required libs

Expand Down
28 changes: 28 additions & 0 deletions src/mailDialog.cpp
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());
Copy link
Contributor

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()); });

this->done(0);
});
QObject::connect(&m_buttonOk, &QPushButton::clicked, [=](){
this->done(1);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To close the dialog, please add
QObject::connect(&m_buttonCancel, &QPushButton::clicked, this, [=]() { this->close(); });

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);
}
35 changes: 35 additions & 0 deletions src/mailDialog.hpp
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
37 changes: 25 additions & 12 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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";
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
Expand Down Expand Up @@ -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"),
Copy link
Contributor

Choose a reason for hiding this comment

The 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()
Expand Down
3 changes: 3 additions & 0 deletions src/mainwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "helpers/painter.hpp"
#include "algorithms/voronoi.hpp"
#include "mailDialog.hpp"

class MainWindow : public QMainWindow {
Q_OBJECT
Expand Down Expand Up @@ -93,6 +94,8 @@ class MainWindow : public QMainWindow {
void processAndShowPicture(std::shared_ptr<QImage> image);
void initializeSidebar();

MailDialog m_mailDialog;

public slots:
void shareButtonClick();
void showDia();
Expand Down