File: TaskBarProgressNotifications.h

package info (click to toggle)
qtop 2.3.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,976 kB
  • sloc: cpp: 40,477; makefile: 7
file content (132 lines) | stat: -rw-r--r-- 3,271 bytes parent folder | download | duplicates (3)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef TaskBarProgressNotifications_h
#define TaskBarProgressNotifications_h

/*
 * based on UnityLauncher class
 * Copyright 2016 Kai Uwe Broulik <kde@privat.broulik.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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 6 of version 3 of the license.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "Counter.h"

#include <QObject>
#include <QVariantMap>

class TaskBarProgressNotifications : public QObject, private Base::Counter<TaskBarProgressNotifications>
{
    Q_OBJECT

    public:

    //* contructor
    explicit TaskBarProgressNotifications(QObject* parent = nullptr):
        QObject( parent ),
        Counter( "TaskBarProgressNotifications" )
        {}

    //*@name accessors
    //@{

    //* dbus path
    QString path() const
    { return path_; }

    //* launcher id
    QString launcherId() const
    { return launcherId_; }

    //* true if progress is visible
    bool progressVisible() const
    { return progressVisible_; }

    //* max progress
    int maximum() const
    { return maximum_; }

    //* current progress
    int value() const
    { return value_; }

    //@}

    //*@name modifiers
    //@{

    void setApplicationName( const QString& value )
    {
        path_ = QString( "/org/%1/UnityLauncher" ).arg( value );
        launcherId_ = QString( "%1.desktop" ).arg( value );
    }

    void setPath( const QString& value )
    { path_ = value; }

    void setLauncherId( const QString& value )
    { launcherId_ = value; }

    void setProgressVisible( bool );

    //@}

    public Q_SLOTS:

    //* maximum
    void setMaximum( int );

    //* value
    void setValue( int );

    private:

    #if QT_VERSION < 0x050100
    //* needed because there is not QMap constructor from initialzer list in older versions of Qt
    void _update(const std::initializer_list<typename std::pair<QString, QVariant>>& propertyList)
    {
        QVariantMap properties;
        for( auto property:propertyList )
        { properties.insert( property.first, property.second ); }
        _update( properties );
    }
    #endif

    //* update progress, by passing dbus signal
    void _update(const QVariantMap &properties);

    //* dbus signal path
    QString path_;

    //* launcher id
    QString launcherId_;

    //* true for the first time progressVisible is set to true
    bool first_ = true;

    //* true if progress is visible
    bool progressVisible_ = false;

    //* maximum progress
    int maximum_ = 0;

    //* current progress
    int value_ = 0;

};


#endif