1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/*
* Cantata
*
* Copyright (c) 2011-2022 Craig Drummond <craig.p.drummond@gmail.com>
*
* ----
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "lyricsdialog.h"
#include "support/icon.h"
#include <QFormLayout>
#include <QLabel>
#include <QStyle>
LyricsDialog::LyricsDialog(const Song& s, QWidget* parent)
: Dialog(parent), prev(s)
{
QWidget* mw = new QWidget(this);
QGridLayout* mainLayout = new QGridLayout(mw);
QWidget* wid = new QWidget(mw);
QFormLayout* layout = new QFormLayout(wid);
int row = 0;
QLabel* lbl = new QLabel(tr("If Cantata has failed to find lyrics, or has found the wrong ones, "
"use this dialog to enter new search details. For example, the current "
"song may actually be a cover-version - if so, then searching for "
"lyrics by the original artist might help.\n\nIf this search does find "
"new lyrics, these will still be associated with the original song title "
"and artist as displayed in Cantata."),
mw);
lbl->setWordWrap(true);
QLabel* icn = new QLabel(mw);
icn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
int iconSize = Icon::dlgIconSize();
icn->setFixedSize(iconSize, iconSize);
icn->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(iconSize, iconSize));
mainLayout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(icn, 0, 0, 1, 1);
mainLayout->addWidget(lbl, 0, 1, 1, 1);
mainLayout->addItem(new QSpacerItem(8, 4, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
mainLayout->addWidget(wid, 2, 0, 1, 2);
titleEntry = new LineEdit(wid);
artistEntry = new LineEdit(wid);
layout->setWidget(row, QFormLayout::LabelRole, new QLabel(tr("Title:"), wid));
layout->setWidget(row++, QFormLayout::FieldRole, titleEntry);
layout->setWidget(row, QFormLayout::LabelRole, new QLabel(tr("Artist:"), wid));
layout->setWidget(row++, QFormLayout::FieldRole, artistEntry);
setCaption(tr("Search For Lyrics"));
setMainWidget(mw);
setButtons(Ok | Cancel);
enableButton(Ok, false);
connect(titleEntry, SIGNAL(textChanged(const QString&)), SLOT(changed()));
connect(artistEntry, SIGNAL(textChanged(const QString&)), SLOT(changed()));
titleEntry->setFocus();
titleEntry->setText(s.title);
artistEntry->setText(s.artist);
}
Song LyricsDialog::song() const
{
Song s = prev;
s.artist = artistEntry->text().trimmed();
s.title = titleEntry->text().trimmed();
return s;
}
void LyricsDialog::changed()
{
Song s = song();
enableButton(Ok, !s.artist.isEmpty() && !s.title.isEmpty() && (s.artist != prev.artist || s.title != prev.title));
}
#include "moc_lyricsdialog.cpp"
|