feat: add Cat support
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
5c02265325
commit
3009356c8a
@ -882,7 +882,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
|
|||||||
ui->actionCAT->setChecked(cat_enable);
|
ui->actionCAT->setChecked(cat_enable);
|
||||||
// NOTE: calling the operator like that is an ugly hack to appease ancient gcc...
|
// NOTE: calling the operator like that is an ugly hack to appease ancient gcc...
|
||||||
connect(ui->actionCAT.operator->(), SIGNAL(toggled(bool)), SLOT(onCatToggled(bool)));
|
connect(ui->actionCAT.operator->(), SIGNAL(toggled(bool)), SLOT(onCatToggled(bool)));
|
||||||
setCatBackground(cat_enable);
|
view->setCatDisplayed(cat_enable);
|
||||||
}
|
}
|
||||||
// start instance when double-clicked
|
// start instance when double-clicked
|
||||||
connect(view, &InstanceView::instanceActivated, this, &MainWindow::instanceActivated);
|
connect(view, &InstanceView::instanceActivated, this, &MainWindow::instanceActivated);
|
||||||
@ -1469,54 +1469,10 @@ void MainWindow::downloadUpdates(GoUpdate::Status status)
|
|||||||
|
|
||||||
void MainWindow::onCatToggled(bool state)
|
void MainWindow::onCatToggled(bool state)
|
||||||
{
|
{
|
||||||
setCatBackground(state);
|
view->setCatDisplayed(state);
|
||||||
APPLICATION->settings()->set("TheCat", state);
|
APPLICATION->settings()->set("TheCat", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
template <typename T>
|
|
||||||
T non_stupid_abs(T in)
|
|
||||||
{
|
|
||||||
if (in < 0)
|
|
||||||
return -in;
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setCatBackground(bool enabled)
|
|
||||||
{
|
|
||||||
if (enabled)
|
|
||||||
{
|
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
|
||||||
QDateTime birthday(QDate(now.date().year(), 11, 30), QTime(0, 0));
|
|
||||||
QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
|
|
||||||
QString cat;
|
|
||||||
if(non_stupid_abs(now.daysTo(xmas)) <= 4) {
|
|
||||||
cat = "catmas";
|
|
||||||
}
|
|
||||||
else if (non_stupid_abs(now.daysTo(birthday)) <= 12) {
|
|
||||||
cat = "cattiversary";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cat = "kitteh";
|
|
||||||
}
|
|
||||||
view->setStyleSheet(QString(R"(
|
|
||||||
InstanceView
|
|
||||||
{
|
|
||||||
background-image: url(:/backgrounds/%1);
|
|
||||||
background-attachment: fixed;
|
|
||||||
background-clip: padding;
|
|
||||||
background-position: top right;
|
|
||||||
background-repeat: none;
|
|
||||||
background-color:palette(base);
|
|
||||||
})").arg(cat));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
view->setStyleSheet(QString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::runModalTask(Task *task)
|
void MainWindow::runModalTask(Task *task)
|
||||||
{
|
{
|
||||||
connect(task, &Task::failed, [this](QString reason)
|
connect(task, &Task::failed, [this](QString reason)
|
||||||
|
@ -212,7 +212,6 @@ private:
|
|||||||
|
|
||||||
void addInstance(QString url = QString());
|
void addInstance(QString url = QString());
|
||||||
void activateInstance(InstancePtr instance);
|
void activateInstance(InstancePtr instance);
|
||||||
void setCatBackground(bool enabled);
|
|
||||||
void updateInstanceToolIcon(QString new_icon);
|
void updateInstanceToolIcon(QString new_icon);
|
||||||
void setSelectedInstanceById(const QString &id);
|
void setSelectedInstanceById(const QString &id);
|
||||||
void updateStatusCenter();
|
void updateStatusCenter();
|
||||||
|
@ -161,3 +161,35 @@ QModelIndex InstanceView::mappedIndex(const QModelIndex& index) const
|
|||||||
{
|
{
|
||||||
return m_proxy->mapToSource(index);
|
return m_proxy->mapToSource(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceView::setCatDisplayed(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled) {
|
||||||
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
QDateTime birthday(QDate(now.date().year(), 11, 30), QTime(0, 0));
|
||||||
|
QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
|
||||||
|
QString cat;
|
||||||
|
if (std::abs(now.daysTo(xmas)) <= 4) {
|
||||||
|
cat = "catmas";
|
||||||
|
} else if (std::abs(now.daysTo(birthday)) <= 12) {
|
||||||
|
cat = "cattiversary";
|
||||||
|
} else {
|
||||||
|
cat = "kitteh";
|
||||||
|
}
|
||||||
|
setStyleSheet(QString(R"(
|
||||||
|
*
|
||||||
|
{
|
||||||
|
background-image: url(:/backgrounds/%1);
|
||||||
|
background-attachment: fixed;
|
||||||
|
background-clip: padding;
|
||||||
|
background-position: bottom right;
|
||||||
|
background-repeat: none;
|
||||||
|
background-color:palette(base);
|
||||||
|
})")
|
||||||
|
.arg(cat));
|
||||||
|
m_table->setAlternatingRowColors(false);
|
||||||
|
} else {
|
||||||
|
setStyleSheet(QString());
|
||||||
|
m_table->setAlternatingRowColors(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -39,6 +39,8 @@ class InstanceView : public QStackedWidget {
|
|||||||
// save state of current view
|
// save state of current view
|
||||||
void storeState();
|
void storeState();
|
||||||
|
|
||||||
|
void setCatDisplayed(bool enabled);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void instanceActivated(InstancePtr inst);
|
void instanceActivated(InstancePtr inst);
|
||||||
void currentInstanceChanged(InstancePtr current, InstancePtr previous);
|
void currentInstanceChanged(InstancePtr current, InstancePtr previous);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user