mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-13 11:32:48 -04:00
Added functionality to save a Privat Chat session and GroupChat History via ToolButton
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2807 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3b1d1d35fe
commit
c91bc09c74
6 changed files with 101 additions and 8 deletions
|
@ -156,6 +156,7 @@ PeersDialog::PeersDialog(QWidget *parent)
|
|||
connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
|
||||
connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(getFont()));
|
||||
connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(setColor()));
|
||||
connect(ui.actionSave_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
|
||||
|
||||
ui.fontsButton->setIcon(QIcon(QString(":/images/fonts.png")));
|
||||
|
||||
|
@ -179,6 +180,7 @@ PeersDialog::PeersDialog(QWidget *parent)
|
|||
|
||||
QMenu * grpchatmenu = new QMenu();
|
||||
grpchatmenu->addAction(ui.actionClearChat);
|
||||
grpchatmenu->addAction(ui.actionSave_History);
|
||||
grpchatmenu->addAction(ui.actionDisable_Emoticons);
|
||||
ui.menuButton->setMenu(grpchatmenu);
|
||||
|
||||
|
@ -1789,3 +1791,36 @@ void PeersDialog::dragEnterEvent(QDragEnterEvent *event)
|
|||
std::cerr << "PeersDialog::dragEnterEvent() No Urls" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
bool PeersDialog::fileSave()
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return fileSaveAs();
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
return false;
|
||||
QTextStream ts(&file);
|
||||
ts.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
ts << ui.msgText->document()->toPlainText();
|
||||
ui.msgText->document()->setModified(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PeersDialog::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("Text File (*.txt );;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
void PeersDialog::setCurrentFileName(const QString &fileName)
|
||||
{
|
||||
this->fileName = fileName;
|
||||
ui.msgText->document()->setModified(false);
|
||||
|
||||
setWindowModified(false);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue