Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
Cleaner fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed May 27, 2018
1 parent 0b569dd commit 912b745
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 39 deletions.
64 changes: 33 additions & 31 deletions shell/infopanedropdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,33 @@ InfoPaneDropdown::InfoPaneDropdown(WId MainWindowId, QWidget *parent) :

updateBatteryChart();

//Check Redshift
QProcess* redshiftQuery = new QProcess;
redshiftQuery->start("redshift -V");
connect(redshiftQuery, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus) {
QString output = redshiftQuery->readAll().trimmed();
output.remove("redshift ");

QStringList parts = output.split(".");
for (int i = 0; i < parts.count(); i++) {
int version = parts.at(i).toInt();
if (i == 0) {
if (version > 1) {
break;
} else if (version < 1) {
isNewRedshift = false;
break;
}
} else if (i == 1) {
if (version < 11) {
isNewRedshift = false;
}
break;
}
}
redshiftQuery->deleteLater();
});

//Set up KDE Connect
if (!QFile("/usr/lib/kdeconnectd").exists()) {
//If KDE Connect is not installed, hide the KDE Connect option
Expand Down Expand Up @@ -523,9 +550,6 @@ void InfoPaneDropdown::processTimer() {
int endMsecs = ui->endRedshift->time().msecsSinceStartOfDay();
int endIntensity = ui->redshiftIntensity->value();
const int oneHour = 3600000;
QProcess* redshiftQuery = new QProcess;
redshiftQuery->start("redshift -V");

QString redshiftCommand;

if (ui->redshiftPause->isChecked()) {
Expand Down Expand Up @@ -604,36 +628,14 @@ void InfoPaneDropdown::processTimer() {
emit redshiftEnabledChanged(false);
}
}
connect(redshiftQuery, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus) {
QString runCommand = redshiftCommand;

QString output = redshiftQuery->readAll().trimmed();
output.remove("redshift ");

QStringList parts = output.split(".");
for (int i = 0; i < parts.count(); i++) {
int version = parts.at(i).toInt();
if (i == 0) {
if (version > 1) {
runCommand += " -P";
break;
} else if (version < 1) {
break;
}
} else if (i == 1) {
if (version > 11) {
runCommand += " -P";
}
break;
}
}

redshiftQuery->deleteLater();
if (isNewRedshift) {
redshiftCommand += " -P";
}

QProcess* redshiftAdjust = new QProcess();
redshiftAdjust->start(runCommand);
connect(redshiftAdjust, SIGNAL(finished(int)), redshiftAdjust, SLOT(deleteLater()));
});
QProcess* redshiftAdjust = new QProcess();
redshiftAdjust->start(redshiftCommand);
connect(redshiftAdjust, SIGNAL(finished(int)), redshiftAdjust, SLOT(deleteLater()));
}

/*{
Expand Down
1 change: 1 addition & 0 deletions shell/infopanedropdown.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ private slots:
Ui::InfoPaneDropdown *ui;

bool isRedshiftOn = false;
bool isNewRedshift = true;
dropdownType currentDropDown = Clock;
void changeDropDown(dropdownType changeTo, bool doAnimation = true);
int mouseClickPoint;
Expand Down
17 changes: 9 additions & 8 deletions shell/infopanedropdown.ui
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1151</width>
<height>1038</height>
<width>616</width>
<height>1062</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_26">
Expand Down Expand Up @@ -611,14 +611,14 @@
<second>0</second>
<year>1969</year>
<month>9</month>
<day>5</day>
<day>4</day>
</datetime>
</property>
<property name="date">
<date>
<year>1969</year>
<month>9</month>
<day>5</day>
<day>4</day>
</date>
</property>
<property name="displayFormat">
Expand Down Expand Up @@ -1504,7 +1504,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1165</width>
<width>182</width>
<height>114</height>
</rect>
</property>
Expand Down Expand Up @@ -1947,7 +1947,7 @@
<item>
<widget class="QStackedWidget" name="settingsTabs">
<property name="currentIndex">
<number>13</number>
<number>14</number>
</property>
<widget class="QWidget" name="StartupSettings">
<layout class="QVBoxLayout" name="verticalLayout_9">
Expand Down Expand Up @@ -4896,7 +4896,8 @@ Items that will be kept if you choose to keep files:
<string>Reset Device</string>
</property>
<property name="icon">
<iconset theme="view-refresh"/>
<iconset theme="view-refresh">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
Expand All @@ -4920,7 +4921,7 @@ Items that will be kept if you choose to keep files:
<item row="7" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>theShell is Copyright (c) Victor Tran 2017. Licensed under the terms of the GNU General Public License, version 3 or later.</string>
<string>theShell is Copyright (c) Victor Tran 2018. Licensed under the terms of the GNU General Public License, version 3 or later.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down

0 comments on commit 912b745

Please sign in to comment.