Commit ffd821d3 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

allow to configure when to show the messages pane

parent 372485eb
......@@ -335,7 +335,7 @@ void BranchesDialog::sendMessage(const QString &plainText, bool warn)
{
// use generic output view
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Warning") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Error") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("category"), i18n("Git"));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT m_pluginView->message(genericMessage);
......
......@@ -129,7 +129,7 @@ void GitWidget::sendMessage(const QString &plainText, bool warn)
{
// use generic output view
QVariantMap genericMessage;
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Warning") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("type"), warn ? QStringLiteral("Error") : QStringLiteral("Info"));
genericMessage.insert(QStringLiteral("category"), i18n("Git"));
genericMessage.insert(QStringLiteral("plainText"), plainText);
Q_EMIT m_pluginView->message(genericMessage);
......
......@@ -81,6 +81,17 @@ void KateConfigDialog::addBehaviorPage()
QVBoxLayout *vbox = new QVBoxLayout;
layout->addWidget(buttonGroup);
auto hlayout = new QHBoxLayout;
auto label = new QLabel(i18n("&Switch to output view upon message type:"), buttonGroup);
hlayout->addWidget(label);
m_messageTypes = new QComboBox(buttonGroup);
hlayout->addWidget(m_messageTypes);
label->setBuddy(m_messageTypes);
m_messageTypes->addItems({i18n("Never"), i18n("Error"), i18n("Warning"), i18n("Info"), i18n("Log")});
m_messageTypes->setCurrentIndex(cgGeneral.readEntry("Show output view for message type", 1));
connect(m_messageTypes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &KateConfigDialog::slotChanged);
vbox->addLayout(hlayout);
// modified files notification
m_modNotifications = new QCheckBox(i18n("Wa&rn about files modified by foreign processes"), buttonGroup);
m_modNotifications->setChecked(m_mainWindow->modNotificationEnabled());
......@@ -99,8 +110,8 @@ void KateConfigDialog::addBehaviorPage()
buttonGroup = new QGroupBox(i18n("&Tabs"), generalFrame);
vbox = new QVBoxLayout;
buttonGroup->setLayout(vbox);
auto hlayout = new QHBoxLayout;
auto label = new QLabel(i18n("&Limit number of tabs:"), buttonGroup);
hlayout = new QHBoxLayout;
label = new QLabel(i18n("&Limit number of tabs:"), buttonGroup);
hlayout->addWidget(label);
m_tabLimit = new QSpinBox(buttonGroup);
hlayout->addWidget(m_tabLimit);
......@@ -331,6 +342,8 @@ void KateConfigDialog::slotApply()
cg.writeEntry("Close After Last", sessionConfigUi.modCloseAfterLast->isChecked());
m_mainWindow->setModCloseAfterLast(sessionConfigUi.modCloseAfterLast->isChecked());
cg.readEntry("Show output view for message type", m_messageTypes->currentIndex());
cg.writeEntry("Tabbar Tab Limit", m_tabLimit->value());
cg.writeEntry("Show Tabs Close Button", m_showTabCloseButton->isChecked());
......
......@@ -78,6 +78,7 @@ private:
bool m_dataChanged = false;
QComboBox *m_messageTypes;
QCheckBox *m_modNotifications;
QComboBox *m_cmbQuickOpenListMode;
QSpinBox *m_tabLimit;
......
......@@ -5,9 +5,12 @@
*/
#include "kateoutputview.h"
#include "kateapp.h"
#include "katemainwindow.h"
#include <KConfigGroup>
#include <KLocalizedString>
#include <KSharedConfig>
#include <QDateTime>
#include <QPainter>
......@@ -87,6 +90,19 @@ KateOutputView::KateOutputView(KateMainWindow *mainWindow, QWidget *parent)
// we want a special delegate to render the message body, as that might be plain text
// mark down or HTML
m_messagesTreeView->setItemDelegateForColumn(3, &m_messageBodyDelegate);
// read config once
readConfig();
// handle config changes
connect(KateApp::self(), &KateApp::configurationChanged, this, &KateOutputView::readConfig);
}
void KateOutputView::readConfig()
{
KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup cgGeneral = KConfigGroup(config, "General");
m_showOutputViewForMessageType = cgGeneral.readEntry("Show output view for message type", 1);
}
void KateOutputView::slotMessage(const QVariantMap &message)
......@@ -106,17 +122,19 @@ void KateOutputView::slotMessage(const QVariantMap &message)
auto typeColumn = new QStandardItem();
const auto typeString = message.value(QStringLiteral("type")).toString();
if (typeString == QLatin1String("Error")) {
shouldShowOutputToolView = true;
shouldShowOutputToolView = (m_showOutputViewForMessageType >= 1);
typeColumn->setText(i18nc("@info", "Error"));
typeColumn->setIcon(QIcon::fromTheme(QStringLiteral("data-error")));
} else if (typeString == QLatin1String("Warning")) {
shouldShowOutputToolView = true;
shouldShowOutputToolView = (m_showOutputViewForMessageType >= 2);
typeColumn->setText(i18nc("@info", "Warning"));
typeColumn->setIcon(QIcon::fromTheme(QStringLiteral("data-warning")));
} else if (typeString == QLatin1String("Info")) {
shouldShowOutputToolView = (m_showOutputViewForMessageType >= 3);
typeColumn->setText(i18nc("@info", "Info"));
typeColumn->setIcon(QIcon::fromTheme(QStringLiteral("data-information")));
} else {
shouldShowOutputToolView = (m_showOutputViewForMessageType >= 4);
typeColumn->setText(i18nc("@info", "Log"));
}
......
......@@ -51,6 +51,11 @@ public:
KateOutputView(KateMainWindow *mainWindow, QWidget *parent);
public Q_SLOTS:
/**
* Read and apply our configuration.
*/
void readConfig();
/**
* slot for incoming messages
* @param message incoming message we shall handle
......@@ -109,6 +114,16 @@ private:
* Our special output delegate for the message body
*/
KateOutputMessageStyledDelegate m_messageBodyDelegate;
/**
* When to show output view
* 0 => never
* 1 => on error
* 2 => on warning or above
* 3 => on info or above
* 4 => on log or above
*/
int m_showOutputViewForMessageType = 1;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment