mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-22 21:31:07 -05:00
Merge pull request #2706 from thunder2/SaveImage
Moved QAction for saving an image from customContextMenu of GxsForumT…
This commit is contained in:
commit
8dfa772782
@ -165,7 +165,6 @@ ChatWidget::ChatWidget(QWidget *parent)
|
|||||||
connect(ui->actionResetFont, SIGNAL(triggered()), this, SLOT(resetFont()));
|
connect(ui->actionResetFont, SIGNAL(triggered()), this, SLOT(resetFont()));
|
||||||
connect(ui->actionQuote, SIGNAL(triggered()), this, SLOT(quote()));
|
connect(ui->actionQuote, SIGNAL(triggered()), this, SLOT(quote()));
|
||||||
connect(ui->actionDropPlacemark, SIGNAL(triggered()), this, SLOT(dropPlacemark()));
|
connect(ui->actionDropPlacemark, SIGNAL(triggered()), this, SLOT(dropPlacemark()));
|
||||||
connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage()));
|
|
||||||
connect(ui->actionImport_sticker, SIGNAL(triggered()), this, SLOT(saveSticker()));
|
connect(ui->actionImport_sticker, SIGNAL(triggered()), this, SLOT(saveSticker()));
|
||||||
connect(ui->actionShow_Hidden_Images, SIGNAL(triggered()), ui->textBrowser, SLOT(showImages()));
|
connect(ui->actionShow_Hidden_Images, SIGNAL(triggered()), ui->textBrowser, SLOT(showImages()));
|
||||||
ui->actionShow_Hidden_Images->setIcon(ui->textBrowser->getBlockedImage());
|
ui->actionShow_Hidden_Images->setIcon(ui->textBrowser->getBlockedImage());
|
||||||
@ -1151,10 +1150,7 @@ void ChatWidget::pasteText(const QString& S)
|
|||||||
|
|
||||||
void ChatWidget::contextMenuTextBrowser(QPoint point)
|
void ChatWidget::contextMenuTextBrowser(QPoint point)
|
||||||
{
|
{
|
||||||
QMatrix matrix;
|
QMenu *contextMnu = ui->textBrowser->createStandardContextMenuFromPoint(point);
|
||||||
matrix.translate(ui->textBrowser->horizontalScrollBar()->value(), ui->textBrowser->verticalScrollBar()->value());
|
|
||||||
|
|
||||||
QMenu *contextMnu = ui->textBrowser->createStandardContextMenu(matrix.map(point));
|
|
||||||
|
|
||||||
contextMnu->addSeparator();
|
contextMnu->addSeparator();
|
||||||
contextMnu->addAction(ui->actionClearChatHistory);
|
contextMnu->addAction(ui->actionClearChatHistory);
|
||||||
@ -1167,9 +1163,7 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
|
|||||||
if (! ui->textBrowser->getShowImages())
|
if (! ui->textBrowser->getShowImages())
|
||||||
contextMnu->addAction(ui->actionShow_Hidden_Images);
|
contextMnu->addAction(ui->actionShow_Hidden_Images);
|
||||||
|
|
||||||
ui->actionSave_image->setData(point);
|
|
||||||
ui->actionImport_sticker->setData(point);
|
ui->actionImport_sticker->setData(point);
|
||||||
contextMnu->addAction(ui->actionSave_image);
|
|
||||||
contextMnu->addAction(ui->actionImport_sticker);
|
contextMnu->addAction(ui->actionImport_sticker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1995,13 +1989,6 @@ void ChatWidget::dropPlacemark()
|
|||||||
// or not.
|
// or not.
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatWidget::saveImage()
|
|
||||||
{
|
|
||||||
QPoint point = ui->actionSave_image->data().toPoint();
|
|
||||||
QTextCursor cursor = ui->textBrowser->cursorForPosition(point);
|
|
||||||
ImageUtil::extractImage(window(), cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatWidget::saveSticker()
|
void ChatWidget::saveSticker()
|
||||||
{
|
{
|
||||||
QPoint point = ui->actionImport_sticker->data().toPoint();
|
QPoint point = ui->actionImport_sticker->data().toPoint();
|
||||||
|
@ -196,7 +196,6 @@ private slots:
|
|||||||
|
|
||||||
void quote();
|
void quote();
|
||||||
void dropPlacemark();
|
void dropPlacemark();
|
||||||
void saveImage();
|
|
||||||
void saveSticker();
|
void saveSticker();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1049,15 +1049,6 @@ border-image: url(:/images/closepressed.png)
|
|||||||
<string>Insert horizontal rule</string>
|
<string>Insert horizontal rule</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave_image">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/document_save.png</normaloff>:/images/document_save.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Save image</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionImport_sticker">
|
<action name="actionImport_sticker">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../icons.qrc">
|
<iconset resource="../icons.qrc">
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "RSImageBlockWidget.h"
|
#include "RSImageBlockWidget.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
|
#include "util/imageutil.h"
|
||||||
|
|
||||||
#include <retroshare/rsinit.h> //To get RsAccounts
|
#include <retroshare/rsinit.h> //To get RsAccounts
|
||||||
|
|
||||||
@ -33,6 +34,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -317,18 +319,43 @@ QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
|
|||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMenu *RSTextBrowser::createStandardContextMenu()
|
void RSTextBrowser::addContextMenuAction(QAction *action)
|
||||||
{
|
{
|
||||||
return createStandardContextMenu(QPoint());
|
mContextMenuActions.push_back(action);
|
||||||
}
|
}
|
||||||
QMenu *RSTextBrowser::createStandardContextMenu(const QPoint &position)
|
|
||||||
|
void RSTextBrowser::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QMenu *menu = QTextBrowser::createStandardContextMenu(position);
|
emit calculateContextMenuActions();
|
||||||
|
|
||||||
|
QMenu *contextMenu = createStandardContextMenuFromPoint(event->pos());
|
||||||
|
|
||||||
|
QList<QAction*>::iterator it;
|
||||||
|
for (it = mContextMenuActions.begin(); it != mContextMenuActions.end(); ++it) {
|
||||||
|
contextMenu->addAction(*it);
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenu->exec(QCursor::pos());
|
||||||
|
|
||||||
|
delete(contextMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu *RSTextBrowser::createStandardContextMenuFromPoint(const QPoint &widgetPos)
|
||||||
|
{
|
||||||
|
QMatrix matrix;
|
||||||
|
matrix.translate(horizontalScrollBar()->value(), verticalScrollBar()->value());
|
||||||
|
|
||||||
|
QMenu *menu = QTextBrowser::createStandardContextMenu(matrix.map(widgetPos));
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource()));
|
QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource()));
|
||||||
a->setEnabled(!this->document()->isEmpty());
|
a->setEnabled(!this->document()->isEmpty());
|
||||||
|
|
||||||
|
if (checkImage(widgetPos)) {
|
||||||
|
a = menu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/document_save.png"), tr("Save image"), this, SLOT(saveImage()));
|
||||||
|
a->setData(widgetPos);
|
||||||
|
}
|
||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,3 +377,15 @@ void RSTextBrowser::viewSource()
|
|||||||
|
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSTextBrowser::saveImage()
|
||||||
|
{
|
||||||
|
QAction *action = dynamic_cast<QAction*>(sender()) ;
|
||||||
|
if (!action) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPoint point = action->data().toPoint();
|
||||||
|
QTextCursor cursor = cursorForPosition(point);
|
||||||
|
ImageUtil::extractImage(window(), cursor);
|
||||||
|
}
|
||||||
|
@ -49,6 +49,8 @@ public:
|
|||||||
bool checkImage(QPoint pos) {QString imageStr; return checkImage(pos, imageStr); }
|
bool checkImage(QPoint pos) {QString imageStr; return checkImage(pos, imageStr); }
|
||||||
QString anchorForPosition(const QPoint &pos) const;
|
QString anchorForPosition(const QPoint &pos) const;
|
||||||
|
|
||||||
|
// Add QAction to context menu (action won't be deleted)
|
||||||
|
void addContextMenuAction(QAction *action);
|
||||||
|
|
||||||
void activateLinkClick(bool active);
|
void activateLinkClick(bool active);
|
||||||
|
|
||||||
@ -58,8 +60,10 @@ public:
|
|||||||
QVariant textColorQuotes() const { return highlighter->textColorQuotes();}
|
QVariant textColorQuotes() const { return highlighter->textColorQuotes();}
|
||||||
bool getShowImages() const { return mShowImages; }
|
bool getShowImages() const { return mShowImages; }
|
||||||
|
|
||||||
QMenu *createStandardContextMenu();
|
QMenu *createStandardContextMenuFromPoint(const QPoint &widgetPos);
|
||||||
QMenu *createStandardContextMenu(const QPoint &position);
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void calculateContextMenuActions();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showImages();
|
void showImages();
|
||||||
@ -70,9 +74,15 @@ private slots:
|
|||||||
void linkClicked(const QUrl &url);
|
void linkClicked(const QUrl &url);
|
||||||
void destroyImageBlockWidget();
|
void destroyImageBlockWidget();
|
||||||
void viewSource();
|
void viewSource();
|
||||||
|
void saveImage();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Hide method from QTextBrowser
|
||||||
|
using QTextBrowser::createStandardContextMenu;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString mPlaceholderText;
|
QString mPlaceholderText;
|
||||||
@ -80,6 +90,7 @@ private:
|
|||||||
RSImageBlockWidget *mImageBlockWidget;
|
RSImageBlockWidget *mImageBlockWidget;
|
||||||
bool mLinkClickActive;
|
bool mLinkClickActive;
|
||||||
RsSyntaxHighlighter *highlighter;
|
RsSyntaxHighlighter *highlighter;
|
||||||
|
QList<QAction*> mContextMenuActions;
|
||||||
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
|
#ifdef RSTEXTBROWSER_CHECKIMAGE_DEBUG
|
||||||
QRect mCursorRectStart;
|
QRect mCursorRectStart;
|
||||||
QRect mCursorRectLeft;
|
QRect mCursorRectLeft;
|
||||||
|
@ -276,7 +276,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||||||
|
|
||||||
connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedVersion()));
|
connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedVersion()));
|
||||||
connect(ui->threadTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(threadListCustomPopupMenu(QPoint)));
|
connect(ui->threadTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(threadListCustomPopupMenu(QPoint)));
|
||||||
connect(ui->postText, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint)));
|
|
||||||
connect(ui->forumName, SIGNAL(clicked(QPoint)), this, SLOT(showForumInfo()));
|
connect(ui->forumName, SIGNAL(clicked(QPoint)), this, SLOT(showForumInfo()));
|
||||||
|
|
||||||
ui->subscribeToolButton->hide() ;
|
ui->subscribeToolButton->hide() ;
|
||||||
@ -303,8 +302,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||||
connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
|
connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
|
||||||
|
|
||||||
connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage()));
|
|
||||||
|
|
||||||
connect(ui->threadedView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleThreadedView(bool)));
|
connect(ui->threadedView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleThreadedView(bool)));
|
||||||
connect(ui->flatView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleFlatView(bool)));
|
connect(ui->flatView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleFlatView(bool)));
|
||||||
connect(ui->latestPostInThreadView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleLstPostInThreadView(bool)));
|
connect(ui->latestPostInThreadView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleLstPostInThreadView(bool)));
|
||||||
@ -793,25 +790,6 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
|
|||||||
contextMnu.exec(QCursor::pos());
|
contextMnu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::contextMenuTextBrowser(QPoint point)
|
|
||||||
{
|
|
||||||
QMatrix matrix;
|
|
||||||
matrix.translate(ui->postText->horizontalScrollBar()->value(), ui->postText->verticalScrollBar()->value());
|
|
||||||
|
|
||||||
QMenu *contextMnu = ui->postText->createStandardContextMenu(matrix.map(point));
|
|
||||||
|
|
||||||
contextMnu->addSeparator();
|
|
||||||
|
|
||||||
if(ui->postText->checkImage(point))
|
|
||||||
{
|
|
||||||
ui->actionSave_image->setData(point);
|
|
||||||
contextMnu->addAction(ui->actionSave_image);
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMnu->exec(ui->postText->viewport()->mapToGlobal(point));
|
|
||||||
delete(contextMnu);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsForumThreadWidget::headerContextMenuRequested(const QPoint &pos)
|
void GxsForumThreadWidget::headerContextMenuRequested(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QMenu* header_context_menu = new QMenu(tr("Show column"), this);
|
QMenu* header_context_menu = new QMenu(tr("Show column"), this);
|
||||||
@ -1823,13 +1801,6 @@ void GxsForumThreadWidget::replyForumMessageData(const RsGxsForumMsg &msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::saveImage()
|
|
||||||
{
|
|
||||||
QPoint point = ui->actionSave_image->data().toPoint();
|
|
||||||
QTextCursor cursor = ui->postText->cursorForPosition(point);
|
|
||||||
ImageUtil::extractImage(window(), cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GxsForumThreadWidget::toggleThreadedView(bool b) { if(b) changedViewBox(VIEW_THREADED); }
|
void GxsForumThreadWidget::toggleThreadedView(bool b) { if(b) changedViewBox(VIEW_THREADED); }
|
||||||
void GxsForumThreadWidget::toggleFlatView(bool b) { if(b) changedViewBox(VIEW_FLAT); }
|
void GxsForumThreadWidget::toggleFlatView(bool b) { if(b) changedViewBox(VIEW_FLAT); }
|
||||||
void GxsForumThreadWidget::toggleLstPostInThreadView(bool b) { if(b) changedViewBox(VIEW_LAST_POST); }
|
void GxsForumThreadWidget::toggleLstPostInThreadView(bool b) { if(b) changedViewBox(VIEW_LAST_POST); }
|
||||||
|
@ -108,7 +108,6 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
/** Create the context popup menu and it's submenus */
|
/** Create the context popup menu and it's submenus */
|
||||||
void threadListCustomPopupMenu(QPoint point);
|
void threadListCustomPopupMenu(QPoint point);
|
||||||
void contextMenuTextBrowser(QPoint point);
|
|
||||||
void headerContextMenuRequested(const QPoint& pos);
|
void headerContextMenuRequested(const QPoint& pos);
|
||||||
void showForumInfo();
|
void showForumInfo();
|
||||||
|
|
||||||
@ -134,8 +133,6 @@ private slots:
|
|||||||
// This method is used to perform an asynchroneous action on the message data. Any of the methods above can be used as parameter.
|
// This method is used to perform an asynchroneous action on the message data. Any of the methods above can be used as parameter.
|
||||||
void async_msg_action(const MsgMethod& method);
|
void async_msg_action(const MsgMethod& method);
|
||||||
|
|
||||||
void saveImage();
|
|
||||||
|
|
||||||
void markMsgAsRead();
|
void markMsgAsRead();
|
||||||
void markMsgAsReadChildren();
|
void markMsgAsReadChildren();
|
||||||
void markMsgAsUnread();
|
void markMsgAsUnread();
|
||||||
|
@ -568,9 +568,6 @@
|
|||||||
<family>MS Sans Serif</family>
|
<family>MS Sans Serif</family>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="contextMenuPolicy">
|
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -578,15 +575,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<action name="actionSave_image">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/document_save.png</normaloff>:/images/document_save.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Save image</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
@ -19289,7 +19289,12 @@ p, li { white-space: pre-wrap; }
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location line="+17"/>
|
<location line="+4"/>
|
||||||
|
<source>Save image</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location line="+19"/>
|
||||||
<source>Document source</source>
|
<source>Document source</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
Loading…
Reference in New Issue
Block a user