digiKam
calsettings.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2003-11-03
7  * Description : calendar parameters.
8  *
9  * Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com>
10  * Copyright (C) 2007-2008 by Orgad Shaneh <orgads at gmail dot com>
11  * Copyright (C) 2011 by Andi Clemens <andi dot clemens at googlemail dot com>
12  * Copyright (C) 2012 by Angelo Naselli <anaselli at linux dot it>
13  * Copyright (C) 2012-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
14  *
15  * This program is free software; you can redistribute it
16  * and/or modify it under the terms of the GNU General
17  * Public License as published by the Free Software Foundation;
18  * either version 2, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * ============================================================ */
26 
27 #ifndef DIGIKAM_CAL_SETTINGS_H
28 #define DIGIKAM_CAL_SETTINGS_H
29 
30 // Qt includes
31 
32 #include <QUrl>
33 #include <QMap>
34 #include <QDate>
35 #include <QFont>
36 #include <QPair>
37 #include <QColor>
38 #include <QObject>
39 #include <QString>
40 #include <QPointer>
41 #include <QPrinter>
42 
43 // Local includes
44 
45 #include "digikam_config.h"
46 
48 {
49 
50 typedef QPair<QColor, QString> Day;
51 
52 struct CalParams
53 {
54 public:
55 
57  {
58  Top = 0,
60  Right
61  };
62 
63 public:
64 
65  QPageSize::PageSizeId pageSize;
66  QPrinter::PrinterMode printResolution;
69  int width;
70  int height;
71  bool drawLines;
72  float ratio;
74  QFont baseFont;
75  int year;
76 };
77 
78 // ---------------------------------------------------------------------------
79 
80 class CalSettings : public QObject
81 {
82  Q_OBJECT
83 
84 public:
85 
86  ~CalSettings() override;
87 
88  void setYear(int year);
89  int year() const;
90  void setImage(int month, const QUrl& url);
91  QUrl image(int month) const;
92  void clearSpecial();
93  void addSpecial(const QDate& date, const Day& info);
94  bool isSpecial(int month, int day) const;
95 
96  QColor getDayColor(int month, int day) const;
97  QString getDayDescr(int month, int day) const;
98  QPrinter::PrinterMode resolution() const;
99 
100 #ifdef HAVE_KCALENDAR
101 
102  void loadSpecial(const QUrl& url, const QColor& color);
103 
104 #endif
105 
106  static CalSettings* instance(QObject* const parent = nullptr);
107 
108 public:
109 
111 
112 Q_SIGNALS:
113 
115 
116 public Q_SLOTS:
117 
118  void setPaperSize(const QString& paperSize);
119  void setResolution(const QString& resolution);
120  void setImagePos(int pos);
121  void setDrawLines(bool draw);
122  void setRatio(int ratio);
123  void setFont(const QString& font);
124 
125 protected:
126 
127  bool isPrayDay(const QDate& date) const;
128 
129 private:
130 
131  // Disable
132  explicit CalSettings(QObject* const parent);
133  CalSettings(CalSettings const&) = delete;
134  CalSettings& operator=(CalSettings const&) = delete;
135 
136 private:
137 
138  static QPointer<CalSettings> s_instance;
139 
140  class Private;
141  Private* const d;
142 };
143 
144 } // namespace Digikam
145 
146 #endif // DIGIKAM_CAL_SETTINGS_H
Definition: calsettings.h:81
void setDrawLines(bool draw)
Definition: calsettings.cpp:190
static CalSettings * instance(QObject *const parent=nullptr)
Definition: calsettings.cpp:83
bool isPrayDay(const QDate &date) const
Definition: calsettings.cpp:234
bool isSpecial(int month, int day) const
Definition: calsettings.cpp:242
CalParams params
Definition: calsettings.h:110
QPrinter::PrinterMode resolution() const
Definition: calsettings.cpp:288
int year() const
Definition: calsettings.cpp:100
QColor getDayColor(int month, int day) const
Definition: calsettings.cpp:252
void setYear(int year)
Definition: calsettings.cpp:93
void setFont(const QString &font)
Definition: calsettings.cpp:208
~CalSettings() override
Definition: calsettings.cpp:78
void addSpecial(const QDate &date, const Day &info)
Definition: calsettings.cpp:222
void setImage(int month, const QUrl &url)
Definition: calsettings.cpp:105
QUrl image(int month) const
Definition: calsettings.cpp:110
void setRatio(int ratio)
Definition: calsettings.cpp:199
void clearSpecial()
Definition: calsettings.cpp:217
QString getDayDescr(int month, int day) const
Definition: calsettings.cpp:274
void setImagePos(int pos)
Definition: calsettings.cpp:147
void setResolution(const QString &resolution)
Definition: calsettings.cpp:133
void setPaperSize(const QString &paperSize)
Definition: calsettings.cpp:115
Definition: calendarplugin.cpp:38
QPair< QColor, QString > Day
Definition: calsettings.h:50
Definition: calsettings.h:53
ItemPosition
Definition: calsettings.h:57
@ Right
Definition: calsettings.h:60
@ Left
Definition: calsettings.h:59
@ Top
Definition: calsettings.h:58
int paperWidth
Definition: calsettings.h:67
int width
Definition: calsettings.h:69
QPrinter::PrinterMode printResolution
Definition: calsettings.h:66
bool drawLines
Definition: calsettings.h:71
QPageSize::PageSizeId pageSize
Definition: calsettings.h:65
float ratio
Definition: calsettings.h:72
int height
Definition: calsettings.h:70
QFont baseFont
Definition: calsettings.h:74
int paperHeight
Definition: calsettings.h:68
ItemPosition imgPos
Definition: calsettings.h:73
int year
Definition: calsettings.h:75