File: knotifyconfig.h

package info (click to toggle)
kde-runtime 4%3A17.08.3-2.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 25,204 kB
  • sloc: cpp: 111,675; ansic: 5,030; perl: 1,579; xml: 793; sh: 407; makefile: 42; python: 28
file content (128 lines) | stat: -rw-r--r-- 3,009 bytes parent folder | download | duplicates (4)
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
/*
   Copyright (C) 2005-2009 by Olivier Goffart <ogoffart at kde.org>


   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, or (at your option)
   any later version.

   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, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

 */

#ifndef KNOTIFYCONFIG_H
#define KNOTIFYCONFIG_H

#include <ksharedconfig.h>

#include <QPair>
#include <QPixmap>
#include <QObject> //for Wid

#include "knotify_export.h"

typedef QList< QPair<QString,QString> > ContextList;

/**
 * An image with lazy loading from the byte array
 */
class KNOTIFY_EXPORT KNotifyImage
{
	public:
		KNotifyImage() : dirty(false) {}
		KNotifyImage(const QByteArray &data) : source(data), dirty(true) {}
		QImage toImage();
		bool isNull() {
			return dirty ? source.isEmpty() : image.isNull();
		}
		QByteArray data() const {
			return source;
		}
	private:
		QByteArray source;
		QImage image;
		bool dirty;
};


/**
 * Represent the configuration for an event
 * @author Olivier Goffart <ogoffart@kde.org>
*/
class KNOTIFY_EXPORT KNotifyConfig
{
	public:
		KNotifyConfig(const QString &appname, const ContextList &_contexts , const QString &_eventid);
		~KNotifyConfig();

		KNotifyConfig *copy() const;
	
		/**
		 * @return entry from the knotifyrc file
		 * 
		 * This will return the configuration from the user for the given key.
		 * It first look into the user config file, and then in the global config file.
		 * 
		 * return a null string if the entry doesn't exist
		 */
		QString readEntry(const QString& entry , bool path=false);
		
		/**
		 * the title of the notification
		 */
		QString title;
		/**
		 * the text of the notification
		 */
		QString text;
		/**
		 * the pixmap to put on the notification
		 */
		KNotifyImage image;
		/**
		 * How long the notification should be presented (in seconds).
		 * -1 means server decides,
		 *  0 means infinite.
		 */
		int timeout;
		/**
		 * The windowsID of the window that initiated the notification
		 * (it is a window in the client)
		 */
		WId winId;
		/**
		 * the user-readable list of action.
		 */
		QStringList actions;
		
		/**
		 * the name of the application that triggered the notification
		 */
		QString appname;

		/**
		 * @internal
		 */
		KSharedConfig::Ptr eventsfile,configfile;
		ContextList contexts;
		
		/**
		 * the name of the notification
		 */
		QString eventid;

		/**
		 * reparse the cached configs.  to be used when the config may have changed
		 */
		static void reparseConfiguration();
};

#endif