Quiesce QIODevice warnings

This commit is contained in:
Nicolas Mailloux 2021-09-05 09:49:37 -04:00
parent 4c5fd69f57
commit 9154d6a0bd
2 changed files with 75 additions and 46 deletions

View file

@ -110,6 +110,7 @@ namespace {
int defaultPdfPageHeight; int defaultPdfPageHeight;
bool checked_box = false; bool checked_box = false;
bool checkconfig(QString file) { bool checkconfig(QString file) {
if(QFile::exists(file)) {
QFile config(file); QFile config(file);
config.open(QIODevice::ReadOnly); config.open(QIODevice::ReadOnly);
QTextStream in (&config); QTextStream in (&config);
@ -122,9 +123,14 @@ namespace {
return false; return false;
} }
config.close(); config.close();
}
else {
return false;
}
return 0; return 0;
}; };
bool checkconfig_rw(QString file) { bool checkconfig_rw(QString file) {
if(QFile::exists(file)) {
QFile config(file); QFile config(file);
config.open(QIODevice::ReadWrite); config.open(QIODevice::ReadWrite);
QTextStream in (&config); QTextStream in (&config);
@ -137,12 +143,17 @@ namespace {
return false; return false;
} }
config.close(); config.close();
}
else {
return false;
}
return 0; return 0;
}; };
void setDefaultWorkDir() { void setDefaultWorkDir() {
QDir::setCurrent("/mnt/onboard/.adds/inkbox"); QDir::setCurrent("/mnt/onboard/.adds/inkbox");
} }
int brightness_checkconfig(QString file) { int brightness_checkconfig(QString file) {
if(QFile::exists(file)) {
QFile config(file); QFile config(file);
config.open(QIODevice::ReadWrite); config.open(QIODevice::ReadWrite);
QTextStream in (&config); QTextStream in (&config);
@ -150,6 +161,10 @@ namespace {
int content_int = content.toInt(); int content_int = content.toInt();
return content_int; return content_int;
config.close(); config.close();
}
else {
return EXIT_FAILURE;
}
return 0; return 0;
} }
void set_brightness(int value) { void set_brightness(int value) {
@ -167,12 +182,17 @@ namespace {
ioctl(light, 241, value); ioctl(light, 241, value);
} }
int int_checkconfig(QString file) { int int_checkconfig(QString file) {
if(QFile::exists(file)) {
QFile int_config(file); QFile int_config(file);
int_config.open(QIODevice::ReadOnly); int_config.open(QIODevice::ReadOnly);
QString valuestr = int_config.readAll(); QString valuestr = int_config.readAll();
int value = valuestr.toInt(); int value = valuestr.toInt();
int_config.close(); int_config.close();
return value; return value;
}
else {
return EXIT_FAILURE;
}
return 0; return 0;
} }
int display_quote() { int display_quote() {
@ -197,6 +217,7 @@ namespace {
fhandler.close(); fhandler.close();
} }
void string_checkconfig(QString file) { void string_checkconfig(QString file) {
if(QFile::exists(file)) {
checkconfig_str_val = ""; checkconfig_str_val = "";
QFile config(file); QFile config(file);
config.open(QIODevice::ReadWrite); config.open(QIODevice::ReadWrite);
@ -204,7 +225,12 @@ namespace {
checkconfig_str_val = in.readAll(); checkconfig_str_val = in.readAll();
config.close(); config.close();
} }
else {
checkconfig_str_val = "";
}
}
void string_checkconfig_ro(QString file) { void string_checkconfig_ro(QString file) {
if(QFile::exists(file)) {
checkconfig_str_val = ""; checkconfig_str_val = "";
QFile config(file); QFile config(file);
config.open(QIODevice::ReadOnly); config.open(QIODevice::ReadOnly);
@ -212,6 +238,10 @@ namespace {
checkconfig_str_val = in.readAll(); checkconfig_str_val = in.readAll();
config.close(); config.close();
} }
else {
checkconfig_str_val = "";
}
}
void brightness_writeconfig(int value) { void brightness_writeconfig(int value) {
std::ofstream fhandler; std::ofstream fhandler;
fhandler.open(".config/03-brightness/config"); fhandler.open(".config/03-brightness/config");

View file

@ -21,7 +21,6 @@ toast::toast(QWidget *parent) :
ui->messageLabel->setText(global::toast::message); ui->messageLabel->setText(global::toast::message);
this->adjustSize(); this->adjustSize();
centerToast(); centerToast();
qDebug() << global::toast::delay;
if(global::toast::indefiniteToast == false) { if(global::toast::indefiniteToast == false) {
if(global::toast::delay == 0) { if(global::toast::delay == 0) {
global::toast::delay = 5000; global::toast::delay = 5000;