mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-31 01:50:47 +03:00
cleanup QSettings usage a bit
This commit is contained in:
parent
ef068ac2b3
commit
47c7c4c777
3 changed files with 17 additions and 19 deletions
|
@ -6,7 +6,6 @@
|
|||
#include <QApplication>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
|
||||
#include <mtx/responses.hpp>
|
||||
|
||||
|
@ -277,15 +276,15 @@ ChatPage::resetUI()
|
|||
void
|
||||
ChatPage::deleteConfigs()
|
||||
{
|
||||
QSettings settings;
|
||||
auto settings = UserSettings::instance()->qsettings();
|
||||
|
||||
if (UserSettings::instance()->profile() != "") {
|
||||
settings.beginGroup("profile");
|
||||
settings.beginGroup(UserSettings::instance()->profile());
|
||||
settings->beginGroup("profile");
|
||||
settings->beginGroup(UserSettings::instance()->profile());
|
||||
}
|
||||
settings.beginGroup("auth");
|
||||
settings.remove("");
|
||||
settings.endGroup(); // auth
|
||||
settings->beginGroup("auth");
|
||||
settings->remove("");
|
||||
settings->endGroup(); // auth
|
||||
|
||||
http::client()->shutdown();
|
||||
cache::deleteData();
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <QLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QPluginLoader>
|
||||
#include <QSettings>
|
||||
#include <QShortcut>
|
||||
|
||||
#include <mtx/requests.hpp>
|
||||
|
@ -188,9 +187,10 @@ MainWindow::event(QEvent *event)
|
|||
void
|
||||
MainWindow::restoreWindowSize()
|
||||
{
|
||||
QSettings settings;
|
||||
int savedWidth = settings.value("window/width").toInt();
|
||||
int savedheight = settings.value("window/height").toInt();
|
||||
int savedWidth = userSettings_->qsettings()->value("window/width").toInt();
|
||||
int savedheight = userSettings_->qsettings()->value("window/height").toInt();
|
||||
|
||||
nhlog::ui()->info("Restoring window size {}x{}", savedWidth, savedheight);
|
||||
|
||||
if (savedWidth == 0 || savedheight == 0)
|
||||
resize(conf::window::width, conf::window::height);
|
||||
|
@ -201,11 +201,11 @@ MainWindow::restoreWindowSize()
|
|||
void
|
||||
MainWindow::saveCurrentWindowSize()
|
||||
{
|
||||
QSettings settings;
|
||||
auto settings = userSettings_->qsettings();
|
||||
QSize current = size();
|
||||
|
||||
settings.setValue("window/width", current.width());
|
||||
settings.setValue("window/height", current.height());
|
||||
settings->setValue("window/width", current.width());
|
||||
settings->setValue("window/height", current.height());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -301,14 +301,14 @@ MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
|
|||
bool
|
||||
MainWindow::hasActiveUser()
|
||||
{
|
||||
QSettings settings;
|
||||
auto settings = userSettings_->qsettings();
|
||||
QString prefix;
|
||||
if (userSettings_->profile() != "")
|
||||
prefix = "profile/" + userSettings_->profile() + "/";
|
||||
|
||||
return settings.contains(prefix + "auth/access_token") &&
|
||||
settings.contains(prefix + "auth/home_server") &&
|
||||
settings.contains(prefix + "auth/user_id");
|
||||
return settings->contains(prefix + "auth/access_token") &&
|
||||
settings->contains(prefix + "auth/home_server") &&
|
||||
settings->contains(prefix + "auth/user_id");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <QMessageBox>
|
||||
#include <QPoint>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QTranslator>
|
||||
|
||||
|
|
Loading…
Reference in a new issue