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();
|
||||
bool docTitleModified = false;
|
||||
if(!args.docTitleArg.values().empty()) {
|
||||
if(container) {
|
||||
if(container && container->supportsTitle()) {
|
||||
size_t segmentIndex = 0, segmentCount = container->titles().size();
|
||||
for(const auto &newTitle : args.docTitleArg.values()) {
|
||||
if(segmentIndex < segmentCount) {
|
||||
container->setTitle(newTitle, segmentIndex);
|
||||
docTitleModified = true;
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#include <tagparser/tag.h>
|
||||
#include <tagparser/id3/id3v1tag.h>
|
||||
#include <tagparser/id3/id3v2tag.h>
|
||||
#include <tagparser/mp4/mp4container.h>
|
||||
#include <tagparser/mp4/mp4tag.h>
|
||||
#include <tagparser/matroska/matroskatag.h>
|
||||
#include <tagparser/mp4/mp4container.h>
|
||||
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/io/path.h>
|
||||
|
@ -60,6 +60,7 @@ using namespace std;
|
|||
using namespace Utility;
|
||||
using namespace Media;
|
||||
using namespace Dialogs;
|
||||
using namespace Widgets;
|
||||
|
||||
namespace QtGui {
|
||||
|
||||
|
@ -346,6 +347,44 @@ void MainWindow::saveAndShowNextFile()
|
|||
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.
|
||||
* \param tags Specifies the tags to be shown.
|
||||
|
@ -504,6 +543,8 @@ void MainWindow::updateUiStatus()
|
|||
// notification widgets
|
||||
m_ui->parsingNotificationWidget->setVisible(opened);
|
||||
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
|
||||
m_ui->saveButton->setEnabled(opened);
|
||||
m_ui->deleteTagsButton->setEnabled(hasTag);
|
||||
|
@ -860,6 +901,7 @@ void MainWindow::showFile(char result)
|
|||
m_fileWatcher->addPath(m_currentPath);
|
||||
m_fileChangedOnDisk = false;
|
||||
// update related widgets
|
||||
updateDocumentTitleEdits();
|
||||
updateTagEditsAndAttachmentEdits();
|
||||
updateTagSelectionComboBox();
|
||||
updateTagManagementMenu();
|
||||
|
@ -889,6 +931,15 @@ bool MainWindow::applyEntriesAndSaveChangings()
|
|||
m_ui->makingNotificationWidget->setHidden(false);
|
||||
m_makingResultsAvailable = true;
|
||||
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
|
||||
foreachTagEdit([] (TagEdit *edit) {edit->apply();});
|
||||
static const QString statusMsg(tr("Saving tags ..."));
|
||||
|
|
|
@ -104,6 +104,7 @@ private slots:
|
|||
void spawnExternalPlayer();
|
||||
|
||||
private:
|
||||
void updateDocumentTitleEdits();
|
||||
void updateTagEditsAndAttachmentEdits(bool updateUi = true, PreviousValueHandling previousValueHandling = PreviousValueHandling::Auto);
|
||||
void updateTagSelectionComboBox();
|
||||
void updateUiStatus();
|
||||
|
|
|
@ -105,6 +105,31 @@
|
|||
<item>
|
||||
<widget class="NotificationLabel" name="parsingNotificationWidget" native="true"/>
|
||||
</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>
|
||||
<widget class="QSplitter" name="tagSplitter">
|
||||
<property name="orientation">
|
||||
|
@ -169,8 +194,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-revert">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -190,8 +214,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -238,8 +261,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="process-stop">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -319,7 +341,7 @@ the file reverting all unsaved changings.</string>
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1225</width>
|
||||
<height>27</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -370,8 +392,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save &entered tags</string>
|
||||
|
@ -386,8 +407,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Delete all tags</string>
|
||||
|
@ -402,8 +422,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-revert">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
|
@ -415,8 +434,7 @@ the file reverting all unsaved changings.</string>
|
|||
<action name="actionSelect_next_file">
|
||||
<property name="icon">
|
||||
<iconset theme="go-next">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Select next file</string>
|
||||
|
@ -436,8 +454,7 @@ the file reverting all unsaved changings.</string>
|
|||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Open</string>
|
||||
|
@ -452,8 +469,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-copy">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<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">
|
||||
<property name="icon">
|
||||
<iconset theme="go-next">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select &next file and save current</string>
|
||||
|
@ -478,8 +493,7 @@ the file reverting all unsaved changings.</string>
|
|||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&About</string>
|
||||
|
@ -488,8 +502,7 @@ the file reverting all unsaved changings.</string>
|
|||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="application-exit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
|
@ -498,8 +511,7 @@ the file reverting all unsaved changings.</string>
|
|||
<action name="actionSettings">
|
||||
<property name="icon">
|
||||
<iconset theme="preferences-other">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Settings</string>
|
||||
|
@ -546,8 +558,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-revert">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Reload (reverts all changes!)</string>
|
||||
|
@ -562,8 +573,7 @@ the file reverting all unsaved changings.</string>
|
|||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="media-playback-start">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Play (external player)</string>
|
||||
|
|
Loading…
Reference in New Issue