Skip to content

Commit

Permalink
Initial commit of MDINowPlayingView. Hooked up and working.
Browse files Browse the repository at this point in the history
  • Loading branch information
gvansickle committed Dec 15, 2017
1 parent 10e91a3 commit 15fd511
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ set(SOURCE_FILES
gui/settings/SettingsDialog.cpp
gui/settings/SettingsDialogPageBase.cpp gui/settings/SettingsDialogPageBase.h
gui/settings/SDPageAppearance.cpp gui/settings/SDPageAppearance.h
gui/settings/SettingsDialogSideWidget.cpp gui/settings/SDPageLibrary.cpp gui/settings/SDPageLibrary.h)
gui/settings/SettingsDialogSideWidget.cpp gui/settings/SDPageLibrary.cpp gui/settings/SDPageLibrary.h gui/MDINowPlayingView.cpp gui/MDINowPlayingView.h)

# This function sets up the variable META_FILES_TO_INCLUDE to the extra files
# needed for a windows build (essentially just the configured .rc file).
Expand Down
25 changes: 25 additions & 0 deletions gui/MDINowPlayingView.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2017 Gary R. Van Sickle ([email protected]).
*
* This file is part of AwesomeMediaLibraryManager.
*
* AwesomeMediaLibraryManager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AwesomeMediaLibraryManager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AwesomeMediaLibraryManager. If not, see <http://www.gnu.org/licenses/>.
*/

#include "MDINowPlayingView.h"

MDINowPlayingView::MDINowPlayingView(QWidget *parent) : MDIPlaylistView(parent)
{

}
35 changes: 35 additions & 0 deletions gui/MDINowPlayingView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2017 Gary R. Van Sickle ([email protected]).
*
* This file is part of AwesomeMediaLibraryManager.
*
* AwesomeMediaLibraryManager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AwesomeMediaLibraryManager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AwesomeMediaLibraryManager. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef AWESOMEMEDIALIBRARYMANAGER_MDINOWPLAYINGVIEW_H
#define AWESOMEMEDIALIBRARYMANAGER_MDINOWPLAYINGVIEW_H


#include "MDIPlaylistView.h"

class MDINowPlayingView : public MDIPlaylistView
{
Q_OBJECT

public:
MDINowPlayingView(QWidget *parent);
};


#endif //AWESOMEMEDIALIBRARYMANAGER_MDINOWPLAYINGVIEW_H
4 changes: 4 additions & 0 deletions gui/MDIPlaylistView.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public slots:
void next();
void previous();

/**
* Slot which appends the incoming library entry and starts playing it.
* Intended for use primarily on the single "Now Playing" playlist.
*/
void onSendToNowPlaying(std::shared_ptr<LibraryEntry>);

protected:
Expand Down
9 changes: 9 additions & 0 deletions gui/MDITreeViewBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ class MDITreeViewBase : public QTreeView
bool saveAs();
bool saveFile(QUrl save_url, QString filter);

/// Returns the current basename of this window's backing file.
QString userFriendlyCurrentFile() const;

/// Returns the full URL of this window's backing file.
QUrl getCurrentUrl() const;

protected:
Expand All @@ -55,6 +58,7 @@ class MDITreeViewBase : public QTreeView
bool m_isUntitled = true;

/// Protected function which is used to set the view's filename properties on a save or load.
/// Called by loadFile() and saveFile().
void setCurrentFile(QUrl url);

virtual void closeEvent(QCloseEvent* event) override;
Expand Down Expand Up @@ -99,6 +103,11 @@ protected slots:
/// Return True if you handle it, False if you don't.
virtual bool onBlankAreaToolTip(QHelpEvent* event);

/**
* Called by closeEvent(). If document shows as modified, pops up a "Do you want to save?" box,
* then calls save() or not depending on the user's choice.
* @return false if file was modified and user cancelled, true otherwise.
*/
virtual bool maybeSave();

/**
Expand Down
51 changes: 38 additions & 13 deletions gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ void MainWindow::connectLibraryViewAndMainWindow(MDILibraryView *lv)
void MainWindow::connectNowPlayingViewAndMainWindow(MDIPlaylistView* plv)
{
connect(this, &MainWindow::sendToNowPlaying, plv, &MDIPlaylistView::onSendToNowPlaying);

connectPlayerAndPlaylistView(&m_player, plv);
connectPlayerControlsAndPlaylistView(m_controls, plv);
}

void MainWindow::updateConnections()
Expand All @@ -473,26 +476,23 @@ void MainWindow::updateConnections()
if(childIsLibrary != nullptr)
{
auto connection_handle = connect(activeMdiChild()->selectionModel(), &QItemSelectionModel::selectionChanged,
m_metadataDockWidget, &MetadataDockWidget::playlistSelectionChanged,
Qt::ConnectionType(Qt::AutoConnection | Qt::UniqueConnection));
if(!connection_handle)
m_metadataDockWidget, &MetadataDockWidget::playlistSelectionChanged,
Qt::ConnectionType(Qt::AutoConnection | Qt::UniqueConnection));
if (!connection_handle)
{
qDebug() << "Connection failed: already connected?";
}

connection_handle = connect(childIsLibrary, &MDILibraryView::playTrackNowSignal,
this, &MainWindow::onPlayTrackNowSignal, Qt::ConnectionType(Qt::AutoConnection | Qt::UniqueConnection));
if(!connection_handle)
connection_handle = connect(childIsLibrary,
&MDILibraryView::playTrackNowSignal,
this,
&MainWindow::onPlayTrackNowSignal,
Qt::ConnectionType(Qt::AutoConnection | Qt::UniqueConnection));
if (!connection_handle)
{
qDebug() << "Connection failed: already connected?";
}
}

if(childIsPlaylist != nullptr)
{
connectPlayerAndPlaylistView(&m_player, childIsPlaylist);
connectPlayerControlsAndPlaylistView(m_controls, childIsPlaylist);
}
}
}

Expand Down Expand Up @@ -779,7 +779,7 @@ void MainWindow::onStartup()
changeIconTheme(QIcon::themeName());

// Create the "Now Playing" playlist.
auto wins = createMdiChildPlaylist();
auto wins = createMdiNowPlayingView();
m_now_playing_playlist_view = wins.first;
QMdiSubWindow* mdisubwindow = wins.second;

Expand Down Expand Up @@ -1031,6 +1031,31 @@ std::pair<MDIPlaylistView*, QMdiSubWindow*> MainWindow::createMdiChildPlaylist()
return std::make_pair(child, mdisubwindow);
}

std::pair<MDINowPlayingView*, QMdiSubWindow*> MainWindow::createMdiNowPlayingView()
{
// Create a new "Now Playing" playlist model.
auto new_playlist_model = new PlaylistModel(this);

// TODO REMOVE
m_playlist_models.push_back(new_playlist_model);
m_now_playing_playlist_model = new_playlist_model;

MDINowPlayingView* child = new MDINowPlayingView(this);
child->setModel(new_playlist_model);
auto mdisubwindow = m_mdi_area->addSubWindow(child);

// child.undoAvailable.connect(editUndoAct.setEnabled)
// child.redoAvailable.connect(redoAct.setEnabled)
// child.copyAvailable.connect(cutAct.setEnabled)
// child.copyAvailable.connect(copyAct.setEnabled)

// Connect signals.
//child.cursorPositionChanged.connect(cursorPosChanged)

// Add the new playlist to the collection doc widget.
m_libraryDockWidget->addPlaylist(new PlaylistItem(child));
return std::make_pair(child, mdisubwindow);
}

// Top-level "saveAs" action handler for "Save playlist as..."
void MainWindow::savePlaylistAs()
Expand Down
2 changes: 2 additions & 0 deletions gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "MDIPlaylistView.h"
#include "MDITreeViewBase.h"
#include "PlayerControls.h"
#include "MDINowPlayingView.h"

#include <QMainWindow>
#include <QUrl>
Expand Down Expand Up @@ -144,6 +145,7 @@ private slots:
MDITreeViewBase* activeMdiChild();
QMdiSubWindow* findSubWindow(QUrl url);
std::pair<MDIPlaylistView*, QMdiSubWindow*> createMdiChildPlaylist();
std::pair<MDINowPlayingView*, QMdiSubWindow*> createMdiNowPlayingView();

QSharedPointer<LibraryModel> openLibraryModelOnUrl(QUrl url);
void openMDILibraryViewOnModel(LibraryModel* libmodel);
Expand Down

0 comments on commit 15fd511

Please sign in to comment.