mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-05 01:25:39 -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 <QDateTime>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "GxsForumThreadWidget.h"
|
#include "GxsForumThreadWidget.h"
|
||||||
#include "ui_GxsForumThreadWidget.h"
|
#include "ui_GxsForumThreadWidget.h"
|
||||||
@ -39,6 +40,7 @@
|
|||||||
#include "util/DateTime.h"
|
#include "util/DateTime.h"
|
||||||
#include "gui/common/UIStateHelper.h"
|
#include "gui/common/UIStateHelper.h"
|
||||||
#include "util/QtVersion.h"
|
#include "util/QtVersion.h"
|
||||||
|
#include "util/imageutil.h"
|
||||||
|
|
||||||
#include <retroshare/rsgxsforums.h>
|
#include <retroshare/rsgxsforums.h>
|
||||||
#include <retroshare/rsgrouter.h>
|
#include <retroshare/rsgrouter.h>
|
||||||
@ -135,6 +137,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||||||
mThreadCompareRole->setRole(COLUMN_THREAD_DATE, ROLE_THREAD_SORT);
|
mThreadCompareRole->setRole(COLUMN_THREAD_DATE, ROLE_THREAD_SORT);
|
||||||
|
|
||||||
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)));
|
||||||
|
|
||||||
ui->subscribeToolButton->hide() ;
|
ui->subscribeToolButton->hide() ;
|
||||||
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
|
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(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()));
|
||||||
|
|
||||||
/* Set own item delegate */
|
/* Set own item delegate */
|
||||||
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
|
RSItemDelegate *itemDelegate = new RSItemDelegate(this);
|
||||||
itemDelegate->setSpacing(QSize(0, 2));
|
itemDelegate->setSpacing(QSize(0, 2));
|
||||||
@ -500,6 +505,22 @@ 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();
|
||||||
|
|
||||||
|
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)
|
bool GxsForumThreadWidget::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
if (obj == ui->threadTreeWidget) {
|
if (obj == ui->threadTreeWidget) {
|
||||||
@ -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()
|
void GxsForumThreadWidget::changedViewBox()
|
||||||
{
|
{
|
||||||
if (mInProcessSettings) {
|
if (mInProcessSettings) {
|
||||||
|
@ -70,6 +70,7 @@ 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 changedThread();
|
void changedThread();
|
||||||
void clickedThread (QTreeWidgetItem *item, int column);
|
void clickedThread (QTreeWidgetItem *item, int column);
|
||||||
@ -80,7 +81,7 @@ private slots:
|
|||||||
void replyMessageData(const RsGxsForumMsg &msg);
|
void replyMessageData(const RsGxsForumMsg &msg);
|
||||||
void replyForumMessageData(const RsGxsForumMsg &msg);
|
void replyForumMessageData(const RsGxsForumMsg &msg);
|
||||||
|
|
||||||
|
void saveImage();
|
||||||
|
|
||||||
|
|
||||||
//void print();
|
//void print();
|
||||||
|
@ -453,10 +453,22 @@
|
|||||||
<verstretch>10</verstretch>
|
<verstretch>10</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user