~ubuntu-branches/ubuntu/precise/konversation/precise-updates

« back to all changes in this revision

Viewing changes to src/viewer/trayicon.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-17 09:50:41 UTC
  • mfrom: (1.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091217095041-k5ssvxm2u8wgf0ll
Tags: 1.2.1+git20091217-0ubuntu1
* New upstream git snapshot:
  - Refresh all patches
  - Update initial Indicator patch to apply properly.
  - Remove docs and locale files from the install manifest; they aren't
    present in git snapshots. We will uncomment them for official (pre)
    releases with tarballs from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  This program is free software; you can redistribute it and/or modify
3
 
  it under the terms of the GNU General Public License as published by
4
 
  the Free Software Foundation; either version 2 of the License, or
5
 
  (at your option) any later version.
6
 
*/
7
 
 
8
 
/*
9
 
  This class handles the system tray icon
10
 
  begin:     Sun Nov 9 2003
11
 
  copyright: (C) 2003 by Peter Simonsson
12
 
  email:     psn@linux.se
13
 
*/
14
 
 
15
 
#include "trayicon.h"
16
 
#include "application.h"
17
 
#include "channel.h"
18
 
#include "server.h"
19
 
#include "chatwindow.h"
20
 
#include "config/preferences.h"
21
 
 
22
 
#include <QTimer>
23
 
 
24
 
 
25
 
 
26
 
namespace Konversation
27
 
{
28
 
 
29
 
    TrayIcon::TrayIcon(QWidget* parent) : KSystemTrayIcon(parent)
30
 
    {
31
 
        m_notificationEnabled = false;
32
 
        m_blinkTimer = new QTimer(this);
33
 
        connect(m_blinkTimer, SIGNAL(timeout()), SLOT(blinkTimeout()));
34
 
 
35
 
        updateAppearance();
36
 
 
37
 
        setToolTip(i18n("Konversation - IRC Client"));
38
 
    }
39
 
 
40
 
    TrayIcon::~TrayIcon()
41
 
    {
42
 
    }
43
 
 
44
 
    void TrayIcon::startNotification()
45
 
    {
46
 
        if(!m_notificationEnabled)
47
 
        {
48
 
            return;
49
 
        }
50
 
 
51
 
        if(Preferences::self()->trayNotifyBlink())
52
 
        {
53
 
            if(!m_blinkTimer->isActive())
54
 
            {
55
 
                setIcon(m_messagePix);
56
 
                m_blinkOn = true;
57
 
                m_blinkTimer->start(500);
58
 
            }
59
 
        }
60
 
        else
61
 
        {
62
 
            setIcon(m_messagePix);
63
 
            m_blinkTimer->stop();
64
 
        }
65
 
    }
66
 
 
67
 
    void TrayIcon::endNotification()
68
 
    {
69
 
        m_blinkTimer->stop();
70
 
        setIcon(m_nomessagePix);
71
 
    }
72
 
 
73
 
    void TrayIcon::blinkTimeout()
74
 
    {
75
 
        m_blinkOn = !m_blinkOn;
76
 
 
77
 
        if(m_blinkOn)
78
 
        {
79
 
            setIcon(m_messagePix);
80
 
        }
81
 
        else
82
 
        {
83
 
            setIcon(m_nomessagePix);
84
 
        }
85
 
    }
86
 
 
87
 
    void TrayIcon::updateAppearance()
88
 
    {
89
 
        m_nomessagePix = loadIcon("konversation");
90
 
        m_messagePix = loadIcon("konv_message");
91
 
        setIcon(m_nomessagePix);
92
 
    }
93
 
}
94
 
 
95
 
#include "trayicon.moc"