Chris Cannam wrote:
> Guillaume Laurent wrote:
>> I think it will simply default to the last directory opened by a
>> KDE app not using any tag. I'm not sure if it can be overridden,
>> though.
>
> I'm not so much saying "can we override it" as "we need to find a way
> to override it".
We can work-around it.
I wanted to solve a similar problem to the one you described
without having to wait for a solution in a future version of KDE.
The attached patch is my solution. It may do what you're looking for.
The drawback, if that is what it is, is in not following
the one true path in KDE.
William
--- rosegarden.orig/gui/rosegardengui.cpp 2004-07-23 14:32:46.000000000 +0100
+++ rosegarden/gui/rosegardengui.cpp 2004-07-25 11:47:22.000000000 +0100
@@ -1668,7 +1668,12 @@
_settingLog(QString("SETTING 1 : show track labels =
%1").arg(m_viewTrackLabels->isChecked()));
#endif
- bool canClose = m_doc->saveIfModified();
+ bool canClose;
+
+ if (m_doc->getComposition().getNbSegments() > 0)
+ canClose = m_doc->saveIfModified();
+ else
+ canClose = true;
/*
if (canClose && m_transport) {
@@ -1717,12 +1722,16 @@
bool makeNew = false;
- if (!m_doc->isModified()) {
- makeNew = true;
- // m_doc->closeDocument();
- } else if (m_doc->saveIfModified()) {
- makeNew = true;
+ if (m_doc->getComposition().getNbSegments() > 0) {
+ if (!m_doc->isModified()) {
+ makeNew = true;
+ // m_doc->closeDocument();
+ } else if (m_doc->saveIfModified()) {
+ makeNew = true;
+ }
}
+ else
+ makeNew = true;
if (makeNew) {
@@ -1754,7 +1763,7 @@
QString netFile = url.prettyURL();
RG_DEBUG << "RosegardenGUIApp::openURL: KURL " << netFile << endl;
- if (url.isMalformed()) {
+ if (!url.isValid()) {
QString string;
string = i18n( "Malformed URL\n%1").arg(netFile);
@@ -1772,7 +1781,9 @@
RG_DEBUG << "RosegardenGUIApp::openURL: target : " << target << endl;
- if (!m_doc->saveIfModified()) return;
+ if (m_doc)
+ if (m_doc->getComposition().getNbSegments() > 0)
+ if (!m_doc->saveIfModified()) return;
openFile(target);
@@ -1781,28 +1792,50 @@
void RosegardenGUIApp::slotFileOpen()
{
+ QString fileTypes, defaultURL, defaultFilter;
+ QStringList fileTypesList;
+ KConfig *config = KGlobal::config();
+ config->setGroup("KFileDialog Settings");
+
+ /* William's "fix" for limitations of KDE's KFileDialog */
+ fileTypes = config->readEntry("Supported File Types", "audio/x-rosegarden
audio/x-midi audio/x-rosegarden21");
+ fileTypesList = QStringList::split( " ", fileTypes, false);
+ defaultURL = config->readEntry("Initial Directory",
"/opt/kde/share/apps/rosegarden/library/");
+ defaultFilter = config->readEntry("Default Filter", QString::null);
+ if ( defaultFilter != QString::null )
+ fileTypesList.prepend("all/allfiles"); /* allsupportedfiles is hidden inside
KFileDialog combo boxes */
+
+ KFileDialog * d = new KFileDialog(defaultURL, defaultFilter, this, i18n("Open
File"), false);
+
slotStatusHelpMsg(i18n("Opening file..."));
- KURL url = KFileDialog::getOpenURL
- (
-#if KDE_VERSION >= 196614
- ":ROSEGARDEN",
-#else
- QString::null,
-#endif
- "audio/x-rosegarden audio/x-midi audio/x-rosegarden21", this,
- i18n("Open File"));
- if ( url.isEmpty() ) { return; }
+ d->setMimeFilter(fileTypesList, defaultFilter);
+ KURL url;
+ if ( d->exec() == QDialog::Accepted )
+ url = d->selectedURL();
+ else {
+ delete d;
+ return;
+ }
- if (m_doc) {
-
- if (!m_doc->saveIfModified()) {
- return;
-
- }
+ if ( url.isEmpty() ) {
+ delete d;
+ return;
}
+ if (m_doc)
+ if (m_doc->getComposition().getNbSegments() > 0)
+ if (!m_doc->saveIfModified()) {
+ delete d;
+ return;
+ }
+
+ config->writeEntry("Initial Directory", d->baseURL().path());
+ config->writeEntry("Default Filter", d->currentMimeFilter());
+ config->sync();
+
openURL(url);
+ delete d;
}
void RosegardenGUIApp::slotMerge()
@@ -1837,11 +1870,11 @@
KTmpStatusMsg msg(i18n("Opening file..."), this);
if (m_doc) {
-
- if (!m_doc->saveIfModified()) {
- return;
-
- }
+ if (m_doc->getComposition().getNbSegments() > 0) {
+ if (!m_doc->saveIfModified()) {
+ return;
+ }
+ }
}
openURL(url);
@@ -1883,16 +1916,16 @@
// KFileDialog::getSaveFileName
KFileDialog saveFileDialog(":ROSEGARDEN", descriptiveExtension, this, label,
true);
if (m_doc) {
- QString saveFileName=m_doc->getAbsFilePath();
+ QString saveFileName = m_doc->getAbsFilePath();
// Show filename without the old extension
- int dotLoc=saveFileName.findRev('.');
+ int dotLoc = saveFileName.findRev('.');
if (dotLoc > int(saveFileName.length() - 4)) {
- saveFileName=saveFileName.left(dotLoc);
+ saveFileName = saveFileName.left(dotLoc);
}
saveFileDialog.setSelection(saveFileName);
}
saveFileDialog.exec();
- QString name=saveFileDialog.selectedFile();
+ QString name = saveFileDialog.selectedFile();
// RG_DEBUG << "RosegardenGUIApp::getValidWriteFile() :
KFileDialog::getSaveFileName returned "
// << name << endl;
@@ -1911,7 +1944,7 @@
KURL *u = new KURL(name);
- if (u->isMalformed()) {
+ if (!u->isValid()) {
KMessageBox::sorry(this, i18n("This is not a valid filename.\n"));
return "";
}
@@ -1969,8 +2002,10 @@
KTmpStatusMsg msg(i18n("Closing file..."), this);
- if (m_doc->saveIfModified()) {
- setDocument(new RosegardenGUIDoc(this, m_pluginManager));
+ if (m_doc->getComposition().getNbSegments() > 0) {
+ if (m_doc->saveIfModified()) {
+ setDocument(new RosegardenGUIDoc(this, m_pluginManager));
+ }
}
// Don't close the whole view (i.e. Quit), just close the doc.