Esempio n. 1
0
MessageView::MessageView(ViewInfo::Type type, IrcConnection* connection, IrcChannelStackView* stackView) :
	QWidget(stackView)
{
	d.setupUi(this);
	d.viewType = type;
	d.sentId = 1;
#if QT_VERSION >= 0x040700
	d.awayReply.invalidate();
#else
	d.awayReply = QTime();
#endif
	d.playback = false;
	d.parser = stackView->parser();
	d.firstNames = true;
	d.messageTimer = new QTimer(this);
	connect(d.messageTimer, SIGNAL(timeout()), this, SLOT(sendMessageLine()));

	d.joined = 0;
	d.parted = 0;
	d.connected = 0;
	d.disconnected = 0;

	d.chatInput = new CWidgetChatInput(this, true);
	d.verticalLayoutInputWidget->addWidget(d.chatInput);
	d.widgetInput->setFixedHeight(130);
	d.chatInput->setFixedHeight(130);

	connect(d.splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(onSplitterMoved()));

	setFocusProxy(d.chatInput->textEdit());
	d.textBrowser->setBuddy(d.chatInput->textEdit());
	d.textBrowser->viewport()->installEventFilter(this);
	connect(d.textBrowser, SIGNAL(anchorClicked(QUrl)), SLOT(onAnchorClicked(QUrl)));

	d.highlighter = new SyntaxHighlighter(d.textBrowser->document());

	d.connection = connection;
	connect(d.connection, SIGNAL(statusChanged(IrcConnection::Status)), this, SLOT(onConnectionStatusChanged()));

	if (type == ViewInfo::Server)
		connect(d.connection, SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(onSocketError()));

	d.topicLabel->setVisible(type == ViewInfo::Channel);
	d.listView->setVisible(type == ViewInfo::Channel);
	if (type == ViewInfo::Channel) {
		d.listView->setConnection(connection);
		connect(d.listView, SIGNAL(queried(QString)), this, SIGNAL(queried(QString)));
		connect(d.listView, SIGNAL(doubleClicked(QString)), this, SIGNAL(queried(QString)));
		connect(d.listView, SIGNAL(commandRequested(IrcCommand*)), d.connection, SLOT(sendCommand(IrcCommand*)));
		connect(d.topicLabel, SIGNAL(edited(QString)), this, SLOT(onTopicEdited(QString)));
	} else if (type == ViewInfo::Server) {
void GlobalPresence::setAccountManager(const Tp::AccountManagerPtr &accountManager)
{
    if (! accountManager->isReady()) {
        qCWarning(KTP_COMMONINTERNALS) << "GlobalPresence used with unready account manager";
    }

    m_enabledAccounts = accountManager->enabledAccounts();
    m_onlineAccounts = accountManager->onlineAccounts();

    Q_FOREACH(const Tp::AccountPtr &account, m_enabledAccounts->accounts()) {
        onAccountAdded(account);
    }

    onCurrentPresenceChanged();
    onRequestedPresenceChanged();
    onChangingPresence();
    onConnectionStatusChanged();

    connect(m_enabledAccounts.data(), SIGNAL(accountAdded(Tp::AccountPtr)), SLOT(onAccountAdded(Tp::AccountPtr)));
    connect(m_enabledAccounts.data(), SIGNAL(accountRemoved(Tp::AccountPtr)), this, SIGNAL(enabledAccountsChanged()));
}
void GlobalPresence::onAccountAdded(const Tp::AccountPtr &account)
{
    connect(account.data(), SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)), SLOT(onConnectionStatusChanged()));
    connect(account.data(), SIGNAL(requestedPresenceChanged(Tp::Presence)), SLOT(onRequestedPresenceChanged()));
    connect(account.data(), SIGNAL(currentPresenceChanged(Tp::Presence)), SLOT(onCurrentPresenceChanged()));

    Q_EMIT enabledAccountsChanged();
}