Files
pilotclient/src/blackgui/components/settingshotkeycomponent.h
Mat Sutcliffe 57ff07592a [AFV] CInputManager stores icon indexes instead of QPixmap instances
The GUI converts icon indexes to QPixmap indexes when needed.
This fixes the context unittest that was broken by audio context changes.
2019-10-11 19:00:52 +01:00

97 lines
3.3 KiB
C++

/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_SETTINGSHOTKEYCOMPONENT_H
#define BLACKGUI_COMPONENTS_SETTINGSHOTKEYCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackgui/models/actionhotkeylistmodel.h"
#include "blackcore/actionbind.h"
#include "blackcore/application/applicationsettings.h"
#include "blackmisc/identifierlist.h"
#include "blackmisc/settingscache.h"
#include "blackmisc/icons.h"
#include <QFrame>
#include <QObject>
#include <QWizardPage>
#include <QScopedPointer>
namespace Ui { class CSettingsHotkeyComponent; }
namespace BlackGui
{
namespace Components
{
//! Configure hotkeys
class BLACKGUI_EXPORT CSettingsHotkeyComponent : public QFrame
{
Q_OBJECT
public:
//! Constructor
CSettingsHotkeyComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CSettingsHotkeyComponent() override;
//! Save settings
void saveSettings();
//! Create dummy/emtpy Ptt entry for wizard
void registerDummyPttEntry();
//! Reload keys from settings
void reloadHotkeysFromSettings();
private:
void addEntry();
void editEntry();
void removeEntry();
void hotkeySlot(bool keyDown);
void addHotkeytoSettings(const BlackMisc::Input::CActionHotkey &actionHotkey);
void updateHotkeyInSettings(const BlackMisc::Input::CActionHotkey &oldValue, const BlackMisc::Input::CActionHotkey &newValue);
void removeHotkeyFromSettings(const BlackMisc::Input::CActionHotkey &actionHotkey);
bool checkAndConfirmConflicts(const BlackMisc::Input::CActionHotkey &actionHotkey, const BlackMisc::Input::CActionHotkeyList &ignore = {});
BlackMisc::CIdentifierList getAllIdentifiers() const;
QScopedPointer<Ui::CSettingsHotkeyComponent> ui;
Models::CActionHotkeyListModel m_model; //!< hotkeys model
BlackMisc::CSetting<BlackCore::Application::TActionHotkeys> m_actionHotkeys { this, &CSettingsHotkeyComponent::reloadHotkeysFromSettings };
BlackCore::CActionBind m_action { "/Test/Message", BlackMisc::CIcons::StandardIconWrench16, this, &CSettingsHotkeyComponent::hotkeySlot };
};
/**
* Wizard page for CConfigSimulatorComponent
*/
class CConfigHotkeyWizardPage : public QWizardPage
{
Q_OBJECT
public:
//! Constructors
using QWizardPage::QWizardPage;
//! Set config
void setConfigComponent(CSettingsHotkeyComponent *config) { m_config = config; }
//! \copydoc QWizardPage::validatePage
virtual bool validatePage() override;
//! \copydoc QWizardPage::initializePage
virtual void initializePage() override;
private:
CSettingsHotkeyComponent *m_config = nullptr;
};
} // ns
} // ns
#endif // guard