File indexing completed on 2023-05-30 10:45:25

0001 /*
0002     SPDX-FileCopyrightText: 2009-2011 Peter Hedlund <peter.hedlund@kdemail.net>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include "kwqcardview.h"
0007 
0008 
0009 KWQCardView::KWQCardView(QWidget *parent) : QGraphicsView(parent)
0010 {
0011     setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
0012     setInteractive(true);
0013     setStyleSheet(QStringLiteral("background: transparent; border: none"));
0014     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0015     setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0016 
0017     m_scene = new KWQCardScene(this);
0018     setScene(m_scene);
0019     connect(m_scene, &KWQCardScene::cardClicked, this, &KWQCardView::cardClicked);
0020 }
0021 
0022 void KWQCardView::resizeEvent(QResizeEvent* event)
0023 {
0024     if (scene() != 0)
0025         fitInView(scene()->sceneRect().adjusted(0, 0, 30, 30), Qt::KeepAspectRatio);
0026 
0027     QGraphicsView::resizeEvent(event);
0028 }
0029 
0030 void KWQCardView::setIdentifier(const QString &identifier)
0031 {
0032     if (scene() != 0)
0033         m_scene->setIdentifier(identifier);
0034 }
0035 
0036 void KWQCardView::setText(const QString &text)
0037 {
0038     if (scene() != 0)
0039         m_scene->setText(text);
0040 }
0041 
0042 void KWQCardView::setTextColor(const QColor &textColor)
0043 {
0044     if (scene() != 0)
0045         m_scene->setTextColor(textColor);
0046 }
0047 
0048 void KWQCardView::setTextFont(const QFont &font)
0049 {
0050     if (scene() != 0)
0051         m_scene->setTextFont(font);
0052 }
0053 
0054 void KWQCardView::setCardColor(const QColor &cardColor)
0055 {
0056     if (scene() != 0)
0057         m_scene->setCardColor(cardColor);
0058 }
0059 
0060 void KWQCardView::setFrameColor(const QColor &frameColor)
0061 {
0062     if (scene() != 0)
0063         m_scene->setFrameColor(frameColor);
0064 }
0065 
0066 void KWQCardView::setImage(const QPixmap &image)
0067 {
0068     if (scene() != 0)
0069         m_scene->setImage(image);
0070 }