save and load ToolButtonStyles

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2122 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-01-25 12:44:12 +00:00
parent b8c2367c41
commit c86196e8fa
2 changed files with 94 additions and 4 deletions

View File

@ -62,6 +62,9 @@ MessagesDialog::MessagesDialog(QWidget *parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Create RshareSettings object */
_settings = new RshareSettings();
connect( ui.msgWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messageslistWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.msgList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( msgfilelistWidgetCostumPopupMenu( QPoint ) ) );
@ -133,6 +136,8 @@ MessagesDialog::MessagesDialog(QWidget *parent)
ui.msgWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui.msgWidget->sortItems( 3, Qt::DescendingOrder );
loadToolButtonsettings();
/* Hide platform specific features */
@ -1000,6 +1005,8 @@ void MessagesDialog::setCurrentFileName(const QString &fileName)
void MessagesDialog::buttonsicononly()
{
_settings->beginGroup("MessageDialog");
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
@ -1007,10 +1014,22 @@ void MessagesDialog::buttonsicononly()
ui.forwardmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.printbutton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
_settings->setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle());
_settings->endGroup();
}
void MessagesDialog::buttonstextbesideicon()
{
_settings->beginGroup("MessageDialog");
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@ -1018,11 +1037,23 @@ void MessagesDialog::buttonstextbesideicon()
ui.forwardmessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
_settings->setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle());
_settings->endGroup();
}
void MessagesDialog::buttonstextundericon()
{
_settings->beginGroup("MessageDialog");
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
@ -1031,4 +1062,56 @@ void MessagesDialog::buttonstextundericon()
ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
}
_settings->setValue("ToolButon_Stlye1",ui.newmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye2",ui.removemessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye3",ui.replymessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye4",ui.replyallmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye5",ui.forwardmessageButton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye6",ui.printbutton->toolButtonStyle());
_settings->setValue("ToolButon_Stlye7",ui.viewtoolButton->toolButtonStyle());
_settings->endGroup();
}
void MessagesDialog::loadToolButtonsettings()
{
_settings->beginGroup("MessageDialog");
if(_settings->value("ToolButon_Stlye1","0").toInt() == 0)
{
qDebug() << "ToolButon IconOnly";
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.replyallmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.forwardmessageButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.printbutton->setToolButtonStyle(Qt::ToolButtonIconOnly);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
}
else if (_settings->value("ToolButon_Stlye1","2").toInt() ==2)
{
qDebug() << "ToolButon TextBesideIcon";
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.replyallmessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.forwardmessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
}
else if(_settings->value("ToolButon_Stlye1","3").toInt() ==3)
{
qDebug() << "ToolButton TextUnderIcon";
ui.newmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.removemessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.replymessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.replyallmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.forwardmessageButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.printbutton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
ui.viewtoolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
}
_settings->endGroup();
}

View File

@ -22,6 +22,8 @@
#ifndef _MESSAGESDIALOG_H
#define _MESSAGESDIALOG_H
#include "settings/rsharesettings.h"
#include <QFileDialog>
#include "mainpage.h"
@ -35,11 +37,12 @@ public:
/** Default Constructor */
MessagesDialog(QWidget *parent = 0);
/** Default Destructor */
void insertMsgTxtAndFiles();
virtual void keyPressEvent(QKeyEvent *) ;
void insertMsgTxtAndFiles();
virtual void keyPressEvent(QKeyEvent *) ;
public slots:
void insertMessages();
void insertMessages();
private slots:
/** Create the context popup menu and it's submenus */
@ -74,8 +77,12 @@ private slots:
void buttonstextbesideicon();
void buttonsicononly();
void buttonstextundericon();
void loadToolButtonsettings();
private:
/** A RetroShare Settings object used for saving/loading settings */
RshareSettings *_settings;
bool getCurrentMsg(std::string &cid, std::string &mid);
void setMsgAsRead(QTreeWidgetItem *);