File: c2bSettings.h

package info (click to toggle)
cb2bib 1.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,368 kB
  • sloc: cpp: 24,179; sh: 481; makefile: 16
file content (83 lines) | stat: -rw-r--r-- 2,105 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
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
/***************************************************************************
 *   Copyright (C) 2004-2015 by Pere Constans
 *   constans@molspaces.com
 *   cb2Bib version 1.9.2. Licensed under the GNU GPL version 3.
 *   See the LICENSE file that comes with this distribution.
 ***************************************************************************/
#ifndef C2BSETTINGS_H
#define C2BSETTINGS_H

#include "c2bColors.h"

#include <settings.h>

#include <QFont>
#include <QKeySequence>

class QAction;
class QProgressBar;
class QShortcut;


class c2bSettings : public settings
{

    Q_OBJECT

public:
    ~c2bSettings();

    QFont c2bMonoFont;
    c2bColors colors;
    void notify();
    void update();
    static c2bSettings* initSettings();

    void setKeysequence(const QString& fullname, QShortcut* shortcut);
    void setKeysequence(const QString& path, QAction* action);
    void setKeysequences(const QHash<QString, QKeySequence>& keysequences);
    inline QKeySequence keysequence(const QString& fullname) const
    {
        return value(fullname).value<QKeySequence>();
    }
    inline QKeySequence defaultKeysequence(const QString& fullname) const
    {
        return _default_keysequences.value(fullname);
    }
    inline QByteArray ksname(const QString& fullname) const
    {
        return value(fullname).value<QKeySequence>().toString(QKeySequence::NativeText).toLatin1();
    }
    inline QStringList shortcutNames() const
    {
        return _default_keysequences.keys();
    }


signals:
    void newSettings();


private:
    c2bSettings(const QString& organization, const QString& application, QObject* parento = 0);
    c2bSettings(const QString& fn, QObject* parento = 0);

    QMap<QString, QKeySequence> _default_keysequences;
    QProgressBar* _progress_bar;
    void init();
    void processReferenceFile();
    void setDefaults();
#ifdef Q_OS_WIN
    QString decodeFilename(const QString& fn) const;
#endif


private slots:
    void guiExits();
    void processReferenceFileEvent();

};

#define c2bSettingsP (static_cast<c2bSettings*>(settings::instance()))

#endif