2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-09-15 07:12:54 +00:00
|
|
|
// oxygenexceptiondialog.cpp
|
2009-08-24 16:15:14 +00:00
|
|
|
// -------------------
|
2009-09-09 00:55:55 +00:00
|
|
|
//
|
2009-08-25 04:15:13 +00:00
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
2009-08-24 16:15:14 +00:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
2009-09-09 00:55:55 +00:00
|
|
|
// IN THE SOFTWARE.
|
2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-09-16 06:09:31 +00:00
|
|
|
#include "oxygenexceptiondialog.h"
|
|
|
|
#include "oxygenexceptiondialog.moc"
|
|
|
|
#include "oxygendetectwidget.h"
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-08-22 08:24:06 +00:00
|
|
|
{
|
2009-09-09 00:55:55 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
|
|
|
ExceptionDialog::ExceptionDialog( QWidget* parent ):
|
|
|
|
KDialog( parent ),
|
2012-11-27 08:36:48 +00:00
|
|
|
_detectDialog(0),
|
|
|
|
_changed( false )
|
2009-09-13 16:43:26 +00:00
|
|
|
{
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// define buttons
|
|
|
|
setButtons( Ok|Cancel );
|
|
|
|
QWidget* local( new QWidget( this ) );
|
|
|
|
ui.setupUi( local );
|
|
|
|
setMainWidget( local );
|
|
|
|
|
2012-11-27 08:36:48 +00:00
|
|
|
// store checkboxes from ui into list
|
2012-11-23 09:09:39 +00:00
|
|
|
_checkBoxes.insert( FrameBorder, ui.frameBorderCheckBox );
|
|
|
|
_checkBoxes.insert( BlendColor, ui.blendColorCheckBox );
|
|
|
|
_checkBoxes.insert( SizeGripMode, ui.sizeGripCheckBox );
|
|
|
|
_checkBoxes.insert( TitleOutline, ui.titleOutlineCheckBox );
|
|
|
|
_checkBoxes.insert( DrawSeparator, ui.separatorCheckBox );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2012-11-27 08:36:48 +00:00
|
|
|
// detect window properties
|
|
|
|
connect( ui.detectDialogButton, SIGNAL( clicked( void ) ), SLOT(selectWindowProperties()) );
|
|
|
|
|
|
|
|
// connections
|
|
|
|
connect( ui.exceptionType, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
|
|
|
connect( ui.exceptionEditor, SIGNAL( textChanged( const QString& ) ), SLOT( updateChanged( void ) ) );
|
|
|
|
connect( ui.frameBorderComboBox, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
|
|
|
connect( ui.blendColorComboBox, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
|
|
|
connect( ui.sizeGripComboBox, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
|
|
|
connect( ui.titleOutlineComboBox, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
|
|
|
connect( ui.separatorComboBox, SIGNAL( currentIndexChanged( int ) ), SLOT( updateChanged( void ) ) );
|
|
|
|
|
|
|
|
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
|
|
|
|
{ connect( iter.value(), SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) ); }
|
|
|
|
|
|
|
|
connect( ui.hideTitleBar, SIGNAL( clicked( void ) ), SLOT( updateChanged( void ) ) );
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
2012-11-23 09:09:39 +00:00
|
|
|
void ExceptionDialog::setException( ConfigurationPtr exception )
|
2009-09-13 16:43:26 +00:00
|
|
|
{
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// store exception internally
|
2011-02-24 16:47:38 +00:00
|
|
|
_exception = exception;
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// type
|
2012-11-23 09:09:39 +00:00
|
|
|
ui.exceptionType->setCurrentIndex(_exception->exceptionType() );
|
|
|
|
ui.exceptionEditor->setText( _exception->exceptionPattern() );
|
|
|
|
ui.frameBorderComboBox->setCurrentIndex( _exception->frameBorder() );
|
|
|
|
ui.blendColorComboBox->setCurrentIndex( _exception->blendStyle() );
|
|
|
|
ui.sizeGripComboBox->setCurrentIndex( _exception->drawSizeGrip() );
|
|
|
|
ui.separatorComboBox->setCurrentIndex( _exception->separatorMode() );
|
|
|
|
ui.titleOutlineComboBox->setCurrentIndex( _exception->drawTitleOutline() );
|
|
|
|
ui.hideTitleBar->setChecked( _exception->hideTitleBar() );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// mask
|
2011-02-24 16:47:38 +00:00
|
|
|
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
|
2012-11-23 09:09:39 +00:00
|
|
|
{ iter.value()->setChecked( _exception->mask() & iter.key() ); }
|
2010-05-02 18:34:08 +00:00
|
|
|
|
2012-11-27 08:36:48 +00:00
|
|
|
setChanged( false );
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
2012-11-23 09:09:39 +00:00
|
|
|
void ExceptionDialog::save( void )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2012-11-23 09:09:39 +00:00
|
|
|
_exception->setExceptionType( ui.exceptionType->currentIndex() );
|
|
|
|
_exception->setExceptionPattern( ui.exceptionEditor->text() );
|
|
|
|
_exception->setFrameBorder( ui.frameBorderComboBox->currentIndex() );
|
|
|
|
_exception->setBlendStyle( ui.blendColorComboBox->currentIndex() );
|
|
|
|
_exception->setDrawSizeGrip( ui.sizeGripComboBox->currentIndex() );
|
|
|
|
_exception->setSeparatorMode( ui.separatorComboBox->currentIndex() );
|
|
|
|
_exception->setDrawTitleOutline( ui.titleOutlineComboBox->currentIndex() );
|
|
|
|
_exception->setHideTitleBar( ui.hideTitleBar->isChecked() );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// mask
|
2012-11-23 09:09:39 +00:00
|
|
|
unsigned int mask = None;
|
2012-11-27 08:36:48 +00:00
|
|
|
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
|
2012-11-23 09:09:39 +00:00
|
|
|
{ if( iter.value()->isChecked() ) mask |= iter.key(); }
|
2010-05-02 18:34:08 +00:00
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
_exception->setMask( mask );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2012-11-27 08:36:48 +00:00
|
|
|
setChanged( false );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
void ExceptionDialog::updateChanged( void )
|
|
|
|
{
|
|
|
|
bool modified( false );
|
|
|
|
if( _exception->exceptionType() != ui.exceptionType->currentIndex() ) modified = true;
|
|
|
|
else if( _exception->exceptionPattern() != ui.exceptionEditor->text() ) modified = true;
|
|
|
|
else if( _exception->frameBorder() != ui.frameBorderComboBox->currentIndex() ) modified = true;
|
|
|
|
else if( _exception->blendStyle() != ui.blendColorComboBox->currentIndex() ) modified = true;
|
|
|
|
else if( _exception->drawSizeGrip() != ui.sizeGripComboBox->currentIndex() ) modified = true;
|
|
|
|
else if( _exception->separatorMode() != ui.separatorComboBox->currentIndex() ) modified = true;
|
|
|
|
else if( _exception->drawTitleOutline() != ui.titleOutlineComboBox->currentIndex() ) modified = true;
|
|
|
|
else if( _exception->hideTitleBar() != ui.hideTitleBar->isChecked() ) modified = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// check mask
|
|
|
|
for( CheckBoxMap::iterator iter = _checkBoxes.begin(); iter != _checkBoxes.end(); ++iter )
|
|
|
|
{
|
|
|
|
if( iter.value()->isChecked() != (bool)( _exception->mask() & iter.key() ) )
|
|
|
|
{
|
|
|
|
modified = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setChanged( modified );
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
|
|
|
void ExceptionDialog::selectWindowProperties( void )
|
|
|
|
{
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// create widget
|
2011-02-24 16:47:38 +00:00
|
|
|
if( !_detectDialog )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2011-02-24 16:47:38 +00:00
|
|
|
_detectDialog = new DetectDialog( this );
|
2011-08-17 21:51:55 +00:00
|
|
|
connect( _detectDialog, SIGNAL(detectionDone(bool)), SLOT(readWindowProperties(bool)) );
|
2010-05-02 18:34:08 +00:00
|
|
|
}
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
_detectDialog->detect(0);
|
2009-09-13 16:43:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//___________________________________________
|
|
|
|
void ExceptionDialog::readWindowProperties( bool valid )
|
|
|
|
{
|
2012-11-23 09:09:39 +00:00
|
|
|
Q_CHECK_PTR( _detectDialog );
|
2010-05-02 18:34:08 +00:00
|
|
|
if( valid )
|
|
|
|
{
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
// type
|
2012-11-23 09:09:39 +00:00
|
|
|
ui.exceptionType->setCurrentIndex( _detectDialog->exceptionType() );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
// window info
|
2011-02-24 16:47:38 +00:00
|
|
|
const KWindowInfo& info( _detectDialog->windowInfo() );
|
2010-05-02 18:34:08 +00:00
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
switch( _detectDialog->exceptionType() )
|
2010-05-02 18:34:08 +00:00
|
|
|
{
|
2012-11-23 09:09:39 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
case Configuration::ExceptionWindowClassName:
|
2010-05-02 18:34:08 +00:00
|
|
|
ui.exceptionEditor->setText( info.windowClassClass() );
|
|
|
|
break;
|
|
|
|
|
2012-11-23 09:09:39 +00:00
|
|
|
case Configuration::ExceptionWindowTitle:
|
2010-05-02 18:34:08 +00:00
|
|
|
ui.exceptionEditor->setText( info.name() );
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-02-24 16:47:38 +00:00
|
|
|
delete _detectDialog;
|
|
|
|
_detectDialog = 0;
|
2010-05-02 18:34:08 +00:00
|
|
|
|
|
|
|
}
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2009-08-24 06:27:49 +00:00
|
|
|
}
|