File indexing completed on 2024-12-01 04:36:38

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "configuregeneralwidget.h"
0008 #include "ruqolaglobalconfig.h"
0009 #include <KLocalizedString>
0010 #include <QCheckBox>
0011 #include <QVBoxLayout>
0012 
0013 ConfigureGeneralWidget::ConfigureGeneralWidget(QWidget *parent)
0014     : QWidget(parent)
0015     , mSetOnlineForAllAccount(new QCheckBox(i18n("Set accounts online on startup"), this))
0016     , mShowImageByDefault(new QCheckBox(i18n("Show images by default"), this))
0017     , mShowPreviewUrlByDefault(new QCheckBox(i18n("Show preview url by default"), this))
0018     , mMarkAsReadOnTextClicked(new QCheckBox(i18n("Mark room as read when clicking to write a reply"), this))
0019     , mEnableSystemTray(new QCheckBox(i18n("Enable system tray icon"), this))
0020     , mEnableLogging(new QCheckBox(i18n("Enable logging"), this))
0021     , mShowHoverHightLights(new QCheckBox(i18n("Show hover highlights"), this))
0022     , mAnimateGif(new QCheckBox(i18n("Animate Gif Image"), this))
0023     , mStoreMessageInDataBase(new QCheckBox(i18n("Use local dataBase (experimental)"), this))
0024 {
0025     auto mainLayout = new QVBoxLayout(this);
0026     mainLayout->setObjectName(QStringLiteral("mainLayout"));
0027 
0028     mSetOnlineForAllAccount->setObjectName(QStringLiteral("mSetOnlineForAllAccount"));
0029     mainLayout->addWidget(mSetOnlineForAllAccount);
0030 
0031     mShowImageByDefault->setObjectName(QStringLiteral("mShowImageByDefault"));
0032     mainLayout->addWidget(mShowImageByDefault);
0033 
0034     mShowPreviewUrlByDefault->setObjectName(QStringLiteral("mShowPreviewUrlByDefault"));
0035     mainLayout->addWidget(mShowPreviewUrlByDefault);
0036 
0037     mMarkAsReadOnTextClicked->setObjectName(QStringLiteral("mMarkAsReadOnTextClicked"));
0038     mainLayout->addWidget(mMarkAsReadOnTextClicked);
0039 
0040     mEnableSystemTray->setObjectName(QStringLiteral("mEnableSystemTray"));
0041     mainLayout->addWidget(mEnableSystemTray);
0042 
0043     mEnableLogging->setObjectName(QStringLiteral("mEnableLogging"));
0044     mainLayout->addWidget(mEnableLogging);
0045 
0046     mShowHoverHightLights->setObjectName(QStringLiteral("mShowHoverHightLights"));
0047     mainLayout->addWidget(mShowHoverHightLights);
0048 
0049     mAnimateGif->setObjectName(QStringLiteral("mAnimateGif"));
0050     mainLayout->addWidget(mAnimateGif);
0051 
0052     mStoreMessageInDataBase->setObjectName(QStringLiteral("mStoreMessageInDataBase"));
0053     mainLayout->addWidget(mStoreMessageInDataBase);
0054 
0055     mainLayout->addStretch(1);
0056 }
0057 
0058 ConfigureGeneralWidget::~ConfigureGeneralWidget() = default;
0059 
0060 void ConfigureGeneralWidget::save()
0061 {
0062     RuqolaGlobalConfig::self()->setSetOnlineAccounts(mSetOnlineForAllAccount->isChecked());
0063     RuqolaGlobalConfig::self()->setShowImage(mShowImageByDefault->isChecked());
0064     RuqolaGlobalConfig::self()->setMarkAsReadOnTextClicked(mMarkAsReadOnTextClicked->isChecked());
0065     RuqolaGlobalConfig::self()->setEnableSystemTray(mEnableSystemTray->isChecked());
0066     RuqolaGlobalConfig::self()->setEnableLogging(mEnableLogging->isChecked());
0067     RuqolaGlobalConfig::self()->setShowHoverHighlights(mShowHoverHightLights->isChecked());
0068     RuqolaGlobalConfig::self()->setAnimateGifImage(mAnimateGif->isChecked());
0069     RuqolaGlobalConfig::self()->setStoreMessageInDataBase(mStoreMessageInDataBase->isChecked());
0070     RuqolaGlobalConfig::self()->setShowPreviewUrl(mShowPreviewUrlByDefault->isChecked());
0071     RuqolaGlobalConfig::self()->save();
0072 }
0073 
0074 void ConfigureGeneralWidget::load()
0075 {
0076     mSetOnlineForAllAccount->setChecked(RuqolaGlobalConfig::self()->setOnlineAccounts());
0077     mShowImageByDefault->setChecked(RuqolaGlobalConfig::self()->showImage());
0078     mMarkAsReadOnTextClicked->setChecked(RuqolaGlobalConfig::self()->markAsReadOnTextClicked());
0079     mEnableSystemTray->setChecked(RuqolaGlobalConfig::self()->enableSystemTray());
0080     mEnableLogging->setChecked(RuqolaGlobalConfig::self()->enableLogging());
0081     mShowHoverHightLights->setChecked(RuqolaGlobalConfig::self()->showHoverHighlights());
0082     mAnimateGif->setChecked(RuqolaGlobalConfig::self()->animateGifImage());
0083     mStoreMessageInDataBase->setChecked(RuqolaGlobalConfig::self()->storeMessageInDataBase());
0084     mShowPreviewUrlByDefault->setChecked(RuqolaGlobalConfig::self()->showPreviewUrl());
0085 }
0086 
0087 #include "moc_configuregeneralwidget.cpp"