+ Help menu implemented.

+ Translations are shown whenever user presses enter or clicks a word in list.
This commit is contained in:
Konstantin Isakov 2009-02-08 14:02:27 +00:00
parent 61943519c1
commit d917ae8896
5 changed files with 208 additions and 7 deletions

139
src/about.ui Normal file
View file

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QDialog" name="About">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>123</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/icons/programicon.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>GoldenDict dictionary lookup progam, version 0.5</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>(c) 2008-2009 Konstantin Isakov &lt;ikm@users.berlios.de&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Licensed under GPLv3 or later</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>About</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>About</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -70,7 +70,8 @@ HEADERS += folding.hh \
FORMS += groups.ui dictgroupwidget.ui mainwindow.ui sources.ui initializing.ui\ FORMS += groups.ui dictgroupwidget.ui mainwindow.ui sources.ui initializing.ui\
groupselectorwidget.ui scanpopup.ui articleview.ui preferences.ui groupselectorwidget.ui scanpopup.ui articleview.ui preferences.ui\
about.ui
SOURCES += folding.cc main.cc dictionary.cc md5.c config.cc sources.cc \ SOURCES += folding.cc main.cc dictionary.cc md5.c config.cc sources.cc \
mainwindow.cc utf8.cc file.cc bgl_babylon.cc bgl.cc initializing.cc \ mainwindow.cc utf8.cc file.cc bgl_babylon.cc bgl.cc initializing.cc \

View file

@ -10,11 +10,13 @@
#include "lsa.hh" #include "lsa.hh"
#include "dsl.hh" #include "dsl.hh"
#include "dictlock.hh" #include "dictlock.hh"
#include "ui_about.h"
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
#include <QIcon> #include <QIcon>
#include <QToolBar> #include <QToolBar>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDesktopServices>
#include <set> #include <set>
#include <map> #include <map>
@ -80,16 +82,29 @@ MainWindow::MainWindow():
connect( ui.preferences, SIGNAL( activated() ), connect( ui.preferences, SIGNAL( activated() ),
this, SLOT( editPreferences() ) ); this, SLOT( editPreferences() ) );
connect( ui.visitHomepage, SIGNAL( activated() ),
this, SLOT( visitHomepage() ) );
connect( ui.visitForum, SIGNAL( activated() ),
this, SLOT( visitForum() ) );
connect( ui.about, SIGNAL( activated() ),
this, SLOT( showAbout() ) );
connect( ui.groupList, SIGNAL( currentIndexChanged( QString const & ) ), connect( ui.groupList, SIGNAL( currentIndexChanged( QString const & ) ),
this, SLOT( currentGroupChanged( QString const & ) ) ); this, SLOT( currentGroupChanged( QString const & ) ) );
connect( ui.translateLine, SIGNAL( textChanged( QString const & ) ), connect( ui.translateLine, SIGNAL( textChanged( QString const & ) ),
this, SLOT( translateInputChanged( QString const & ) ) ); this, SLOT( translateInputChanged( QString const & ) ) );
connect( ui.translateLine, SIGNAL( returnPressed() ),
this, SLOT( translateInputFinished() ) );
connect( ui.wordList, SIGNAL( itemActivated( QListWidgetItem * ) ), connect( ui.wordList, SIGNAL( itemActivated( QListWidgetItem * ) ),
this, SLOT( wordListItemActivated( QListWidgetItem * ) ) ); this, SLOT( wordListItemActivated( QListWidgetItem * ) ) );
connect( ui.wordList, SIGNAL( itemSelectionChanged() ),
this, SLOT( wordListSelectionChanged() ) );
connect( wordFinder.qobject(), SIGNAL( prefixMatchComplete( WordFinderResults ) ), connect( wordFinder.qobject(), SIGNAL( prefixMatchComplete( WordFinderResults ) ),
this, SLOT( prefixMatchComplete( WordFinderResults ) ) ); this, SLOT( prefixMatchComplete( WordFinderResults ) ) );
@ -493,6 +508,12 @@ void MainWindow::translateInputChanged( QString const & newValue )
wordFinder.prefixMatch( req, &getActiveDicts() ); wordFinder.prefixMatch( req, &getActiveDicts() );
} }
void MainWindow::translateInputFinished()
{
if ( ui.wordList->count() )
wordListItemActivated( ui.wordList->item( 0 ) );
}
void MainWindow::prefixMatchComplete( WordFinderResults r ) void MainWindow::prefixMatchComplete( WordFinderResults r )
{ {
if ( r.requestStr != ui.translateLine->text().trimmed() || if ( r.requestStr != ui.translateLine->text().trimmed() ||
@ -538,11 +559,17 @@ void MainWindow::prefixMatchComplete( WordFinderResults r )
void MainWindow::wordListItemActivated( QListWidgetItem * item ) void MainWindow::wordListItemActivated( QListWidgetItem * item )
{ {
printf( "act: %s\n", item->text().toLocal8Bit().data() );
showTranslationFor( item->text() ); showTranslationFor( item->text() );
} }
void MainWindow::wordListSelectionChanged()
{
QList< QListWidgetItem * > selected = ui.wordList->selectedItems();
if ( selected.size() )
wordListItemActivated( selected.front() );
}
void MainWindow::showTranslationFor( QString const & inWord ) void MainWindow::showTranslationFor( QString const & inWord )
{ {
ArticleView & view = ArticleView & view =
@ -654,3 +681,25 @@ void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason )
hide(); hide();
} }
void MainWindow::visitHomepage()
{
QDesktopServices::openUrl( QUrl( "http://goldendict.berlios.de/" ) );
}
void MainWindow::visitForum()
{
QDesktopServices::openUrl( QUrl( "http://goldendict.berlios.de/forum/" ) );
}
void MainWindow::showAbout()
{
QDialog about( this );
Ui::About ui;
ui.setupUi( &about );
about.show();
about.exec();
}

View file

@ -116,12 +116,18 @@ private slots:
void currentGroupChanged( QString const & ); void currentGroupChanged( QString const & );
void translateInputChanged( QString const & ); void translateInputChanged( QString const & );
void translateInputFinished();
void prefixMatchComplete( WordFinderResults ); void prefixMatchComplete( WordFinderResults );
void wordListItemActivated( QListWidgetItem * ); void wordListItemActivated( QListWidgetItem * );
void wordListSelectionChanged();
void showTranslationFor( QString const & ); void showTranslationFor( QString const & );
void trayIconActivated( QSystemTrayIcon::ActivationReason ); void trayIconActivated( QSystemTrayIcon::ActivationReason );
void visitHomepage();
void visitForum();
void showAbout();
}; };
#endif #endif

View file

@ -260,7 +260,8 @@
<property name="title"> <property name="title">
<string>&amp;Help</string> <string>&amp;Help</string>
</property> </property>
<addaction name="openWebsite"/> <addaction name="visitHomepage"/>
<addaction name="visitForum"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="about"/> <addaction name="about"/>
</widget> </widget>
@ -289,9 +290,9 @@
<string>&amp;Preferences...</string> <string>&amp;Preferences...</string>
</property> </property>
</action> </action>
<action name="openWebsite"> <action name="visitHomepage">
<property name="text"> <property name="text">
<string>Program's &amp;website</string> <string>&amp;Homepage</string>
</property> </property>
</action> </action>
<action name="about"> <action name="about">
@ -304,6 +305,11 @@
<string>&amp;Quit</string> <string>&amp;Quit</string>
</property> </property>
</action> </action>
<action name="visitForum">
<property name="text">
<string>&amp;Forum</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>