00001 #include "bugreportdialog.h" 00002 #include "../Data/datadefinitions.h" 00003 #include <QFile> 00004 #include <QFileDialog> 00005 #include <QMessageBox> 00006 #include <QTextEdit> 00007 #include "../Data/project.h" 00008 #include "../Data/settings.h" 00009 00010 BugReportDialog::BugReportDialog(Settings &settings, MailerThread *m, QWidget *parent) : QDialog(parent), mailerThread(m) 00011 { 00012 setupUi(this); 00013 setAttribute(Qt::WA_DeleteOnClose, true); 00014 00015 this->settings = &settings; 00016 00017 labelProgramVersion->setText(QCoreApplication::organizationName() + " " + QCoreApplication::applicationName() + " " + QCoreApplication::applicationVersion()); 00018 labelOperatingSystem->setText(OperatingSystems().os()); 00019 00020 createActions(); 00021 } 00022 00023 void BugReportDialog::createActions() 00024 { 00025 connect(buttonChooseAttachment, SIGNAL(clicked()), this, SLOT(chooseAttachment())); 00026 connect(buttonOk, SIGNAL(clicked()), this, SLOT(sendMail())); 00027 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(close())); 00028 } 00029 00030 void BugReportDialog::chooseAttachment() 00031 { 00032 QFileDialog dialog(this); 00033 textAttachment->setText(dialog.getOpenFileName(this, tr("Anhang auswählen"), settings->workspace().absolutePath())); 00034 } 00035 00036 void BugReportDialog::sendMail() 00037 { 00038 QString subject = textShortDescription->text(); 00039 QString message = QCoreApplication::organizationName() + " " + QCoreApplication::applicationName() + " " + QCoreApplication::organizationDomain() + " - Doppelte Buchhaltung - " + QCoreApplication::applicationVersion(); 00040 message += "\r\n" + OperatingSystems().os() + "\r\n\r\n"; 00041 message += textShortDescription->text() + "\r\n\r\n"; 00042 message += textDetailedDescription->toPlainText(); 00043 QString attachment = textAttachment->text(); 00044 00045 if(!QFile(attachment).exists() && attachment != "") 00046 { 00047 QMessageBox::critical(this, "Datei existiert nicht", "Die ausgewählte Datei scheint nicht zu existieren!"); 00048 return; 00049 } 00050 if(subject != "" && message != "") 00051 { 00052 mailerThread->setSubject("[Allevo II bugreport] [" + comboBoxReportType->currentText() + "] " + subject); 00053 mailerThread->setMessage(message); 00054 mailerThread->setAttachement(attachment); 00055 if(Project::ownerEmail() != "") 00056 { 00057 mailerThread->setCc(Project::ownerEmail()); 00058 } 00059 00060 mailerThread->start(); 00061 } 00062 else 00063 { 00064 QMessageBox::critical(this, "Mussfelder ausfüllen", "Um Ihren Beitrag zur Verbesserung von Allevo leisten zu können müssen alle Felder ausgefüllt sein (Kurzbeschreibung und Detailbeschreibung)"); 00065 return; 00066 } 00067 done(0); 00068 }