File indexing completed on 2024-03-24 03:53:58
0001 /* 0002 SPDX-FileCopyrightText: 2021 Andreas Cord-Landwehr <cordlandwehr@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "translationshelloptions.h" 0007 #include <KLed> 0008 #include <KLocalizedString> 0009 0010 TranslationShellOptions::TranslationShellOptions(QWidget *parent) 0011 : QWidget(parent) 0012 { 0013 setupUi(this); 0014 0015 KLed *installStatusLed = new KLed(this); 0016 installStatusLed->setLook(KLed::Look::Flat); 0017 QLabel *installStatusText = new QLabel(this); 0018 if (mTranslationShellAdapter.isTranslateShellAvailable()) { 0019 installStatusLed->setState(KLed::State::On); 0020 installStatusText->setText(i18n("translate-shell is available.")); 0021 } else { 0022 installStatusLed->setState(KLed::State::Off); 0023 installStatusText->setText(i18n("translate-shell executable could not be found.")); 0024 buttonRunTest->setEnabled(false); 0025 } 0026 formLayoutInstalledState->insertRow(0, installStatusLed, installStatusText); 0027 0028 connect(buttonRunTest, &QToolButton::clicked, this, &TranslationShellOptions::runTranslateShellTest); 0029 labelResultArea->setText("..."); 0030 } 0031 0032 void TranslationShellOptions::runTranslateShellTest() 0033 { 0034 auto translationResult = mTranslationShellAdapter.translate("parley", "en", "de"); 0035 if (translationResult.m_suggestions.count() > 0) { 0036 labelResultArea->setText(translationResult.m_suggestions.first()); 0037 } else { 0038 labelResultArea->setText(i18n("Error")); 0039 } 0040 } 0041 0042 #include "moc_translationshelloptions.cpp"