Files
renderdoc/qrenderdoc/Code/Interface/PersistantConfig.h
T
baldurk 094c4164dc Refactor qrenderdoc to provide stable, clean and deliberate API
* Note, this API is still in-flux and beta, so there may still be some
  more changes before it's 'stable', and even then it will still be
  subject to some amount of change.
* This API is then exposed to python via SWIG bindings and hides
  internals that don't need to be visible, and means the actual API is
  easier to work with.
* We also use this API to reduce inter-dependencies between different
  windows that need to interact with each other at a high level.
* The naming is python/standard RenderDoc TitleCase method names, not
  Qt style camelCase methods.

# Conflicts:
#	qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp
#	qrenderdoc/Windows/TextureViewer.cpp
2017-04-18 14:57:43 +01:00

180 lines
9.7 KiB
C++

/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2016-2017 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#pragma once
// do not include any headers here, they must all be in QRDInterface.h
#include "QRDInterface.h"
#include "RemoteHost.h"
typedef QMap<QString, QString> QStringMap;
struct SPIRVDisassembler
{
SPIRVDisassembler() {}
VARIANT_CAST(SPIRVDisassembler);
QString name;
QString executable;
QString args;
};
DECLARE_REFLECTION_STRUCT(SPIRVDisassembler);
#define CONFIG_SETTING_VAL(access, variantType, type, name, defaultValue) \
access: \
type name = defaultValue;
#define CONFIG_SETTING(access, variantType, type, name) \
access: \
type name;
#define CONFIG_SETTINGS() \
\
CONFIG_SETTING_VAL(public, QString, QString, LastLogPath, "") \
\
CONFIG_SETTING(public, QVariantList, QList<QString>, RecentLogFiles) \
\
CONFIG_SETTING_VAL(public, QString, QString, LastCapturePath, "") \
\
CONFIG_SETTING_VAL(public, QString, QString, LastCaptureExe, "") \
\
CONFIG_SETTING(public, QVariantList, QList<QString>, RecentCaptureSettings) \
\
CONFIG_SETTING_VAL(public, int, int, CallstackLevelSkip, 0) \
\
CONFIG_SETTING_VAL(public, QString, QString, TemporaryCaptureDirectory, "") \
\
CONFIG_SETTING_VAL(public, QString, QString, DefaultCaptureSaveDirectory, "") \
\
CONFIG_SETTING_VAL(public, bool, bool, TextureViewer_ResetRange, false) \
\
CONFIG_SETTING_VAL(public, bool, bool, TextureViewer_PerTexSettings, true) \
\
CONFIG_SETTING_VAL(public, bool, bool, ShaderViewer_FriendlyNaming, true) \
\
CONFIG_SETTING_VAL(public, bool, bool, AlwaysReplayLocally, false) \
\
CONFIG_SETTING_VAL(public, int, int, LocalProxyAPI, -1) \
\
CONFIG_SETTING_VAL(public, int, TimeUnit, EventBrowser_TimeUnit, TimeUnit::Microseconds) \
\
CONFIG_SETTING_VAL(public, bool, bool, EventBrowser_HideEmpty, false) \
\
CONFIG_SETTING_VAL(public, bool, bool, EventBrowser_HideAPICalls, false) \
\
CONFIG_SETTING_VAL(public, bool, bool, EventBrowser_ApplyColors, true) \
\
CONFIG_SETTING_VAL(public, bool, bool, EventBrowser_ColorEventRow, true) \
\
CONFIG_SETTING_VAL(public, int, int, Formatter_MinFigures, 2) \
\
CONFIG_SETTING_VAL(public, int, int, Formatter_MaxFigures, 5) \
\
CONFIG_SETTING_VAL(public, int, int, Formatter_NegExp, 5) \
\
CONFIG_SETTING_VAL(public, int, int, Formatter_PosExp, 7) \
\
CONFIG_SETTING_VAL(public, bool, bool, Font_PreferMonospaced, false) \
\
CONFIG_SETTING_VAL(public, QString, QString, Android_AdbExecutablePath, "") \
\
CONFIG_SETTING_VAL(public, int, int, Android_MaxConnectTimeout, 30) \
\
CONFIG_SETTING_VAL(public, bool, bool, CheckUpdate_AllowChecks, true) \
\
CONFIG_SETTING_VAL(public, bool, bool, CheckUpdate_UpdateAvailable, false) \
\
CONFIG_SETTING_VAL(public, QString, QString, CheckUpdate_UpdateResponse, "") \
\
CONFIG_SETTING_VAL(public, QDateTime, QDateTime, CheckUpdate_LastUpdate, \
QDateTime(QDate(2012, 06, 27), QTime(0, 0, 0))) \
\
CONFIG_SETTING_VAL(public, QDateTime, QDateTime, DegradedLog_LastUpdate, \
QDateTime(QDate(2015, 01, 01), QTime(0, 0, 0))) \
\
CONFIG_SETTING_VAL(public, bool, bool, Tips_HasSeenFirst, false) \
\
CONFIG_SETTING_VAL(public, bool, bool, AllowGlobalHook, false) \
\
CONFIG_SETTING(public, QVariantList, QList<SPIRVDisassembler>, SPIRVDisassemblers) \
\
CONFIG_SETTING(private, QVariantMap, QStringMap, ConfigSettings) \
\
CONFIG_SETTING(private, QVariantList, QList<RemoteHost>, RemoteHostList)
enum class TimeUnit : int
{
Seconds = 0,
Milliseconds,
Microseconds,
Nanoseconds,
Count,
};
inline QString UnitPrefix(TimeUnit t)
{
if(t == TimeUnit::Seconds)
return "s";
else if(t == TimeUnit::Milliseconds)
return "ms";
else if(t == TimeUnit::Microseconds)
return "µs";
else if(t == TimeUnit::Nanoseconds)
return "ns";
return "s";
}
void AddRecentFile(QList<QString> &recentList, const QString &file, int maxItems);
class PersistantConfig
{
public:
// Runtime list of dynamically allocated hosts.
// Saved to/from private RemoteHostList in CONFIG_SETTINGS()
QList<RemoteHost *> RemoteHosts;
void AddAndroidHosts();
CONFIG_SETTINGS()
public:
PersistantConfig() {}
~PersistantConfig();
bool Load(const QString &filename);
bool Save();
void SetupFormatting();
void SetConfigSetting(const QString &name, const QString &value);
QString GetConfigSetting(const QString &name);
private:
bool Deserialize(const QString &filename);
bool Serialize(const QString &filename);
QVariantMap storeValues() const;
void applyValues(const QVariantMap &values);
QString m_Filename;
};