File indexing completed on 2024-04-14 05:39:24
0001 /* 0002 SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "statusBar.h" 0008 0009 #include <QComboBox> 0010 #include <QLabel> 0011 #include <QPushButton> 0012 #include <QTime> 0013 0014 #include <KLocalizedString> 0015 0016 #include "ksystemlog_debug.h" 0017 using namespace KSystemLog; 0018 StatusBar::StatusBar(QWidget *parent) 0019 : QStatusBar(parent) 0020 { 0021 mLineCountLabel = new QLabel(this); 0022 mLineCountLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); 0023 mLineCountLabel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 0024 mLineCountLabel->setLineWidth(2); 0025 mLineCountLabel->setMidLineWidth(2); 0026 addPermanentWidget(mLineCountLabel, 1); 0027 mMessageList = new QComboBox(this); 0028 mMessageList->setInsertPolicy(QComboBox::InsertAtTop); 0029 mMessageList->setMaxVisibleItems(5); 0030 connect(mMessageList, &QComboBox::currentIndexChanged, this, &StatusBar::selectLastHistory); 0031 addPermanentWidget(mMessageList, 4); 0032 0033 mLastModificationLabel = new QLabel(this); 0034 mLastModificationLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 0035 mLastModificationLabel->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); 0036 mLastModificationLabel->setLineWidth(2); 0037 mLastModificationLabel->setMidLineWidth(2); 0038 addPermanentWidget(mLastModificationLabel, 1); 0039 } 0040 0041 StatusBar::~StatusBar() 0042 { 0043 } 0044 0045 void StatusBar::changeLineCountMessage(const QString &lineCountMessage) 0046 { 0047 mLineCountLabel->setText(lineCountMessage); 0048 } 0049 0050 void StatusBar::changeLastModification(QTime lastModification) 0051 { 0052 // lastModificationLabel->setText(i18n("Last updated: %1.", 0053 // KLocale::global()->formatTime(lastModification, true, false) )); 0054 mLastModificationLabel->setText(i18n("Last updated: %1.", QLocale().toString(lastModification, QStringLiteral("hh:mm:ss")))); 0055 } 0056 0057 void StatusBar::changeMessage(const QString &message) 0058 { 0059 // messageLabel->setText(message); 0060 // messageList->insertItem(0, i18n("%1: %2", KLocale::global()->formatTime(QTime::currentTime(), true, 0061 // false), message)); 0062 mMessageList->insertItem(0, i18n("%1: %2", QLocale().toString(QTime::currentTime(), QStringLiteral("hh:mm:ss")), message)); 0063 0064 // 100 log history message max. 0065 if (mMessageList->count() > 100) { 0066 mMessageList->removeItem(mMessageList->count() - 1); 0067 } 0068 } 0069 0070 void StatusBar::selectLastHistory() 0071 { 0072 mMessageList->setCurrentIndex(0); 0073 } 0074 0075 void StatusBar::toggleHistory() 0076 { 0077 qCDebug(KSYSTEMLOG) << "Toggling History..."; 0078 mMessageList->showPopup(); 0079 } 0080 0081 #include "moc_statusBar.cpp"