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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/******************************************************************************
*
* Copyright (C) 2002 Hugo PEREIRA <mailto: hugo.pereira@free.fr>
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* Any WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
*******************************************************************************/
#include "CounterDialog.h"
#include "Debug.h"
#include "DebugMenu.h"
#include "IconCacheDialog.h"
#include "OptionDialog.h"
#include "SystemEnvironmentDialog.h"
#include <QApplication>
#include <QKeyEvent>
//_______________________________________________________
DebugMenu::DebugMenu( QWidget* parent, Flags flags ):
QMenu( parent ),
Counter( "DebugMenu" )
{
setTitle( tr( "Debug" ) );
Debug::Throw( "DebugMenu::DebugMenu.\n" );
if( flags&Flag::Counters ) addAction( tr("Object Counters"), this, SLOT(_showCounterDialog()) );
if( flags&Flag::Icons ) addAction( tr("Icon Cache"), this, SLOT(_showIconCacheDialog()) );
if( flags&Flag::System ) addAction( tr("System environment"), this, SLOT(_showSystemEnvironment()) );
if( flags&Flag::Options ) addAction( tr("Run-time options"), this, SLOT(_showOptions()) );
if( qobject_cast<QMenu*>( parent ) ) parent->installEventFilter( this );
}
//_______________________________________________
bool DebugMenu::eventFilter( QObject* object, QEvent* event )
{
// check object
if( object == parentWidget() )
{
switch( event->type() )
{
case QEvent::KeyPress:
if( static_cast<QKeyEvent*>( event )->key() == Qt::Key_Shift )
{ menuAction()->setVisible( true ); }
break;
case QEvent::KeyRelease:
if( static_cast<QKeyEvent*>( event )->key() == Qt::Key_Shift )
{ menuAction()->setVisible( false ); }
break;
case QEvent::Show:
menuAction()->setVisible( false );
default: break;
}
}
return QMenu::eventFilter( object, event );
}
//_______________________________________________
void DebugMenu::_showCounterDialog()
{
Debug::Throw( "DebugMenu::_ShowCounterDialog.\n" );
// check counter dialog has been build
if( !counterDialog_ ) {
counterDialog_ = new CounterDialog( qApp->activeWindow() );
counterDialog_->centerOnWidget( qApp->activeWindow() );
counterDialog_->update();
counterDialog_->show();
} else {
counterDialog_->update();
counterDialog_->centerOnWidget( qApp->activeWindow() );
counterDialog_->show();
counterDialog_->uniconify();
}
}
//_______________________________________________
void DebugMenu::_showIconCacheDialog()
{
Debug::Throw( "DebugMenu::_ShowIconCacheDialog.\n" );
// check IconCache dialog has been build
if( !iconCacheDialog_ ) {
iconCacheDialog_ = new IconCacheDialog( this );
iconCacheDialog_->centerOnWidget( qApp->activeWindow() );
iconCacheDialog_->update();
iconCacheDialog_->show();
} else {
iconCacheDialog_->update();
iconCacheDialog_->centerOnWidget( qApp->activeWindow() );
iconCacheDialog_->show();
iconCacheDialog_->uniconify();
}
}
//_______________________________________________
void DebugMenu::_showSystemEnvironment()
{
Debug::Throw( "DebugMenu::_showSystemEnvironment.\n" );
auto&& dialog = new SystemEnvironmentDialog( qApp->activeWindow() );
dialog->centerOnWidget( qApp->activeWindow() );
dialog->show();
return;
}
//_______________________________________________
void DebugMenu::_showOptions()
{
Debug::Throw( "DebugMenu::_showOptions.\n" );
auto&& dialog = new OptionDialog( qApp->activeWindow() );
dialog->centerOnWidget( qApp->activeWindow() );
dialog->show();
return;
}
|