File indexing completed on 2024-04-21 03:41:40

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003 */
0004 
0005 #include "isotopetablesettingscard.h"
0006 
0007 #include <QVBoxLayout>
0008 #include <KLocalizedString>
0009 
0010 #include <iostream>
0011 
0012 IsotopeTableSettingsCard::IsotopeTableSettingsCard(QWidget *parent, int mode)
0013     : QFrame(parent)
0014 {
0015     m_isotopeView = new IsotopeView(this, mode);
0016     initialize();
0017 }
0018 
0019 IsotopeTableSettingsCard::IsotopeTableSettingsCard(QWidget *parent)
0020     : QFrame(parent)
0021 {
0022     m_isotopeView = new IsotopeView(this);
0023     initialize();
0024 }
0025 
0026 void IsotopeTableSettingsCard::initialize()
0027 {
0028     auto vLayout = new QVBoxLayout();
0029 
0030     m_isotopeView->setInteractive(false);
0031     m_isotopeView->setZoom(0.06);
0032     // m_isotopeView->setMaximumWidth(200);
0033     // m_isotopeView->setMaximumHeight(150);
0034 
0035     m_radioButton = new QRadioButton();
0036     m_radioButton->setText(i18n("Next to each other"));
0037     connect(m_radioButton, &QRadioButton::toggled, this, [=]() {
0038         if (m_radioButton->isChecked())
0039             Q_EMIT checked(m_isotopeView->mode());
0040     });
0041 
0042     vLayout->addWidget(m_isotopeView);
0043     vLayout->addWidget(m_radioButton);
0044 
0045     setLayout(vLayout);
0046     installEventFilter(this);
0047     m_isotopeView->installEventFilter(this);
0048     m_isotopeView->viewport()->installEventFilter(this);
0049     m_radioButton->installEventFilter(this);
0050     setFocusProxy(m_radioButton);
0051 }
0052 
0053 bool IsotopeTableSettingsCard::eventFilter(QObject *object, QEvent *event)
0054 {
0055     Q_UNUSED(object);
0056     if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) {
0057         auto mouseEvent = static_cast<QMouseEvent *>(event);
0058         if (mouseEvent->button() == Qt::MouseButton::LeftButton) {
0059             m_radioButton->setChecked(true);
0060             return true;
0061         }
0062     }
0063     return false;
0064 }
0065 
0066 #include "moc_isotopetablesettingscard.cpp"