mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
* Incorporate group selector into the search pane's titlebar, replacing the
original with it.
This commit is contained in:
parent
974594e1c6
commit
3fff19f910
|
@ -32,6 +32,8 @@ using std::pair;
|
|||
|
||||
MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||
trayIcon( 0 ),
|
||||
groupLabel( &searchPaneTitleBar ),
|
||||
groupList( &searchPaneTitleBar ),
|
||||
focusTranslateLineAction( this ),
|
||||
addTabAction( this ),
|
||||
closeCurrentTabAction( this ),
|
||||
|
@ -48,6 +50,19 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
{
|
||||
ui.setupUi( this );
|
||||
|
||||
// Make the search pane's titlebar
|
||||
|
||||
groupLabel.setText( tr( "Look up in:" ) );
|
||||
|
||||
searchPaneTitleBarLayout.setContentsMargins( 8, 2, 8, 0 );
|
||||
searchPaneTitleBarLayout.addWidget( &groupLabel );
|
||||
searchPaneTitleBarLayout.addWidget( &groupList );
|
||||
searchPaneTitleBarLayout.addStretch();
|
||||
|
||||
searchPaneTitleBar.setLayout( &searchPaneTitleBarLayout );
|
||||
|
||||
ui.searchPane->setTitleBarWidget( &searchPaneTitleBar );
|
||||
|
||||
// Make the toolbar
|
||||
navToolbar = addToolBar( tr( "Navigation" ) );
|
||||
navToolbar->setObjectName( "navToolbar" );
|
||||
|
@ -173,7 +188,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
connect( ui.about, SIGNAL( activated() ),
|
||||
this, SLOT( showAbout() ) );
|
||||
|
||||
connect( ui.groupList, SIGNAL( currentIndexChanged( QString const & ) ),
|
||||
connect( &groupList, SIGNAL( currentIndexChanged( QString const & ) ),
|
||||
this, SLOT( currentGroupChanged( QString const & ) ) );
|
||||
|
||||
connect( ui.translateLine, SIGNAL( textChanged( QString const & ) ),
|
||||
|
@ -537,13 +552,13 @@ void MainWindow::updateGroupList()
|
|||
{
|
||||
bool haveGroups = cfg.groups.size();
|
||||
|
||||
ui.groupList->setVisible( haveGroups );
|
||||
groupList.setVisible( haveGroups );
|
||||
|
||||
ui.groupLabel->setText( haveGroups ? tr( "Look up in:" ) : tr( "Look up:" ) );
|
||||
groupLabel.setText( haveGroups ? tr( "Look up in:" ) : tr( "Look up:" ) );
|
||||
|
||||
// currentIndexChanged() signal is very trigger-happy. To avoid triggering
|
||||
// it, we disconnect it while we're clearing and filling back groups.
|
||||
disconnect( ui.groupList, SIGNAL( currentIndexChanged( QString const & ) ),
|
||||
disconnect( &groupList, SIGNAL( currentIndexChanged( QString const & ) ),
|
||||
this, SLOT( currentGroupChanged( QString const & ) ) );
|
||||
|
||||
groupInstances.clear();
|
||||
|
@ -557,10 +572,10 @@ void MainWindow::updateGroupList()
|
|||
Instances::updateNames( cfg.groups[ x ], dictionaries );
|
||||
}
|
||||
|
||||
ui.groupList->fill( groupInstances );
|
||||
ui.groupList->setCurrentGroup( cfg.lastMainGroupId );
|
||||
groupList.fill( groupInstances );
|
||||
groupList.setCurrentGroup( cfg.lastMainGroupId );
|
||||
|
||||
connect( ui.groupList, SIGNAL( currentIndexChanged( QString const & ) ),
|
||||
connect( &groupList, SIGNAL( currentIndexChanged( QString const & ) ),
|
||||
this, SLOT( currentGroupChanged( QString const & ) ) );
|
||||
}
|
||||
|
||||
|
@ -582,7 +597,7 @@ vector< sptr< Dictionary::Class > > const & MainWindow::getActiveDicts()
|
|||
if ( cfg.groups.empty() )
|
||||
return dictionaries;
|
||||
|
||||
int current = ui.groupList->currentIndex();
|
||||
int current = groupList.currentIndex();
|
||||
|
||||
if ( current < 0 || current >= (int) groupInstances.size() )
|
||||
{
|
||||
|
@ -800,7 +815,7 @@ void MainWindow::editPreferences()
|
|||
|
||||
void MainWindow::currentGroupChanged( QString const & )
|
||||
{
|
||||
cfg.lastMainGroupId = ui.groupList->getCurrentGroup();
|
||||
cfg.lastMainGroupId = groupList.getCurrentGroup();
|
||||
|
||||
// Update word search results
|
||||
|
||||
|
@ -1014,7 +1029,7 @@ void MainWindow::showTranslationFor( QString const & inWord )
|
|||
navPronounce->setEnabled( false );
|
||||
|
||||
view.showDefinition( inWord, cfg.groups.empty() ? 0 :
|
||||
groupInstances[ ui.groupList->currentIndex() ].id );
|
||||
groupInstances[ groupList.currentIndex() ].id );
|
||||
|
||||
updatePronounceAvailability();
|
||||
|
||||
|
@ -1026,7 +1041,7 @@ void MainWindow::showTranslationFor( QString const & inWord )
|
|||
req.addQueryItem( "word", inWord );
|
||||
req.addQueryItem( "group",
|
||||
cfg.groups.empty() ? "" :
|
||||
groupInstances[ ui.groupList->currentIndex() ].name );
|
||||
groupInstances[ groupList.currentIndex() ].name );
|
||||
|
||||
ui.definition->load( req );
|
||||
|
||||
|
|
|
@ -75,6 +75,14 @@ private:
|
|||
QSystemTrayIcon * trayIcon;
|
||||
|
||||
Ui::MainWindow ui;
|
||||
|
||||
/// This widget is used as a title bar for the searchPane dock, and
|
||||
/// incorporates the next three objects inside
|
||||
QWidget searchPaneTitleBar;
|
||||
QHBoxLayout searchPaneTitleBarLayout;
|
||||
QLabel groupLabel;
|
||||
GroupComboBox groupList;
|
||||
|
||||
QAction focusTranslateLineAction, addTabAction, closeCurrentTabAction,
|
||||
switchToNextTabAction, switchToPrevTabAction;
|
||||
QToolBar * navToolbar;
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QDockWidget" name="searchPane">
|
||||
<property name="windowTitle">
|
||||
<string>Look up:</string>
|
||||
<string>Search Pane</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
|
@ -114,46 +114,6 @@
|
|||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="groupLabel">
|
||||
<property name="text">
|
||||
<string>Look up in:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="GroupComboBox" name="groupList">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="duplicatesEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="translateLine">
|
||||
<property name="minimumSize">
|
||||
|
@ -323,11 +283,6 @@
|
|||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>GroupComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>groupcombobox.hh</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SearchPaneWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
|
|
Loading…
Reference in a new issue