added file layout settings
This commit is contained in:
parent
e5e804da1c
commit
c4fb8eb60e
|
@ -107,6 +107,37 @@ bool &mergeMultipleSuccessiveId3v2Tags()
|
|||
return v;
|
||||
}
|
||||
|
||||
// file layout
|
||||
TagPosition &preferredTagPosition()
|
||||
{
|
||||
static TagPosition v = TagPosition::BeforeData;
|
||||
return v;
|
||||
}
|
||||
|
||||
bool &forceTagPosition()
|
||||
{
|
||||
static bool v = true;
|
||||
return v;
|
||||
}
|
||||
|
||||
size_t &minPadding()
|
||||
{
|
||||
static size_t v = 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
size_t &maxPadding()
|
||||
{
|
||||
static size_t v = 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
size_t &preferredPadding()
|
||||
{
|
||||
static size_t v = 0;
|
||||
return v;
|
||||
}
|
||||
|
||||
// fields
|
||||
KnownFieldModel &selectedFieldsModel()
|
||||
{
|
||||
|
@ -263,6 +294,20 @@ void restore()
|
|||
keepVersionOfExistingId3v2Tag() = settings.value(QStringLiteral("keepversionofexistingtag"), true).toBool();
|
||||
mergeMultipleSuccessiveId3v2Tags() = settings.value(QStringLiteral("mergemultiplesuccessivetags"), true).toBool();
|
||||
settings.endGroup();
|
||||
settings.beginGroup(QStringLiteral("filelayout"));
|
||||
switch(settings.value(QStringLiteral("tagpos")).toInt()) {
|
||||
case 0:
|
||||
preferredTagPosition() = TagPosition::BeforeData;
|
||||
break;
|
||||
case 1:
|
||||
preferredTagPosition() = TagPosition::AfterData;
|
||||
break;
|
||||
}
|
||||
forceTagPosition() = settings.value(QStringLiteral("forcetagpos"), true).toBool();
|
||||
minPadding() = settings.value(QStringLiteral("minpad"), 0).toInt();
|
||||
maxPadding() = settings.value(QStringLiteral("maxpad"), 0).toInt();
|
||||
preferredPadding() = settings.value(QStringLiteral("prefpad"), 0).toInt();
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("mainwindow"));
|
||||
|
@ -317,6 +362,13 @@ void save()
|
|||
settings.setValue(QStringLiteral("keepversionofexistingtag"), keepVersionOfExistingId3v2Tag());
|
||||
settings.setValue(QStringLiteral("mergemultiplesuccessivetags"), mergeMultipleSuccessiveId3v2Tags());
|
||||
settings.endGroup();
|
||||
settings.beginGroup(QStringLiteral("filelayout"));
|
||||
settings.setValue(QStringLiteral("tagpos"), static_cast<int>(preferredTagPosition()));
|
||||
settings.setValue(QStringLiteral("forcetagpos"), forceTagPosition());
|
||||
settings.setValue(QStringLiteral("minpad"), QVariant::fromValue(minPadding()));
|
||||
settings.setValue(QStringLiteral("maxpad"), QVariant::fromValue(maxPadding()));
|
||||
settings.setValue(QStringLiteral("prefpad"), QVariant::fromValue(preferredPadding()));
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QStringLiteral("mainwindow"));
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
|
||||
#include <QtGlobal>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QByteArray;
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
QT_FORWARD_DECLARE_CLASS(QByteArray)
|
||||
QT_FORWARD_DECLARE_CLASS(QString)
|
||||
|
||||
namespace Media {
|
||||
enum class TagUsage;
|
||||
enum class TagPosition;
|
||||
}
|
||||
|
||||
namespace Settings {
|
||||
|
@ -66,6 +65,13 @@ uint32 &id3v2versionToBeUsed();
|
|||
bool &keepVersionOfExistingId3v2Tag();
|
||||
bool &mergeMultipleSuccessiveId3v2Tags();
|
||||
|
||||
// file layout
|
||||
Media::TagPosition &preferredTagPosition();
|
||||
bool &forceTagPosition();
|
||||
size_t &minPadding();
|
||||
size_t &maxPadding();
|
||||
size_t &preferredPadding();
|
||||
|
||||
// fields
|
||||
class KnownFieldModel;
|
||||
KnownFieldModel &selectedFieldsModel();
|
||||
|
|
|
@ -0,0 +1,191 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QtGui::FileLayoutPage</class>
|
||||
<widget class="QWidget" name="QtGui::FileLayoutPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>325</width>
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QGroupBox { font-weight: bold };</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="paddingGroupBox">
|
||||
<property name="title">
|
||||
<string>Padding</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="minPaddingLabel">
|
||||
<property name="text">
|
||||
<string>minimum padding</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="minPaddingSpinBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> byte</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="maxPaddingLabel">
|
||||
<property name="text">
|
||||
<string>maximum padding</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="maxPaddingSpinBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> byte</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>429496729</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="preferredPaddingLabel">
|
||||
<property name="text">
|
||||
<string>preferred padding</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="preferredPaddingSpinBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> byte</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>429496729</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="tagPositionGroupBox">
|
||||
<property name="title">
|
||||
<string>Preferred tag position</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="beforeDataRadioButton">
|
||||
<property name="text">
|
||||
<string>befo&re (media) data / at the beginning of the file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="afterDataRadioButton">
|
||||
<property name="text">
|
||||
<string>after (&media) data / at the end of the file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="forcePositionCheckBox">
|
||||
<property name="text">
|
||||
<string>Use preferred position event if putting the tags at
|
||||
another position would prevent rewriting the entire file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="NotificationLabel" name="preferredTagPosLabel" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>NotificationLabel</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/notificationlabel.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -636,7 +636,7 @@ void MainWindow::updateInfoWebView()
|
|||
{
|
||||
if(m_fileInfo.isOpen()) {
|
||||
m_fileInfoHtml = HtmlInfo::generateInfo(m_fileInfo, m_originalNotifications);
|
||||
m_infoWebView->setHtml(m_fileInfoHtml);
|
||||
m_infoWebView->setContent(m_fileInfoHtml, QStringLiteral("application/xhtml+xml"));
|
||||
} else {
|
||||
m_infoWebView->setUrl(QStringLiteral("about:blank"));
|
||||
}
|
||||
|
@ -987,11 +987,18 @@ bool MainWindow::startSaving()
|
|||
// tags might get invalidated
|
||||
m_tags.clear();
|
||||
foreachTagEdit([] (TagEdit *edit) { edit->setTag(nullptr, false); });
|
||||
// show abort button
|
||||
m_ui->abortButton->setHidden(false);
|
||||
m_ui->abortButton->setEnabled(true);
|
||||
m_abortClicked = false;
|
||||
// remove current path from file watcher
|
||||
m_fileWatcher->removePath(m_currentPath);
|
||||
// use current configuration
|
||||
m_fileInfo.setTagPosition(Settings::preferredTagPosition());
|
||||
m_fileInfo.setForceTagPosition(Settings::forceTagPosition());
|
||||
m_fileInfo.setMinPadding(Settings::minPadding());
|
||||
m_fileInfo.setMaxPadding(Settings::maxPadding());
|
||||
m_fileInfo.setPreferredPadding(Settings::preferredPadding());
|
||||
// define functions to show the saving progress and to actually applying the changes
|
||||
auto showProgress = [this] (StatusProvider &sender) -> void {
|
||||
QMetaObject::invokeMethod(m_ui->makingNotificationWidget, "setPercentage", Qt::QueuedConnection, Q_ARG(int, static_cast<int>(sender.currentPercentage() * 100.0)));
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <functional>
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
using namespace Settings;
|
||||
using namespace Media;
|
||||
|
||||
|
@ -138,7 +142,7 @@ void EditorTempOptionPage::reset()
|
|||
|
||||
QWidget *EditorTempOptionPage::setupWidget()
|
||||
{
|
||||
QWidget *widget = UiFileBasedOptionPage<Ui::EditorTempOptionPage>::setupWidget();
|
||||
auto *widget = UiFileBasedOptionPage<Ui::EditorTempOptionPage>::setupWidget();
|
||||
QObject::connect(ui()->selectPushButton, &QPushButton::clicked, std::bind(&EditorTempOptionPage::showDirectorySelection, this));
|
||||
return widget;
|
||||
}
|
||||
|
@ -185,7 +189,7 @@ void EditorFieldsOptionPage::reset()
|
|||
|
||||
QWidget *EditorFieldsOptionPage::setupWidget()
|
||||
{
|
||||
QWidget *w = UiFileBasedOptionPage<Ui::EditorFieldsOptionPage>::setupWidget();
|
||||
auto *w = UiFileBasedOptionPage<Ui::EditorFieldsOptionPage>::setupWidget();
|
||||
if(!m_model) {
|
||||
m_model = new KnownFieldModel(w);
|
||||
}
|
||||
|
@ -203,7 +207,7 @@ EditorAutoCorrectionOptionPage::~EditorAutoCorrectionOptionPage()
|
|||
|
||||
QString EditorAutoCorrectionOptionPage::displayName() const
|
||||
{
|
||||
return QApplication::translate("QtGui::EditorAutoCorrectionOptionPage", "Auto correction/completition");
|
||||
return QApplication::translate("QtGui::EditorAutoCorrectionOptionPage", "Auto correction/completion");
|
||||
}
|
||||
|
||||
bool EditorAutoCorrectionOptionPage::apply()
|
||||
|
@ -235,7 +239,7 @@ void EditorAutoCorrectionOptionPage::reset()
|
|||
|
||||
QWidget *EditorAutoCorrectionOptionPage::setupWidget()
|
||||
{
|
||||
QWidget *w = UiFileBasedOptionPage<Ui::EditorAutoCorrectionOptionPage>::setupWidget();
|
||||
auto *w = UiFileBasedOptionPage<Ui::EditorAutoCorrectionOptionPage>::setupWidget();
|
||||
if(!m_model) {
|
||||
m_model = new KnownFieldModel(w);
|
||||
}
|
||||
|
@ -451,6 +455,67 @@ void Id3v2OptionPage::reset()
|
|||
}
|
||||
}
|
||||
|
||||
// FileLayoutPage
|
||||
FileLayoutPage::FileLayoutPage()
|
||||
{}
|
||||
|
||||
FileLayoutPage::~FileLayoutPage()
|
||||
{}
|
||||
|
||||
QString FileLayoutPage::displayName() const
|
||||
{
|
||||
return QApplication::translate("QtGui::FileLayoutPage", "File layout");
|
||||
}
|
||||
|
||||
bool FileLayoutPage::apply()
|
||||
{
|
||||
if(hasBeenShown()) {
|
||||
if(ui()->minPaddingSpinBox->value() > ui()->maxPaddingSpinBox->value()) {
|
||||
return false;
|
||||
}
|
||||
Settings::maxPadding() = static_cast<size_t>(ui()->maxPaddingSpinBox->value());
|
||||
Settings::minPadding() = static_cast<size_t>(ui()->minPaddingSpinBox->value());
|
||||
Settings::preferredPadding() = static_cast<size_t>(ui()->preferredPaddingSpinBox->value());
|
||||
if(ui()->beforeDataRadioButton->isChecked()) {
|
||||
preferredTagPosition() = TagPosition::BeforeData;
|
||||
} else if(ui()->afterDataRadioButton->isChecked()) {
|
||||
preferredTagPosition() = TagPosition::AfterData;
|
||||
}
|
||||
forceTagPosition() = ui()->forcePositionCheckBox->isChecked();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileLayoutPage::reset()
|
||||
{
|
||||
if(hasBeenShown()) {
|
||||
ui()->maxPaddingSpinBox->setValue(static_cast<int>(Settings::maxPadding()));
|
||||
ui()->minPaddingSpinBox->setValue(static_cast<int>(Settings::minPadding()));
|
||||
ui()->preferredPaddingSpinBox->setValue(static_cast<int>(Settings::preferredPadding()));
|
||||
switch(preferredTagPosition()) {
|
||||
case TagPosition::BeforeData:
|
||||
ui()->beforeDataRadioButton->setChecked(true);
|
||||
break;
|
||||
case TagPosition::AfterData:
|
||||
ui()->afterDataRadioButton->setChecked(true);
|
||||
break;
|
||||
}
|
||||
ui()->forcePositionCheckBox->setChecked(forceTagPosition());
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *FileLayoutPage::setupWidget()
|
||||
{
|
||||
auto *widget = Dialogs::UiFileBasedOptionPage<Ui::FileLayoutPage>::setupWidget();
|
||||
ui()->preferredTagPosLabel->setNotificationType(NotificationType::Warning);
|
||||
ui()->preferredTagPosLabel->setText(QApplication::translate("QtGui::FileLayoutPage", "These options might be ignored if not supported by either the format or the implementation."));
|
||||
QObject::connect(ui()->minPaddingSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui()->maxPaddingSpinBox, &QSpinBox::setMinimum);
|
||||
QObject::connect(ui()->minPaddingSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui()->preferredPaddingSpinBox, &QSpinBox::setMinimum);
|
||||
QObject::connect(ui()->maxPaddingSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui()->minPaddingSpinBox, &QSpinBox::setMaximum);
|
||||
QObject::connect(ui()->maxPaddingSpinBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), ui()->preferredPaddingSpinBox, &QSpinBox::setMaximum);
|
||||
return widget;
|
||||
}
|
||||
|
||||
/*
|
||||
TRANSLATOR QtGui::SettingsDialog
|
||||
Necessary for lupdate.
|
||||
|
@ -467,7 +532,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
|
|||
category->setDisplayName(tr("Tag processing"));
|
||||
category->assignPages(QList<Dialogs::OptionPage *>()
|
||||
<< new TagProcessingGeneralOptionPage <<
|
||||
new Id3v1OptionPage << new Id3v2OptionPage);
|
||||
new Id3v1OptionPage << new Id3v2OptionPage << new FileLayoutPage);
|
||||
category->setIcon(QIcon(QStringLiteral(":/tageditor/icons/hicolor/32x32/settingscategories/tag.png")));
|
||||
categories << category;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "gui/ui_tagprocessinggeneraloptionpage.h"
|
||||
#include "gui/ui_id3v1optionpage.h"
|
||||
#include "gui/ui_id3v2optionpage.h"
|
||||
#include "gui/ui_filelayout.h"
|
||||
|
||||
#include <qtutilities/settingsdialog/settingsdialog.h>
|
||||
#include <qtutilities/settingsdialog/optionpage.h>
|
||||
|
@ -179,6 +180,25 @@ public:
|
|||
void reset();
|
||||
};
|
||||
|
||||
// FileLayoutPage
|
||||
namespace Ui {
|
||||
class FileLayoutPage;
|
||||
}
|
||||
|
||||
class FileLayoutPage : public Dialogs::UiFileBasedOptionPage<Ui::FileLayoutPage>
|
||||
{
|
||||
public:
|
||||
explicit FileLayoutPage();
|
||||
~FileLayoutPage();
|
||||
|
||||
QString displayName() const;
|
||||
bool apply();
|
||||
void reset();
|
||||
|
||||
private:
|
||||
QWidget *setupWidget();
|
||||
};
|
||||
|
||||
class SettingsDialog : public Dialogs::SettingsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
Loading…
Reference in New Issue