Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions TeXmacs/misc/themes/liii-night.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ QMenuBar QWidget {
}

QMenuBar {
padding-top: 6px;
spacing: 8px;
padding-top: 2px;
spacing: 4px;
}

QMenuBar::item {
background: transparent;
padding: 6px 12px;
padding: 3px 10px;
border-radius: 4px;
}

Expand Down Expand Up @@ -119,16 +119,31 @@ QToolBar {
background: #2c2c2c;
color: #ffffff;
border-bottom: none;
spacing: 3px;
padding: 4px;
min-height: 36px !important;
max-height: 36px !important;
spacing: 1px;
padding: 1px;
min-height: 28px !important;
max-height: 28px !important;
}

QToolBar#focusToolBar,
QToolBar#modeToolBar,
QToolBar#mainToolBar,
QToolBar#tabToolBar {
min-height: 28px !important;
max-height: 28px !important;
padding: 2px;
}

QToolBar#menuToolBar {
min-height: 28px !important;
max-height: 28px !important;
padding: 0px;
}

QToolButton {
border-radius: 8px;
padding: 4px;
margin: 2px;
border-radius: 6px;
padding: 2px;
margin: 1px;
background-color: transparent;
border: 1px solid transparent;
color: #ffffff;
Expand Down
32 changes: 19 additions & 13 deletions TeXmacs/misc/themes/liii.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ QMenuBar QWidget {
}

QMenuBar {
padding-top: 6px;
spacing: 8px;
padding-top: 2px;
spacing: 4px;
}

QMenuBar::item {
background: transparent;
padding: 6px 12px;
padding: 3px 10px;
border-radius: 4px;
}

Expand Down Expand Up @@ -115,25 +115,31 @@ QToolBar {
background: #f3f3f3;
color: #2c2c2c;
border-bottom: none;
spacing: 3px;
padding: 2px;
min-height: 36px !important;
max-height: 36px !important;
spacing: 1px;
padding: 1px;
min-height: 28px !important;
max-height: 28px !important;
}

QToolBar#focusToolBar,
QToolBar#modeToolBar,
QToolBar#mainToolBar,
QToolBar#tabToolBar {
min-height: 36px !important;
max-height: 36px !important;
padding: 4px;
min-height: 28px !important;
max-height: 28px !important;
padding: 2px;
}

QToolBar#menuToolBar {
min-height: 28px !important;
max-height: 28px !important;
padding: 0px;
}

QToolButton {
border-radius: 8px;
padding: 4px;
margin: 2px;
border-radius: 6px;
padding: 2px;
margin: 1px;
background-color: transparent;
border: 1px solid transparent;
}
Expand Down
37 changes: 37 additions & 0 deletions devel/222_45.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 222_45 Compact toolbar and native menu bar fix

Issue #2877

## Summary

Reduce vertical height of the `liii` and `liii-night` toolbars for a more compact UI,
and fix an empty white strip left behind when `use_native_menubar` is enabled.

## How to Test

### Compact toolbar (liii / liii-night theme)

- Build and launch Mogan with the default (`liii`) or `liii Dark` theme.
- Verify the toolbar rows (main, mode, focus, tab) are visually more compact than before.
- Verify the menu bar (File, Edit, etc.) is visible and items are readable.
- Verify icon hover/press states still render correctly.

### Native menu bar (macOS)

- In Preferences -> User Interface, enable `use_native_menubar`.
- Restart Mogan.
- Verify the macOS system menu bar shows File, Edit, etc. correctly.
- Verify no empty white strip appears where the in-window menu bar used to be.
- Disable `use_native_menubar`, restart - verify the in-window menu bar returns.

## Files Changed

- `TeXmacs/misc/themes/liii.css` - reduced toolbar `min/max-height` from 36 px to 28 px;
reduced `QToolButton` and `QMenuBar` padding to fit the new height.
- `TeXmacs/misc/themes/liii-night.css` - same changes as `liii.css` for the dark theme.
- `src/Plugins/Qt/qt_tm_widget.cpp`:
- Removed erroneous `dest->setFixedHeight(108 * devicePixelRatio)` in
`install_main_menu()` (physical-pixel value used for a logical-pixel widget height).
- Guard `menuToolBar` visibility on `!use_native_menubar` in both
`update_visibility()` and `install_main_menu()` so the toolbar is hidden when
the native menu bar is active.
22 changes: 4 additions & 18 deletions src/Plugins/Qt/qt_tm_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ qt_tm_widget_rep::update_visibility () {
bool old_titleVisibility = windowAgent->titleBar ()->isVisible ();

bool new_mainVisibility = visibility[1] && visibility[0];
bool new_menuVisibility = visibility[0];
bool new_menuVisibility = visibility[0] && !use_native_menubar;
bool new_modeVisibility = visibility[2] && visibility[0];
bool new_focusVisibility = visibility[3] && visibility[0];
bool new_userVisibility = visibility[4] && visibility[0];
Expand Down Expand Up @@ -1205,21 +1205,7 @@ qt_tm_widget_rep::install_main_menu () {
main_menu_widget = waiting_main_menu_widget;
QList<QAction*>* src= main_menu_widget->get_qactionlist ();
if (!src) return;
QMenuBar* dest = new QMenuBar ();
QScreen* screen= QGuiApplication::primaryScreen ();
#ifdef Q_OS_WIN
// 设置与 menuToolBar 匹配的固定高度
// 使用 devicePixelRatio() 获取正确的屏幕缩放比
// 获取屏幕DPI缩放比例
double dpi = screen ? screen->logicalDotsPerInch () : 96.0;
double scale= dpi / 96.0;

int h= (int) floor (72 * scale + 0.5);
#else
double scale= screen ? screen->devicePixelRatio () : 1.0; // 正确的屏幕缩放比
int h = (int) floor (108 * scale + 0.5);
#endif
dest->setFixedHeight (h);
QMenuBar* dest= new QMenuBar ();

if (tm_style_sheet == "") dest->setStyle (qtmstyle ());
if (!use_native_menubar) {
Expand Down Expand Up @@ -1249,8 +1235,8 @@ qt_tm_widget_rep::install_main_menu () {
for (QWidget* w : widgets) {
w->setParent (nullptr);
}
// 确保 menuToolBar 可见
if (!menuToolBar->isVisible ()) {
// 确保 menuToolBar 可见 (only when not using native menu bar)
if (!use_native_menubar && !menuToolBar->isVisible ()) {
menuToolBar->setVisible (true);
}

Expand Down