edit document title via GUI
This commit is contained in:
parent
a163c0a4db
commit
b105b86d29
|
@ -951,14 +951,14 @@ void setTagInfo(const StringVector ¶meterValues, const SetTagInfoArgs &args)
|
||||||
auto container = fileInfo.container();
|
auto container = fileInfo.container();
|
||||||
bool docTitleModified = false;
|
bool docTitleModified = false;
|
||||||
if(!args.docTitleArg.values().empty()) {
|
if(!args.docTitleArg.values().empty()) {
|
||||||
if(container) {
|
if(container && container->supportsTitle()) {
|
||||||
size_t segmentIndex = 0, segmentCount = container->titles().size();
|
size_t segmentIndex = 0, segmentCount = container->titles().size();
|
||||||
for(const auto &newTitle : args.docTitleArg.values()) {
|
for(const auto &newTitle : args.docTitleArg.values()) {
|
||||||
if(segmentIndex < segmentCount) {
|
if(segmentIndex < segmentCount) {
|
||||||
container->setTitle(newTitle, segmentIndex);
|
container->setTitle(newTitle, segmentIndex);
|
||||||
docTitleModified = true;
|
docTitleModified = true;
|
||||||
} else {
|
} else {
|
||||||
cout << "Warning: The specified document title \"" << newTitle << "\" can not be set because the file has not that many segments or document titles are not supported." << endl;
|
cout << "Warning: The specified document title \"" << newTitle << "\" can not be set because the file has not that many segments." << endl;
|
||||||
}
|
}
|
||||||
++segmentIndex;
|
++segmentIndex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#include <tagparser/tag.h>
|
#include <tagparser/tag.h>
|
||||||
#include <tagparser/id3/id3v1tag.h>
|
#include <tagparser/id3/id3v1tag.h>
|
||||||
#include <tagparser/id3/id3v2tag.h>
|
#include <tagparser/id3/id3v2tag.h>
|
||||||
|
#include <tagparser/mp4/mp4container.h>
|
||||||
#include <tagparser/mp4/mp4tag.h>
|
#include <tagparser/mp4/mp4tag.h>
|
||||||
#include <tagparser/matroska/matroskatag.h>
|
#include <tagparser/matroska/matroskatag.h>
|
||||||
#include <tagparser/mp4/mp4container.h>
|
|
||||||
|
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
#include <c++utilities/io/path.h>
|
#include <c++utilities/io/path.h>
|
||||||
|
@ -60,6 +60,7 @@ using namespace std;
|
||||||
using namespace Utility;
|
using namespace Utility;
|
||||||
using namespace Media;
|
using namespace Media;
|
||||||
using namespace Dialogs;
|
using namespace Dialogs;
|
||||||
|
using namespace Widgets;
|
||||||
|
|
||||||
namespace QtGui {
|
namespace QtGui {
|
||||||
|
|
||||||
|
@ -346,6 +347,44 @@ void MainWindow::saveAndShowNextFile()
|
||||||
applyEntriesAndSaveChangings();
|
applyEntriesAndSaveChangings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Updates the line edits for the document title(s).
|
||||||
|
*/
|
||||||
|
void MainWindow::updateDocumentTitleEdits()
|
||||||
|
{
|
||||||
|
// get container, segment count and present titles
|
||||||
|
AbstractContainer *container = m_fileInfo.container();
|
||||||
|
int segmentCount = container ? static_cast<int>(container->segmentCount()) : 0;
|
||||||
|
const vector<string> &titles = container ? container->titles() : vector<string>();
|
||||||
|
|
||||||
|
// get layout
|
||||||
|
QLayout *docTitleLayout = m_ui->docTitleWidget->layout();
|
||||||
|
int lineEditCount = docTitleLayout->count() - 1;
|
||||||
|
|
||||||
|
// update existing line edits, remove unneeded line edits
|
||||||
|
int i = 0;
|
||||||
|
for(; i < lineEditCount; ++i) {
|
||||||
|
if(i < segmentCount) {
|
||||||
|
// update existing line edit
|
||||||
|
static_cast<ClearLineEdit *>(docTitleLayout->itemAt(i + 1)->widget())
|
||||||
|
->setText(static_cast<size_t>(i) < titles.size() ? QString::fromUtf8(titles[i].data()) : QString());
|
||||||
|
} else {
|
||||||
|
// remove unneeded line edit
|
||||||
|
docTitleLayout->removeItem(docTitleLayout->itemAt(i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add missing line edits
|
||||||
|
while(i < segmentCount) {
|
||||||
|
auto *lineEdit = new Widgets::ClearLineEdit;
|
||||||
|
if(static_cast<size_t>(i) < titles.size()) {
|
||||||
|
lineEdit->setText(QString::fromUtf8(titles[i].data()));
|
||||||
|
}
|
||||||
|
lineEdit->setPlaceholderText(tr("Segment %1").arg(++i));
|
||||||
|
docTitleLayout->addWidget(lineEdit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Update the tag edits and the tag selection to show the specified \a tags.
|
* \brief Update the tag edits and the tag selection to show the specified \a tags.
|
||||||
* \param tags Specifies the tags to be shown.
|
* \param tags Specifies the tags to be shown.
|
||||||
|
@ -504,6 +543,8 @@ void MainWindow::updateUiStatus()
|
||||||
// notification widgets
|
// notification widgets
|
||||||
m_ui->parsingNotificationWidget->setVisible(opened);
|
m_ui->parsingNotificationWidget->setVisible(opened);
|
||||||
m_ui->makingNotificationWidget->setVisible(opened && (m_makingResultsAvailable));
|
m_ui->makingNotificationWidget->setVisible(opened && (m_makingResultsAvailable));
|
||||||
|
// document title widget
|
||||||
|
m_ui->docTitleWidget->setVisible(opened && m_fileInfo.container() && m_fileInfo.container()->supportsTitle());
|
||||||
// buttons and actions to save, delete, close
|
// buttons and actions to save, delete, close
|
||||||
m_ui->saveButton->setEnabled(opened);
|
m_ui->saveButton->setEnabled(opened);
|
||||||
m_ui->deleteTagsButton->setEnabled(hasTag);
|
m_ui->deleteTagsButton->setEnabled(hasTag);
|
||||||
|
@ -860,6 +901,7 @@ void MainWindow::showFile(char result)
|
||||||
m_fileWatcher->addPath(m_currentPath);
|
m_fileWatcher->addPath(m_currentPath);
|
||||||
m_fileChangedOnDisk = false;
|
m_fileChangedOnDisk = false;
|
||||||
// update related widgets
|
// update related widgets
|
||||||
|
updateDocumentTitleEdits();
|
||||||
updateTagEditsAndAttachmentEdits();
|
updateTagEditsAndAttachmentEdits();
|
||||||
updateTagSelectionComboBox();
|
updateTagSelectionComboBox();
|
||||||
updateTagManagementMenu();
|
updateTagManagementMenu();
|
||||||
|
@ -889,6 +931,15 @@ bool MainWindow::applyEntriesAndSaveChangings()
|
||||||
m_ui->makingNotificationWidget->setHidden(false);
|
m_ui->makingNotificationWidget->setHidden(false);
|
||||||
m_makingResultsAvailable = true;
|
m_makingResultsAvailable = true;
|
||||||
if(m_fileInfo.isOpen()) {
|
if(m_fileInfo.isOpen()) {
|
||||||
|
// apply titles
|
||||||
|
if(AbstractContainer *container = m_fileInfo.container()) {
|
||||||
|
if(container->supportsTitle()) {
|
||||||
|
QLayout *docTitleLayout = m_ui->docTitleWidget->layout();
|
||||||
|
for(int i = 0, count = min<int>(docTitleLayout->count() - 1, container->segmentCount()); i < count; ++i) {
|
||||||
|
container->setTitle(static_cast<ClearLineEdit *>(docTitleLayout->itemAt(i + 1)->widget())->text().toUtf8().data(), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// apply all tags
|
// apply all tags
|
||||||
foreachTagEdit([] (TagEdit *edit) {edit->apply();});
|
foreachTagEdit([] (TagEdit *edit) {edit->apply();});
|
||||||
static const QString statusMsg(tr("Saving tags ..."));
|
static const QString statusMsg(tr("Saving tags ..."));
|
||||||
|
|
|
@ -104,6 +104,7 @@ private slots:
|
||||||
void spawnExternalPlayer();
|
void spawnExternalPlayer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateDocumentTitleEdits();
|
||||||
void updateTagEditsAndAttachmentEdits(bool updateUi = true, PreviousValueHandling previousValueHandling = PreviousValueHandling::Auto);
|
void updateTagEditsAndAttachmentEdits(bool updateUi = true, PreviousValueHandling previousValueHandling = PreviousValueHandling::Auto);
|
||||||
void updateTagSelectionComboBox();
|
void updateTagSelectionComboBox();
|
||||||
void updateUiStatus();
|
void updateUiStatus();
|
||||||
|
|
|
@ -105,6 +105,31 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="NotificationLabel" name="parsingNotificationWidget" native="true"/>
|
<widget class="NotificationLabel" name="parsingNotificationWidget" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="docTitleWidget" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<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="QLabel" name="docTitleLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Document title</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSplitter" name="tagSplitter">
|
<widget class="QSplitter" name="tagSplitter">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -169,8 +194,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="document-revert">
|
<iconset theme="document-revert">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -190,8 +214,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="edit-clear">
|
<iconset theme="edit-clear">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -238,8 +261,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="process-stop">
|
<iconset theme="process-stop">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -319,7 +341,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1225</width>
|
<width>1225</width>
|
||||||
<height>27</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
@ -370,8 +392,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="document-save">
|
<iconset theme="document-save">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save &entered tags</string>
|
<string>Save &entered tags</string>
|
||||||
|
@ -386,8 +407,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="edit-delete">
|
<iconset theme="edit-delete">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Delete all tags</string>
|
<string>&Delete all tags</string>
|
||||||
|
@ -402,8 +422,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="document-revert">
|
<iconset theme="document-revert">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Close</string>
|
<string>&Close</string>
|
||||||
|
@ -415,8 +434,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<action name="actionSelect_next_file">
|
<action name="actionSelect_next_file">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="go-next">
|
<iconset theme="go-next">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Select next file</string>
|
<string>&Select next file</string>
|
||||||
|
@ -436,8 +454,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="document-open">
|
<iconset theme="document-open">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Open</string>
|
<string>&Open</string>
|
||||||
|
@ -452,8 +469,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="edit-copy">
|
<iconset theme="edit-copy">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Save file information as HTML document</string>
|
<string>&Save file information as HTML document</string>
|
||||||
|
@ -465,8 +481,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<action name="actionSelect_next_file_and_save_current">
|
<action name="actionSelect_next_file_and_save_current">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="go-next">
|
<iconset theme="go-next">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Select &next file and save current</string>
|
<string>Select &next file and save current</string>
|
||||||
|
@ -478,8 +493,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<action name="actionAbout">
|
<action name="actionAbout">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="help-about">
|
<iconset theme="help-about">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&About</string>
|
<string>&About</string>
|
||||||
|
@ -488,8 +502,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<action name="actionQuit">
|
<action name="actionQuit">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="application-exit">
|
<iconset theme="application-exit">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Quit</string>
|
<string>&Quit</string>
|
||||||
|
@ -498,8 +511,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<action name="actionSettings">
|
<action name="actionSettings">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="preferences-other">
|
<iconset theme="preferences-other">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Settings</string>
|
<string>&Settings</string>
|
||||||
|
@ -546,8 +558,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="document-revert">
|
<iconset theme="document-revert">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Reload (reverts all changes!)</string>
|
<string>&Reload (reverts all changes!)</string>
|
||||||
|
@ -562,8 +573,7 @@ the file reverting all unsaved changings.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="media-playback-start">
|
<iconset theme="media-playback-start">
|
||||||
<normaloff/>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</iconset>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Play (external player)</string>
|
<string>&Play (external player)</string>
|
||||||
|
|
Loading…
Reference in New Issue