Skip to content

Commit

Permalink
Merge pull request mixxxdj#4 from daschuer/libraryFocus
Browse files Browse the repository at this point in the history
Library focus
  • Loading branch information
jmigual authored Dec 8, 2016
2 parents 73094d0 + d16b7c4 commit c028f29
Show file tree
Hide file tree
Showing 19 changed files with 270 additions and 176 deletions.
42 changes: 32 additions & 10 deletions res/skins/Deere/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,24 @@ QTableView, QTreeView {
border: 1px solid #1A1A1A;
}

QTreeView::branch:selected, QTableView::item:selected, QTreeView::item:selected {
QTreeView::branch {
background-color: #1F1F1F;
}

QTableView::item:selected:active,
QTreeView::item:selected:active {
color: #ffffff;

background-color: #006596;
}


QTableView::item:selected:!active,
QTreeView::item:selected:!active {
color: #d2d2d2;
background-color: #0d4866;
}

/* checkbox in library "Played" column */
QTableView::indicator {
width: 12px;
Expand All @@ -147,14 +161,6 @@ QTableView::indicator:unchecked {
background: url(skin:/image/style_checkbox_unchecked.png);
}

WBaseLibrary[showFocus="0"] {
border-top: 2px solid transparent;
}

WBaseLibrary[showFocus="1"] {
border-top: 2px solid #0080BE;
}

/* BPM lock icon in the library "BPM" column. */
#LibraryBPMButton::indicator:checked {
image: url(:/images/library/ic_library_checked.png);
Expand Down Expand Up @@ -205,7 +211,8 @@ WBaseLibrary QLabel {
border: 1px solid #1A1A1A;
}

#LibraryCoverArtSplitter QTabWidget QTreeView, #DlgAutoDJ {
#LibraryCoverArtSplitter QTabWidget QTreeView,
#DlgAutoDJ {
margin: 0;
border: none;
}
Expand Down Expand Up @@ -282,6 +289,17 @@ QPushButton#LibraryPreviewButton:checked {
image: url(skin:/image/style_library_preview_pause.png);
}


#LibrarySidebarButtons:focus,
#LibrarySidebarButtons QToolButton:focus,
#LibrarySidebarExpanded > QWidget:focus,
#LibrarySidebarExpanded QAbstractScrollArea > QWidget:focus,
WLibrarySidebar:focus,
WLibrary:focus,
QTableView:focus {
border: 1px solid #0080BE;
}

/* library header row */
QHeaderView {
color: #d2d2d2;
Expand Down Expand Up @@ -471,6 +489,10 @@ WBaseLibrary QPushButton {
outline: none;
}

WBaseLibrary QPushButton:focus {
background-color: #006596;
}

WBaseLibrary QPushButton:!enabled {
/* buttons in "disabled" (not click-able) state. They are nearly invisible
by default QT palette, so style accordingly */
Expand Down
14 changes: 8 additions & 6 deletions res/skins/Shade/skin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,14 @@
border: 2px solid #e74421;
}

WBaseLibrary[showFocus="0"] {
border-top: 2px solid transparent;
}

WBaseLibrary[showFocus="1"] {
border-top: 2px solid #e74421;
#LibrarySidebarButtons:focus,
#LibrarySidebarButtons QToolButton:focus,
#LibrarySidebarExpanded > QWidget:focus,
#LibrarySidebarExpanded QAbstractScrollArea > QWidget:focus,
WLibrarySidebar:focus,
WLibrary:focus,
QTableView:focus {
border: 1px solid #e74421;
}

WLibraryBreadCrumb QLabel {
Expand Down
24 changes: 11 additions & 13 deletions src/library/features/baseplaylist/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,10 @@ QPointer<PlaylistTableModel> BasePlaylistFeature::getPlaylistTableModel(int pane
}

void BasePlaylistFeature::activate() {
int preselectedPane = getPreselectedPane();
if (preselectedPane >= 0) {
m_featurePane = preselectedPane;
}
adoptPreselectedPane();

auto modelIt = m_lastChildClicked.find(m_featurePane);
if (modelIt != m_lastChildClicked.end() && (*modelIt).isValid()) {
auto modelIt = m_lastChildClicked.constFind(m_featurePane);
if (modelIt != m_lastChildClicked.constEnd() && (*modelIt).isValid()) {
qDebug() << "BasePlaylistFeature::activate" << "m_lastChildClicked found";
// Open last clicked Playlist in the preselectded pane
activateChild(*modelIt);
Expand All @@ -146,12 +143,9 @@ void BasePlaylistFeature::activate() {
}

void BasePlaylistFeature::activateChild(const QModelIndex& index) {
int preselectedPane = getPreselectedPane();
if (preselectedPane >= 0) {
m_featurePane = preselectedPane;
}
adoptPreselectedPane();

if (index == m_lastChildClicked[m_featurePane]) {
if (index == m_lastChildClicked.value(m_featurePane)) {
restoreSearch("");
showTable(m_featurePane);
switchToFeature();
Expand All @@ -178,6 +172,10 @@ void BasePlaylistFeature::activateChild(const QModelIndex& index) {
}
}

void BasePlaylistFeature::invalidateChild() {
m_lastChildClicked.clear();
}

void BasePlaylistFeature::activatePlaylist(int playlistId) {
//qDebug() << "BasePlaylistFeature::activatePlaylist()" << playlistId;
if (playlistId != -1 && m_pPlaylistTableModel) {
Expand Down Expand Up @@ -317,9 +315,9 @@ void BasePlaylistFeature::slotCreatePlaylist() {
}
}

void BasePlaylistFeature::setFeaturePane(int focus) {
void BasePlaylistFeature::setFeaturePaneId(int focus) {
m_pPlaylistTableModel = getPlaylistTableModel(focus);
LibraryFeature::setFeaturePane(focus);
LibraryFeature::setFeaturePaneId(focus);
}

void BasePlaylistFeature::slotDeletePlaylist() {
Expand Down
8 changes: 5 additions & 3 deletions src/library/features/baseplaylist/baseplaylistfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ class BasePlaylistFeature : public LibraryFeature {
void analyzeTracks(QList<TrackId>);

public slots:
virtual void activate();
virtual void activateChild(const QModelIndex& index);
void activate() override;
void activateChild(const QModelIndex& index) override;
void invalidateChild() override;

virtual void activatePlaylist(int playlistId);
virtual void htmlLinkClicked(const QUrl& link);

virtual void slotPlaylistTableChanged(int playlistId) = 0;
virtual void slotPlaylistContentChanged(int playlistId) = 0;
virtual void slotPlaylistTableRenamed(int playlistId, QString a_strName) = 0;
void slotCreatePlaylist();
void setFeaturePane(int focus);
void setFeaturePaneId(int focus);

protected slots:
void slotDeletePlaylist();
Expand Down
20 changes: 9 additions & 11 deletions src/library/features/crates/cratefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,10 @@ TreeItemModel* CrateFeature::getChildModel() {
}

void CrateFeature::activate() {
int preselectedPane = getPreselectedPane();
if (preselectedPane >= 0) {
m_featurePane = preselectedPane;
}
adoptPreselectedPane();

auto modelIt = m_lastClickedIndex.find(m_featurePane);
if (modelIt != m_lastClickedIndex.end() && (*modelIt).isValid()) {
auto modelIt = m_lastClickedIndex.constFind(m_featurePane);
if (modelIt != m_lastClickedIndex.constEnd() && (*modelIt).isValid()) {
activateChild(*modelIt);
return;
}
Expand All @@ -237,10 +234,7 @@ void CrateFeature::activate() {
}

void CrateFeature::activateChild(const QModelIndex& index) {
int preselectedPane = getPreselectedPane();
if (preselectedPane >= 0) {
m_featurePane = preselectedPane;
}
adoptPreselectedPane();

m_lastClickedIndex[m_featurePane] = index;
int crateId = crateIdFromIndex(index);
Expand All @@ -256,6 +250,10 @@ void CrateFeature::activateChild(const QModelIndex& index) {
showTrackModel(m_pCrateTableModel);
}

void CrateFeature::invalidateChild() {
m_lastClickedIndex.clear();
}

void CrateFeature::activateCrate(int crateId) {
//qDebug() << "CrateFeature::activateCrate()" << crateId;
m_pCrateTableModel = getTableModel(m_featurePane);
Expand All @@ -280,7 +278,7 @@ void CrateFeature::onRightClick(const QPoint& globalPos) {
menu.exec(globalPos);
}

void CrateFeature::onRightClickChild(const QPoint& globalPos, QModelIndex index) {
void CrateFeature::onRightClickChild(const QPoint& globalPos, const QModelIndex& index) {
//Save the model index so we can get it in the action slots...
m_lastRightClickedIndex = index;
int crateId = crateIdFromIndex(index);
Expand Down
9 changes: 5 additions & 4 deletions src/library/features/crates/cratefeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ class CrateFeature : public LibraryFeature {
void analyzeTracks(QList<TrackId>);

public slots:
void activate();
void activateChild(const QModelIndex& index);
void activate() override;
void activateChild(const QModelIndex& index) override;
void invalidateChild() override;
void activateCrate(int crateId);
void onRightClick(const QPoint& globalPos);
void onRightClickChild(const QPoint& globalPos, QModelIndex index);
void onRightClick(const QPoint& globalPos) override;
void onRightClickChild(const QPoint& globalPos, const QModelIndex& index) override;

void slotCreateCrate();
void slotDeleteCrate();
Expand Down
6 changes: 5 additions & 1 deletion src/library/features/libraryfolder/libraryfoldermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ LibraryFolderModel::LibraryFolderModel(LibraryFeature* pFeature,
reloadTree();
}

bool LibraryFolderModel::setData(const QModelIndex& index, const QVariant& value, int role) {
bool LibraryFolderModel::setData(
const QModelIndex& index, const QVariant& value, int role) {
if (role == AbstractRole::RoleSettings) {
m_folderRecursive = value.toBool();
m_pConfig->set(ConfigKey("[Library]", "FolderRecursive"),
Expand Down Expand Up @@ -75,6 +76,8 @@ QVariant LibraryFolderModel::data(const QModelIndex& index, int role) const {
}

void LibraryFolderModel::reloadTree() {
//qDebug() << "LibraryFolderModel::reloadTree()";
beginResetModel();
// Remove current root
setRootItem(new TreeItem(m_pFeature));

Expand Down Expand Up @@ -109,6 +112,7 @@ void LibraryFolderModel::reloadTree() {
// For each source folder create the tree
createTreeForLibraryDir(dir, query);
}
endResetModel();
}

void LibraryFolderModel::createTreeForLibraryDir(const QString& dir, QSqlQuery& query) {
Expand Down
11 changes: 6 additions & 5 deletions src/library/features/maintenance/maintenancefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ MaintenanceFeature::MaintenanceFeature(UserSettingsPointer pConfig,
kMissingTitle(tr("Missing Tracks")),
m_pHiddenView(nullptr),
m_pMissingView(nullptr),
m_pTab(nullptr) {
m_pTab(nullptr),
m_idExpandedHidden(-1),
m_idExpandedMissing(-1) {

}

Expand Down Expand Up @@ -56,8 +58,8 @@ void MaintenanceFeature::selectionChanged(const QItemSelection&,
return;
}

auto it = m_idPaneCurrent.find(m_featurePane);
if (it == m_idPaneCurrent.end()) {
auto it = m_idPaneCurrent.constFind(m_featurePane);
if (it == m_idPaneCurrent.constEnd()) {
return;
}

Expand Down Expand Up @@ -112,8 +114,7 @@ QWidget* MaintenanceFeature::createPaneWidget(KeyboardEventFilter* pKeyboard,

void MaintenanceFeature::slotTabIndexChanged(int index) {
QPointer<WTrackTableView> pTable = getFocusedTable();

DEBUG_ASSERT_AND_HANDLE(!pTable.isNull()) {
if (pTable.isNull()) {
return;
}
pTable->setSortingEnabled(false);
Expand Down
Loading

0 comments on commit c028f29

Please sign in to comment.