mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-18 12:24:22 -05:00
* Added Formating support for Create Forum Messages
* set correct WindowsTitle for Create Channel git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@843 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1eab434f2d
commit
d56d3e57f9
@ -118,6 +118,7 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
void ChannelFeed::createChannel()
|
||||
{
|
||||
CreateForum *cf = new CreateForum(NULL, false);
|
||||
cf->setWindowTitle(tr("Create Channel"));
|
||||
cf->show();
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
#define IMAGE_DOWNLOAD ":/images/start.png"
|
||||
#define IMAGE_DOWNLOADALL ":/images/startall.png"
|
||||
|
||||
/* Images for TreeWidget */
|
||||
/* Images for TreeWidget */
|
||||
#define IMAGE_FOLDER ":/images/folder16.png"
|
||||
#define IMAGE_FOLDERGREEN ":/images/folder_green.png"
|
||||
#define IMAGE_FOLDERRED ":/images/folder_red.png"
|
||||
@ -65,7 +65,7 @@
|
||||
|
||||
|
||||
/** Constructor */
|
||||
ForumsDialog::ForumsDialog(QWidget *parent)
|
||||
ForumsDialog::ForumsDialog(QWidget *parent)
|
||||
: MainPage(parent)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
@ -94,72 +94,19 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
||||
timer->start(1000);
|
||||
|
||||
|
||||
#if 0
|
||||
connect( ui.msgWidget, SIGNAL( itemClicked ( QTreeWidgetItem *, int) ), this, SLOT( updateMessages ( QTreeWidgetItem *, int) ) );
|
||||
connect( ui.listWidget, SIGNAL( currentRowChanged ( int) ), this, SLOT( changeBox ( int) ) );
|
||||
|
||||
connect(ui.newmessageButton, SIGNAL(clicked()), this, SLOT(newmessage()));
|
||||
connect(ui.removemessageButton, SIGNAL(clicked()), this, SLOT(removemessage()));
|
||||
//connect(ui.printbutton, SIGNAL(clicked()), this, SLOT(print()));
|
||||
//connect(ui.actionPrint, SIGNAL(triggered()), this, SLOT(print()));
|
||||
//connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printpreview()));
|
||||
|
||||
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
|
||||
|
||||
|
||||
mCurrCertId = "";
|
||||
mCurrMsgId = "";
|
||||
|
||||
/* hide the Tree +/- */
|
||||
ui.msgList->setRootIsDecorated( false );
|
||||
ui.msgWidget->setRootIsDecorated( false );
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * msgwheader = ui.msgWidget->header () ;
|
||||
msgwheader->setResizeMode (0, QHeaderView::Custom);
|
||||
msgwheader->setResizeMode (3, QHeaderView::Interactive);
|
||||
|
||||
msgwheader->resizeSection ( 0, 24 );
|
||||
msgwheader->resizeSection ( 2, 250 );
|
||||
msgwheader->resizeSection ( 3, 140 );
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * msglheader = ui.msgList->header () ;
|
||||
msglheader->setResizeMode (0, QHeaderView::Interactive);
|
||||
msglheader->setResizeMode (1, QHeaderView::Interactive);
|
||||
msglheader->setResizeMode (2, QHeaderView::Interactive);
|
||||
msglheader->setResizeMode (3, QHeaderView::Interactive);
|
||||
|
||||
msglheader->resizeSection ( 0, 200 );
|
||||
msglheader->resizeSection ( 1, 100 );
|
||||
msglheader->resizeSection ( 2, 100 );
|
||||
msglheader->resizeSection ( 3, 200 );
|
||||
|
||||
ui.newmessageButton->setIcon(QIcon(QString(":/images/folder-draft24-pressed.png")));
|
||||
ui.replymessageButton->setIcon(QIcon(QString(":/images/replymail-pressed.png")));
|
||||
ui.removemessageButton->setIcon(QIcon(QString(":/images/deletemail-pressed.png")));
|
||||
ui.printbutton->setIcon(QIcon(QString(":/images/print24.png")));
|
||||
|
||||
/*Disabled Reply Button */
|
||||
ui.replymessageButton->setEnabled(false);
|
||||
|
||||
QMenu * printmenu = new QMenu();
|
||||
printmenu->addAction(ui.actionPrint);
|
||||
printmenu->addAction(ui.actionPrintPreview);
|
||||
ui.printbutton->setMenu(printmenu);
|
||||
|
||||
#endif
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * ftheader = ui.forumTreeWidget->header () ;
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * ftheader = ui.forumTreeWidget->header () ;
|
||||
ftheader->setResizeMode (0, QHeaderView::Interactive);
|
||||
|
||||
|
||||
ftheader->resizeSection ( 0, 170 );
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * ttheader = ui.threadTreeWidget->header () ;
|
||||
ttheader->setResizeMode (0, QHeaderView::Interactive);
|
||||
|
||||
QHeaderView * ttheader = ui.threadTreeWidget->header () ;
|
||||
ttheader->setResizeMode (0, QHeaderView::Interactive);
|
||||
|
||||
ttheader->resizeSection ( 0, 170 );
|
||||
ttheader->resizeSection ( 1, 170 );
|
||||
|
||||
|
||||
|
||||
@ -230,7 +177,7 @@ void ForumsDialog::newmessage()
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void ForumsDialog::replytomessage()
|
||||
void ForumsDialog::replytomessage()
|
||||
{
|
||||
/* put msg on msgBoard, and switch to it. */
|
||||
|
||||
@ -276,7 +223,7 @@ void ForumsDialog::togglefileview()
|
||||
newSizeList.push_back(totalSize);
|
||||
newSizeList.push_back(0);
|
||||
ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
||||
ui.expandButton->setToolTip("Expand");
|
||||
ui.expandButton->setToolTip("Expand");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -285,8 +232,8 @@ void ForumsDialog::togglefileview()
|
||||
int nMsgSize = (totalSize / 2);
|
||||
newSizeList.push_back(nlistSize);
|
||||
newSizeList.push_back(nMsgSize);
|
||||
ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
||||
ui.expandButton->setToolTip("Hide");
|
||||
ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
||||
ui.expandButton->setToolTip("Hide");
|
||||
}
|
||||
|
||||
ui.msgSplitter->setSizes(newSizeList);
|
||||
|
@ -26,6 +26,29 @@
|
||||
|
||||
#include "rsiface/rsforums.h"
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QCloseEvent>
|
||||
#include <QColorDialog>
|
||||
#include <QClipboard>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QMenu>
|
||||
#include <QCursor>
|
||||
#include <QPoint>
|
||||
#include <QMouseEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QPixmap>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QHeaderView>
|
||||
#include <QTextCodec>
|
||||
#include <QTextEdit>
|
||||
#include <QTextCursor>
|
||||
#include <QTextList>
|
||||
#include <QTextStream>
|
||||
#include <QTextDocumentFragment>
|
||||
|
||||
/** Constructor */
|
||||
CreateForumMsg::CreateForumMsg(std::string fId, std::string pId)
|
||||
: QMainWindow(NULL), mForumId(fId), mParentId(pId)
|
||||
@ -33,13 +56,106 @@ CreateForumMsg::CreateForumMsg(std::string fId, std::string pId)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
RshareSettings config;
|
||||
RshareSettings config;
|
||||
config.loadWidgetInformation(this);
|
||||
|
||||
// connect up the buttons.
|
||||
connect( ui.postmessage_action, SIGNAL( triggered (bool) ), this, SLOT( createMsg( ) ) );
|
||||
connect( ui.close_action, SIGNAL( triggered (bool) ), this, SLOT( cancelMsg( ) ) );
|
||||
|
||||
connect(ui.boldbtn, SIGNAL(clicked()), this, SLOT(textBold()));
|
||||
connect(ui.underlinebtn, SIGNAL(clicked()), this, SLOT(textUnderline()));
|
||||
connect(ui.italicbtn, SIGNAL(clicked()), this, SLOT(textItalic()));
|
||||
connect(ui.colorbtn, SIGNAL(clicked()), this, SLOT(textColor()));
|
||||
|
||||
connect(ui.forumMessage, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
|
||||
this, SLOT(currentCharFormatChanged(const QTextCharFormat &)));
|
||||
connect(ui.forumMessage, SIGNAL(cursorPositionChanged()),
|
||||
this, SLOT(cursorPositionChanged()));
|
||||
|
||||
connect(ui.forumMessage->document(), SIGNAL(modificationChanged(bool)),
|
||||
actionSave, SLOT(setEnabled(bool)));
|
||||
connect(ui.forumMessage->document(), SIGNAL(modificationChanged(bool)),
|
||||
this, SLOT(setWindowModified(bool)));
|
||||
connect(ui.forumMessage->document(), SIGNAL(undoAvailable(bool)),
|
||||
actionUndo, SLOT(setEnabled(bool)));
|
||||
connect(ui.forumMessage->document(), SIGNAL(redoAvailable(bool)),
|
||||
actionRedo, SLOT(setEnabled(bool)));
|
||||
|
||||
setWindowModified(ui.forumMessage->document()->isModified());
|
||||
actionSave->setEnabled(ui.forumMessage->document()->isModified());
|
||||
actionUndo->setEnabled(ui.forumMessage->document()->isUndoAvailable());
|
||||
actionRedo->setEnabled(ui.forumMessage->document()->isRedoAvailable());
|
||||
|
||||
connect(actionUndo, SIGNAL(triggered()), ui.forumMessage, SLOT(undo()));
|
||||
connect(actionRedo, SIGNAL(triggered()), ui.forumMessage, SLOT(redo()));
|
||||
|
||||
actionCut->setEnabled(false);
|
||||
actionCopy->setEnabled(false);
|
||||
|
||||
connect(actionCut, SIGNAL(triggered()), ui.forumMessage, SLOT(cut()));
|
||||
connect(actionCopy, SIGNAL(triggered()), ui.forumMessage, SLOT(copy()));
|
||||
connect(actionPaste, SIGNAL(triggered()), ui.forumMessage, SLOT(paste()));
|
||||
|
||||
connect(ui.forumMessage, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
|
||||
connect(ui.forumMessage, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
|
||||
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
|
||||
|
||||
QActionGroup *grp = new QActionGroup(this);
|
||||
connect(grp, SIGNAL(triggered(QAction *)), this, SLOT(textAlign(QAction *)));
|
||||
|
||||
actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"), tr("&Left"), grp);
|
||||
actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
|
||||
actionAlignLeft->setCheckable(true);
|
||||
actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp);
|
||||
actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
|
||||
actionAlignCenter->setCheckable(true);
|
||||
actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp);
|
||||
actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
|
||||
actionAlignRight->setCheckable(true);
|
||||
actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp);
|
||||
actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
|
||||
actionAlignJustify->setCheckable(true);
|
||||
|
||||
ui.comboStyle->addItem("Standard");
|
||||
ui.comboStyle->addItem("Bullet List (Disc)");
|
||||
ui.comboStyle->addItem("Bullet List (Circle)");
|
||||
ui.comboStyle->addItem("Bullet List (Square)");
|
||||
ui.comboStyle->addItem("Ordered List (Decimal)");
|
||||
ui.comboStyle->addItem("Ordered List (Alpha lower)");
|
||||
ui.comboStyle->addItem("Ordered List (Alpha upper)");
|
||||
connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(textStyle(int)));
|
||||
|
||||
connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &)));
|
||||
|
||||
ui.comboSize->setEditable(true);
|
||||
|
||||
QFontDatabase db;
|
||||
foreach(int size, db.standardSizes())
|
||||
ui.comboSize->addItem(QString::number(size));
|
||||
|
||||
connect(ui.comboSize, SIGNAL(activated(const QString &)),this, SLOT(textSize(const QString &)));
|
||||
ui.comboSize->setCurrentIndex(ui.comboSize->findText(QString::number(QApplication::font().pointSize())));
|
||||
|
||||
ui.boldbtn->setIcon(QIcon(QString(":/images/textedit/textbold.png")));
|
||||
ui.underlinebtn->setIcon(QIcon(QString(":/images/textedit/textunder.png")));
|
||||
ui.italicbtn->setIcon(QIcon(QString(":/images/textedit/textitalic.png")));
|
||||
ui.textalignmentbtn->setIcon(QIcon(QString(":/images/textedit/textcenter.png")));
|
||||
//ui.actionContactsView->setIcon(QIcon(":/images/contacts24.png"));
|
||||
//ui.actionSaveas->setIcon(QIcon(":/images/save24.png"));
|
||||
|
||||
QMenu * alignmentmenu = new QMenu();
|
||||
alignmentmenu->addAction(actionAlignLeft);
|
||||
alignmentmenu->addAction(actionAlignCenter);
|
||||
alignmentmenu->addAction(actionAlignRight);
|
||||
alignmentmenu->addAction(actionAlignJustify);
|
||||
ui.textalignmentbtn->setMenu(alignmentmenu);
|
||||
|
||||
QPixmap pxm(24,24);
|
||||
pxm.fill(Qt::black);
|
||||
ui.colorbtn->setIcon(pxm);
|
||||
|
||||
newMsg();
|
||||
|
||||
}
|
||||
@ -101,7 +217,306 @@ void CreateForumMsg::cancelMsg()
|
||||
close();
|
||||
return;
|
||||
|
||||
RshareSettings config;
|
||||
RshareSettings config;
|
||||
config.saveWidgetInformation(this);
|
||||
}
|
||||
|
||||
void CreateForumMsg::textBold()
|
||||
{
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontWeight(ui.boldbtn->isChecked() ? QFont::Bold : QFont::Normal);
|
||||
mergeFormatOnWordOrSelection(fmt);
|
||||
}
|
||||
|
||||
void CreateForumMsg::textUnderline()
|
||||
{
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontUnderline(ui.underlinebtn->isChecked());
|
||||
mergeFormatOnWordOrSelection(fmt);
|
||||
}
|
||||
|
||||
void CreateForumMsg::textItalic()
|
||||
{
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontItalic(ui.italicbtn->isChecked());
|
||||
mergeFormatOnWordOrSelection(fmt);
|
||||
}
|
||||
|
||||
void CreateForumMsg::textFamily(const QString &f)
|
||||
{
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontFamily(f);
|
||||
mergeFormatOnWordOrSelection(fmt);
|
||||
}
|
||||
|
||||
void CreateForumMsg::textSize(const QString &p)
|
||||
{
|
||||
QTextCharFormat fmt;
|
||||
fmt.setFontPointSize(p.toFloat());
|
||||
mergeFormatOnWordOrSelection(fmt);
|
||||
}
|
||||
|
||||
void CreateForumMsg::textStyle(int styleIndex)
|
||||
{
|
||||
QTextCursor cursor = ui.forumMessage->textCursor();
|
||||
|
||||
if (styleIndex != 0) {
|
||||
QTextListFormat::Style style = QTextListFormat::ListDisc;
|
||||
|
||||
switch (styleIndex) {
|
||||
default:
|
||||
case 1:
|
||||
style = QTextListFormat::ListDisc;
|
||||
break;
|
||||
case 2:
|
||||
style = QTextListFormat::ListCircle;
|
||||
break;
|
||||
case 3:
|
||||
style = QTextListFormat::ListSquare;
|
||||
break;
|
||||
case 4:
|
||||
style = QTextListFormat::ListDecimal;
|
||||
break;
|
||||
case 5:
|
||||
style = QTextListFormat::ListLowerAlpha;
|
||||
break;
|
||||
case 6:
|
||||
style = QTextListFormat::ListUpperAlpha;
|
||||
break;
|
||||
}
|
||||
|
||||
cursor.beginEditBlock();
|
||||
|
||||
QTextBlockFormat blockFmt = cursor.blockFormat();
|
||||
|
||||
QTextListFormat listFmt;
|
||||
|
||||
if (cursor.currentList()) {
|
||||
listFmt = cursor.currentList()->format();
|
||||
} else {
|
||||
listFmt.setIndent(blockFmt.indent() + 1);
|
||||
blockFmt.setIndent(0);
|
||||
cursor.setBlockFormat(blockFmt);
|
||||
}
|
||||
|
||||
listFmt.setStyle(style);
|
||||
|
||||
cursor.createList(listFmt);
|
||||
|
||||
cursor.endEditBlock();
|
||||
} else {
|
||||
// ####
|
||||
QTextBlockFormat bfmt;
|
||||
bfmt.setObjectIndex(-1);
|
||||
cursor.mergeBlockFormat(bfmt);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumMsg::textColor()
|
||||
{
|
||||
QColor col = QColorDialog::getColor(ui.forumMessage->textColor(), this);
|
||||
if (!col.isValid())
|
||||
return;
|
||||
QTextCharFormat fmt;
|
||||
fmt.setForeground(col);
|
||||
mergeFormatOnWordOrSelection(fmt);
|
||||
colorChanged(col);
|
||||
}
|
||||
|
||||
void CreateForumMsg::textAlign(QAction *a)
|
||||
{
|
||||
if (a == actionAlignLeft)
|
||||
ui.forumMessage->setAlignment(Qt::AlignLeft);
|
||||
else if (a == actionAlignCenter)
|
||||
ui.forumMessage->setAlignment(Qt::AlignHCenter);
|
||||
else if (a == actionAlignRight)
|
||||
ui.forumMessage->setAlignment(Qt::AlignRight);
|
||||
else if (a == actionAlignJustify)
|
||||
ui.forumMessage->setAlignment(Qt::AlignJustify);
|
||||
}
|
||||
|
||||
void CreateForumMsg::currentCharFormatChanged(const QTextCharFormat &format)
|
||||
{
|
||||
fontChanged(format.font());
|
||||
colorChanged(format.foreground().color());
|
||||
}
|
||||
|
||||
void CreateForumMsg::cursorPositionChanged()
|
||||
{
|
||||
alignmentChanged(ui.forumMessage->alignment());
|
||||
}
|
||||
|
||||
void CreateForumMsg::mergeFormatOnWordOrSelection(const QTextCharFormat &format)
|
||||
{
|
||||
QTextCursor cursor = ui.forumMessage->textCursor();
|
||||
if (!cursor.hasSelection())
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
cursor.mergeCharFormat(format);
|
||||
ui.forumMessage->mergeCurrentCharFormat(format);
|
||||
}
|
||||
|
||||
void CreateForumMsg::fontChanged(const QFont &f)
|
||||
{
|
||||
ui.comboFont->setCurrentIndex(ui.comboFont->findText(QFontInfo(f).family()));
|
||||
ui.comboSize->setCurrentIndex(ui.comboSize->findText(QString::number(f.pointSize())));
|
||||
ui.boldbtn->setChecked(f.bold());
|
||||
ui.italicbtn->setChecked(f.italic());
|
||||
ui.underlinebtn->setChecked(f.underline());
|
||||
}
|
||||
|
||||
void CreateForumMsg::colorChanged(const QColor &c)
|
||||
{
|
||||
QPixmap pix(16, 16);
|
||||
pix.fill(c);
|
||||
ui.colorbtn->setIcon(pix);
|
||||
}
|
||||
|
||||
void CreateForumMsg::alignmentChanged(Qt::Alignment a)
|
||||
{
|
||||
if (a & Qt::AlignLeft) {
|
||||
actionAlignLeft->setChecked(true);
|
||||
} else if (a & Qt::AlignHCenter) {
|
||||
actionAlignCenter->setChecked(true);
|
||||
} else if (a & Qt::AlignRight) {
|
||||
actionAlignRight->setChecked(true);
|
||||
} else if (a & Qt::AlignJustify) {
|
||||
actionAlignJustify->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumMsg::clipboardDataChanged()
|
||||
{
|
||||
actionPaste->setEnabled(!QApplication::clipboard()->text().isEmpty());
|
||||
}
|
||||
|
||||
void CreateForumMsg::fileNew()
|
||||
{
|
||||
if (maybeSave()) {
|
||||
ui.forumMessage->clear();
|
||||
//setCurrentFileName(QString());
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumMsg::fileOpen()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName(this, tr("Open File..."),
|
||||
QString(), tr("HTML-Files (*.htm *.html);;All Files (*)"));
|
||||
if (!fn.isEmpty())
|
||||
load(fn);
|
||||
}
|
||||
|
||||
bool CreateForumMsg::fileSave()
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return fileSaveAs();
|
||||
|
||||
QFile file(fileName);
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
return false;
|
||||
QTextStream ts(&file);
|
||||
ts.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
ts << ui.forumMessage->document()->toHtml("UTF-8");
|
||||
ui.forumMessage->document()->setModified(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreateForumMsg::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("HTML-Files (*.htm *.html);;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
void CreateForumMsg::filePrint()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setFullPage(true);
|
||||
QPrintDialog *dlg = new QPrintDialog(&printer, this);
|
||||
if (ui.forumMessage->textCursor().hasSelection())
|
||||
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
||||
dlg->setWindowTitle(tr("Print Document"));
|
||||
if (dlg->exec() == QDialog::Accepted) {
|
||||
ui.forumMessage->print(&printer);
|
||||
}
|
||||
delete dlg;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*void TextEdit::filePrintPreview()
|
||||
{
|
||||
PrintPreview *preview = new PrintPreview(textEdit->document(), this);
|
||||
preview->setWindowModality(Qt::WindowModal);
|
||||
preview->setAttribute(Qt::WA_DeleteOnClose);
|
||||
preview->show();
|
||||
}*/
|
||||
|
||||
void CreateForumMsg::filePrintPdf()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",
|
||||
QString(), "*.pdf");
|
||||
if (!fileName.isEmpty()) {
|
||||
if (QFileInfo(fileName).suffix().isEmpty())
|
||||
fileName.append(".pdf");
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
printer.setOutputFileName(fileName);
|
||||
ui.forumMessage->document()->print(&printer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CreateForumMsg::setCurrentFileName(const QString &fileName)
|
||||
{
|
||||
this->fileName = fileName;
|
||||
ui.forumMessage->document()->setModified(false);
|
||||
|
||||
setWindowModified(false);
|
||||
}
|
||||
|
||||
bool CreateForumMsg::load(const QString &f)
|
||||
{
|
||||
if (!QFile::exists(f))
|
||||
return false;
|
||||
QFile file(f);
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
return false;
|
||||
|
||||
QByteArray data = file.readAll();
|
||||
QTextCodec *codec = Qt::codecForHtml(data);
|
||||
QString str = codec->toUnicode(data);
|
||||
if (Qt::mightBeRichText(str)) {
|
||||
ui.forumMessage->setHtml(str);
|
||||
} else {
|
||||
str = QString::fromLocal8Bit(data);
|
||||
ui.forumMessage->setPlainText(str);
|
||||
}
|
||||
|
||||
setCurrentFileName(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CreateForumMsg::maybeSave()
|
||||
{
|
||||
if (!ui.forumMessage->document()->isModified())
|
||||
return true;
|
||||
if (fileName.startsWith(QLatin1String(":/")))
|
||||
return true;
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("Save Message"),
|
||||
tr("Forum Message has not been Sent.\n"
|
||||
"Do you want to save forum message ?"),
|
||||
QMessageBox::Save | QMessageBox::Discard
|
||||
| QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Save)
|
||||
return fileSave();
|
||||
else if (ret == QMessageBox::Cancel)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,12 @@
|
||||
|
||||
#include "ui_CreateForumMsg.h"
|
||||
|
||||
class QAction;
|
||||
class QComboBox;
|
||||
class QFontComboBox;
|
||||
class QTextEdit;
|
||||
class QTextCharFormat;
|
||||
|
||||
class CreateForumMsg : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -35,18 +41,67 @@ class CreateForumMsg : public QMainWindow
|
||||
public:
|
||||
CreateForumMsg(std::string fId, std::string pId);
|
||||
|
||||
void newMsg(); /* cleanup */
|
||||
void newMsg(); /* cleanup */
|
||||
|
||||
private slots:
|
||||
|
||||
/* actions to take.... */
|
||||
void createMsg();
|
||||
void cancelMsg();
|
||||
void createMsg();
|
||||
void cancelMsg();
|
||||
|
||||
void fileNew();
|
||||
void fileOpen();
|
||||
bool fileSave();
|
||||
bool fileSaveAs();
|
||||
void filePrint();
|
||||
|
||||
//void filePrintPreview();
|
||||
void filePrintPdf();
|
||||
|
||||
void textBold();
|
||||
void textUnderline();
|
||||
void textItalic();
|
||||
void textFamily(const QString &f);
|
||||
void textSize(const QString &p);
|
||||
void textStyle(int styleIndex);
|
||||
void textColor();
|
||||
void textAlign(QAction *a);
|
||||
|
||||
void currentCharFormatChanged(const QTextCharFormat &format);
|
||||
void cursorPositionChanged();
|
||||
|
||||
void clipboardDataChanged();
|
||||
|
||||
private:
|
||||
|
||||
std::string mForumId;
|
||||
std::string mParentId;
|
||||
std::string mForumId;
|
||||
std::string mParentId;
|
||||
|
||||
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
|
||||
void fontChanged(const QFont &f);
|
||||
void colorChanged(const QColor &c);
|
||||
void alignmentChanged(Qt::Alignment a);
|
||||
|
||||
bool load(const QString &f);
|
||||
bool maybeSave();
|
||||
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
|
||||
|
||||
QAction *actionSave,
|
||||
*actionAlignLeft,
|
||||
*actionAlignCenter,
|
||||
*actionAlignRight,
|
||||
*actionAlignJustify,
|
||||
*actionUndo,
|
||||
*actionRedo,
|
||||
*actionCut,
|
||||
*actionCopy,
|
||||
*actionPaste;
|
||||
|
||||
QString fileName;
|
||||
|
||||
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::CreateForumMsg ui;
|
||||
|
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>441</width>
|
||||
<height>353</height>
|
||||
<width>533</width>
|
||||
<height>398</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
@ -21,75 +21,220 @@
|
||||
<widget class="QWidget" name="centralwidget" >
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Forum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="forumName" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Forum</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Forum Post Subject</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="forumSubject" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>Forum Post</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="signBox" >
|
||||
<property name="text" >
|
||||
<string>Sign Message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="forumMessage" />
|
||||
<widget class="QLineEdit" name="forumName" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Forum Post Subject</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="forumSubject" />
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string>Forum Post</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="signBox" >
|
||||
<property name="text" >
|
||||
<string>Sign Message</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QComboBox" name="comboStyle" />
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QFontComboBox" name="comboFont" />
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<widget class="QComboBox" name="comboSize" >
|
||||
<property name="toolTip" >
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" >
|
||||
<widget class="QPushButton" name="boldbtn" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Bold</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4" >
|
||||
<widget class="QPushButton" name="underlinebtn" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Underline</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5" >
|
||||
<widget class="QPushButton" name="italicbtn" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Italic</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6" >
|
||||
<widget class="QPushButton" name="colorbtn" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Color</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7" >
|
||||
<widget class="QPushButton" name="textalignmentbtn" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Alignment</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QTextEdit" name="forumMessage" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar" >
|
||||
@ -105,6 +250,16 @@
|
||||
<addaction name="postmessage_action" />
|
||||
<addaction name="close_action" />
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>533</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<action name="postmessage_action" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../images.qrc" >:/images/mail_send24.png</iconset>
|
||||
|
Loading…
Reference in New Issue
Block a user