Skip to content

Commit

Permalink
Merge branch '2.3' of https://github.com/mixxxdj/mixxx into fix_selec…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
poelzi committed Jan 5, 2021
2 parents a681a15 + 488c4ad commit 9c81098
Show file tree
Hide file tree
Showing 19 changed files with 199 additions and 114 deletions.
66 changes: 26 additions & 40 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,54 +416,40 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
}

// Intro/outro range markers
QMenu* introOutroMenu = addSubmenu(tr("Intro / Outro Cues"));
QString introStartTitle(tr("Intro Start Cue"));
QString introEndTitle(tr("Intro End Cue"));
QString outroStartTitle(tr("Outro Start Cue"));
QString outroEndTitle(tr("Outro End Cue"));
QMenu* introStartMenu = addSubmenu(introStartTitle, introOutroMenu);
QMenu* introEndMenu = addSubmenu(introEndTitle, introOutroMenu);
QMenu* outroStartMenu = addSubmenu(outroStartTitle, introOutroMenu);
QMenu* outroEndMenu = addSubmenu(outroEndTitle, introOutroMenu);
QList<QMenu*> introOutroSubmenus = {
introStartMenu,
introEndMenu,
outroStartMenu,
outroEndMenu};
const QStringList cueTypeTitles = {
introStartTitle,
introEndTitle,
outroStartTitle,
outroEndTitle};
const QStringList cueTypeNames = {
tr("intro start cue"),
tr("intro end cue"),
tr("outro start cue"),
tr("outro end cue")};
const QStringList cueTypeCOs = {
QMenu* introOutroMenu = addSubmenu(tr("Intro / Outro Markers"));
const QStringList markerTitles = {
tr("Intro Start Marker"),
tr("Intro End Marker"),
tr("Outro Start Marker"),
tr("Outro End Marker")};
const QStringList markerNames = {
tr("intro start marker"),
tr("intro end marker"),
tr("outro start marker"),
tr("outro end marker")};
const QStringList markerCOs = {
"intro_start",
"intro_end",
"outro_start",
"outro_end"};

for (int i = 0; i < introOutroSubmenus.size(); ++i) {
for (int i = 0; i < markerTitles.size(); ++i) {
QMenu* tempMenu = addSubmenu(markerTitles[i], introOutroMenu);
addDeckAndSamplerAndPreviewDeckControl(
QString("%1_activate").arg(cueTypeCOs[i]),
tr("Activate %1").arg(cueTypeTitles[i]),
tr("Jump to or set the %1")
.arg(cueTypeNames[i]),
introOutroSubmenus[i]);
QString("%1_activate").arg(markerCOs[i]),
tr("Activate %1", "[intro/outro marker").arg(markerTitles[i]),
tr("Jump to or set the %1", "[intro/outro marker").arg(markerNames[i]),
tempMenu);
addDeckAndSamplerAndPreviewDeckControl(
QString("%1_set").arg(cueTypeCOs[i]),
tr("Set %1").arg(cueTypeTitles[i]),
tr("Set or jump to the %1")
.arg(cueTypeNames[i]),
introOutroSubmenus[i]);
QString("%1_set").arg(markerCOs[i]),
tr("Set %1", "[intro/outro marker").arg(markerTitles[i]),
tr("Set or jump to the %1", "[intro/outro marker").arg(markerNames[i]),
tempMenu);
addDeckAndSamplerAndPreviewDeckControl(
QString("%1_clear").arg(cueTypeCOs[i]),
tr("Clear %1").arg(cueTypeTitles[i]),
tr("Clear the %1").arg(cueTypeNames[i]),
introOutroSubmenus[i]);
QString("%1_clear").arg(markerCOs[i]),
tr("Clear %1", "[intro/outro marker").arg(markerTitles[i]),
tr("Clear the %1", "[intro/outro marker").arg(markerNames[i]),
tempMenu);
}

// Loops
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DlgPrefController::DlgPrefController(QWidget* parent,

// When the user picks a preset, load it.
connect(m_ui.comboBoxPreset,
QOverload<int>::of(&QComboBox::activated),
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefController::slotPresetSelected);

Expand Down Expand Up @@ -433,7 +433,7 @@ void DlgPrefController::slotApply() {
}
m_ui.chkEnabledDevice->setChecked(bEnabled);

// The shouldn't be dirty at this pint because we already tried to save
// The shouldn't be dirty at this point because we already tried to save
// it. If that failed, don't apply the preset.
if (m_pPreset && m_pPreset->isDirty()) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/dialog/dlgabout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ DlgAbout::DlgAbout(QWidget* parent) : QDialog(parent), Ui::DlgAboutDlg() {
<< "Edward Millen"
<< "Frank Breitling"
<< "Christian"
<< "Geraldo Nascimento";
<< "Geraldo Nascimento"
<< "Albert Aparicio";

QStringList specialThanks;
specialThanks
Expand Down
2 changes: 1 addition & 1 deletion src/library/basesqltablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ void BaseSqlTableModel::setSort(int column, Qt::SortOrder order) {
}

m_trackSourceOrderBy.append(first ? "ORDER BY " : ", ");
m_trackSourceOrderBy.append(mixxx::DbConnection::collateLexicographically(sort_field));
m_trackSourceOrderBy.append(sort_field);
m_trackSourceOrderBy.append((sc.m_order == Qt::AscendingOrder) ? " ASC" : " DESC");
//qDebug() << m_trackSourceOrderBy;
first = false;
Expand Down
1 change: 0 additions & 1 deletion src/library/basetrackcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class BaseTrackCache : public QObject {
bool m_bIsCaching;
QHash<TrackId, QVector<QVariant> > m_trackInfo;
QSqlDatabase m_database;
ControlProxy* m_pKeyNotationCP;

DISALLOW_COPY_AND_ASSIGN(BaseTrackCache);
};
49 changes: 30 additions & 19 deletions src/library/columncache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
#include "library/dao/playlistdao.h"
#include "library/dao/trackschema.h"
#include "moc_columncache.cpp"
#include "util/db/dbconnection.h"

namespace {

const QString kSortInt = QStringLiteral("cast(%1 as integer)");
const QString kSortNoCase = QStringLiteral("lower(%1)");
const QString kSortNoCaseLex = mixxx::DbConnection::collateLexicographically(
QStringLiteral("lower(%1)"));

} // namespace

ColumnCache::ColumnCache(const QStringList& columns) {
m_pKeyNotationCP = new ControlProxy("[Library]", "key_notation", this);
Expand Down Expand Up @@ -90,27 +100,28 @@ void ColumnCache::setColumns(const QStringList& columns) {
m_columnIndexByEnum[it.key()] = fieldIndex(it.value());
}

const QString sortInt("cast(%1 as integer)");
const QString sortNoCase("lower(%1)");

m_columnSortByIndex.clear();
// Add the columns that requires a special sort
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_ARTIST, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_TITLE, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_ALBUM, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_ALBUMARTIST, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_YEAR, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_GENRE, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_COMPOSER, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_GROUPING, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_TRACKNUMBER, sortInt);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_FILETYPE, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_NATIVELOCATION, sortNoCase);
insertColumnSortByIndex(COLUMN_LIBRARYTABLE_COMMENT, sortNoCase);

insertColumnSortByIndex(COLUMN_PLAYLISTTRACKSTABLE_LOCATION, sortNoCase);
insertColumnSortByIndex(COLUMN_PLAYLISTTRACKSTABLE_ARTIST, sortNoCase);
insertColumnSortByIndex(COLUMN_PLAYLISTTRACKSTABLE_TITLE, sortNoCase);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_ARTIST, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_TITLE, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_ALBUM, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_ALBUMARTIST, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_YEAR, kSortNoCase);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_GENRE, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_COMPOSER, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_GROUPING, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_TRACKNUMBER, kSortInt);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_FILETYPE, kSortNoCase);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_NATIVELOCATION, kSortNoCase);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_COMMENT, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_BITRATE, kSortInt);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_BPM, kSortInt);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_SAMPLERATE, kSortInt);
insertColumnSortByEnum(COLUMN_LIBRARYTABLE_TIMESPLAYED, kSortInt);

insertColumnSortByEnum(COLUMN_PLAYLISTTRACKSTABLE_LOCATION, kSortNoCase);
insertColumnSortByEnum(COLUMN_PLAYLISTTRACKSTABLE_ARTIST, kSortNoCaseLex);
insertColumnSortByEnum(COLUMN_PLAYLISTTRACKSTABLE_TITLE, kSortNoCaseLex);

slotSetKeySortOrder(m_pKeyNotationCP->get());
}
Expand Down
14 changes: 9 additions & 5 deletions src/library/columncache.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,16 @@ class ColumnCache : public QObject {
return format.arg(columnNameForFieldIndex(index));
}

void insertColumnSortByIndex(
int index,
const QString& name) {
void insertColumnSortByEnum(
Column column,
const QString& sortFormat) {
int index = fieldIndex(column);
if (index < 0) {
return;
}
DEBUG_ASSERT(!m_columnSortByIndex.contains(index) ||
m_columnSortByIndex[index] == name);
m_columnSortByIndex.insert(index, name);
m_columnSortByIndex[index] == sortFormat);
m_columnSortByIndex.insert(index, sortFormat);
}

void insertColumnNameByEnum(
Expand Down
1 change: 1 addition & 0 deletions src/library/playlisttablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void PlaylistTableModel::setTableModel(int playlistId) {
m_pTrackCollectionManager->internalCollection()->getTrackSource());
setSearch("");
setDefaultSort(fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION), Qt::AscendingOrder);
setSort(defaultSortColumn(), defaultSortOrder());
}

int PlaylistTableModel::addTracks(const QModelIndex& index,
Expand Down
18 changes: 17 additions & 1 deletion src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,23 @@ void MixxxMainWindow::finalize() {
m_pTrackCollectionManager->stopLibraryScan();
m_pLibrary->stopPendingTasks();

// Save the current window state (position, maximized, etc)
// Save the current window state (position, maximized, etc)
// Note(ronso0): Unfortunately saveGeometry() also stores the fullscreen state.
// On next start restoreGeometry would enable fullscreen mode even though that
// might not be requested (no '--fullscreen' command line arg and
// [Config],StartInFullscreen is '0'.
// https://bugs.launchpad.net/mixxx/+bug/1882474
// https://bugs.launchpad.net/mixxx/+bug/1909485
// So let's quit fullscreen if StartInFullscreen is not checked in Preferences.
bool fullscreenPref = m_pSettingsManager->settings()->getValue<bool>(
ConfigKey("[Config]", "StartInFullscreen"));
if (isFullScreen() && !fullscreenPref) {
slotViewFullScreen(false);
// After returning from fullscreen the main window incl. window decoration
// may be too large for the screen.
// Maximize the window so we can store a geometry that fits the screen.
showMaximized();
}
m_pSettingsManager->settings()->set(ConfigKey("[MainWindow]", "geometry"),
QString(saveGeometry().toBase64()));
m_pSettingsManager->settings()->set(ConfigKey("[MainWindow]", "state"),
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgprefbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DlgPrefBeats::DlgPrefBeats(QWidget* parent, UserSettingsPointer pConfig)

// Connections
connect(comboBoxBeatPlugin,
QOverload<int>::of(&QComboBox::activated),
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefBeats::pluginSelected);
connect(checkBoxAnalyzerEnabled,
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/dialog/dlgprefdeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ DlgPrefDeck::DlgPrefDeck(QWidget* parent,
pControl->set(static_cast<int>(m_cueMode));
}
connect(ComboBoxCueMode,
QOverload<int>::of(&QComboBox::activated),
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefDeck::slotCueModeCombobox);

Expand Down Expand Up @@ -227,7 +227,7 @@ DlgPrefDeck::DlgPrefDeck(QWidget* parent,
ComboBoxRateRange->addItem(tr("50%"), 50);
ComboBoxRateRange->addItem(tr("90%"), 90);
connect(ComboBoxRateRange,
QOverload<int>::of(&QComboBox::activated),
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefDeck::slotRateRangeComboBox);

Expand Down
77 changes: 47 additions & 30 deletions src/preferences/dialog/dlgprefinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,59 @@ DlgPrefInterface::DlgPrefInterface(QWidget * parent, MixxxMainWindow * mixxx,
m_bRebootMixxxView(false) {
setupUi(this);

//
// Locale setting
//

// Iterate through the available locales and add them to the combobox
// Borrowed following snippet from http://qt-project.org/wiki/How_to_create_a_multi_language_application
QString translationsFolder = m_pConfig->getResourcePath() + "translations/";
const auto translationsDir = QDir(
m_pConfig->getResourcePath() +
QStringLiteral("translations/"));
DEBUG_ASSERT(translationsDir.exists());

QDir translationsDir(translationsFolder);
QStringList fileNames = translationsDir.entryList(QStringList("mixxx_*.qm"));
fileNames.push_back("mixxx_en_US.qm"); // add source language as a fake value

for (int i = 0; i < fileNames.size(); ++i) {
// Extract locale from filename
QString locale = fileNames[i];
locale.truncate(locale.lastIndexOf('.'));
locale.remove(0, locale.indexOf('_') + 1);
QLocale qlocale = QLocale(locale);

QString lang = QLocale::languageToString(qlocale.language());
QString country = QLocale::countryToString(qlocale.country());
if (lang == "C") { // Ugly hack to remove the non-resolving locales
// Add source language as a fake value
DEBUG_ASSERT(!fileNames.contains(QStringLiteral("mixxx_en_US.qm")));
fileNames.push_back(QStringLiteral("mixxx_en_US.qm"));

for (const auto& fileName : qAsConst(fileNames)) {
// Extract locale name from file name
QString localeName = fileName;
// Strip prefix
DEBUG_ASSERT(localeName.startsWith(QStringLiteral("mixxx_")));
localeName.remove(0, QStringLiteral("mixxx_").length());
// Strip file extension
localeName.truncate(localeName.lastIndexOf('.'));
// Convert to QLocale name format. Unfortunately the translation files
// use inconsistent language/country separators, i.e. both '-' and '_'.
auto localeNameFixed = localeName;
localeNameFixed.replace('-', '_');
const auto locale = QLocale(localeNameFixed);

const QString languageName = QLocale::languageToString(locale.language());
// Ugly hack to skip non-resolvable locales
if (languageName == QStringLiteral("C")) {
qWarning() << "Unsupported locale" << localeNameFixed;
continue;
}
lang = QString("%1 (%2)").arg(lang, country);
ComboBoxLocale->addItem(lang, locale); // locale as userdata (for storing to config)
QString countryName;
// Ugly hack to detect locales with an explicitly specified country.
// https://doc.qt.io/qt-5/qlocale.html#QLocale-1
// "If country is not present, or is not a valid ISO 3166 code, the most
// appropriate country is chosen for the specified language."
if (localeNameFixed.contains('_')) {
countryName = QLocale::countryToString(locale.country());
DEBUG_ASSERT(!countryName.isEmpty());
}
QString displayName = languageName;
if (!countryName.isEmpty()) {
displayName += QStringLiteral(" (") + countryName + ')';
}
// The locale name is stored in the config
ComboBoxLocale->addItem(displayName, localeName);
}
ComboBoxLocale->model()->sort(0); // Sort languages list
ComboBoxLocale->insertItem(0, "System", ""); // System default locale - insert at the top
// Sort languages list...
ComboBoxLocale->model()->sort(0);
// ...and then insert entry for default system locale at the top
ComboBoxLocale->insertItem(0, QStringLiteral("System"), "");

// Skin configurations
QString sizeWarningString =
Expand Down Expand Up @@ -149,27 +173,23 @@ DlgPrefInterface::DlgPrefInterface(QWidget * parent, MixxxMainWindow * mixxx,
}

connect(ComboBoxSkinconf,
QOverload<int>::of(&QComboBox::activated),
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefInterface::slotSetSkin);
connect(ComboBoxSchemeconf,
QOverload<int>::of(&QComboBox::activated),
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefInterface::slotSetScheme);

checkBoxScaleFactorAuto->hide();
spinBoxScaleFactor->hide();
labelScaleFactor->hide();

//
// Start in fullscreen mode
//
checkBoxStartFullScreen->setChecked(m_pConfig->getValueString(
ConfigKey("[Config]", "StartInFullscreen")).toInt()==1);

//
// Screensaver mode
//
comboBoxScreensaver->clear();
comboBoxScreensaver->addItem(tr("Allow screensaver to run"),
static_cast<int>(mixxx::ScreenSaverPreference::PREVENT_OFF));
Expand All @@ -181,10 +201,7 @@ DlgPrefInterface::DlgPrefInterface(QWidget * parent, MixxxMainWindow * mixxx,
int inhibitsettings = static_cast<int>(mixxx->getInhibitScreensaver());
comboBoxScreensaver->setCurrentIndex(comboBoxScreensaver->findData(inhibitsettings));

//
// Tooltip configuration
//

// Initialize checkboxes to match config
loadTooltipPreferenceFromConfig();
slotSetTooltips(); // Update disabled status of "only library" checkbox
Expand Down
Loading

0 comments on commit 9c81098

Please sign in to comment.