File indexing completed on 2024-12-08 04:00:44
0001 /* 0002 SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #include "window.hpp" 0008 0009 // plugins 0010 #include "../clipboardexport/plugin.hpp" 0011 #include "../fileexport/plugin.hpp" 0012 #include "../imagesource/plugin.hpp" 0013 #include "../plaintextdisplay/plugin.hpp" 0014 // widgets 0015 #include <abstractdisplaytool.hpp> 0016 #include <abstractexporttool.hpp> 0017 #include <abstractsourcetool.hpp> 0018 // KF 0019 #include <KLocalizedString> 0020 // Qt 0021 #include <QUrl> 0022 0023 namespace Kodaskanna 0024 { 0025 0026 Window::Window() 0027 : QDialog() 0028 { 0029 m_ui.setupUi(this); 0030 0031 m_sourceTool = ImageSource::createSourceTool(this); 0032 connect(m_sourceTool, &AbstractSourceTool::scanFinished, this, &Window::handleScanFinished); 0033 m_ui.sourceWidgetStackLayout->addWidget(m_sourceTool->widget()); 0034 0035 m_displayTool = PlainTextDisplay::createDisplayTool(this); 0036 m_ui.displayWidgetStackLayout->addWidget(m_displayTool->widget()); 0037 0038 m_exportTools = { 0039 ClipboardExport::createExportTool(this), 0040 FileExport::createExportTool(this), 0041 }; 0042 for (auto *tool : std::as_const(m_exportTools)) { 0043 tool->setupButtonBox(m_ui.buttonBox); 0044 } 0045 0046 connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accepted); 0047 connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &QDialog::rejected); 0048 } 0049 0050 Window::~Window() = default; 0051 0052 void Window::scanFromFile(const QUrl &fileUrl) 0053 { 0054 m_sourceTool->setOrigin(fileUrl); 0055 } 0056 0057 void Window::handleScanFinished(const ScanResult &scanResult) 0058 { 0059 m_scanResult = scanResult; 0060 m_displayTool->setScanResult(scanResult); 0061 for (auto *tool : std::as_const(m_exportTools)) { 0062 tool->setScanResult(scanResult); 0063 } 0064 } 0065 0066 }