mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Merge branch 'staged' into dev
This commit is contained in:
commit
c14009d9f7
|
@ -18,12 +18,22 @@ ArticleInspector::ArticleInspector( QWidget * parent ) : QWidget( parent, Qt::Wi
|
|||
|
||||
void ArticleInspector::setInspectPage( QWebEngineView * view )
|
||||
{
|
||||
auto page=view->page();
|
||||
viewContainer->page()->setInspectedPage(page);
|
||||
#if( QT_VERSION > QT_VERSION_CHECK( 6, 3, 0 ) || QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
||||
auto page = view->page();
|
||||
viewContainer->page()->setInspectedPage( page );
|
||||
#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) )
|
||||
page->triggerAction( QWebEnginePage::InspectElement );
|
||||
#else
|
||||
// without this line, application will crash on qt6.2 ,see https://bugreports.qt.io/browse/QTBUG-101724
|
||||
// and seems to hangup forever on qt6.3.0 ,so the best solution for now is to comment out the following lines.
|
||||
page->triggerAction( QWebEnginePage::InspectElement );
|
||||
static bool first{ true };
|
||||
if( first )
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
page->triggerAction( QWebEnginePage::InspectElement );
|
||||
}
|
||||
#endif
|
||||
|
||||
raise();
|
||||
|
|
|
@ -411,7 +411,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
actTrackingClipboard = trayIconMenu.addAction( tr( "Tracking Clipboard" ) );
|
||||
actTrackingClipboard->setCheckable(true);
|
||||
actTrackingClipboard->setChecked(cfg.preferences.trackClipboardChanges);
|
||||
actTrackingClipboard->setVisible( cfg.preferences.enableScanPopup );
|
||||
// actTrackingClipboard->setVisible( cfg.preferences.enableScanPopup );
|
||||
connect( actTrackingClipboard , SIGNAL( triggered(bool) ),
|
||||
this, SLOT( trackingClipboard(bool) ) );
|
||||
trayIconMenu.addSeparator();
|
||||
|
@ -918,6 +918,16 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
}
|
||||
|
||||
inspector = new ArticleInspector( this );
|
||||
|
||||
connect( QApplication::clipboard(), &QClipboard::changed, this, &MainWindow::clipboardChange );
|
||||
}
|
||||
|
||||
void MainWindow::clipboardChange( QClipboard::Mode mode )
|
||||
{
|
||||
if( scanPopup && cfg.preferences.trackClipboardChanges )
|
||||
{
|
||||
scanPopup->translateWordFromClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ctrlTabPressed()
|
||||
|
|
|
@ -487,6 +487,8 @@ private slots:
|
|||
void showGDHelp();
|
||||
void hideGDHelp();
|
||||
|
||||
void clipboardChange( QClipboard::Mode mode );
|
||||
|
||||
signals:
|
||||
/// Set optional parts expand mode for all tabs
|
||||
void setExpandOptionalParts( bool expand );
|
||||
|
|
|
@ -514,14 +514,6 @@ void ScanPopup::delayShow()
|
|||
|
||||
void ScanPopup::clipboardChanged( QClipboard::Mode m )
|
||||
{
|
||||
if( cfg.preferences.trackClipboardChanges )
|
||||
{
|
||||
QString subtype = "plain";
|
||||
|
||||
handleInputWord( QApplication::clipboard()->text( subtype, m ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !isScanningEnabled )
|
||||
return;
|
||||
|
||||
|
|
138
sptr.hh
138
sptr.hh
|
@ -4,22 +4,150 @@
|
|||
#ifndef __SPTR_HH_INCLUDED__
|
||||
#define __SPTR_HH_INCLUDED__
|
||||
|
||||
// using std::shared_ptr
|
||||
|
||||
// A generic non-intrusive smart-pointer template. We could use boost::, tr1::
|
||||
// or whatever, but since there's no standard solution yet, it isn't worth
|
||||
// the dependency given the simplicity of the template.
|
||||
|
||||
template< class T >
|
||||
class sptr: public std::shared_ptr< T >
|
||||
class sptr_base
|
||||
{
|
||||
template< class TT > friend class sptr_base;
|
||||
|
||||
T * p;
|
||||
unsigned * count;
|
||||
|
||||
|
||||
void increment()
|
||||
{
|
||||
if ( count )
|
||||
++*count;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
sptr_base(): p( 0 ), count( 0 ) {}
|
||||
|
||||
sptr_base( T * p_ ): p( p_ ), count( p ? new unsigned( 1 ) : 0 )
|
||||
{
|
||||
}
|
||||
|
||||
sptr_base( sptr_base< T > const & other ): p( other.p ), count( other.count )
|
||||
{ increment(); }
|
||||
|
||||
// TT is meant to be a derivative of T
|
||||
template< class TT >
|
||||
sptr_base( sptr_base< TT > const & other ): p( ( T * ) other.p ),
|
||||
count( other.count )
|
||||
{ increment(); }
|
||||
|
||||
void reset()
|
||||
{
|
||||
if ( count )
|
||||
{
|
||||
if ( ! -- *count )
|
||||
{
|
||||
delete count;
|
||||
|
||||
count = 0;
|
||||
|
||||
if ( p )
|
||||
{
|
||||
T * p_ = p;
|
||||
|
||||
p = 0;
|
||||
|
||||
delete p_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = 0;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sptr_base & operator = ( sptr_base const & other )
|
||||
{ if ( &other != this ) { reset(); p = other.p; count = other.count; increment(); }
|
||||
return * this; }
|
||||
|
||||
bool operator ! ( void ) const
|
||||
{ return !p; }
|
||||
|
||||
bool operator == ( sptr_base const & other ) const
|
||||
{ return p == other.p; }
|
||||
|
||||
bool operator != ( sptr_base const & other ) const
|
||||
{ return p != other.p; }
|
||||
|
||||
~sptr_base()
|
||||
{ reset(); }
|
||||
|
||||
protected:
|
||||
|
||||
T * get_base( void ) const
|
||||
{ return p; }
|
||||
};
|
||||
|
||||
template< class T >
|
||||
class sptr: public sptr_base< T >
|
||||
{
|
||||
public:
|
||||
|
||||
sptr() {}
|
||||
|
||||
sptr( T * p ): std::shared_ptr< T >( p ) {}
|
||||
sptr( T * p ): sptr_base< T >( p ) {}
|
||||
|
||||
// TT is meant to be a derivative of T
|
||||
template< class TT >
|
||||
sptr( sptr< TT > const & other ): std::shared_ptr< T >( other ) {}
|
||||
sptr( sptr< TT > const & other ): sptr_base< T >( other ) {}
|
||||
|
||||
// Retrieval
|
||||
T * get( void ) const
|
||||
{ return sptr_base< T > :: get_base(); }
|
||||
|
||||
T * operator -> ( void ) const
|
||||
{ return get(); }
|
||||
|
||||
T & operator * ( void ) const
|
||||
{ return * get(); }
|
||||
|
||||
// Check
|
||||
|
||||
operator bool( void ) const
|
||||
{ return get(); }
|
||||
|
||||
bool operator ! ( void ) const
|
||||
{ return !get(); }
|
||||
};
|
||||
|
||||
template< class T >
|
||||
class const_sptr: public sptr_base< T >
|
||||
{
|
||||
public:
|
||||
|
||||
const_sptr() {}
|
||||
|
||||
const_sptr( T * p_ ): sptr_base< T >( p_ ) {}
|
||||
|
||||
const_sptr( sptr< T > const & other ): sptr_base< T >( other ) {}
|
||||
|
||||
// TT is meant to be a derivative of T
|
||||
template< class TT >
|
||||
const_sptr( sptr_base< TT > const & other ): sptr_base< T >( other ) {}
|
||||
|
||||
// Retrieval
|
||||
|
||||
T const * get( void ) const
|
||||
{ return sptr_base< T > :: get_base(); }
|
||||
|
||||
T const * operator -> ( void ) const
|
||||
{ return get(); }
|
||||
|
||||
T const & operator * ( void ) const
|
||||
{ return * get(); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -44,9 +44,10 @@ public:
|
|||
{
|
||||
QString temp=urlTemplate_;
|
||||
if(temp.endsWith("##")){
|
||||
experimentalIframe=true;
|
||||
temp.chop(2);
|
||||
}
|
||||
//make this default.
|
||||
experimentalIframe = true;
|
||||
|
||||
urlTemplate = QUrl( temp ).toEncoded() ;
|
||||
|
||||
|
|
Loading…
Reference in a new issue