File indexing completed on 2024-05-19 04:55:51
0001 /** 0002 * \file kdeplatformtools.h 0003 * KDE platform specific tools. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 30 Mar 2013 0008 * 0009 * Copyright (C) 2013-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QScopedPointer> 0030 #include "iplatformtools.h" 0031 #include "guiplatformtools.h" 0032 0033 /** 0034 * KDE platform specific tools. 0035 */ 0036 class KdePlatformTools : public IPlatformTools, private GuiPlatformTools { 0037 public: 0038 /** 0039 * Constructor. 0040 */ 0041 KdePlatformTools(); 0042 0043 /** 0044 * Destructor. 0045 */ 0046 ~KdePlatformTools() override; 0047 0048 /** 0049 * Get application settings. 0050 * @return settings instance. 0051 */ 0052 ISettings* applicationSettings() override; 0053 0054 /** 0055 * Get icon provider for tagged files. 0056 * @return icon provider. 0057 */ 0058 CoreTaggedFileIconProvider* iconProvider() override; 0059 0060 /** 0061 * Write text to clipboard. 0062 * @param text text to write 0063 * @return true if operation is supported. 0064 */ 0065 bool writeToClipboard(const QString& text) const override; 0066 0067 /** 0068 * Read text from clipboard. 0069 * @return text, null if operation not supported. 0070 */ 0071 QString readFromClipboard() const override; 0072 0073 /** 0074 * Create an audio player instance. 0075 * @param app application context 0076 * @param dbusEnabled true to enable MPRIS D-Bus interface 0077 * @return audio player, nullptr if not supported. 0078 */ 0079 QObject* createAudioPlayer(Kid3Application* app, 0080 bool dbusEnabled) const override; 0081 0082 /** 0083 * Move file or directory to trash. 0084 * 0085 * @param path path to file or directory 0086 * 0087 * @return true if ok. 0088 */ 0089 bool moveToTrash(const QString& path) const override; 0090 0091 /** 0092 * Display help for a topic. 0093 * 0094 * @param anchor anchor in help document 0095 */ 0096 void displayHelp(const QString& anchor) override; 0097 0098 /** 0099 * Get a themed icon by name. 0100 * @param name name of icon 0101 * @return icon. 0102 */ 0103 QIcon iconFromTheme(const QString& name) const override; 0104 0105 /** 0106 * Construct a name filter string suitable for file dialogs. 0107 * @param nameFilters list of description, filter pairs, e.g. 0108 * [("Images", "*.jpg *.jpeg *.png"), ("All Files", "*")]. 0109 * @return name filter string. 0110 */ 0111 QString fileDialogNameFilter( 0112 const QList<QPair<QString, QString> >& nameFilters) const override; 0113 0114 /** 0115 * Get file pattern part of m_nameFilter. 0116 * @param nameFilter name filter string 0117 * @return file patterns, e.g. "*.mp3". 0118 */ 0119 QString getNameFilterPatterns(const QString& nameFilter) const override; 0120 0121 /** 0122 * Display error dialog with item list. 0123 * @param parent parent widget 0124 * @param text text 0125 * @param strlist list of items 0126 * @param caption caption 0127 */ 0128 void errorList(QWidget* parent, const QString& text, 0129 const QStringList& strlist, const QString& caption) override; 0130 0131 /** 0132 * Display warning dialog with yes, no, cancel buttons. 0133 * @param parent parent widget 0134 * @param text text 0135 * @param caption caption 0136 * @return QMessageBox::Yes, QMessageBox::No or QMessageBox::Cancel. 0137 */ 0138 int warningYesNoCancel(QWidget* parent, const QString& text, 0139 const QString& caption) override; 0140 0141 /** 0142 * Display warning dialog with item list. 0143 * @param parent parent widget 0144 * @param text text 0145 * @param strlist list of items 0146 * @param caption caption 0147 * @return QMessageBox::Yes or QMessageBox::No. 0148 */ 0149 int warningYesNoList(QWidget* parent, const QString& text, 0150 const QStringList& strlist, const QString& caption) override; 0151 0152 /** 0153 * Display dialog to select an existing file. 0154 * @param parent parent widget 0155 * @param caption caption 0156 * @param dir directory 0157 * @param filter filter 0158 * @param selectedFilter the selected filter is returned here 0159 * @return selected file, empty if canceled. 0160 */ 0161 QString getOpenFileName(QWidget* parent, 0162 const QString& caption, const QString& dir, const QString& filter, 0163 QString* selectedFilter) override; 0164 0165 /** 0166 * Display dialog to select existing files. 0167 * @param parent parent widget 0168 * @param caption caption 0169 * @param dir directory 0170 * @param filter filter 0171 * @param selectedFilter the selected filter is returned here 0172 * @return selected files, empty if canceled. 0173 */ 0174 QStringList getOpenFileNames(QWidget* parent, 0175 const QString& caption, const QString& dir, const QString& filter, 0176 QString* selectedFilter) override; 0177 0178 /** 0179 * Display dialog to select a file to save. 0180 * @param parent parent widget 0181 * @param caption caption 0182 * @param dir directory 0183 * @param filter filter 0184 * @param selectedFilter the selected filter is returned here 0185 * @return selected file, empty if canceled. 0186 */ 0187 QString getSaveFileName(QWidget* parent, 0188 const QString& caption, const QString& dir, const QString& filter, 0189 QString* selectedFilter) override; 0190 0191 /** 0192 * Display dialog to select an existing directory. 0193 * @param parent parent widget 0194 * @param caption caption 0195 * @param startDir start directory 0196 * @return selected directory, empty if canceled. 0197 */ 0198 QString getExistingDirectory(QWidget* parent, 0199 const QString& caption, const QString& startDir) override; 0200 0201 /** 0202 * Check if platform has a graphical user interface. 0203 * @return true if platform has GUI. 0204 */ 0205 bool hasGui() const override; 0206 0207 /** 0208 * Display warning dialog. 0209 * @param parent parent widget 0210 * @param text text 0211 * @param details detailed message 0212 * @param caption caption 0213 */ 0214 void warningDialog(QWidget* parent, 0215 const QString& text, const QString& details, const QString& caption) override; 0216 0217 /** 0218 * Display warning dialog with options to continue or cancel. 0219 * @param parent parent widget 0220 * @param text text 0221 * @param strlist list of items 0222 * @param caption caption 0223 * @return true if continue was selected. 0224 */ 0225 bool warningContinueCancelList(QWidget* parent, 0226 const QString& text, const QStringList& strlist, const QString& caption) override; 0227 0228 private: 0229 QScopedPointer<ISettings> m_config; 0230 };