| 10 | #include <QVBoxLayout> |
| 11 | |
| 12 | ApiKeyDialog::ApiKeyDialog(QWidget *parent) |
| 13 | : QDialog(parent) |
| 14 | { |
| 15 | auto layout = new QVBoxLayout; |
| 16 | auto buttonsLayout = new QHBoxLayout; |
| 17 | |
| 18 | settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); // TODO unificar la creación del fichero de config con el servidor |
| 19 | settings->beginGroup("ComicVine"); |
| 20 | |
| 21 | QLabel *info = new QLabel(tr("Before you can connect to Comic Vine, you need your own API key. Please, get one free <a href=\"http://www.comicvine.com/api/\">here</a>")); |
| 22 | info->setWordWrap(true); |
| 23 | info->setOpenExternalLinks(true); |
| 24 | edit = new QLineEdit(); |
| 25 | edit->setPlaceholderText(tr("Paste here your Comic Vine API key")); |
| 26 | connect(edit, &QLineEdit::textChanged, this, &ApiKeyDialog::enableAccept); |
| 27 | |
| 28 | acceptButton = new QPushButton(tr("Accept")); |
| 29 | acceptButton->setDisabled(true); |
| 30 | connect(acceptButton, &QAbstractButton::clicked, this, &ApiKeyDialog::saveApiKey); |
| 31 | |
| 32 | cancelButton = new QPushButton(tr("Cancel")); |
| 33 | connect(cancelButton, &QAbstractButton::clicked, this, &QDialog::reject); |
| 34 | |
| 35 | layout->addWidget(info); |
| 36 | layout->addWidget(edit); |
| 37 | layout->addStretch(); |
| 38 | |
| 39 | buttonsLayout->addStretch(); |
| 40 | buttonsLayout->addWidget(acceptButton); |
| 41 | buttonsLayout->addWidget(cancelButton); |
| 42 | |
| 43 | layout->addLayout(buttonsLayout); |
| 44 | |
| 45 | setLayout(layout); |
| 46 | |
| 47 | resize(400, 150); |
| 48 | |
| 49 | if (settings->contains(COMIC_VINE_API_KEY)) |
| 50 | edit->setText(settings->value(COMIC_VINE_API_KEY).toString()); |
| 51 | } |
| 52 | |
| 53 | ApiKeyDialog::~ApiKeyDialog() |
| 54 | { |
nothing calls this directly
no test coverage detected