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 widget used to preview the active template. 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: 2012 by Angelo Naselli <anaselli at linux dot it> 0012 * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0013 * 0014 * SPDX-License-Identifier: GPL-2.0-or-later 0015 * 0016 * ============================================================ */ 0017 0018 #include "calwidget.h" 0019 0020 // Local includes 0021 0022 #include "calpainter.h" 0023 #include "calsettings.h" 0024 #include "digikam_debug.h" 0025 0026 namespace DigikamGenericCalendarPlugin 0027 { 0028 0029 CalWidget::CalWidget(QWidget* const parent) 0030 : QWidget (parent), 0031 m_current(1) 0032 { 0033 setAttribute(Qt::WA_OpaquePaintEvent); 0034 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 0035 } 0036 0037 CalWidget::~CalWidget() 0038 { 0039 } 0040 0041 void CalWidget::setCurrent(int curr) 0042 { 0043 m_current = curr; 0044 } 0045 0046 int CalWidget::current() const 0047 { 0048 return m_current; 0049 } 0050 0051 void CalWidget::paintEvent(QPaintEvent* e) 0052 { 0053 int month = m_current; 0054 CalPainter painter(this); 0055 0056 QUrl imgUrl = CalSettings::instance()->image(month); 0057 painter.setImage(imgUrl); 0058 painter.paint(month); 0059 0060 Q_UNUSED(e); 0061 } 0062 0063 void CalWidget::recreate() 0064 { 0065 CalParams& params = CalSettings::instance()->params; 0066 0067 setFixedSize(params.width, params.height); 0068 update(); 0069 } 0070 0071 } // Namespace Digikam 0072 0073 #include "moc_calwidget.cpp"