Added Print Button

Added Print Feature to MessagesDialog
Added Print Preview Feature

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@422 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2008-03-26 14:22:51 +00:00
parent 048e84630e
commit 8079660291
8 changed files with 519 additions and 61 deletions

View file

@ -23,7 +23,7 @@
#include "MessagesDialog.h"
#include "msgs/ChanMsgDialog.h"
#include "gui/toaster/MessageToaster.h"
#include "util/printpreview.h"
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
@ -36,6 +36,8 @@
#include <QPoint>
#include <QMouseEvent>
#include <QPixmap>
#include <QPrintDialog>
#include <QPrinter>
#include <QDateTime>
#include <QHeaderView>
@ -62,6 +64,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
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.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
@ -92,6 +97,19 @@ MessagesDialog::MessagesDialog(QWidget *parent)
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);
/* Hide platform specific features */
@ -621,4 +639,26 @@ void MessagesDialog::markMsgAsRead()
return;
}
void MessagesDialog::print()
{
#ifndef QT_NO_PRINTER
QPrinter printer(QPrinter::HighResolution);
printer.setFullPage(true);
QPrintDialog *dlg = new QPrintDialog(&printer, this);
if (ui.msgText->textCursor().hasSelection())
dlg->addEnabledOption(QAbstractPrintDialog::PrintSelection);
dlg->setWindowTitle(tr("Print Document"));
if (dlg->exec() == QDialog::Accepted) {
ui.msgText->print(&printer);
}
delete dlg;
#endif
}
void MessagesDialog::printpreview()
{
PrintPreview *preview = new PrintPreview(ui.msgText->document(), this);
preview->setWindowModality(Qt::WindowModal);
preview->setAttribute(Qt::WA_DeleteOnClose);
preview->show();
}

View file

@ -53,6 +53,8 @@ void updateMessages ( QTreeWidgetItem * item, int column );
void newmessage();
void replytomessage();
void print();
void printpreview();
void removemessage();
void markMsgAsRead();

View file

@ -509,14 +509,14 @@
<widget class="QPushButton" name="newmessageButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip" >
@ -526,20 +526,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">New Message&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>QPushButton
{
border-image: url(:/images/folder-draft24.png);
}
QPushButton:hover
{
border-image: url(:/images/folder-draft24-hover.png);
}
QPushButton:pressed
{
border-image: url(:/images/folder-draft24-pressed.png);
}
</string>
<string/>
</property>
<property name="text" >
<string/>
@ -559,14 +546,14 @@ border-image: url(:/images/folder-draft24-pressed.png);
<widget class="QPushButton" name="replymessageButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip" >
@ -576,22 +563,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">reply to selected message&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>
QPushButton
{
border-image: url(:/images/replymail24.png);
}
QPushButton:hover
{
border-image: url(:/images/replymail24-hover.png);
}
QPushButton:pressed
{
border-image: url(:/images/replymail-pressed.png);
}
</string>
<string/>
</property>
<property name="text" >
<string/>
@ -608,14 +580,14 @@ border-image: url(:/images/replymail-pressed.png);
<widget class="QPushButton" name="removemessageButton" >
<property name="minimumSize" >
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip" >
@ -625,20 +597,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">remove selected message&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>QPushButton
{
border-image: url(:/images/deletemail24.png);
}
QPushButton:hover
{
border-image: url(:/images/deletemail-hover.png);
}
QPushButton:pressed
{
border-image: url(:/images/deletemail-pressed.png);
}</string>
<string/>
</property>
<property name="text" >
<string/>
@ -652,19 +611,50 @@ border-image: url(:/images/deletemail-pressed.png);
</widget>
</item>
<item row="0" column="3" >
<widget class="QPushButton" name="printbutton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="text" >
<string/>
</property>
<property name="iconSize" >
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="0" column="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
<width>571</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="4" >
<item row="1" column="0" colspan="5" >
<widget class="QSplitter" name="splitter_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@ -1180,6 +1170,16 @@ p, li { white-space: pre-wrap; }
</widget>
</item>
</layout>
<action name="actionPrint" >
<property name="text" >
<string>Print</string>
</property>
</action>
<action name="actionPrintPreview" >
<property name="text" >
<string>PrintPreview</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>newmessageButton</tabstop>

View file

@ -155,6 +155,7 @@
<file>images/peerdetails_16x16.png</file>
<file>images/peers_16x16.png</file>
<file>images/peers_24x24.png</file>
<file>images/print24.png</file>
<file>images/removefriend16.png</file>
<file>images/replymail-pressed.png</file>
<file>images/replymail24-hover.png</file>
@ -192,6 +193,8 @@
<file>images/textedit/fileopen.png</file>
<file>images/textedit/fileprint.png</file>
<file>images/textedit/filesave.png</file>
<file>images/textedit/zoomin.png</file>
<file>images/textedit/zoomout.png</file>
<file>images/toaster/chat.png</file>
<file>images/toaster/hangup.png</file>
<file>images/toaster/pickup.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB