kbindicatordialog.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "kbindicatordialog.h"
  2. void KbIndicatorDialog::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* flagRadioButton = new QRadioButton(tr("Flag"));
  11. flagRadioButton->setFont(mFont);
  12. contentsLayout->addWidget(flagRadioButton);
  13. QRadioButton* isoCodeRadioButton = new QRadioButton(tr("ISO code"));
  14. isoCodeRadioButton->setFont(mFont);
  15. contentsLayout->addWidget(isoCodeRadioButton);
  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("useCountryFlag").toBool()) {
  32. flagRadioButton->setChecked(true);
  33. }
  34. else { // ISO Code
  35. isoCodeRadioButton->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, flagRadioButton]() {
  43. prepareToSave(flagRadioButton);
  44. saveConfig();
  45. this->hide();
  46. delete this;
  47. });
  48. finalizeUI();
  49. setWindowGeometry();
  50. setTransparency(this);
  51. }
  52. void KbIndicatorDialog::prepareToSave(QRadioButton* flagRadioButton) {
  53. setEntry("useCountryFlag", flagRadioButton->isChecked());
  54. }
  55. KbIndicatorDialog::KbIndicatorDialog(QJsonObject* cfgObj) : Dialog(cfgObj,
  56. tr("Keyboard Layout applet settings"),
  57. "cs-keyboard") {
  58. }