Fixed Buttons layout,

Added save as, print, printpreview to context menu

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2112 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-01-22 19:23:12 +00:00
parent 51c2e5b642
commit acca7d5c90
3 changed files with 59 additions and 8 deletions

View file

@ -35,7 +35,6 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>
#include <QCursor> #include <QCursor>
@ -87,7 +86,7 @@ MessagesDialog::MessagesDialog(QWidget *parent)
connect(ui.actionIconOnly, SIGNAL(triggered()), this, SLOT(buttonsicononly())); connect(ui.actionIconOnly, SIGNAL(triggered()), this, SLOT(buttonsicononly()));
connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonstextundericon())); connect(ui.actionTextUnderIcon, SIGNAL(triggered()), this, SLOT(buttonstextundericon()));
connect(ui.actionSave_as, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
mCurrCertId = ""; mCurrCertId = "";
mCurrMsgId = ""; mCurrMsgId = "";
@ -192,7 +191,10 @@ void MessagesDialog::messageslistWidgetCostumPopupMenu( QPoint point )
connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) ); connect( removemsgAct , SIGNAL( triggered() ), this, SLOT( removemessage() ) );
contextMnu.addAction( removemsgAct); contextMnu.addAction( removemsgAct);
} }
contextMnu.addAction( ui.actionSave_as);
contextMnu.addAction( ui.actionPrintPreview);
contextMnu.addAction( ui.actionPrint);
contextMnu.addSeparator();
contextMnu.addAction( newmsgAct); contextMnu.addAction( newmsgAct);
contextMnu.exec( mevent->globalPos() ); contextMnu.exec( mevent->globalPos() );
} }
@ -963,6 +965,39 @@ void MessagesDialog::anchorClicked (const QUrl& link )
} }
} }
bool MessagesDialog::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.msgText->document()->toHtml("UTF-8");
ui.msgText->document()->setModified(false);
return true;
}
bool MessagesDialog::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 MessagesDialog::setCurrentFileName(const QString &fileName)
{
this->fileName = fileName;
ui.msgText->document()->setModified(false);
setWindowModified(false);
}
void MessagesDialog::buttonsicononly() void MessagesDialog::buttonsicononly()
{ {
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly); ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);

View file

@ -58,6 +58,9 @@ private slots:
void print(); void print();
void printpreview(); void printpreview();
bool fileSave();
bool fileSaveAs();
void removemessage(); void removemessage();
void anchorClicked (const QUrl &); void anchorClicked (const QUrl &);
@ -77,6 +80,8 @@ private:
bool getCurrentMsg(std::string &cid, std::string &mid); bool getCurrentMsg(std::string &cid, std::string &mid);
void setMsgAsRead(QTreeWidgetItem *); void setMsgAsRead(QTreeWidgetItem *);
void setCurrentFileName(const QString &fileName);
std::string mCurrCertId; std::string mCurrCertId;
std::string mCurrMsgId; std::string mCurrMsgId;
@ -93,6 +98,9 @@ private:
QAction* getRecAct; QAction* getRecAct;
QAction* getAllRecAct; QAction* getAllRecAct;
QString fileName;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::MessagesDialog ui; Ui::MessagesDialog ui;
}; };

View file

@ -550,7 +550,7 @@ border: 1px solid #CCCCCC;}</string>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QToolButton" name="replymessageButton"> <widget class="QToolButton" name="replymessageButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -772,7 +772,7 @@ p, li { white-space: pre-wrap; }
<item row="0" column="7"> <item row="0" column="7">
<widget class="QToolButton" name="printbutton"> <widget class="QToolButton" name="printbutton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -816,7 +816,7 @@ p, li { white-space: pre-wrap; }
<item row="0" column="8"> <item row="0" column="8">
<widget class="QToolButton" name="viewtoolButton"> <widget class="QToolButton" name="viewtoolButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -1388,7 +1388,10 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
<action name="actionPrint"> <action name="actionPrint">
<property name="text"> <property name="text">
<string>Print</string> <string>Print...</string>
</property>
<property name="toolTip">
<string>Print...</string>
</property> </property>
</action> </action>
<action name="actionPrintPreview"> <action name="actionPrintPreview">
@ -1420,6 +1423,11 @@ p, li { white-space: pre-wrap; }
<string>Set Text Under Icon</string> <string>Set Text Under Icon</string>
</property> </property>
</action> </action>
<action name="actionSave_as">
<property name="text">
<string>Save As...</string>
</property>
</action>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>newmessageButton</tabstop> <tabstop>newmessageButton</tabstop>