windowlistdialog.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include "windowlistdialog.h"
  2. void WindowListDialog::setPaneContents() {
  3. mContentsWidget = new QWidget();
  4. QVBoxLayout* contentsLayout = new QVBoxLayout(mContentsWidget);
  5. mContentsWidget->setObjectName("innerPane");
  6. // Adding widgets
  7. QHBoxLayout* iconSizeLayout = new QHBoxLayout();
  8. QLabel* iconSizeLabel = new QLabel(tr("Icon Size:"));
  9. iconSizeLabel->setFont(mTitleFont);
  10. iconSizeLayout->addWidget(iconSizeLabel);
  11. QSpinBox* iconSizeSpinBox = new QSpinBox();
  12. iconSizeSpinBox->setMinimum(0);
  13. iconSizeSpinBox->setMaximum(256);
  14. iconSizeSpinBox->setFont(mFont);
  15. iconSizeLayout->addWidget(iconSizeSpinBox);
  16. contentsLayout->addLayout(iconSizeLayout);
  17. QCheckBox* showTitlesCheckBox = new QCheckBox(tr("Show Window Titles"));
  18. showTitlesCheckBox->setFont(mTitleFont);
  19. contentsLayout->addWidget(showTitlesCheckBox);
  20. contentsLayout->addSpacerItem(new QSpacerItem(0, 0,
  21. QSizePolicy::Ignored,
  22. QSizePolicy::MinimumExpanding));
  23. QHBoxLayout* buttonsLayout = new QHBoxLayout();
  24. buttonsLayout->addSpacerItem(new QSpacerItem(0, 0,
  25. QSizePolicy::MinimumExpanding,
  26. QSizePolicy::Ignored));
  27. QPushButton* cancelButton = new QPushButton(tr("Cancel"));
  28. cancelButton->setFont(mFont);
  29. buttonsLayout->addWidget(cancelButton);
  30. QPushButton* okButton = new QPushButton(tr("OK"));
  31. okButton->setFont(mFont);
  32. buttonsLayout->addWidget(okButton);
  33. contentsLayout->addLayout(buttonsLayout);
  34. // Setting current settings
  35. iconSizeSpinBox->setValue(getConfigValue("winListIconSize").toInt());
  36. showTitlesCheckBox->setChecked(getConfigValue("winListShowTitles").toBool());
  37. // Making connections
  38. connect(cancelButton, &QPushButton::clicked, this, [this]() {
  39. this->hide();
  40. delete this;
  41. });
  42. connect(okButton, &QPushButton::clicked, this, [this, iconSizeSpinBox,
  43. showTitlesCheckBox]() {
  44. prepareToSave(iconSizeSpinBox, showTitlesCheckBox);
  45. saveConfig();
  46. this->hide();
  47. delete this;
  48. });
  49. finalizeUI();
  50. setWindowGeometry();
  51. setTransparency(this);
  52. }
  53. void WindowListDialog::prepareToSave(QSpinBox* iconSizeSpinBox,
  54. QCheckBox* showTitlesCheckBox) {
  55. setEntry("winListIconSize", iconSizeSpinBox->value());
  56. setEntry("winListShowTitles", showTitlesCheckBox->isChecked());
  57. }
  58. WindowListDialog::WindowListDialog(QJsonObject* cfgObj) : Dialog(cfgObj,
  59. tr("Window List applet settings"),
  60. "preferences-system-windows") {
  61. }