MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), mScanner(nullptr) { Messages::setHandler(this); setupUi(this); qApp->setWindowIcon(loadMainIcon()); toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); toolBar->setIconSize(QSize(24,24)); qApp->setAttribute(Qt::AA_DontShowIconsInMenus, true); qApp->setAttribute(Qt::AA_UseHighDpiPixmaps, true); #ifdef Q_OS_MAC this->setUnifiedTitleAndToolBarOnMac(true); setWindowIcon(QIcon()); trackView->setFrameShape(QFrame::NoFrame); splitter->setStyleSheet("::handle{ border-right: 1px solid #b6b6b6;}"); #endif setAcceptDrops(true); setAcceptDrops(true); this->setContextMenuPolicy(Qt::NoContextMenu); outPatternButton->setToolTip(outPatternEdit->toolTip()); outDirEdit->setToolTip(actionSelectResultDir->toolTip()); // TrackView ............................................... trackView->setRootIsDecorated(false); trackView->setItemsExpandable(false); trackView->hideColumn((int)TrackView::ColumnComment); trackView->setAlternatingRowColors(false); // Tag edits ............................................... tagGenreEdit->setTagId(TagId::Genre); connect(tagGenreEdit, SIGNAL(textEdited(QString)), this, SLOT(setTrackTag())); tagYearEdit->setTagId(TagId::Date); connect(tagYearEdit, SIGNAL(textEdited(QString)), this, SLOT(setTrackTag())); tagArtistEdit->setTagId(TagId::Artist); connect(tagArtistEdit, SIGNAL(textEdited(QString)), this, SLOT(setTrackTag())); connect(tagArtistEdit, SIGNAL(textEdited(QString)), this, SLOT(refreshEdits())); tagDiskPerformerEdit->setTagId(TagId::AlbumArtist); connect(tagDiskPerformerEdit, SIGNAL(textEdited(QString)), this, SLOT(setDiskTag())); connect(tagDiskPerformerEdit, SIGNAL(textEdited(QString)), this, SLOT(refreshEdits())); tagAlbumEdit->setTagId(TagId::Album); connect(tagAlbumEdit, SIGNAL(textEdited(QString)), this, SLOT(setTrackTag())); tagDiscIdEdit->setTagId(TagId::DiscId); connect(tagStartNumEdit, SIGNAL(editingFinished()), this, SLOT(setStartTrackNum())); connect(tagStartNumEdit, SIGNAL(valueChanged(int)), this, SLOT(setStartTrackNum())); connect(trackView->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(refreshEdits())); connect(trackView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(trackViewMenu(QPoint))); connect(editTagsButton, &QPushButton::clicked, this, &MainWindow::openEditTagsDialog); initActions(); // Buttons ................................................. outDirButton->setAutoRaise(true); outDirButton->setStyleSheet("border: none;"); initOutDirButton(); configureEncoderBtn->setDefaultAction(actionConfigureEncoder); configureEncoderBtn->setAutoRaise(true); configureEncoderBtn->setStyleSheet("border: none;"); outPatternButton->addPattern("%n", tr("Insert \"Track number\"")); outPatternButton->addPattern("%N", tr("Insert \"Total number of tracks\"")); outPatternButton->addPattern("%a", tr("Insert \"Artist\"")); outPatternButton->addPattern("%A", tr("Insert \"Album title\"")); outPatternButton->addPattern("%t", tr("Insert \"Track title\"")); outPatternButton->addPattern("%y", tr("Insert \"Year\"")); outPatternButton->addPattern("%g", tr("Insert \"Genre\"")); outPatternButton->addPattern("%d", tr("Insert \"Disk number\"")); outPatternButton->addPattern("%D", tr("Insert \"Total number of disks\"")); const QString patterns[] = { "%a/{%y - }%A/%n - %t", "%a -{ %y }%A/%n - %t", "{%y }%A - %a/%n - %t", "%a/%A/%n - %t", "%a - %A/%n - %t", "%A - %a/%n - %t" }; for (QString pattern: patterns) { outPatternButton->addFullPattern(pattern, tr("Use \"%1\"", "Predefined out file pattern, string like 'Use \"%a/%A/%n - %t\"'") .arg(pattern) + " ( " + PatternExpander::example(pattern) + ".flac )"); } outPatternButton->menu()->addSeparator(); outPatternEdit->deleteItemAction()->setText(tr("Delete current pattern from history")); outPatternButton->menu()->addAction(outPatternEdit->deleteItemAction()); connect(outPatternButton, SIGNAL(paternSelected(QString)), this, SLOT(insertOutPattern(QString))); connect(outPatternButton, SIGNAL(fullPaternSelected(QString)), this, SLOT(replaceOutPattern(QString))); outPatternButton->setIcon(Icon("pattern-button")); // Format combo ............................................ initOutFormatCombo(); loadSettings(); outDirEdit->setHistory(settings->value(Settings::OutFiles_DirectoryHistory).toStringList()); outDirEdit->setCurrentText(settings->value(Settings::OutFiles_Directory).toString()); outPatternEdit->setHistory(settings->value(Settings::OutFiles_PatternHistory).toStringList()); // Signals ................................................. connect(settings, SIGNAL(changed()), trackView->model(), SIGNAL(layoutChanged())); connect(outPatternEdit->lineEdit(), SIGNAL(editingFinished()), this, SLOT(setPattern())); connect(outPatternEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(setPattern())); connect(outDirEdit->lineEdit(), SIGNAL(editingFinished()), this, SLOT(setOutDir())); connect(outDirEdit, SIGNAL(currentIndexChanged(int)), this, SLOT(setOutDir())); connect(outFormatCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setOutFormat())); connect(codepageCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setCodePage())); connect(trackView, SIGNAL(selectCueFile(Disk*)), this, SLOT(setCueForDisc(Disk*))); connect(trackView, SIGNAL(selectAudioFile(Disk*)), this, SLOT(setAudioForDisk(Disk*))); connect(trackView, SIGNAL(selectCoverImage(Disk*)), this, SLOT(setCoverImage(Disk*))); connect(trackView, SIGNAL(downloadInfo(Disk*)), this, SLOT(downloadDiskInfo(Disk*))); connect(trackView->model(), SIGNAL(layoutChanged()), this, SLOT(refreshEdits())); connect(trackView->model(), SIGNAL(layoutChanged()), this, SLOT(setControlsEnable())); connect(trackView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(refreshEdits())); connect(trackView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(setControlsEnable())); connect(project, SIGNAL(layoutChanged()), trackView, SLOT(layoutChanged())); connect(project, SIGNAL(layoutChanged()), this, SLOT(refreshEdits())); connect(project, SIGNAL(layoutChanged()), this, SLOT(setControlsEnable())); connect(project, SIGNAL(diskChanged(Disk*)), this, SLOT(refreshEdits())); connect(project, SIGNAL(diskChanged(Disk*)), this, SLOT(setControlsEnable())); connect(Application::instance(), &Application::visualModeChanged, [](){ Icon::setDarkMode(Application::instance()->isDarkVisualMode()); }); Icon::setDarkMode(Application::instance()->isDarkVisualMode()); refreshEdits(); setControlsEnable(); }
void TagSet::setTrackTag(int track, const QString &tagName, const QString &value) { const QByteArray &data = QTextCodec::codecForName(ENC_CODEC)->fromUnicode(value); setTrackTag(track, tagName, data, true); }