Fix minor bugs in HTML info and cover selection
Additionally, the buttons of the cover selections can now be hidden.
This commit is contained in:
parent
b5f26228ff
commit
9b659f2c8f
|
@ -52,6 +52,11 @@ bool &noWebView()
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
bool &hideCoverButtons()
|
||||||
|
{
|
||||||
|
static bool v = false;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
// file browser
|
// file browser
|
||||||
bool &hideBackupFiles()
|
bool &hideBackupFiles()
|
||||||
|
@ -313,6 +318,7 @@ void restore()
|
||||||
fixUmlauts() = settings.value(QStringLiteral("fixumlauts"), false).toBool();
|
fixUmlauts() = settings.value(QStringLiteral("fixumlauts"), false).toBool();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
BackupHelper::backupDirectory() = settings.value(QStringLiteral("tempdir")).toString().toStdString();
|
BackupHelper::backupDirectory() = settings.value(QStringLiteral("tempdir")).toString().toStdString();
|
||||||
|
Settings::hideCoverButtons() = settings.value(QStringLiteral("hidecoverbtn"), false).toBool();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
selectedFieldsModel().restore(settings, QStringLiteral("selectedfields"));
|
selectedFieldsModel().restore(settings, QStringLiteral("selectedfields"));
|
||||||
|
@ -445,6 +451,7 @@ void save()
|
||||||
settings.setValue(QStringLiteral("fixumlauts"), Settings::fixUmlauts());
|
settings.setValue(QStringLiteral("fixumlauts"), Settings::fixUmlauts());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.setValue(QStringLiteral("tempdir"), QString::fromStdString(BackupHelper::backupDirectory()));
|
settings.setValue(QStringLiteral("tempdir"), QString::fromStdString(BackupHelper::backupDirectory()));
|
||||||
|
settings.setValue(QStringLiteral("hidecoverbtn"), Settings::hideCoverButtons());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
selectedFieldsModel().save(settings, QStringLiteral("selectedfields"));
|
selectedFieldsModel().save(settings, QStringLiteral("selectedfields"));
|
||||||
|
|
|
@ -46,6 +46,7 @@ bool &forceFullParse();
|
||||||
#ifndef TAGEDITOR_NO_WEBVIEW
|
#ifndef TAGEDITOR_NO_WEBVIEW
|
||||||
bool &noWebView();
|
bool &noWebView();
|
||||||
#endif
|
#endif
|
||||||
|
bool &hideCoverButtons();
|
||||||
|
|
||||||
// file browser
|
// file browser
|
||||||
bool &hideBackupFiles();
|
bool &hideBackupFiles();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="toBeShownLabel">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font-weight: bold;</string>
|
<string notr="true">font-weight: bold;</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -2,14 +2,6 @@
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>QtGui::EditorGeneralOptionPage</class>
|
<class>QtGui::EditorGeneralOptionPage</class>
|
||||||
<widget class="QWidget" name="QtGui::EditorGeneralOptionPage">
|
<widget class="QWidget" name="QtGui::EditorGeneralOptionPage">
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>468</width>
|
|
||||||
<height>374</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>General</string>
|
<string>General</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -106,6 +98,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="hideCoverButtonsCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Hide cover buttons</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -365,7 +365,7 @@ void FileInfoModel::updateCache()
|
||||||
trackHelper.appendRow(tr("Type"), track->mediaTypeName());
|
trackHelper.appendRow(tr("Type"), track->mediaTypeName());
|
||||||
const char *fmtName = track->formatName(), *fmtAbbr = track->formatAbbreviation();
|
const char *fmtName = track->formatName(), *fmtAbbr = track->formatAbbreviation();
|
||||||
trackHelper.appendRow(tr("Format"), fmtName);
|
trackHelper.appendRow(tr("Format"), fmtName);
|
||||||
if(strcmp(fmtName, fmtAbbr)) { // format name and abbreviation differ
|
if(track->format() != GeneralMediaFormat::Unknown && strcmp(fmtName, fmtAbbr)) { // format name and abbreviation differ
|
||||||
trackHelper.appendRow(tr("Abbreviation"), fmtAbbr);
|
trackHelper.appendRow(tr("Abbreviation"), fmtAbbr);
|
||||||
}
|
}
|
||||||
if(track->version()) {
|
if(track->version()) {
|
||||||
|
|
|
@ -26,9 +26,13 @@
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Media;
|
using namespace Media;
|
||||||
|
@ -50,11 +54,13 @@ PicturePreviewSelection::PicturePreviewSelection(Tag *tag, KnownField field, QWi
|
||||||
m_currentTypeIndex(0)
|
m_currentTypeIndex(0)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
m_ui->coverButtonsWidget->setHidden(Settings::hideCoverButtons());
|
||||||
connect(m_ui->addButton, &QPushButton::clicked, this, static_cast<void (PicturePreviewSelection::*)(void)>(&PicturePreviewSelection::addOfSelectedType));
|
connect(m_ui->addButton, &QPushButton::clicked, this, static_cast<void (PicturePreviewSelection::*)(void)>(&PicturePreviewSelection::addOfSelectedType));
|
||||||
connect(m_ui->removeButton, &QPushButton::clicked, this, &PicturePreviewSelection::removeSelected);
|
connect(m_ui->removeButton, &QPushButton::clicked, this, &PicturePreviewSelection::removeSelected);
|
||||||
connect(m_ui->extractButton, &QPushButton::clicked, this, &PicturePreviewSelection::extractSelected);
|
connect(m_ui->extractButton, &QPushButton::clicked, this, &PicturePreviewSelection::extractSelected);
|
||||||
connect(m_ui->displayButton, &QPushButton::clicked, this, &PicturePreviewSelection::displaySelected);
|
connect(m_ui->displayButton, &QPushButton::clicked, this, &PicturePreviewSelection::displaySelected);
|
||||||
connect(m_ui->restoreButton, &QPushButton::clicked, std::bind(&PicturePreviewSelection::setup, this, PreviousValueHandling::Clear));
|
connect(m_ui->restoreButton, &QPushButton::clicked, std::bind(&PicturePreviewSelection::setup, this, PreviousValueHandling::Clear));
|
||||||
|
connect(m_ui->previewGraphicsView, &QGraphicsView::customContextMenuRequested, this, &PicturePreviewSelection::showContextMenu);
|
||||||
setup();
|
setup();
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
@ -70,16 +76,15 @@ PicturePreviewSelection::~PicturePreviewSelection()
|
||||||
*/
|
*/
|
||||||
void PicturePreviewSelection::setValue(const TagValue &value, PreviousValueHandling previousValueHandling)
|
void PicturePreviewSelection::setValue(const TagValue &value, PreviousValueHandling previousValueHandling)
|
||||||
{
|
{
|
||||||
if(m_currentTypeIndex < static_cast<unsigned int>(m_values.count())) {
|
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||||
TagValue ¤tValue = m_values[m_currentTypeIndex];
|
TagValue ¤tValue = m_values[m_currentTypeIndex];
|
||||||
if(previousValueHandling == PreviousValueHandling::Clear || !value.isEmpty()) {
|
if(previousValueHandling == PreviousValueHandling::Clear || !value.isEmpty()) {
|
||||||
if(previousValueHandling != PreviousValueHandling::Keep || currentValue.isEmpty()) {
|
if(previousValueHandling != PreviousValueHandling::Keep || currentValue.isEmpty()) {
|
||||||
currentValue = value; // TODO: move(value);
|
currentValue = value; // TODO: move(value);
|
||||||
emit pictureChanged();
|
emit pictureChanged();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
updatePreview(m_currentTypeIndex);
|
|
||||||
}
|
}
|
||||||
|
updatePreview(m_currentTypeIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -164,7 +169,7 @@ void PicturePreviewSelection::setup(PreviousValueHandling previousValueHandling)
|
||||||
<< tr("Illustration")
|
<< tr("Illustration")
|
||||||
<< tr("Band/artist logotype")
|
<< tr("Band/artist logotype")
|
||||||
<< tr("Publisher/Studio logotype")
|
<< tr("Publisher/Studio logotype")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
int first;
|
int first;
|
||||||
switch(m_tag->type()) {
|
switch(m_tag->type()) {
|
||||||
|
@ -172,6 +177,7 @@ void PicturePreviewSelection::setup(PreviousValueHandling previousValueHandling)
|
||||||
first = fetchId3v2CoverValues(static_cast<Id3v2Tag *>(m_tag), m_field, m_values, m_ui->switchTypeComboBox->count(), previousValueHandling);
|
first = fetchId3v2CoverValues(static_cast<Id3v2Tag *>(m_tag), m_field, m_values, m_ui->switchTypeComboBox->count(), previousValueHandling);
|
||||||
break;
|
break;
|
||||||
case TagType::VorbisComment:
|
case TagType::VorbisComment:
|
||||||
|
case TagType::OggVorbisComment:
|
||||||
first = fetchId3v2CoverValues(static_cast<VorbisComment *>(m_tag), m_field, m_values, m_ui->switchTypeComboBox->count(), previousValueHandling);
|
first = fetchId3v2CoverValues(static_cast<VorbisComment *>(m_tag), m_field, m_values, m_ui->switchTypeComboBox->count(), previousValueHandling);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -224,9 +230,9 @@ template<class TagType>
|
||||||
void pushId3v2CoverValues(TagType *tag, KnownField field, const QList<Media::TagValue> &values)
|
void pushId3v2CoverValues(TagType *tag, KnownField field, const QList<Media::TagValue> &values)
|
||||||
{
|
{
|
||||||
auto &fields = tag->fields();
|
auto &fields = tag->fields();
|
||||||
auto id = tag->fieldId(field);
|
const auto id = tag->fieldId(field);
|
||||||
auto range = fields.equal_range(id);
|
const auto range = fields.equal_range(id);
|
||||||
auto first = range.first;
|
const auto first = range.first;
|
||||||
// iterate through all tag values
|
// iterate through all tag values
|
||||||
for(unsigned int index = 0, valueCount = values.size(); index < valueCount; ++index) {
|
for(unsigned int index = 0, valueCount = values.size(); index < valueCount; ++index) {
|
||||||
// check whether there is already a tag value with the current index/type
|
// check whether there is already a tag value with the current index/type
|
||||||
|
@ -236,11 +242,10 @@ void pushId3v2CoverValues(TagType *tag, KnownField field, const QList<Media::Tag
|
||||||
// -> update this value
|
// -> update this value
|
||||||
pair->second.setValue(values[index]);
|
pair->second.setValue(values[index]);
|
||||||
// check whether there are more values with the current index/type assigned
|
// check whether there are more values with the current index/type assigned
|
||||||
while((pair = find_if(++first, range.second, std::bind(fieldPredicate<TagType>, index, placeholders::_1))) != range.second) {
|
while((pair = find_if(++pair, range.second, std::bind(fieldPredicate<TagType>, index, placeholders::_1))) != range.second) {
|
||||||
// -> remove these values as we only support one value of a type in the same tag
|
// -> remove these values as we only support one value of a type in the same tag
|
||||||
pair->second.setValue(TagValue());
|
pair->second.setValue(TagValue());
|
||||||
}
|
}
|
||||||
first = range.first; // reset the first value
|
|
||||||
} else if(!values[index].isEmpty()) {
|
} else if(!values[index].isEmpty()) {
|
||||||
typename TagType::fieldType field(id, values[index]);
|
typename TagType::fieldType field(id, values[index]);
|
||||||
field.setTypeInfo(index);
|
field.setTypeInfo(index);
|
||||||
|
@ -293,13 +298,10 @@ void PicturePreviewSelection::clear()
|
||||||
*/
|
*/
|
||||||
void PicturePreviewSelection::addOfSelectedType()
|
void PicturePreviewSelection::addOfSelectedType()
|
||||||
{
|
{
|
||||||
if(m_currentTypeIndex < static_cast<unsigned int>(m_values.count())) {
|
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||||
QString path = QFileDialog::getOpenFileName(this, tr("Select a picture to add as cover"));
|
QString path = QFileDialog::getOpenFileName(this, tr("Select a picture to add as cover"));
|
||||||
if(!path.isEmpty()) {
|
if(!path.isEmpty()) {
|
||||||
addOfSelectedType(path);
|
addOfSelectedType(path);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw logic_error("Invalid type selected (no corresponding value assigned).");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,6 +310,7 @@ void PicturePreviewSelection::addOfSelectedType()
|
||||||
*/
|
*/
|
||||||
void PicturePreviewSelection::addOfSelectedType(const QString &path)
|
void PicturePreviewSelection::addOfSelectedType(const QString &path)
|
||||||
{
|
{
|
||||||
|
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||||
TagValue &selectedCover = m_values[m_currentTypeIndex];
|
TagValue &selectedCover = m_values[m_currentTypeIndex];
|
||||||
try {
|
try {
|
||||||
MediaFileInfo fileInfo(path.toLocal8Bit().constData());
|
MediaFileInfo fileInfo(path.toLocal8Bit().constData());
|
||||||
|
@ -340,7 +343,7 @@ void PicturePreviewSelection::addOfSelectedType(const QString &path)
|
||||||
*/
|
*/
|
||||||
void PicturePreviewSelection::removeSelected()
|
void PicturePreviewSelection::removeSelected()
|
||||||
{
|
{
|
||||||
if(m_currentTypeIndex < static_cast<unsigned int>(m_values.count())) {
|
if(m_currentTypeIndex < static_cast<unsigned int>(m_values.size())) {
|
||||||
if(m_values[m_currentTypeIndex].isEmpty()) {
|
if(m_values[m_currentTypeIndex].isEmpty()) {
|
||||||
QMessageBox::information(this, QApplication::applicationName(), tr("There is no cover to remove."));
|
QMessageBox::information(this, QApplication::applicationName(), tr("There is no cover to remove."));
|
||||||
} else {
|
} else {
|
||||||
|
@ -358,28 +361,25 @@ void PicturePreviewSelection::removeSelected()
|
||||||
*/
|
*/
|
||||||
void PicturePreviewSelection::extractSelected()
|
void PicturePreviewSelection::extractSelected()
|
||||||
{
|
{
|
||||||
if(m_currentTypeIndex < static_cast<unsigned int>(m_values.count())) {
|
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||||
TagValue &value = m_values[m_currentTypeIndex];
|
TagValue &value = m_values[m_currentTypeIndex];
|
||||||
if(value.isEmpty()) {
|
if(value.isEmpty()) {
|
||||||
QMessageBox::information(this, QApplication::applicationName(), tr("There is no image attached to be extracted."));
|
QMessageBox::information(this, QApplication::applicationName(), tr("There is no image attached to be extracted."));
|
||||||
} else {
|
} else {
|
||||||
const auto path = QFileDialog::getSaveFileName(this, tr("Where do you want to save the cover?"));
|
const auto path = QFileDialog::getSaveFileName(this, tr("Where do you want to save the cover?"));
|
||||||
if(!path.isEmpty()) {
|
if(!path.isEmpty()) {
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
if(file.open(QIODevice::WriteOnly)) {
|
if(file.open(QIODevice::WriteOnly)) {
|
||||||
if(file.write(value.dataPointer(), value.dataSize()) > 0) {
|
if(file.write(value.dataPointer(), value.dataSize()) > 0) {
|
||||||
QMessageBox::information(this, QApplication::applicationName(), tr("The cover has extracted."));
|
QMessageBox::information(this, QApplication::applicationName(), tr("The cover has extracted."));
|
||||||
} else {
|
|
||||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Unable to write to output file."));
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Unable to open output file."));
|
QMessageBox::warning(this, QApplication::applicationName(), tr("Unable to write to output file."));
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
QMessageBox::warning(this, QApplication::applicationName(), tr("Unable to open output file."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw logic_error("Invalid type selected (no corresponding value assigned).");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,46 +388,67 @@ void PicturePreviewSelection::extractSelected()
|
||||||
*/
|
*/
|
||||||
void PicturePreviewSelection::displaySelected()
|
void PicturePreviewSelection::displaySelected()
|
||||||
{
|
{
|
||||||
if(m_currentTypeIndex < static_cast<unsigned int>(m_values.count())) {
|
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||||
TagValue &value = m_values[m_currentTypeIndex];
|
TagValue &value = m_values[m_currentTypeIndex];
|
||||||
if(!value.isEmpty()) {
|
if(!value.isEmpty()) {
|
||||||
QImage img;
|
QImage img;
|
||||||
if(value.mimeType() == "-->") {
|
if(value.mimeType() == "-->") {
|
||||||
QFile file(Utility::stringToQString(value.toString(), value.dataEncoding()));
|
QFile file(Utility::stringToQString(value.toString(), value.dataEncoding()));
|
||||||
if(file.open(QFile::ReadOnly)) {
|
if(file.open(QFile::ReadOnly)) {
|
||||||
img = QImage::fromData(file.readAll());
|
img = QImage::fromData(file.readAll());
|
||||||
} else {
|
|
||||||
QMessageBox::warning(this, QApplication::applicationName(), tr("The attached image can't be found."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
img = QImage::fromData(reinterpret_cast<const uchar *>(value.dataPointer()), value.dataSize());
|
QMessageBox::warning(this, QApplication::applicationName(), tr("The attached image can't be found."));
|
||||||
}
|
return;
|
||||||
if(img.isNull()) {
|
|
||||||
QMessageBox::warning(this, QApplication::applicationName(), tr("The attached image can't be displayed."));
|
|
||||||
} else {
|
|
||||||
QDialog dlg;
|
|
||||||
dlg.setWindowFlags(Qt::Tool);
|
|
||||||
dlg.setWindowTitle(tr("Cover - %1").arg(QApplication::applicationName()));
|
|
||||||
QBoxLayout layout(QBoxLayout::Up);
|
|
||||||
layout.setMargin(0);
|
|
||||||
QGraphicsView view(&dlg);
|
|
||||||
QGraphicsScene scene;
|
|
||||||
layout.addWidget(&view);
|
|
||||||
scene.addItem(new QGraphicsPixmapItem(QPixmap::fromImage(img)));
|
|
||||||
view.setScene(&scene);
|
|
||||||
view.show();
|
|
||||||
dlg.setLayout(&layout);
|
|
||||||
dlg.exec();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QMessageBox::warning(this, QApplication::applicationName(), tr("There is no image attached."));
|
img = QImage::fromData(reinterpret_cast<const uchar *>(value.dataPointer()), value.dataSize());
|
||||||
|
}
|
||||||
|
if(img.isNull()) {
|
||||||
|
QMessageBox::warning(this, QApplication::applicationName(), tr("The attached image can't be displayed."));
|
||||||
|
} else {
|
||||||
|
QDialog dlg;
|
||||||
|
dlg.setWindowFlags(Qt::Tool);
|
||||||
|
dlg.setWindowTitle(tr("Cover - %1").arg(QApplication::applicationName()));
|
||||||
|
QBoxLayout layout(QBoxLayout::Up);
|
||||||
|
layout.setMargin(0);
|
||||||
|
QGraphicsView view(&dlg);
|
||||||
|
QGraphicsScene scene;
|
||||||
|
layout.addWidget(&view);
|
||||||
|
scene.addItem(new QGraphicsPixmapItem(QPixmap::fromImage(img)));
|
||||||
|
view.setScene(&scene);
|
||||||
|
view.show();
|
||||||
|
dlg.setLayout(&layout);
|
||||||
|
dlg.exec();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw logic_error("Invalid type selected (no corresponding value assigned).");
|
QMessageBox::warning(this, QApplication::applicationName(), tr("There is no image attached."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Asks the user to alter the MIME-type of the selected cover.
|
||||||
|
*/
|
||||||
|
void PicturePreviewSelection::changeMimeTypeOfSelected()
|
||||||
|
{
|
||||||
|
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||||
|
TagValue &selectedCover = m_values[m_currentTypeIndex];
|
||||||
|
auto mimeType = QString::fromLocal8Bit(selectedCover.mimeType().data());
|
||||||
|
bool ok;
|
||||||
|
mimeType = QInputDialog::getText(this, tr("Enter/confirm mime type"), tr("Confirm or enter the mime type of the selected file."), QLineEdit::Normal, mimeType, &ok);
|
||||||
|
if(ok) {
|
||||||
|
selectedCover.setMimeType(mimeType.toLocal8Bit().data());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets whether cover buttons are hidden.
|
||||||
|
*/
|
||||||
|
void PicturePreviewSelection::setCoverButtonsHidden(bool hideCoverButtons)
|
||||||
|
{
|
||||||
|
m_ui->coverButtonsWidget->setHidden(hideCoverButtons);
|
||||||
|
}
|
||||||
|
|
||||||
void PicturePreviewSelection::changeEvent(QEvent *event)
|
void PicturePreviewSelection::changeEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
switch(event->type()) {
|
switch(event->type()) {
|
||||||
|
@ -499,11 +520,9 @@ void PicturePreviewSelection::dropEvent(QDropEvent *event)
|
||||||
*/
|
*/
|
||||||
void PicturePreviewSelection::typeSwitched(int index)
|
void PicturePreviewSelection::typeSwitched(int index)
|
||||||
{
|
{
|
||||||
if(m_currentTypeIndex >= static_cast<unsigned int>(m_values.count())) {
|
assert(m_currentTypeIndex < static_cast<unsigned int>(m_values.size()));
|
||||||
throw logic_error("current type index is invalid");
|
|
||||||
}
|
|
||||||
int lastIndex = m_currentTypeIndex;
|
int lastIndex = m_currentTypeIndex;
|
||||||
if(index < 0 || index >= m_values.count()) {
|
if(index < 0 || index >= m_values.size()) {
|
||||||
throw logic_error("current type index is invalid");
|
throw logic_error("current type index is invalid");
|
||||||
} else {
|
} else {
|
||||||
m_currentTypeIndex = static_cast<unsigned int>(index);
|
m_currentTypeIndex = static_cast<unsigned int>(index);
|
||||||
|
@ -600,4 +619,40 @@ void PicturePreviewSelection::updatePreview(int index)
|
||||||
m_rectItem->setRect(0, 0, m_ui->previewGraphicsView->width(), m_ui->previewGraphicsView->height());
|
m_rectItem->setRect(0, 0, m_ui->previewGraphicsView->width(), m_ui->previewGraphicsView->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PicturePreviewSelection::showContextMenu()
|
||||||
|
{
|
||||||
|
QMenu menu;
|
||||||
|
QAction *addAction = menu.addAction(m_ui->addButton->text());
|
||||||
|
addAction->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
|
||||||
|
connect(addAction, &QAction::triggered, this, static_cast<void (PicturePreviewSelection::*)(void)>(&PicturePreviewSelection::addOfSelectedType));
|
||||||
|
if(m_ui->extractButton->isEnabled()) {
|
||||||
|
QAction *mimeAction = menu.addAction(tr("Change MIME-type"));
|
||||||
|
mimeAction->setIcon(QIcon::fromTheme(QStringLiteral("document-properties")));
|
||||||
|
connect(mimeAction, &QAction::triggered, this, &PicturePreviewSelection::changeMimeTypeOfSelected);
|
||||||
|
}
|
||||||
|
menu.addSeparator();
|
||||||
|
if(m_ui->removeButton->isEnabled()) {
|
||||||
|
QAction *removeAction = menu.addAction(m_ui->removeButton->text());
|
||||||
|
removeAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
|
||||||
|
connect(removeAction, &QAction::triggered, this, &PicturePreviewSelection::removeSelected);
|
||||||
|
}
|
||||||
|
if(m_ui->restoreButton->isEnabled()) {
|
||||||
|
QAction *restoreAction = menu.addAction(m_ui->restoreButton->text());
|
||||||
|
restoreAction->setIcon(QIcon::fromTheme(QStringLiteral("document-revert")));
|
||||||
|
connect(restoreAction, &QAction::triggered, std::bind(&PicturePreviewSelection::setup, this, PreviousValueHandling::Clear));
|
||||||
|
}
|
||||||
|
menu.addSeparator();
|
||||||
|
if(m_ui->extractButton->isEnabled()) {
|
||||||
|
QAction *extractAction = menu.addAction(m_ui->extractButton->text());
|
||||||
|
extractAction->setIcon(QIcon::fromTheme(QStringLiteral("document-save")));
|
||||||
|
connect(extractAction, &QAction::triggered, this, &PicturePreviewSelection::extractSelected);
|
||||||
|
}
|
||||||
|
if(m_ui->displayButton->isEnabled()) {
|
||||||
|
QAction *displayAction = menu.addAction(m_ui->displayButton->text());
|
||||||
|
displayAction->setIcon(QIcon::fromTheme(QStringLiteral("image-x-generic")));
|
||||||
|
connect(displayAction, &QAction::triggered, this, &PicturePreviewSelection::displaySelected);
|
||||||
|
}
|
||||||
|
menu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,8 @@ public slots:
|
||||||
void removeSelected();
|
void removeSelected();
|
||||||
void extractSelected();
|
void extractSelected();
|
||||||
void displaySelected();
|
void displaySelected();
|
||||||
|
void changeMimeTypeOfSelected();
|
||||||
|
void setCoverButtonsHidden(bool hideCoverButtons);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pictureChanged();
|
void pictureChanged();
|
||||||
|
@ -66,6 +68,7 @@ private slots:
|
||||||
void updateDescription(int newIndex);
|
void updateDescription(int newIndex);
|
||||||
void updateDescription(int lastIndex, int newIndex);
|
void updateDescription(int lastIndex, int newIndex);
|
||||||
void updatePreview(int index);
|
void updatePreview(int index);
|
||||||
|
void showContextMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setup(PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
|
void setup(PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>284</width>
|
<width>284</width>
|
||||||
<height>230</height>
|
<height>242</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -100,6 +100,9 @@
|
||||||
<height>170</height>
|
<height>170</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="verticalScrollBarPolicy">
|
<property name="verticalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -73,6 +73,7 @@ bool EditorGeneralOptionPage::apply()
|
||||||
saveAndShowNextOnEnter() = ui()->nextWhenPressingEnterCheckBox->isChecked();
|
saveAndShowNextOnEnter() = ui()->nextWhenPressingEnterCheckBox->isChecked();
|
||||||
askBeforeDeleting() = ui()->askBeforeDeletingCheckBox->isChecked();
|
askBeforeDeleting() = ui()->askBeforeDeletingCheckBox->isChecked();
|
||||||
hideTagSelectionComboBox() = ui()->hideTagSelectionComboBoxCheckBox->isChecked();
|
hideTagSelectionComboBox() = ui()->hideTagSelectionComboBoxCheckBox->isChecked();
|
||||||
|
hideCoverButtons() = ui()->hideCoverButtonsCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +103,7 @@ void EditorGeneralOptionPage::reset()
|
||||||
ui()->nextWhenPressingEnterCheckBox->setChecked(saveAndShowNextOnEnter());
|
ui()->nextWhenPressingEnterCheckBox->setChecked(saveAndShowNextOnEnter());
|
||||||
ui()->askBeforeDeletingCheckBox->setChecked(askBeforeDeleting());
|
ui()->askBeforeDeletingCheckBox->setChecked(askBeforeDeleting());
|
||||||
ui()->hideTagSelectionComboBoxCheckBox->setChecked(hideTagSelectionComboBox());
|
ui()->hideTagSelectionComboBoxCheckBox->setChecked(hideTagSelectionComboBox());
|
||||||
|
ui()->hideCoverButtonsCheckBox->setChecked(hideCoverButtons());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,16 @@ void TagEdit::invalidate()
|
||||||
setupUi();
|
setupUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets whether cover buttons are hidden.
|
||||||
|
*/
|
||||||
|
void TagEdit::setCoverButtonsHidden(bool hideCoverButtons)
|
||||||
|
{
|
||||||
|
for(auto i = m_widgets.begin(), end = m_widgets.end(); i != end; ++i) {
|
||||||
|
i.value()->setCoverButtonsHidden(hideCoverButtons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Internally called to setup the UI.
|
* \brief Internally called to setup the UI.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,6 +48,7 @@ public slots:
|
||||||
void restore();
|
void restore();
|
||||||
void apply();
|
void apply();
|
||||||
void invalidate();
|
void invalidate();
|
||||||
|
void setCoverButtonsHidden(bool hideCoverButtons);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void returnPressed();
|
void returnPressed();
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace std::placeholders;
|
||||||
using namespace Utility;
|
using namespace Utility;
|
||||||
using namespace Dialogs;
|
using namespace Dialogs;
|
||||||
using namespace Widgets;
|
using namespace Widgets;
|
||||||
|
@ -1223,6 +1224,7 @@ void TagEditorWidget::applySettingsFromDialog()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_ui->actionManage_tags_automatically_when_loading_file->setChecked(Settings::autoTagManagement());
|
m_ui->actionManage_tags_automatically_when_loading_file->setChecked(Settings::autoTagManagement());
|
||||||
|
foreachTagEdit(bind(&TagEdit::setCoverButtonsHidden, _1, Settings::hideCoverButtons()));
|
||||||
// ensure info view is displayed/not displayed according to settings
|
// ensure info view is displayed/not displayed according to settings
|
||||||
initInfoView();
|
initInfoView();
|
||||||
updateInfoView();
|
updateInfoView();
|
||||||
|
|
|
@ -212,6 +212,16 @@ bool TagFieldEdit::canApply(KnownField field) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets whether the cover buttons are hidden.
|
||||||
|
*/
|
||||||
|
void TagFieldEdit::setCoverButtonsHidden(bool hideCoverButtons)
|
||||||
|
{
|
||||||
|
if(m_pictureSelection) {
|
||||||
|
m_pictureSelection->setCoverButtonsHidden(hideCoverButtons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Internally called to determine the data type of the current tag field.
|
* \brief Internally called to determine the data type of the current tag field.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -53,6 +53,7 @@ public slots:
|
||||||
void clear();
|
void clear();
|
||||||
void apply();
|
void apply();
|
||||||
void restore();
|
void restore();
|
||||||
|
void setCoverButtonsHidden(bool hideCoverButtons);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void returnPressed();
|
void returnPressed();
|
||||||
|
|
|
@ -512,7 +512,7 @@ public:
|
||||||
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Type"), qstr(track->mediaTypeName()));
|
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Type"), qstr(track->mediaTypeName()));
|
||||||
const char *fmtName = track->formatName(), *fmtAbbr = track->formatAbbreviation();
|
const char *fmtName = track->formatName(), *fmtAbbr = track->formatAbbreviation();
|
||||||
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Format"), QCoreApplication::translate("HtmlInfo", "The unabbreviated name of the track's format."), qstr(fmtName));
|
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Format"), QCoreApplication::translate("HtmlInfo", "The unabbreviated name of the track's format."), qstr(fmtName));
|
||||||
if(strcmp(fmtName, fmtAbbr)) { // format name and abbreviation differ
|
if(track->format() != GeneralMediaFormat::Unknown && strcmp(fmtName, fmtAbbr)) { // format name and abbreviation differ
|
||||||
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Abbreviation"), QCoreApplication::translate("HtmlInfo", "The abbreviated name of the track's format."), qstr(fmtAbbr));
|
rowMaker.mkRow(QCoreApplication::translate("HtmlInfo", "Abbreviation"), QCoreApplication::translate("HtmlInfo", "The abbreviated name of the track's format."), qstr(fmtAbbr));
|
||||||
}
|
}
|
||||||
if(track->version()) {
|
if(track->version()) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue