File: common.cpp

package info (click to toggle)
plasma-widget-fastuserswitch 0.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 116 kB
  • ctags: 43
  • sloc: cpp: 355; makefile: 2; sh: 2
file content (31 lines) | stat: -rw-r--r-- 647 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "common.h"

#include <QtCore/QFile>

#include <kicon.h>
#include <kiconloader.h>
#include <kuser.h>

const QString getUsername(bool useShortName, const KUser& user)
{
  if (useShortName)
    return user.loginName();

  QString username = user.property(KUser::FullName).toString();
  if (username.isEmpty())
    username = user.loginName();

  return username;
}

QPixmap getUserIcon(const KUser& user)
{
  QPixmap pixmap;
  int iconSize = IconSize(KIconLoader::Desktop);
  if (QFile::exists(user.faceIconPath())) {
    pixmap.load(user.faceIconPath());
  } else
    pixmap = KIcon(DEFAULT_ICON_NAME).pixmap(iconSize);

  return pixmap;
}