mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #2104 from PhenomRetroShare/Add_ViewSourceInRSTextBrowser
Add View Source in RSTextBrowser
This commit is contained in:
commit
8e32a804ad
@ -18,19 +18,24 @@
|
|||||||
* *
|
* *
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QTextDocumentFragment>
|
|
||||||
|
|
||||||
#include "RSTextBrowser.h"
|
#include "RSTextBrowser.h"
|
||||||
|
|
||||||
#include "RSImageBlockWidget.h"
|
#include "RSImageBlockWidget.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
|
|
||||||
#include <retroshare/rsinit.h> //To get RsAccounts
|
#include <retroshare/rsinit.h> //To get RsAccounts
|
||||||
|
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QTextDocumentFragment>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
RSTextBrowser::RSTextBrowser(QWidget *parent) :
|
RSTextBrowser::RSTextBrowser(QWidget *parent) :
|
||||||
QTextBrowser(parent)
|
QTextBrowser(parent)
|
||||||
{
|
{
|
||||||
@ -291,3 +296,37 @@ QString RSTextBrowser::anchorForPosition(const QPoint &pos) const
|
|||||||
}
|
}
|
||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMenu *RSTextBrowser::createStandardContextMenu()
|
||||||
|
{
|
||||||
|
return createStandardContextMenu(QPoint());
|
||||||
|
}
|
||||||
|
QMenu *RSTextBrowser::createStandardContextMenu(const QPoint &position)
|
||||||
|
{
|
||||||
|
QMenu *menu = QTextBrowser::createStandardContextMenu(position);
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
QAction *a = menu->addAction(FilesDefs::getIconFromQtResourcePath("://icons/textedit/code.png"), tr("View &Source"), this, SLOT(viewSource()));
|
||||||
|
a->setEnabled(!this->document()->isEmpty());
|
||||||
|
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSTextBrowser::viewSource()
|
||||||
|
{
|
||||||
|
QString text = this->textCursor().selection().toHtml();
|
||||||
|
if (text.isEmpty())
|
||||||
|
text = this->document()->toHtml();
|
||||||
|
|
||||||
|
QDialog *dialog = new QDialog(this);
|
||||||
|
QPlainTextEdit *pte = new QPlainTextEdit(dialog);
|
||||||
|
pte->setPlainText(text);
|
||||||
|
QGridLayout *gl = new QGridLayout(dialog);
|
||||||
|
gl->addWidget(pte,0,0,1,1);
|
||||||
|
dialog->setWindowTitle(tr("Document source"));
|
||||||
|
dialog->resize(500, 400);
|
||||||
|
|
||||||
|
dialog->exec();
|
||||||
|
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
@ -56,6 +56,9 @@ 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 *createStandardContextMenu(const QPoint &position);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showImages();
|
void showImages();
|
||||||
void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);}
|
void setTextColorQuote(QColor textColorQuote) { highlighter->setTextColorQuote(textColorQuote);}
|
||||||
@ -64,6 +67,7 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void linkClicked(const QUrl &url);
|
void linkClicked(const QUrl &url);
|
||||||
void destroyImageBlockWidget();
|
void destroyImageBlockWidget();
|
||||||
|
void viewSource();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
Loading…
Reference in New Issue
Block a user