mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35: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
@ -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);
|
||||
}
|
@ -139,6 +139,10 @@ private slots:
|
||||
void anchorClicked (const QUrl &);
|
||||
void addAttachment(std::string);
|
||||
|
||||
bool fileSave();
|
||||
bool fileSaveAs();
|
||||
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
|
||||
signals:
|
||||
void friendsUpdated() ;
|
||||
@ -151,6 +155,8 @@ private:
|
||||
class QWidgetAction *widgetAction;
|
||||
class QSpacerItem *spacerItem;
|
||||
|
||||
QString fileName;
|
||||
|
||||
/* Worker Functions */
|
||||
/* (1) Update Display */
|
||||
|
||||
|
@ -1418,6 +1418,14 @@ p, li { white-space: pre-wrap; }
|
||||
<string>Disable Emoticons</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_History">
|
||||
<property name="text">
|
||||
<string>Save Chat History</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Chat History</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
|
@ -96,6 +96,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
|
||||
connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
|
||||
connect(ui.styleButton, SIGNAL(clicked()), SLOT(changeStyle()));
|
||||
connect(ui.actionSave_Chat_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
|
||||
|
||||
connect(ui.textBrowser, SIGNAL(anchorClicked(const QUrl &)), SLOT(anchorClicked(const QUrl &)));
|
||||
|
||||
@ -133,6 +134,7 @@ PopupChatDialog::PopupChatDialog(std::string id, std::string name,
|
||||
|
||||
QMenu * toolmenu = new QMenu();
|
||||
toolmenu->addAction(ui.actionClear_Chat);
|
||||
toolmenu->addAction(ui.actionSave_Chat_History);
|
||||
toolmenu->addAction(ui.action_Disable_Emoticons);
|
||||
ui.pushtoolsButton->setMenu(toolmenu);
|
||||
|
||||
@ -978,4 +980,35 @@ void PopupChatDialog::dragEnterEvent(QDragEnterEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
bool PopupChatDialog::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.textBrowser->document()->toPlainText();
|
||||
ui.textBrowser->document()->setModified(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PopupChatDialog::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 PopupChatDialog::setCurrentFileName(const QString &fileName)
|
||||
{
|
||||
this->fileName = fileName;
|
||||
ui.textBrowser->document()->setModified(false);
|
||||
|
||||
setWindowModified(false);
|
||||
}
|
||||
|
@ -61,8 +61,6 @@ public:
|
||||
void updateAvatar();
|
||||
|
||||
QString loadEmptyStyle();
|
||||
|
||||
|
||||
QPixmap picture;
|
||||
|
||||
|
||||
@ -108,6 +106,10 @@ private slots:
|
||||
|
||||
void on_actionClear_Chat_triggered();
|
||||
|
||||
bool fileSave();
|
||||
bool fileSaveAs();
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -132,6 +134,7 @@ private:
|
||||
QString emptyStyle;
|
||||
QStringList history;
|
||||
QString wholeChat;
|
||||
QString fileName;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::PopupChatDialog ui;
|
||||
|
@ -639,6 +639,14 @@ border: 1px solid #CCCCCC;
|
||||
<string>Disable Emoticons</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_Chat_History">
|
||||
<property name="text">
|
||||
<string>Save Chat History</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Chat History</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
|
Loading…
Reference in New Issue
Block a user