forked from qt-creator/qt-creator
Temporary "feature" to allow user specific MIME types
We need a feature which allows a more flexible binding of MIME types and editors. This is definetely not the way to handle it, but a temporary workaround. Reviewed-by: con
This commit is contained in:
@@ -87,6 +87,7 @@
|
|||||||
#include <QtCore/QtPlugin>
|
#include <QtCore/QtPlugin>
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QFile>
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QtGui/QCloseEvent>
|
#include <QtGui/QCloseEvent>
|
||||||
@@ -339,6 +340,8 @@ void MainWindow::extensionsInitialized()
|
|||||||
readSettings();
|
readSettings();
|
||||||
updateContext();
|
updateContext();
|
||||||
|
|
||||||
|
registerUserMimeTypes();
|
||||||
|
|
||||||
emit m_coreImpl->coreAboutToOpen();
|
emit m_coreImpl->coreAboutToOpen();
|
||||||
show();
|
show();
|
||||||
emit m_coreImpl->coreOpened();
|
emit m_coreImpl->coreOpened();
|
||||||
@@ -1383,3 +1386,15 @@ bool MainWindow::showWarningWithOptions(const QString &title,
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::registerUserMimeTypes() const
|
||||||
|
{
|
||||||
|
// This is to temporarily allow user specific MIME types (without recompilation).
|
||||||
|
// Be careful with the file contents. Otherwise unpredictable behavior might arise.
|
||||||
|
const QString &fileName = m_coreImpl->userResourcePath() + QLatin1String("/mimetypes.xml");
|
||||||
|
if (QFile::exists(fileName)) {
|
||||||
|
QString error;
|
||||||
|
if (!m_coreImpl->mimeDatabase()->addMimeTypes(fileName, &error))
|
||||||
|
qWarning() << error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -177,6 +177,8 @@ private:
|
|||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
void registerUserMimeTypes() const;
|
||||||
|
|
||||||
CoreImpl *m_coreImpl;
|
CoreImpl *m_coreImpl;
|
||||||
UniqueIDManager *m_uniqueIDManager;
|
UniqueIDManager *m_uniqueIDManager;
|
||||||
Context m_additionalContexts;
|
Context m_additionalContexts;
|
||||||
|
|||||||
Reference in New Issue
Block a user