[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:10:56 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=8602711
The following commit has been merged in the master branch:
commit 860271155e5210d77751d4ccbac5cd35326acb42
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date: Sun Jul 15 23:48:45 2012 +0200
Add Minimalistic delegate (aka Lydia Pintscher mode)
A contact list type which uses the smallest readable font and very small avatars to fit as many contacts into the list as possible.
Reviewed-by: David Edmundson
REVIEW: 105477
FEATURE: 303051
FIXED-IN: 0.5
DIGEST
---
contact-delegate-compact.cpp | 60 +++++++++++++++++++++++++++++---------------
contact-delegate-compact.h | 17 +++++++++++--
contact-list-widget.cpp | 33 ++++++++++++++++++++----
contact-list-widget.h | 1 +
main-widget.cpp | 15 ++++++++---
5 files changed, 96 insertions(+), 30 deletions(-)
diff --git a/contact-delegate-compact.cpp b/contact-delegate-compact.cpp
index 948e5a8..1915397 100644
--- a/contact-delegate-compact.cpp
+++ b/contact-delegate-compact.cpp
@@ -41,15 +41,10 @@
#include <KTp/Models/groups-model.h>
#include <KTp/presence.h>
-const int SPACING = 4;
-const int AVATAR_SIZE = 22;
-const int PRESENCE_ICON_SIZE = 16;
-const int CLIENT_TYPE_ICON_SIZE = 16;
-const int ACCOUNT_ICON_SIZE = 13;
-
-ContactDelegateCompact::ContactDelegateCompact(QObject * parent)
+ContactDelegateCompact::ContactDelegateCompact(ContactDelegateCompact::ListSize size, QObject * parent)
: AbstractContactDelegate(parent)
{
+ setListMode(size);
}
ContactDelegateCompact::~ContactDelegateCompact()
@@ -71,8 +66,8 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter);
QRect iconRect = optV4.rect;
- iconRect.setSize(QSize(AVATAR_SIZE, AVATAR_SIZE));
- iconRect.moveTo(QPoint(iconRect.x() + SPACING, iconRect.y() + SPACING));
+ iconRect.setSize(QSize(m_avatarSize, m_avatarSize));
+ iconRect.moveTo(QPoint(iconRect.x() + m_spacing, iconRect.y() + m_spacing));
QPixmap avatar;
avatar.load(index.data(AccountsModel::AvatarRole).toString());
@@ -88,31 +83,38 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
KTp::Presence presence = index.data(AccountsModel::PresenceRole).value<KTp::Presence>();
// This value is used to set the correct width for the username and the presence message.
- int rightIconsWidth = PRESENCE_ICON_SIZE + SPACING;
+ int rightIconsWidth = m_presenceIconSize + m_spacing;
QPixmap icon = presence.icon().pixmap(KIconLoader::SizeSmallMedium);
QRect statusIconRect = optV4.rect;
- statusIconRect.setSize(QSize(PRESENCE_ICON_SIZE, PRESENCE_ICON_SIZE));
+
+ statusIconRect.setSize(QSize(m_presenceIconSize, m_presenceIconSize));
statusIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
- optV4.rect.top() + (optV4.rect.height() - PRESENCE_ICON_SIZE) / 2));
+ optV4.rect.top() + (optV4.rect.height() - m_presenceIconSize) / 2));
painter->drawPixmap(statusIconRect, icon);
// Right now we only check for 'phone', as that's the most interesting type.
if (index.data(AccountsModel::ClientTypesRole).toStringList().contains(QLatin1String("phone"))) {
// Additional space is needed for the icons, don't add too much spacing between the two icons
- rightIconsWidth += CLIENT_TYPE_ICON_SIZE + (SPACING / 2);
+ rightIconsWidth += m_clientTypeIconSize + (m_spacing / 2);
- QPixmap phone = QIcon::fromTheme("phone").pixmap(CLIENT_TYPE_ICON_SIZE);
+ QPixmap phone = QIcon::fromTheme("phone").pixmap(m_clientTypeIconSize);
QRect phoneIconRect = optV4.rect;
- phoneIconRect.setSize(QSize(CLIENT_TYPE_ICON_SIZE, CLIENT_TYPE_ICON_SIZE));
+ phoneIconRect.setSize(QSize(m_clientTypeIconSize, m_clientTypeIconSize));
phoneIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
- optV4.rect.top() + (optV4.rect.height() - CLIENT_TYPE_ICON_SIZE) / 2));
+ optV4.rect.top() + (optV4.rect.height() - m_clientTypeIconSize) / 2));
painter->drawPixmap(phoneIconRect, phone);
}
- QFont nameFont = KGlobalSettings::generalFont();
+ QFont nameFont;
+
+ if (m_listSize == ContactDelegateCompact::Mini) {
+ nameFont = KGlobalSettings::smallestReadableFont();
+ } else {
+ nameFont = KGlobalSettings::generalFont();
+ }
const QFontMetrics nameFontMetrics(nameFont);
@@ -125,7 +127,7 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
painter->setFont(nameFont);
QRect userNameRect = optV4.rect;
- userNameRect.setX(iconRect.x() + iconRect.width() + SPACING * 2);
+ userNameRect.setX(iconRect.x() + iconRect.width() + m_spacing * 2);
userNameRect.setY(userNameRect.y() + (userNameRect.height()/2 - nameFontMetrics.height()/2));
userNameRect.setWidth(userNameRect.width() - rightIconsWidth);
@@ -133,7 +135,7 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
QRect presenceMessageRect = optV4.rect;
- presenceMessageRect.setX(userNameRect.x() + nameFontMetrics.boundingRect(optV4.text).width() + SPACING * 2);
+ presenceMessageRect.setX(userNameRect.x() + nameFontMetrics.boundingRect(optV4.text).width() + m_spacing * 2);
presenceMessageRect.setWidth(optV4.rect.width() - presenceMessageRect.x() - rightIconsWidth);
presenceMessageRect.setY(presenceMessageRect.y() + (presenceMessageRect.height()/2 - nameFontMetrics.height()/2));
@@ -154,7 +156,25 @@ QSize ContactDelegateCompact::sizeHintContact(const QStyleOptionViewItem &option
{
Q_UNUSED(option);
Q_UNUSED(index);
- return QSize(0, AVATAR_SIZE + 2 * SPACING);
+ return QSize(0, qMax(m_avatarSize + 2 * m_spacing, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing));
}
+void ContactDelegateCompact::setListMode(ContactDelegateCompact::ListSize size)
+{
+ if (size == ContactDelegateCompact::Mini) {
+ m_spacing = 2;
+ m_avatarSize = qMax(12, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing);
+ m_presenceIconSize = qMax(12, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing);
+ m_clientTypeIconSize = qMax(12, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing);
+ } else if (size == ContactDelegateCompact::Normal) {
+ m_spacing = 4;
+ m_avatarSize = 22;
+ m_presenceIconSize = 16;
+ m_clientTypeIconSize = 16;
+ }
+
+ m_listSize = size;
+}
+
+
#include "contact-delegate-compact.moc"
diff --git a/contact-delegate-compact.h b/contact-delegate-compact.h
index 7fa2907..e6013d5 100644
--- a/contact-delegate-compact.h
+++ b/contact-delegate-compact.h
@@ -26,14 +26,27 @@
class ContactDelegateCompact : public AbstractContactDelegate
{
Q_OBJECT
-// Q_PROPERTY(int m_fadingValue READ fadingValue WRITE setFadingValue);
public:
- ContactDelegateCompact(QObject *parent = 0);
+ enum ListSize {
+ Normal,
+ Mini
+ };
+ ContactDelegateCompact(ContactDelegateCompact::ListSize size = Normal, QObject *parent = 0);
~ContactDelegateCompact();
void paintContact(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
QSize sizeHintContact(const QStyleOptionViewItem & option, const QModelIndex & index) const;
+
+ void setListMode(ContactDelegateCompact::ListSize size);
+
+private:
+ int m_spacing;
+ int m_avatarSize;
+ int m_presenceIconSize;
+ int m_accountIconSize;
+ int m_clientTypeIconSize;
+ ContactDelegateCompact::ListSize m_listSize;
};
#endif // CONTACTDELEGATECOMPACT_H
diff --git a/contact-list-widget.cpp b/contact-list-widget.cpp
index ee65883..09a9c4b 100644
--- a/contact-list-widget.cpp
+++ b/contact-list-widget.cpp
@@ -71,7 +71,7 @@ ContactListWidget::ContactListWidget(QWidget *parent)
KConfigGroup guiConfigGroup(config, "GUI");
d->delegate = new ContactDelegate(this);
- d->compactDelegate = new ContactDelegateCompact(this);
+ d->compactDelegate = new ContactDelegateCompact(ContactDelegateCompact::Normal, this);
d->model = new AccountsModel(this);
d->groupsModel = new GroupsModel(d->model, this);
@@ -100,14 +100,20 @@ ContactListWidget::ContactListWidget(QWidget *parent)
viewport()->setAcceptDrops(true);
setDropIndicatorShown(true);
- if (guiConfigGroup.readEntry("selected_delegate", "compact") == QLatin1String("compact")) {
+ QString delegateMode = guiConfigGroup.readEntry("selected_delegate", "normal");
+
+ if (delegateMode == QLatin1String("full")) {
+ setItemDelegate(d->delegate);
+ } else if (delegateMode == QLatin1String("mini")) {
setItemDelegate(d->compactDelegate);
+ d->compactDelegate->setListMode(ContactDelegateCompact::Mini);
} else {
- setItemDelegate(d->delegate);
+ setItemDelegate(d->compactDelegate);
+ d->compactDelegate->setListMode(ContactDelegateCompact::Normal);
}
addOverlayButtons();
- emit enableOverlays(guiConfigGroup.readEntry("selected_delegate", "compact") == QLatin1String("full"));
+ emit enableOverlays(guiConfigGroup.readEntry("selected_delegate", "normal") == QLatin1String("full"));
connect(this, SIGNAL(clicked(QModelIndex)),
this, SLOT(onContactListClicked(QModelIndex)));
@@ -486,13 +492,30 @@ void ContactListWidget::onSwitchToCompactView()
Q_D(ContactListWidget);
setItemDelegate(d->compactDelegate);
+ d->compactDelegate->setListMode(ContactDelegateCompact::Normal);
+ doItemsLayout();
+
+ emit enableOverlays(false);
+
+ KSharedConfigPtr config = KGlobal::config();
+ KConfigGroup guiConfigGroup(config, "GUI");
+ guiConfigGroup.writeEntry("selected_delegate", "normal");
+ guiConfigGroup.config()->sync();
+}
+
+void ContactListWidget::onSwitchToMiniView()
+{
+ Q_D(ContactListWidget);
+
+ setItemDelegate(d->compactDelegate);
+ d->compactDelegate->setListMode(ContactDelegateCompact::Mini);;
doItemsLayout();
emit enableOverlays(false);
KSharedConfigPtr config = KGlobal::config();
KConfigGroup guiConfigGroup(config, "GUI");
- guiConfigGroup.writeEntry("selected_delegate", "compact");
+ guiConfigGroup.writeEntry("selected_delegate", "mini");
guiConfigGroup.config()->sync();
}
diff --git a/contact-list-widget.h b/contact-list-widget.h
index 724050d..3e3b071 100644
--- a/contact-list-widget.h
+++ b/contact-list-widget.h
@@ -55,6 +55,7 @@ public Q_SLOTS:
void onSwitchToFullView();
void onSwitchToCompactView();
+ void onSwitchToMiniView();
void onShowAllContacts();
void onShowUnblockedContacts();
diff --git a/main-widget.cpp b/main-widget.cpp
index 79869b8..0c3eb97 100644
--- a/main-widget.cpp
+++ b/main-widget.cpp
@@ -169,15 +169,24 @@ MainWidget::MainWidget(QWidget *parent)
m_contactsListView, SLOT(onSwitchToFullView())));
delegateTypeGroup->actions().last()->setCheckable(true);
- if (guiConfigGroup.readEntry("selected_delegate", "compact") == QLatin1String("full")) {
+ if (guiConfigGroup.readEntry("selected_delegate", "normal") == QLatin1String("full")) {
delegateTypeGroup->actions().last()->setChecked(true);
}
- delegateTypeGroup->addAction(setDelegateTypeMenu->addAction(i18n("Use Compact List"),
+ delegateTypeGroup->addAction(setDelegateTypeMenu->addAction(i18n("Use Normal List"),
m_contactsListView, SLOT(onSwitchToCompactView())));
delegateTypeGroup->actions().last()->setCheckable(true);
- if (guiConfigGroup.readEntry("selected_delegate", "compact") == QLatin1String("compact")) {
+ if (guiConfigGroup.readEntry("selected_delegate", "normal") == QLatin1String("normal")
+ || guiConfigGroup.readEntry("selected_delegate", "normal") == QLatin1String("compact")) { //needed for backwards compatibility
+ delegateTypeGroup->actions().last()->setChecked(true);
+ }
+
+ delegateTypeGroup->addAction(setDelegateTypeMenu->addAction(i18n("Use Minimalistic List"),
+ m_contactsListView, SLOT(onSwitchToMiniView())));
+ delegateTypeGroup->actions().last()->setCheckable(true);
+
+ if (guiConfigGroup.readEntry("selected_delegate", "normal") == QLatin1String("mini")) {
delegateTypeGroup->actions().last()->setChecked(true);
}
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list