chore(cpn): Increase number of profiles that can be created (#4373)

This commit is contained in:
philmoz
2023-12-06 10:45:24 +10:00
committed by GitHub
parent 8e8feca046
commit 5d8ffcc244
5 changed files with 231 additions and 178 deletions
+17
View File
@@ -304,6 +304,11 @@ Profile::Profile() : CompStoreObj(), index(-1)
CompStoreObj::addObjectMapping(propertyGroup(), this);
}
Profile::Profile(const Profile & rhs) : CompStoreObj(), index(-1)
{
*this = rhs;
}
// The default copy operator can not be used since the index variable would be destroyed
Profile & Profile::operator= (const Profile & rhs)
{
@@ -661,6 +666,18 @@ QMap<int, QString> AppData::getActiveProfiles() const
return active;
}
void AppData::moveCurrentProfileToTop()
{
if (g.sortProfiles() && m_sessionId > 0) {
Profile tmpProfile(g.profile[m_sessionId]);
for (int i = m_sessionId; i > 0; i -= 1) {
g.profile[i] = g.profile[i - 1];
}
g.profile[0] = tmpProfile;
id(0);
}
}
void AppData::convertSettings(QSettings & settings)
{
quint32 savedVer = settings.value(SETTINGS_VERSION_KEY, 0).toUInt();
+5 -1
View File
@@ -58,7 +58,7 @@
#define CPN_SETTINGS_INI_FILE QString(PRODUCT % " " % QCoreApplication::translate("Companion", "settings") % " %1.ini")
#define CPN_SETTINGS_INI_PATH QString(CPN_SETTINGS_BACKUP_DIR % "/" % CPN_SETTINGS_INI_FILE)
#define MAX_PROFILES 20
#define MAX_PROFILES 32
#define MAX_JS_AXES 10
#define MAX_JS_BUTTONS 32
#define MAX_COMPONENTS 10
@@ -472,6 +472,7 @@ class Profile: public CompStoreObj
protected:
explicit Profile();
explicit Profile(const Profile & rhs);
void setIndex(int idx) { index = idx; }
inline QString propertyGroup() const override { return QStringLiteral("Profiles"); }
inline QString settingsPath() const override { return QString("%1/profile%2/").arg(propertyGroup()).arg(index); }
@@ -685,6 +686,8 @@ class AppData: public CompStoreObj
const Profile & getProfile(int index) const;
//! List of all active profiles mapped by index.
QMap<int, QString> getActiveProfiles() const;
// Move the currently selected profile to the top of the list
void moveCurrentProfileToTop();
//! Get a modifiable (non-const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.
ComponentData & getComponent(int index);
@@ -791,6 +794,7 @@ class AppData: public CompStoreObj
PROPERTY4(bool, jsSupport, "js_support", false)
PROPERTY4(bool, showSplash, "show_splash", true)
PROPERTY4(bool, sortProfiles, "sort_profiles", false)
PROPERTY4(bool, snapToClpbrd, "snapshot_to_clipboard", false)
PROPERTY(UpdateCheckFreq, updateCheckFreq, UPDATE_CHECK_MANUAL)