3
* Copyright (C) 2007 Kevin Smith
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include "tabbablewidget.h"
22
#include "tabmanager.h"
25
#include "groupchatdlg.h"
26
#include "psioptions.h"
34
//----------------------------------------------------------------------------
36
//----------------------------------------------------------------------------
38
TabbableWidget::TabbableWidget(const Jid &jid, PsiAccount *pa, TabManager *tabManager)
39
: AdvancedWidget<QWidget>(0)
42
, tabManager_(tabManager)
44
QTimer::singleShot(0, this, SLOT(ensureTabbedCorrectly()));
47
void TabbableWidget::ensureTabbedCorrectly()
49
if (tabManager_->shouldBeTabbed(this)) {
51
tabManager_->getTabs(this)->addTab(this);
55
if (PsiOptions::instance()->getOption("options.ui.tabs.tab-singles").toString().contains(tabManager_->tabKind(this))) {
57
if (getManagingTabDlg()->tabCount() > 1) {
58
getManagingTabDlg()->closeTab(this, false);
59
tabManager_->newTabs(this)->addTab(this);
63
tabManager_->newTabs(this)->addTab(this);
68
getManagingTabDlg()->closeTab(this, false);
71
// FIXME: showWithoutActivation() works on all
72
// platforms, but bringToFront() (which might be
73
// called immediately after) does not work on all
74
// platforms if it follows a call to
75
// showWithoutActivation(). As a temporary fix, we
76
// will only call showWithoutActivation() on
77
// platforms where both calls can be made in
80
showWithoutActivation();
88
void TabbableWidget::bringToFront()
91
getManagingTabDlg()->selectTab(this);
96
TabbableWidget::~TabbableWidget()
99
getManagingTabDlg()->removeTabWithNoChecks(this);
104
* Checks if the dialog is in a tabset
106
bool TabbableWidget::isTabbed()
108
return tabManager_->isChatTabbed(this);
111
TabDlg* TabbableWidget::getManagingTabDlg()
113
return tabManager_->getManagingTabs(this);
117
* Runs any gumph necessary before hiding a tab.
118
* (checking new messages, setting the autodelete, cancelling composing etc)
119
* \return TabbableWidget is ready to be hidden.
121
bool TabbableWidget::readyToHide()
126
Jid TabbableWidget::jid() const
131
void TabbableWidget::setJid(const Jid& j)
136
const QString& TabbableWidget::getDisplayName()
141
void TabbableWidget::deactivated()
145
void TabbableWidget::activated()
150
* Returns true if this tab is active in the active window.
152
bool TabbableWidget::isActiveTab()
158
return isActiveWindow() && !isMinimized();
160
return getManagingTabDlg()->isActiveWindow() &&
161
getManagingTabDlg()->tabOnTop(this) &&
162
!getManagingTabDlg()->isMinimized();
165
void TabbableWidget::doFlash(bool on)
167
AdvancedWidget<QWidget>::doFlash(on);
168
emit updateFlashState();
171
TabbableWidget::State TabbableWidget::state() const
173
return TabbableWidget::StateNone;
176
int TabbableWidget::unreadMessageCount() const
182
* Use this to invalidate tab state.
184
void TabbableWidget::invalidateTab()
186
setWindowTitle(desiredCaption());
187
emit invalidateTabInfo();
190
PsiAccount* TabbableWidget::account() const
195
void TabbableWidget::changeEvent(QEvent* event)
197
AdvancedWidget<QWidget>::changeEvent(event);
199
if (event->type() == QEvent::ActivationChange ||
200
event->type() == QEvent::WindowStateChange)