File indexing completed on 2025-01-05 03:52:00

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2003-11-03
0007  * Description : calendar parameters.
0008  *
0009  * SPDX-FileCopyrightText: 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com>
0010  * SPDX-FileCopyrightText: 2007-2008 by Orgad Shaneh <orgads at gmail dot com>
0011  * SPDX-FileCopyrightText: 2011      by Andi Clemens <andi dot clemens at googlemail dot com>
0012  * SPDX-FileCopyrightText: 2012      by Angelo Naselli <anaselli at linux dot it>
0013  * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0014  *
0015  * SPDX-License-Identifier: GPL-2.0-or-later
0016  *
0017  * ============================================================ */
0018 
0019 #ifndef DIGIKAM_CAL_SETTINGS_H
0020 #define DIGIKAM_CAL_SETTINGS_H
0021 
0022 // Qt includes
0023 
0024 #include <QUrl>
0025 #include <QMap>
0026 #include <QDate>
0027 #include <QFont>
0028 #include <QPair>
0029 #include <QColor>
0030 #include <QObject>
0031 #include <QString>
0032 #include <QPointer>
0033 #include <QPrinter>
0034 
0035 // Local includes
0036 
0037 #include "digikam_config.h"
0038 
0039 namespace DigikamGenericCalendarPlugin
0040 {
0041 
0042 typedef QPair<QColor, QString> Day;
0043 
0044 struct CalParams
0045 {
0046 public:
0047 
0048     enum ItemPosition
0049     {
0050         Top = 0,
0051         Left,
0052         Right
0053     };
0054 
0055 public:
0056 
0057     QPageSize::PageSizeId pageSize;
0058     QPrinter::PrinterMode printResolution;
0059     int                   paperWidth;
0060     int                   paperHeight;
0061     int                   width;
0062     int                   height;
0063     bool                  drawLines;
0064     float                 ratio;
0065     ItemPosition         imgPos;
0066     QFont                 baseFont;
0067     int                   year;
0068 };
0069 
0070 // ---------------------------------------------------------------------------
0071 
0072 class CalSettings : public QObject
0073 {
0074     Q_OBJECT
0075 
0076 public:
0077 
0078     ~CalSettings() override;
0079 
0080     void setYear(int year);
0081     int  year() const;
0082     void setImage(int month, const QUrl& url);
0083     QUrl image(int month) const;
0084     void clearSpecial();
0085     void addSpecial(const QDate& date, const Day& info);
0086     bool isSpecial(int month, int day) const;
0087 
0088     QColor getDayColor(int month, int day) const;
0089     QString getDayDescr(int month, int day) const;
0090     QPrinter::PrinterMode resolution() const;
0091 
0092 #ifdef HAVE_KCALENDAR
0093 
0094     void loadSpecial(const QUrl& url, const QColor& color);
0095 
0096 #endif
0097 
0098     static CalSettings* instance(QObject* const parent = nullptr);
0099 
0100 public:
0101 
0102     CalParams params;
0103 
0104 Q_SIGNALS:
0105 
0106     void settingsChanged();
0107 
0108 public Q_SLOTS:
0109 
0110     void setPaperSize(const QString& paperSize);
0111     void setResolution(const QString& resolution);
0112     void setImagePos(int pos);
0113     void setDrawLines(bool draw);
0114     void setRatio(int ratio);
0115     void setFont(const QString& font);
0116 
0117 protected:
0118 
0119     bool isPrayDay(const QDate& date) const;
0120 
0121 private:
0122 
0123     // Disable
0124     explicit CalSettings(QObject* const parent);
0125     CalSettings(CalSettings const&)             = delete;
0126     CalSettings& operator=(CalSettings const&)  = delete;
0127 
0128 private:
0129 
0130     static QPointer<CalSettings> s_instance;
0131 
0132     class Private;
0133     Private* const d;
0134 };
0135 
0136 } // namespace Digikam
0137 
0138 #endif // DIGIKAM_CAL_SETTINGS_H