1
0
forked from blue/squawk

may be a bit better quit handling

This commit is contained in:
Blue 2022-01-25 23:35:55 +03:00
parent c708c33a92
commit 802e2f11a1
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
7 changed files with 46 additions and 12 deletions

View File

@ -105,11 +105,15 @@ int main(int argc, char *argv[])
QThread* coreThread = new QThread();
squawk->moveToThread(coreThread);
QObject::connect(&sc, &SignalCatcher::interrupt, &app, &QApplication::closeAllWindows);
QObject::connect(coreThread, &QThread::started, squawk, &Core::Squawk::start);
QObject::connect(&app, &QApplication::aboutToQuit, squawk, &Core::Squawk::stop);
QObject::connect(&app, &QApplication::aboutToQuit, &w, &QMainWindow::close);
QObject::connect(squawk, &Core::Squawk::quit, coreThread, &QThread::quit);
QObject::connect(coreThread, &QThread::finished, squawk, &Core::Squawk::deleteLater);
QObject::connect(&app, &QApplication::lastWindowClosed, squawk, &Core::Squawk::stop);
QObject::connect(&app, &QApplication::lastWindowClosed, &w, &Squawk::writeSettings);
//QObject::connect(&app, &QApplication::aboutToQuit, &w, &QMainWindow::close);
QObject::connect(squawk, &Core::Squawk::quit, squawk, &Core::Squawk::deleteLater);
QObject::connect(squawk, &Core::Squawk::quit, coreThread, &QThread::quit, Qt::QueuedConnection);
QObject::connect(coreThread, &QThread::finished, &app, &QApplication::quit, Qt::QueuedConnection);
QObject::connect(&w, &Squawk::newAccountRequest, squawk, &Core::Squawk::newAccountRequest);
QObject::connect(&w, &Squawk::modifyAccountRequest, squawk, &Core::Squawk::modifyAccountRequest);
@ -169,12 +173,11 @@ int main(int argc, char *argv[])
QObject::connect(squawk, &Core::Squawk::ready, &w, &Squawk::readSettings);
coreThread->start();
int result = app.exec();
w.writeSettings();
coreThread->wait(500); //TODO hate doing that but settings for some reason don't get saved to the disk
if (coreThread->isRunning()) {
coreThread->wait();
}
return result;
}

View File

@ -50,7 +50,7 @@ void SignalCatcher::handleSigInt()
char tmp;
ssize_t s = ::read(sigintFd[1], &tmp, sizeof(tmp));
app->quit();
emit interrupt();
snInt->setEnabled(true);
}

View File

@ -33,6 +33,9 @@ public:
static void intSignalHandler(int unused);
signals:
void interrupt();
public slots:
void handleSigInt();

View File

@ -883,6 +883,10 @@ void Squawk::writeSettings()
}
settings.endGroup();
settings.endGroup();
settings.sync();
qDebug() << "Saved settings";
}
void Squawk::onItemCollepsed(const QModelIndex& index)

View File

@ -54,8 +54,6 @@ public:
explicit Squawk(QWidget *parent = nullptr);
~Squawk() override;
void writeSettings();
signals:
void newAccountRequest(const QMap<QString, QVariant>&);
void modifyAccountRequest(const QString&, const QMap<QString, QVariant>&);
@ -84,6 +82,7 @@ signals:
void localPathInvalid(const QString& path);
public slots:
void writeSettings();
void readSettings();
void newAccount(const QMap<QString, QVariant>& account);
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);

View File

@ -2,6 +2,10 @@
#include "ui_pageappearance.h"
#include <QDebug>
#include <QStandardPaths>
#include <QDir>
static const QStringList filters = {"*.colors"};
PageAppearance::PageAppearance(QWidget* parent):
QWidget(parent),
@ -28,6 +32,17 @@ PageAppearance::PageAppearance(QWidget* parent):
}
connect(m_ui->themeInput, qOverload<int>(&QComboBox::currentIndexChanged), this, &PageAppearance::onThemeChanged);
m_ui->colorInput->addItem(tr("System"));
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "color-schemes", QStandardPaths::LocateDirectory);
QStringList schemeFiles;
for (const QString &dir : dirs) {
const QStringList fileNames = QDir(dir).entryList(filters);
for (const QString &file : fileNames) {
m_ui->colorInput->addItem(dir + QDir::separator() + file);
}
}
}
PageAppearance::~PageAppearance()

View File

@ -21,6 +21,16 @@
<item row="0" column="1">
<widget class="QComboBox" name="themeInput"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="colorInput"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="colorLabel">
<property name="text">
<string>Color scheme</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>