File: chat-window-style.h

package info (click to toggle)
ktp-text-ui 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,680 kB
  • ctags: 1,142
  • sloc: cpp: 9,451; sh: 15; makefile: 9
file content (238 lines) | stat: -rw-r--r-- 6,613 bytes parent folder | download | duplicates (2)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
//Stolen from Kopete.

/*
   kopetechat-window-style.h - A Chat Window Style.

   Copyright (c) 2005      by Michaël Larouche     <larouche@kde.org>

   Kopete    (c) 2002-2008 by the Kopete developers <kopete-devel@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 of the License, or     *
   * (at your option) any later version.                                   *
   *                                                                       *
   *************************************************************************
*/
#ifndef CHATWINDOWSTYLE_H
#define CHATWINDOWSTYLE_H

#include <QtCore/QHash>
#include <ktpchat_export.h>

/**
* This class represent a single chat window style.
*
* @author Michaël Larouche <larouche@kde.org>
*/
class KDE_TELEPATHY_CHAT_EXPORT ChatWindowStyle : public QObject
{
public:
    /**
     * StyleVariants is a typedef to a QHash
     * key = Variant Name
     * value = Path to variant CSS file.
     * Path is relative to Resources directory.
     */
    typedef QHash<QString, QString> StyleVariants;

    /**
     * This enum specifies the mode of the constructor
     * - StyleBuildFast : Build the style the fatest possible
     * - StyleBuildNormal : List all variants of this style. Require a async dir list.
     */
    enum StyleBuildMode { StyleBuildFast, StyleBuildNormal};

    /**
     * @brief Build a single chat window style.
     *
     */
    explicit ChatWindowStyle(const QString &styleId, StyleBuildMode styleBuildMode = StyleBuildNormal);
    ChatWindowStyle(const QString &styleId, const QString &variantPath,
                    StyleBuildMode styleBuildMode = StyleBuildFast);
    virtual ~ChatWindowStyle();

    /**
     * Checks if the style is valid
     */
    bool isValid() const;

    /**
     * Get the list of all variants for this theme.
     * If the variant aren't listed, it call the lister
     * before returning the list of the Variants.
     * If the variant are listed, it just return the cached
     * variant list.
     * @return the StyleVariants QMap.
     */
    StyleVariants getVariants();

    /**
     * Get the style path.
     * The style path points to the directory where the style is located.
     * ex: ~/.kde/share/apps/kopete/styles/StyleName/
     *
     * @return the style path based.
     */
    QString id() const;

    /**
     * Get the style resource directory.
     * Resources directory is the base where all CSS, HTML and images are located.
     *
     * Adium(and now Kopete too) style directories are disposed like this:
     * StyleName/
     *          Contents/
     *            Resources/
     *
     * @return the path to the resource directory.
     */
    QString getStyleBaseHref() const;

    /** Returns true if this style supports showing a header at the top of the chat window*/

    bool hasHeader() const;


    QString getTemplateHtml() const;
    QString getHeaderHtml() const;
    QString getFooterHtml() const;
    QString getTopicHtml() const;

    QString getIncomingContentHtml() const;
    QString getIncomingNextContentHtml() const;
    QString getOutgoingContentHtml() const;
    QString getOutgoingNextContentHtml() const;
    QString getStatusHtml() const;

    QString getIncomingHistoryHtml() const;
    QString getIncomingNextHistoryHtml() const;
    QString getOutgoingHistoryHtml() const;
    QString getOutgoingNextHistoryHtml() const;
    QString getStatusHistoryHtml() const;

    QString getActionIncomingHtml() const;
    QString getActionOutgoingHtml() const;

    QString getFileTransferIncomingHtml() const;

    QString getVoiceClipIncomingHtml() const;

    QString getOutgoingStateSendingHtml() const;
    QString getOutgoingStateSentHtml() const;
    QString getOutgoingStateErrorHtml() const;
    QString getOutgoingStateUnknownHtml() const;

    /**
     * Check if the style is using a custom Template.html file
     */
    bool hasCustomTemplateHtml() const;

    /**
     * Check if the style has the support for Kopete Action template (Kopete extension)
     * @return true if the style has Action template.
     */
    bool hasActionTemplate() const;

    /**
     * Check if the supplied variant has a compact form
     */
    bool hasCompact(const QString & variant) const;

    /**
     * Return the compact version of the given style variant.
     * For the unmodified style, this returns "Variants/_compact_.css"
     */
    QString compact(const QString & variant) const;

    /**
     * Reload style from disk.
     */
    void reload();

    QString defaultVariantName() const;
    QString defaultFontFamily() const;
    int defaultFontSize() const;
    bool disableCombineConsecutive() const;
    int messageViewVersion() const;
private:
    /**
     * Read style HTML files from disk
     */
    void readStyleFiles();

    /**
     * Init this class
     */
    void init(const QString &styleName, StyleBuildMode styleBuildMode);

    /**
     * List available variants for the current style.
     */
    void listVariants();

    enum InternalIdentifier {
        Template,

        Header,
        Footer,
        Topic,

        Content,
        NextContent,
        History,
        NextHistory,
        Status,

        IncomingContent,
        IncomingNextContent,
        IncomingContext,
        IncomingNextContext,
        IncomingHistory,
        IncomingNextHistory,

        OutgoingContent,
        OutgoingNextContent,
        OutgoingContext,
        OutgoingNextContext,
        OutgoingHistory,
        OutgoingNextHistory,

        StatusHistory,

        ActionIncoming,
        ActionOutgoing,

        FileTransferIncoming,
        VoiceClipIncoming,

        OutgoingStateUnknown,
        OutgoingStateSending,
        OutgoingStateSent,
        OutgoingStateError
        //InfoPlist
    };

    /**
     * Abbreviate d->templateContents.insert( internalIdentifier, content )
     */
    void setContent(InternalIdentifier id, const QString &content);

    /**
     * Abbreviate d->templateContents.value( internalIdentifier )
     */
    QString content(InternalIdentifier id) const;

    /**
     * If subType is empty, use the superType
     */
    void inheritContent(InternalIdentifier subType, InternalIdentifier superType);

private:
    class Private;
    Private * const d;
};

#endif