mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-02-02 10:36:45 +01:00
Add ResizableTextEdit
This commit is contained in:
parent
32ac02007b
commit
683991b1c9
2
debian/copyright
vendored
2
debian/copyright
vendored
@ -96,6 +96,8 @@ Files: src/core/main.h
|
||||
ext/libstrawberry-tagreader/tagreadertagparser.cpp
|
||||
ext/libstrawberry-tagreader/tagreadertagparser.h
|
||||
ext/macdeploycheck/*
|
||||
widgets/resizabletextedit.cpp
|
||||
widgets/resizabletextedit.h
|
||||
Copyright: 2012-2014, 2017-2022, Jonas Kvinge <jonas@jkvinge.net>
|
||||
License: GPL-3+
|
||||
|
||||
|
@ -212,6 +212,7 @@ set(SOURCES
|
||||
widgets/tracksliderslider.cpp
|
||||
widgets/loginstatewidget.cpp
|
||||
widgets/ratingwidget.cpp
|
||||
widgets/resizabletextedit.cpp
|
||||
|
||||
osd/osdbase.cpp
|
||||
osd/osdpretty.cpp
|
||||
@ -445,6 +446,7 @@ set(HEADERS
|
||||
widgets/qsearchfield.h
|
||||
widgets/ratingwidget.h
|
||||
widgets/forcescrollperpixel.h
|
||||
widgets/resizabletextedit.h
|
||||
|
||||
osd/osdbase.h
|
||||
osd/osdpretty.h
|
||||
|
45
src/widgets/resizabletextedit.cpp
Normal file
45
src/widgets/resizabletextedit.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2022, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QResizeEvent>
|
||||
|
||||
#include "resizabletextedit.h"
|
||||
|
||||
ResizableTextEdit::ResizableTextEdit(QWidget *parent)
|
||||
: QTextEdit(parent) {
|
||||
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
}
|
||||
|
||||
QSize ResizableTextEdit::sizeHint() const {
|
||||
|
||||
return QSize(std::max(QTextEdit::sizeHint().width(), 10), std::max(document()->size().toSize().height(), 10));
|
||||
|
||||
}
|
||||
|
||||
void ResizableTextEdit::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
updateGeometry();
|
||||
QTextEdit::resizeEvent(e);
|
||||
|
||||
}
|
39
src/widgets/resizabletextedit.h
Normal file
39
src/widgets/resizabletextedit.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2022, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RESIZABLETEXTEDIT_H
|
||||
#define RESIZABLETEXTEDIT_H
|
||||
|
||||
#include <QTextEdit>
|
||||
|
||||
class QResizeEvent;
|
||||
|
||||
class ResizableTextEdit: public QTextEdit {
|
||||
|
||||
public:
|
||||
explicit ResizableTextEdit(QWidget *parent = nullptr);
|
||||
|
||||
virtual QSize sizeHint() const override;
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // RESIZABLETEXTEDIT_H
|
Loading…
x
Reference in New Issue
Block a user