2015-09-06 20:20:00 +02:00
# include "./settingsdialog.h"
# include "./notificationlabel.h"
2015-04-22 19:33:53 +02:00
2015-09-06 20:20:00 +02:00
# include "../application/settings.h"
# include "../application/knownfieldmodel.h"
2016-05-26 02:15:41 +02:00
# include "../application/targetlevelmodel.h"
2015-04-22 19:33:53 +02:00
# include <tagparser/mediafileinfo.h>
# include <tagparser/backuphelper.h>
# include <qtutilities/settingsdialog/optioncategory.h>
# include <qtutilities/settingsdialog/optioncategorymodel.h>
2016-07-27 18:31:42 +02:00
# include <qtutilities/settingsdialog/qtsettings.h>
2015-04-22 19:33:53 +02:00
# include <QFileDialog>
2015-11-21 01:13:45 +01:00
# include <functional>
using namespace std ;
using namespace std : : placeholders ;
2015-04-22 19:33:53 +02:00
using namespace Settings ;
using namespace Media ;
namespace QtGui {
// FileBrowserGeneralOptionPage
2016-04-04 14:51:14 +02:00
FileBrowserGeneralOptionPage : : FileBrowserGeneralOptionPage ( QWidget * parentWidget ) :
FileBrowserGeneralOptionPageBase ( parentWidget )
2015-04-22 19:33:53 +02:00
{ }
FileBrowserGeneralOptionPage : : ~ FileBrowserGeneralOptionPage ( )
{ }
bool FileBrowserGeneralOptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
hideBackupFiles ( ) = ui ( ) - > hideBackupFilesCheckBox - > isChecked ( ) ;
fileBrowserReadOnly ( ) = ui ( ) - > readOnlyCheckBox - > isChecked ( ) ;
}
return true ;
}
void FileBrowserGeneralOptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
ui ( ) - > hideBackupFilesCheckBox - > setChecked ( hideBackupFiles ( ) ) ;
ui ( ) - > readOnlyCheckBox - > setChecked ( fileBrowserReadOnly ( ) ) ;
}
}
// EditorGeneralOptionPage
2016-04-04 14:51:14 +02:00
EditorGeneralOptionPage : : EditorGeneralOptionPage ( QWidget * parentWidget ) :
EditorGeneralOptionPageBase ( parentWidget )
2015-04-22 19:33:53 +02:00
{ }
EditorGeneralOptionPage : : ~ EditorGeneralOptionPage ( )
{ }
bool EditorGeneralOptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
if ( ui ( ) - > disableAdoptRadioButton - > isChecked ( ) ) {
adoptFields ( ) = AdoptFields : : Never ;
} else if ( ui ( ) - > enableWithinDirRadioButton - > isChecked ( ) ) {
adoptFields ( ) = AdoptFields : : WithinDirectory ;
} else if ( ui ( ) - > enableForAllRadioButton - > isChecked ( ) ) {
adoptFields ( ) = AdoptFields : : Always ;
}
if ( ui ( ) - > multipleTagsOneEditorRadioButton - > isChecked ( ) ) {
multipleTagHandling ( ) = MultipleTagHandling : : SingleEditorPerTarget ;
} else if ( ui ( ) - > multipleTagsSeparateEditorsRadioButton - > isChecked ( ) ) {
multipleTagHandling ( ) = MultipleTagHandling : : SeparateEditors ;
}
saveAndShowNextOnEnter ( ) = ui ( ) - > nextWhenPressingEnterCheckBox - > isChecked ( ) ;
askBeforeDeleting ( ) = ui ( ) - > askBeforeDeletingCheckBox - > isChecked ( ) ;
hideTagSelectionComboBox ( ) = ui ( ) - > hideTagSelectionComboBoxCheckBox - > isChecked ( ) ;
2016-05-16 21:01:01 +02:00
hideCoverButtons ( ) = ui ( ) - > hideCoverButtonsCheckBox - > isChecked ( ) ;
2015-04-22 19:33:53 +02:00
}
return true ;
}
void EditorGeneralOptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
switch ( adoptFields ( ) ) {
case AdoptFields : : Never :
ui ( ) - > disableAdoptRadioButton - > setChecked ( true ) ;
break ;
case AdoptFields : : WithinDirectory :
ui ( ) - > enableWithinDirRadioButton - > setChecked ( true ) ;
break ;
case AdoptFields : : Always :
ui ( ) - > enableForAllRadioButton - > setChecked ( true ) ;
break ;
}
switch ( multipleTagHandling ( ) ) {
case MultipleTagHandling : : SingleEditorPerTarget :
ui ( ) - > multipleTagsOneEditorRadioButton - > setChecked ( true ) ;
break ;
case MultipleTagHandling : : SeparateEditors :
ui ( ) - > multipleTagsSeparateEditorsRadioButton - > setChecked ( true ) ;
break ;
}
ui ( ) - > nextWhenPressingEnterCheckBox - > setChecked ( saveAndShowNextOnEnter ( ) ) ;
ui ( ) - > askBeforeDeletingCheckBox - > setChecked ( askBeforeDeleting ( ) ) ;
ui ( ) - > hideTagSelectionComboBoxCheckBox - > setChecked ( hideTagSelectionComboBox ( ) ) ;
2016-05-16 21:01:01 +02:00
ui ( ) - > hideCoverButtonsCheckBox - > setChecked ( hideCoverButtons ( ) ) ;
2015-04-22 19:33:53 +02:00
}
}
// EditorTempOptionPage
EditorTempOptionPage : : EditorTempOptionPage ( QWidget * parentWindow ) :
2016-04-04 14:51:14 +02:00
EditorTempOptionPageBase ( parentWindow )
2015-04-22 19:33:53 +02:00
{ }
EditorTempOptionPage : : ~ EditorTempOptionPage ( )
{ }
bool EditorTempOptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
2016-05-01 20:07:04 +02:00
BackupHelper : : backupDirectory ( ) = ui ( ) - > directoryWidget - > lineEdit ( ) - > text ( ) . toStdString ( ) ;
2015-04-22 19:33:53 +02:00
}
return true ;
}
void EditorTempOptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
2016-05-01 20:07:04 +02:00
ui ( ) - > directoryWidget - > lineEdit ( ) - > setText ( QString : : fromStdString ( BackupHelper : : backupDirectory ( ) ) ) ;
2015-04-22 19:33:53 +02:00
}
}
QWidget * EditorTempOptionPage : : setupWidget ( )
{
2016-04-04 14:51:14 +02:00
auto * widget = EditorTempOptionPageBase : : setupWidget ( ) ;
2016-05-01 20:07:04 +02:00
ui ( ) - > notificationLabel - > setText ( QCoreApplication : : translate ( " QtGui::EditorTempOptionPage " , " To avoid unnecessary copying this directory should be on the same partition as the files you want to edit. " ) ) ;
2016-03-22 23:01:50 +01:00
ui ( ) - > notificationLabel - > setNotificationType ( NotificationType : : Information ) ;
2015-04-22 19:33:53 +02:00
return widget ;
}
// EditorFieldsOptionPage
2016-04-04 14:51:14 +02:00
EditorFieldsOptionPage : : EditorFieldsOptionPage ( QWidget * parentWidget ) :
2016-05-26 02:15:41 +02:00
EditorFieldsOptionPageBase ( parentWidget ) ,
2015-04-22 19:33:53 +02:00
m_model ( nullptr )
{ }
EditorFieldsOptionPage : : ~ EditorFieldsOptionPage ( )
{ }
bool EditorFieldsOptionPage : : apply ( )
{
if ( hasBeenShown ( ) & & m_model ) {
Settings : : selectedFieldsModel ( ) . setItems ( m_model - > items ( ) ) ;
}
return true ;
}
void EditorFieldsOptionPage : : reset ( )
{
if ( hasBeenShown ( ) & & m_model ) {
m_model - > setItems ( Settings : : selectedFieldsModel ( ) . items ( ) ) ;
}
}
QWidget * EditorFieldsOptionPage : : setupWidget ( )
{
2016-04-04 14:51:14 +02:00
auto * w = EditorFieldsOptionPageBase : : setupWidget ( ) ;
2015-04-22 19:33:53 +02:00
if ( ! m_model ) {
m_model = new KnownFieldModel ( w ) ;
}
ui ( ) - > fieldsListView - > setModel ( m_model ) ;
return w ;
}
// EditorAutoCorrectionOptionPage
2016-04-04 14:51:14 +02:00
EditorAutoCorrectionOptionPage : : EditorAutoCorrectionOptionPage ( QWidget * parentWidget ) :
EditorAutoCorrectionOptionPageBase ( parentWidget ) ,
2015-04-22 19:33:53 +02:00
m_model ( nullptr )
{ }
EditorAutoCorrectionOptionPage : : ~ EditorAutoCorrectionOptionPage ( )
{ }
bool EditorAutoCorrectionOptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
Settings : : insertTitleFromFilename ( ) = ui ( ) - > insertTitleFromFilenameCheckBox - > isChecked ( ) ;
Settings : : trimWhitespaces ( ) = ui ( ) - > trimWhitespacesCheckBox - > isChecked ( ) ;
Settings : : formatNames ( ) = ui ( ) - > formatNamesCheckBox - > isChecked ( ) ;
Settings : : fixUmlauts ( ) = ui ( ) - > fixUmlautsCheckBox - > isChecked ( ) ;
if ( m_model ) {
Settings : : autoCorrectionFields ( ) . setItems ( m_model - > items ( ) ) ;
}
}
return true ;
}
void EditorAutoCorrectionOptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
ui ( ) - > insertTitleFromFilenameCheckBox - > setChecked ( Settings : : insertTitleFromFilename ( ) ) ;
ui ( ) - > trimWhitespacesCheckBox - > setChecked ( Settings : : trimWhitespaces ( ) ) ;
ui ( ) - > formatNamesCheckBox - > setChecked ( Settings : : formatNames ( ) ) ;
ui ( ) - > fixUmlautsCheckBox - > setChecked ( Settings : : fixUmlauts ( ) ) ;
if ( m_model ) {
m_model - > setItems ( Settings : : autoCorrectionFields ( ) . items ( ) ) ;
}
}
}
QWidget * EditorAutoCorrectionOptionPage : : setupWidget ( )
{
2016-04-04 14:51:14 +02:00
auto * w = EditorAutoCorrectionOptionPageBase : : setupWidget ( ) ;
2015-04-22 19:33:53 +02:00
if ( ! m_model ) {
m_model = new KnownFieldModel ( w ) ;
}
ui ( ) - > fieldsListView - > setModel ( m_model ) ;
return w ;
}
2016-03-05 16:50:23 +01:00
// EditorDbQueryOptionsPage
2016-04-04 14:51:14 +02:00
EditorDbQueryOptionsPage : : EditorDbQueryOptionsPage ( QWidget * parentWidget ) :
EditorDbQueryOptionsPageBase ( parentWidget )
2016-03-05 16:50:23 +01:00
{ }
EditorDbQueryOptionsPage : : ~ EditorDbQueryOptionsPage ( )
{ }
bool EditorDbQueryOptionsPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
Settings : : musicBrainzUrl ( ) = ui ( ) - > musicBrainzUrlLineEdit - > text ( ) ;
2016-03-06 17:52:33 +01:00
Settings : : coverArtArchiveUrl ( ) = ui ( ) - > coverArtArchiveUrlLineEdit - > text ( ) ;
2016-03-05 16:50:23 +01:00
}
return true ;
}
void EditorDbQueryOptionsPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
ui ( ) - > musicBrainzUrlLineEdit - > setText ( Settings : : musicBrainzUrl ( ) ) ;
2016-03-06 17:52:33 +01:00
ui ( ) - > coverArtArchiveUrlLineEdit - > setText ( Settings : : coverArtArchiveUrl ( ) ) ;
2016-03-05 16:50:23 +01:00
}
}
2015-04-22 19:33:53 +02:00
// InfoOptionPage
2016-04-04 14:51:14 +02:00
InfoOptionPage : : InfoOptionPage ( QWidget * parentWidget ) :
InfoOptionPageBase ( parentWidget )
2015-04-22 19:33:53 +02:00
{ }
InfoOptionPage : : ~ InfoOptionPage ( )
{ }
bool InfoOptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
Settings : : forceFullParse ( ) = ui ( ) - > forceFullParseCheckBox - > isChecked ( ) ;
2016-04-21 23:55:22 +02:00
# ifndef TAGEDITOR_NO_WEBVIEW
Settings : : noWebView ( ) = ui ( ) - > noWebViewCheckBox - > isChecked ( ) ;
# endif
2015-04-22 19:33:53 +02:00
}
return true ;
}
void InfoOptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
ui ( ) - > forceFullParseCheckBox - > setChecked ( Settings : : forceFullParse ( ) ) ;
2016-04-21 23:55:22 +02:00
# ifdef TAGEDITOR_NO_WEBVIEW
ui ( ) - > noWebViewCheckBox - > setChecked ( true ) ;
ui ( ) - > noWebViewCheckBox - > setEnabled ( false ) ;
# else
ui ( ) - > noWebViewCheckBox - > setChecked ( Settings : : noWebView ( ) ) ;
# endif
2015-04-22 19:33:53 +02:00
}
}
// TagProcessingGeneralOptionPage
2016-04-04 14:51:14 +02:00
TagProcessingGeneralOptionPage : : TagProcessingGeneralOptionPage ( QWidget * parentWidget ) :
TagProcessingGeneralOptionPageBase ( parentWidget )
2015-04-22 19:33:53 +02:00
{ }
TagProcessingGeneralOptionPage : : ~ TagProcessingGeneralOptionPage ( )
{ }
bool TagProcessingGeneralOptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
if ( ui ( ) - > latin1RadioButton - > isChecked ( ) ) {
preferredEncoding ( ) = TagTextEncoding : : Latin1 ;
} else if ( ui ( ) - > utf8RadioButton - > isChecked ( ) ) {
preferredEncoding ( ) = TagTextEncoding : : Utf8 ;
} else if ( ui ( ) - > utf16leRadioButton - > isChecked ( ) ) {
preferredEncoding ( ) = TagTextEncoding : : Utf16LittleEndian ;
} else if ( ui ( ) - > utf16beRadioButton - > isChecked ( ) ) {
preferredEncoding ( ) = TagTextEncoding : : Utf16BigEndian ;
} else if ( ui ( ) - > autoRadioButton - > isChecked ( ) ) {
preferredEncoding ( ) = TagTextEncoding : : Unspecified ;
}
if ( ui ( ) - > ignoreUnsupportedRadioButton - > isChecked ( ) ) {
unsupportedFieldHandling ( ) = UnsupportedFieldHandling : : Ignore ;
} else if ( ui ( ) - > discardUnsupportedRadioButton - > isChecked ( ) ) {
unsupportedFieldHandling ( ) = UnsupportedFieldHandling : : Discard ;
}
autoTagManagement ( ) = ui ( ) - > autoTagManagementCheckBox - > isChecked ( ) ;
}
return true ;
}
void TagProcessingGeneralOptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
switch ( preferredEncoding ( ) ) {
case TagTextEncoding : : Latin1 :
ui ( ) - > latin1RadioButton - > setChecked ( true ) ;
break ;
case TagTextEncoding : : Utf8 :
ui ( ) - > utf8RadioButton - > setChecked ( true ) ;
break ;
case TagTextEncoding : : Utf16LittleEndian :
ui ( ) - > utf16leRadioButton - > setChecked ( true ) ;
break ;
case TagTextEncoding : : Utf16BigEndian :
ui ( ) - > utf16beRadioButton - > setChecked ( true ) ;
break ;
case TagTextEncoding : : Unspecified :
ui ( ) - > autoRadioButton - > setChecked ( true ) ;
break ;
}
switch ( unsupportedFieldHandling ( ) ) {
case UnsupportedFieldHandling : : Ignore :
ui ( ) - > ignoreUnsupportedRadioButton - > setChecked ( true ) ;
break ;
case UnsupportedFieldHandling : : Discard :
ui ( ) - > discardUnsupportedRadioButton - > setChecked ( true ) ;
break ;
}
ui ( ) - > autoTagManagementCheckBox - > setChecked ( autoTagManagement ( ) ) ;
}
}
// Id3v1OptionPage
2016-04-04 14:51:14 +02:00
Id3v1OptionPage : : Id3v1OptionPage ( QWidget * parentWidget ) :
Id3v1OptionPageBase ( parentWidget )
2015-04-22 19:33:53 +02:00
{ }
Id3v1OptionPage : : ~ Id3v1OptionPage ( )
{ }
bool Id3v1OptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
if ( ui ( ) - > alwaysCreateRadioButton - > isChecked ( ) ) {
id3v1usage ( ) = TagUsage : : Always ;
} else if ( ui ( ) - > keepExistingRadioButton - > isChecked ( ) ) {
id3v1usage ( ) = TagUsage : : KeepExisting ;
} else if ( ui ( ) - > removeExistingRadioButton - > isChecked ( ) ) {
id3v1usage ( ) = TagUsage : : Never ;
}
}
return true ;
}
void Id3v1OptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
switch ( id3v1usage ( ) ) {
case TagUsage : : Always :
ui ( ) - > alwaysCreateRadioButton - > setChecked ( true ) ;
break ;
case TagUsage : : KeepExisting :
ui ( ) - > keepExistingRadioButton - > setChecked ( true ) ;
break ;
case TagUsage : : Never :
ui ( ) - > removeExistingRadioButton - > setChecked ( true ) ;
break ;
}
}
}
// Id3v2OptionPage
2016-04-04 14:51:14 +02:00
Id3v2OptionPage : : Id3v2OptionPage ( QWidget * parentWidget ) :
Id3v2OptionPageBase ( parentWidget )
2015-04-22 19:33:53 +02:00
{ }
Id3v2OptionPage : : ~ Id3v2OptionPage ( )
{ }
bool Id3v2OptionPage : : apply ( )
{
if ( hasBeenShown ( ) ) {
if ( ui ( ) - > alwaysCreateRadioButton - > isChecked ( ) ) {
id3v2usage ( ) = TagUsage : : Always ;
} else if ( ui ( ) - > keepExistingRadioButton - > isChecked ( ) ) {
id3v2usage ( ) = TagUsage : : KeepExisting ;
} else if ( ui ( ) - > removeExistingRadioButton - > isChecked ( ) ) {
id3v2usage ( ) = TagUsage : : Never ;
}
if ( ui ( ) - > version230radioButton - > isChecked ( ) ) {
id3v2versionToBeUsed ( ) = 3 ;
} else if ( ui ( ) - > version240radioButton - > isChecked ( ) ) {
id3v2versionToBeUsed ( ) = 4 ;
} else if ( ui ( ) - > version220radioButton - > isChecked ( ) ) {
id3v2versionToBeUsed ( ) = 2 ;
}
keepVersionOfExistingId3v2Tag ( ) = ui ( ) - > keepExistingVersionCheckBox - > isChecked ( ) ;
mergeMultipleSuccessiveId3v2Tags ( ) = ui ( ) - > mergeRadioButton - > isChecked ( ) ;
}
return true ;
}
void Id3v2OptionPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
switch ( id3v2usage ( ) ) {
case TagUsage : : Always :
ui ( ) - > alwaysCreateRadioButton - > setChecked ( true ) ;
break ;
case TagUsage : : KeepExisting :
ui ( ) - > keepExistingRadioButton - > setChecked ( true ) ;
break ;
case TagUsage : : Never :
ui ( ) - > removeExistingRadioButton - > setChecked ( true ) ;
break ;
}
switch ( id3v2versionToBeUsed ( ) ) {
case 3 :
ui ( ) - > version230radioButton - > setChecked ( true ) ;
break ;
case 4 :
ui ( ) - > version240radioButton - > setChecked ( true ) ;
break ;
case 2 :
ui ( ) - > version220radioButton - > setChecked ( true ) ;
break ;
}
ui ( ) - > keepExistingVersionCheckBox - > setChecked ( keepVersionOfExistingId3v2Tag ( ) ) ;
if ( mergeMultipleSuccessiveId3v2Tags ( ) ) {
ui ( ) - > mergeRadioButton - > setChecked ( true ) ;
} else {
ui ( ) - > keepSeparateRadioButton - > setChecked ( true ) ;
}
}
}
2016-05-26 02:15:41 +02:00
// TagProcessingTargetsOptionPage
TagProcessingTargetsOptionPage : : TagProcessingTargetsOptionPage ( QWidget * parentWidget ) :
TagProcessingTargetsOptionPageBase ( parentWidget ) ,
m_model ( nullptr )
{ }
TagProcessingTargetsOptionPage : : ~ TagProcessingTargetsOptionPage ( )
{ }
bool TagProcessingTargetsOptionPage : : apply ( )
{
if ( hasBeenShown ( ) & & m_model ) {
Settings : : defaultTargetsModel ( ) . setItems ( m_model - > items ( ) ) ;
}
return true ;
}
void TagProcessingTargetsOptionPage : : reset ( )
{
if ( hasBeenShown ( ) & & m_model ) {
m_model - > setItems ( Settings : : defaultTargetsModel ( ) . items ( ) ) ;
}
}
QWidget * TagProcessingTargetsOptionPage : : setupWidget ( )
{
auto * w = TagProcessingTargetsOptionPageBase : : setupWidget ( ) ;
if ( ! m_model ) {
m_model = new TargetLevelModel ( w ) ;
}
ui ( ) - > targetsToBeAddedListView - > setModel ( m_model ) ;
return w ;
}
2015-11-21 01:13:45 +01:00
// FileLayoutPage
2016-04-04 14:51:14 +02:00
FileLayoutPage : : FileLayoutPage ( QWidget * parentWidget ) :
FileLayoutPageBase ( parentWidget )
2015-11-21 01:13:45 +01:00
{ }
FileLayoutPage : : ~ FileLayoutPage ( )
{ }
bool FileLayoutPage : : apply ( )
{
2016-04-04 14:51:14 +02:00
// error handling
errors ( ) . clear ( ) ;
bool ok = true ;
2015-11-21 01:13:45 +01:00
if ( hasBeenShown ( ) ) {
2015-11-26 19:25:59 +01:00
Settings : : forceRewrite ( ) = ui ( ) - > forceRewriteCheckBox - > isChecked ( ) ;
2015-11-21 01:13:45 +01:00
if ( ui ( ) - > minPaddingSpinBox - > value ( ) > ui ( ) - > maxPaddingSpinBox - > value ( ) ) {
2016-04-04 14:51:14 +02:00
errors ( ) < < QCoreApplication : : translate ( " QtGui::FileLayoutPage " , " Minimum padding must be less or equal than maximum padding. " ) ;
ok = false ;
} else {
Settings : : maxPadding ( ) = static_cast < size_t > ( ui ( ) - > maxPaddingSpinBox - > value ( ) ) ;
Settings : : minPadding ( ) = static_cast < size_t > ( ui ( ) - > minPaddingSpinBox - > value ( ) ) ;
2015-11-21 01:13:45 +01:00
}
Settings : : preferredPadding ( ) = static_cast < size_t > ( ui ( ) - > preferredPaddingSpinBox - > value ( ) ) ;
2015-11-26 19:25:59 +01:00
if ( ui ( ) - > tagPosBeforeDataRadioButton - > isChecked ( ) ) {
preferredTagPosition ( ) = ElementPosition : : BeforeData ;
} else if ( ui ( ) - > tagPosAfterDataRadioButton - > isChecked ( ) ) {
preferredTagPosition ( ) = ElementPosition : : AfterData ;
} else if ( ui ( ) - > tagPosKeepRadioButton - > isChecked ( ) ) {
preferredTagPosition ( ) = ElementPosition : : Keep ;
2015-11-21 01:13:45 +01:00
}
2015-11-26 19:25:59 +01:00
forceTagPosition ( ) = ui ( ) - > tagPosForceCheckBox - > isChecked ( ) ;
if ( ui ( ) - > indexPosBeforeDataRadioButton - > isChecked ( ) ) {
preferredIndexPosition ( ) = ElementPosition : : BeforeData ;
} else if ( ui ( ) - > indexPosAfterDataRadioButton - > isChecked ( ) ) {
preferredIndexPosition ( ) = ElementPosition : : AfterData ;
} else if ( ui ( ) - > indexPosKeepRadioButton - > isChecked ( ) ) {
preferredIndexPosition ( ) = ElementPosition : : Keep ;
}
forceIndexPosition ( ) = ui ( ) - > indexPosForceCheckBox - > isChecked ( ) ;
2015-11-21 01:13:45 +01:00
}
2016-04-04 14:51:14 +02:00
return ok ;
2015-11-21 01:13:45 +01:00
}
void FileLayoutPage : : reset ( )
{
if ( hasBeenShown ( ) ) {
2015-11-26 19:25:59 +01:00
ui ( ) - > forceRewriteCheckBox - > setChecked ( Settings : : forceRewrite ( ) ) ;
2015-11-21 01:13:45 +01:00
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 ( ) ) {
2015-11-26 19:25:59 +01:00
case ElementPosition : : BeforeData :
ui ( ) - > tagPosBeforeDataRadioButton - > setChecked ( true ) ;
break ;
case ElementPosition : : AfterData :
ui ( ) - > tagPosAfterDataRadioButton - > setChecked ( true ) ;
break ;
case ElementPosition : : Keep :
ui ( ) - > tagPosKeepRadioButton - > setChecked ( true ) ;
break ;
}
ui ( ) - > tagPosForceCheckBox - > setChecked ( forceTagPosition ( ) ) ;
switch ( preferredIndexPosition ( ) ) {
case ElementPosition : : BeforeData :
ui ( ) - > indexPosBeforeDataRadioButton - > setChecked ( true ) ;
break ;
case ElementPosition : : AfterData :
ui ( ) - > indexPosAfterDataRadioButton - > setChecked ( true ) ;
2015-11-21 01:13:45 +01:00
break ;
2015-11-26 19:25:59 +01:00
case ElementPosition : : Keep :
ui ( ) - > indexPosKeepRadioButton - > setChecked ( true ) ;
2015-11-21 01:13:45 +01:00
break ;
}
2015-11-26 19:25:59 +01:00
ui ( ) - > indexPosForceCheckBox - > setChecked ( forceIndexPosition ( ) ) ;
2015-11-21 01:13:45 +01:00
}
}
QWidget * FileLayoutPage : : setupWidget ( )
{
2016-04-04 14:51:14 +02:00
auto * widget = FileLayoutPageBase : : setupWidget ( ) ;
2015-11-21 01:13:45 +01:00
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 ;
}
2015-04-22 19:33:53 +02:00
/*
TRANSLATOR QtGui : : SettingsDialog
Necessary for lupdate .
*/
SettingsDialog : : SettingsDialog ( QWidget * parent ) :
Dialogs : : SettingsDialog ( parent )
{
// setup categories
QList < Dialogs : : OptionCategory * > categories ;
Dialogs : : OptionCategory * category ;
category = new Dialogs : : OptionCategory ( this ) ;
category - > setDisplayName ( tr ( " Tag processing " ) ) ;
category - > assignPages ( QList < Dialogs : : OptionPage * > ( )
2016-05-26 02:15:41 +02:00
< < new TagProcessingGeneralOptionPage < < new Id3v1OptionPage
< < new Id3v2OptionPage < < new TagProcessingTargetsOptionPage < < new FileLayoutPage ) ;
2015-12-02 01:24:27 +01:00
category - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " tag " ) , QIcon ( QStringLiteral ( " :/tageditor/icons/hicolor/32x32/settingscategories/tag.png " ) ) ) ) ;
2015-04-22 19:33:53 +02:00
categories < < category ;
category = new Dialogs : : OptionCategory ( this ) ;
category - > setDisplayName ( tr ( " Editor " ) ) ;
2015-12-02 01:24:27 +01:00
category - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " document-edit " ) , QIcon ( QStringLiteral ( " :/tageditor/icons/hicolor/32x32/settingscategories/key-enter.png " ) ) ) ) ;
2015-04-22 19:33:53 +02:00
category - > assignPages ( QList < Dialogs : : OptionPage * > ( )
< < new EditorGeneralOptionPage < < new EditorTempOptionPage ( this ) < < new EditorFieldsOptionPage
2016-03-05 16:50:23 +01:00
< < new InfoOptionPage < < new EditorAutoCorrectionOptionPage < < new EditorDbQueryOptionsPage ) ;
2015-04-22 19:33:53 +02:00
categories < < category ;
category = new Dialogs : : OptionCategory ( this ) ;
category - > setDisplayName ( tr ( " File browser " ) ) ;
2015-12-02 01:24:27 +01:00
category - > setIcon ( QIcon : : fromTheme ( QStringLiteral ( " view-list-tree " ) , QIcon ( QStringLiteral ( " :/tageditor/icons/hicolor/32x32/settingscategories/system-file-manager.png " ) ) ) ) ;
2015-04-22 19:33:53 +02:00
category - > assignPages ( QList < Dialogs : : OptionPage * > ( ) < < new FileBrowserGeneralOptionPage ) ;
categories < < category ;
2016-04-04 14:51:14 +02:00
2016-07-27 18:31:42 +02:00
categories < < Dialogs : : qtOptionCategory ( this ) ;
2016-04-04 14:51:14 +02:00
2015-04-22 19:33:53 +02:00
categoryModel ( ) - > setCategories ( categories ) ;
setMinimumSize ( 800 , 450 ) ;
setWindowIcon ( QIcon : : fromTheme ( QStringLiteral ( " preferences-other " ) , QIcon ( QStringLiteral ( " :/tageditor/icons/hicolor/32x32/settingscategories/preferences-other.png " ) ) ) ) ;
}
SettingsDialog : : ~ SettingsDialog ( )
{ }
}