File indexing completed on 2022-11-29 18:12:04

0001 /*
0002     appmenuwidget.cpp  -  The main Qt/KDE window
0003 
0004     SPDX-FileCopyrightText: 2008 Danilo Balzaque <danilo.balzaque@ltia.fc.unesp.br>
0005     SPDX-FileCopyrightText: 2008 Tadeu Araujo <tadeu.araujo@ltia.fc.unesp.br>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #include "AppMenuWidget.h"
0011 
0012 /* these includes are needed for KDE support */
0013 #include <KLocalizedString>
0014 #include <KActionCollection>
0015 #include <KStandardAction>
0016 
0017 /* these includes are needed for Qt support */
0018 #include <QPushButton>
0019 #include <QStandardPaths>
0020 
0021 #ifdef DEBUG
0022 #include <QDebug>
0023 #endif
0024 
0025 #include "ui_taskcolorsbase.h"
0026 #include "ui_taskfontsbase.h"
0027 #include "settingsclass.h"
0028 
0029 /* standard C++ library includes */
0030 #include <cstdlib>
0031 
0032 /* ----- public member functions ----- */
0033 
0034 /* constructor */
0035 AppMenuWidget::AppMenuWidget()
0036 {
0037 #ifdef DEBUG
0038     qDebug() << QStringLiteral("constructor AppMenuWidget");
0039 
0040 #endif
0041     setupActions();
0042 
0043     QString css =
0044         QStringLiteral("QPushButton#m_Freestyle {"
0045         "border: none;"
0046         "image: url(") +
0047         QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/icon_freestyle_1.png")) +
0048         QStringLiteral(");"
0049         "}"
0050         "QPushButton#m_Freestyle:hover {"
0051         "border: none;"
0052         "image: url(") +
0053         QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/icon_freestyle.png")) +
0054         QStringLiteral(");"
0055         "}"
0056         "QPushButton#m_Learning {"
0057         "border: none;"
0058         "image: url(") +
0059         QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/icon_learning_1.png")) +
0060         QStringLiteral(");"
0061         "}"
0062         "QPushButton#m_Learning:hover {"
0063         "border: none;"
0064         "image: url(") +
0065         QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kbruch/pics/icon_learning.png")) +
0066         QStringLiteral(");"
0067         "}"
0068         "QLabel#labelInfo, QLabel#labelFreestyle, QLabel#labelLearning"
0069         "{ font: bold 20px; }");
0070 
0071     setStyleSheet(css);
0072 
0073     QFont defaultFont = SettingsClass::taskFont();
0074     defaultFont.setBold(true);
0075     defaultFont.setPointSize(26);
0076 
0077     layout1 = new QHBoxLayout();
0078     layout1->setObjectName(QStringLiteral("layout1"));
0079     layout1->setAlignment(Qt::AlignCenter);
0080 
0081     baseWidget = new QWidget();
0082     baseWidget->setObjectName(QStringLiteral("baseWidget"));
0083 
0084     setCentralWidget(baseWidget);
0085 
0086     interfaceWidget = new QWidget(this);
0087     interfaceWidget->setObjectName(QStringLiteral("interfaceWidget"));
0088     interfaceWidget->setFixedSize(QSize(550, 350));
0089 
0090     gridLayout = new QGridLayout();
0091     gridLayout->setObjectName(QStringLiteral("gridLayout"));
0092 
0093     labelInfo = new QLabel(this);
0094     labelInfo->setObjectName(QStringLiteral("labelInfo"));
0095     labelInfo->setText(i18n("KBruch modes:"));
0096     labelInfo->setFont(defaultFont);
0097     gridLayout->addWidget(labelInfo, 0, 0, 1, 2);
0098 
0099     // Freestyle mode ----------------------------
0100     m_Freestyle = new QPushButton(this);
0101     m_Freestyle->setObjectName(QStringLiteral("m_Freestyle"));
0102     m_Freestyle->setToolTip(i18n("Open standard KBruch"));
0103     m_Freestyle->setFixedSize(QSize(150, 197));
0104     gridLayout->addWidget(m_Freestyle, 1, 0, Qt::AlignCenter);
0105 
0106     labelFreestyle = new QLabel(this);
0107     labelFreestyle->setObjectName(QStringLiteral("labelFreestyle"));
0108     labelFreestyle->setText(i18n("Exercise"));
0109     labelFreestyle->setFont(defaultFont);
0110     gridLayout->addWidget(labelFreestyle, 2, 0, Qt::AlignCenter);
0111 
0112     QObject::connect(m_Freestyle, &QPushButton::clicked, this, &AppMenuWidget::slotFreestyleClicked);
0113 
0114     // Learning mode ----------------------------
0115     m_Learning = new QPushButton(this);
0116     m_Learning->setObjectName(QStringLiteral("m_Learning"));
0117     m_Learning->setToolTip(i18n("Open learning KBruch"));
0118     m_Learning->setFixedSize(QSize(150, 197));
0119     gridLayout->addWidget(m_Learning, 1, 1, Qt::AlignCenter);
0120 
0121     labelLearning = new QLabel(this);
0122     labelLearning->setObjectName(QStringLiteral("labelLearning"));
0123     labelLearning->setText(i18n("Learning"));
0124     labelLearning->setFont(defaultFont);
0125     gridLayout->addWidget(labelLearning, 2, 1, Qt::AlignCenter);
0126 
0127     QObject::connect(m_Learning, &QPushButton::clicked, this, &AppMenuWidget::slotLearningClicked);
0128 
0129     gridLayout->setRowMinimumHeight(0, 30);
0130     gridLayout->setRowMinimumHeight(1, 250);
0131     gridLayout->setRowMinimumHeight(2, 70);
0132 
0133 
0134     interfaceWidget->setLayout(gridLayout);
0135     layout1->addWidget(interfaceWidget);
0136     baseWidget->setLayout(layout1);
0137 
0138     move(50, 50);
0139     setFixedSize(QSize(742, 520));
0140 }
0141 
0142 /* destructor */
0143 AppMenuWidget::~AppMenuWidget()
0144 {
0145 #ifdef DEBUG
0146     qDebug() << QStringLiteral("destructor AppMenuWidget()");
0147 #endif
0148 
0149     /* no need to delete any child widgets, Qt does it by itself */
0150 }
0151 
0152 void AppMenuWidget::setupActions()
0153 {
0154 #ifdef DEBUG
0155     qDebug() << QStringLiteral("setupActions FractionRingWidget");
0156 #endif
0157 
0158     // quit action
0159     KStandardAction::quit(this, SLOT(close()), actionCollection());
0160 
0161     resize(QSize(725, 330).expandedTo(minimumSizeHint()));
0162     setupGUI(Keys | Create, QStringLiteral("AppMenuWidgetui.rc"));
0163     setAutoSaveSettings();
0164 }
0165 
0166 void AppMenuWidget::slotApplySettings()
0167 {
0168 #ifdef DEBUG
0169     qDebug() << QStringLiteral("slotApplySettings FractionRingWidget");
0170 #endif
0171     return;
0172 }
0173 
0174 /* ------ private slots ------ */
0175 
0176 void AppMenuWidget::slotFreestyleClicked()
0177 {
0178     kbruchApp = new MainQtWidget();
0179     kbruchApp->show();
0180     hide();
0181     return;
0182 }
0183 
0184 void AppMenuWidget::slotLearningClicked()
0185 {
0186     fractionRing = new FractionRingWidget();
0187     fractionRing->show();
0188     hide();
0189     return;
0190 }