refactor: QTextStream& screen::writeScreensSection(QTextStream&) -> QString Screen::screenSection()
refactor: QTextStream& screen::writeAliasSection(QTextStream&) -> QString Screen::aliasSection()
This commit is contained in:
parent
0ba35fca7a
commit
26367635d9
3 changed files with 34 additions and 33 deletions
|
|
@ -239,7 +239,7 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
|
|||
|
||||
for (const Screen &s : config.screens()) {
|
||||
if (!s.isNull())
|
||||
s.writeScreensSection(outStream);
|
||||
outStream << s.screensSection();
|
||||
}
|
||||
|
||||
outStream << "end" << Qt::endl << Qt::endl;
|
||||
|
|
@ -248,7 +248,7 @@ QTextStream &operator<<(QTextStream &outStream, const ServerConfig &config)
|
|||
|
||||
for (const Screen &s : config.screens()) {
|
||||
if (!s.isNull())
|
||||
s.writeAliasesSection(outStream);
|
||||
outStream << s.aliasesSection();
|
||||
}
|
||||
|
||||
outStream << "end" << Qt::endl << Qt::endl;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-FileCopyrightText: (C) 2012 Symless Ltd.
|
||||
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
|
|
@ -76,40 +77,40 @@ void Screen::saveSettings(QSettingsProxy &settings) const
|
|||
writeSettings(settings, fixes(), "fix");
|
||||
}
|
||||
|
||||
QTextStream &Screen::writeScreensSection(QTextStream &outStream) const
|
||||
QString Screen::screensSection() const
|
||||
{
|
||||
outStream << "\t" << name() << ":" << Qt::endl;
|
||||
const QString lineTemplate = QStringLiteral("\t\t%1 = %2\n");
|
||||
|
||||
for (int i = 0; i < modifiers().size(); i++)
|
||||
QString out = QStringLiteral("\t%1:\n").arg(name());
|
||||
for (int i = 0; i < modifiers().size(); i++) {
|
||||
if (modifier(i) != i)
|
||||
outStream << "\t\t" << modifierName(i) << " = " << modifierName(modifier(i)) << Qt::endl;
|
||||
|
||||
for (int i = 0; i < fixes().size(); i++)
|
||||
outStream << "\t\t" << fixName(i) << " = " << (fixes()[i] ? "true" : "false") << Qt::endl;
|
||||
|
||||
outStream << "\t\t"
|
||||
<< "switchCorners = none ";
|
||||
for (int i = 0; i < switchCorners().size(); i++)
|
||||
if (switchCorners()[i])
|
||||
outStream << "+" << switchCornerName(i) << " ";
|
||||
outStream << Qt::endl;
|
||||
|
||||
outStream << "\t\t"
|
||||
<< "switchCornerSize = " << switchCornerSize() << Qt::endl;
|
||||
|
||||
return outStream;
|
||||
}
|
||||
|
||||
QTextStream &Screen::writeAliasesSection(QTextStream &outStream) const
|
||||
{
|
||||
if (!aliases().isEmpty()) {
|
||||
outStream << "\t" << name() << ":" << Qt::endl;
|
||||
|
||||
for (const QString &alias : aliases())
|
||||
outStream << "\t\t" << alias << Qt::endl;
|
||||
out.append(lineTemplate.arg(modifierName(i), modifierName(modifier(i))));
|
||||
}
|
||||
|
||||
return outStream;
|
||||
for (int i = 0; i < fixes().size(); i++)
|
||||
out.append(lineTemplate.arg(fixName(i), fixes().at(i) ? QStringLiteral("true") : QStringLiteral("false")));
|
||||
|
||||
out.append(QStringLiteral("\t\tswitchCorners = none"));
|
||||
for (int i = 0; i < switchCorners().size(); i++)
|
||||
if (switchCorners()[i])
|
||||
out.append(QStringLiteral("+%1 ").arg(switchCornerName(i)));
|
||||
|
||||
out.append("\n");
|
||||
out.append(lineTemplate.arg(QStringLiteral("switchCornerSize"), QString::number(switchCornerSize())));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QString Screen::aliasesSection() const
|
||||
{
|
||||
QString out;
|
||||
if (!aliases().isEmpty()) {
|
||||
out = QStringLiteral("\t%1:\n").arg(name());
|
||||
|
||||
for (const QString &alias : aliases())
|
||||
out.append(QStringLiteral("\t\t%1\n").arg(alias));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool Screen::operator==(const Screen &screen) const
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ public:
|
|||
|
||||
void loadSettings(QSettingsProxy &settings);
|
||||
void saveSettings(QSettingsProxy &settings) const;
|
||||
QTextStream &writeScreensSection(QTextStream &outStream) const;
|
||||
QTextStream &writeAliasesSection(QTextStream &outStream) const;
|
||||
QString screensSection() const;
|
||||
QString aliasesSection() const;
|
||||
|
||||
bool swapped() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue