mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
The following patches made by Dmitry E. Oboukhov applied:
* Middle click on the tray icon translates current selection * Middle click on the main window also translates current selection * When editing groups, double click on the dictionary adds it to the current group.
This commit is contained in:
parent
f7d47163d3
commit
64867e9f1b
|
@ -36,6 +36,8 @@ Groups::Groups( QWidget * parent,
|
||||||
this, SLOT( removeAll() ) );
|
this, SLOT( removeAll() ) );
|
||||||
connect( ui.addDictsToGroup, SIGNAL( clicked() ),
|
connect( ui.addDictsToGroup, SIGNAL( clicked() ),
|
||||||
this, SLOT( addToGroup() ) );
|
this, SLOT( addToGroup() ) );
|
||||||
|
connect( ui.dictionaries, SIGNAL( doubleClicked(const QModelIndex &) ),
|
||||||
|
this, SLOT( addToGroup() ) );
|
||||||
connect( ui.removeDictsFromGroup, SIGNAL( clicked() ),
|
connect( ui.removeDictsFromGroup, SIGNAL( clicked() ),
|
||||||
this, SLOT( removeFromGroup() ) );
|
this, SLOT( removeFromGroup() ) );
|
||||||
|
|
||||||
|
|
|
@ -274,6 +274,22 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
doDeferredInit( dictionaries );
|
doDeferredInit( dictionaries );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::mousePressEvent( QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() != Qt::MidButton)
|
||||||
|
return QMainWindow::mousePressEvent(event);
|
||||||
|
// middle clicked
|
||||||
|
QString subtype = "plain";
|
||||||
|
|
||||||
|
QString str = QApplication::clipboard()->text(subtype,
|
||||||
|
QClipboard::Selection);
|
||||||
|
ui.translateLine->setText(str);
|
||||||
|
|
||||||
|
QKeyEvent ev(QEvent::Type(6)/*QEvent::KeyPress*/, Qt::Key_Enter,
|
||||||
|
Qt::NoModifier);
|
||||||
|
QApplication::sendEvent(ui.translateLine, &ev);
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
// Save MainWindow state and geometry
|
// Save MainWindow state and geometry
|
||||||
|
@ -1273,11 +1289,23 @@ void MainWindow::latestReleaseReplyReady()
|
||||||
|
|
||||||
void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason r )
|
void MainWindow::trayIconActivated( QSystemTrayIcon::ActivationReason r )
|
||||||
{
|
{
|
||||||
if ( r == QSystemTrayIcon::Trigger )
|
switch(r) {
|
||||||
{
|
case QSystemTrayIcon::Trigger:
|
||||||
// Left click toggles the visibility of main window
|
// Left click toggles the visibility of main window
|
||||||
toggleMainWindow();
|
toggleMainWindow();
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
case QSystemTrayIcon::MiddleClick:
|
||||||
|
// Middle mouse click on Tray translates selection
|
||||||
|
// it is functional like as stardict
|
||||||
|
if ( scanPopup.get() ) {
|
||||||
|
scanPopup->translateWordFromSelection();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::scanEnableToggled( bool on )
|
void MainWindow::scanEnableToggled( bool on )
|
||||||
|
|
|
@ -108,6 +108,8 @@ private:
|
||||||
|
|
||||||
void applyZoomFactor();
|
void applyZoomFactor();
|
||||||
|
|
||||||
|
void mousePressEvent ( QMouseEvent * event );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void hotKeyActivated( int );
|
void hotKeyActivated( int );
|
||||||
|
|
|
@ -141,12 +141,21 @@ void ScanPopup::applyZoomFactor()
|
||||||
|
|
||||||
void ScanPopup::translateWordFromClipboard()
|
void ScanPopup::translateWordFromClipboard()
|
||||||
{
|
{
|
||||||
printf( "translating from clipboard\n" );
|
return translateWordFromClipboard(QClipboard::Clipboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScanPopup::translateWordFromSelection()
|
||||||
|
{
|
||||||
|
return translateWordFromClipboard(QClipboard::Selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScanPopup::translateWordFromClipboard(QClipboard::Mode m)
|
||||||
|
{
|
||||||
|
printf( "translating from clipboard or selection\n" );
|
||||||
|
|
||||||
QString subtype = "plain";
|
QString subtype = "plain";
|
||||||
|
|
||||||
QString str = QApplication::clipboard()->text( subtype,
|
QString str = QApplication::clipboard()->text( subtype, m);
|
||||||
QClipboard::Clipboard );
|
|
||||||
|
|
||||||
str = pendingInputWord = gd::toQString( Folding::trimWhitespaceOrPunct( gd::toWString( str ) ) );
|
str = pendingInputWord = gd::toQString( Folding::trimWhitespaceOrPunct( gd::toWString( str ) ) );
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,14 @@ public slots:
|
||||||
|
|
||||||
/// Translates the word from the clipboard, showing the window etc.
|
/// Translates the word from the clipboard, showing the window etc.
|
||||||
void translateWordFromClipboard();
|
void translateWordFromClipboard();
|
||||||
|
/// Translates the word from the clipboard selection
|
||||||
|
void translateWordFromSelection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// Translates the word from the clipboard or the clipboard selection
|
||||||
|
void translateWordFromClipboard(QClipboard::Mode m);
|
||||||
|
|
||||||
Config::Class & cfg;
|
Config::Class & cfg;
|
||||||
bool isScanningEnabled;
|
bool isScanningEnabled;
|
||||||
std::vector< sptr< Dictionary::Class > > const & allDictionaries;
|
std::vector< sptr< Dictionary::Class > > const & allDictionaries;
|
||||||
|
|
Loading…
Reference in a new issue