Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 669:331be52cd473 single-point
Permit subclass to determine window title format
author | Chris Cannam |
---|---|
date | Tue, 14 May 2019 14:51:09 +0100 |
parents | 31ea416fea3c |
children | 5e9b1956b609 |
comparison
equal
deleted
inserted
replaced
667:31ea416fea3c | 669:331be52cd473 |
---|---|
746 bool recordDeviceFailed = (m_playTarget != nullptr && m_audioIO == nullptr); | 746 bool recordDeviceFailed = (m_playTarget != nullptr && m_audioIO == nullptr); |
747 emit canRecord(!recordDisabled && !recordDeviceFailed); | 747 emit canRecord(!recordDisabled && !recordDeviceFailed); |
748 } | 748 } |
749 | 749 |
750 void | 750 void |
751 MainWindowBase::updateWindowTitle() | |
752 { | |
753 QString title; | |
754 | |
755 if (m_sessionFile != "") { | |
756 if (m_originalLocation != "" && | |
757 m_originalLocation != m_sessionFile) { // session + location | |
758 title = tr("%1: %2 [%3]") | |
759 .arg(QApplication::applicationName()) | |
760 .arg(QFileInfo(m_sessionFile).fileName()) | |
761 .arg(m_originalLocation); | |
762 } else { // session only | |
763 title = tr("%1: %2") | |
764 .arg(QApplication::applicationName()) | |
765 .arg(QFileInfo(m_sessionFile).fileName()); | |
766 } | |
767 } else { | |
768 if (m_originalLocation != "") { // location only | |
769 title = tr("%1: %2") | |
770 .arg(QApplication::applicationName()) | |
771 .arg(m_originalLocation); | |
772 } else { // neither | |
773 title = QApplication::applicationName(); | |
774 } | |
775 } | |
776 | |
777 if (m_documentModified) { | |
778 title = tr("%1 (modified)").arg(title); | |
779 } | |
780 | |
781 setWindowTitle(title); | |
782 } | |
783 | |
784 void | |
751 MainWindowBase::documentModified() | 785 MainWindowBase::documentModified() |
752 { | 786 { |
753 // SVDEBUG << "MainWindowBase::documentModified" << endl; | 787 // SVDEBUG << "MainWindowBase::documentModified" << endl; |
754 | 788 |
755 if (!m_documentModified) { | |
756 //!!! this in subclass implementation? | |
757 setWindowTitle(tr("%1 (modified)").arg(windowTitle())); | |
758 } | |
759 | |
760 m_documentModified = true; | 789 m_documentModified = true; |
790 updateWindowTitle(); | |
761 updateMenuStates(); | 791 updateMenuStates(); |
762 } | 792 } |
763 | 793 |
764 void | 794 void |
765 MainWindowBase::documentRestored() | 795 MainWindowBase::documentRestored() |
766 { | 796 { |
767 // SVDEBUG << "MainWindowBase::documentRestored" << endl; | 797 // SVDEBUG << "MainWindowBase::documentRestored" << endl; |
768 | 798 |
769 if (m_documentModified) { | |
770 //!!! this in subclass implementation? | |
771 QString wt(windowTitle()); | |
772 wt.replace(tr(" (modified)"), ""); | |
773 setWindowTitle(wt); | |
774 } | |
775 | |
776 m_documentModified = false; | 799 m_documentModified = false; |
800 updateWindowTitle(); | |
777 updateMenuStates(); | 801 updateMenuStates(); |
778 } | 802 } |
779 | 803 |
780 void | 804 void |
781 MainWindowBase::playLoopToggled() | 805 MainWindowBase::playLoopToggled() |
1661 SVDEBUG << "Now switching to ReplaceMainModel mode" << endl; | 1685 SVDEBUG << "Now switching to ReplaceMainModel mode" << endl; |
1662 mode = ReplaceMainModel; | 1686 mode = ReplaceMainModel; |
1663 } | 1687 } |
1664 | 1688 |
1665 emit activity(tr("Import audio file \"%1\"").arg(source.getLocation())); | 1689 emit activity(tr("Import audio file \"%1\"").arg(source.getLocation())); |
1666 | 1690 |
1667 if (mode == ReplaceMainModel) { | 1691 if (mode == ReplaceMainModel) { |
1668 | 1692 |
1669 Model *prevMain = getMainModel(); | 1693 Model *prevMain = getMainModel(); |
1670 if (prevMain) { | 1694 if (prevMain) { |
1671 m_playSource->removeModel(prevMain); | 1695 m_playSource->removeModel(prevMain); |
1677 | 1701 |
1678 m_document->setMainModel(newModel); | 1702 m_document->setMainModel(newModel); |
1679 | 1703 |
1680 setupMenus(); | 1704 setupMenus(); |
1681 | 1705 |
1706 m_originalLocation = source.getLocation(); | |
1707 | |
1682 if (loadedTemplate || (m_sessionFile == "")) { | 1708 if (loadedTemplate || (m_sessionFile == "")) { |
1683 //!!! shouldn't be dealing directly with title from here -- call a method | |
1684 setWindowTitle(tr("%1: %2") | |
1685 .arg(QApplication::applicationName()) | |
1686 .arg(source.getLocation())); | |
1687 CommandHistory::getInstance()->clear(); | 1709 CommandHistory::getInstance()->clear(); |
1688 CommandHistory::getInstance()->documentSaved(); | 1710 CommandHistory::getInstance()->documentSaved(); |
1689 m_documentModified = false; | 1711 m_documentModified = false; |
1690 } else { | 1712 } else { |
1691 setWindowTitle(tr("%1: %2 [%3]") | |
1692 .arg(QApplication::applicationName()) | |
1693 .arg(QFileInfo(m_sessionFile).fileName()) | |
1694 .arg(source.getLocation())); | |
1695 if (m_documentModified) { | 1713 if (m_documentModified) { |
1696 m_documentModified = false; | 1714 m_documentModified = false; |
1697 documentModified(); // so as to restore "(modified)" window title | |
1698 } | 1715 } |
1699 } | 1716 } |
1700 | 1717 |
1701 if (!source.isRemote() && registerSource) { | 1718 if (!source.isRemote() && registerSource) { |
1702 m_audioFile = source.getLocalFilename(); | 1719 m_audioFile = source.getLocalFilename(); |
1703 } | 1720 } |
1704 | 1721 |
1722 updateWindowTitle(); | |
1723 | |
1705 } else if (mode == CreateAdditionalModel) { | 1724 } else if (mode == CreateAdditionalModel) { |
1706 | 1725 |
1707 SVCERR << "Mode is CreateAdditionalModel" << endl; | 1726 SVCERR << "Mode is CreateAdditionalModel" << endl; |
1708 | 1727 |
1709 CommandHistory::getInstance()->startCompoundOperation | 1728 CommandHistory::getInstance()->startCompoundOperation |
2162 | 2181 |
2163 if (ok) { | 2182 if (ok) { |
2164 | 2183 |
2165 emit activity(tr("Import session file \"%1\"").arg(source.getLocation())); | 2184 emit activity(tr("Import session file \"%1\"").arg(source.getLocation())); |
2166 | 2185 |
2167 setWindowTitle(tr("%1: %2") | |
2168 .arg(QApplication::applicationName()) | |
2169 .arg(source.getLocation())); | |
2170 | |
2171 if (!source.isRemote() && !m_document->isIncomplete()) { | 2186 if (!source.isRemote() && !m_document->isIncomplete()) { |
2172 // Setting the session file path enables the Save (as | 2187 // Setting the session file path enables the Save (as |
2173 // opposed to Save As...) option. We can't do this if we | 2188 // opposed to Save As...) option. We can't do this if we |
2174 // don't have a local path to save to, but we also don't | 2189 // don't have a local path to save to, but we also don't |
2175 // want to do it if we failed to find an audio file or | 2190 // want to do it if we failed to find an audio file or |
2182 tr("Incomplete session loaded"), | 2197 tr("Incomplete session loaded"), |
2183 tr("Some of the audio content referred to by the original session file could not be loaded.\nIf you save this session, it will be saved without any reference to that audio, and information may be lost."), | 2198 tr("Some of the audio content referred to by the original session file could not be loaded.\nIf you save this session, it will be saved without any reference to that audio, and information may be lost."), |
2184 QMessageBox::Ok); | 2199 QMessageBox::Ok); |
2185 } | 2200 } |
2186 | 2201 |
2202 updateWindowTitle(); | |
2187 setupMenus(); | 2203 setupMenus(); |
2188 findTimeRulerLayer(); | 2204 findTimeRulerLayer(); |
2189 | 2205 |
2190 CommandHistory::getInstance()->clear(); | 2206 CommandHistory::getInstance()->clear(); |
2191 CommandHistory::getInstance()->documentSaved(); | 2207 CommandHistory::getInstance()->documentSaved(); |
2198 // for file dialog | 2214 // for file dialog |
2199 registerLastOpenedFilePath(FileFinder::SessionFile, | 2215 registerLastOpenedFilePath(FileFinder::SessionFile, |
2200 source.getLocalFilename()); | 2216 source.getLocalFilename()); |
2201 } | 2217 } |
2202 | 2218 |
2219 m_originalLocation = source.getLocation(); | |
2220 | |
2203 emit sessionLoaded(); | 2221 emit sessionLoaded(); |
2204 | 2222 |
2205 } else { | 2223 updateWindowTitle(); |
2206 setWindowTitle(QApplication::applicationName()); | 2224 } |
2207 } | 2225 |
2208 | |
2209 return ok ? FileOpenSucceeded : FileOpenFailed; | 2226 return ok ? FileOpenSucceeded : FileOpenFailed; |
2210 } | 2227 } |
2211 | 2228 |
2212 MainWindowBase::FileOpenStatus | 2229 MainWindowBase::FileOpenStatus |
2213 MainWindowBase::openSessionTemplate(QString templateName) | 2230 MainWindowBase::openSessionTemplate(QString templateName) |
2269 delete inputSource; | 2286 delete inputSource; |
2270 delete file; | 2287 delete file; |
2271 | 2288 |
2272 bool ok = (error == ""); | 2289 bool ok = (error == ""); |
2273 | 2290 |
2274 setWindowTitle(QApplication::applicationName()); | |
2275 | |
2276 if (ok) { | 2291 if (ok) { |
2277 | 2292 |
2278 emit activity(tr("Open session template \"%1\"").arg(source.getLocation())); | 2293 emit activity(tr("Open session template \"%1\"").arg(source.getLocation())); |
2279 | 2294 |
2280 setupMenus(); | 2295 setupMenus(); |
2286 updateMenuStates(); | 2301 updateMenuStates(); |
2287 | 2302 |
2288 emit sessionLoaded(); | 2303 emit sessionLoaded(); |
2289 } | 2304 } |
2290 | 2305 |
2306 updateWindowTitle(); | |
2307 | |
2291 return ok ? FileOpenSucceeded : FileOpenFailed; | 2308 return ok ? FileOpenSucceeded : FileOpenFailed; |
2292 } | 2309 } |
2293 | 2310 |
2294 MainWindowBase::FileOpenStatus | 2311 MainWindowBase::FileOpenStatus |
2295 MainWindowBase::openSessionFromRDF(FileSource source) | 2312 MainWindowBase::openSessionFromRDF(FileSource source) |
2308 | 2325 |
2309 FileOpenStatus status = openLayersFromRDF(source); | 2326 FileOpenStatus status = openLayersFromRDF(source); |
2310 | 2327 |
2311 setupMenus(); | 2328 setupMenus(); |
2312 findTimeRulerLayer(); | 2329 findTimeRulerLayer(); |
2313 | 2330 |
2314 setWindowTitle(tr("%1: %2") | |
2315 .arg(QApplication::applicationName()) | |
2316 .arg(source.getLocation())); | |
2317 CommandHistory::getInstance()->clear(); | 2331 CommandHistory::getInstance()->clear(); |
2318 CommandHistory::getInstance()->documentSaved(); | 2332 CommandHistory::getInstance()->documentSaved(); |
2319 m_documentModified = false; | 2333 m_documentModified = false; |
2334 updateWindowTitle(); | |
2320 | 2335 |
2321 emit sessionLoaded(); | 2336 emit sessionLoaded(); |
2322 | 2337 |
2323 return status; | 2338 return status; |
2324 } | 2339 } |
3285 | 3300 |
3286 m_document->setMainModel(model); | 3301 m_document->setMainModel(model); |
3287 setupMenus(); | 3302 setupMenus(); |
3288 findTimeRulerLayer(); | 3303 findTimeRulerLayer(); |
3289 | 3304 |
3305 m_originalLocation = model->getLocation(); | |
3306 | |
3290 if (loadedTemplate || (m_sessionFile == "")) { | 3307 if (loadedTemplate || (m_sessionFile == "")) { |
3291 //!!! shouldn't be dealing directly with title from here -- call a method | |
3292 setWindowTitle(tr("%1: %2") | |
3293 .arg(QApplication::applicationName()) | |
3294 .arg(model->getLocation())); | |
3295 CommandHistory::getInstance()->clear(); | 3308 CommandHistory::getInstance()->clear(); |
3296 CommandHistory::getInstance()->documentSaved(); | 3309 CommandHistory::getInstance()->documentSaved(); |
3297 m_documentModified = false; | 3310 } |
3298 } else { | 3311 |
3299 setWindowTitle(tr("%1: %2 [%3]") | 3312 m_documentModified = false; |
3300 .arg(QApplication::applicationName()) | 3313 updateWindowTitle(); |
3301 .arg(QFileInfo(m_sessionFile).fileName()) | |
3302 .arg(model->getLocation())); | |
3303 if (m_documentModified) { | |
3304 m_documentModified = false; | |
3305 documentModified(); // so as to restore "(modified)" window title | |
3306 } | |
3307 } | |
3308 | 3314 |
3309 } else { | 3315 } else { |
3310 | 3316 |
3311 CommandHistory::getInstance()->startCompoundOperation | 3317 CommandHistory::getInstance()->startCompoundOperation |
3312 (tr("Import Recorded Audio"), true); | 3318 (tr("Import Recorded Audio"), true); |