mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
clean: purge undocumented and useless editDictionaryCommandLine
(#1794)
Some checks failed
SonarCloud / Build and analyze (push) Has been cancelled
Some checks failed
SonarCloud / Build and analyze (push) Has been cancelled
This commit is contained in:
parent
97bf80451a
commit
96ada0737c
|
@ -1171,9 +1171,6 @@ Class load()
|
||||||
if ( !root.namedItem( "articleSavePath" ).isNull() )
|
if ( !root.namedItem( "articleSavePath" ).isNull() )
|
||||||
c.articleSavePath = root.namedItem( "articleSavePath" ).toElement().text();
|
c.articleSavePath = root.namedItem( "articleSavePath" ).toElement().text();
|
||||||
|
|
||||||
if ( !root.namedItem( "editDictionaryCommandLine" ).isNull() )
|
|
||||||
c.editDictionaryCommandLine = root.namedItem( "editDictionaryCommandLine" ).toElement().text();
|
|
||||||
|
|
||||||
if ( !root.namedItem( "maxHeadwordSize" ).isNull() ) {
|
if ( !root.namedItem( "maxHeadwordSize" ).isNull() ) {
|
||||||
unsigned int value = root.namedItem( "maxHeadwordSize" ).toElement().text().toUInt();
|
unsigned int value = root.namedItem( "maxHeadwordSize" ).toElement().text().toUInt();
|
||||||
if ( value != 0 ) // 0 is invalid value for our purposes
|
if ( value != 0 ) // 0 is invalid value for our purposes
|
||||||
|
@ -2176,10 +2173,6 @@ void save( Class const & c )
|
||||||
root.appendChild( opt );
|
root.appendChild( opt );
|
||||||
}
|
}
|
||||||
|
|
||||||
opt = dd.createElement( "editDictionaryCommandLine" );
|
|
||||||
opt.appendChild( dd.createTextNode( c.editDictionaryCommandLine ) );
|
|
||||||
root.appendChild( opt );
|
|
||||||
|
|
||||||
opt = dd.createElement( "maxHeadwordSize" );
|
opt = dd.createElement( "maxHeadwordSize" );
|
||||||
opt.appendChild( dd.createTextNode( QString::number( c.maxHeadwordSize ) ) );
|
opt.appendChild( dd.createTextNode( QString::number( c.maxHeadwordSize ) ) );
|
||||||
root.appendChild( opt );
|
root.appendChild( opt );
|
||||||
|
|
|
@ -885,8 +885,6 @@ struct Class
|
||||||
|
|
||||||
HeadwordsDialog headwordsDialog;
|
HeadwordsDialog headwordsDialog;
|
||||||
|
|
||||||
QString editDictionaryCommandLine; // Command line to call external editor for dictionary
|
|
||||||
|
|
||||||
Class():
|
Class():
|
||||||
lastMainGroupId( 0 ),
|
lastMainGroupId( 0 ),
|
||||||
lastPopupGroupId( 0 ),
|
lastPopupGroupId( 0 ),
|
||||||
|
|
|
@ -27,9 +27,6 @@ void DictInfo::showInfo( sptr< Dictionary::Class > dict )
|
||||||
ui.dictionaryTranslatesTo->setText( Language::localizedStringForId( dict->getLangTo() ) );
|
ui.dictionaryTranslatesTo->setText( Language::localizedStringForId( dict->getLangTo() ) );
|
||||||
|
|
||||||
ui.openFolder->setVisible( dict->isLocalDictionary() );
|
ui.openFolder->setVisible( dict->isLocalDictionary() );
|
||||||
ui.editDictionary->setVisible( dict->isLocalDictionary() && !dict->getMainFilename().isEmpty()
|
|
||||||
&& !cfg.editDictionaryCommandLine.isEmpty() );
|
|
||||||
ui.editDictionary->setToolTip( tr( "Edit the dictionary via command:\n%1" ).arg( cfg.editDictionaryCommandLine ) );
|
|
||||||
|
|
||||||
if ( dict->getWordCount() == 0 )
|
if ( dict->getWordCount() == 0 )
|
||||||
ui.headwordsButton->setVisible( false );
|
ui.headwordsButton->setVisible( false );
|
||||||
|
@ -63,11 +60,6 @@ void DictInfo::savePos( int )
|
||||||
cfg.dictInfoGeometry = saveGeometry();
|
cfg.dictInfoGeometry = saveGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DictInfo::on_editDictionary_clicked()
|
|
||||||
{
|
|
||||||
done( EDIT_DICTIONARY );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DictInfo::on_openFolder_clicked()
|
void DictInfo::on_openFolder_clicked()
|
||||||
{
|
{
|
||||||
done( OPEN_FOLDER );
|
done( OPEN_FOLDER );
|
||||||
|
|
|
@ -16,7 +16,6 @@ public:
|
||||||
REJECTED,
|
REJECTED,
|
||||||
ACCEPTED,
|
ACCEPTED,
|
||||||
OPEN_FOLDER,
|
OPEN_FOLDER,
|
||||||
EDIT_DICTIONARY,
|
|
||||||
SHOW_HEADWORDS
|
SHOW_HEADWORDS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ private:
|
||||||
Config::Class & cfg;
|
Config::Class & cfg;
|
||||||
private slots:
|
private slots:
|
||||||
void savePos( int );
|
void savePos( int );
|
||||||
void on_editDictionary_clicked();
|
|
||||||
void on_openFolder_clicked();
|
void on_openFolder_clicked();
|
||||||
void on_OKButton_clicked();
|
void on_OKButton_clicked();
|
||||||
void on_headwordsButton_clicked();
|
void on_headwordsButton_clicked();
|
||||||
|
|
|
@ -23,16 +23,6 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="4">
|
|
||||||
<widget class="QPushButton" name="editDictionary">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Edit dictionary</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="3">
|
<item row="1" column="3">
|
||||||
<widget class="QLabel" name="dictionaryTranslatesTo">
|
<widget class="QLabel" name="dictionaryTranslatesTo">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -11,12 +11,10 @@ using std::vector;
|
||||||
|
|
||||||
DictionaryBar::DictionaryBar( QWidget * parent,
|
DictionaryBar::DictionaryBar( QWidget * parent,
|
||||||
Config::Events & events,
|
Config::Events & events,
|
||||||
QString const & _editDictionaryCommand,
|
|
||||||
unsigned short const & maxDictionaryRefsInContextMenu_ ):
|
unsigned short const & maxDictionaryRefsInContextMenu_ ):
|
||||||
QToolBar( tr( "&Dictionary Bar" ), parent ),
|
QToolBar( tr( "&Dictionary Bar" ), parent ),
|
||||||
mutedDictionaries( nullptr ),
|
mutedDictionaries( nullptr ),
|
||||||
configEvents( events ),
|
configEvents( events ),
|
||||||
editDictionaryCommand( _editDictionaryCommand ),
|
|
||||||
maxDictionaryRefsInContextMenu( maxDictionaryRefsInContextMenu_ )
|
maxDictionaryRefsInContextMenu( maxDictionaryRefsInContextMenu_ )
|
||||||
{
|
{
|
||||||
normalIconSize = { this->iconSize().height(), this->iconSize().height() };
|
normalIconSize = { this->iconSize().height(), this->iconSize().height() };
|
||||||
|
@ -115,7 +113,6 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
|
||||||
|
|
||||||
const QAction * infoAction = nullptr;
|
const QAction * infoAction = nullptr;
|
||||||
const QAction * headwordsAction = nullptr;
|
const QAction * headwordsAction = nullptr;
|
||||||
const QAction * editDictAction = nullptr;
|
|
||||||
const QAction * openDictFolderAction = nullptr;
|
const QAction * openDictFolderAction = nullptr;
|
||||||
QString dictFilename;
|
QString dictFilename;
|
||||||
|
|
||||||
|
@ -138,13 +135,6 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
|
||||||
headwordsAction = menu.addAction( tr( "Dictionary headwords" ) );
|
headwordsAction = menu.addAction( tr( "Dictionary headwords" ) );
|
||||||
|
|
||||||
openDictFolderAction = menu.addAction( tr( "Open dictionary folder" ) );
|
openDictFolderAction = menu.addAction( tr( "Open dictionary folder" ) );
|
||||||
|
|
||||||
if ( !editDictionaryCommand.isEmpty() ) {
|
|
||||||
if ( !pDict->getMainFilename().isEmpty() ) {
|
|
||||||
dictFilename = pDict->getMainFilename();
|
|
||||||
editDictAction = menu.addAction( tr( "Edit dictionary" ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,13 +191,6 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( result && result == editDictAction ) {
|
|
||||||
QString command( editDictionaryCommand );
|
|
||||||
command.replace( "%GDDICT%", QString( R"("%1")" ).arg( dictFilename ) );
|
|
||||||
if ( !QProcess::startDetached( command, QStringList() ) )
|
|
||||||
QApplication::beep();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( result && result == maxDictionaryRefsAction ) {
|
if ( result && result == maxDictionaryRefsAction ) {
|
||||||
showContextMenu( event, true );
|
showContextMenu( event, true );
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,10 +18,7 @@ class DictionaryBar: public QToolBar
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Constructs an empty dictionary bar
|
/// Constructs an empty dictionary bar
|
||||||
DictionaryBar( QWidget * parent,
|
DictionaryBar( QWidget * parent, Config::Events &, unsigned short const & maxDictionaryRefsInContextMenu_ );
|
||||||
Config::Events &,
|
|
||||||
QString const & _editDictionaryCommand,
|
|
||||||
unsigned short const & maxDictionaryRefsInContextMenu_ );
|
|
||||||
|
|
||||||
/// Sets dictionaries to be displayed in the bar. Their statuses (enabled/
|
/// Sets dictionaries to be displayed in the bar. Their statuses (enabled/
|
||||||
/// disabled) are taken from the configuration data.
|
/// disabled) are taken from the configuration data.
|
||||||
|
@ -68,7 +65,7 @@ private:
|
||||||
Config::MutedDictionaries storedMutedSet;
|
Config::MutedDictionaries storedMutedSet;
|
||||||
|
|
||||||
bool enterSoloMode = false;
|
bool enterSoloMode = false;
|
||||||
QString editDictionaryCommand;
|
|
||||||
// how many dictionaries should be shown in the context menu:
|
// how many dictionaries should be shown in the context menu:
|
||||||
unsigned short const & maxDictionaryRefsInContextMenu;
|
unsigned short const & maxDictionaryRefsInContextMenu;
|
||||||
std::vector< sptr< Dictionary::Class > > allDictionaries;
|
std::vector< sptr< Dictionary::Class > > allDictionaries;
|
||||||
|
|
|
@ -155,7 +155,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
addTab( this ),
|
addTab( this ),
|
||||||
cfg( cfg_ ),
|
cfg( cfg_ ),
|
||||||
history( History::Load(), cfg_.preferences.maxStringsInHistory, cfg_.maxHeadwordSize ),
|
history( History::Load(), cfg_.preferences.maxStringsInHistory, cfg_.maxHeadwordSize ),
|
||||||
dictionaryBar( this, configEvents, cfg.editDictionaryCommandLine, cfg.preferences.maxDictionaryRefsInContextMenu ),
|
dictionaryBar( this, configEvents, cfg.preferences.maxDictionaryRefsInContextMenu ),
|
||||||
articleMaker( dictionaries, groupInstances, cfg.preferences ),
|
articleMaker( dictionaries, groupInstances, cfg.preferences ),
|
||||||
articleNetMgr( this,
|
articleNetMgr( this,
|
||||||
dictionaries,
|
dictionaries,
|
||||||
|
@ -4021,9 +4021,6 @@ void MainWindow::showDictionaryInfo( const QString & id )
|
||||||
if ( result == DictInfo::OPEN_FOLDER ) {
|
if ( result == DictInfo::OPEN_FOLDER ) {
|
||||||
openDictionaryFolder( id );
|
openDictionaryFolder( id );
|
||||||
}
|
}
|
||||||
else if ( result == DictInfo::EDIT_DICTIONARY ) {
|
|
||||||
editDictionary( dictionaries[ x ].get() );
|
|
||||||
}
|
|
||||||
else if ( result == DictInfo::SHOW_HEADWORDS ) {
|
else if ( result == DictInfo::SHOW_HEADWORDS ) {
|
||||||
showDictionaryHeadwords( dictionaries[ x ].get() );
|
showDictionaryHeadwords( dictionaries[ x ].get() );
|
||||||
}
|
}
|
||||||
|
@ -4100,21 +4097,6 @@ void MainWindow::stopAudio()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::editDictionary( Dictionary::Class * dict )
|
|
||||||
{
|
|
||||||
QString dictFilename = dict->getMainFilename();
|
|
||||||
if ( !cfg.editDictionaryCommandLine.isEmpty() && !dictFilename.isEmpty() ) {
|
|
||||||
QString command( cfg.editDictionaryCommandLine );
|
|
||||||
command.replace( "%GDDICT%", "\"" + dictFilename + "\"" );
|
|
||||||
if ( command.contains( "%GDWORD%" ) ) {
|
|
||||||
QString headword = unescapeTabHeader( ui.tabWidget->tabText( ui.tabWidget->currentIndex() ) );
|
|
||||||
command.replace( "%GDWORD%", headword );
|
|
||||||
}
|
|
||||||
if ( !QProcess::startDetached( command, QStringList() ) )
|
|
||||||
QApplication::beep();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::openDictionaryFolder( const QString & id )
|
void MainWindow::openDictionaryFolder( const QString & id )
|
||||||
{
|
{
|
||||||
for ( unsigned x = 0; x < dictionaries.size(); x++ ) {
|
for ( unsigned x = 0; x < dictionaries.size(); x++ ) {
|
||||||
|
@ -4161,12 +4143,6 @@ void MainWindow::foundDictsContextMenuRequested( const QPoint & pos )
|
||||||
|
|
||||||
QAction * openDictFolderAction = menu.addAction( tr( "Open dictionary folder" ) );
|
QAction * openDictFolderAction = menu.addAction( tr( "Open dictionary folder" ) );
|
||||||
|
|
||||||
QAction * editAction = nullptr;
|
|
||||||
|
|
||||||
QString dictFilename = pDict->getMainFilename();
|
|
||||||
if ( !cfg.editDictionaryCommandLine.isEmpty() && !dictFilename.isEmpty() )
|
|
||||||
editAction = menu.addAction( tr( "Edit dictionary" ) );
|
|
||||||
|
|
||||||
QAction * result = menu.exec( ui.dictsList->mapToGlobal( pos ) );
|
QAction * result = menu.exec( ui.dictsList->mapToGlobal( pos ) );
|
||||||
|
|
||||||
if ( result && result == infoAction ) {
|
if ( result && result == infoAction ) {
|
||||||
|
@ -4186,9 +4162,6 @@ void MainWindow::foundDictsContextMenuRequested( const QPoint & pos )
|
||||||
else if ( result && result == openDictFolderAction ) {
|
else if ( result && result == openDictFolderAction ) {
|
||||||
openDictionaryFolder( id );
|
openDictionaryFolder( id );
|
||||||
}
|
}
|
||||||
else if ( result && result == editAction ) {
|
|
||||||
editDictionary( pDict );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,8 +290,6 @@ private slots:
|
||||||
|
|
||||||
void openDictionaryFolder( QString const & id );
|
void openDictionaryFolder( QString const & id );
|
||||||
|
|
||||||
void editDictionary( Dictionary::Class * dict );
|
|
||||||
|
|
||||||
void showFTSIndexingName( QString const & name );
|
void showFTSIndexingName( QString const & name );
|
||||||
|
|
||||||
void handleAddToFavoritesButton();
|
void handleAddToFavoritesButton();
|
||||||
|
|
|
@ -80,7 +80,7 @@ ScanPopup::ScanPopup( QWidget * parent,
|
||||||
stopAudioAction( this ),
|
stopAudioAction( this ),
|
||||||
openSearchAction( this ),
|
openSearchAction( this ),
|
||||||
wordFinder( this ),
|
wordFinder( this ),
|
||||||
dictionaryBar( this, configEvents, cfg.editDictionaryCommandLine, cfg.preferences.maxDictionaryRefsInContextMenu ),
|
dictionaryBar( this, configEvents, cfg.preferences.maxDictionaryRefsInContextMenu ),
|
||||||
hideTimer( this )
|
hideTimer( this )
|
||||||
{
|
{
|
||||||
ui.setupUi( this );
|
ui.setupUi( this );
|
||||||
|
|
Loading…
Reference in a new issue