Added a new image to the private chat window to set the window always on top.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4409 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-07-08 22:33:26 +00:00
parent 71f632b99f
commit b86407f395
9 changed files with 391 additions and 64 deletions

View file

@ -87,27 +87,43 @@ PopupChatWindow::PopupChatWindow(bool tabbed, QWidget *parent, Qt::WFlags flags)
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()));
connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabCurrentChanged(int)));
if (tabbedWindow) {
/* signal toggled is called */
ui.actionSetOnTop->setChecked(Settings->valueFromGroup("ChatWindow", "OnTop", false).toBool());
}
setWindowIcon(QIcon(IMAGE_WINDOW));
}
/** Destructor. */
PopupChatWindow::~PopupChatWindow()
{
if (tabbedWindow) {
Settings->saveWidgetInformation(this);
} else {
PeerSettings->saveWidgetInformation(peerId, this);
}
saveSettings();
if (this == instance) {
instance = NULL;
}
}
void PopupChatWindow::saveSettings()
{
if (tabbedWindow) {
Settings->saveWidgetInformation(this);
Settings->setValueToGroup("ChatWindow", "OnTop", ui.actionSetOnTop->isChecked());
} else {
if (!peerId.empty()) {
PeerSettings->saveWidgetInformation(peerId, this);
PeerSettings->setPrivateChatOnTop(peerId, ui.actionSetOnTop->isChecked());
}
}
}
void PopupChatWindow::showEvent(QShowEvent *event)
{
if (firstShow) {
@ -151,6 +167,9 @@ void PopupChatWindow::addDialog(PopupChatDialog *dialog)
peerId = dialog->getPeerId();
chatDialog = dialog;
calculateStyle(dialog);
/* signal toggled is called */
ui.actionSetOnTop->setChecked(PeerSettings->getPrivateChatOnTop(peerId));
}
}
@ -167,8 +186,10 @@ void PopupChatWindow::removeDialog(PopupChatDialog *dialog)
}
} else {
if (chatDialog == dialog) {
saveSettings();
ui.horizontalLayout->removeWidget(dialog);
chatDialog = NULL;
peerId.erase();
deleteLater();
}
}
@ -347,6 +368,20 @@ void PopupChatWindow::setStyle()
}
}
void PopupChatWindow::setOnTop()
{
Qt::WindowFlags flags = windowFlags();
if (ui.actionSetOnTop->isChecked()) {
flags |= Qt::WindowStaysOnTopHint;
} else {
flags &= ~Qt::WindowStaysOnTopHint;
}
setWindowFlags(flags);
/* Show window again */
show();
}
void PopupChatWindow::calculateStyle(PopupChatDialog *dialog)
{
QString toolSheet;

View file

@ -59,6 +59,7 @@ private slots:
void dockTab();
void undockTab();
void setStyle();
void setOnTop();
private:
bool tabbedWindow;
@ -67,6 +68,7 @@ private:
PopupChatDialog *chatDialog;
PopupChatDialog *getCurrentDialog();
void saveSettings();
void calculateStyle(PopupChatDialog *dialog);
/** Qt Designer generated object */

View file

@ -79,6 +79,7 @@
</attribute>
<addaction name="actionAvatar"/>
<addaction name="actionColor"/>
<addaction name="actionSetOnTop"/>
<addaction name="actionDockTab"/>
<addaction name="actionUndockTab"/>
</widget>
@ -130,6 +131,21 @@
<string>Set Chat Window Color</string>
</property>
</action>
<action name="actionSetOnTop">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/pin32.png</normaloff>:/images/pin32.png</iconset>
</property>
<property name="text">
<string>Set window on top</string>
</property>
<property name="toolTip">
<string>Set window on top</string>
</property>
</action>
</widget>
<resources>
<include location="../images.qrc"/>