2009-08-24 16:15:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nitrogenexceptiondialog.cpp
|
|
|
|
// -------------------
|
|
|
|
//
|
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
|
|
|
|
// IN THE SOFTWARE.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLayout>
|
|
|
|
#include <KLocale>
|
|
|
|
|
|
|
|
#include "nitrogenexceptiondialog.h"
|
|
|
|
|
|
|
|
namespace Nitrogen
|
|
|
|
{
|
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
NitrogenExceptionDialog::NitrogenExceptionDialog( QWidget* parent ):
|
|
|
|
KDialog( parent )
|
|
|
|
{
|
|
|
|
|
|
|
|
// define buttons
|
|
|
|
setButtons( Ok|Cancel );
|
|
|
|
showButtonSeparator( true );
|
|
|
|
|
|
|
|
// main widget
|
|
|
|
QWidget* widget = new QWidget( this );
|
|
|
|
setMainWidget( widget );
|
|
|
|
|
|
|
|
widget->setLayout( new QVBoxLayout() );
|
|
|
|
widget->layout()->setSpacing(5);
|
|
|
|
widget->layout()->setMargin(0);
|
|
|
|
|
|
|
|
// exception definition
|
|
|
|
QGroupBox* box;
|
2009-08-24 07:31:29 +00:00
|
|
|
widget->layout()->addWidget( box = new QGroupBox( i18n( "Definition" ), widget ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
QGridLayout* gridLayout = new QGridLayout();
|
|
|
|
gridLayout->setSpacing(5);
|
|
|
|
gridLayout->setMargin(5);
|
|
|
|
box->setLayout( gridLayout );
|
|
|
|
|
|
|
|
QLabel *label;
|
|
|
|
|
|
|
|
// exception type
|
2009-08-24 07:31:29 +00:00
|
|
|
gridLayout->addWidget( label = new QLabel( i18n( "Exception type: " ), box ), 0, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( type_combobox_ = new QComboBox(box), 0, 1, 1, 1 );
|
|
|
|
type_combobox_->insertItems(0, QStringList()
|
|
|
|
<< NitrogenException::typeName( NitrogenException::WindowClassName )
|
|
|
|
<< NitrogenException::typeName( NitrogenException::WindowTitle ) );
|
2009-08-24 07:31:29 +00:00
|
|
|
type_combobox_->setToolTip( i18n(
|
2009-08-25 18:33:51 +00:00
|
|
|
"Select here the window characteristic used to \n"
|
2009-08-22 08:24:06 +00:00
|
|
|
"identify windows to which the exception apply." ) );
|
|
|
|
|
|
|
|
label->setAlignment( Qt::AlignRight );
|
|
|
|
|
|
|
|
// regular expression
|
2009-08-24 07:31:29 +00:00
|
|
|
gridLayout->addWidget( label = new QLabel( i18n( "Regular expression to match: " ), box ), 1, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( editor_ = new KLineEdit( box ), 1, 1, 1, 1 );
|
|
|
|
editor_->setClearButtonShown( true );
|
2009-08-24 07:31:29 +00:00
|
|
|
editor_->setToolTip( i18n(
|
2009-08-22 08:24:06 +00:00
|
|
|
"Type here the regular expression used to \n"
|
|
|
|
"identify windows to which the exception apply." ) );
|
|
|
|
|
|
|
|
label->setAlignment( Qt::AlignRight );
|
|
|
|
|
|
|
|
// decoration flags
|
2009-08-24 07:31:29 +00:00
|
|
|
widget->layout()->addWidget( box = new QGroupBox( i18n( "Decoration" ), widget ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout = new QGridLayout();
|
|
|
|
gridLayout->setSpacing(5);
|
|
|
|
gridLayout->setMargin(5);
|
|
|
|
box->setLayout( gridLayout );
|
|
|
|
|
|
|
|
QCheckBox* checkbox;
|
|
|
|
|
|
|
|
// border size
|
2009-08-24 07:31:29 +00:00
|
|
|
gridLayout->addWidget( checkbox = new QCheckBox( i18n("Border size:" ), box ), 2, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( frame_border_combobox_ = new QComboBox(box), 2, 1, 1, 1 );
|
|
|
|
frame_border_combobox_->insertItems(0, QStringList()
|
2009-08-25 04:51:08 +00:00
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderNone, true )
|
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderTiny, true )
|
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderDefault, true )
|
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderLarge, true )
|
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderVeryLarge, true )
|
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderHuge, true )
|
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderVeryHuge, true )
|
|
|
|
<< NitrogenConfiguration::frameBorderName( NitrogenConfiguration::BorderOversized, true )
|
|
|
|
);
|
2009-08-22 08:24:06 +00:00
|
|
|
frame_border_combobox_->setEnabled( false );
|
|
|
|
checkboxes_.insert( std::make_pair( NitrogenException::FrameBorder, checkbox ) );
|
2009-08-24 07:29:46 +00:00
|
|
|
checkbox->setToolTip( i18n("If checked, specified frame border is used in place of default value.") );
|
2009-08-22 08:24:06 +00:00
|
|
|
connect( checkbox, SIGNAL( toggled( bool ) ), frame_border_combobox_, SLOT( setEnabled( bool ) ) );
|
|
|
|
|
|
|
|
// blend color
|
2009-08-29 06:05:50 +00:00
|
|
|
gridLayout->addWidget( checkbox = new QCheckBox( i18n("Background style:" ), box ), 3, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( blend_combobox_ = new QComboBox(box), 3, 1, 1, 1 );
|
|
|
|
blend_combobox_->insertItems(0, QStringList()
|
2009-08-24 16:15:14 +00:00
|
|
|
<< NitrogenException::blendColorName( NitrogenException::NoBlending, true )
|
|
|
|
<< NitrogenException::blendColorName( NitrogenException::RadialBlending, true ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
blend_combobox_->setEnabled( false );
|
|
|
|
checkboxes_.insert( std::make_pair( NitrogenException::BlendColor, checkbox ) );
|
2009-08-24 07:29:46 +00:00
|
|
|
checkbox->setToolTip( i18n("If checked, specified blending color is used in title bar in place of default value.") );
|
2009-08-22 08:24:06 +00:00
|
|
|
connect( checkbox, SIGNAL( toggled( bool ) ), blend_combobox_, SLOT( setEnabled( bool ) ) );
|
|
|
|
|
|
|
|
// separator
|
2009-08-30 17:26:47 +00:00
|
|
|
gridLayout->addWidget( checkbox = new QCheckBox( i18n("Draw separator between title bar and window contents:" ), box ), 4, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( draw_separator_combobox_ = new ComboBox( box ), 4, 1, 1, 1 );
|
2009-08-30 17:26:47 +00:00
|
|
|
draw_separator_combobox_->setEnabled( false );
|
|
|
|
checkboxes_.insert( std::make_pair( NitrogenException::DrawSeparator, checkbox ) );
|
|
|
|
connect( checkbox, SIGNAL( toggled( bool ) ), draw_separator_combobox_, SLOT( setEnabled( bool ) ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
// stripes
|
2009-08-30 17:26:47 +00:00
|
|
|
gridLayout->addWidget( checkbox = new QCheckBox( i18n("Show stripes next to the title:" ), box ), 5, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( show_stripes_combobox_ = new ComboBox( box ), 5, 1, 1, 1 );
|
2009-08-30 17:26:47 +00:00
|
|
|
show_stripes_combobox_->setEnabled( false );
|
|
|
|
checkboxes_.insert( std::make_pair( NitrogenException::ShowStripes, checkbox ) );
|
|
|
|
connect( checkbox, SIGNAL( toggled( bool ) ), show_stripes_combobox_, SLOT( setEnabled( bool ) ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
// overwrite colors
|
2009-08-30 17:26:47 +00:00
|
|
|
gridLayout->addWidget( checkbox = new QCheckBox( i18n("Blend title bar colors with window content:" ), box ), 6, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( overwrite_colors_combobox_ = new ComboBox( box ), 6, 1, 1, 1 );
|
2009-08-30 17:26:47 +00:00
|
|
|
overwrite_colors_combobox_->setEnabled( false );
|
2009-09-02 00:49:52 +00:00
|
|
|
checkboxes_.insert( std::make_pair( NitrogenException::OverwriteColors, checkbox ) );
|
2009-08-30 17:26:47 +00:00
|
|
|
connect( checkbox, SIGNAL( toggled( bool ) ), overwrite_colors_combobox_, SLOT( setEnabled( bool ) ) );
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// size grip
|
2009-08-30 17:26:47 +00:00
|
|
|
gridLayout->addWidget( checkbox = new QCheckBox( i18n("Draw size grip in bottom-right corner of windows:" ), box ), 7, 0, 1, 1 );
|
2009-08-22 08:24:06 +00:00
|
|
|
gridLayout->addWidget( draw_size_grip_combobox_ = new ComboBox( box ), 7, 1, 1, 1 );
|
2009-08-30 17:26:47 +00:00
|
|
|
draw_size_grip_combobox_->setEnabled( false );
|
|
|
|
checkboxes_.insert( std::make_pair( NitrogenException::DrawSizeGrip, checkbox ) );
|
|
|
|
connect( checkbox, SIGNAL( toggled( bool ) ), draw_size_grip_combobox_, SLOT( setEnabled( bool ) ) );
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
void NitrogenExceptionDialog::setException( NitrogenException exception )
|
|
|
|
{
|
|
|
|
|
|
|
|
// store exception internally
|
|
|
|
exception_ = exception;
|
|
|
|
|
|
|
|
// type
|
|
|
|
type_combobox_->setCurrentIndex( type_combobox_->findText( exception.typeName() ) );
|
|
|
|
|
|
|
|
// regular expression
|
|
|
|
editor_->setText( exception.regExp().pattern() );
|
|
|
|
|
|
|
|
// border size
|
2009-08-24 16:15:14 +00:00
|
|
|
frame_border_combobox_->setCurrentIndex( frame_border_combobox_->findText( exception.frameBorderName( true ) ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
// blend color
|
2009-08-24 16:15:14 +00:00
|
|
|
blend_combobox_->setCurrentIndex( blend_combobox_->findText( exception.blendColorName( true ) ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
// flags
|
2009-08-30 17:26:47 +00:00
|
|
|
draw_separator_combobox_->setValue( exception.drawSeparator() );
|
|
|
|
show_stripes_combobox_->setValue( exception.showStripes() );
|
|
|
|
overwrite_colors_combobox_->setValue( exception.overwriteColors() );
|
|
|
|
draw_size_grip_combobox_->setValue( exception.drawSizeGrip() );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
// mask
|
|
|
|
for( CheckBoxMap::iterator iter = checkboxes_.begin(); iter != checkboxes_.end(); iter++ )
|
|
|
|
{ iter->second->setChecked( exception.mask() & iter->first ); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
NitrogenException NitrogenExceptionDialog::exception( void ) const
|
|
|
|
{
|
|
|
|
NitrogenException exception( exception_ );
|
|
|
|
exception.setType( NitrogenException::type( type_combobox_->currentText() ) );
|
|
|
|
exception.regExp().setPattern( editor_->text() );
|
2009-08-24 16:15:14 +00:00
|
|
|
exception.setFrameBorder( NitrogenException::frameBorder( frame_border_combobox_->currentText(), true ) );
|
|
|
|
exception.setBlendColor( NitrogenException::blendColor( blend_combobox_->currentText(), true ) );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
2009-08-30 17:26:47 +00:00
|
|
|
// flags
|
|
|
|
exception.setDrawSeparator( draw_separator_combobox_->isChecked() );
|
|
|
|
exception.setShowStripes( show_stripes_combobox_->isChecked() );
|
|
|
|
exception.setOverwriteColors( overwrite_colors_combobox_->isChecked() );
|
|
|
|
exception.setDrawSizeGrip( draw_size_grip_combobox_->isChecked() );
|
|
|
|
|
2009-08-22 08:24:06 +00:00
|
|
|
// mask
|
|
|
|
unsigned int mask = NitrogenException::None;
|
|
|
|
for( CheckBoxMap::const_iterator iter = checkboxes_.begin(); iter != checkboxes_.end(); iter++ )
|
|
|
|
{ if( iter->second->isChecked() ) mask |= iter->first; }
|
|
|
|
|
|
|
|
exception.setMask( mask );
|
|
|
|
return exception;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//___________________________________________
|
2009-08-29 06:05:50 +00:00
|
|
|
const QString NitrogenExceptionDialog::ComboBox::Yes( i18n("Enabled") );
|
|
|
|
const QString NitrogenExceptionDialog::ComboBox::No( i18n("Disabled") );
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
NitrogenExceptionDialog::ComboBox::ComboBox( QWidget* parent ):
|
|
|
|
QComboBox( parent )
|
2009-08-30 17:26:47 +00:00
|
|
|
{ insertItems( 0, QStringList() << Yes << No ); }
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
//___________________________________________
|
2009-08-30 17:26:47 +00:00
|
|
|
void NitrogenExceptionDialog::ComboBox::setValue( bool checked )
|
|
|
|
{ setCurrentIndex( findText( checked ? Yes:No ) ); }
|
2009-08-22 08:24:06 +00:00
|
|
|
|
|
|
|
//___________________________________________
|
|
|
|
bool NitrogenExceptionDialog::ComboBox::isChecked( void ) const
|
|
|
|
{ return currentText() == Yes; }
|
|
|
|
|
2009-08-24 06:27:49 +00:00
|
|
|
}
|