mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 07:05:26 -04:00
Added standard context menu to the input text in private chat, group chat and create forum message.
Added paste RetroShare link to the context menu of the text edit and file list in message composer. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3846 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
20c97680b5
commit
064b619f70
15 changed files with 260 additions and 349 deletions
|
@ -151,12 +151,15 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WFlags flags)
|
|||
|
||||
connect(ui.msgText, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &)));
|
||||
connect(ui.msgText, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()));
|
||||
connect(ui.msgText,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));
|
||||
|
||||
connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), actionSave, SLOT(setEnabled(bool)));
|
||||
connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));
|
||||
connect(ui.msgText->document(), SIGNAL(undoAvailable(bool)), actionUndo, SLOT(setEnabled(bool)));
|
||||
connect(ui.msgText->document(), SIGNAL(redoAvailable(bool)), actionRedo, SLOT(setEnabled(bool)));
|
||||
|
||||
connect(ui.msgFileList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuFileList(QPoint)));
|
||||
|
||||
setWindowModified(ui.msgText->document()->isModified());
|
||||
actionSave->setEnabled(ui.msgText->document()->isModified());
|
||||
actionUndo->setEnabled(ui.msgText->document()->isUndoAvailable());
|
||||
|
@ -448,6 +451,50 @@ void MessageComposer::closeEvent (QCloseEvent * event)
|
|||
}
|
||||
}
|
||||
|
||||
void MessageComposer::contextMenu(QPoint)
|
||||
{
|
||||
QMenu *contextMnu = ui.msgText->createStandardContextMenu();
|
||||
|
||||
contextMnu->addSeparator();
|
||||
QAction *action = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
|
||||
action->setDisabled(RSLinkClipboard::empty());
|
||||
|
||||
contextMnu->exec(QCursor::pos());
|
||||
delete(contextMnu);
|
||||
}
|
||||
|
||||
void MessageComposer::pasteLink()
|
||||
{
|
||||
ui.msgText->insertHtml(RSLinkClipboard::toHtml()) ;
|
||||
}
|
||||
|
||||
void MessageComposer::contextMenuFileList(QPoint)
|
||||
{
|
||||
QMenu contextMnu(this);
|
||||
|
||||
QAction *action = contextMnu.addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteRecommended()));
|
||||
action->setDisabled(RSLinkClipboard::empty(RetroShareLink::TYPE_FILE));
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void MessageComposer::pasteRecommended()
|
||||
{
|
||||
std::vector<RetroShareLink> links;
|
||||
RSLinkClipboard::pasteLinks(links);
|
||||
|
||||
for (uint32_t i = 0; i < links.size(); i++) {
|
||||
if (links[i].valid() && links[i].type() == RetroShareLink::TYPE_FILE) {
|
||||
FileInfo fileInfo;
|
||||
fileInfo.fname = links[i].name().toStdString();
|
||||
fileInfo.hash = links[i].hash().toStdString();
|
||||
fileInfo.size = links[i].size();
|
||||
|
||||
addFile(fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void setNewCompleter(QTableWidget *tableWidget, QCompleter *completer)
|
||||
{
|
||||
int rowCount = tableWidget->rowCount();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue