mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +08:00
refs #697, BlackGui settings renamed
This commit is contained in:
106
src/blackgui/settings/navigatorsettings.cpp
Normal file
106
src/blackgui/settings/navigatorsettings.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "navigatorsettings.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include <QStringList>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
CNavigatorSettings::CNavigatorSettings()
|
||||
{ }
|
||||
|
||||
void CNavigatorSettings::reset()
|
||||
{ }
|
||||
|
||||
void CNavigatorSettings::setMargins(const QMargins &margins)
|
||||
{
|
||||
this->m_margins = CGuiUtility::marginsToString(margins);
|
||||
}
|
||||
|
||||
QMargins CNavigatorSettings::getMargins() const
|
||||
{
|
||||
return CGuiUtility::stringToMargins(this->m_margins);
|
||||
}
|
||||
|
||||
QByteArray CNavigatorSettings::getGeometry() const
|
||||
{
|
||||
return byteArrayFromHexString(this->m_geometry);
|
||||
}
|
||||
|
||||
void CNavigatorSettings::setGeometry(const QByteArray &ba)
|
||||
{
|
||||
this->m_geometry = bytesToHexString(ba);
|
||||
}
|
||||
|
||||
QString CNavigatorSettings::convertToQString(bool i18n) const
|
||||
{
|
||||
return convertToQString(", ", i18n);
|
||||
}
|
||||
|
||||
QString CNavigatorSettings::convertToQString(const QString &separator, bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s("margins: ");
|
||||
s.append(this->m_margins);
|
||||
s.append(separator);
|
||||
s.append("frameless: ");
|
||||
s.append(boolToTrueFalse(this->m_frameless));
|
||||
s.append(separator);
|
||||
s.append("columns: ");
|
||||
s.append(this->m_columns);
|
||||
return s;
|
||||
}
|
||||
|
||||
CVariant CNavigatorSettings::propertyByIndex(const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMargins:
|
||||
return CVariant::fromValue(this->m_margins);
|
||||
case IndexFrameless:
|
||||
return CVariant::fromValue(this->isFramless());
|
||||
case IndexColumns:
|
||||
return CVariant::fromValue(this->m_columns);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CNavigatorSettings::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CNavigatorSettings>(); return; }
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexMargins:
|
||||
this->m_margins = variant.toQString();
|
||||
break;
|
||||
case IndexColumns:
|
||||
this->m_columns = variant.toInt();
|
||||
break;
|
||||
case IndexFrameless:
|
||||
this->m_frameless = variant.toBool();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
Reference in New Issue
Block a user