Set system window title text on macOS.
This commit is contained in:
parent
51fd4a0509
commit
30e7657859
1 changed files with 15 additions and 8 deletions
|
|
@ -130,6 +130,7 @@ public:
|
||||||
[[nodiscard]] bool checkNativeMove(void *nswindow) const;
|
[[nodiscard]] bool checkNativeMove(void *nswindow) const;
|
||||||
void activateBeforeNativeMove();
|
void activateBeforeNativeMove();
|
||||||
void setStaysOnTop(bool enabled);
|
void setStaysOnTop(bool enabled);
|
||||||
|
void setNativeTitleVisibility(bool visible);
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -220,6 +221,15 @@ void WindowHelper::Private::setStaysOnTop(bool enabled) {
|
||||||
_owner->BasicWindowHelper::setStaysOnTop(enabled);
|
_owner->BasicWindowHelper::setStaysOnTop(enabled);
|
||||||
resolveWeakPointers();
|
resolveWeakPointers();
|
||||||
initCustomTitle();
|
initCustomTitle();
|
||||||
|
_owner->updateCustomTitleVisibility(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowHelper::Private::setNativeTitleVisibility(bool visible) {
|
||||||
|
if (!_nativeWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto value = visible ? NSWindowTitleVisible : NSWindowTitleHidden;
|
||||||
|
[_nativeWindow setTitleVisibility:value];
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::Private::close() {
|
void WindowHelper::Private::close() {
|
||||||
|
|
@ -316,9 +326,6 @@ WindowHelper::WindowHelper(not_null<RpWidget*> window)
|
||||||
window.get(),
|
window.get(),
|
||||||
_private->customTitleHeight()))
|
_private->customTitleHeight()))
|
||||||
, _body(Ui::CreateChild<RpWidget>(window.get())) {
|
, _body(Ui::CreateChild<RpWidget>(window.get())) {
|
||||||
if (_title->shouldBeHidden()) {
|
|
||||||
updateCustomTitleVisibility();
|
|
||||||
}
|
|
||||||
init();
|
init();
|
||||||
_title->setControlsRect(_private->controlsRect());
|
_title->setControlsRect(_private->controlsRect());
|
||||||
}
|
}
|
||||||
|
|
@ -337,15 +344,13 @@ QMargins WindowHelper::frameMargins() {
|
||||||
|
|
||||||
void WindowHelper::setTitle(const QString &title) {
|
void WindowHelper::setTitle(const QString &title) {
|
||||||
_title->setText(title);
|
_title->setText(title);
|
||||||
window()->setWindowTitle(_titleVisible ? QString() : title);
|
window()->setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::setTitleStyle(const style::WindowTitle &st) {
|
void WindowHelper::setTitleStyle(const style::WindowTitle &st) {
|
||||||
_title->setStyle(st);
|
_title->setStyle(st);
|
||||||
if (_title->shouldBeHidden()) {
|
|
||||||
updateCustomTitleVisibility();
|
updateCustomTitleVisibility();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void WindowHelper::updateCustomTitleVisibility(bool force) {
|
void WindowHelper::updateCustomTitleVisibility(bool force) {
|
||||||
const auto visible = !_title->shouldBeHidden() && _titleVisible;
|
const auto visible = !_title->shouldBeHidden() && _titleVisible;
|
||||||
|
|
@ -353,7 +358,7 @@ void WindowHelper::updateCustomTitleVisibility(bool force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_title->setVisible(visible);
|
_title->setVisible(visible);
|
||||||
window()->setWindowTitle(_titleVisible ? QString() : _title->text());
|
_private->setNativeTitleVisibility(!_titleVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::setMinimumSize(QSize size) {
|
void WindowHelper::setMinimumSize(QSize size) {
|
||||||
|
|
@ -395,6 +400,8 @@ void WindowHelper::close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowHelper::init() {
|
void WindowHelper::init() {
|
||||||
|
updateCustomTitleVisibility(true);
|
||||||
|
|
||||||
style::PaletteChanged(
|
style::PaletteChanged(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
Ui::ForceFullRepaint(window());
|
Ui::ForceFullRepaint(window());
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue