diff --git a/src/i18n/MControlCenter_pt_BR.ts b/src/i18n/MControlCenter_pt_BR.ts index 06e3b43..04314b4 100644 --- a/src/i18n/MControlCenter_pt_BR.ts +++ b/src/i18n/MControlCenter_pt_BR.ts @@ -9,15 +9,15 @@ EC Build: - Compilação do EC: + Build do EC: Battery charge: - Carga da bateria: + Carregando: Battery threshold: - Limite da bateria: + Limitador de carga da bateria: CPU temp: @@ -29,7 +29,7 @@ Cooler Boost - Impulsionar Ventoinha + Ventoinha com Esteroides Battery @@ -69,7 +69,7 @@ WebCam - Câmara de Web + Câmera Debug @@ -89,15 +89,15 @@ Charging - A carregar + Carregando Discharging - A descarregar + Descarregando Not charging - Não está a carregar + Não está carregando Unknown @@ -169,136 +169,165 @@ Reset - Repor + Resetar Fan control - Controlo da ventoinha + Controle da ventoinha Enable advanced fan control - Habilitar controlo avançado da ventoinha + Habilitar controle avançado da ventoinha Overview - + Resumo The middle spot between fan noise and power usage - + O equilíbrio entre consumo e barulho da ventoinha Low fan noise and moderate power usage - + Baixo barulho da ventoinha e consumo moderado Limits performance and turns off fans at lower temperatures - + Limita a performance e desliga as ventoinhas em baixas temperaturas GPU Fan: - + Ventoinha da GPU CPU Fan: - + Ventoinha da CPU USB Power - + USB Power FN ⇄ Meta - + FN ⇄ Meta Current fan Mode: - + Modo atual da ventoinha Keyboard - + Teclado <html><head/><body><p><span style=" font-weight:700;">MC</span>ontrol<span style=" font-weight:700;">C</span>enter (MCC) is an application that allows you to change the settings of MSI laptops running Linux.</p><p>MCC acts as a graphical interface for the <span style=" font-weight:700;">MSI-EC </span>driver that already exist in the Linux kernel, if your device is not supported (grey buttons/limited in-app functionality), please visit the msi-ec github page to get help.</p></body></html> - + <html><head/><body><p><span style=" font-weight:700;">MC</span>ontrol<span style=" font-weight:700;">C</span>enter (MCC) é uma aplicação que permite alterar as configurações de notebooks MSI rodando Linux.</p><p>O MCC atua como uma interface gráfica para o driver <span style=" font-weight:700;">MSI-EC</span> que já existe no kernel Linux. Se o seu dispositivo não for suportado (botões cinza/funcionalidade limitada), visite a página do msi-ec no GitHub para obter ajuda.</p></body></html> MCC GitHub: - + MCC GitHub: MSI-EC GitHub: - + MSI-EC GitHub: This mode unlocks Advanced fan mode - + Este modo desbloqueia o modo Avançado de ventoinha High Performance - + Alta Performance Maximum performance at the cost of heat and increased power consumption - + Performance máxima ao custo de aquecimento e maior consumo de energia If you mainly use your laptop with the charger plugged most of the time, it is recommended to set the charge capacity at a lower percentage (60% or 80%) to prolong your battery lifecycle. - + Se você utiliza seu notebook com o carregador conectado na maior parte do tempo, é recomendado definir a capacidade de carga em uma porcentagem menor (60% ou 80%) para prolongar a vida útil da bateria. Charge the battery when under 90%, stop at 100% - + Carregar a bateria quando estiver abaixo de 90%, parar a 100% Keyboard Backlight - + Luz de Fundo do Teclado - - + - MCC Bug Tracker: - + MCC Bug Tracker: Qt version: - + Versão Qt: MSI-EC Status: - + Status MSI-EC: <html><head/><body><p align="center"><span style=" font-weight:700;">Warning</span>: Writing the wrong values to the wrong addresses <span style=" font-weight:700;">WILL BRICK YOUR DEVICE!</span></p><p align="center"><span style=" font-weight:700;">Never</span> write to EC memory without knowing how to do a proper <span style=" font-weight:700;">BIOS/EC</span> reset, keep in mind that a reset <span style=" font-weight:700;">might not</span> fix the device if the device got bricked/broken. </p></body></html> - + <html><head/><body><p align="center"><span style=" font-weight:700;">Aviso</span>: Escrever valores errados nos endereços errados <span style=" font-weight:700;">VAI QUEBRAR SEU DISPOSITIVO!</span></p><p align="center"><span style=" font-weight:700;">Nunca</span> escrever na memória do EC sem saber como fazer um reset adequado de <span style=" font-weight:700;">BIOS/EC</span>. Tenha em mente que um reset <span style=" font-weight:700;">pode não</span> corrigir o dispositivo se ele foi quebrado/danificado.</p></body></html> The msi-ec module is not loaded/installed. Check the <About> page for more info. - + O módulo msi-ec não está carregado/instalado. +Verifique a página <Sobre> para mais informações. The ec_sys module couldn't be detected, it might be required to control the fans. - + O módulo ec_sys não foi detectado, ele pode ser necessário para controlar as ventoinhas. Loaded - + Carregado Fallback: Only ec_sys is loaded - + Fallback: Apenas ec_sys está carregado Failed to load both msi-ec/ec_sys - + Falha ao carregar msi-ec/ec_sys OFF - + DESLIGADO + + + Follow system's power profile + Seguir o perfil de energia do sistema + + + Automatic Profile Switching + Troca Automática de Perfil + + + On Charger: + Carregando: + + + On Battery: + Descarregando: + + + Couldn't connect to UPower to get charger status. +Make sure that UPower is installed and running then restart the system. + Não foi possível conectar ao UPower para obter o estado de carregamento. +Certifique-se de que o UPower está instalado e em execução e reinicie o sistema. + + + Couldn't connect to a power profile service. +Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system. + Não foi possível conectar a um serviço de perfil de energia. +Certifique-se de que o Power Profiles Daemon, TuneD ou system76-power está instalado e reinicie o sistema. diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c5f29ba..9866ef3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -843,6 +843,7 @@ void MainWindow::on_autoAcDcProfilesGroupBox_toggled(bool checked) { } powerMonitor.disconnectFromPowerProfiles(); + powerMonitor.disconnectFromSystem76Power(); ui->autoPPDCheckBox->setChecked(0); ui->autoPPDCheckBox->setEnabled(0); powerMonitor.queryChargerState(); @@ -856,10 +857,13 @@ void MainWindow::on_autoAcDcProfilesGroupBox_toggled(bool checked) { void MainWindow::on_autoPPDCheckBox_toggled(bool checked) { if (checked) { - - if (!powerMonitor.connectToPowerProfiles()) { - QMessageBox::critical(nullptr, this->windowTitle(), tr("Couldn't connect to Power Profiles Daemon.\n" - "Make sure that either Power Profiles Daemon or TuneD is installed and restart the system.")); + if (powerMonitor.connectToSystem76Power()) { + powerMonitor.querySystem76Profile(); + } else if (powerMonitor.connectToPowerProfiles()) { + powerMonitor.queryPowerProfile(); + } else { + QMessageBox::critical(nullptr, this->windowTitle(), tr("Couldn't connect to a power profile service.\n" + "Make sure that Power Profiles Daemon, TuneD, or system76-power is installed and restart the system.")); ui->autoPPDCheckBox->setChecked(0); return; } @@ -871,13 +875,14 @@ void MainWindow::on_autoPPDCheckBox_toggled(bool checked) { ui->superBatteryModeRadioButton->setEnabled(0); ui->autoAcDcProfilesGroupBox->setChecked(0); ui->autoAcDcProfilesGroupBox->setEnabled(0); - powerMonitor.queryPowerProfile(); } else { ui->highPerformanceModeRadioButton->setEnabled(1); ui->balancedModeRadioButton->setEnabled(1); ui->silentModeRadioButton->setEnabled(1); ui->superBatteryModeRadioButton->setEnabled(1); ui->autoAcDcProfilesGroupBox->setEnabled(1); + powerMonitor.disconnectFromPowerProfiles(); + powerMonitor.disconnectFromSystem76Power(); } Settings::setValue("Settings/autoPPDstate", checked); } diff --git a/src/powermonitor.cpp b/src/powermonitor.cpp index 81e90f2..dd88308 100644 --- a/src/powermonitor.cpp +++ b/src/powermonitor.cpp @@ -205,3 +205,78 @@ PowerProfile PowerMonitor::parsePowerProfile(const QString &profile) { return PowerProfile::PowerSaver; return PowerProfile::Unknown; } + +bool PowerMonitor::connectToSystem76Power() { + if(isSystem76Connected) { + return true; + } + + auto bus = QDBusConnection::systemBus(); + + if (!bus.interface()->isServiceRegistered("com.system76.PowerDaemon")) { + return false; + } + + bool ok = bus.connect( + "com.system76.PowerDaemon", + "/com/system76/PowerDaemon", + "com.system76.PowerDaemon", + "PowerProfileSwitch", + this, + SLOT(onSystem76ProfileChanged(QString)) + ); + + isSystem76Connected = ok; + return ok; +} + +void PowerMonitor::disconnectFromSystem76Power() { + if (isSystem76Connected) { + QDBusConnection::systemBus().disconnect( + "com.system76.PowerDaemon", + "/com/system76/PowerDaemon", + "com.system76.PowerDaemon", + "PowerProfileSwitch", + this, + SLOT(onSystem76ProfileChanged(QString)) + ); + isSystem76Connected = false; + } +} + +void PowerMonitor::querySystem76Profile() { + if (isSystem76Connected) { + QDBusInterface iface( + "com.system76.PowerDaemon", + "/com/system76/PowerDaemon", + "com.system76.PowerDaemon", + QDBusConnection::systemBus() + ); + + QDBusReply reply = iface.call("GetProfile"); + + if (!reply.isValid()) { + return; + } + + const QString profileName = reply.value(); + + PowerProfile profile = parseSystem76Profile(profileName); + + emit currentPowerProfile(profile); + } +} + +void PowerMonitor::onSystem76ProfileChanged(const QString &profile) { + emit currentPowerProfile(parseSystem76Profile(profile)); +} + +PowerProfile PowerMonitor::parseSystem76Profile(const QString &profile) { + if (profile == "Performance") + return PowerProfile::Performance; + if (profile == "Balanced") + return PowerProfile::Balanced; + if (profile == "Battery") + return PowerProfile::PowerSaver; + return PowerProfile::Unknown; +} diff --git a/src/powermonitor.h b/src/powermonitor.h index 01f16cc..ab0c85c 100644 --- a/src/powermonitor.h +++ b/src/powermonitor.h @@ -36,19 +36,24 @@ class PowerMonitor : public QObject { bool connectToUpower(); bool connectToPowerProfiles(); + bool connectToSystem76Power(); void disconnectFromUpower(); void disconnectFromPowerProfiles(); + void disconnectFromSystem76Power(); void queryChargerState(); void queryPowerProfile(); + void querySystem76Profile(); Q_ENUM(PowerProfile) private: bool parseChargerState(uint state) const; PowerProfile parsePowerProfile(const QString &profile); + PowerProfile parseSystem76Profile(const QString &profile); bool isUPowerConnected = false; bool isPowerProfileConnected = false; + bool isSystem76Connected = false; signals: void currentChargerState(bool isOnline); @@ -62,6 +67,8 @@ private slots: void onPowerProfileChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidatedProps); + + void onSystem76ProfileChanged(const QString &profile); }; #endif // POWERMONITOR_H