added to check if attachments is ready for send Message

added for every new Message/Reply or Forward setWindowTitle beginning with always "Compose: " 

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2106 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-01-21 16:35:00 +00:00
parent daee15776c
commit 9df7ac473f
3 changed files with 54 additions and 6 deletions

View File

@ -121,7 +121,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
ui.printbutton->setIcon(QIcon(QString(":/images/print24.png")));
ui.forwardmessageButton->setToolTip(tr("Forward selected Message"));
ui.replyallmessageButton->setToolTip(tr("Replay to All"));
ui.replyallmessageButton->setToolTip(tr("Reply to All"));
QMenu * printmenu = new QMenu();
printmenu->addAction(ui.actionPrint);
@ -260,7 +260,7 @@ void MessagesDialog::replytomessage()
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
}
nMsgDialog->setWindowTitle(tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;
nMsgDialog->setWindowTitle( tr ("Compose: ") + tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;
QTextDocument doc ;
@ -305,7 +305,7 @@ void MessagesDialog::replyallmessage()
{
nMsgDialog->insertTitleText( (QString("Re: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
}
nMsgDialog->setWindowTitle(tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;
nMsgDialog->setWindowTitle( tr ("Compose: ") + tr("Re: ") + QString::fromStdWString(msgInfo.title) ) ;
QTextDocument doc ;
@ -361,7 +361,7 @@ void MessagesDialog::forwardmessage()
nMsgDialog->insertTitleText( (QString("Fwd: ") + QString::fromStdWString(msgInfo.title)).toStdString()) ;
}
nMsgDialog->setWindowTitle(tr("Fwd: ") + QString::fromStdWString(msgInfo.title) ) ;
nMsgDialog->setWindowTitle( tr ("Compose: ") + tr("Fwd: ") + QString::fromStdWString(msgInfo.title) ) ;
QTextDocument doc ;

View File

@ -32,7 +32,7 @@
#include "util/misc.h"
#include <sstream>
#include <QtGui>
#include <QContextMenuEvent>
#include <QCloseEvent>
#include <QColorDialog>
@ -59,7 +59,7 @@
/** Constructor */
ChanMsgDialog::ChanMsgDialog(bool msg, QWidget *parent, Qt::WFlags flags)
: mIsMsg(msg), QMainWindow(parent, flags)
: mIsMsg(msg), QMainWindow(parent, flags), mCheckAttachment(true)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -493,7 +493,11 @@ void ChanMsgDialog::insertFileList(const std::list<DirDetails>& files_info)
void ChanMsgDialog::newMsg()
{
/* clear all */
QString titlestring = ui.titleEdit->text();
setWindowTitle(tr("Compose: ") + titlestring );
ui.titleEdit->setText("No Title");
ui.msgText->setText("");
/* worker fns */
@ -1126,6 +1130,13 @@ void ChanMsgDialog::addAttachment(std::string filePath) {
} else {
QObject::connect(file,SIGNAL(fileFinished(AttachFileItem *)),this, SLOT(fileHashingFinished(AttachFileItem *))) ;
}
mAttachments.push_back(file);
if (mCheckAttachment)
{
checkAttachmentReady();
}
}
void ChanMsgDialog::fileHashingFinished(AttachFileItem* file) {
@ -1170,3 +1181,35 @@ void ChanMsgDialog::fileHashingFinished(AttachFileItem* file) {
}
void ChanMsgDialog::checkAttachmentReady()
{
std::list<AttachFileItem *>::iterator fit;
mCheckAttachment = false;
for(fit = mAttachments.begin(); fit != mAttachments.end(); fit++)
{
if (!(*fit)->isHidden())
{
if (!(*fit)->ready())
{
/*
*/
ui.actionSend->setEnabled(false);
break;
return;
}
}
}
if (fit == mAttachments.end())
{
ui.actionSend->setEnabled(true);
}
/* repeat... */
int msec_rate = 1000;
QTimer::singleShot( msec_rate, this, SLOT(checkAttachmentReady(void)));
}

View File

@ -117,6 +117,7 @@ private slots:
void attachFile();
void addAttachment(std::string);
void checkAttachmentReady();
private:
@ -162,8 +163,12 @@ private:
QHash<QString, QString> autoLinkDictionary;
QHash<QString, QString> autoLinkTitleDictionary;
QHash<QString, int> autoLinkTargetDictionary;
/* maps of files */
std::list<AttachFileItem *> mAttachments;
bool mIsMsg; /* different behaviour for Msg or ChanMsg */
bool mCheckAttachment;
/** Qt Designer generated object */
Ui::ChanMsgDialog ui;