2010-11-15 15:49:24 -05:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006, crypton
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-01-17 15:36:36 -05:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2010-11-15 15:49:24 -05:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include <QPixmap>
|
2012-01-27 09:49:48 -05:00
|
|
|
#include <QCloseEvent>
|
2010-11-15 15:49:24 -05:00
|
|
|
|
|
|
|
#include "PopupChatWindow.h"
|
2012-01-17 15:36:36 -05:00
|
|
|
#include "ChatDialog.h"
|
2010-11-15 15:49:24 -05:00
|
|
|
#include "gui/settings/rsharesettings.h"
|
|
|
|
#include "gui/settings/RsharePeerSettings.h"
|
|
|
|
#include "gui/common/StatusDefs.h"
|
2011-04-09 18:52:52 -04:00
|
|
|
#include "gui/style/RSStyle.h"
|
2012-10-25 14:06:33 -04:00
|
|
|
#include "util/misc.h"
|
|
|
|
#include "rshare.h"
|
2010-11-15 15:49:24 -05:00
|
|
|
|
|
|
|
#include <retroshare/rsmsgs.h>
|
|
|
|
#include <retroshare/rsnotify.h>
|
|
|
|
|
2014-07-24 19:26:04 -04:00
|
|
|
|
2014-11-02 08:20:48 -05:00
|
|
|
#define IMAGE_TYPING ":/images/white-bubble-64.png"
|
|
|
|
#define IMAGE_CHAT ":/images/orange-bubble-64.png"
|
2010-11-15 15:49:24 -05:00
|
|
|
|
|
|
|
static PopupChatWindow *instance = NULL;
|
|
|
|
|
|
|
|
/*static*/ PopupChatWindow *PopupChatWindow::getWindow(bool needSingleWindow)
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if (needSingleWindow == false && (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW)) {
|
|
|
|
if (instance == NULL) {
|
|
|
|
instance = new PopupChatWindow(true);
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
return instance;
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
return new PopupChatWindow(false);
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void PopupChatWindow::cleanup()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if (instance) {
|
|
|
|
delete(instance);
|
|
|
|
instance = NULL;
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Default constructor */
|
2013-10-18 17:10:33 -04:00
|
|
|
PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
/* Invoke Qt Designer generated QObject setup routine */
|
|
|
|
ui.setupUi(this);
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
tabbedWindow = tabbed;
|
|
|
|
firstShow = true;
|
|
|
|
chatDialog = NULL;
|
2012-10-25 14:06:33 -04:00
|
|
|
mEmptyIcon = NULL;
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
ui.tabWidget->setVisible(tabbedWindow);
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
if (Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) {
|
|
|
|
ui.actionDockTab->setVisible(tabbedWindow == false);
|
|
|
|
ui.actionUndockTab->setVisible(tabbedWindow);
|
|
|
|
} else {
|
|
|
|
ui.actionDockTab->setVisible(false);
|
|
|
|
ui.actionUndockTab->setVisible(false);
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
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()));
|
|
|
|
connect(ui.actionSetOnTop, SIGNAL(toggled(bool)), this, SLOT(setOnTop()));
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
connect(ui.tabWidget, SIGNAL(tabChanged(ChatDialog*)), this, SLOT(tabChanged(ChatDialog*)));
|
2012-01-26 16:30:57 -05:00
|
|
|
connect(ui.tabWidget, SIGNAL(tabClosed(ChatDialog*)), this, SLOT(tabClosed(ChatDialog*)));
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-10-25 14:06:33 -04:00
|
|
|
connect(rApp, SIGNAL(blink(bool)), this, SLOT(blink(bool)));
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
if (tabbedWindow) {
|
|
|
|
/* signal toggled is called */
|
|
|
|
ui.actionSetOnTop->setChecked(Settings->valueFromGroup("ChatWindow", "OnTop", false).toBool());
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Destructor. */
|
|
|
|
PopupChatWindow::~PopupChatWindow()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
saveSettings();
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-10-25 14:06:33 -04:00
|
|
|
if (mEmptyIcon) {
|
|
|
|
delete(mEmptyIcon);
|
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
if (this == instance) {
|
|
|
|
instance = NULL;
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2011-07-08 18:33:26 -04:00
|
|
|
void PopupChatWindow::saveSettings()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if (tabbedWindow) {
|
|
|
|
Settings->saveWidgetInformation(this);
|
|
|
|
|
|
|
|
Settings->setValueToGroup("ChatWindow", "OnTop", ui.actionSetOnTop->isChecked());
|
|
|
|
} else {
|
2014-12-29 16:41:05 -05:00
|
|
|
if (!chatId.isNotSet()) {
|
|
|
|
PeerSettings->saveWidgetInformation(chatId, this);
|
|
|
|
PeerSettings->setPrivateChatOnTop(chatId, ui.actionSetOnTop->isChecked());
|
|
|
|
}
|
2012-01-17 15:36:36 -05:00
|
|
|
}
|
2011-07-08 18:33:26 -04:00
|
|
|
}
|
|
|
|
|
2011-08-12 10:06:29 -04:00
|
|
|
void PopupChatWindow::showEvent(QShowEvent */*event*/)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if (firstShow) {
|
|
|
|
firstShow = false;
|
|
|
|
|
|
|
|
if (tabbedWindow) {
|
|
|
|
Settings->loadWidgetInformation(this);
|
|
|
|
} else {
|
|
|
|
this->move(qrand()%100, qrand()%100); //avoid to stack multiple popup chat windows on the same position
|
2014-12-29 16:41:05 -05:00
|
|
|
PeerSettings->loadWidgetInformation(chatId, this);
|
2012-01-17 15:36:36 -05:00
|
|
|
}
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2012-01-27 09:49:48 -05:00
|
|
|
void PopupChatWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
if (tabbedWindow) {
|
|
|
|
for (int index = ui.tabWidget->count() - 1; index >= 0; --index) {
|
|
|
|
ChatDialog *dialog = dynamic_cast<ChatDialog*>(ui.tabWidget->widget(0));
|
|
|
|
if (dialog == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dialog->close()) {
|
|
|
|
event->ignore();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (chatDialog && !chatDialog->close()) {
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
ChatDialog *PopupChatWindow::getCurrentDialog()
|
2011-04-09 18:52:52 -04:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if (tabbedWindow) {
|
|
|
|
return dynamic_cast<ChatDialog*>(ui.tabWidget->currentWidget());
|
|
|
|
}
|
2011-04-09 18:52:52 -04:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
return chatDialog;
|
2011-04-09 18:52:52 -04:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::addDialog(ChatDialog *dialog)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if (tabbedWindow) {
|
|
|
|
ui.tabWidget->addDialog(dialog);
|
|
|
|
} else {
|
|
|
|
ui.horizontalLayout->addWidget(dialog);
|
|
|
|
dialog->addToParent(this);
|
|
|
|
ui.horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
2014-12-29 16:41:05 -05:00
|
|
|
chatId = dialog->getChatId();
|
2012-01-17 15:36:36 -05:00
|
|
|
chatDialog = dialog;
|
|
|
|
calculateStyle(dialog);
|
|
|
|
|
|
|
|
/* signal toggled is called */
|
2014-12-29 16:41:05 -05:00
|
|
|
ui.actionSetOnTop->setChecked(PeerSettings->getPrivateChatOnTop(chatId));
|
2012-01-27 09:49:48 -05:00
|
|
|
|
|
|
|
QObject::connect(dialog, SIGNAL(dialogClose(ChatDialog*)), this, SLOT(dialogClose(ChatDialog*)));
|
2012-01-17 15:36:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QObject::connect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
|
|
|
QObject::connect(dialog, SIGNAL(newMessage(ChatDialog*)), this, SLOT(tabNewMessage(ChatDialog*)));
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::removeDialog(ChatDialog *dialog)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
QObject::disconnect(dialog, SIGNAL(infoChanged(ChatDialog*)), this, SLOT(tabInfoChanged(ChatDialog*)));
|
|
|
|
QObject::disconnect(dialog, SIGNAL(newMessage(ChatDialog*)), this, SLOT(tabNewMessage(ChatDialog*)));
|
|
|
|
|
|
|
|
if (tabbedWindow) {
|
|
|
|
ui.tabWidget->removeDialog(dialog);
|
|
|
|
|
|
|
|
if (ui.tabWidget->count() == 0) {
|
|
|
|
deleteLater();
|
|
|
|
}
|
|
|
|
} else {
|
2012-01-27 09:49:48 -05:00
|
|
|
QObject::disconnect(dialog, SIGNAL(dialogClose(ChatDialog*)), this, SLOT(dialogClose(ChatDialog*)));
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
if (chatDialog == dialog) {
|
|
|
|
saveSettings();
|
|
|
|
dialog->removeFromParent(this);
|
|
|
|
ui.horizontalLayout->removeWidget(dialog);
|
|
|
|
chatDialog = NULL;
|
2014-12-29 16:41:05 -05:00
|
|
|
chatId = ChatId();
|
2012-01-17 15:36:36 -05:00
|
|
|
deleteLater();
|
|
|
|
}
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::showDialog(ChatDialog *dialog, uint chatflags)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if (chatflags & RS_CHAT_FOCUS) {
|
|
|
|
if (tabbedWindow) {
|
|
|
|
ui.tabWidget->setCurrentWidget(dialog);
|
|
|
|
}
|
|
|
|
show();
|
|
|
|
activateWindow();
|
|
|
|
setWindowState((windowState() & (~Qt::WindowMinimized)) | Qt::WindowActive);
|
|
|
|
raise();
|
|
|
|
dialog->focusDialog();
|
|
|
|
} else {
|
|
|
|
if (isVisible() == false) {
|
|
|
|
showMinimized();
|
|
|
|
}
|
|
|
|
alertDialog(dialog);
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::alertDialog(ChatDialog */*dialog*/)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
QApplication::alert(this);
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::calculateTitle(ChatDialog *dialog)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
bool hasNewMessages = false;
|
|
|
|
ChatDialog *cd;
|
|
|
|
|
|
|
|
/* is typing */
|
|
|
|
bool isTyping = false;
|
|
|
|
if (ui.tabWidget->isVisible()) {
|
|
|
|
ui.tabWidget->getInfo(isTyping, hasNewMessages, NULL);
|
|
|
|
} else {
|
|
|
|
if (dialog) {
|
|
|
|
isTyping = dialog->isTyping();
|
|
|
|
hasNewMessages = dialog->hasNewMessages();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui.tabWidget->isVisible()) {
|
|
|
|
cd = dynamic_cast<ChatDialog*>(ui.tabWidget->currentWidget());
|
|
|
|
} else {
|
|
|
|
cd = dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
QIcon icon;
|
|
|
|
if (isTyping) {
|
2012-10-25 14:06:33 -04:00
|
|
|
mBlinkIcon = QIcon();
|
2012-01-17 15:36:36 -05:00
|
|
|
icon = QIcon(IMAGE_TYPING);
|
|
|
|
} else if (hasNewMessages) {
|
|
|
|
icon = QIcon(IMAGE_CHAT);
|
2012-10-27 11:59:12 -04:00
|
|
|
if (Settings->getChatFlags() & RS_CHAT_BLINK) {
|
|
|
|
mBlinkIcon = icon;
|
|
|
|
} else {
|
|
|
|
mBlinkIcon = QIcon();
|
|
|
|
}
|
2012-01-17 15:36:36 -05:00
|
|
|
} else {
|
2012-10-25 14:06:33 -04:00
|
|
|
mBlinkIcon = QIcon();
|
2012-01-17 15:36:36 -05:00
|
|
|
if (cd && cd->hasPeerStatus()) {
|
|
|
|
icon = QIcon(StatusDefs::imageIM(cd->getPeerStatus()));
|
|
|
|
} else {
|
2014-07-24 19:26:04 -04:00
|
|
|
icon = qApp->windowIcon();
|
2012-01-17 15:36:36 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setWindowIcon(icon);
|
|
|
|
|
|
|
|
if (cd) {
|
|
|
|
QString title = cd->getTitle();
|
|
|
|
if (cd->hasPeerStatus()) {
|
|
|
|
title += " (" + StatusDefs::name(cd->getPeerStatus()) + ")";
|
|
|
|
}
|
|
|
|
setWindowTitle(title);
|
|
|
|
} else {
|
|
|
|
setWindowTitle("RetroShare");
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void PopupChatWindow::getAvatar()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
QByteArray ba;
|
|
|
|
if (misc::getOpenAvatarPicture(this, ba)) {
|
|
|
|
std::cerr << "Avatar image size = " << ba.size() << std::endl ;
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()), ba.size()); // last char 0 included.
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2012-02-17 05:03:38 -05:00
|
|
|
void PopupChatWindow::tabClosed(ChatDialog */*dialog*/)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-26 16:30:57 -05:00
|
|
|
if (tabbedWindow) {
|
|
|
|
if (ui.tabWidget->count() == 0) {
|
|
|
|
deleteLater();
|
|
|
|
}
|
|
|
|
}
|
2012-01-11 19:13:25 -05:00
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-27 09:49:48 -05:00
|
|
|
void PopupChatWindow::dialogClose(ChatDialog *dialog)
|
|
|
|
{
|
|
|
|
if (!tabbedWindow) {
|
|
|
|
removeDialog(dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::tabChanged(ChatDialog *dialog)
|
2012-01-11 19:13:25 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
calculateStyle(dialog);
|
|
|
|
calculateTitle(dialog);
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::tabInfoChanged(ChatDialog *dialog)
|
2010-11-15 15:49:24 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
calculateTitle(dialog);
|
2012-01-11 19:13:25 -05:00
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::tabNewMessage(ChatDialog *dialog)
|
2012-01-11 19:13:25 -05:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
alertDialog(dialog);
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void PopupChatWindow::dockTab()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
if ((Settings->getChatFlags() & RS_CHAT_TABBED_WINDOW) && chatDialog) {
|
|
|
|
PopupChatWindow *pcw = getWindow(false);
|
|
|
|
if (pcw) {
|
|
|
|
ChatDialog *pcd = chatDialog;
|
|
|
|
removeDialog(pcd);
|
|
|
|
pcw->addDialog(pcd);
|
|
|
|
pcw->show();
|
|
|
|
pcw->calculateTitle(pcd);
|
|
|
|
}
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void PopupChatWindow::undockTab()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
ChatDialog *cd = dynamic_cast<ChatDialog*>(ui.tabWidget->currentWidget());
|
|
|
|
|
|
|
|
if (cd) {
|
|
|
|
PopupChatWindow *pcw = getWindow(true);
|
|
|
|
if (pcw) {
|
|
|
|
removeDialog(cd);
|
|
|
|
pcw->addDialog(cd);
|
|
|
|
cd->show();
|
|
|
|
pcw->show();
|
|
|
|
pcw->calculateTitle(cd);
|
|
|
|
}
|
|
|
|
}
|
2010-11-15 15:49:24 -05:00
|
|
|
}
|
2011-04-09 18:52:52 -04:00
|
|
|
|
|
|
|
void PopupChatWindow::setStyle()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
ChatDialog *cd = getCurrentDialog();
|
2011-04-09 18:52:52 -04:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
if (cd && cd->setStyle()) {
|
|
|
|
calculateStyle(cd);
|
|
|
|
}
|
2011-04-09 18:52:52 -04:00
|
|
|
}
|
|
|
|
|
2011-07-08 18:33:26 -04:00
|
|
|
void PopupChatWindow::setOnTop()
|
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
Qt::WindowFlags flags = windowFlags();
|
|
|
|
if (ui.actionSetOnTop->isChecked()) {
|
|
|
|
flags |= Qt::WindowStaysOnTopHint;
|
|
|
|
} else {
|
|
|
|
flags &= ~Qt::WindowStaysOnTopHint;
|
|
|
|
}
|
|
|
|
setWindowFlags(flags);
|
|
|
|
|
|
|
|
/* Show window again */
|
|
|
|
show();
|
2011-07-08 18:33:26 -04:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
void PopupChatWindow::calculateStyle(ChatDialog *dialog)
|
2011-04-09 18:52:52 -04:00
|
|
|
{
|
2012-01-17 15:36:36 -05:00
|
|
|
QString toolSheet;
|
|
|
|
QString statusSheet;
|
|
|
|
QString widgetSheet;
|
|
|
|
|
|
|
|
if (dialog) {
|
|
|
|
const RSStyle *style = dialog->getStyle();
|
|
|
|
if (style) {
|
|
|
|
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);
|
2011-04-09 18:52:52 -04:00
|
|
|
}
|
2012-10-25 14:06:33 -04:00
|
|
|
|
|
|
|
void PopupChatWindow::blink(bool on)
|
|
|
|
{
|
|
|
|
if (!mBlinkIcon.isNull()) {
|
|
|
|
if (mEmptyIcon == NULL) {
|
|
|
|
/* create empty icon */
|
|
|
|
QPixmap pixmap(16, 16);
|
|
|
|
pixmap.fill(Qt::transparent);
|
|
|
|
mEmptyIcon = new QIcon(pixmap);
|
|
|
|
}
|
|
|
|
setWindowIcon(on ? mBlinkIcon : *mEmptyIcon);
|
|
|
|
}
|
|
|
|
}
|