| 22 | |
| 23 | |
| 24 | class FirstRunDialog : public QDialog { |
| 25 | private: |
| 26 | Ui::FirstRunDialog* firstRunDialog{}; |
| 27 | |
| 28 | // stores custom destination dir for AppImages |
| 29 | // if this is empty, the default value (defined in-code, might change over time) will be chosen |
| 30 | // the default will not be written to the config file, hence we need a way to detect that state, and it's assumed |
| 31 | // that when this string is empty, that's the case |
| 32 | // we could also just compare this directory with the default value just before saving, but IMO it's more obvious |
| 33 | // to the user that the "default" state is lost after having saved something with the "choose" button in a file |
| 34 | // dialog |
| 35 | QString destinationDir; |
| 36 | |
| 37 | private Q_SLOTS: |
| 38 | void resetDefaults() { |
| 39 | firstRunDialog->askMoveCheckBox->setChecked(true); |
| 40 | |
| 41 | destinationDir = ""; |
| 42 | updateDestinationDirLabel(); |
| 43 | } |
| 44 | |
| 45 | void handleButtonClicked(QAbstractButton* button) { |
| 46 | if (button == firstRunDialog->buttonBox->button(QDialogButtonBox::RestoreDefaults)) { |
| 47 | qDebug() << "restore defaults"; |
| 48 | resetDefaults(); |
| 49 | } else if (button == firstRunDialog->buttonBox->button(QDialogButtonBox::Help)) { |
| 50 | qDebug() << "help"; |
| 51 | QDesktopServices::openUrl(QUrl("https://github.com/TheAssassin/AppImageLauncher/wiki/First-run")); |
| 52 | |
| 53 | } else { |
| 54 | qDebug() << "unknown button clicked" << button; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | void handleAskMoveCheckBoxStateChange(int state) { |
| 59 | qDebug() << "new ask move check box state" << state; |
| 60 | |
| 61 | // this alone unfortunately doesn't do the trick... |
| 62 | for (auto* layout : { |
| 63 | static_cast<QLayout*>(firstRunDialog->destDirVertLayout), |
| 64 | static_cast<QLayout*>(firstRunDialog->destDirHorLayout), |
| 65 | }) { |
| 66 | layout->setEnabled(state > 0); |
| 67 | } |
| 68 | |
| 69 | // have to also manually enable/disable all the |
| 70 | for (auto* label : { |
| 71 | static_cast<QWidget*>(firstRunDialog->destinationDirDescLabel), |
| 72 | static_cast<QWidget*>(firstRunDialog->destinationDirLabel), |
| 73 | static_cast<QWidget*>(firstRunDialog->customizeIntegrationDirButton), |
| 74 | }) { |
| 75 | label->setEnabled(state > 0); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | void handleCustomizeIntegrationDirButtonClicked(bool checked = false) { |
| 80 | (void) checked; |
| 81 |
nothing calls this directly
no outgoing calls
no test coverage detected