PreferencesAppearanceConfigPage::PreferencesAppearanceConfigPage( Knipptasch::Preferences *pref, ConfigWidget *parent )
    : AbstractConfigPage( tr( "Appearance" ), DesktopIcon( "preferences-desktop-theme" ), parent ),
      ui( new Ui::PreferencesAppearanceConfigPage ),
      m_preferences( pref )
{
    ui->setupUi( this );

    connect( ui->positiveAmountForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgPositiveAmountWidget, SLOT( setEditable( bool ) ) );
    connect( ui->negativeAmountForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgNegativeAmountWidget, SLOT( setEditable( bool ) ) );
    connect( ui->availableWarrantyForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgAvailableWarrantyWidget, SLOT( setEditable( bool ) ) );
    connect( ui->expiredWarrantyForegroundEnabled, SIGNAL( toggled( bool ) ),
             ui->fgExpiredWarrantyWidget, SLOT( setEditable( bool ) ) );
    connect( ui->currentPostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgCurrentPostingWidget, SLOT( setEditable( bool ) ) );
    connect( ui->futurePostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgFuturePostingWidget, SLOT( setEditable( bool ) ) );
    connect( ui->defaultPostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgNormalPostingWidget, SLOT( setEditable( bool ) ) );
    connect( ui->incompletePostingBackgroundEnabled, SIGNAL( toggled( bool ) ),
             ui->bgIncompletePostingWidget, SLOT( setEditable( bool ) ) );

    connect( ui->positiveAmountForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->negativeAmountForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->availableWarrantyForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->expiredWarrantyForegroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->currentPostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->futurePostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->defaultPostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->incompletePostingBackgroundEnabled, SIGNAL( stateChanged( int ) ),
             this, SIGNAL( pageModified() ) );

    connect( ui->fgPositiveAmountWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->fgNegativeAmountWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->fgAvailableWarrantyWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->fgExpiredWarrantyWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgCurrentPostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgFuturePostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgNormalPostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );
    connect( ui->bgIncompletePostingWidget, SIGNAL( colorChanged( QColor ) ),
             this, SIGNAL( pageModified() ) );

    revert();
}
void PreferencesAppearanceConfigPage::revert()
{
    bool block = blockSignals( true );

    ui->positiveAmountForegroundEnabled->setChecked( m_preferences->positiveAmountForegroundEnabled() );
    ui->negativeAmountForegroundEnabled->setChecked( m_preferences->negativeAmountForegroundEnabled() );
    ui->availableWarrantyForegroundEnabled->setChecked( m_preferences->availableWarrantyForegroundEnabled() );
    ui->expiredWarrantyForegroundEnabled->setChecked( m_preferences->expiredWarrantyForegroundEnabled() );
    ui->currentPostingBackgroundEnabled->setChecked( m_preferences->currentPostingBackgroundEnabled() );
    ui->futurePostingBackgroundEnabled->setChecked( m_preferences->futurePostingBackgroundEnabled() );
    ui->defaultPostingBackgroundEnabled->setChecked( m_preferences->defaultPostingBackgroundEnabled() );
    ui->incompletePostingBackgroundEnabled->setChecked( m_preferences->incompletePostingBackgroundEnabled() );

    ui->fgPositiveAmountWidget->setColor( m_preferences->positiveAmountForegroundColor() );
    ui->fgNegativeAmountWidget->setColor( m_preferences->negativeAmountForegroundColor() );
    ui->fgAvailableWarrantyWidget->setColor( m_preferences->availableWarrantyForegroundColor() );
    ui->fgExpiredWarrantyWidget->setColor( m_preferences->expiredWarrantyForegroundColor() );
    ui->bgCurrentPostingWidget->setColor( m_preferences->currentPostingBackgroundColor() );
    ui->bgFuturePostingWidget->setColor( m_preferences->futurePostingBackgroundColor() );
    ui->bgNormalPostingWidget->setColor( m_preferences->defaultPostingBackgroundColor() );
    ui->bgIncompletePostingWidget->setColor( m_preferences->incompletePostingBackgroundColor() );

    blockSignals( block );

    emit pageModified();
}
Ejemplo n.º 3
0
/*!
    Constructs a VkOptionsDialog
*/
VkOptionsDialog::VkOptionsDialog( QWidget* parent )
   : QDialog( parent )
{
   // ------------------------------------------------------------
   // basic dialog setup
   setObjectName( QString::fromUtf8( "VkOptionsDialog" ) );
   setWindowTitle( "[*]Valkyrie Options Dialog" ); // [*] == 'windowModified' placeholder
   setupLayout();
   
   // ------------------------------------------------------------
   // Add categories, and the pages
   // Note: both the pages and categories list use the same 'index',
   // which is how we keep them in sync.
   // TODO: if any complaints re speed, load the pages on demand.
   VkObjectList objList = (( MainWindow* )parent )->getValkyrie()->vkObjList();
   
   for ( int i = 0; i < objList.size(); ++i ) {
   
      // Allow the VkObject to create the appropriate options page
      // Pass 'this' so constructor widgets auto-size correctly.
      VkObject* obj = objList.at( i );
      VkOptionsPage* page = obj->createVkOptionsPage();
      vk_assert( page != 0 );
      page->init();
      connect( page, SIGNAL( modified() ), this, SLOT( pageModified() ) );
      // handle e.g. user pressing return in an ledit
      connect( page, SIGNAL( apply() ), this, SLOT( apply() ) );
      
      // Set list item entry
      QListWidgetItem* item = new QListWidgetItem( contentsListWidget );
      QString itemName = obj->objectName();
      itemName[0] = itemName[0].toUpper();
      item->setText( itemName );

      QFont font = item->font();
      font.setBold( true );
      font.setPointSize( font.pointSize() * 1.2 );
      item->setFont( font );

      // insert into stack (takes ownership)
      optionPages->addWidget( page );
   }
   
   contentsListWidget->setCurrentRow( 0 );
   contentsListWidget->setFocus();
   optionPages->setCurrentIndex( 0 );
   
   // Give a max to our contentsList, based on hints from the list-items.
   // TODO: surely this can be done automatically?
   // - QSizePolicy::* don't seem to do the job :-(
   contentsListWidget->setMaximumWidth( 40 + contentsListWidget->sizeHintForColumn( 0 ) );
   
   ContextHelp::addHelp( this, urlValkyrie::optsDlg );
}
bool PreferencesAppearanceConfigPage::commit()
{
    m_preferences->setPositiveAmountForegroundEnabled( ui->positiveAmountForegroundEnabled->checkState() );
    m_preferences->setPositiveAmountForegroundColor( ui->fgPositiveAmountWidget->color() );
    m_preferences->setNegativeAmountForegroundEnabled( ui->negativeAmountForegroundEnabled->isChecked() );
    m_preferences->setNegativeAmountForegroundColor( ui->fgNegativeAmountWidget->color() );
    m_preferences->setAvailableWarrantyForegroundEnabled( ui->availableWarrantyForegroundEnabled->isChecked() );
    m_preferences->setAvailableWarrantyForegroundColor( ui->fgAvailableWarrantyWidget->color() );
    m_preferences->setExpiredWarrantyForegroundEnabled( ui->availableWarrantyForegroundEnabled->isChecked() );
    m_preferences->setExpiredWarrantyForegroundColor( ui->fgExpiredWarrantyWidget->color() );
    m_preferences->setCurrentPostingBackgroundEnabled( ui->currentPostingBackgroundEnabled->isChecked() );
    m_preferences->setCurrentPostingBackgroundColor( ui->bgCurrentPostingWidget->color() );
    m_preferences->setFuturePostingBackgroundEnabled( ui->futurePostingBackgroundEnabled->isChecked() );
    m_preferences->setFuturePostingBackgroundColor( ui->bgFuturePostingWidget->color() );
    m_preferences->setDefaultPostingBackgroundEnabled( ui->defaultPostingBackgroundEnabled->isChecked() );
    m_preferences->setDefaultPostingBackgroundColor( ui->bgNormalPostingWidget->color() );
    m_preferences->setIncompletePostingBackgroundEnabled( ui->incompletePostingBackgroundEnabled->isChecked() );
    m_preferences->setIncompletePostingBackgroundColor( ui->bgIncompletePostingWidget->color() );

    emit pageModified();

    return true;
}