File indexing completed on 2025-03-09 03:52:06
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-09-09 0007 * Description : a presentation tool. 0008 * 0009 * SPDX-FileCopyrightText: 2008 by Valerio Fuoglio <valerio dot fuoglio at gmail dot com> 0010 * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "presentation_captionpage.h" 0017 0018 // Qt includes 0019 0020 #include <QFont> 0021 #include <QFontDialog> 0022 #include <QPalette> 0023 0024 // Local includes 0025 0026 #include "presentationcontainer.h" 0027 0028 namespace DigikamGenericPresentationPlugin 0029 { 0030 0031 PresentationCaptionPage::PresentationCaptionPage(QWidget* const parent, 0032 PresentationContainer* const sharedData) 0033 : QWidget(parent) 0034 { 0035 setupUi(this); 0036 0037 m_sharedData = sharedData; 0038 m_fontSampleLbl->setText(i18n("This is a comment sample...")); 0039 m_fontSampleLbl->setAutoFillBackground(true); 0040 } 0041 0042 PresentationCaptionPage::~PresentationCaptionPage() 0043 { 0044 } 0045 0046 void PresentationCaptionPage::readSettings() 0047 { 0048 connect(m_commentsFontColor, SIGNAL(signalColorSelected(QColor)), 0049 this, SLOT(slotCommentsFontColorChanged())); 0050 0051 connect(m_commentsBgColor, SIGNAL(signalColorSelected(QColor)), 0052 this, SLOT(slotCommentsBgColorChanged())); 0053 0054 connect(m_fontselectBtn, SIGNAL(clicked()), 0055 this, SLOT(slotOpenFontDialog())); 0056 0057 m_commentsLinesLengthSpinBox->setValue(m_sharedData->commentsLinesLength); 0058 m_commentsFontColor->setColor(QColor(m_sharedData->commentsFontColor)); 0059 m_commentsBgColor->setColor(QColor(m_sharedData->commentsBgColor)); 0060 m_commentsDrawOutlineCheckBox->setChecked(m_sharedData->commentsDrawOutline); 0061 m_fontSampleLbl->setFont(*(m_sharedData->captionFont)); 0062 m_commentsBgTransparency->setValue(m_sharedData->bgOpacity); 0063 0064 slotCommentsBgColorChanged(); 0065 slotCommentsFontColorChanged(); 0066 } 0067 0068 void PresentationCaptionPage::saveSettings() 0069 { 0070 delete m_sharedData->captionFont; 0071 m_sharedData->captionFont = new QFont(m_fontSampleLbl->font()); 0072 QColor fontColor = QColor(m_commentsFontColor->color()); 0073 m_sharedData->commentsFontColor = fontColor.rgb(); 0074 QColor bgColor = QColor(m_commentsBgColor->color()); 0075 m_sharedData->commentsBgColor = bgColor.rgb(); 0076 m_sharedData->commentsDrawOutline = m_commentsDrawOutlineCheckBox->isChecked(); 0077 m_sharedData->commentsLinesLength = m_commentsLinesLengthSpinBox->value(); 0078 m_sharedData->bgOpacity = m_commentsBgTransparency->value(); 0079 } 0080 0081 void PresentationCaptionPage::slotCommentsBgColorChanged() 0082 { 0083 QPalette palette = m_fontSampleLbl->palette(); 0084 palette.setColor(m_fontSampleLbl->backgroundRole(), m_commentsBgColor->color()); 0085 m_fontSampleLbl->setPalette(palette); 0086 } 0087 0088 void PresentationCaptionPage::slotCommentsFontColorChanged() 0089 { 0090 QPalette palette = m_fontSampleLbl->palette(); 0091 palette.setColor(m_fontSampleLbl->foregroundRole(), m_commentsFontColor->color()); 0092 m_fontSampleLbl->setPalette(palette); 0093 } 0094 0095 void PresentationCaptionPage::slotOpenFontDialog() 0096 { 0097 bool ok = false; 0098 QFont f = QFontDialog::getFont(&ok, *(m_sharedData->captionFont), this); 0099 0100 if (ok) 0101 { 0102 m_fontSampleLbl->setFont(f); 0103 } 0104 } 0105 0106 } // namespace DigikamGenericPresentationPlugin 0107 0108 #include "moc_presentation_captionpage.cpp"