Load arbitrary schemes by path via setColorScheme().
This commit is contained in:
+22
-3
@@ -360,12 +360,31 @@ void QTermWidget::setTextCodec(QTextCodec *codec)
|
||||
m_impl->m_session->setCodec(codec);
|
||||
}
|
||||
|
||||
void QTermWidget::setColorScheme(const QString & name)
|
||||
void QTermWidget::setColorScheme(const QString& origName)
|
||||
{
|
||||
const ColorScheme *cs;
|
||||
const ColorScheme *cs = 0;
|
||||
|
||||
const bool isFile = QFile::exists(origName);
|
||||
const QString& name = isFile ?
|
||||
QFileInfo(origName).baseName() :
|
||||
origName;
|
||||
|
||||
// avoid legacy (int) solution
|
||||
if (!availableColorSchemes().contains(name))
|
||||
cs = ColorSchemeManager::instance()->defaultColorScheme();
|
||||
{
|
||||
if (isFile)
|
||||
{
|
||||
if (ColorSchemeManager::instance()->loadCustomColorScheme(origName))
|
||||
cs = ColorSchemeManager::instance()->findColorScheme(name);
|
||||
else
|
||||
qWarning () << Q_FUNC_INFO
|
||||
<< "cannot load color scheme from"
|
||||
<< origName;
|
||||
}
|
||||
|
||||
if (!cs)
|
||||
cs = ColorSchemeManager::instance()->defaultColorScheme();
|
||||
}
|
||||
else
|
||||
cs = ColorSchemeManager::instance()->findColorScheme(name);
|
||||
|
||||
|
||||
+5
-1
@@ -84,7 +84,11 @@ public:
|
||||
//Text codec, default is UTF-8
|
||||
void setTextCodec(QTextCodec * codec);
|
||||
|
||||
//Color scheme, default is white on black
|
||||
/** @brief Sets the color scheme, default is white on black
|
||||
*
|
||||
* @param[in] name The name of the color scheme, either returned from
|
||||
* availableColorSchemes() or a full path to a color scheme.
|
||||
*/
|
||||
void setColorScheme(const QString & name);
|
||||
static QStringList availableColorSchemes();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user