pane.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #include "pane.h"
  2. #include <QDBusConnection>
  3. #include <QDBusMessage>
  4. #include <QDebug>
  5. void Pane::saveConfig(QJsonObject config) {
  6. QString homePath = getenv("HOME");
  7. QString configPath = homePath + "/.config/plainDE/config.json";
  8. QJsonDocument doc(config);
  9. QFile jsonFile(configPath);
  10. jsonFile.open(QFile::WriteOnly);
  11. jsonFile.write(doc.toJson(QJsonDocument::Indented));
  12. jsonFile.close();
  13. QDBusConnection bus = QDBusConnection::sessionBus();
  14. QDBusMessage request = QDBusMessage::createMethodCall("org.plainDE.plainPanel",
  15. "/Actions",
  16. "org.plainDE.actions",
  17. "reconfigurePanel");
  18. QDBusMessage response = bus.call(request);
  19. /* We will show this message if plainPanel is not running at the moment,
  20. * so user will know everything is ok. */
  21. if (response.type() == QDBusMessage::ErrorMessage) {
  22. QMessageBox msg;
  23. msg.setWindowTitle("Success");
  24. msg.setText("Settings were saved successfully.");
  25. msg.setStandardButtons(QMessageBox::Ok);
  26. msg.setIcon(QMessageBox::Information);
  27. msg.exec();
  28. }
  29. }