File indexing completed on 2024-05-19 04:56:13

0001 /**
0002  * \file androidutils.h
0003  * Platform utility functions for Android.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 27 Feb 2019
0008  *
0009  * Copyright (C) 2019  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 <QObject>
0030 #include "kid3api.h"
0031 
0032 /**
0033  * Communication with the Java part of the Android app.
0034  * A single instance of this class shall be created and then be accessed
0035  * using the instance() method.
0036  */
0037 class KID3_CORE_EXPORT AndroidUtils : public QObject {
0038   Q_OBJECT
0039 public:
0040   /**
0041    * Constructor.
0042    * @param parent parent object
0043    */
0044   explicit AndroidUtils(QObject* parent);
0045 
0046   /**
0047    * Check if an intent was received before the application was ready.
0048    */
0049   void checkPendingIntents();
0050 
0051   /**
0052    * Emit signal when a view or edit intent to open a file is received.
0053    * @param path path of file
0054    */
0055   void emitFilePathReceived(const QString& path);
0056 
0057   /**
0058    * Get a pointer to the application's config store instance.
0059    * @return config store, 0 if no instance has been allocated.
0060    */
0061   static AndroidUtils* instance() { return s_self; }
0062 
0063 signals:
0064   /**
0065    * Emitted when a view or edit intent to open a file is received.
0066    * @param path path to file
0067    */
0068   void filePathReceived(const QString& path);
0069 
0070 private:
0071   static AndroidUtils* s_self;
0072 };