File indexing completed on 2024-09-22 04:47:57
0001 /* 0002 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com> 0003 0004 Based on MailTransport code by: 0005 SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org> 0006 0007 Based on KMail code by: 0008 SPDX-FileCopyrightText: 2001-2002 Michael Haeckel <haeckel@kde.org> 0009 0010 SPDX-License-Identifier: LGPL-2.0-or-later 0011 */ 0012 0013 #pragma once 0014 0015 #include "mailtransport_export.h" 0016 #include <QWidget> 0017 0018 #include <memory> 0019 0020 class KConfigDialogManager; 0021 0022 namespace MailTransport 0023 { 0024 class Transport; 0025 class TransportConfigWidgetPrivate; 0026 0027 /** 0028 @internal 0029 0030 Abstract configuration widget for a mail transport. It makes sure that 0031 the configured transport has a unique name, and takes care of writing its 0032 settings to the config file. If it is a new transport, the caller must 0033 still call TransportManager::addTransport() to register the transport. 0034 0035 Concrete configuration is done in subclasses SMTPConfigWidget. 0036 0037 To configure a transport from applications, use 0038 TransportManager::configureTransport(). You still need to call 0039 TransportManager::addTransport() if this is a new transport, not registered 0040 with TransportManager. 0041 0042 @author Constantin Berzan <exit3219@gmail.com> 0043 @since 4.4 0044 */ 0045 class MAILTRANSPORT_EXPORT TransportConfigWidget : public QWidget 0046 { 0047 Q_OBJECT 0048 0049 public: 0050 /** 0051 Creates a new mail transport configuration widget for the given 0052 Transport object. 0053 @param transport The Transport object to configure. 0054 @param parent The parent widget. 0055 */ 0056 explicit TransportConfigWidget(Transport *transport, QWidget *parent = nullptr); 0057 0058 /** 0059 Destroys the widget. 0060 */ 0061 ~TransportConfigWidget() override; 0062 0063 /** 0064 @internal 0065 Get the KConfigDialogManager for this widget. 0066 */ 0067 KConfigDialogManager *configManager() const; 0068 0069 public Q_SLOTS: 0070 /** 0071 Saves the transport's settings. 0072 0073 The base implementation writes the settings to the config file and makes 0074 sure the transport has a unique name. Reimplement in derived classes to 0075 save your custom settings, and call the base implementation. 0076 */ 0077 // TODO: do we also want to check for invalid settings? 0078 virtual void apply(); 0079 0080 protected: 0081 std::unique_ptr<TransportConfigWidgetPrivate> const d_ptr; 0082 TransportConfigWidget(TransportConfigWidgetPrivate &dd, Transport *transport, QWidget *parent); 0083 0084 private: 0085 Q_DECLARE_PRIVATE(TransportConfigWidget) 0086 0087 void init(Transport *transport); 0088 }; 0089 } // namespace MailTransport