加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
settings.cpp 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
觉皇 提交于 2022-11-15 13:48 . 首次提交
#include "settings.h"
#include <QApplication>
#include <QDir>
#include <QHostInfo>
#include <QSettings>
#include <QStandardPaths>
QString Settings::deviceName()
{
QString d = QHostInfo::localHostName();
return QSettings("config.ini", QSettings::IniFormat).value("deviceName", d).toString();
}
QString Settings::downloadPath()
{
QString d = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
d += QDir::separator() + QApplication::applicationName();
return QSettings("config.ini", QSettings::IniFormat).value("downloadPath", d).toString();
}
bool Settings::discoverable()
{
return QSettings("config.ini", QSettings::IniFormat).value("discoverable", true).toBool();
}
quint16 Settings::serverPort()
{
return QSettings("config.ini", QSettings::IniFormat).value("serverPort", TRANSFER_PORT).toUInt();
}
void Settings::setDeviceName(const QString &deviceName)
{
QSettings("config.ini", QSettings::IniFormat).setValue("deviceName", deviceName);
}
void Settings::setDownloadPath(const QString &downloadPath)
{
QSettings("config.ini", QSettings::IniFormat).setValue("downloadPath", downloadPath);
}
void Settings::setDiscoverable(bool discoverable)
{
QSettings("config.ini", QSettings::IniFormat).setValue("discoverable", discoverable);
}
void Settings::setServerPort(quint16 serverPort)
{
QSettings("config.ini", QSettings::IniFormat).setValue("serverPort", serverPort);
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化