mirror of
https://github.com/vicr123/theshell.git
synced 2025-01-23 04:11:49 -05:00
Add battery indicator to status bar
This commit is contained in:
parent
c85b2ebdfb
commit
6f50bbd400
4 changed files with 72 additions and 59 deletions
|
@ -41,24 +41,24 @@ EndSessionWait::EndSessionWait(shutdownType type, QWidget *parent) :
|
|||
}
|
||||
|
||||
switch (type) {
|
||||
case powerOff:
|
||||
ui->label->setText(tr("Power Off"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case reboot:
|
||||
ui->label->setText(tr("Reboot"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case logout:
|
||||
ui->label->setText(tr("Log out"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case dummy:
|
||||
ui->label->setText(tr("Dummy"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case ask:
|
||||
ui->poweringOff->setVisible(false);
|
||||
case powerOff:
|
||||
ui->label->setText(tr("Power Off"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case reboot:
|
||||
ui->label->setText(tr("Reboot"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case logout:
|
||||
ui->label->setText(tr("Log out"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case dummy:
|
||||
ui->label->setText(tr("Dummy"));
|
||||
ui->askWhatToDo->setVisible(false);
|
||||
break;
|
||||
case ask:
|
||||
ui->poweringOff->setVisible(false);
|
||||
}
|
||||
|
||||
this->type = type;
|
||||
|
@ -125,7 +125,6 @@ void EndSessionWait::showFullScreen() {
|
|||
alreadyShowing = true;
|
||||
this->setWindowOpacity(0.0);
|
||||
QDialog::showFullScreen();
|
||||
//ui->terminateAppFrame->resize(ui->terminateAppFrame->width(), 0);
|
||||
ui->terminateAppFrame->setGeometry(ui->terminateAppFrame->x(), ui->terminateAppFrame->y(), ui->terminateAppFrame->width(), 0);
|
||||
ui->terminateAppFrame->setVisible(false);
|
||||
ui->ExitFrameTop->resize(ui->ExitFrameTop->sizeHint());
|
||||
|
|
|
@ -351,17 +351,17 @@ InfoPaneDropdown::InfoPaneDropdown(NotificationDBus* notificationEngine, UPowerD
|
|||
//Don't forget to change settings pane setup things
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-system-login"), tr("Startup")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-desktop-bar", QIcon::fromTheme("preferences-desktop")), tr("Bar")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-desktop"), tr("Gateway")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-desktop-gateway", QIcon::fromTheme("preferences-desktop")), tr("Gateway")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-desktop-display"), tr("Display")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-desktop-theme"), tr("Theme")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("dialog-warning"), tr("Notifications")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-system-notifications", QIcon::fromTheme("dialog-warning")), tr("Notifications")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("input-tablet"), tr("Input")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("system-lock-screen"), tr("Lock Screen")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("thewave", QIcon(":/icons/thewave.svg")), tr("theWave")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-desktop-user"), tr("Users")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-system-time"), tr("Date and Time")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-system-locale"), tr("Language")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("emblem-warning"), tr("Danger")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("preferences-system-danger", QIcon::fromTheme("emblem-warning")), tr("Danger")));
|
||||
ui->settingsList->addItem(new QListWidgetItem(QIcon::fromTheme("help-about"), tr("About")));
|
||||
ui->settingsList->item(ui->settingsList->count() - 1)->setSelected(true);
|
||||
ui->settingsTabs->setCurrentIndex(ui->settingsTabs->count() - 1);
|
||||
|
|
|
@ -75,8 +75,42 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
if (updbus->hasBattery()) {
|
||||
ui->batteryFrame->setVisible(true);
|
||||
ui->batteryLabel->setText(display);
|
||||
|
||||
QString iconName;
|
||||
if (updbus->charging()) {
|
||||
if (updbus->currentBattery() < 10) {
|
||||
iconName = "battery-charging-empty";
|
||||
} else if (updbus->currentBattery() < 30) {
|
||||
iconName = "battery-charging-020";
|
||||
} else if (updbus->currentBattery() < 50) {
|
||||
iconName = "battery-charging-040";
|
||||
} else if (updbus->currentBattery() < 70) {
|
||||
iconName = "battery-charging-060";
|
||||
} else if (updbus->currentBattery() < 90) {
|
||||
iconName = "battery-charging-080";
|
||||
} else {
|
||||
iconName = "battery-charging-100";
|
||||
}
|
||||
} else {
|
||||
if (updbus->currentBattery() < 10) {
|
||||
iconName = "battery-empty";
|
||||
} else if (updbus->currentBattery() < 30) {
|
||||
iconName = "battery-020";
|
||||
} else if (updbus->currentBattery() < 50) {
|
||||
iconName = "battery-040";
|
||||
} else if (updbus->currentBattery() < 70) {
|
||||
iconName = "battery-060";
|
||||
} else if (updbus->currentBattery() < 90) {
|
||||
iconName = "battery-080";
|
||||
} else {
|
||||
iconName = "battery-100";
|
||||
}
|
||||
}
|
||||
|
||||
ui->StatusBarBattery->setPixmap(QIcon::fromTheme(iconName).pixmap(16 * getDPIScaling(), 16 * getDPIScaling()));
|
||||
} else {
|
||||
ui->batteryFrame->setVisible(false);
|
||||
ui->StatusBarBattery->setVisible(false);
|
||||
}
|
||||
|
||||
updbus->currentBattery();
|
||||
|
@ -116,10 +150,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
ui->timer->setVisible(false);
|
||||
ui->timerIcon->setVisible(false);
|
||||
ui->timerIcon->setPixmap(QIcon::fromTheme("player-time").pixmap(16 * getDPIScaling(), 16 * getDPIScaling()));
|
||||
ui->StatusBarNotificationsIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16 * getDPIScaling(), 16 * getDPIScaling()));
|
||||
ui->networkStrength->setVisible(false);
|
||||
ui->StatusBarNotifications->setVisible(false);
|
||||
ui->StatusBarNotificationsIcon->setVisible(false);
|
||||
ui->StatusBarMpris->setVisible(false);
|
||||
ui->StatusBarMprisIcon->setVisible(false);
|
||||
|
||||
|
@ -941,13 +973,14 @@ void MainWindow::on_volumeFrame_MouseEnter()
|
|||
{
|
||||
ui->volumeSlider->setVisible(true);
|
||||
|
||||
//Animate the volume frame
|
||||
tVariantAnimation* anim = new tVariantAnimation;
|
||||
connect(anim, &tVariantAnimation::valueChanged, [=](QVariant value) {
|
||||
ui->volumeSlider->setFixedWidth(value.toInt());
|
||||
});
|
||||
connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
anim->setStartValue(ui->volumeSlider->width());
|
||||
anim->setEndValue(150 * getDPIScaling());
|
||||
anim->setEndValue((int) (150 * getDPIScaling()));
|
||||
anim->setDuration(250);
|
||||
anim->setEasingCurve(QEasingCurve::OutCubic);
|
||||
anim->start();
|
||||
|
@ -959,6 +992,7 @@ void MainWindow::on_volumeFrame_MouseEnter()
|
|||
|
||||
void MainWindow::on_volumeFrame_MouseExit()
|
||||
{
|
||||
//Animate the volume frame
|
||||
tVariantAnimation* anim = new tVariantAnimation;
|
||||
connect(anim, &tVariantAnimation::valueChanged, [=](QVariant value) {
|
||||
ui->volumeSlider->setFixedWidth(value.toInt());
|
||||
|
@ -982,11 +1016,11 @@ void MainWindow::on_volumeSlider_sliderMoved(int position)
|
|||
void MainWindow::on_volumeSlider_valueChanged(int value)
|
||||
{
|
||||
on_volumeSlider_sliderMoved(value);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_brightnessFrame_MouseEnter()
|
||||
{
|
||||
//Animate the brightness frame
|
||||
ui->brightnessSlider->setVisible(true);
|
||||
tVariantAnimation* anim = new tVariantAnimation;
|
||||
connect(anim, &tVariantAnimation::valueChanged, [=](QVariant value) {
|
||||
|
@ -994,7 +1028,7 @@ void MainWindow::on_brightnessFrame_MouseEnter()
|
|||
});
|
||||
connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
anim->setStartValue(ui->brightnessSlider->width());
|
||||
anim->setEndValue(150 * getDPIScaling());
|
||||
anim->setEndValue((int) (150 * getDPIScaling()));
|
||||
anim->setDuration(250);
|
||||
anim->setEasingCurve(QEasingCurve::OutCubic);
|
||||
anim->start();
|
||||
|
@ -1089,7 +1123,6 @@ void MainWindow::numNotificationsChanged(int notifications) {
|
|||
font.setBold(false);
|
||||
ui->notifications->setText(tr("No notifications"));
|
||||
ui->StatusBarNotifications->setVisible(false);
|
||||
ui->StatusBarNotificationsIcon->setVisible(false);
|
||||
} else {
|
||||
font.setBold(true);
|
||||
if (notifications == 1) {
|
||||
|
@ -1099,7 +1132,6 @@ void MainWindow::numNotificationsChanged(int notifications) {
|
|||
}
|
||||
ui->StatusBarNotifications->setText(QString::number(notifications));
|
||||
ui->StatusBarNotifications->setVisible(true);
|
||||
ui->StatusBarNotificationsIcon->setVisible(true);
|
||||
}
|
||||
ui->notifications->setFont(font);
|
||||
}
|
||||
|
|
|
@ -198,17 +198,11 @@
|
|||
<item>
|
||||
<widget class="HoverFrame" name="brightnessFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>228</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
|
@ -256,12 +250,6 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="brightnessSlider">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
|
@ -327,17 +315,11 @@
|
|||
<item>
|
||||
<widget class="HoverFrame" name="volumeFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>228</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
|
@ -379,12 +361,6 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="volumeSlider">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
|
@ -738,16 +714,22 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="StatusBarNotifications">
|
||||
<widget class="QLabel" name="StatusBarBattery">
|
||||
<property name="text">
|
||||
<string notr="true">Notifications</string>
|
||||
<string>Battery</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="StatusBarNotificationsIcon">
|
||||
<widget class="QLabel" name="StatusBarNotifications">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(200, 100, 0);
|
||||
color: white;
|
||||
padding-left: 3px;
|
||||
padding-right: 3px;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Icon</string>
|
||||
<string notr="true">Notifications</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue