File indexing completed on 2025-01-19 05:06:21
0001 /* 0002 SPDX-FileCopyrightText: 2010 Daniel Nicoletti <dantti12@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "ChooseLpd.h" 0008 #include "ui_ChooseLpd.h" 0009 0010 #include <KCupsRequest.h> 0011 #include <KLocalizedString> 0012 0013 #include <QPainter> 0014 0015 #include <QUrl> 0016 0017 ChooseLpd::ChooseLpd(QWidget *parent) 0018 : GenericPage(parent) 0019 , ui(new Ui::ChooseLpd) 0020 , m_isValid(false) 0021 { 0022 ui->setupUi(this); 0023 0024 // setup default options 0025 setWindowTitle(i18nc("@title:window", "Select a Printer to Add")); 0026 } 0027 0028 ChooseLpd::~ChooseLpd() 0029 { 0030 delete ui; 0031 } 0032 0033 void ChooseLpd::setValues(const QVariantMap &args) 0034 { 0035 m_args = args; 0036 const QString deviceUri = args[KCUPS_DEVICE_URI].toString(); 0037 if (deviceUri.contains(QLatin1Char('/'))) { 0038 m_isValid = false; 0039 return; 0040 } 0041 m_isValid = true; 0042 0043 ui->addressLE->setText(deviceUri); 0044 ui->addressLE->setFocus(); 0045 } 0046 0047 QVariantMap ChooseLpd::values() const 0048 { 0049 QVariantMap ret = m_args; 0050 ret[KCUPS_DEVICE_URI] = static_cast<QString>(QLatin1String("lpd://") + ui->addressLE->text()); 0051 return ret; 0052 } 0053 0054 bool ChooseLpd::canProceed() const 0055 { 0056 bool allow = false; 0057 if (!ui->addressLE->text().isEmpty()) { 0058 const QUrl url = QUrl(QLatin1String("lpd://") + ui->addressLE->text()); 0059 allow = url.isValid(); 0060 } 0061 return allow; 0062 } 0063 0064 bool ChooseLpd::isValid() const 0065 { 0066 return m_isValid; 0067 } 0068 0069 void ChooseLpd::checkSelected() 0070 { 0071 // Q_EMIT allowProceed(!devicesLV->selectionModel()->selection().isEmpty()); 0072 } 0073 0074 #include "moc_ChooseLpd.cpp"