rewrote Cancel and Save behavior in SimplePlaylistMgmtWindow
This commit is contained in:
parent
b297754948
commit
128f8034b8
5 changed files with 179 additions and 79 deletions
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.59 $
|
||||
Version : $Revision: 1.60 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -443,6 +443,7 @@ LiveSupport :: GLiveSupport ::
|
|||
GLiveSupport :: logout(void) throw ()
|
||||
{
|
||||
if (sessionId.get() != 0) {
|
||||
cancelEditedPlaylist();
|
||||
stopCueAudio();
|
||||
storeScratchpadContents();
|
||||
scratchpadContents->clear();
|
||||
|
@ -700,24 +701,19 @@ GLiveSupport :: addToPlaylist(Ptr<const UniqueId>::Ref id)
|
|||
/*------------------------------------------------------------------------------
|
||||
* Save the currently edited playlist in storage
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<Playlist>::Ref
|
||||
void
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: savePlaylist(void)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
Ptr<Playlist>::Ref playlist;
|
||||
|
||||
if (editedPlaylist) {
|
||||
if (editedPlaylist->isLocked()) {
|
||||
editedPlaylist->deleteSavedCopy();
|
||||
storage->savePlaylist(sessionId, editedPlaylist);
|
||||
playlist = storage->getPlaylist(sessionId, editedPlaylist->getId());
|
||||
addToScratchpad(playlist);
|
||||
addToScratchpad(editedPlaylist); // update with new version
|
||||
}
|
||||
editedPlaylist.reset();
|
||||
}
|
||||
|
||||
return playlist;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.43 $
|
||||
Version : $Revision: 1.44 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -102,7 +102,7 @@ class MasterPanelWindow;
|
|||
* respective documentation.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.43 $
|
||||
* @version $Revision: 1.44 $
|
||||
* @see LocalizedObject#getBundle(const xmlpp::Element &)
|
||||
* @see AuthenticationClientFactory
|
||||
* @see StorageClientFactory
|
||||
|
@ -547,13 +547,14 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
* Save the currently edited playlist in storage.
|
||||
* This call has to be preceeded by a call to openPlaylistForEditing()
|
||||
* or addToPlaylist().
|
||||
* After this call, the playlist is no longer being edited. If you
|
||||
* want to continue editing, open the playlist for editing again.
|
||||
*
|
||||
* @return the audio clip that was saved.
|
||||
* @exception XmlRpcException on upload failures.
|
||||
* @see #openPlaylistForEditing
|
||||
* @see #addToPlaylist
|
||||
*/
|
||||
Ptr<Playlist>::Ref
|
||||
void
|
||||
savePlaylist(void) throw (XmlRpcException);
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.21 $
|
||||
Version : $Revision: 1.22 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -69,7 +69,8 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
|
|||
Colors::White,
|
||||
WidgetFactory::getInstance()->getWhiteWindowCorners()),
|
||||
LocalizedObject(bundle),
|
||||
gLiveSupport(gLiveSupport)
|
||||
gLiveSupport(gLiveSupport),
|
||||
isPlaylistModified(false)
|
||||
{
|
||||
Ptr<WidgetFactory>::Ref wf = WidgetFactory::getInstance();
|
||||
|
||||
|
@ -128,6 +129,23 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
|
|||
entriesView->signalCellEdited().connect(sigc::mem_fun(
|
||||
*this, &SimplePlaylistManagementWindow::onFadeInfoEdited ));
|
||||
|
||||
// construct the "lock fades" check button
|
||||
Ptr<Glib::ustring>::Ref lockFadesCheckButtonLabel;
|
||||
try {
|
||||
lockFadesCheckButtonLabel = getResourceUstring(
|
||||
"lockFadesCheckButtonLabel");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
Gtk::CheckButton * lockFadesCheckButton = Gtk::manage(new Gtk::CheckButton(
|
||||
*lockFadesCheckButtonLabel ));
|
||||
lockFadesCheckButton->set_active(true);
|
||||
areFadesLocked = true;
|
||||
lockFadesCheckButton->signal_toggled().connect(sigc::mem_fun(
|
||||
*this,
|
||||
&SimplePlaylistManagementWindow::onLockFadesCheckButtonClicked ));
|
||||
|
||||
// set up the layout
|
||||
Gtk::VBox * mainBox = Gtk::manage(new Gtk::VBox);
|
||||
|
||||
|
@ -142,6 +160,8 @@ SimplePlaylistManagementWindow :: SimplePlaylistManagementWindow (
|
|||
|
||||
mainBox->pack_start(*entriesScrolledWindow, Gtk::PACK_EXPAND_WIDGET, 5);
|
||||
|
||||
mainBox->pack_start(*lockFadesCheckButton, Gtk::PACK_SHRINK, 5);
|
||||
|
||||
Gtk::ButtonBox * buttonBox = Gtk::manage(new Gtk::HButtonBox(
|
||||
Gtk::BUTTONBOX_END, 5));
|
||||
buttonBox->pack_start(*saveButton);
|
||||
|
@ -218,16 +238,15 @@ SimplePlaylistManagementWindow :: savePlaylist (void) throw ()
|
|||
|
||||
playlist->setTitle(title);
|
||||
gLiveSupport->savePlaylist();
|
||||
gLiveSupport->openPlaylistForEditing(playlist->getId());
|
||||
isPlaylistModified = false;
|
||||
|
||||
Ptr<Glib::ustring>::Ref statusText = formatMessage(
|
||||
"playlistSavedMsg",
|
||||
*playlist->getTitle());
|
||||
statusBar->set_text(*statusText);
|
||||
|
||||
// clean the entry fields
|
||||
nameEntry->set_text("");
|
||||
entriesModel->clear();
|
||||
return true;
|
||||
|
||||
} catch (XmlRpcException &e) {
|
||||
statusBar->set_text(e.what());
|
||||
return false;
|
||||
|
@ -236,7 +255,7 @@ SimplePlaylistManagementWindow :: savePlaylist (void) throw ()
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Event handler for the save button getting clicked.
|
||||
* Signal handler for the save button getting clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onSaveButtonClicked(void) throw ()
|
||||
|
@ -246,40 +265,71 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw ()
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Event handler for the close button getting clicked.
|
||||
* Cancel the edited playlist (no questions asked).
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
|
||||
{
|
||||
gLiveSupport->cancelEditedPlaylist();
|
||||
closeWindow();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Signal handler for the close button getting clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onCloseButtonClicked(void) throw ()
|
||||
{
|
||||
if (gLiveSupport->getEditedPlaylist()) {
|
||||
if (!isPlaylistModified) {
|
||||
cancelPlaylist();
|
||||
} else {
|
||||
DialogWindow::ButtonType result = dialogWindow->run();
|
||||
switch (result) {
|
||||
case DialogWindow::noButton:
|
||||
gLiveSupport->cancelEditedPlaylist();
|
||||
case DialogWindow::noButton: cancelPlaylist();
|
||||
break;
|
||||
|
||||
case DialogWindow::yesButton: if (savePlaylist()) {
|
||||
closeWindow();
|
||||
}
|
||||
break;
|
||||
|
||||
case DialogWindow::cancelButton: break;
|
||||
|
||||
default : break;
|
||||
// can happen if window is closed
|
||||
} // with Alt-F4 -- treated as cancel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Clean and close the window.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: closeWindow(void) throw ()
|
||||
{
|
||||
statusBar->set_text("");
|
||||
nameEntry->set_text("");
|
||||
entriesModel->clear();
|
||||
break;
|
||||
|
||||
case DialogWindow::yesButton:
|
||||
if (savePlaylist()) {
|
||||
statusBar->set_text("");
|
||||
break;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
case DialogWindow::cancelButton:
|
||||
return;
|
||||
default : // can happen if window is closed
|
||||
return; // with Alt-F4 -- treated as cancel
|
||||
}
|
||||
}
|
||||
|
||||
isPlaylistModified = false;
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Signal handler for the "lock fades" check button toggled.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SimplePlaylistManagementWindow :: onLockFadesCheckButtonClicked(void)
|
||||
throw ()
|
||||
{
|
||||
areFadesLocked = !areFadesLocked;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Show the contents of the currently edited playlist.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -349,8 +399,13 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited(
|
|||
std::vector<int> rowNumberVector = path.get_indices();
|
||||
int rowNumber = rowNumberVector.at(0);
|
||||
|
||||
Ptr<time_duration>::Ref newTime(new time_duration(
|
||||
duration_from_string(newText) ));
|
||||
Ptr<time_duration>::Ref newTime;
|
||||
try {
|
||||
newTime.reset(new time_duration(duration_from_string(newText)));
|
||||
} catch (boost::bad_lexical_cast &e) {
|
||||
showContents(); // bad time format; restore previous state
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist();
|
||||
Playlist::const_iterator iter = playlist->begin();
|
||||
|
@ -363,16 +418,14 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited(
|
|||
switch (columnId) {
|
||||
case fadeInColumnId :
|
||||
setFadeIn(playlistElement, newTime);
|
||||
if (iter != playlist->begin()) {
|
||||
--iter;
|
||||
if (areFadesLocked && iter-- != playlist->begin()) {
|
||||
Ptr<PlaylistElement>::Ref prevPlaylistElement = iter->second;
|
||||
setFadeOut(prevPlaylistElement, newTime);
|
||||
}
|
||||
break;
|
||||
case fadeOutColumnId :
|
||||
setFadeOut(playlistElement, newTime);
|
||||
++iter;
|
||||
if (iter != playlist->end()) {
|
||||
if (areFadesLocked && ++iter != playlist->end()) {
|
||||
Ptr<PlaylistElement>::Ref nextPlaylistElement = iter->second;
|
||||
setFadeIn(nextPlaylistElement, newTime);
|
||||
}
|
||||
|
@ -392,22 +445,26 @@ SimplePlaylistManagementWindow :: onFadeInfoEdited(
|
|||
* Auxilliary function: set the fade in of a playlist element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GLiveSupport :: setFadeIn(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
SimplePlaylistManagementWindow :: setFadeIn(
|
||||
Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeIn)
|
||||
throw()
|
||||
{
|
||||
Ptr<FadeInfo>::Ref oldFadeInfo = playlistElement->getFadeInfo();
|
||||
Ptr<time_duration>::Ref oldFadeOut;
|
||||
if (oldFadeInfo) {
|
||||
if (*oldFadeInfo->getFadeIn() == *newFadeIn) {
|
||||
return;
|
||||
}
|
||||
oldFadeOut = oldFadeInfo->getFadeOut();
|
||||
} else {
|
||||
oldFadeOut.reset(new time_duration(0,0,0,0));
|
||||
}
|
||||
|
||||
Ptr<FadeInfo>::Ref newFadeInfo(new FadeInfo(
|
||||
newFadeIn, oldFadeOut ));
|
||||
if (isLengthOkay(playlistElement, newFadeInfo)) {
|
||||
playlistElement->setFadeInfo(newFadeInfo);
|
||||
isPlaylistModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,13 +473,17 @@ GLiveSupport :: setFadeIn(Ptr<PlaylistElement>::Ref playlistElement,
|
|||
* Auxilliary function: set the fade out of a playlist element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
GLiveSupport :: setFadeOut(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
SimplePlaylistManagementWindow :: setFadeOut(
|
||||
Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeOut)
|
||||
throw()
|
||||
{
|
||||
Ptr<FadeInfo>::Ref oldFadeInfo = playlistElement->getFadeInfo();
|
||||
Ptr<time_duration>::Ref oldFadeIn;
|
||||
if (oldFadeInfo) {
|
||||
if (*oldFadeInfo->getFadeOut() == *newFadeOut) {
|
||||
return;
|
||||
}
|
||||
oldFadeIn = oldFadeInfo->getFadeIn();
|
||||
} else {
|
||||
oldFadeIn.reset(new time_duration(0,0,0,0));
|
||||
|
@ -431,6 +492,7 @@ GLiveSupport :: setFadeOut(Ptr<PlaylistElement>::Ref playlistElement,
|
|||
oldFadeIn, newFadeOut ));
|
||||
if (isLengthOkay(playlistElement, newFadeInfo)) {
|
||||
playlistElement->setFadeInfo(newFadeInfo);
|
||||
isPlaylistModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,12 +501,13 @@ GLiveSupport :: setFadeOut(Ptr<PlaylistElement>::Ref playlistElement,
|
|||
* Auxilliary function: check that fades are not longer than the whole clip.
|
||||
*----------------------------------------------------------------------------*/
|
||||
inline bool
|
||||
GLiveSupport :: isLengthOkay(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
SimplePlaylistManagementWindow :: isLengthOkay(
|
||||
Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<FadeInfo>::Ref newFadeInfo)
|
||||
throw()
|
||||
{
|
||||
time_duration totalFades = *newFadeInfo->getFadeIn()
|
||||
+ *newFadeInfo->getFadeOut();
|
||||
return (totalFades < *playlistElement->getPlayable()->getPlaylength());
|
||||
return (totalFades <= *playlistElement->getPlayable()->getPlaylength());
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.10 $
|
||||
Version : $Revision: 1.11 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -81,13 +81,14 @@ using namespace LiveSupport::Widgets;
|
|||
* | | +-- entry2 ----------------------------+ | |
|
||||
* | | ... | |
|
||||
* | +------------------------------------------+ |
|
||||
* | +- lock fades checkbox -+ |
|
||||
* | +- save button -+ +- close button -+ |
|
||||
* | +-- status bar ----------------------------+ |
|
||||
* +----------------------------------------------+
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.10 $
|
||||
* @version $Revision: 1.11 $
|
||||
*/
|
||||
class SimplePlaylistManagementWindow : public WhiteWindow,
|
||||
public LocalizedObject
|
||||
|
@ -108,6 +109,46 @@ class SimplePlaylistManagementWindow : public WhiteWindow,
|
|||
int columnId,
|
||||
const Glib::ustring & newText) throw();
|
||||
|
||||
/**
|
||||
* Set the fade in of a playlist element.
|
||||
*/
|
||||
void
|
||||
setFadeIn(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeIn) throw();
|
||||
|
||||
/**
|
||||
* Set the fade out of a playlist element.
|
||||
*/
|
||||
void
|
||||
setFadeOut(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeOut) throw();
|
||||
|
||||
/**
|
||||
* Check that fades are not longer than the whole clip.
|
||||
*
|
||||
* @return true if (fadeIn + fadeOut <= playlength).
|
||||
*/
|
||||
bool
|
||||
isLengthOkay(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<FadeInfo>::Ref newFadeInfo) throw();
|
||||
|
||||
/**
|
||||
* Cancel the edited playlist.
|
||||
* Cancel the edited playlist in GLiveSupport, and close the window.
|
||||
*
|
||||
* @see GLiveSupport::cancelEditedPlaylist()
|
||||
* @see closeWindow()
|
||||
*/
|
||||
void
|
||||
cancelPlaylist(void) throw();
|
||||
|
||||
/**
|
||||
* Clean and close the window.
|
||||
* Set all widgets to empty and close the window.
|
||||
*/
|
||||
void
|
||||
closeWindow(void) throw();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -116,7 +157,7 @@ class SimplePlaylistManagementWindow : public WhiteWindow,
|
|||
* Lists one playlist entry per row.
|
||||
*
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.10 $
|
||||
* @version $Revision: 1.11 $
|
||||
*/
|
||||
class ModelColumns : public ZebraTreeModelColumnRecord
|
||||
{
|
||||
|
@ -221,6 +262,18 @@ class SimplePlaylistManagementWindow : public WhiteWindow,
|
|||
*/
|
||||
Ptr<DialogWindow>::Ref dialogWindow;
|
||||
|
||||
/**
|
||||
* A flag set to true when the edited playlist is modified.
|
||||
*/
|
||||
bool isPlaylistModified;
|
||||
|
||||
/**
|
||||
* A flag controlled by the "lock fades" check button.
|
||||
* This determines whether the fade-out of a clip is assumed to
|
||||
* be equal to the fade-in of the next clip.
|
||||
*/
|
||||
bool areFadesLocked;
|
||||
|
||||
/**
|
||||
* Save the edited playlist.
|
||||
*
|
||||
|
@ -241,6 +294,12 @@ class SimplePlaylistManagementWindow : public WhiteWindow,
|
|||
virtual void
|
||||
onCloseButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the "lock fades" check button toggled.
|
||||
*/
|
||||
virtual void
|
||||
onLockFadesCheckButtonClicked(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -273,27 +332,6 @@ class SimplePlaylistManagementWindow : public WhiteWindow,
|
|||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
/**
|
||||
* Auxilliary function: set the fade in of a playlist element.
|
||||
*/
|
||||
void
|
||||
setFadeIn(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeIn) throw();
|
||||
|
||||
/**
|
||||
* Auxilliary function: set the fade out of a playlist element.
|
||||
*/
|
||||
void
|
||||
setFadeOut(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<time_duration>::Ref newFadeOut) throw();
|
||||
|
||||
/**
|
||||
* Auxilliary function: check that fades are not longer than
|
||||
* the whole clip.
|
||||
*/
|
||||
bool
|
||||
isLengthOkay(Ptr<PlaylistElement>::Ref playlistElement,
|
||||
Ptr<FadeInfo>::Ref newFadeInfo) throw();
|
||||
|
||||
} // namespace GLiveSupport
|
||||
} // namespace LiveSupport
|
||||
|
|
|
@ -117,6 +117,8 @@ root:table
|
|||
nameLabel:string { "Name" }
|
||||
saveButtonLabel:string { "Save" }
|
||||
closeButtonLabel:string { "Close" }
|
||||
lockFadesCheckButtonLabel:string
|
||||
{ "Lock fade-out to following fade-in" }
|
||||
statusBar:string { "status bar" }
|
||||
playlistSavedMsg:string { "Saved playlist ''{0}''." }
|
||||
savePlaylistDialogMsg:string { "Do you want to save the playlist?" }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue