6#include "bergamotenginesettingswidget.h"
7#include <KLocalizedString>
15BergamotEngineSettingsWidget::BergamotEngineSettingsWidget(
QWidget *parent)
19 , mUseLocalCache(new
QCheckBox(
i18nc(
"@option:check",
"Use translation cache"), this))
22 mainLayout->setObjectName(QStringLiteral(
"mainLayout"));
23 mainLayout->setContentsMargins({});
25 auto resourceBox =
new QGroupBox(
i18n(
"Resource Usage"),
this);
26 resourceBox->setObjectName(QStringLiteral(
"resourceBox"));
27 mainLayout->addWidget(resourceBox);
29 mNumberThreads->setObjectName(QStringLiteral(
"mNumberThreads"));
30 mMemoryByThreads->setObjectName(QStringLiteral(
"mMemoryByThreads"));
32 mUseLocalCache->setObjectName(QStringLiteral(
"mUseLocalCache"));
36 resourceBox->setLayout(formLayout);
37 formLayout->addRow(
i18n(
"Thread:"), mNumberThreads);
38 formLayout->addRow(
i18n(
"Memory by Thread:"), mMemoryByThreads);
39 formLayout->addWidget(mUseLocalCache);
43BergamotEngineSettingsWidget::~BergamotEngineSettingsWidget() =
default;
45void BergamotEngineSettingsWidget::setSettingsInfo(
const BergamotEngineUtils::SettingsInfo &info)
49 mUseLocalCache->
setChecked(info.useLocalCache);
52BergamotEngineUtils::SettingsInfo BergamotEngineSettingsWidget::settingsInfo()
const
54 BergamotEngineUtils::SettingsInfo info;
55 info.memoryByThread = mMemoryByThreads->
currentData().toInt();
56 info.numberOfThread = mNumberThreads->
currentData().toInt();
57 info.useLocalCache = mUseLocalCache->
isChecked();
61void BergamotEngineSettingsWidget::fillCombobox()
63 const auto processorCount = std::thread::hardware_concurrency();
65 for (
int cores = processorCount; cores > 0; cores -= 2) {
69 const QList<int> memorys = {64, 128, 256, 512, 768, 1024, 1280, 1536, 1762, 2048};
70 for (
const int memory : memorys) {
75#include "moc_bergamotenginesettingswidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
void setCurrentIndex(int index)
int findData(const QVariant &data, int role, Qt::MatchFlags flags) const const
void setObjectName(QAnyStringView name)
QString number(double n, char format, int precision)