2012-09-26 19:32:53 -04:00
|
|
|
/****************************************************************
|
|
|
|
* This file is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012, RetroShare Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#ifndef MIMETEXTEDIT_H
|
|
|
|
#define MIMETEXTEDIT_H
|
|
|
|
|
2013-07-04 15:36:12 -04:00
|
|
|
#include <QCompleter>
|
2014-12-24 21:39:40 -05:00
|
|
|
#include "RSTextEdit.h"
|
2015-12-12 20:01:06 -05:00
|
|
|
#include "util/RsSyntaxHighlighter.h"
|
2012-09-26 19:32:53 -04:00
|
|
|
|
2014-12-24 21:39:40 -05:00
|
|
|
class MimeTextEdit : public RSTextEdit
|
2012-09-26 19:32:53 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2015-12-12 20:01:06 -05:00
|
|
|
Q_PROPERTY(QColor textColorQuote READ textColorQuote WRITE setTextColorQuote)
|
|
|
|
|
2012-09-26 19:32:53 -04:00
|
|
|
public:
|
|
|
|
MimeTextEdit(QWidget *parent = 0);
|
|
|
|
|
2013-12-30 14:12:16 -05:00
|
|
|
//Form here: http://qt-project.org/doc/qt-4.8/tools-customcompleter.html
|
|
|
|
void setCompleter(QCompleter *completer);
|
|
|
|
QCompleter *completer() const;
|
|
|
|
void setCompleterKeyModifiers(Qt::KeyboardModifier modifiers);
|
|
|
|
Qt::KeyboardModifier getCompleterKeyModifiers() const;
|
|
|
|
void setCompleterKey(Qt::Key key);
|
|
|
|
Qt::Key getCompleterKey() const;
|
|
|
|
void forceCompleterShowNextKeyEvent(QString startString = "");
|
|
|
|
|
|
|
|
// Add QAction to context menu (action won't be deleted)
|
|
|
|
void addContextMenuAction(QAction *action);
|
|
|
|
|
2015-12-12 20:01:06 -05:00
|
|
|
QColor textColorQuote() const { return highliter->textColorQuote();}
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setTextColorQuote(QColor textColorQuote) { highliter->setTextColorQuote(textColorQuote);}
|
|
|
|
|
2013-12-30 14:12:16 -05:00
|
|
|
signals:
|
|
|
|
void calculateContextMenuActions();
|
2013-07-04 15:36:12 -04:00
|
|
|
|
2012-09-26 19:32:53 -04:00
|
|
|
protected:
|
|
|
|
virtual bool canInsertFromMimeData(const QMimeData* source) const;
|
|
|
|
virtual void insertFromMimeData(const QMimeData* source);
|
2013-12-30 14:12:16 -05:00
|
|
|
virtual void contextMenuEvent(QContextMenuEvent *e);
|
|
|
|
virtual void keyPressEvent(QKeyEvent *e);
|
|
|
|
virtual void focusInEvent(QFocusEvent *e);
|
2013-07-04 15:36:12 -04:00
|
|
|
|
|
|
|
private slots:
|
2013-12-30 14:12:16 -05:00
|
|
|
void insertCompletion(const QString &completion);
|
|
|
|
void pasteLink();
|
|
|
|
void pasteOwnCertificateLink();
|
2015-09-02 18:27:14 -04:00
|
|
|
void pastePlainText();
|
2015-12-06 20:28:27 -05:00
|
|
|
void spoiler();
|
|
|
|
|
2013-07-04 15:36:12 -04:00
|
|
|
private:
|
2013-12-30 14:12:16 -05:00
|
|
|
QString textUnderCursor() const;
|
2013-07-04 15:36:12 -04:00
|
|
|
|
|
|
|
private:
|
2013-12-30 14:12:16 -05:00
|
|
|
QCompleter *mCompleter;
|
|
|
|
Qt::KeyboardModifier mCompleterKeyModifiers;
|
|
|
|
Qt::Key mCompleterKey;
|
|
|
|
bool mForceCompleterShowNextKeyEvent;
|
|
|
|
QString mCompleterStartString;
|
|
|
|
QList<QAction*> mContextMenuActions;
|
2015-12-12 20:01:06 -05:00
|
|
|
RsSyntaxHighlighter *highliter;
|
2012-09-26 19:32:53 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MIMETEXTEDIT_H
|