Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotate text 90°/270° in vertical panels #21

Open
Zren opened this issue Sep 26, 2020 · 0 comments
Open

Rotate text 90°/270° in vertical panels #21

Zren opened this issue Sep 26, 2020 · 0 comments

Comments

@Zren
Copy link
Owner

Zren commented Sep 26, 2020

https://www.pling.com/u/dzwiedziu/ asked if I could optionally make text rotate

2020-09-26___11-21-00

This isn't a trivial as setting rotation: 270 https://doc.qt.io/qt-5/qml-qtquick-item.html#rotation-prop

2020-09-26___11-31-30

Nor is it easy as creating a container around the Text and setting the container's implicitWidth/implicitHeight.
2020-09-26___11-33-10

I'm not really interested in adding this feature, so feel free to play around with this code.

Save it as ~/Desktop/test.qml then run qmlscene ~/Desktop/test.qml to run the test.qml. Feel free to find a solution then modify ~/.local/share/plasma/plasmoids/com.github.zren.commandoutput/ and test with https://zren.github.io/kde/docs/widget/#testing.

import QtQuick 2.0
import QtQuick.Layouts 1.0
import QtQuick.Window 2.0

Window {
	width: 640
	height: 480

	ColumnLayout {
		anchors.fill: parent

		Rectangle {
			Layout.fillWidth: true
			Layout.fillHeight: true
			color: "red"
		}

		// Text {
		// 	id: label
		// 	property bool isRotated: label.rotation == 90 || label.rotation == 270
		// 	rotation: 270
		// 	text: "Test really long text"
		// 	wrapMode: Text.Wrap
		// }

		Item {
			id: labelContainer
			implicitWidth: label.isRotated ? label.implicitHeight : label.implicitWidth
			implicitHeight: label.isRotated ? label.implicitWidth : label.implicitHeight

			Text {
				id: label
				property bool isRotated: label.rotation == 90 || label.rotation == 270
				rotation: 270
				text: "Test really long text"
			}
		}

		Rectangle {
			Layout.fillWidth: true
			Layout.fillHeight: true
			color: "green"
		}
	}
}

We could also look into wrapMode: Text.WrapAnywhere

https://doc.qt.io/qt-5/qml-qtquick-text.html#wrapMode-prop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant