workspacesdialog.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "workspacesdialog.h"
  2. void WorkspacesDialog::setPaneContents() {
  3. mContentsWidget = new QWidget();
  4. QVBoxLayout* contentsLayout = new QVBoxLayout(mContentsWidget);
  5. mContentsWidget->setObjectName("innerPane");
  6. // Adding widgets
  7. QLabel* indicatorTypeLabel = new QLabel(tr("Indicator Type:"));
  8. indicatorTypeLabel->setFont(mTitleFont);
  9. contentsLayout->addWidget(indicatorTypeLabel);
  10. QRadioButton* useNumbersRadioButton = new QRadioButton(tr("Show workspaces numbers"));
  11. useNumbersRadioButton->setFont(mFont);
  12. contentsLayout->addWidget(useNumbersRadioButton);
  13. QRadioButton* useTitlesRadioButton = new QRadioButton(tr("Show workspaces names"));
  14. useTitlesRadioButton->setFont(mFont);
  15. contentsLayout->addWidget(useTitlesRadioButton);
  16. contentsLayout->addSpacerItem(new QSpacerItem(0, 0,
  17. QSizePolicy::Ignored,
  18. QSizePolicy::MinimumExpanding));
  19. QHBoxLayout* buttonsLayout = new QHBoxLayout();
  20. buttonsLayout->addSpacerItem(new QSpacerItem(0, 0,
  21. QSizePolicy::MinimumExpanding,
  22. QSizePolicy::Ignored));
  23. QPushButton* cancelButton = new QPushButton(tr("Cancel"));
  24. cancelButton->setFont(mFont);
  25. buttonsLayout->addWidget(cancelButton);
  26. QPushButton* okButton = new QPushButton(tr("OK"));
  27. okButton->setFont(mFont);
  28. buttonsLayout->addWidget(okButton);
  29. contentsLayout->addLayout(buttonsLayout);
  30. // Setting current settings
  31. if (getConfigValue("showDesktopNames").toBool()) {
  32. useTitlesRadioButton->setChecked(true);
  33. }
  34. else { // Numbers
  35. useNumbersRadioButton->setChecked(true);
  36. }
  37. // Making connections
  38. connect(cancelButton, &QPushButton::clicked, this, [this]() {
  39. this->hide();
  40. delete this;
  41. });
  42. connect(okButton, &QPushButton::clicked, this, [this, useTitlesRadioButton]() {
  43. prepareToSave(useTitlesRadioButton);
  44. saveConfig();
  45. this->hide();
  46. delete this;
  47. });
  48. finalizeUI();
  49. setWindowGeometry();
  50. setTransparency(this);
  51. }
  52. void WorkspacesDialog::prepareToSave(QRadioButton* useTitlesRadioButton) {
  53. setEntry("showDesktopNames", useTitlesRadioButton->isChecked());
  54. }
  55. WorkspacesDialog::WorkspacesDialog(QJsonObject* cfgObj) : Dialog(cfgObj,
  56. tr("Workspaces applet settings"),
  57. "workspace-switcher-top-left") {
  58. }