|
|
4c75f9e |
/*
|
|
|
4c75f9e |
Copyright (c) 2017, Lukas Holecek <hluk@email.cz>
|
|
|
4c75f9e |
|
|
|
4c75f9e |
This file is part of CopyQ.
|
|
|
4c75f9e |
|
|
|
4c75f9e |
CopyQ is free software: you can redistribute it and/or modify
|
|
|
4c75f9e |
it under the terms of the GNU General Public License as published by
|
|
|
4c75f9e |
the Free Software Foundation, either version 3 of the License, or
|
|
|
4c75f9e |
(at your option) any later version.
|
|
|
4c75f9e |
|
|
|
4c75f9e |
CopyQ is distributed in the hope that it will be useful,
|
|
|
4c75f9e |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c75f9e |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
4c75f9e |
GNU General Public License for more details.
|
|
|
4c75f9e |
|
|
|
4c75f9e |
You should have received a copy of the GNU General Public License
|
|
|
4c75f9e |
along with CopyQ. If not, see <http://www.gnu.org/licenses/>.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
|
|
|
4c75f9e |
#ifndef PLATFORMNATIVEINTERFACE_H
|
|
|
4c75f9e |
#define PLATFORMNATIVEINTERFACE_H
|
|
|
4c75f9e |
|
|
|
4c75f9e |
#include <QWidget> // WId
|
|
|
4c75f9e |
|
|
|
4c75f9e |
#include <memory>
|
|
|
4c75f9e |
|
|
|
4c75f9e |
class QApplication;
|
|
|
4c75f9e |
class QByteArray;
|
|
|
4c75f9e |
class QCoreApplication;
|
|
|
4c75f9e |
class QDir;
|
|
|
4c75f9e |
class QKeyEvent;
|
|
|
4c75f9e |
class QWidget;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
class PlatformWindow;
|
|
|
4c75f9e |
class PlatformClipboard;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
using PlatformWindowPtr = std::shared_ptr<PlatformWindow>;
|
|
|
4c75f9e |
using PlatformClipboardPtr = std::shared_ptr<PlatformClipboard>;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Interface for platform dependent code.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
class PlatformNativeInterface
|
|
|
4c75f9e |
{
|
|
|
4c75f9e |
public:
|
|
|
4c75f9e |
virtual ~PlatformNativeInterface() = default;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Get window from widget (nullptr if failed or not implemented).
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual PlatformWindowPtr getWindow(WId winId) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Get currently focused window (nullptr if failed or not implemented).
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual PlatformWindowPtr getCurrentWindow() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Return true only if window titles can be retrieved using PlatformWindow::getTitle().
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual bool canGetWindowTitle() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Return true automatic the application start at system startup is supported.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual bool canAutostart() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Return true if the application is automatically started at system startup.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual bool isAutostartEnabled() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Enable automatic application start at system startup.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual void setAutostartEnabled(bool enable) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Create QCoreApplication object for console output (to show help or version and quit).
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QCoreApplication *createConsoleApplication(int &argc, char **argv) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Create QApplication object for server.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QApplication *createServerApplication(int &argc, char **argv) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Create QApplication object for clipboard monitor.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QApplication *createMonitorApplication(int &argc, char **argv) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Create QCoreApplication object for client.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QCoreApplication *createClientApplication(int &argc, char **argv) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Modify settings (QSettings) before it's first used.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual void loadSettings() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Return object for managing clipboard.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual PlatformClipboardPtr clipboard() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Return Qt key code from key press event (possibly using QKeyEvent::nativeVirtualKey()).
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual int keyCode(const QKeyEvent &event) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Returns list of command line arguments without executable name (argv[0]).
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QStringList getCommandLineArguments(int argc, char **argv) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Find directory with plugins and return true on success.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual bool findPluginDir(QDir *pluginsDir) = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Default editor command (e.g. "notepad %1"; "%1" will be replaced with file name to edit).
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QString defaultEditorCommand() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Path to translations.
|
|
|
4c75f9e |
*
|
|
|
4c75f9e |
* Can be overridden by preprocessor flag COPYQ_TRANSLATION_PREFIX.
|
|
|
4c75f9e |
*
|
|
|
4c75f9e |
* Custom translation prefix can be added by setting COPYQ_TRANSLATION_PREFIX
|
|
|
4c75f9e |
* environment variable.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QString translationPrefix() = 0;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Path to installed themes.
|
|
|
4c75f9e |
*
|
|
|
4c75f9e |
* Can be overridden by preprocessor flag COPYQ_THEME_PREFIX.
|
|
|
4c75f9e |
*
|
|
|
4c75f9e |
* Custom theme prefix can be added by setting COPYQ_THEME_PREFIX
|
|
|
4c75f9e |
* environment variable.
|
|
|
4c75f9e |
*
|
|
|
4c75f9e |
* Note: Customized themes are saved to settings path.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
virtual QString themePrefix() = 0;
|
|
|
4c75f9e |
};
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Shared pointer type for PlatformNativeInterface instance.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
using PlatformPtr = std::shared_ptr<PlatformNativeInterface>;
|
|
|
4c75f9e |
|
|
|
4c75f9e |
/**
|
|
|
4c75f9e |
* Factory method to create PlatformNativeInterface instance.
|
|
|
4c75f9e |
*/
|
|
|
4c75f9e |
PlatformPtr createPlatformNativeInterface();
|
|
|
4c75f9e |
|
|
|
4c75f9e |
#endif // PLATFORMNATIVEINTERFACE_H
|