Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit f40dc581 authored by James D. Smith's avatar James D. Smith

Independent account presence support.

Bugfixes and improvements.
REVIEW: 130189
BUG: 181748
GUI:
parent dc7cf9cb
......@@ -51,6 +51,7 @@ set (ktp_contactlist_SRCS
global-presence-chooser.cpp
dialogs/remove-contact-dialog.cpp
dialogs/custom-presence-dialog.cpp
dialogs/advanced-presence-dialog.cpp
tooltips/ktooltip.cpp
tooltips/tooltipmanager.cpp
tooltips/ktooltipwindow.cpp
......
This diff is collapsed.
/*
Copyright © 2017 James D. Smith <smithjd15@gmail.com>
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) version 3 or any later version
accepted by the membership of KDE e.V. (or its successor approved
by the membership of KDE e.V.), which shall act as a proxy
defined in Section 14 of version 3 of the license.
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADVANCED_PRESENCE_DIALOG_H
#define ADVANCED_PRESENCE_DIALOG_H
#include <QDialog>
#include <QComboBox>
class QPushButton;
class QListView;
class QComboBox;
class AccountPresenceModelExtended;
namespace KTp {
class Presence;
class GlobalPresence;
class PresenceModel;
class AccountsListModel;
}
class AdvancedPresenceDialog : public QDialog
{
Q_OBJECT
public:
explicit AdvancedPresenceDialog(KTp::PresenceModel *presenceModel, KTp::GlobalPresence *globalPresence, QWidget *parent = 0);
bool eventFilter(QObject* obj, QEvent* event);
private:
///Setup the initial dialog
void setupDialog();
KTp::PresenceModel *m_presenceModel;
KTp::AccountsListModel *m_accountsModel;
KTp::GlobalPresence *m_globalPresence;
QHash<int,QComboBox*> m_comboBoxes;
QHash<int,AccountPresenceModelExtended*> m_extendedModels;
};
#endif // ADVANCED_PRESENCE_DIALOG_H
......@@ -19,6 +19,7 @@
*/
#include "custom-presence-dialog.h"
#include "global-presence-chooser.h"
#include <QListView>
#include <QHBoxLayout>
......@@ -97,6 +98,7 @@ void CustomPresenceDialog::setupDialog()
m_statusMessage->show();
m_statusMessage->lineEdit()->setPlaceholderText(m_statusMessage->currentText());
m_statusMessage->lineEdit()->setWhatsThis(KDED_STATUS_MESSAGE_PARSER_WHATSTHIS);
connect(m_statusMessage, SIGNAL(editTextChanged(QString)),
this, SLOT(presenceMessageTextChanged(QString)));
......@@ -202,6 +204,9 @@ void CustomPresenceDialog::presenceViewSelectionChanged(const QModelIndex& index
} else {
m_removeStatus->setEnabled(false);
}
KTp::Presence presence = index.data(KTp::PresenceModel::PresenceRole).value<KTp::Presence>();
m_statusMessage->lineEdit()->setText(presence.statusMessage());
}
#include "custom-presence-dialog.moc"
......
This diff is collapsed.
......@@ -23,7 +23,7 @@
#include <KComboBox>
#include <TelepathyQt/AccountManager>
#include <KTp/global-presence.h>
#include <KTp/presence.h>
class QMenu;
......@@ -36,15 +36,18 @@ namespace KTp {
class PresenceModel;
}
extern const QString KDED_STATUS_MESSAGE_PARSER_WHATSTHIS;
class GlobalPresenceChooser : public KComboBox
{
Q_OBJECT
public:
explicit GlobalPresenceChooser(QWidget *parent = 0);
void setAccountManager(const Tp::AccountManagerPtr &accountManager);
void repositionOverlays();
KTp::GlobalPresence *globalPresence() {return m_globalPresence;};
protected:
virtual bool event(QEvent *event);
virtual void setEditable(bool editable); /** Hides overlay and calls ancestor's method. */
......@@ -53,7 +56,7 @@ private Q_SLOTS:
void onUserActivatedComboChange(int index);
void onAllComboChanges(int index);
void onPresenceChanged(const KTp::Presence &presence);
void onConnectionStatusChanged(Tp::ConnectionStatus connectionStatus);
void onConnectionStatusChanged(KTp::GlobalPresence::ConnectionStatus connectionStatus);
void onChangePresenceMessageClicked();
void onConfirmPresenceMessageClicked();
......@@ -63,7 +66,6 @@ private:
PresenceModelExtended *m_modelExtended;
KPixmapSequenceOverlayPainter *m_busyOverlay;
Tp::AccountManagerPtr m_accountManager;
QPushButton *m_changePresenceMessageButton;
QPointer<QMenu> m_lineEditContextMenu;
};
......
......@@ -46,6 +46,7 @@
#include <KTp/actions.h>
#include <KTp/contact-factory.h>
#include <KTp/types.h>
#include <KTp/global-presence.h>
#include <KTp/Widgets/add-contact-dialog.h>
#include <KTp/Widgets/join-chat-room-dialog.h>
#include <KTp/Widgets/start-chat-dialog.h>
......@@ -179,7 +180,7 @@ void MainWidget::onAccountManagerReady(Tp::PendingOperation* op)
return;
}
m_presenceChooser->setAccountManager(m_accountManager);
m_presenceChooser->globalPresence()->setAccountManager(m_accountManager);
m_contactsListView->setAccountManager(m_accountManager);
m_contextMenu->setAccountManager(m_accountManager);
}
......@@ -291,8 +292,9 @@ void MainWidget::closeEvent(QCloseEvent* e)
if (qApp->closingDown()) {
//the standard KMessageBox control saves "true" if you select the checkbox, therefore the reversed var name
bool dontCheckForPlasmoid = notifyConigGroup.readEntry("dont_check_for_plasmoid", false);
bool onlineAccounts = !m_presenceChooser->globalPresence()->onlineAccounts()->accounts().isEmpty();
if (isAnyAccountOnline() && !dontCheckForPlasmoid) {
if (onlineAccounts && !dontCheckForPlasmoid) {
if (!isPresencePlasmoidPresent()) {
switch (KMessageBox::warningYesNoCancel(this,
i18n("You do not have any other presence controls active (a Presence widget for example).\n"
......@@ -305,17 +307,17 @@ void MainWidget::closeEvent(QCloseEvent* e)
case KMessageBox::No:
generalConfigGroup.writeEntry("go_offline_when_closing", true);
goOffline();
m_presenceChooser->globalPresence()->setPresence(KTp::Presence::offline(), KTp::GlobalPresence::Session);
break;
case KMessageBox::Cancel:
e->ignore();
return;
}
}
} else if (isAnyAccountOnline() && dontCheckForPlasmoid) {
} else if (onlineAccounts && dontCheckForPlasmoid) {
bool shouldGoOffline = generalConfigGroup.readEntry("go_offline_when_closing", false);
if (shouldGoOffline) {
goOffline();
m_presenceChooser->globalPresence()->setPresence(KTp::Presence::offline(), KTp::GlobalPresence::Session);
}
}
......@@ -340,28 +342,6 @@ bool MainWidget::isPresencePlasmoidPresent() const
}
}
void MainWidget::goOffline()
{
//FIXME use global presence
qCDebug(KTP_CONTACTLIST_MODULE) << "Setting all accounts offline...";
foreach (const Tp::AccountPtr &account, m_accountManager->allAccounts()) {
if (account->isEnabled() && account->isValid()) {
account->setRequestedPresence(Tp::Presence::offline());
}
}
}
bool MainWidget::isAnyAccountOnline() const
{
foreach (const Tp::AccountPtr &account, m_accountManager->allAccounts()) {
if (account->isEnabled() && account->isValid() && account->isOnline()) {
return true;
}
}
return false;
}
void MainWidget::toggleSearchWidget(bool show)
{
m_searchContactAction->setChecked(show);
......
......@@ -57,7 +57,6 @@ public:
~MainWidget();
bool isPresencePlasmoidPresent() const;
bool isAnyAccountOnline() const;
enum SystemMessageType {
/*
......@@ -77,7 +76,6 @@ public:
public Q_SLOTS:
void showMessageToUser(const QString &text, const SystemMessageType type);
void goOffline();
Q_INVOKABLE void toggleWindowVisibility();
private Q_SLOTS:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment