mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Show information about a dictionary on rigth mouse click in "Found in" pane
This commit is contained in:
parent
405c2b50ee
commit
34419706c9
39
dictinfo.cc
Normal file
39
dictinfo.cc
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "dictinfo.hh"
|
||||
#include "langcoder.hh"
|
||||
#include "language.hh"
|
||||
#include "fsencoding.hh"
|
||||
#include <QString>
|
||||
|
||||
DictInfo::DictInfo( QWidget *parent )
|
||||
{
|
||||
ui.setupUi( this );
|
||||
}
|
||||
|
||||
void DictInfo::showInfo( sptr<Dictionary::Class> dict )
|
||||
{
|
||||
setWindowTitle( QString::fromUtf8( dict->getName().data(), dict->getName().size() ) );
|
||||
|
||||
ui.dictionaryTotalArticles->setText( QString::number( dict->getArticleCount() ) );
|
||||
ui.dictionaryTotalWords->setText( QString::number( dict->getWordCount() ) );
|
||||
ui.dictionaryTranslatesFrom->setText( Language::localizedStringForId( dict->getLangFrom() ) );
|
||||
ui.dictionaryTranslatesTo->setText( Language::localizedStringForId( dict->getLangTo() ) );
|
||||
|
||||
std::vector< std::string > const & filenames = dict->getDictionaryFilenames();
|
||||
|
||||
QString filenamesText;
|
||||
|
||||
for( unsigned x = 0; x < filenames.size(); x++ )
|
||||
{
|
||||
filenamesText += FsEncoding::decode( filenames[ x ].c_str() );
|
||||
filenamesText += '\n';
|
||||
}
|
||||
|
||||
ui.dictionaryFileList->setPlainText( filenamesText );
|
||||
|
||||
QString info = dict->getDescription();
|
||||
|
||||
if( !info.isEmpty() && info.compare( "NONE" ) != 0 )
|
||||
ui.infoLabel->setPlainText( info );
|
||||
else
|
||||
ui.infoLabel->clear();
|
||||
}
|
20
dictinfo.hh
Normal file
20
dictinfo.hh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef DICTINFO_HH
|
||||
#define DICTINFO_HH
|
||||
|
||||
#include <QDialog>
|
||||
#include "ui_dictinfo.h"
|
||||
#include "dictionary.hh"
|
||||
|
||||
class DictInfo: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
DictInfo( QWidget * parent = 0 );
|
||||
void showInfo( sptr< Dictionary::Class > dict );
|
||||
|
||||
private:
|
||||
Ui::DictInfo ui;
|
||||
};
|
||||
|
||||
#endif // DICTINFO_HH
|
258
dictinfo.ui
Normal file
258
dictinfo.ui
Normal file
|
@ -0,0 +1,258 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DictInfo</class>
|
||||
<widget class="QDialog" name="DictInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Total articles:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="dictionaryTotalArticles">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Translates from:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="dictionaryTranslatesFrom">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Total words:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="dictionaryTotalWords">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Translates to:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="dictionaryTranslatesTo">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Files comprising this dictionary:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="dictionaryFileList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>65</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>65</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>223</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>223</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>212</red>
|
||||
<green>208</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="dictionaryDescriptionLabel">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="infoLabel">
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>223</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>224</red>
|
||||
<green>223</green>
|
||||
<blue>223</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>212</red>
|
||||
<green>208</green>
|
||||
<blue>200</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DictInfo</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>180</x>
|
||||
<y>379</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>25</x>
|
||||
<y>791</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DictInfo</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>199</x>
|
||||
<y>378</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>199</x>
|
||||
<y>199</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -200,7 +200,8 @@ HEADERS += folding.hh \
|
|||
sdict.hh \
|
||||
decompress.hh \
|
||||
aard.hh \
|
||||
mruqmenu.hh
|
||||
mruqmenu.hh \
|
||||
dictinfo.hh
|
||||
FORMS += groups.ui \
|
||||
dictgroupwidget.ui \
|
||||
mainwindow.ui \
|
||||
|
@ -212,7 +213,8 @@ FORMS += groups.ui \
|
|||
preferences.ui \
|
||||
about.ui \
|
||||
editdictionaries.ui \
|
||||
orderandprops.ui
|
||||
orderandprops.ui \
|
||||
dictinfo.ui
|
||||
SOURCES += folding.cc \
|
||||
main.cc \
|
||||
dictionary.cc \
|
||||
|
@ -293,7 +295,8 @@ SOURCES += folding.cc \
|
|||
sdict.cc \
|
||||
decompress.cc \
|
||||
aard.cc \
|
||||
mruqmenu.cc
|
||||
mruqmenu.cc \
|
||||
dictinfo.cc
|
||||
win32 {
|
||||
SOURCES += mouseover_win32/ThTypes.c \
|
||||
wordbyauto.cc \
|
||||
|
|
11
language.cc
11
language.cc
|
@ -449,4 +449,15 @@ QString countryCodeForId( Id id )
|
|||
return i->second;
|
||||
}
|
||||
|
||||
QString localizedStringForId( Id langId )
|
||||
{
|
||||
QString name = localizedNameForId( langId );
|
||||
|
||||
if ( name.isEmpty() )
|
||||
return name;
|
||||
|
||||
QString iconId = countryCodeForId( langId );
|
||||
|
||||
return QString( "<img src=\":/flags/%1.png\"> %2" ).arg( iconId ).arg( name );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,10 @@ QString localizedNameForId( Id );
|
|||
/// corresponding country it the database, returns an empty strings.
|
||||
QString countryCodeForId( Id );
|
||||
|
||||
/// Returns name for the given Id, translated to the current UI language, wish corresponding image tag.
|
||||
/// If the Id is incorrect, or has Unknown/Any values, returns empty string.
|
||||
QString localizedStringForId( Id );
|
||||
|
||||
// All other functions are to be used from LangCoder, which is supposed to
|
||||
// be migrated here over time.
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "dprintf.hh"
|
||||
#include <QDebug>
|
||||
#include <QTextStream>
|
||||
#include "dictinfo.hh"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "lionsupport.h"
|
||||
|
@ -100,12 +101,16 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
dictsPaneTitleBarLayout.addWidget( &foundInDictsLabel );
|
||||
dictsPaneTitleBar.setLayout( &dictsPaneTitleBarLayout );
|
||||
ui.dictsPane->setTitleBarWidget( &dictsPaneTitleBar );
|
||||
ui.dictsList->setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
|
||||
connect( ui.dictsPane, SIGNAL( visibilityChanged( bool ) ),
|
||||
this, SLOT( dictsPaneVisibilityChanged ( bool ) ) );
|
||||
|
||||
connect( ui.dictsList, SIGNAL( itemClicked( QListWidgetItem * ) ),
|
||||
this, SLOT( dictsPaneClicked( QListWidgetItem * ) ) );
|
||||
this, SLOT( foundDictsPaneClicked( QListWidgetItem * ) ) );
|
||||
|
||||
connect( ui.dictsList, SIGNAL( customContextMenuRequested( const QPoint & ) ),
|
||||
this, SLOT( foundDictsContextMenuRequested( const QPoint & ) ) );
|
||||
|
||||
// Make the toolbar
|
||||
navToolbar = addToolBar( tr( "Navigation" ) );
|
||||
|
@ -2968,7 +2973,7 @@ void MainWindow::switchExpandOptionalPartsMode()
|
|||
view->switchExpandOptionalParts();
|
||||
}
|
||||
|
||||
void MainWindow::dictsPaneClicked( QListWidgetItem * item )
|
||||
void MainWindow::foundDictsPaneClicked( QListWidgetItem * item )
|
||||
{
|
||||
if ( QApplication::keyboardModifiers() &
|
||||
( Qt::ControlModifier | Qt::ShiftModifier ) )
|
||||
|
@ -2978,6 +2983,27 @@ void MainWindow::dictsPaneClicked( QListWidgetItem * item )
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::foundDictsContextMenuRequested( const QPoint &pos )
|
||||
{
|
||||
QListWidgetItem *item = ui.dictsList->itemAt( pos );
|
||||
if( item )
|
||||
{
|
||||
QString id = item->data( Qt::UserRole ).toString();
|
||||
for( unsigned x = 0; x < dictionaries.size(); x++ )
|
||||
{
|
||||
if( dictionaries[ x ]->getId() == id.toUtf8().data() )
|
||||
{
|
||||
scanPopup.get()->blockSignals( true );
|
||||
DictInfo infoMsg;
|
||||
infoMsg.showInfo( dictionaries[ x ] );
|
||||
infoMsg.exec();
|
||||
scanPopup.get()->blockSignals( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
bool MainWindow::winEvent( MSG * message, long * result )
|
||||
|
|
|
@ -194,7 +194,10 @@ private slots:
|
|||
void latestReleaseReplyReady();
|
||||
|
||||
/// Receive click on "Found in:" pane
|
||||
void dictsPaneClicked( QListWidgetItem * item );
|
||||
void foundDictsPaneClicked( QListWidgetItem * item );
|
||||
|
||||
/// Receive right click on "Found in:" pane
|
||||
void foundDictsContextMenuRequested( const QPoint & pos );
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
|
@ -78,20 +78,6 @@ void OrderAndProps::disableDictionaryDescription()
|
|||
ui.dictionaryDescriptionLabel->setVisible( false );
|
||||
}
|
||||
|
||||
namespace {
|
||||
QString makeLangText( Language::Id langId )
|
||||
{
|
||||
QString name = Language::localizedNameForId( langId );
|
||||
|
||||
if ( name.isEmpty() )
|
||||
return name;
|
||||
|
||||
QString iconId = Language::countryCodeForId( langId );
|
||||
|
||||
return QString( "<img src=\":/flags/%1.png\"> %2" ).arg( iconId ).arg( name );
|
||||
}
|
||||
}
|
||||
|
||||
void OrderAndProps::describeDictionary( DictListWidget * lst, QModelIndex const & idx )
|
||||
{
|
||||
if ( !idx.isValid() || (unsigned) idx.row() >= lst->getCurrentDictionaries().size() )
|
||||
|
@ -106,8 +92,8 @@ void OrderAndProps::describeDictionary( DictListWidget * lst, QModelIndex const
|
|||
|
||||
ui.dictionaryTotalArticles->setText( QString::number( dict->getArticleCount() ) );
|
||||
ui.dictionaryTotalWords->setText( QString::number( dict->getWordCount() ) );
|
||||
ui.dictionaryTranslatesFrom->setText( makeLangText( dict->getLangFrom() ) );
|
||||
ui.dictionaryTranslatesTo->setText( makeLangText( dict->getLangTo() ) );
|
||||
ui.dictionaryTranslatesFrom->setText( Language::localizedStringForId( dict->getLangFrom() ) );
|
||||
ui.dictionaryTranslatesTo->setText( Language::localizedStringForId( dict->getLangTo() ) );
|
||||
|
||||
std::vector< std::string > const & filenames = dict->getDictionaryFilenames();
|
||||
|
||||
|
|
Loading…
Reference in a new issue