mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
* removed CDockWidgetsSettings (note Widgets, not Widget) * goal: Use CDockWidgetSettings for all dock widgets refs #684
139 lines
5.0 KiB
C++
139 lines
5.0 KiB
C++
/* Copyright (C) 2016
|
|
* 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 and at http://www.swift-project.org/license.html. 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_SETTINGS_DOCKWIDGET_H
|
|
#define BLACKGUI_SETTINGS_DOCKWIDGET_H
|
|
|
|
#include "blackgui/blackguiexport.h"
|
|
#include "blackmisc/settingscache.h"
|
|
#include "blackmisc/propertyindex.h"
|
|
#include "blackmisc/dictionary.h"
|
|
#include "blackmisc/variant.h"
|
|
|
|
#include <QMap>
|
|
#include <QString>
|
|
#include <QMetaType>
|
|
|
|
namespace BlackGui
|
|
{
|
|
namespace Settings
|
|
{
|
|
//! Settings for dockwidget
|
|
class BLACKGUI_EXPORT CDockWidgetSettings :
|
|
public BlackMisc::CValueObject<CDockWidgetSettings>
|
|
{
|
|
public:
|
|
//! Properties by index
|
|
enum ColumnIndex
|
|
{
|
|
IndexFloatingMargins = BlackMisc::CPropertyIndex::GlobalIndexCDockWidgetSettings,
|
|
IndexFloatingFramelessMargins,
|
|
IndexDockedMargins,
|
|
IndexFrameless,
|
|
IndexFloating
|
|
};
|
|
|
|
//! Default constructor
|
|
CDockWidgetSettings();
|
|
|
|
//! Destructor.
|
|
~CDockWidgetSettings() {}
|
|
|
|
//! Reset margins to default
|
|
void resetMarginsToDefault();
|
|
|
|
//! Reset to defaults
|
|
void reset();
|
|
|
|
//! Set margins for given dock widget
|
|
void setMarginsWhenFramelessFloating(const QMargins &margins);
|
|
|
|
//! Margins for given dock widget
|
|
QMargins getMarginsWhenFramelessFloating() const;
|
|
|
|
//! Set margins for given dock widget
|
|
void setMarginsWhenFloating(const QMargins &margins);
|
|
|
|
//! Margins for given dock widget
|
|
QMargins getMarginsWhenFloating() const;
|
|
|
|
//! Set margins for given dock widget
|
|
void setMarginsWhenDocked(const QMargins &margins);
|
|
|
|
//! Margins for given dock widget
|
|
QMargins getMarginsWhenDocked() const;
|
|
|
|
//! Floating?
|
|
bool isFloating() const { return m_floating; }
|
|
|
|
//! Frameless?
|
|
bool isFramless() const { return m_frameless; }
|
|
|
|
//! Floating
|
|
void setFloating(bool floating) { m_floating = floating; }
|
|
|
|
//! Frameless
|
|
void setFrameless(bool frameless) { m_frameless = frameless; }
|
|
|
|
//! Geometry
|
|
QByteArray getGeometry() const;
|
|
|
|
//! Set geometry
|
|
void setGeometry(const QByteArray &ba);
|
|
|
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
|
QString convertToQString(bool i18n = false) const;
|
|
|
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
|
QString convertToQString(const QString &separator, bool i18n = false) const;
|
|
|
|
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
|
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
|
|
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
|
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const BlackMisc::CVariant &variant);
|
|
|
|
private:
|
|
QString m_floatingMargins {"0:0:0:0"}; //!< margins: when floating
|
|
QString m_floatingFramelessMargins {"0:0:0:0"}; //!< margins, when floating and frameless
|
|
QString m_dockedMargins {"0:0:0:0"}; //!< margins, when docked
|
|
QString m_geometry; //!< geometry as HEX values
|
|
bool m_floating = false; //!< floating
|
|
bool m_frameless = false; //!< frameless
|
|
|
|
BLACK_METACLASS(
|
|
CDockWidgetSettings,
|
|
BLACK_METAMEMBER(floatingMargins),
|
|
BLACK_METAMEMBER(floatingFramelessMargins),
|
|
BLACK_METAMEMBER(dockedMargins),
|
|
BLACK_METAMEMBER(floating),
|
|
BLACK_METAMEMBER(frameless),
|
|
BLACK_METAMEMBER(geometry)
|
|
);
|
|
};
|
|
|
|
//! Trait for settings for dock widget
|
|
//! \details All settings will go in one file, separated by application and object name
|
|
//! (of the parent object using this setting). If the object name is not set, it will not work correctly
|
|
struct TDockWidget : public BlackMisc::TSettingTrait<CDockWidgetSettings>
|
|
{
|
|
//! Key in data cache https://dev.vatsim-germany.org/issues/776
|
|
static const char *key() { return "guidockwidget/%Application%/%OwnerName%"; }
|
|
};
|
|
} // ns
|
|
} // ns
|
|
|
|
Q_DECLARE_METATYPE(BlackGui::Settings::CDockWidgetSettings)
|
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackGui::Settings::CDockWidgetSettings>)
|
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackGui::Settings::CDockWidgetSettings>)
|
|
|
|
#endif // guard
|