Added a "More" actions button for some needed actions

* Added a "More" actions button for some needed actions
* Added actions back for Save, Print.. , View Source & Button style
This commit is contained in:
defnax 2020-02-27 01:04:44 +01:00
parent 54a0319f33
commit 7569517193
3 changed files with 112 additions and 1 deletions

View File

@ -28,6 +28,8 @@
#include <QTextStream>
#include <QTextCodec>
#include <QDesktopServices>
#include <QPlainTextEdit>
#include <QDialog>
#include "gui/notifyqt.h"
#include "gui/RetroShareLink.h"
@ -131,6 +133,9 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
isWindow = false;
currMsgFlags = 0;
ui.actionTextBesideIcon->setData(Qt::ToolButtonTextBesideIcon);
ui.actionIconOnly->setData(Qt::ToolButtonIconOnly);
connect(ui.msgList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(msgfilelistWidgetCostumPopupMenu(QPoint)));
connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
@ -141,6 +146,16 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
connect(ui.replyallButton, SIGNAL(clicked()), this, SLOT(replyAll()));
connect(ui.forwardButton, SIGNAL(clicked()), this, SLOT(forward()));
connect(ui.deleteButton, SIGNAL(clicked()), this, SLOT(remove()));
connect(ui.actionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));
connect(ui.actionPrint, SIGNAL(triggered()), this, SLOT(print()));
connect(ui.actionPrintPreview, SIGNAL(triggered()), this, SLOT(printPreview()));
connect(ui.actionIconOnly, SIGNAL(triggered()), this, SLOT(buttonStyle()));
connect(ui.actionTextBesideIcon, SIGNAL(triggered()), this, SLOT(buttonStyle()));
QAction *viewsource = new QAction(tr("View source"), this);
viewsource->setShortcut(QKeySequence("CTRL+O"));
connect(viewsource, SIGNAL(triggered()), this, SLOT(viewSource()));
connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged()));
@ -162,6 +177,16 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WindowFlags f
msglheader->resizeSection (COLUMN_FILE_SIZE, 100);
msglheader->resizeSection (COLUMN_FILE_HASH, 200);
QMenu *moremenu = new QMenu();
moremenu->addAction(viewsource);
moremenu->addAction(ui.actionSaveAs);
moremenu->addAction(ui.actionPrint);
moremenu->addAction(ui.actionPrintPreview);
moremenu->addSeparator();
moremenu->addAction(ui.actionTextBesideIcon);
moremenu->addAction(ui.actionIconOnly);
ui.moreButton->setMenu(moremenu);
QFont font = QFont("Arial", 10, QFont::Bold);
ui.subjectText->setFont(font);
@ -260,11 +285,18 @@ void MessageWidget::processSettings(const QString &settingsGroup, bool load)
ui.expandFilesButton->setChecked(value);
ui.msgList->setVisible(value);
togglefileview();
// toolbar button style
Qt::ToolButtonStyle style = (Qt::ToolButtonStyle) Settings->value("ToolButon_Style", Qt::ToolButtonTextBesideIcon).toInt();
setToolbarButtonStyle(style);
} else {
// save settings
// expandFiles
Settings->setValue("expandFiles", ui.expandFilesButton->isChecked());
//toolbar button style
Settings->setValue("ToolButon_Style", ui.replyButton->toolButtonStyle());
}
Settings->endGroup();
@ -801,3 +833,34 @@ void MessageWidget::sendInvite()
//}
}
void MessageWidget::setToolbarButtonStyle(Qt::ToolButtonStyle style)
{
ui.deleteButton->setToolButtonStyle(style);
ui.replyButton->setToolButtonStyle(style);
ui.replyallButton->setToolButtonStyle(style);
ui.forwardButton->setToolButtonStyle(style);
ui.moreButton->setToolButtonStyle(style);
}
void MessageWidget::buttonStyle()
{
setToolbarButtonStyle((Qt::ToolButtonStyle) dynamic_cast<QAction*>(sender())->data().toInt());
}
void MessageWidget::viewSource()
{
QDialog *dialog = new QDialog(this);
QPlainTextEdit *pte = new QPlainTextEdit(dialog);
pte->setPlainText( ui.msgText->toHtml() );
QGridLayout *gl = new QGridLayout(dialog);
gl->addWidget(pte,0,0,1,1);
dialog->setWindowTitle(tr("Document source"));
dialog->resize(500, 400);
dialog->exec();
ui.msgText->setHtml(pte->toPlainText());
delete dialog;
}

View File

@ -82,10 +82,13 @@ private slots:
void anchorClicked(const QUrl &url);
void loadImagesAlways();
void buttonStyle();
void viewSource();
private:
void clearTagLabels();
void showTagLabels();
void setToolbarButtonStyle(Qt::ToolButtonStyle style);
bool isControlled;
bool isWindow;

View File

@ -256,6 +256,38 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="moreButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;More actions&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>More</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/options2.png</normaloff>:/icons/png/options2.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1" colspan="3">
@ -719,7 +751,7 @@
<string>Print</string>
</property>
</action>
<action name="actionPrint_Preview">
<action name="actionPrintPreview">
<property name="text">
<string>Print Preview</string>
</property>
@ -729,6 +761,19 @@
<string>Save as</string>
</property>
</action>
<action name="actionTextBesideIcon">
<property name="text">
<string>Buttons Text Beside Icon</string>
</property>
<property name="toolTip">
<string>Buttons Text Beside Icon</string>
</property>
</action>
<action name="actionIconOnly">
<property name="text">
<string>Buttons Icon only</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>