forgot to commit in a while

This commit is contained in:
fourtf
2018-06-01 14:20:46 +02:00
parent a3e4c92b9f
commit 3a78068810
15 changed files with 218 additions and 72 deletions
@@ -31,6 +31,7 @@ namespace ipc = boost::interprocess;
namespace chatterino {
namespace singletons {
// fourtf: don't add this class to the application class
NativeMessagingManager::NativeMessagingManager()
{
qDebug() << "init NativeMessagingManager";
@@ -8,6 +8,7 @@ namespace singletons {
class NativeMessagingManager
{
public:
// fourtf: don't add this class to the application class
NativeMessagingManager();
~NativeMessagingManager() = delete;
+15 -10
View File
@@ -142,7 +142,12 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
this->splits.messageSeperator = isLight ? QColor(127, 127, 127) : QColor(60, 60, 60);
this->splits.background = getColor(0, sat, 1);
this->splits.dropPreview = QColor(0, 148, 255, 0x30);
this->splits.dropPreviewBorder = QColor(0, 148, 255, 0x70);
this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff);
this->splits.dropTargetRect = QColor(0, 148, 255, 0x00);
this->splits.dropTargetRectBorder = QColor(0, 148, 255, 0x00);
this->splits.resizeHandle = QColor(0, 148, 255, 0x70);
this->splits.resizeHandleBackground = QColor(0, 148, 255, 0x20);
// this->splits.border
// this->splits.borderFocused
@@ -191,9 +196,9 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
QColor ThemeManager::blendColors(const QColor &color1, const QColor &color2, qreal ratio)
{
int r = color1.red() * (1 - ratio) + color2.red() * ratio;
int g = color1.green() * (1 - ratio) + color2.green() * ratio;
int b = color1.blue() * (1 - ratio) + color2.blue() * ratio;
int r = int(color1.red() * (1 - ratio) + color2.red() * ratio);
int g = int(color1.green() * (1 - ratio) + color2.green() * ratio);
int b = int(color1.blue() * (1 - ratio) + color2.blue() * ratio);
return QColor(r, g, b, 255);
}
@@ -201,22 +206,22 @@ QColor ThemeManager::blendColors(const QColor &color1, const QColor &color2, qre
void ThemeManager::normalizeColor(QColor &color)
{
if (this->isLight) {
if (color.lightnessF() > 0.5f) {
color.setHslF(color.hueF(), color.saturationF(), 0.5f);
if (color.lightnessF() > 0.5) {
color.setHslF(color.hueF(), color.saturationF(), 0.5);
}
if (color.lightnessF() > 0.4f && color.hueF() > 0.1 && color.hueF() < 0.33333) {
if (color.lightnessF() > 0.4 && color.hueF() > 0.1 && color.hueF() < 0.33333) {
color.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() - sin((color.hueF() - 0.1) / (0.3333 - 0.1) * 3.14159) *
color.saturationF() * 0.2);
}
} else {
if (color.lightnessF() < 0.5f) {
color.setHslF(color.hueF(), color.saturationF(), 0.5f);
if (color.lightnessF() < 0.5) {
color.setHslF(color.hueF(), color.saturationF(), 0.5);
}
if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
if (color.lightnessF() < 0.6 && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
color.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
+4
View File
@@ -63,6 +63,10 @@ public:
QColor borderFocused;
QColor dropPreview;
QColor dropPreviewBorder;
QColor dropTargetRect;
QColor dropTargetRectBorder;
QColor resizeHandle;
QColor resizeHandleBackground;
struct {
QColor border;
+33 -6
View File
@@ -7,25 +7,31 @@ namespace chatterino {
namespace singletons {
UpdateManager::UpdateManager()
: currentVersion(CHATTERINO_VERSION)
: currentVersion_(CHATTERINO_VERSION)
{
qDebug() << "init UpdateManager";
}
UpdateManager &UpdateManager::getInstance()
{
// fourtf: don't add this class to the application class
static UpdateManager instance;
return instance;
}
const QString &UpdateManager::getCurrentVersion() const
{
return this->getCurrentVersion();
return currentVersion_;
}
const QString &UpdateManager::getOnlineVersion() const
{
return this->getOnlineVersion();
return onlineVersion_;
}
void UpdateManager::installUpdates()
{
}
void UpdateManager::checkForUpdates()
@@ -33,17 +39,38 @@ void UpdateManager::checkForUpdates()
QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable";
util::NetworkRequest req(url);
req.setTimeout(20000);
req.setTimeout(30000);
req.getJSON([this](QJsonObject &object) {
QJsonValue version_val = object.value("version");
if (!version_val.isString()) {
this->setStatus_(Error);
qDebug() << "error updating";
return;
}
this->onlineVersion = version_val.toString();
this->onlineVersionUpdated.invoke();
this->onlineVersion_ = version_val.toString();
if (this->currentVersion_ != this->onlineVersion_) {
this->setStatus_(UpdateAvailable);
} else {
this->setStatus_(NoUpdateAvailable);
}
});
this->setStatus_(Searching);
req.execute();
}
UpdateManager::UpdateStatus UpdateManager::getStatus() const
{
return this->status_;
}
void UpdateManager::setStatus_(UpdateStatus status)
{
if (this->status_ != status) {
this->status_ = status;
this->statusUpdated.invoke(status);
}
}
} // namespace singletons
+11 -3
View File
@@ -11,17 +11,25 @@ class UpdateManager
UpdateManager();
public:
enum UpdateStatus { None, Searching, UpdateAvailable, NoUpdateAvailable, Error };
// fourtf: don't add this class to the application class
static UpdateManager &getInstance();
void checkForUpdates();
const QString &getCurrentVersion() const;
const QString &getOnlineVersion() const;
void installUpdates();
UpdateStatus getStatus() const;
pajlada::Signals::NoArgSignal onlineVersionUpdated;
pajlada::Signals::Signal<UpdateStatus> statusUpdated;
private:
QString currentVersion;
QString onlineVersion;
QString currentVersion_;
QString onlineVersion_;
UpdateStatus status_ = None;
void setStatus_(UpdateStatus status);
};
} // namespace singletons