forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
articleinspector.cc
55 lines (44 loc) · 1.25 KB
/
articleinspector.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "articleinspector.hh"
#if QT_VERSION >= 0x040600
#include <algorithm>
using std::list;
list< ArticleInspector * > ArticleInspector::openedInspectors;
ArticleInspector::ArticleInspector( Config::Class * cfg, QWidget* parent ) :
QWebInspector( parent ),
cfg( cfg )
{
if ( cfg == NULL )
throw exInit();
}
ArticleInspector::~ArticleInspector()
{
}
void ArticleInspector::beforeClosed()
{
list< ArticleInspector * >::iterator itemIter = std::find( openedInspectors.begin(),
openedInspectors.end(), this );
if ( itemIter != openedInspectors.end() )
{
openedInspectors.erase( itemIter );
// Save geometry of the recent closed inspector window
QByteArray geometry = saveGeometry();
cfg->inspectorGeometry = geometry;
}
}
void ArticleInspector::showEvent( QShowEvent * event )
{
if ( openedInspectors.empty() )
{
// Restore geometry from config, if no inspector opened
restoreGeometry( cfg->inspectorGeometry );
}
else
{
// Load geometry from first inspector opened
ArticleInspector * p = openedInspectors.front();
setGeometry( p->geometry() );
}
openedInspectors.push_back( this );
QWebInspector::showEvent( event );
}
#endif // QT_VERSION