mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Added a new "Menu Button" when the main menubar is hidden.
This button is very similar to Chrome browser's (wrench) button.
This commit is contained in:
parent
cb8724ce1c
commit
e8cefa1330
BIN
icons/menu_button.png
Normal file
BIN
icons/menu_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 548 B |
|
@ -157,6 +157,31 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
navToolbar->addAction( ui.print );
|
navToolbar->addAction( ui.print );
|
||||||
navToolbar->widgetForAction( ui.print )->setObjectName( "printButton" );
|
navToolbar->widgetForAction( ui.print )->setObjectName( "printButton" );
|
||||||
|
|
||||||
|
beforeOptionsSeparator = navToolbar->addSeparator();
|
||||||
|
navToolbar->widgetForAction( beforeOptionsSeparator )->setObjectName( "beforeOptionsSeparator" );
|
||||||
|
beforeOptionsSeparator->setVisible( cfg.preferences.hideMenubar);
|
||||||
|
|
||||||
|
QMenu * buttonMenu = new QMenu( this );
|
||||||
|
buttonMenu->addAction( ui.dictionaries );
|
||||||
|
buttonMenu->addAction( ui.preferences );
|
||||||
|
buttonMenu->addSeparator();
|
||||||
|
buttonMenu->addMenu( ui.menuHistory );
|
||||||
|
buttonMenu->addSeparator();
|
||||||
|
buttonMenu->addMenu( ui.menuFile );
|
||||||
|
buttonMenu->addMenu( ui.menuView );
|
||||||
|
buttonMenu->addMenu( ui.menu_Help );
|
||||||
|
|
||||||
|
QToolButton * menuButton = new QToolButton( navToolbar );
|
||||||
|
menuButton->setPopupMode( QToolButton::InstantPopup );
|
||||||
|
menuButton->setMenu( buttonMenu );
|
||||||
|
menuButton->setIcon( QIcon (":/icons/menu_button.png") );
|
||||||
|
menuButton->addAction( ui.menuOptions );
|
||||||
|
menuButton->setToolTip( tr( "Menu Button" ) );
|
||||||
|
menuButton->setObjectName( "menuButton" );
|
||||||
|
|
||||||
|
menuButtonAction = navToolbar->addWidget(menuButton);
|
||||||
|
menuButtonAction->setVisible( cfg.preferences.hideMenubar );
|
||||||
|
|
||||||
// Make the search pane's titlebar
|
// Make the search pane's titlebar
|
||||||
groupLabel.setText( tr( "Look up in:" ) );
|
groupLabel.setText( tr( "Look up in:" ) );
|
||||||
groupListInDock = new GroupComboBox( &searchPaneTitleBar );
|
groupListInDock = new GroupComboBox( &searchPaneTitleBar );
|
||||||
|
@ -2616,37 +2641,9 @@ void MainWindow::toggleMenuBarTriggered(bool announce)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtain from the menubar all the actions with shortcuts
|
|
||||||
// and either add them to the main window or remove them,
|
|
||||||
// depending on the menubar state.
|
|
||||||
|
|
||||||
QList<QMenu *> allMenus = menuBar()->findChildren<QMenu *>();
|
|
||||||
QListIterator<QMenu *> menuIter( allMenus );
|
|
||||||
while( menuIter.hasNext() )
|
|
||||||
{
|
|
||||||
QMenu * menu = menuIter.next();
|
|
||||||
QList<QAction *> allMenuActions = menu->actions();
|
|
||||||
QListIterator<QAction *> actionsIter( allMenuActions );
|
|
||||||
while( actionsIter.hasNext() )
|
|
||||||
{
|
|
||||||
QAction * action = actionsIter.next();
|
|
||||||
if ( !action->shortcut().isEmpty() )
|
|
||||||
{
|
|
||||||
if ( cfg.preferences.hideMenubar )
|
|
||||||
{
|
|
||||||
// add all menubar actions to the main window,
|
|
||||||
// before we hide the menubar
|
|
||||||
addAction( action );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// remove all menubar actions from the main window
|
|
||||||
removeAction( action );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
menuBar()->setVisible( !cfg.preferences.hideMenubar );
|
menuBar()->setVisible( !cfg.preferences.hideMenubar );
|
||||||
|
beforeOptionsSeparator->setVisible( cfg.preferences.hideMenubar);
|
||||||
|
menuButtonAction->setVisible( cfg.preferences.hideMenubar );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_clearHistory_triggered()
|
void MainWindow::on_clearHistory_triggered()
|
||||||
|
|
|
@ -109,11 +109,12 @@ private:
|
||||||
QToolBar * navToolbar;
|
QToolBar * navToolbar;
|
||||||
MainStatusBar * mainStatusBar;
|
MainStatusBar * mainStatusBar;
|
||||||
QAction * navBack, * navForward, * navPronounce, * enableScanPopup;
|
QAction * navBack, * navForward, * navPronounce, * enableScanPopup;
|
||||||
QAction * beforeScanPopupSeparator, * afterScanPopupSeparator;
|
QAction * beforeScanPopupSeparator, * afterScanPopupSeparator, * beforeOptionsSeparator;
|
||||||
QAction * zoomIn, * zoomOut, * zoomBase;
|
QAction * zoomIn, * zoomOut, * zoomBase;
|
||||||
QAction * wordsZoomIn, * wordsZoomOut, * wordsZoomBase;
|
QAction * wordsZoomIn, * wordsZoomOut, * wordsZoomBase;
|
||||||
QMenu trayIconMenu;
|
QMenu trayIconMenu;
|
||||||
QMenu *tabMenu;
|
QMenu * tabMenu;
|
||||||
|
QAction * menuButtonAction;
|
||||||
MRUQMenu *tabListMenu;
|
MRUQMenu *tabListMenu;
|
||||||
//List that contains indexes of tabs arranged in a most-recently-used order
|
//List that contains indexes of tabs arranged in a most-recently-used order
|
||||||
QList<QWidget*> mruList;
|
QList<QWidget*> mruList;
|
||||||
|
|
|
@ -446,6 +446,18 @@
|
||||||
<string>Ctrl+O</string>
|
<string>Ctrl+O</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="menuOptions">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="resources.qrc">
|
||||||
|
<normaloff>:/icons/menu_button.png</normaloff>:/icons/menu_button.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Menu Button</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Menu Button</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
|
@ -9,6 +9,10 @@ MainWindow #translateLine[noResults="true"]
|
||||||
background: #febb7d;
|
background: #febb7d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#navToolbar #menuButton::menu-indicator {
|
||||||
|
image: none;
|
||||||
|
}
|
||||||
|
|
||||||
#navToolbar #translateLine
|
#navToolbar #translateLine
|
||||||
{
|
{
|
||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
|
|
|
@ -55,5 +55,6 @@
|
||||||
<file>qt-style-st-babylon.css</file>
|
<file>qt-style-st-babylon.css</file>
|
||||||
<file>icons/1downarrow.png</file>
|
<file>icons/1downarrow.png</file>
|
||||||
<file>icons/system-search.png</file>
|
<file>icons/system-search.png</file>
|
||||||
|
<file>icons/menu_button.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in a new issue