mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 08:34:08 +00:00
Merge branch 'Temp' into Qt4x5
Conflicts: mainwindow.cc
This commit is contained in:
commit
d133ae7369
35
config.cc
35
config.cc
|
@ -799,6 +799,22 @@ Class load() throw( exError )
|
|||
height = maximizedMainWindowGeometry.namedItem( "height" ).toElement().text().toInt();
|
||||
c.maximizedMainWindowGeometry = QRect( x, y, width, height );
|
||||
}
|
||||
|
||||
QDomNode normalMainWindowGeometry = root.namedItem( "normalMainWindowGeometry" );
|
||||
|
||||
if ( !normalMainWindowGeometry.isNull() )
|
||||
{
|
||||
int x = 0, y = 0, width = 0, height = 0;
|
||||
if( !normalMainWindowGeometry.namedItem( "x" ).isNull() )
|
||||
x = normalMainWindowGeometry.namedItem( "x" ).toElement().text().toInt();
|
||||
if( !normalMainWindowGeometry.namedItem( "y" ).isNull() )
|
||||
y = normalMainWindowGeometry.namedItem( "y" ).toElement().text().toInt();
|
||||
if( !normalMainWindowGeometry.namedItem( "width" ).isNull() )
|
||||
width = normalMainWindowGeometry.namedItem( "width" ).toElement().text().toInt();
|
||||
if( !normalMainWindowGeometry.namedItem( "height" ).isNull() )
|
||||
height = normalMainWindowGeometry.namedItem( "height" ).toElement().text().toInt();
|
||||
c.normalMainWindowGeometry = QRect( x, y, width, height );
|
||||
}
|
||||
#endif
|
||||
|
||||
QDomNode dictInfoGeometry = root.namedItem( "dictInfoGeometry" );
|
||||
|
@ -1536,6 +1552,25 @@ void save( Class const & c ) throw( exError )
|
|||
opt = dd.createElement( "height" );
|
||||
opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.height() ) ) );
|
||||
maximizedMainWindowGeometry.appendChild( opt );
|
||||
|
||||
QDomElement normalMainWindowGeometry = dd.createElement( "normalMainWindowGeometry" );
|
||||
root.appendChild( normalMainWindowGeometry );
|
||||
|
||||
opt = dd.createElement( "x" );
|
||||
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.x() ) ) );
|
||||
normalMainWindowGeometry.appendChild( opt );
|
||||
|
||||
opt = dd.createElement( "y" );
|
||||
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.y() ) ) );
|
||||
normalMainWindowGeometry.appendChild( opt );
|
||||
|
||||
opt = dd.createElement( "width" );
|
||||
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.width() ) ) );
|
||||
normalMainWindowGeometry.appendChild( opt );
|
||||
|
||||
opt = dd.createElement( "height" );
|
||||
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.height() ) ) );
|
||||
normalMainWindowGeometry.appendChild( opt );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -475,6 +475,7 @@ struct Class
|
|||
|
||||
#ifdef Q_OS_WIN
|
||||
QRect maximizedMainWindowGeometry;
|
||||
QRect normalMainWindowGeometry;
|
||||
#endif
|
||||
|
||||
QString editDictionaryCommandLine; // Command line to call external editor for dictionary
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "fsencoding.hh"
|
||||
#include "historypanewidget.hh"
|
||||
#include "qt4x5.hh"
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "lionsupport.h"
|
||||
|
@ -48,6 +49,10 @@
|
|||
#include "mouseover_win32/GDDataTranfer.h"
|
||||
#include "wstring.hh"
|
||||
#include "wstring_qt.hh"
|
||||
|
||||
#define gdStoreNormalGeometryEvent ( ( QEvent::Type )( QEvent::User + 1 ) )
|
||||
#define gdApplyNormalGeometryEvent ( ( QEvent::Type )( QEvent::User + 2 ) )
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_X11
|
||||
|
@ -654,13 +659,16 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
ui.historyList->installEventFilter( this );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QRect baseGeometry;
|
||||
if( cfg.normalMainWindowGeometry.width() <= 0 )
|
||||
{
|
||||
QRect r = QApplication::desktop()->availableGeometry();
|
||||
cfg.normalMainWindowGeometry.setRect( r.width() / 4, r.height() / 4, r.width() / 2, r.height() / 2 );
|
||||
}
|
||||
if( cfg.maximizedMainWindowGeometry.width() > 0 )
|
||||
{
|
||||
setGeometry( cfg.maximizedMainWindowGeometry );
|
||||
if ( cfg.mainWindowGeometry.size() )
|
||||
restoreGeometry( cfg.mainWindowGeometry );
|
||||
baseGeometry = geometry();
|
||||
setGeometry( cfg.maximizedMainWindowGeometry );
|
||||
if ( cfg.mainWindowState.size() )
|
||||
restoreState( cfg.mainWindowState, 1 );
|
||||
setWindowState( windowState() | Qt::WindowMaximized );
|
||||
|
@ -742,15 +750,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
{
|
||||
show();
|
||||
focusTranslateLine();
|
||||
#ifdef Q_OS_WIN
|
||||
if( baseGeometry.width() > 0 )
|
||||
{
|
||||
hide();
|
||||
setGeometry( baseGeometry );
|
||||
showMaximized();
|
||||
activateWindow();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
connect( &newReleaseCheckTimer, SIGNAL( timeout() ),
|
||||
|
@ -877,9 +876,15 @@ MainWindow::~MainWindow()
|
|||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if( isMaximized() )
|
||||
{
|
||||
cfg.maximizedMainWindowGeometry = geometry();
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg.maximizedMainWindowGeometry = QRect();
|
||||
if( !isMinimized() )
|
||||
cfg.normalMainWindowGeometry = geometry();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Close all tabs -- they should be destroyed before network managers
|
||||
|
@ -2032,6 +2037,23 @@ bool MainWindow::handleBackForwardMouseButtons ( QMouseEvent * event) {
|
|||
|
||||
bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if( obj == this && ev->type() == gdStoreNormalGeometryEvent )
|
||||
{
|
||||
if( !isMaximized() && !isMinimized() && !isFullScreen() )
|
||||
cfg.normalMainWindowGeometry = normalGeometry();
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
if( obj == this && ev->type() == gdApplyNormalGeometryEvent )
|
||||
{
|
||||
if( !isMaximized() && !isMinimized() && !isFullScreen() )
|
||||
setGeometry( cfg.normalMainWindowGeometry );
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
if ( ev->type() == QEvent::ShortcutOverride ) {
|
||||
// Handle Ctrl+H to show the History Pane.
|
||||
QKeyEvent * ke = static_cast<QKeyEvent*>( ev );
|
||||
|
@ -2054,6 +2076,13 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
// when the main window is moved or resized, hide the word list suggestions
|
||||
if ( obj == this && ( ev->type() == QEvent::Move || ev->type() == QEvent::Resize ) )
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if( !isMaximized() && !isMinimized() && !isFullScreen() && gdAskMessage != 0xFFFFFFFF )
|
||||
{
|
||||
QEvent *ev = new QEvent( gdStoreNormalGeometryEvent );
|
||||
qApp->postEvent( this, ev );
|
||||
}
|
||||
#endif
|
||||
if ( !cfg.preferences.searchInDock )
|
||||
{
|
||||
translateBox->setPopupEnabled( false );
|
||||
|
@ -2065,6 +2094,14 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
|||
{
|
||||
QWindowStateChangeEvent *stev = static_cast< QWindowStateChangeEvent *>( ev );
|
||||
wasMaximized = ( stev->oldState() == Qt::WindowMaximized && isMinimized() );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if( stev->oldState() == Qt::WindowMaximized && !isMinimized() && cfg.normalMainWindowGeometry.width() > 0 )
|
||||
{
|
||||
QEvent *ev = new QEvent( gdApplyNormalGeometryEvent );
|
||||
qApp->postEvent( this, ev );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( ev->type() == QEvent::MouseButtonPress ) {
|
||||
|
|
Loading…
Reference in a new issue