mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-17 23:04:06 +00:00
feature: add anki connect configuration
This commit is contained in:
parent
a625bee498
commit
fbfc2d7f43
31
config.cc
31
config.cc
|
@ -89,6 +89,10 @@ ProxyServer::ProxyServer(): enabled( false ), useSystemProxy( false ), type( Soc
|
|||
{
|
||||
}
|
||||
|
||||
AnkiConnectServer::AnkiConnectServer(): enabled( false ), host("127.0.0.1"), port( 8765 )
|
||||
{
|
||||
}
|
||||
|
||||
HotKey::HotKey(): modifiers( 0 ), key1( 0 ), key2( 0 )
|
||||
{
|
||||
}
|
||||
|
@ -937,6 +941,15 @@ Class load()
|
|||
c.preferences.proxyServer.systemProxyPassword = proxy.namedItem( "systemProxyPassword" ).toElement().text();
|
||||
}
|
||||
|
||||
QDomNode ankiConnectServer = preferences.namedItem( "ankiConnectServer" );
|
||||
|
||||
if ( !ankiConnectServer.isNull() )
|
||||
{
|
||||
c.preferences.ankiConnectServer.enabled = ( ankiConnectServer.toElement().attribute( "enabled" ) == "1" );
|
||||
c.preferences.ankiConnectServer.host = ankiConnectServer.namedItem( "host" ).toElement().text();
|
||||
c.preferences.ankiConnectServer.port = ankiConnectServer.namedItem( "port" ).toElement().text().toULong();
|
||||
}
|
||||
|
||||
if ( !preferences.namedItem( "checkForNewReleases" ).isNull() )
|
||||
c.preferences.checkForNewReleases = ( preferences.namedItem( "checkForNewReleases" ).toElement().text() == "1" );
|
||||
|
||||
|
@ -1872,6 +1885,24 @@ void save( Class const & c )
|
|||
proxy.appendChild( opt );
|
||||
}
|
||||
|
||||
//anki connect
|
||||
{
|
||||
QDomElement proxy = dd.createElement( "ankiConnectServer" );
|
||||
preferences.appendChild( proxy );
|
||||
|
||||
QDomAttr enabled = dd.createAttribute( "enabled" );
|
||||
enabled.setValue( c.preferences.ankiConnectServer.enabled ? "1" : "0" );
|
||||
proxy.setAttributeNode( enabled );
|
||||
|
||||
opt = dd.createElement( "host" );
|
||||
opt.appendChild( dd.createTextNode( c.preferences.ankiConnectServer.host ) );
|
||||
proxy.appendChild( opt );
|
||||
|
||||
opt = dd.createElement( "port" );
|
||||
opt.appendChild( dd.createTextNode( QString::number( c.preferences.ankiConnectServer.port ) ) );
|
||||
proxy.appendChild( opt );
|
||||
}
|
||||
|
||||
opt = dd.createElement( "checkForNewReleases" );
|
||||
opt.appendChild( dd.createTextNode( c.preferences.checkForNewReleases ? "1" : "0" ) );
|
||||
preferences.appendChild( opt );
|
||||
|
|
11
config.hh
11
config.hh
|
@ -137,6 +137,16 @@ struct ProxyServer
|
|||
ProxyServer();
|
||||
};
|
||||
|
||||
struct AnkiConnectServer
|
||||
{
|
||||
bool enabled;
|
||||
|
||||
QString host;
|
||||
unsigned port;
|
||||
|
||||
AnkiConnectServer();
|
||||
};
|
||||
|
||||
// A hotkey -- currently qt modifiers plus one or two keys
|
||||
struct HotKey
|
||||
{
|
||||
|
@ -329,6 +339,7 @@ struct Preferences
|
|||
QString audioPlaybackProgram;
|
||||
|
||||
ProxyServer proxyServer;
|
||||
AnkiConnectServer ankiConnectServer;
|
||||
|
||||
bool checkForNewReleases;
|
||||
bool disallowContentFromOtherSites;
|
||||
|
|
|
@ -323,6 +323,11 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
|||
ui.customSettingsGroup->setEnabled( p.proxyServer.enabled );
|
||||
}
|
||||
|
||||
//anki connect
|
||||
ui.useAnkiConnect->setChecked( p.ankiConnectServer.enabled );
|
||||
ui.ankiHost->setText( p.ankiConnectServer.host );
|
||||
ui.ankiPort->setValue( p.ankiConnectServer.port );
|
||||
|
||||
connect( ui.customProxy, SIGNAL( toggled( bool ) ),
|
||||
this, SLOT( customProxyToggled( bool ) ) );
|
||||
|
||||
|
@ -466,6 +471,11 @@ Config::Preferences Preferences::getPreferences()
|
|||
p.proxyServer.user = ui.proxyUser->text();
|
||||
p.proxyServer.password = ui.proxyPassword->text();
|
||||
|
||||
//anki connect
|
||||
p.ankiConnectServer.enabled = ui.useAnkiConnect->isChecked();
|
||||
p.ankiConnectServer.host = ui.ankiHost->text();
|
||||
p.ankiConnectServer.port = (unsigned)ui.ankiPort->value();
|
||||
|
||||
p.checkForNewReleases = ui.checkForNewReleases->isChecked();
|
||||
p.disallowContentFromOtherSites = ui.disallowContentFromOtherSites->isChecked();
|
||||
p.enableWebPlugins = ui.enableWebPlugins->isChecked();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
|
@ -993,6 +993,9 @@ for all program's network requests.</string>
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="customSettingsGroup">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Custom settings</string>
|
||||
</property>
|
||||
|
@ -1011,6 +1014,9 @@ for all program's network requests.</string>
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
|
@ -1073,20 +1079,69 @@ for all program's network requests.</string>
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_14">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QGroupBox" name="useAnkiConnect">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
<property name="title">
|
||||
<string>Anki Connect</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</spacer>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_17">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_22">
|
||||
<property name="text">
|
||||
<string>Host:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="text">
|
||||
<string>http://</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="ankiHost"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="ankiPort">
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>8080</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_16">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="disallowContentFromOtherSites">
|
||||
|
@ -1176,22 +1231,6 @@ clears its network cache from disk during exit.</string>
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_10">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkForNewReleases">
|
||||
<property name="toolTip">
|
||||
|
|
Loading…
Reference in a new issue