Warning, file /multimedia/kid3/src/app/qt/platformtools.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /**
0002  * \file platformtools.h
0003  * 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 class QSettings;
0034 class BrowserDialog;
0035 
0036 /**
0037  * Platform specific tools.
0038  */
0039 class PlatformTools : public IPlatformTools, private GuiPlatformTools {
0040 public:
0041   /**
0042    * Constructor.
0043    */
0044   PlatformTools();
0045 
0046   /**
0047    * Destructor.
0048    */
0049   ~PlatformTools() override;
0050 
0051   /**
0052    * Get application settings.
0053    * @return settings instance.
0054    */
0055   ISettings* applicationSettings() override;
0056 
0057   /**
0058    * Get icon provider for tagged files.
0059    * @return icon provider.
0060    */
0061   CoreTaggedFileIconProvider* iconProvider() override;
0062 
0063   /**
0064    * Write text to clipboard.
0065    * @param text text to write
0066    * @return true if operation is supported.
0067    */
0068   bool writeToClipboard(const QString& text) const override;
0069 
0070   /**
0071    * Read text from clipboard.
0072    * @return text, null if operation not supported.
0073    */
0074   QString readFromClipboard() const override;
0075 
0076   /**
0077    * Create an audio player instance.
0078    * @param app application context
0079    * @param dbusEnabled true to enable MPRIS D-Bus interface
0080    * @return audio player, nullptr if not supported.
0081    */
0082   QObject* createAudioPlayer(Kid3Application* app,
0083                              bool dbusEnabled) const override;
0084 
0085   /**
0086    * Move file or directory to trash.
0087    *
0088    * @param path path to file or directory
0089    *
0090    * @return true if ok.
0091    */
0092   bool moveToTrash(const QString& path) const override;
0093 
0094   /**
0095    * Display help for a topic.
0096    *
0097    * @param anchor anchor in help document
0098    */
0099   void displayHelp(const QString& anchor) override;
0100 
0101   /**
0102    * Get a themed icon by name.
0103    * @param name name of icon
0104    * @return icon.
0105    */
0106   QIcon iconFromTheme(const QString& name) const override;
0107 
0108   /**
0109    * Construct a name filter string suitable for file dialogs.
0110    * @param nameFilters list of description, filter pairs, e.g.
0111    * [("Images", "*.jpg *.jpeg *.png"), ("All Files", "*")].
0112    * @return name filter string.
0113    */
0114   QString fileDialogNameFilter(
0115       const QList<QPair<QString, QString> >& nameFilters) const override;
0116 
0117   /**
0118    * Get file pattern part of m_nameFilter.
0119    * @param nameFilter name filter string
0120    * @return file patterns, e.g. "*.mp3".
0121    */
0122   QString getNameFilterPatterns(const QString& nameFilter) const override;
0123 
0124   /**
0125    * Display error dialog with item list.
0126    * @param parent parent widget
0127    * @param text text
0128    * @param strlist list of items
0129    * @param caption caption
0130    */
0131   void errorList(QWidget* parent, const QString& text,
0132       const QStringList& strlist, const QString& caption) override;
0133 
0134   /**
0135    * Display warning dialog with yes, no, cancel buttons.
0136    * @param parent parent widget
0137    * @param text text
0138    * @param caption caption
0139    * @return QMessageBox::Yes, QMessageBox::No or QMessageBox::Cancel.
0140    */
0141   int warningYesNoCancel(QWidget* parent, const QString& text,
0142       const QString& caption) override;
0143 
0144   /**
0145    * Display warning dialog with item list.
0146    * @param parent parent widget
0147    * @param text text
0148    * @param strlist list of items
0149    * @param caption caption
0150    * @return QMessageBox::Yes or QMessageBox::No.
0151    */
0152   int warningYesNoList(QWidget* parent, const QString& text,
0153       const QStringList& strlist, const QString& caption) override;
0154 
0155   /**
0156    * Display dialog to select an existing file.
0157    * @param parent parent widget
0158    * @param caption caption
0159    * @param dir directory
0160    * @param filter filter
0161    * @param selectedFilter the selected filter is returned here
0162    * @return selected file, empty if canceled.
0163    */
0164   QString getOpenFileName(QWidget* parent,
0165       const QString& caption, const QString& dir, const QString& filter,
0166       QString* selectedFilter) override;
0167 
0168   /**
0169    * Display dialog to select existing files.
0170    * @param parent parent widget
0171    * @param caption caption
0172    * @param dir directory
0173    * @param filter filter
0174    * @param selectedFilter the selected filter is returned here
0175    * @return selected files, empty if canceled.
0176    */
0177   QStringList getOpenFileNames(QWidget* parent,
0178       const QString& caption, const QString& dir, const QString& filter,
0179       QString* selectedFilter) override;
0180 
0181   /**
0182    * Display dialog to select a file to save.
0183    * @param parent parent widget
0184    * @param caption caption
0185    * @param dir directory
0186    * @param filter filter
0187    * @param selectedFilter the selected filter is returned here
0188    * @return selected file, empty if canceled.
0189    */
0190   QString getSaveFileName(QWidget* parent,
0191       const QString& caption, const QString& dir, const QString& filter,
0192       QString* selectedFilter) override;
0193 
0194   /**
0195    * Display dialog to select an existing directory.
0196    * @param parent parent widget
0197    * @param caption caption
0198    * @param startDir start directory
0199    * @return selected directory, empty if canceled.
0200    */
0201   QString getExistingDirectory(QWidget* parent,
0202       const QString& caption, const QString& startDir) override;
0203 
0204   /**
0205    * Check if platform has a graphical user interface.
0206    * @return true if platform has GUI.
0207    */
0208   bool hasGui() const override;
0209 
0210   /**
0211    * Display warning dialog.
0212    * @param parent parent widget
0213    * @param text text
0214    * @param details detailed message
0215    * @param caption caption
0216    */
0217   void warningDialog(QWidget* parent,
0218       const QString& text, const QString& details, const QString& caption) override;
0219 
0220   /**
0221    * Display warning dialog with options to continue or cancel.
0222    * @param parent parent widget
0223    * @param text text
0224    * @param strlist list of items
0225    * @param caption caption
0226    * @return true if continue was selected.
0227    */
0228   bool warningContinueCancelList(QWidget* parent,
0229       const QString& text, const QStringList& strlist, const QString& caption) override;
0230 
0231 private:
0232   QScopedPointer<BrowserDialog> m_helpBrowser;
0233 };