void MainWindow::createChartView() { if (m_chartView) { m_chartView->show(); addDockWidget(INIMANAGER()->chartViewArea(), m_chartView); return; } m_chartView = new ChartView(tr("Chart View"), LOGVIEWERMANAGER()->isEmpty(currentTabWidget()), this); m_chartView->setChart(LOGVIEWERMANAGER()->chart(currentTabWidget())); addDockWidget(INIMANAGER()->chartViewArea(), m_chartView); connect(m_chartView, SIGNAL(closeTriggered()), windowsMenu(), SLOT(chartViewCloseTriggered())); }
void MainWindow::createResultView() { if (m_resultView) { m_resultView->show(); addDockWidget(INIMANAGER()->resultViewArea(), m_resultView); return; } m_resultView = new ResultView(tr("Highlighting Results"), this); m_resultView->setModel(LOGVIEWERMANAGER()->resultModel(currentTabWidget())); addDockWidget(INIMANAGER()->resultViewArea(), m_resultView); connect(m_resultView, SIGNAL(selected(int)), this, SLOT(gotoLine(int))); connect(m_resultView, SIGNAL(closeTriggered()), windowsMenu(), SLOT(resultViewCloseTriggered())); }
LogViewer::LogViewer(QWidget* parent, bool showLineNumber) : QPlainTextEdit(parent) , m_showLineNumber(showLineNumber) , m_isFirstAppend(true) , m_isZoomMode(false) , m_fileSize(0) , m_customBackgroundColor(INIMANAGER()->defaulCustomBackgroundColor()) , m_currentLineFgColor(INIMANAGER()->defaultCurrentLineFgColor()) , m_currentLineBgColor(INIMANAGER()->defaultCurrentLineBgColor()) , m_lineNumberArea(new LineNumberArea(this)) , m_keywordHighlighter(new KeywordHighlighter(document())) , m_textCodec(QTextCodec::codecForLocale()) { init(); }
void MainWindow::createFileBrowser() { if (m_fileBrowser) { // m_fileBrowser is not removed when clicked close button of dockwidget. m_fileBrowser->show(); addDockWidget(INIMANAGER()->fileBrowserArea(), m_fileBrowser); return; } m_fileBrowser = new FileBrowser(tr("File Browser"), this); addDockWidget(INIMANAGER()->fileBrowserArea(), m_fileBrowser); connect(m_fileBrowser, SIGNAL(selected(QString)), this, SLOT(openFile(QString))); connect(m_fileBrowser, SIGNAL(closeTriggered()), windowsMenu(), SLOT(fileBrowserCloseTriggered())); }
void FontSetupPage::openCurrentLineBgColorDialog() { QColorDialog *dialog = createColorDialog(INIMANAGER()->currentLineBgColor()); connect(dialog, SIGNAL(colorSelected(QColor)), this, SLOT(currentLineBgColorChanged(QColor))); dialog->open(); }
void FontSetupPage::openBackgroundColorDialog() { QColorDialog *dialog = createColorDialog(INIMANAGER()->backgroundColor()); connect(dialog, SIGNAL(colorSelected(QColor)), this, SLOT(backgroudColorChanged(QColor))); dialog->open(); }
FontSetupPage::FontSetupPage(QWidget *parent) : QWidget(parent) , m_fontGroup(0) , m_familyLabel(0) , m_styleLabel(0) , m_sizeLabel(0) , m_familyComboBox(0) , m_styleComboBox(0) , m_sizeComboBox(0) , m_colorGroup(0) , m_foregroudLabel(0) , m_backgroudLabel(0) , m_highlightLabel(0) , m_foregroudColorButton(0) , m_backgroudColorButton(0) , m_customBackgroudColorButton(0) , m_currentLineFgColorButton(0) , m_currentLineBgColorButton(0) , m_colorDialog(0) , m_plainTextEdit(0) , m_customFontEnabled(0) , m_customColorEnabled(0) { m_plainTextEdit = new LogViewer(this, false); m_plainTextEdit->setAutoFillBackground(true); m_plainTextEdit->setGeometry(330, 10, 136, 248); m_plainTextEdit->setLineWrapMode(QPlainTextEdit::NoWrap); m_plainTextEdit->setPlainText(QTextCodec::codecForName("UTF-8")->toUnicode(("안녕\nHello\nこんにちは\nЗдрасти\nПривеx\nBok\nMerhaba"))); m_plainTextEdit->setFont(INIMANAGER()->font()); initFontGroup(); initColorGroup(); }
void FontSetupPage::colorGroupChecked(const bool checked) { if (!checked) { foregroundColorChanged(INIMANAGER()->defaulForegroundColor()); backgroudColorChanged(INIMANAGER()->defaulBackgroundColor()); customBackgroudColorChanged(INIMANAGER()->defaulCustomBackgroundColor()); currentLineFgColorChanged(INIMANAGER()->defaultCurrentLineFgColor()); currentLineBgColorChanged(INIMANAGER()->defaultCurrentLineBgColor()); } else { foregroundColorChanged(static_cast<LogViewer*>(m_plainTextEdit)->forgroundColor()); backgroudColorChanged(static_cast<LogViewer*>(m_plainTextEdit)->backgroundColor()); customBackgroudColorChanged(static_cast<LogViewer*>(m_plainTextEdit)->customBackgroundColor()); currentLineFgColorChanged(static_cast<LogViewer*>(m_plainTextEdit)->currentLineFgColor()); currentLineBgColorChanged(static_cast<LogViewer*>(m_plainTextEdit)->currentLineBgColor()); } m_customColorEnabled = checked; }
void FontSetupPage::optionApplied() { INIMANAGER()->enableCustomFont(m_customFontEnabled); INIMANAGER()->enableCustomColor(m_customColorEnabled); INIMANAGER()->setFont(m_font); INIMANAGER()->setForegroundColor(m_foregroudColor); INIMANAGER()->setBackgroundColor(m_backgroudColor); INIMANAGER()->setCustomBackgroundColor(m_customBackgroudColor); INIMANAGER()->setCurrentLineFgColor(m_currentLineFgColor); INIMANAGER()->setCurrentLineBgColor(m_currentLineBgColor); }
void LogViewer::init() { setAcceptDrops(true); setReadOnly(true); setTabWidth(4); setLineWrapMode(QPlainTextEdit::NoWrap); setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); QPalette palette; palette.setColor(QPalette::Inactive, QPalette::Highlight, palette.color(QPalette::Active, QPalette::Highlight)); palette.setColor(QPalette::Inactive, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::HighlightedText)); setPalette(palette); // Read settings. setFont(INIMANAGER()->font()); setForegroundColor(INIMANAGER()->foregroundColor()); setBackgroundColor(INIMANAGER()->backgroundColor()); setCustomBackgroundColor(INIMANAGER()->customBackgroundColor()); setCurrentLineFgColor(INIMANAGER()->currentLineFgColor()); setCurrentLineBgColor(INIMANAGER()->currentLineBgColor()); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(drawCurrentLine())); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(blockCountChanged(int))); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); // Line Number. updateLineNumberAreaWidth(0); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); // Keyword Highlighter. connect(m_keywordHighlighter, SIGNAL(modelCreated(QStandardItemModel*)), this, SLOT(modelCreated(QStandardItemModel*))); connect(m_keywordHighlighter, SIGNAL(chartLoaded(QPixmap*)), this, SLOT(chartLoaded(QPixmap*))); }
void MainWindow::openFile(const QString& fileName, bool openNewTab, bool reload, bool saveCurrentDir) { if (fileName.isEmpty()) return; if (!reload && (tabCount() == 0 || openNewTab || !LOGVIEWERMANAGER()->isEmpty(currentTabWidget()))) newTab(); if (saveCurrentDir || sender() == m_fileBrowser) INIMANAGER()->setRecentDirectory(QFileInfo(fileName).absolutePath()); m_tabWidget->setTabName(currentTabIndex(), QFileInfo(fileName).fileName(), fileName); recentFilesMenu()->appendRecentFile(fileName); FILELOADMANAGER()->load(currentTabWidget(), fileName, LOGVIEWERMANAGER()->textCodec(currentTabWidget())->name()); }
void FontSetupPage::initFontGroup() { const int offsetW = 40; const int offsetH = 20; m_fontGroup = new QGroupBox(tr("Use Custom Font"), this); m_fontGroup->setCheckable(true); m_fontGroup->setChecked(INIMANAGER()->isEnableCustomFont()); m_fontGroup->setGeometry(10, 10, 270 + offsetW, 110 + offsetH); m_fontGroup->setFixedSize(270 + offsetW, 110 + offsetH); connect(m_fontGroup, SIGNAL(clicked(bool)), this, SLOT(fontGroupChecked(bool))); m_customFontEnabled = INIMANAGER()->isEnableCustomFont(); m_familyLabel = new QLabel(tr("Family"), m_fontGroup); m_familyLabel->setGeometry(10, 30, 46, 20); m_styleLabel = new QLabel(tr("Style"), m_fontGroup); m_styleLabel->setGeometry(10, 60, 46, 20); m_sizeLabel = new QLabel(tr("Size"), m_fontGroup); m_sizeLabel->setGeometry(10, 90, 46, 20); m_familyComboBox = new QFontComboBox(m_fontGroup); m_familyComboBox->setGeometry(66, 30, 194 + offsetW, 20); m_familyComboBox->setCurrentFont(m_plainTextEdit->font()); connect(m_familyComboBox, SIGNAL(currentFontChanged(QFont)), this, SLOT(familyChanged(QFont))); m_styleComboBox = new QComboBox(m_fontGroup); m_styleComboBox->setGeometry(66, 60, 194 + offsetW, 20); m_styleComboBox->addItem(tr("Normal")); m_styleComboBox->addItem(tr("Italic")); m_styleComboBox->addItem(tr("Bold")); m_styleComboBox->addItem(tr("Bold Italic")); connect(m_styleComboBox, SIGNAL(activated(QString)), this, SLOT(styleChanged(QString))); QFont::Style style = m_plainTextEdit->font().style(); bool bold = m_plainTextEdit->font().bold(); int index = 0; if (!bold && !style) { index = 0; } else if (!bold && style == 1) { index = 1; } else if (bold && !style) { index = 2; } else if (bold && style == 1) { index = 3; } m_styleComboBox->setCurrentIndex(index); m_sizeComboBox = new QComboBox(m_fontGroup); m_sizeComboBox->setGeometry(66, 90, 194 + offsetW, 20); m_sizeComboBox->setMaxVisibleItems(10); for (int index = 6; index <= 72; ++index) { m_sizeComboBox->addItem(QString("%1").arg(index)); } m_sizeComboBox->setCurrentIndex(m_sizeComboBox->findText(QString("%1").arg(m_plainTextEdit->font().pointSize()))); connect(m_sizeComboBox, SIGNAL(activated(QString)), this, SLOT(sizeChanged(QString))); m_font = m_plainTextEdit->font(); }
void FontSetupPage::initColorGroup() { m_colorGroup = new QGroupBox(tr("Use Custom Color"), this); m_colorGroup->setCheckable(true); m_colorGroup->setChecked(INIMANAGER()->isEnableCustomColor()); m_colorGroup->setGeometry(10, 150, 310, 110); connect(m_colorGroup, SIGNAL(clicked(bool)), this, SLOT(colorGroupChecked(bool))); m_customColorEnabled = INIMANAGER()->isEnableCustomColor(); m_foregroudLabel = new QLabel(tr("Foreground"), m_colorGroup); m_foregroudLabel->setGeometry(10, 30, 84, 20); m_backgroudLabel = new QLabel(tr("Background"), m_colorGroup); m_backgroudLabel->setGeometry(152, 30, 84, 20); m_highlightLabel = new QLabel(tr("Highlight"), m_colorGroup); m_highlightLabel->setGeometry(10, 70, 84, 20); m_foregroudColorButton = new QPushButton(m_colorGroup); m_foregroudColorButton->setFlat(true); m_foregroudColorButton->setAutoFillBackground(true); m_foregroudColorButton->setGeometry(94, 24, 30, 30); changeButtonColor(m_foregroudColorButton, INIMANAGER()->foregroundColor()); connect(m_foregroudColorButton, SIGNAL(clicked()), this, SLOT(openForegroundColorDialog())); m_backgroudColorButton = new QPushButton(m_colorGroup); m_backgroudColorButton->setFlat(true); m_backgroudColorButton->setAutoFillBackground(true); m_backgroudColorButton->setGeometry(236, 24, 30, 30); changeButtonColor(m_backgroudColorButton, INIMANAGER()->backgroundColor()); connect(m_backgroudColorButton, SIGNAL(clicked()), this, SLOT(openBackgroundColorDialog())); m_customBackgroudColorButton = new QPushButton(m_colorGroup); m_customBackgroudColorButton->setFlat(true); m_customBackgroudColorButton->setAutoFillBackground(true); m_customBackgroudColorButton->setGeometry(272, 24, 30, 30); changeButtonColor(m_customBackgroudColorButton, INIMANAGER()->customBackgroundColor()); connect(m_customBackgroudColorButton, SIGNAL(clicked()), this, SLOT(openCustomBackgroundColorDialog())); m_currentLineFgColorButton = new QPushButton(m_colorGroup); m_currentLineFgColorButton->setFlat(true); m_currentLineFgColorButton->setAutoFillBackground(true); m_currentLineFgColorButton->setGeometry(94, 64, 30, 30); changeButtonColor(m_currentLineFgColorButton, INIMANAGER()->currentLineFgColor()); connect(m_currentLineFgColorButton, SIGNAL(clicked()), this, SLOT(openCurrentLineFgColorDialog())); m_currentLineBgColorButton = new QPushButton(m_colorGroup); m_currentLineBgColorButton->setFlat(true); m_currentLineBgColorButton->setAutoFillBackground(true); m_currentLineBgColorButton->setGeometry(129, 64, 30, 30); changeButtonColor(m_currentLineBgColorButton, INIMANAGER()->currentLineBgColor()); connect(m_currentLineBgColorButton, SIGNAL(clicked()), this, SLOT(openCurrentLineBgColorDialog())); m_foregroudColor = INIMANAGER()->foregroundColor(); m_backgroudColor = INIMANAGER()->backgroundColor(); m_customBackgroudColor = INIMANAGER()->customBackgroundColor(); m_currentLineFgColor = INIMANAGER()->currentLineFgColor(); m_currentLineBgColor = INIMANAGER()->currentLineBgColor(); }
void KeywordButtonGroup::init() { QStringList keywordList(INIMANAGER()->highlightingKeywordList()); foreach (const QString& keyword, keywordList) { addButton(keyword); }