A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 112 lines 3.4 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * This file has been copied from Nokia's Qt Examples, with minor modifications 11 * made available under the LGPL version 2.1, as the original file was licensed 12 * 13 **************************************************************************** 14 **************************************************************************** 15** 16** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 17** All rights reserved. 18** Contact: Nokia Corporation (qt-info@nokia.com) 19** 20** This file is part of the examples of the Qt Toolkit. 21** 22** GNU Lesser General Public License Usage 23** Alternatively, this file may be used under the terms of the GNU Lesser 24** General Public License version 2.1 as published by the Free Software 25** Foundation and appearing in the file LICENSE.LGPL included in the 26** packaging of this file. Please review the following information to 27** ensure the GNU Lesser General Public License version 2.1 requirements 28** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 29** 30** In addition, as a special exception, Nokia gives you certain additional 31** rights. These rights are described in the Nokia Qt LGPL Exception 32** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 33** 34****************************************************************************/ 35 36#ifndef CODEEDITOR_H 37#define CODEEDITOR_H 38 39#include <QPlainTextEdit> 40#include <QObject> 41#include <QSettings> 42 43#include "syntaxcompleter.h" 44 45QT_BEGIN_NAMESPACE 46class QPaintEvent; 47class QResizeEvent; 48class QSize; 49class QWidget; 50QT_END_NAMESPACE 51 52class LineNumberArea; 53 54class CodeEditor : public QPlainTextEdit 55{ 56 Q_OBJECT 57 58public: 59 CodeEditor(QWidget *parent = 0); 60 virtual ~CodeEditor(){ } 61 62 void lineNumberAreaPaintEvent(QPaintEvent *event); 63 int lineNumberAreaWidth(); 64 void addError(int line){ errors.append(line); } 65 void clearErrors(){ errors.clear(); } 66 void setErrorColor(QColor color){ errorColor = color; } 67 bool isError(int line){ return errors.contains(line); } 68 bool hasErrors(){ return !errors.isEmpty(); } 69 70protected: 71 void resizeEvent(QResizeEvent *event); 72 void keyPressEvent(QKeyEvent *event); 73 74private slots: 75 void updateLineNumberAreaWidth(int newBlockCount); 76 void updateLineNumberArea(const QRect &, int); 77 void cursorMoved(); 78 void insertTag(); 79 80private: 81 QWidget *lineNumberArea; 82 QList<int> errors; 83 QColor errorColor; 84 SyntaxCompleter completer; 85 QSettings settings; 86 87 int tagBegin; 88 int tagEnd; 89 int docLength; 90}; 91 92class LineNumberArea : public QWidget 93{ 94public: 95 LineNumberArea(CodeEditor *editor) : QWidget(editor) { 96 codeEditor = editor; 97 } 98 99 QSize sizeHint() const { 100 return QSize(codeEditor->lineNumberAreaWidth(), 0); 101 } 102 103protected: 104 void paintEvent(QPaintEvent *event) { 105 codeEditor->lineNumberAreaPaintEvent(event); 106 } 107 108private: 109 CodeEditor *codeEditor; 110}; 111 112#endif