Added a custom context menu for pasting RS-links to the base class MimeTextEdit and removed the custom context menu from derived classes.

Updated english translation.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6977 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-12-30 19:12:16 +00:00
parent dddc4356f1
commit abd6b46ca0
17 changed files with 206 additions and 374 deletions

View File

@ -1733,18 +1733,6 @@ QString RSLinkClipboard::toHtml()
return res ; return res ;
} }
QString RSLinkClipboard::toHtmlFull()
{
QList<RetroShareLink> links;
parseClipboard(links);
QString res ;
for(int i = 0; i < links.size(); ++i)
res += links[i].toHtmlFull() + "<br>" ;
return res ;
}
bool RSLinkClipboard::empty(RetroShareLink::enumType type /* = RetroShareLink::TYPE_UNKNOWN*/) bool RSLinkClipboard::empty(RetroShareLink::enumType type /* = RetroShareLink::TYPE_UNKNOWN*/)
{ {
QList<RetroShareLink> links; QList<RetroShareLink> links;

View File

@ -187,10 +187,6 @@ class RSLinkClipboard
// //
static QString toHtml(); static QString toHtml();
// produces a list of html links that displays the full links
//
static QString toHtmlFull();
// produces a list of html links that displays with the file name + filesize // produces a list of html links that displays with the file name + filesize
// //
static QString toHtmlSize(); static QString toHtmlSize();

View File

@ -140,6 +140,12 @@ ChatWidget::ChatWidget(QWidget *parent) :
ui->chatTextEdit->setCompleterKeyModifiers(Qt::ControlModifier); ui->chatTextEdit->setCompleterKeyModifiers(Qt::ControlModifier);
ui->chatTextEdit->setCompleterKey(Qt::Key_Space); ui->chatTextEdit->setCompleterKey(Qt::Key_Space);
//#ifdef ENABLE_DISTANT_CHAT_AND_MSGS
// contextMnu->addSeparator();
// QAction *action = new QAction(QIcon(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this);
// connect(action, SIGNAL(triggered()), this, SLOT(pasteCreateMsgLink()));
// ui->chatTextEdit->addContextMenuAction(action);
//#endif
} }
ChatWidget::~ChatWidget() ChatWidget::~ChatWidget()
@ -608,43 +614,6 @@ void ChatWidget::pasteText(const QString& S)
setColorAndFont(); setColorAndFont();
} }
void ChatWidget::pasteLink()
{
//std::cerr << "In paste link" << std::endl;
ui->chatTextEdit->insertHtml(RSLinkClipboard::toHtml());
setColorAndFont();
}
void ChatWidget::pasteOwnCertificateLink()
{
//std::cerr << "In paste own certificate link" << std::endl;
RetroShareLink link ;
std::string ownId = rsPeers->getOwnId() ;
if( link.createCertificate(ownId) ) {
ui->chatTextEdit->insertHtml(link.toHtml() + " ");
setColorAndFont();
}
}
void ChatWidget::contextMenu(QPoint point)
{
std::cerr << "In context menu" << std::endl;
QMenu *contextMnu = ui->chatTextEdit->createStandardContextMenu(point);
contextMnu->addSeparator();
QAction *action = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
action->setDisabled(RSLinkClipboard::empty());
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
//#ifdef ENABLE_DISTANT_CHAT_AND_MSGS
// contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste/Create private chat or Message link..."), this, SLOT(pasteCreateMsgLink()));
//#endif
contextMnu->exec(QCursor::pos());
delete(contextMnu);
}
void ChatWidget::pasteCreateMsgLink() void ChatWidget::pasteCreateMsgLink()
{ {
RSettingsWin::showYourself(this, RSettingsWin::Chat); RSettingsWin::showYourself(this, RSettingsWin::Chat);

View File

@ -81,6 +81,7 @@ public:
public slots: public slots:
void updateStatus(const QString &peer_id, int status); void updateStatus(const QString &peer_id, int status);
private slots: private slots:
void pasteCreateMsgLink() ; void pasteCreateMsgLink() ;
void clearChatHistory(); void clearChatHistory();
@ -100,9 +101,6 @@ protected:
void updateTitle(); void updateTitle();
private slots: private slots:
void pasteLink();
void pasteOwnCertificateLink();
void contextMenu(QPoint);
void contextMenuTextBrowser(QPoint); void contextMenuTextBrowser(QPoint);
void chatCharFormatChanged(); void chatCharFormatChanged();

View File

@ -287,9 +287,6 @@ border-image: url(:/images/closepressed.png)
<height>30</height> <height>30</height>
</size> </size>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -21,20 +21,24 @@
#include <QMimeData> #include <QMimeData>
#include <QTextDocumentFragment> #include <QTextDocumentFragment>
#include "MimeTextEdit.h"
#include "util/HandleRichText.h"
#include <QCompleter> #include <QCompleter>
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QKeyEvent> #include <QKeyEvent>
#include <QScrollBar> #include <QScrollBar>
#include <QMenu>
#include "MimeTextEdit.h"
#include "util/HandleRichText.h"
#include "gui/RetroShareLink.h"
#include <retroshare/rspeers.h>
MimeTextEdit::MimeTextEdit(QWidget *parent) MimeTextEdit::MimeTextEdit(QWidget *parent)
: QTextEdit(parent), mCompleter(0) : QTextEdit(parent), mCompleter(0)
{ {
mCompleterKeyModifiers=Qt::ControlModifier; mCompleterKeyModifiers = Qt::ControlModifier;
mCompleterKey=Qt::Key_Space; mCompleterKey = Qt::Key_Space;
mForceCompleterShowNextKeyEvent=false; mForceCompleterShowNextKeyEvent = false;
mCompleterStartString="";
} }
bool MimeTextEdit::canInsertFromMimeData(const QMimeData* source) const bool MimeTextEdit::canInsertFromMimeData(const QMimeData* source) const
@ -63,7 +67,7 @@ void MimeTextEdit::insertFromMimeData(const QMimeData* source)
QString encodedImage; QString encodedImage;
if (RsHtml::makeEmbeddedImage(image, encodedImage, 640*480)) { if (RsHtml::makeEmbeddedImage(image, encodedImage, 640*480)) {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage); QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
this->textCursor().insertFragment(fragment); textCursor().insertFragment(fragment);
return; return;
} }
} }
@ -76,136 +80,183 @@ void MimeTextEdit::insertFromMimeData(const QMimeData* source)
void MimeTextEdit::setCompleter(QCompleter *completer) void MimeTextEdit::setCompleter(QCompleter *completer)
{ {
if (mCompleter) if (mCompleter)
QObject::disconnect(mCompleter, 0, this, 0); QObject::disconnect(mCompleter, 0, this, 0);
mCompleter = completer; mCompleter = completer;
if (!mCompleter) if (!mCompleter)
return; return;
mCompleter->setWidget(this); mCompleter->setWidget(this);
mCompleter->setCompletionMode(QCompleter::PopupCompletion); mCompleter->setCompletionMode(QCompleter::PopupCompletion);
mCompleter->setCaseSensitivity(Qt::CaseInsensitive); mCompleter->setCaseSensitivity(Qt::CaseInsensitive);
QObject::connect(mCompleter, SIGNAL(activated(QString)), QObject::connect(mCompleter, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString)));
this, SLOT(insertCompletion(QString)));
} }
QCompleter *MimeTextEdit::completer() const QCompleter *MimeTextEdit::completer() const
{ {
return mCompleter; return mCompleter;
} }
void MimeTextEdit::insertCompletion(const QString& completion) void MimeTextEdit::insertCompletion(const QString& completion)
{ {
if (mCompleter->widget() != this) if (mCompleter->widget() != this)
return; return;
QTextCursor tc = textCursor();
if (mCompleter->completionPrefix().length()>0) { QTextCursor tc = textCursor();
tc.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); if (mCompleter->completionPrefix().length() > 0) {
} tc.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
tc.removeSelectedText(); }
tc.insertText(mCompleterStartString+completion); tc.removeSelectedText();
mCompleterStartString=""; tc.insertText(mCompleterStartString+completion);
setTextCursor(tc); mCompleterStartString.clear();
setTextCursor(tc);
} }
QString MimeTextEdit::textUnderCursor() const QString MimeTextEdit::textUnderCursor() const
{ {
QTextCursor tc = textCursor(); QTextCursor tc = textCursor();
tc.select(QTextCursor::WordUnderCursor); tc.select(QTextCursor::WordUnderCursor);
return tc.selectedText(); return tc.selectedText();
} }
void MimeTextEdit::focusInEvent(QFocusEvent *e) void MimeTextEdit::focusInEvent(QFocusEvent *e)
{ {
if (mCompleter) if (mCompleter)
mCompleter->setWidget(this); mCompleter->setWidget(this);
QTextEdit::focusInEvent(e);
QTextEdit::focusInEvent(e);
} }
void MimeTextEdit::keyPressEvent(QKeyEvent *e) void MimeTextEdit::keyPressEvent(QKeyEvent *e)
{ {
if (mCompleter && mCompleter->popup()->isVisible()) {
// The following keys are forwarded by the completer to the widget
switch (e->key()) {
case Qt::Key_Enter:
case Qt::Key_Return:
case Qt::Key_Escape:
case Qt::Key_Tab:
case Qt::Key_Backtab:
mCompleter->popup()->hide();
mForceCompleterShowNextKeyEvent=false;
e->ignore();
return; // let the completer do default behavior
default:
break;
}
}
if (mCompleter && mCompleter->popup()->isVisible()) { bool isShortcut = ((e->modifiers() & mCompleterKeyModifiers) && e->key() == mCompleterKey);
// The following keys are forwarded by the completer to the widget if (isShortcut && !mForceCompleterShowNextKeyEvent) {
switch (e->key()) { mCompleterStartString.clear();
case Qt::Key_Enter: }
case Qt::Key_Return: isShortcut |= mForceCompleterShowNextKeyEvent;
case Qt::Key_Escape: if (!mCompleter || !isShortcut) // do not process the shortcut when we have a completer
case Qt::Key_Tab: QTextEdit::keyPressEvent(e);
case Qt::Key_Backtab:
mCompleter->popup()->hide();
mForceCompleterShowNextKeyEvent=false;
e->ignore();
return; // let the completer do default behavior
default:
break;
}
}
bool isShortcut = ((e->modifiers() & mCompleterKeyModifiers) && e->key() == mCompleterKey); if (!mCompleter) return; //Nothing else to do if not mCompleter initialized
if (isShortcut && !mForceCompleterShowNextKeyEvent) {
mCompleterStartString="";
}
isShortcut |= mForceCompleterShowNextKeyEvent;
if (!mCompleter || !isShortcut) // do not process the shortcut when we have a completer
QTextEdit::keyPressEvent(e);
if (!mCompleter) return; //Nothing else to do if not mCompleter initialized if (!isShortcut && (mCompleter && !mCompleter->popup()->isVisible())) {
return;
}
if (!isShortcut && (mCompleter && !mCompleter->popup()->isVisible())) { if (!mForceCompleterShowNextKeyEvent) {
return; static QString eow(" ~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word
} if (!isShortcut && !e->text().isEmpty() && eow.contains(e->text())){
mCompleter->popup()->hide();
return;
}
}
if (!mForceCompleterShowNextKeyEvent) { QString completionPrefix = textUnderCursor();
static QString eow(" ~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word if (completionPrefix != mCompleter->completionPrefix()) {
if (!isShortcut && !e->text().isEmpty() && eow.contains(e->text())){ mCompleter->setCompletionPrefix(completionPrefix);
mCompleter->popup()->hide(); mCompleter->popup()->setCurrentIndex(mCompleter->completionModel()->index(0, 0));
return; }
}
}
QString completionPrefix = textUnderCursor(); QRect cr = cursorRect();
if (completionPrefix != mCompleter->completionPrefix()) { cr.setWidth(mCompleter->popup()->sizeHintForColumn(0) + mCompleter->popup()->verticalScrollBar()->sizeHint().width());
mCompleter->setCompletionPrefix(completionPrefix); mCompleter->complete(cr); // popup it up!
mCompleter->popup()->setCurrentIndex(mCompleter->completionModel()->index(0, 0));
}
QRect cr = cursorRect(); if (mCompleter->completionCount()==0 && isShortcut){
cr.setWidth(mCompleter->popup()->sizeHintForColumn(0) QTextEdit::keyPressEvent(e);// Process the key if no match
+ mCompleter->popup()->verticalScrollBar()->sizeHint().width()); }
mCompleter->complete(cr); // popup it up! mForceCompleterShowNextKeyEvent = false;
if (mCompleter->completionCount()==0 && isShortcut){
QTextEdit::keyPressEvent(e);// Process the key if no match
}
mForceCompleterShowNextKeyEvent=false;
} }
void MimeTextEdit::setCompleterKeyModifiers(Qt::KeyboardModifier modifiers) void MimeTextEdit::setCompleterKeyModifiers(Qt::KeyboardModifier modifiers)
{ {
mCompleterKeyModifiers=modifiers; mCompleterKeyModifiers = modifiers;
} }
Qt::KeyboardModifier MimeTextEdit::getCompleterKeyModifiers() const Qt::KeyboardModifier MimeTextEdit::getCompleterKeyModifiers() const
{ {
return mCompleterKeyModifiers; return mCompleterKeyModifiers;
} }
void MimeTextEdit::setCompleterKey(Qt::Key key) void MimeTextEdit::setCompleterKey(Qt::Key key)
{ {
mCompleterKey=key; mCompleterKey = key;
} }
Qt::Key MimeTextEdit::getCompleterKey() const Qt::Key MimeTextEdit::getCompleterKey() const
{ {
return mCompleterKey; return mCompleterKey;
} }
void MimeTextEdit::forceCompleterShowNextKeyEvent(QString startString="")
{
if (!mCompleter) return; //Nothing else to do if not mCompleter initialized
if(!mCompleter->popup()->isVisible()){ void MimeTextEdit::forceCompleterShowNextKeyEvent(QString startString)
mForceCompleterShowNextKeyEvent=true; {
mCompleterStartString=startString; if (!mCompleter) return; //Nothing else to do if not mCompleter initialized
if(!mCompleter->popup()->isVisible()){
mForceCompleterShowNextKeyEvent = true;
mCompleterStartString = startString;
}
} }
void MimeTextEdit::addContextMenuAction(QAction *action)
{
mContextMenuActions.push_back(action);
}
void MimeTextEdit::contextMenuEvent(QContextMenuEvent *e)
{
emit calculateContextMenuActions();
QMenu *contextMenu = createStandardContextMenu(e->pos());
/* Add actions for pasting links */
contextMenu->addSeparator();
QAction *pasteLinkAction = contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
contextMenu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
if (RSLinkClipboard::empty()) {
pasteLinkAction->setDisabled(true);
}
QList<QAction*>::iterator it;
for (it = mContextMenuActions.begin(); it != mContextMenuActions.end(); ++it) {
contextMenu->addAction(*it);
}
contextMenu->exec(QCursor::pos());
delete(contextMenu);
}
void MimeTextEdit::pasteLink()
{
insertHtml(RSLinkClipboard::toHtml()) ;
}
void MimeTextEdit::pasteOwnCertificateLink()
{
RetroShareLink link;
std::string ownId = rsPeers->getOwnId();
if (link.createCertificate(ownId)) {
insertHtml(link.toHtml() + " ");
}
} }

View File

@ -32,34 +32,43 @@ class MimeTextEdit : public QTextEdit
public: public:
MimeTextEdit(QWidget *parent = 0); MimeTextEdit(QWidget *parent = 0);
//Form here: http://qt-project.org/doc/qt-4.8/tools-customcompleter.html //Form here: http://qt-project.org/doc/qt-4.8/tools-customcompleter.html
void setCompleter(QCompleter *completer); void setCompleter(QCompleter *completer);
QCompleter *completer() const; QCompleter *completer() const;
void setCompleterKeyModifiers(Qt::KeyboardModifier modifiers); void setCompleterKeyModifiers(Qt::KeyboardModifier modifiers);
Qt::KeyboardModifier getCompleterKeyModifiers() const; Qt::KeyboardModifier getCompleterKeyModifiers() const;
void setCompleterKey(Qt::Key key); void setCompleterKey(Qt::Key key);
Qt::Key getCompleterKey() const; Qt::Key getCompleterKey() const;
void forceCompleterShowNextKeyEvent(QString startString); void forceCompleterShowNextKeyEvent(QString startString = "");
// Add QAction to context menu (action won't be deleted)
void addContextMenuAction(QAction *action);
signals:
void calculateContextMenuActions();
protected: protected:
virtual bool canInsertFromMimeData(const QMimeData* source) const; virtual bool canInsertFromMimeData(const QMimeData* source) const;
virtual void insertFromMimeData(const QMimeData* source); virtual void insertFromMimeData(const QMimeData* source);
void keyPressEvent(QKeyEvent *e); virtual void contextMenuEvent(QContextMenuEvent *e);
void focusInEvent(QFocusEvent *e); virtual void keyPressEvent(QKeyEvent *e);
virtual void focusInEvent(QFocusEvent *e);
private slots: private slots:
void insertCompletion(const QString &completion); void insertCompletion(const QString &completion);
void pasteLink();
void pasteOwnCertificateLink();
private: private:
QString textUnderCursor() const; QString textUnderCursor() const;
private: private:
QCompleter *mCompleter; QCompleter *mCompleter;
Qt::KeyboardModifier mCompleterKeyModifiers; Qt::KeyboardModifier mCompleterKeyModifiers;
Qt::Key mCompleterKey; Qt::Key mCompleterKey;
bool mForceCompleterShowNextKeyEvent; bool mForceCompleterShowNextKeyEvent;
QString mCompleterStartString; QString mCompleterStartString;
QList<QAction*> mContextMenuActions;
}; };
#endif // MIMETEXTEDIT_H #endif // MIMETEXTEDIT_H

View File

@ -21,7 +21,6 @@
#include "CreateForumMsg.h" #include "CreateForumMsg.h"
#include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QFile> #include <QFile>
#include <QDesktopWidget> #include <QDesktopWidget>
@ -30,7 +29,6 @@
#include <QTextDocumentFragment> #include <QTextDocumentFragment>
#include <retroshare/rsforums.h> #include <retroshare/rsforums.h>
#include <retroshare/rspeers.h>
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
@ -58,8 +56,6 @@ CreateForumMsg::CreateForumMsg(const std::string &fId, const std::string &pId)
Settings->loadWidgetInformation(this); Settings->loadWidgetInformation(this);
connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) );
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
// connect up the buttons. // connect up the buttons.
@ -68,7 +64,6 @@ CreateForumMsg::CreateForumMsg(const std::string &fId, const std::string &pId)
connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile())); connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile()));
connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addPicture())); connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addPicture()));
connect( ui.pastersButton, SIGNAL(clicked() ), this , SLOT(pasteLink()));
setAcceptDrops(true); setAcceptDrops(true);
ui.hashBox->setDropWidget(this); ui.hashBox->setDropWidget(this);
@ -77,25 +72,6 @@ CreateForumMsg::CreateForumMsg(const std::string &fId, const std::string &pId)
newMsg(); newMsg();
} }
/** context menu searchTablewidget2 **/
void CreateForumMsg::forumMessageCostumPopupMenu(QPoint point)
{
QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(point);
contextMnu->addSeparator();
QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
QAction *pasteLinkFullAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste full RetroShare Link"), this, SLOT(pasteLinkFull()));
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
if (RSLinkClipboard::empty()) {
pasteLinkAct->setDisabled (true);
pasteLinkFullAct->setDisabled (true);
}
contextMnu->exec(QCursor::pos());
delete(contextMnu);
}
void CreateForumMsg::newMsg() void CreateForumMsg::newMsg()
{ {
/* clear all */ /* clear all */
@ -253,22 +229,3 @@ void CreateForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
ui.forumMessage->setFocus( Qt::OtherFocusReason ); ui.forumMessage->setFocus( Qt::OtherFocusReason );
} }
void CreateForumMsg::pasteLink()
{
ui.forumMessage->insertHtml(RSLinkClipboard::toHtml()) ;
}
void CreateForumMsg::pasteLinkFull()
{
ui.forumMessage->insertHtml(RSLinkClipboard::toHtmlFull()) ;
}
void CreateForumMsg::pasteOwnCertificateLink()
{
RetroShareLink link ;
std::string ownId = rsPeers->getOwnId() ;
if( link.createCertificate(ownId) ) {
ui.forumMessage->insertHtml(link.toHtml() + " ");
}
}

View File

@ -35,15 +35,9 @@ public:
void newMsg(); /* cleanup */ void newMsg(); /* cleanup */
private slots: private slots:
/** Create the context popup menu and it's submenus */
void forumMessageCostumPopupMenu( QPoint point );
void fileHashingFinished(QList<HashedFile> hashedFiles); void fileHashingFinished(QList<HashedFile> hashedFiles);
/* actions to take.... */ /* actions to take.... */
void createMsg(); void createMsg();
void pasteLink();
void pasteLinkFull();
void pasteOwnCertificateLink();
void smileyWidgetForums(); void smileyWidgetForums();
void addSmileys(); void addSmileys();

View File

@ -195,23 +195,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QToolButton" name="pastersButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Paste RetroShare Link</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/pasterslink.png</normaloff>:/images/pasterslink.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -223,9 +206,6 @@
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="MimeTextEdit" name="forumMessage"> <widget class="MimeTextEdit" name="forumMessage">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="html"> <property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;

View File

@ -21,7 +21,6 @@
#include "CreateGxsForumMsg.h" #include "CreateGxsForumMsg.h"
#include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QFile> #include <QFile>
#include <QDesktopWidget> #include <QDesktopWidget>
@ -29,7 +28,6 @@
#include <QPushButton> #include <QPushButton>
#include <retroshare/rsgxsforums.h> #include <retroshare/rsgxsforums.h>
#include <retroshare/rspeers.h>
#include "gui/settings/rsharesettings.h" #include "gui/settings/rsharesettings.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
@ -83,8 +81,6 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
Settings->loadWidgetInformation(this); Settings->loadWidgetInformation(this);
connect(ui.forumMessage, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT(forumMessageCostumPopupMenu(QPoint)));
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
// connect up the buttons. // connect up the buttons.
@ -92,7 +88,6 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums())); connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile())); connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile()));
connect(ui.pastersButton, SIGNAL(clicked()), this, SLOT(pasteLink()));
connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool))); connect(ui.generateCheckBox, SIGNAL(toggled(bool)), ui.generateSpinBox, SLOT(setEnabled(bool)));
setAcceptDrops(true); setAcceptDrops(true);
@ -115,25 +110,6 @@ CreateGxsForumMsg::~CreateGxsForumMsg()
delete(mForumQueue); delete(mForumQueue);
} }
void CreateGxsForumMsg::forumMessageCostumPopupMenu(QPoint point)
{
QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(point);
contextMnu->addSeparator();
QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
QAction *pasteLinkFullAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste full RetroShare Link"), this, SLOT(pasteLinkFull()));
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
if (RSLinkClipboard::empty()) {
pasteLinkAct->setDisabled (true);
pasteLinkFullAct->setDisabled (true);
}
contextMnu->exec(QCursor::pos());
delete(contextMnu);
}
void CreateGxsForumMsg::newMsg() void CreateGxsForumMsg::newMsg()
{ {
/* clear all */ /* clear all */
@ -409,25 +385,6 @@ void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
ui.forumMessage->setFocus( Qt::OtherFocusReason ); ui.forumMessage->setFocus( Qt::OtherFocusReason );
} }
void CreateGxsForumMsg::pasteLink()
{
ui.forumMessage->insertHtml(RSLinkClipboard::toHtml()) ;
}
void CreateGxsForumMsg::pasteLinkFull()
{
ui.forumMessage->insertHtml(RSLinkClipboard::toHtmlFull()) ;
}
void CreateGxsForumMsg::pasteOwnCertificateLink()
{
RetroShareLink link ;
std::string ownId = rsPeers->getOwnId() ;
if( link.createCertificate(ownId) ) {
ui.forumMessage->insertHtml(link.toHtml() + " ");
}
}
void CreateGxsForumMsg::loadForumInfo(const uint32_t &token) void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
{ {
std::cerr << "CreateGxsForumMsg::loadForumInfo()"; std::cerr << "CreateGxsForumMsg::loadForumInfo()";

View File

@ -42,15 +42,9 @@ public:
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private slots: private slots:
/** Create the context popup menu and it's submenus */
void forumMessageCostumPopupMenu( QPoint point );
void fileHashingFinished(QList<HashedFile> hashedFiles); void fileHashingFinished(QList<HashedFile> hashedFiles);
/* actions to take.... */ /* actions to take.... */
void createMsg(); void createMsg();
void pasteLink();
void pasteLinkFull();
void pasteOwnCertificateLink();
void smileyWidgetForums(); void smileyWidgetForums();
void addSmileys(); void addSmileys();

View File

@ -187,26 +187,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QToolButton" name="pastersButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Paste RetroShare Link</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/pasterslink.png</normaloff>:/images/pasterslink.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -217,10 +197,7 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTextEdit" name="forumMessage"> <widget class="MimeTextEdit" name="forumMessage">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="html"> <property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
@ -296,9 +273,15 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>GxsIdChooser</class> <class>HashBox</class>
<extends>QComboBox</extends> <extends>QScrollArea</extends>
<header>gui/gxs/GxsIdChooser.h</header> <header location="global">gui/common/HashBox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MimeTextEdit</class>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>HeaderFrame</class> <class>HeaderFrame</class>
@ -307,10 +290,9 @@ p, li { white-space: pre-wrap; }
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>HashBox</class> <class>GxsIdChooser</class>
<extends>QScrollArea</extends> <extends>QComboBox</extends>
<header location="global">gui/common/HashBox.h</header> <header>gui/gxs/GxsIdChooser.h</header>
<container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>

View File

@ -162,7 +162,6 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
connect(ui.msgText, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &))); connect(ui.msgText, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)), this, SLOT(currentCharFormatChanged(const QTextCharFormat &)));
connect(ui.msgText, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); 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)), actionSave, SLOT(setEnabled(bool)));
connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool))); connect(ui.msgText->document(), SIGNAL(modificationChanged(bool)), this, SLOT(setWindowModified(bool)));
@ -565,23 +564,6 @@ void MessageComposer::closeEvent (QCloseEvent * event)
} }
} }
void MessageComposer::contextMenu(QPoint point)
{
QMenu *contextMnu = ui.msgText->createStandardContextMenu(point);
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) void MessageComposer::contextMenuFileList(QPoint)
{ {
QMenu contextMnu(this); QMenu contextMnu(this);

View File

@ -84,8 +84,6 @@ protected:
private slots: private slots:
/* toggle Contacts DockWidget */ /* toggle Contacts DockWidget */
void contextMenu(QPoint);
void pasteLink();
void contextMenuFileList(QPoint); void contextMenuFileList(QPoint);
void contextMenuMsgSendList(QPoint); void contextMenuMsgSendList(QPoint);
void pasteRecommended(); void pasteRecommended();

View File

@ -671,9 +671,6 @@
<verstretch>4</verstretch> <verstretch>4</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::TextEditorInteraction</set> <set>Qt::TextEditorInteraction</set>
</property> </property>

View File

@ -1870,14 +1870,6 @@ Double click lobbies to enter and chat.</source>
<source>Reset font to default</source> <source>Reset font to default</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Paste RetroShare Link</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Paste my certificate link</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>is typing...</source> <source>is typing...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -3883,10 +3875,6 @@ p, li { white-space: pre-wrap; }
<source>Sign Message</source> <source>Sign Message</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Paste RetroShare Link</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Forum Post</source> <source>Forum Post</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -3903,14 +3891,6 @@ p, li { white-space: pre-wrap; }
<source>Start New Thread</source> <source>Start New Thread</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Paste full RetroShare Link</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Paste my certificate link</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>In Reply to</source> <source>In Reply to</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -4094,10 +4074,6 @@ p, li { white-space: pre-wrap; }
<source>Sign Message</source> <source>Sign Message</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Paste RetroShare Link</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Forum Post</source> <source>Forum Post</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -4114,14 +4090,6 @@ p, li { white-space: pre-wrap; }
<source>Start New Thread</source> <source>Start New Thread</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Paste full RetroShare Link</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Paste my certificate link</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>No Forum</source> <source>No Forum</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -9659,6 +9627,17 @@ Do you want to save message ?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>MimeTextEdit</name>
<message>
<source>Paste RetroShare Link</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Paste my certificate link</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>MsgItem</name> <name>MsgItem</name>
<message> <message>
@ -11661,6 +11640,10 @@ Make sure you know who you&apos;re talking to.</source>
<source>Chat connection is unauthenticated</source> <source>Chat connection is unauthenticated</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Id: </source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>QuickStartWizard</name> <name>QuickStartWizard</name>