| 1 | /* |
| 2 | * Copyright (C) 2020 Damir Porobic <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "EnumTranslator.h" |
| 21 | |
| 22 | EnumTranslator *EnumTranslator::instance() |
| 23 | { |
| 24 | static EnumTranslator instance; |
| 25 | return &instance; |
| 26 | } |
| 27 | |
| 28 | QString EnumTranslator::toTranslatedString(CaptureModes captureMode) const |
| 29 | { |
| 30 | Q_ASSERT(mCaptureModeMap.contains(captureMode)); |
| 31 | |
| 32 | return mCaptureModeMap[captureMode]; |
| 33 | } |
| 34 | |
| 35 | QString EnumTranslator::toString(UploadStatus uploadStatus) const |
| 36 | { |
| 37 | Q_ASSERT(mUploadStatusMap.contains(uploadStatus)); |
| 38 | |
| 39 | return mUploadStatusMap[uploadStatus]; |
| 40 | } |
| 41 | |
| 42 | QString EnumTranslator::toString(PluginType pluginType) const |
| 43 | { |
| 44 | Q_ASSERT(mPluginTypeMap.contains(pluginType)); |
| 45 | |
| 46 | return mPluginTypeMap[pluginType]; |
| 47 | } |
| 48 | |
| 49 | EnumTranslator::EnumTranslator() |
| 50 | { |
| 51 | mapCaptureModeEnum(); |
| 52 | mapUploadStatusEnum(); |
| 53 | mapPluginTypeEnum(); |
| 54 | } |
| 55 | |
| 56 | void EnumTranslator::mapUploadStatusEnum() |
| 57 | { |
| 58 | mUploadStatusMap[UploadStatus::NoError] = QLatin1String("No Error"); |
| 59 | mUploadStatusMap[UploadStatus::ConnectionError] = QLatin1String("Connection Error"); |
| 60 | mUploadStatusMap[UploadStatus::PermissionError] = QLatin1String("Permission Error"); |
| 61 | mUploadStatusMap[UploadStatus::TimedOut] = QLatin1String("Timed Out"); |
| 62 | mUploadStatusMap[UploadStatus::Crashed] = QLatin1String("Crashed"); |
| 63 | mUploadStatusMap[UploadStatus::FailedToStart] = QLatin1String("Failed To Start"); |
| 64 | mUploadStatusMap[UploadStatus::ReadError] = QLatin1String("Read Error"); |
| 65 | mUploadStatusMap[UploadStatus::ScriptWroteToStdErr] = QLatin1String("Script Wrote To StdErr"); |
| 66 | mUploadStatusMap[UploadStatus::UnableToSaveTemporaryImage] = QLatin1String("Unable To Save Temporary Image"); |
| 67 | mUploadStatusMap[UploadStatus::UnknownError] = QLatin1String("Unknown Error"); |
| 68 | mUploadStatusMap[UploadStatus::WebError] = QLatin1String("Web Error"); |
| 69 | mUploadStatusMap[UploadStatus::WriteError] = QLatin1String("Write Error"); |
| 70 | } |
| 71 | |
| 72 | void EnumTranslator::mapCaptureModeEnum() |
| 73 | { |
| 74 | mCaptureModeMap[CaptureModes::RectArea] = tr("Rectangular Area"); |
| 75 | mCaptureModeMap[CaptureModes::LastRectArea] = tr("Last Rectangular Area"); |
| 76 | mCaptureModeMap[CaptureModes::FullScreen] = tr("Full Screen (All Monitors)"); |
| 77 | mCaptureModeMap[CaptureModes::CurrentScreen] = tr("Current Screen"); |
| 78 | mCaptureModeMap[CaptureModes::ActiveWindow] = tr("Active Window"); |
| 79 | mCaptureModeMap[CaptureModes::WindowUnderCursor] = tr("Window Under Cursor"); |
| 80 | mCaptureModeMap[CaptureModes::Portal] = tr("Screenshot Portal"); |
| 81 | } |
| 82 | |
| 83 | void EnumTranslator::mapPluginTypeEnum() |
| 84 | { |
| 85 | mPluginTypeMap[PluginType::Ocr] = QLatin1String("OCR"); |
| 86 | } |