mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-24 22:30:42 -04:00
New dialog for defining own colors for the private chat window.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4150 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
eed8ccd1df
commit
0fbde70e32
16 changed files with 1957 additions and 934 deletions
|
@ -104,7 +104,7 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
|||
peerStatus = 0;
|
||||
|
||||
last_status_send_time = 0 ;
|
||||
style.setStyleFromSettings(ChatStyle::TYPE_PRIVATE);
|
||||
chatStyle.setStyleFromSettings(ChatStyle::TYPE_PRIVATE);
|
||||
|
||||
/* Hide or show the frames */
|
||||
showAvatarFrame(PeerSettings->getShowAvatarFrame(dialogId));
|
||||
|
@ -169,6 +169,9 @@ PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWi
|
|||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
// load style
|
||||
PeerSettings->getStyle(dialogId, "PopupChatDialog", style);
|
||||
|
||||
// initialize first status
|
||||
StatusInfo peerStatusInfo;
|
||||
// No check of return value. Non existing status info is handled as offline.
|
||||
|
@ -643,7 +646,7 @@ void PopupChatDialog::addChatMsg(bool incoming, const std::string &id, const QSt
|
|||
type = incoming ? ChatStyle::FORMATMSG_INCOMING : ChatStyle::FORMATMSG_OUTGOING;
|
||||
}
|
||||
|
||||
QString formatMsg = style.formatMessage(type, name, recvTime, message, formatFlag);
|
||||
QString formatMsg = chatStyle.formatMessage(type, name, recvTime, message, formatFlag);
|
||||
|
||||
if (addToHistory) {
|
||||
historyKeeper.addMessage(incoming, id, name, sendTime, recvTime, message);
|
||||
|
@ -762,7 +765,7 @@ void PopupChatDialog::on_closeInfoFrameButton_clicked()
|
|||
void PopupChatDialog::setColor()
|
||||
{
|
||||
bool ok;
|
||||
QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, this);
|
||||
QRgb color = QColorDialog::getRgba(ui.chattextEdit->textColor().rgba(), &ok, window());
|
||||
if (ok) {
|
||||
mCurrentColor = QColor(color);
|
||||
PeerSettings->setPrivateChatColor(dialogId, mCurrentColor.name());
|
||||
|
@ -910,32 +913,32 @@ void PopupChatDialog::addExtraPicture()
|
|||
{
|
||||
// select a picture file
|
||||
QString file;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg)", file)) {
|
||||
if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg)", file)) {
|
||||
addAttachment(file.toUtf8().constData(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::addAttachment(std::string filePath,int flag)
|
||||
{
|
||||
/* add a AttachFileItem to the attachment section */
|
||||
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
||||
std::cerr << std::endl;
|
||||
/* add a AttachFileItem to the attachment section */
|
||||
std::cerr << "PopupChatDialog::addExtraFile() hashing file.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
/* add widget in for new destination */
|
||||
AttachFileItem *file = new AttachFileItem(filePath);
|
||||
//file->
|
||||
|
||||
if(flag==1)
|
||||
file->setPicFlag(1);
|
||||
/* add widget in for new destination */
|
||||
AttachFileItem *file = new AttachFileItem(filePath);
|
||||
//file->
|
||||
|
||||
ui.vboxLayout->addWidget(file, 1, 0);
|
||||
if(flag==1)
|
||||
file->setPicFlag(1);
|
||||
|
||||
//when the file is local or is finished hashing, call the fileHashingFinished method to send a chat message
|
||||
if (file->getState() == AFI_STATE_LOCAL) {
|
||||
ui.vboxLayout->addWidget(file, 1, 0);
|
||||
|
||||
//when the file is local or is finished hashing, call the fileHashingFinished method to send a chat message
|
||||
if (file->getState() == AFI_STATE_LOCAL) {
|
||||
fileHashingFinished(file);
|
||||
} else {
|
||||
} else {
|
||||
QObject::connect(file,SIGNAL(fileFinished(AttachFileItem *)), SLOT(fileHashingFinished(AttachFileItem *))) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::fileHashingFinished(AttachFileItem* file)
|
||||
|
@ -1120,7 +1123,7 @@ bool PopupChatDialog::fileSave()
|
|||
bool PopupChatDialog::fileSaveAs()
|
||||
{
|
||||
QString fn;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_HISTORY, tr("Save as..."), tr("Text File (*.txt );;All Files (*)"), fn)) {
|
||||
if (misc::getSaveFileName(window(), RshareSettings::LASTDIR_HISTORY, tr("Save as..."), tr("Text File (*.txt );;All Files (*)"), fn)) {
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
@ -1248,6 +1251,21 @@ void PopupChatDialog::updatePeersCustomStateString(const QString& peer_id, const
|
|||
|
||||
void PopupChatDialog::on_actionMessageHistory_triggered()
|
||||
{
|
||||
ImHistoryBrowser imBrowser(dialogId, historyKeeper, ui.chattextEdit, this);
|
||||
ImHistoryBrowser imBrowser(dialogId, historyKeeper, ui.chattextEdit, window());
|
||||
imBrowser.exec();
|
||||
}
|
||||
|
||||
bool PopupChatDialog::setStyle()
|
||||
{
|
||||
if (style.showDialog(window())) {
|
||||
PeerSettings->setStyle(dialogId, "PopupChatDialog", style);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const RSStyle &PopupChatDialog::getStyle()
|
||||
{
|
||||
return style;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ class ChatInfo;
|
|||
#include <retroshare/rsmsgs.h>
|
||||
#include "gui/im_history/IMHistoryKeeper.h"
|
||||
#include "ChatStyle.h"
|
||||
#include "gui/style/RSStyle.h"
|
||||
|
||||
class PopupChatDialog : public QWidget
|
||||
{
|
||||
|
@ -59,6 +60,8 @@ public:
|
|||
int getPeerStatus() { return peerStatus; }
|
||||
void focusDialog();
|
||||
void activate();
|
||||
bool setStyle();
|
||||
const RSStyle &getStyle();
|
||||
|
||||
public slots:
|
||||
void updateStatus(const QString &peer_id, int status);
|
||||
|
@ -144,9 +147,11 @@ private:
|
|||
bool typing;
|
||||
int peerStatus;
|
||||
IMHistoryKeeper historyKeeper;
|
||||
ChatStyle style;
|
||||
ChatStyle chatStyle;
|
||||
bool m_manualDelete;
|
||||
|
||||
RSStyle style;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::PopupChatDialog ui;
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,6 +28,7 @@
|
|||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include "gui/style/RSStyle.h"
|
||||
#include"util/misc.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
@ -83,6 +84,7 @@ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WFlags flags)
|
|||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
connect(ui.actionAvatar, SIGNAL(triggered()),this, SLOT(getAvatar()));
|
||||
connect(ui.actionColor, SIGNAL(triggered()), this, SLOT(setStyle()));
|
||||
connect(ui.actionDockTab, SIGNAL(triggered()), this, SLOT(dockTab()));
|
||||
connect(ui.actionUndockTab, SIGNAL(triggered()), this, SLOT(undockTab()));
|
||||
|
||||
|
@ -120,18 +122,21 @@ void PopupChatWindow::showEvent(QShowEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
PopupChatDialog *PopupChatWindow::getCurrentDialog()
|
||||
{
|
||||
if (tabbedWindow) {
|
||||
return dynamic_cast<PopupChatDialog*>(ui.tabWidget->currentWidget());
|
||||
}
|
||||
|
||||
return chatDialog;
|
||||
}
|
||||
|
||||
void PopupChatWindow::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ActivationChange) {
|
||||
if (tabbedWindow) {
|
||||
PopupChatDialog *pcd = dynamic_cast<PopupChatDialog*>(ui.tabWidget->currentWidget());
|
||||
if (pcd) {
|
||||
pcd->activate();
|
||||
}
|
||||
} else {
|
||||
if (chatDialog) {
|
||||
chatDialog->activate();
|
||||
}
|
||||
PopupChatDialog *pcd = getCurrentDialog();
|
||||
if (pcd) {
|
||||
pcd->activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,6 +149,7 @@ void PopupChatWindow::addDialog(PopupChatDialog *dialog)
|
|||
ui.horizontalLayout->addWidget(dialog);
|
||||
peerId = dialog->getPeerId();
|
||||
chatDialog = dialog;
|
||||
calculateStyle(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,6 +303,7 @@ void PopupChatWindow::tabCurrentChanged(int tab)
|
|||
|
||||
if (pcd) {
|
||||
pcd->activate();
|
||||
calculateStyle(pcd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,3 +336,35 @@ void PopupChatWindow::undockTab()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatWindow::setStyle()
|
||||
{
|
||||
PopupChatDialog *pcd = getCurrentDialog();
|
||||
|
||||
if (pcd && pcd->setStyle()) {
|
||||
calculateStyle(pcd);
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatWindow::calculateStyle(PopupChatDialog *dialog)
|
||||
{
|
||||
QString toolSheet;
|
||||
QString statusSheet;
|
||||
QString widgetSheet;
|
||||
|
||||
if (dialog) {
|
||||
const RSStyle &style = dialog->getStyle();
|
||||
|
||||
QString styleSheet = style.getStyleSheet();
|
||||
|
||||
if (styleSheet.isEmpty() == false) {
|
||||
toolSheet = QString("QToolBar{%1}").arg(styleSheet);
|
||||
statusSheet = QString(".QStatusBar{%1}").arg(styleSheet);
|
||||
widgetSheet = QString(".QWidget{%1}").arg(styleSheet);
|
||||
}
|
||||
}
|
||||
|
||||
ui.chattoolBar->setStyleSheet(toolSheet);
|
||||
ui.chatstatusbar->setStyleSheet(statusSheet);
|
||||
ui.chatcentralwidget->setStyleSheet(widgetSheet);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ private slots:
|
|||
void tabCurrentChanged(int tab);
|
||||
void dockTab();
|
||||
void undockTab();
|
||||
void setStyle();
|
||||
|
||||
private:
|
||||
bool tabbedWindow;
|
||||
|
@ -65,6 +66,9 @@ private:
|
|||
std::string peerId;
|
||||
PopupChatDialog *chatDialog;
|
||||
|
||||
PopupChatDialog *getCurrentDialog();
|
||||
void calculateStyle(PopupChatDialog *dialog);
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::PopupChatWindow ui;
|
||||
};
|
||||
|
|
|
@ -23,32 +23,16 @@
|
|||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -82,6 +66,7 @@
|
|||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionAvatar"/>
|
||||
<addaction name="actionColor"/>
|
||||
<addaction name="actionDockTab"/>
|
||||
<addaction name="actionUndockTab"/>
|
||||
</widget>
|
||||
|
@ -121,6 +106,18 @@
|
|||
<string>Undock tab</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionColor">
|
||||
<property name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/highlight.png</normaloff>:/images/highlight.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set Chat Window Color</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set Chat Window Color</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue