Skip to content

Commit

Permalink
Log: print "Date changed" message in all tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici committed Jul 25, 2018
1 parent fd6f727 commit 3bf8a96
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/mumble/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,19 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own

// Message output on console
if ((flags & Settings::LogConsole)) {
if (qdDate != dt.date()) {
qdDate = dt.date();

const LogTabList tabs = g.mw->qtwLogTabs->getTabs();
foreach(int tab, tabs) {
LogTab *tlog = dynamic_cast<LogTab *>(g.mw->qtwLogTabs->widget(tab));
QTextCursor tc = tlog->textCursor();
tc.insertBlock();
tc.insertHtml(tr("[Date changed to %1]\n").arg(Qt::escape(qdDate.toString(Qt::DefaultLocaleShortDate))));
tc.movePosition(QTextCursor::End);
}
}

if (tabToLog == -1 || tabToLog > g.mw->qtwLogTabs->count()) {
tabToLog = g.mw->qtwLogTabs->getGeneralTab();
}
Expand All @@ -474,13 +487,6 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own

tc.movePosition(QTextCursor::End);

if (qdDate != dt.date()) {
qdDate = dt.date();
tc.insertBlock();
tc.insertHtml(tr("[Date changed to %1]\n").arg(Qt::escape(qdDate.toString(Qt::DefaultLocaleShortDate))));
tc.movePosition(QTextCursor::End);
}

if (plain.contains(QRegExp(QLatin1String("[\\r\\n]")))) {
QTextFrameFormat qttf;
qttf.setBorder(1);
Expand Down
11 changes: 11 additions & 0 deletions src/mumble/LogTabs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ int LogTabWidget::getTab(QString qsHash) {
return iter != m_hashMap.constEnd() ? iter.value() : -1;
}

TabsList LogTabWidget::getTabs() {
TabsList tabs;
HashMap::const_iterator iter = m_hashMap.constBegin();
while (iter != m_hashMap.constEnd()) {
tabs.append(iter.value().first);
++iter;
}

return tabs;
}

int LogTabWidget::getGeneralTab() {
return m_hashMap.find(QString::fromUtf8("general")).value();
}
Expand Down
1 change: 1 addition & 0 deletions src/mumble/LogTabs.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class LogTabWidget : public QTabWidget {
int getTab(QString);
int getGeneralTab();
int getCurrentTab();
LogTabList getTabs();
LogTabList getChannelTabs();
QString getHash(int);
bool isChannelTab(int);
Expand Down

0 comments on commit 3bf8a96

Please sign in to comment.