mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 17:15:31 -05:00
Added custom context menu and save image option into forums
This commit is contained in:
parent
ff44965e2c
commit
1da28aff90
@ -22,6 +22,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include <QKeyEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "GxsForumThreadWidget.h"
|
||||
#include "ui_GxsForumThreadWidget.h"
|
||||
@ -39,6 +40,7 @@
|
||||
#include "util/DateTime.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/imageutil.h"
|
||||
|
||||
#include <retroshare/rsgxsforums.h>
|
||||
#include <retroshare/rsgrouter.h>
|
||||
@ -135,6 +137,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||
mThreadCompareRole->setRole(COLUMN_THREAD_DATE, ROLE_THREAD_SORT);
|
||||
|
||||
connect(ui->threadTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(threadListCustomPopupMenu(QPoint)));
|
||||
connect(ui->postText, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint)));
|
||||
|
||||
ui->subscribeToolButton->hide() ;
|
||||
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
|
||||
@ -154,6 +157,8 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||
connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterColumnChanged(int)));
|
||||
|
||||
connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage()));
|
||||
|
||||
/* Set own item delegate */
|
||||
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
|
||||
itemDelegate->setSpacing(QSize(0, 2));
|
||||
@ -497,7 +502,23 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
|
||||
contextMnu.addSeparator();
|
||||
contextMnu.addAction(replyauthorAct);
|
||||
|
||||
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();
|
||||
|
||||
ui->actionSave_image->setData(point);
|
||||
contextMnu->addAction(ui->actionSave_image);
|
||||
|
||||
contextMnu->exec(ui->postText->viewport()->mapToGlobal(point));
|
||||
delete(contextMnu);
|
||||
}
|
||||
|
||||
bool GxsForumThreadWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
@ -1856,6 +1877,13 @@ 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::changedViewBox()
|
||||
{
|
||||
if (mInProcessSettings) {
|
||||
|
@ -70,6 +70,7 @@ protected:
|
||||
private slots:
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void threadListCustomPopupMenu(QPoint point);
|
||||
void contextMenuTextBrowser(QPoint point);
|
||||
|
||||
void changedThread();
|
||||
void clickedThread (QTreeWidgetItem *item, int column);
|
||||
@ -80,7 +81,7 @@ private slots:
|
||||
void replyMessageData(const RsGxsForumMsg &msg);
|
||||
void replyForumMessageData(const RsGxsForumMsg &msg);
|
||||
|
||||
|
||||
void saveImage();
|
||||
|
||||
|
||||
//void print();
|
||||
|
@ -453,10 +453,22 @@
|
||||
<verstretch>10</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</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>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user