1 /** 2 * \file coreplatformtools.h 3 * Core platform specific tools for Qt. 4 * 5 * \b Project: Kid3 6 * \author Urs Fleisch 7 * \date 10 Aug 2013 8 * 9 * Copyright (C) 2013-2018 Urs Fleisch 10 * 11 * This file is part of Kid3. 12 * 13 * Kid3 is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * Kid3 is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program. If not, see <http://www.gnu.org/licenses/>. 25 */ 26 27 #pragma once 28 29 #include <QScopedPointer> 30 #include "icoreplatformtools.h" 31 #include "isettings.h" 32 #include "coretaggedfileiconprovider.h" 33 34 class QSettings; 35 36 /** 37 * Core platform specific tools for Qt. 38 */ 39 class KID3_CORE_EXPORT CorePlatformTools : public ICorePlatformTools { 40 public: 41 /** 42 * Constructor. 43 */ 44 CorePlatformTools(); 45 46 /** 47 * Destructor. 48 */ 49 virtual ~CorePlatformTools() override; 50 51 /** 52 * Get application settings. 53 * @return settings instance. 54 */ 55 virtual ISettings* applicationSettings() override; 56 57 /** 58 * Get icon provider for tagged files. 59 * @return icon provider. 60 */ 61 virtual CoreTaggedFileIconProvider* iconProvider() override; 62 63 /** 64 * Write text to clipboard. 65 * @param text text to write 66 * @return true if operation is supported. 67 */ 68 virtual bool writeToClipboard(const QString& text) const override; 69 70 /** 71 * Read text from clipboard. 72 * @return text, null if operation not supported. 73 */ 74 virtual QString readFromClipboard() const override; 75 76 /** 77 * Create an audio player instance. 78 * @param app application context 79 * @param dbusEnabled true to enable MPRIS D-Bus interface 80 * @return audio player, nullptr if not supported. 81 */ 82 virtual QObject* createAudioPlayer(Kid3Application* app, 83 bool dbusEnabled) const override; 84 85 /** 86 * Move file or directory to trash. 87 * 88 * @param path path to file or directory 89 * 90 * @return true if ok. 91 */ 92 virtual bool moveToTrash(const QString& path) const override; 93 94 /** 95 * Construct a name filter string suitable for file dialogs. 96 * @param nameFilters list of description, filter pairs, e.g. 97 * [("Images", "*.jpg *.jpeg *.png"), ("All Files", "*")]. 98 * @return name filter string. 99 */ 100 virtual QString fileDialogNameFilter( 101 const QList<QPair<QString, QString> >& nameFilters) const override; 102 103 /** 104 * Get file pattern part of m_nameFilter. 105 * @param nameFilter name filter string 106 * @return file patterns, e.g. "*.mp3". 107 */ 108 virtual QString getNameFilterPatterns(const QString& nameFilter) const override; 109 110 #if !defined Q_OS_WIN32 && !defined Q_OS_MAC 111 /** 112 * Move file or directory to trash. 113 * 114 * @param path path to file or directory 115 * 116 * @return true if ok. 117 */ 118 static bool moveFileToTrash(const QString& path); 119 #endif 120 121 private: 122 QSettings* m_settings; 123 QScopedPointer<ISettings> m_config; 124 QScopedPointer<CoreTaggedFileIconProvider> m_iconProvider; 125 }; 126