Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1c370c2d authored by Robert Knight's avatar Robert Knight

Simplify changing the current color scheme and current key bindings in the...

Simplify changing the current color scheme and current key bindings in the profile editor.  There is no longer a distinction between the color scheme selected for removal/editing and the color scheme selected for use by the profile.  Also select the current color scheme, current key binding when the relevant pages of the profile editor are shown.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=686299
parent b4962d0b
......@@ -364,23 +364,25 @@ void EditProfileDialog::selectInitialDir()
}
void EditProfileDialog::setupAppearancePage(const Profile* info)
{
// setup color list
updateColorSchemeList(true);
ColorSchemeViewDelegate* delegate = new ColorSchemeViewDelegate(this);
_ui->colorSchemeList->setItemDelegate(delegate);
_colorSchemeAnimationTimeLine = new QTimeLine( 500 , this );
delegate->setEntryTimeLine(_colorSchemeAnimationTimeLine);
connect( _colorSchemeAnimationTimeLine , SIGNAL(valueChanged(qreal)) , this ,
SLOT(colorSchemeAnimationUpdate()) );
// setup color list
updateColorSchemeList(true);
_ui->colorSchemeList->setItemDelegate(delegate);
_ui->colorSchemeList->setMouseTracking(true);
_ui->colorSchemeList->installEventFilter(this);
connect( _ui->colorSchemeList , SIGNAL(doubleClicked(const QModelIndex&)) , this ,
SLOT(colorSchemeSelected()) );
connect( _ui->colorSchemeList->selectionModel() ,
SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&))
, this , SLOT(colorSchemeSelected()) );
connect( _ui->colorSchemeList , SIGNAL(entered(const QModelIndex&)) , this ,
SLOT(previewColorScheme(const QModelIndex&)) );
......@@ -433,16 +435,10 @@ void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme)
const ColorScheme* colors = schemeIter.next();
QStandardItem* item = new QStandardItem(colors->description());
item->setData( QVariant::fromValue(colors) , Qt::UserRole + 1);
item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
item->setFlags( item->flags() );
selectedItem = item;
if ( colors == currentScheme )
{
item->setCheckState( Qt::Checked );
selectedItem = item;
}
else
item->setCheckState( Qt::Unchecked );
model->appendRow(item);
}
......@@ -450,14 +446,16 @@ void EditProfileDialog::updateColorSchemeList(bool selectCurrentScheme)
_ui->colorSchemeList->setModel(model);
#if 0
if ( selectCurrentScheme )
_ui->colorSchemeList->selectionModel()->select(
selectedItem->index() , QItemSelectionModel::Select
);
#endif
{
Q_ASSERT( selectedItem );
_ui->colorSchemeList->updateGeometry();
_ui->colorSchemeList->selectionModel()->setCurrentIndex( selectedItem->index() ,
QItemSelectionModel::Select );
}
}
void EditProfileDialog::updateKeyBindingsList()
void EditProfileDialog::updateKeyBindingsList(bool selectCurrentTranslator)
{
KeyboardTranslatorManager* keyManager = KeyboardTranslatorManager::instance();
......@@ -472,6 +470,8 @@ void EditProfileDialog::updateKeyBindingsList()
QStandardItemModel* model = new QStandardItemModel(this);
QStandardItem* selectedItem = 0;
QList<QString> translatorNames = keyManager->allTranslators();
QListIterator<QString> iter(translatorNames);
while (iter.hasNext())
......@@ -488,19 +488,23 @@ void EditProfileDialog::updateKeyBindingsList()
QStandardItem* item = new QStandardItem(translator->description());
item->setData(QVariant::fromValue(translator),Qt::UserRole+1);
item->setIcon( KIcon("keyboard") );
item->setFlags( item->flags() | Qt::ItemIsUserCheckable );
if ( translator == currentTranslator )
item->setCheckState( Qt::Checked );
else
item->setCheckState( Qt::Unchecked );
selectedItem = item;
model->appendRow(item);
}
model->sort(0);
_ui->keyBindingList->setModel(model);
if ( selectCurrentTranslator )
{
Q_ASSERT( selectedItem );
_ui->keyBindingList->selectionModel()->setCurrentIndex( selectedItem->index() ,
QItemSelectionModel::Select );
}
}
bool EditProfileDialog::eventFilter( QObject* watched , QEvent* event )
{
......@@ -641,18 +645,17 @@ void EditProfileDialog::colorSchemeSelected()
const ColorScheme* colors = model->data(selected.first(),Qt::UserRole+1).value<const ColorScheme*>();
_tempProfile->setProperty(Profile::ColorScheme,colors->name());
changeCheckedItem(model,selected.first());
}
}
void EditProfileDialog::setupKeyboardPage(const Profile* info)
{
// setup translator list
updateKeyBindingsList();
updateKeyBindingsList(true);
connect( _ui->keyBindingList , SIGNAL(doubleClicked(const QModelIndex&)) , this ,
SLOT(keyBindingSelected()) );
connect( _ui->keyBindingList->selectionModel() ,
SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
SLOT(keyBindingSelected()) );
connect( _ui->selectKeyBindingsButton , SIGNAL(clicked()) , this ,
SLOT(keyBindingSelected()) );
connect( _ui->newKeyBindingsButton , SIGNAL(clicked()) , this ,
......@@ -672,22 +675,8 @@ void EditProfileDialog::keyBindingSelected()
const KeyboardTranslator* translator = model->data(selected.first(),Qt::UserRole+1)
.value<const KeyboardTranslator*>();
_tempProfile->setProperty(Profile::KeyBindings,translator->name());
changeCheckedItem(model,selected.first());
}
}
void EditProfileDialog::changeCheckedItem( QAbstractItemModel* model , const QModelIndex& to )
{
// uncheck current active item
QModelIndexList list = model->match( model->index(0,0) , Qt::CheckStateRole , Qt::Checked );
QListIterator<QModelIndex> iter(list);
while ( iter.hasNext() )
model->setData( iter.next() , Qt::Unchecked , Qt::CheckStateRole );
// check new active item
model->setData( to , Qt::Checked , Qt::CheckStateRole );
}
void EditProfileDialog::removeKeyBinding()
{
QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes();
......@@ -977,34 +966,6 @@ ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject* parent)
}
#if 0
QWidget* ColorSchemeViewDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,
const QModelIndex& index) const
{
QWidget* holder = new QWidget(parent);
QVBoxLayout* layout = new QVBoxLayout;
QWidget* selectButton = new QPushButton(i18n("Use Color Scheme"));
QWidget* editButton = new QPushButton(i18n("Edit..."));
layout->setMargin(0);
layout->addWidget(selectButton);
layout->addWidget(editButton);
holder->setLayout(layout);
int width = holder->sizeHint().width();
int left = option.rect.right() - width - 10;
int top = option.rect.top();
holder->move( left , top );
return holder;
}
#endif
void ColorSchemeViewDelegate::setEntryTimeLine(QTimeLine* timeLine)
{
_entryTimeLine = timeLine;
......@@ -1089,11 +1050,11 @@ void ColorSchemeViewDelegate::paint(QPainter* painter, const QStyleOptionViewIte
painter->setBrush(gradient);
painter->drawRoundRect( backgroundRect , 4 , 30 );
const bool isChecked = index.data(Qt::CheckStateRole) == Qt::Checked;
//const bool isChecked = index.data(Qt::CheckStateRole) == Qt::Checked;
const bool isSelected = option.state & QStyle::State_Selected;
// draw border on selected items
if ( isSelected || isChecked )
if ( isSelected ) //|| isChecked )
{
static const int selectedBorderWidth = 6;
......@@ -1125,15 +1086,6 @@ void ColorSchemeViewDelegate::paint(QPainter* painter, const QStyleOptionViewIte
QPen pen(scheme->foregroundColor());
painter->setPen(pen);
// use bold text for active color scheme
QFont itemFont = painter->font();
if ( isChecked )
itemFont.setBold(true);
else
itemFont.setBold(false);
painter->setFont(itemFont);
painter->drawText( option.rect , Qt::AlignCenter ,
index.data(Qt::DisplayRole).value<QString>() );
......
......@@ -174,7 +174,7 @@ private:
void setupAdvancedPage(const Profile* info);
void updateColorSchemeList(bool selectCurrentScheme = false);
void updateKeyBindingsList();
void updateKeyBindingsList(bool selectCurrentTranslator = false);
void updateFontPreviewLabel(const QFont& font);
void showColorSchemeEditor(bool newScheme);
......
......@@ -926,7 +926,9 @@ void KeyboardTranslator::removeEntry(const Entry& entry)
}
KeyboardTranslator::Entry KeyboardTranslator::findEntry(int keyCode, Qt::KeyboardModifiers modifiers, States state) const
{
//qDebug() << "Searching for entry for key code =" << keyCode << ", modifiers =" << modifiers;
// qDebug() << "Searching for entry for key code =" << keyCode << ", modifiers =" << modifiers;
// printf("modifiers in hex %x\n",(int)modifiers);
//qDebug() << "Translator keys, count: " << _entries.count() << _entries.keys();
if ( _entries.contains(keyCode) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment