|
|
|
@ -19,17 +19,17 @@
|
|
|
|
|
#include "kbpickicondlg.h"
|
|
|
|
|
#include "boldlistboxitem.h"
|
|
|
|
|
|
|
|
|
|
#include <qlayout.h>
|
|
|
|
|
#include <qlabel.h>
|
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
|
#include <qwhatsthis.h>
|
|
|
|
|
#include <qvbox.h>
|
|
|
|
|
#include <qstyle.h>
|
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
|
#include <qheader.h>
|
|
|
|
|
#include <qobjectlist.h>
|
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
|
#include <qcombobox.h>
|
|
|
|
|
#include <ntqlayout.h>
|
|
|
|
|
#include <ntqlabel.h>
|
|
|
|
|
#include <ntqcheckbox.h>
|
|
|
|
|
#include <ntqwhatsthis.h>
|
|
|
|
|
#include <ntqvbox.h>
|
|
|
|
|
#include <ntqstyle.h>
|
|
|
|
|
#include <ntqgroupbox.h>
|
|
|
|
|
#include <ntqheader.h>
|
|
|
|
|
#include <ntqobjectlist.h>
|
|
|
|
|
#include <ntqpushbutton.h>
|
|
|
|
|
#include <ntqcombobox.h>
|
|
|
|
|
|
|
|
|
|
#include <kdeversion.h>
|
|
|
|
|
#include <klistbox.h>
|
|
|
|
@ -50,12 +50,12 @@
|
|
|
|
|
*/
|
|
|
|
|
class SmallerKeyChooser : public KKeyChooser {
|
|
|
|
|
private:
|
|
|
|
|
QSize m_size_hint;
|
|
|
|
|
TQSize m_size_hint;
|
|
|
|
|
void calcSizeHint();
|
|
|
|
|
public:
|
|
|
|
|
SmallerKeyChooser(KGlobalAccel *accel, QWidget *parent) :
|
|
|
|
|
SmallerKeyChooser(KGlobalAccel *accel, TQWidget *parent) :
|
|
|
|
|
KKeyChooser(accel, parent) { calcSizeHint(); }
|
|
|
|
|
virtual QSize sizeHint() const { return m_size_hint; }
|
|
|
|
|
virtual TQSize sizeHint() const { return m_size_hint; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void SmallerKeyChooser::calcSizeHint()
|
|
|
|
@ -63,28 +63,28 @@ void SmallerKeyChooser::calcSizeHint()
|
|
|
|
|
m_size_hint = KKeyChooser::sizeHint();
|
|
|
|
|
|
|
|
|
|
KListView *lv = NULL;
|
|
|
|
|
QGroupBox *gb = NULL;
|
|
|
|
|
const QObjectList *objects = children();
|
|
|
|
|
QObjectListIt iter(*objects);
|
|
|
|
|
QObject *obj;
|
|
|
|
|
TQGroupBox *gb = NULL;
|
|
|
|
|
const TQObjectList *objects = children();
|
|
|
|
|
TQObjectListIt iter(*objects);
|
|
|
|
|
TQObject *obj;
|
|
|
|
|
|
|
|
|
|
while ( (obj = iter.current()) ) {
|
|
|
|
|
++iter;
|
|
|
|
|
if (obj->inherits("KListView"))
|
|
|
|
|
lv = dynamic_cast<KListView*>(obj);
|
|
|
|
|
else if (obj->inherits("QGroupBox"))
|
|
|
|
|
gb = dynamic_cast<QGroupBox*>(obj);
|
|
|
|
|
else if (obj->inherits("TQGroupBox"))
|
|
|
|
|
gb = dynamic_cast<TQGroupBox*>(obj);
|
|
|
|
|
}
|
|
|
|
|
if (!lv || !gb) return; // oops, should not happen
|
|
|
|
|
|
|
|
|
|
QListViewItem *item = lv->firstChild();
|
|
|
|
|
TQListViewItem *item = lv->firstChild();
|
|
|
|
|
if (!item) return;
|
|
|
|
|
|
|
|
|
|
int height = item->height() * (1 + item->childCount()) + lv->header()->height() +
|
|
|
|
|
style().pixelMetric(QStyle::PM_ScrollBarExtent) + gb->sizeHint().height() +
|
|
|
|
|
style().pixelMetric(TQStyle::PM_ScrollBarExtent) + gb->sizeHint().height() +
|
|
|
|
|
layout()->spacing() * 2;
|
|
|
|
|
int width = lv->columnWidth(0) + lv->columnWidth(1);
|
|
|
|
|
m_size_hint = QSize(width, height);
|
|
|
|
|
m_size_hint = TQSize(width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool iconTypeShowsFlag(KBConfig::IconStyle icon_style)
|
|
|
|
@ -92,14 +92,14 @@ static inline bool iconTypeShowsFlag(KBConfig::IconStyle icon_style)
|
|
|
|
|
return icon_style == KBConfig::ICON_FLAG || icon_style == KBConfig::ICON_CODE_AND_FLAG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KBConfigDlg::KBConfigDlg(KBConfig *kbconf, QWidget *parent, const char *name )
|
|
|
|
|
KBConfigDlg::KBConfigDlg(KBConfig *kbconf, TQWidget *parent, const char *name )
|
|
|
|
|
: KDialogBase(Tabbed, i18n("Configure")/*caption*/, Ok | Apply | Cancel | Help,
|
|
|
|
|
Ok, parent, name, true /*modal*/)
|
|
|
|
|
{
|
|
|
|
|
m_kbconf = kbconf;
|
|
|
|
|
m_default_groupno = m_kbconf->default_groupno();
|
|
|
|
|
|
|
|
|
|
setHelp(QString("configure-kkbswitch"));
|
|
|
|
|
setHelp(TQString("configure-kkbswitch"));
|
|
|
|
|
setButtonBoxOrientation(Horizontal);
|
|
|
|
|
setupGeneralPage();
|
|
|
|
|
setupShortcutsPage();
|
|
|
|
@ -113,64 +113,64 @@ KBConfigDlg::~KBConfigDlg(){
|
|
|
|
|
|
|
|
|
|
void KBConfigDlg::setupGeneralPage()
|
|
|
|
|
{
|
|
|
|
|
QFrame *page = addPage(i18n("&General")); //makeMainWidget();
|
|
|
|
|
QVBoxLayout *vlayout = new QVBoxLayout(page);
|
|
|
|
|
TQFrame *page = addPage(i18n("&General")); //makeMainWidget();
|
|
|
|
|
TQVBoxLayout *vlayout = new TQVBoxLayout(page);
|
|
|
|
|
vlayout->setSpacing(2);
|
|
|
|
|
|
|
|
|
|
QLabel *lbl = new QLabel(i18n("Available &keyboard layouts:"), page);
|
|
|
|
|
TQLabel *lbl = new TQLabel(i18n("Available &keyboard layouts:"), page);
|
|
|
|
|
vlayout->addWidget(lbl);
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *groupsLayout = new QHBoxLayout(vlayout);
|
|
|
|
|
TQHBoxLayout *groupsLayout = new TQHBoxLayout(vlayout);
|
|
|
|
|
groupsLayout->setSpacing(2);
|
|
|
|
|
|
|
|
|
|
lbGroups = new KListBox(page);
|
|
|
|
|
QObject::connect(lbGroups, SIGNAL(selectionChanged()), this, SLOT(slotLayoutSelected()));
|
|
|
|
|
QObject::connect(lbGroups, SIGNAL(doubleClicked(QListBoxItem *)), this,
|
|
|
|
|
SLOT(slotListBoxExecuted(QListBoxItem *)));
|
|
|
|
|
TQObject::connect(lbGroups, SIGNAL(selectionChanged()), this, SLOT(slotLayoutSelected()));
|
|
|
|
|
TQObject::connect(lbGroups, SIGNAL(doubleClicked(TQListBoxItem *)), this,
|
|
|
|
|
SLOT(slotListBoxExecuted(TQListBoxItem *)));
|
|
|
|
|
groupsLayout->addWidget(lbGroups);
|
|
|
|
|
lbl->setBuddy(lbGroups);
|
|
|
|
|
QWhatsThis::add(lbGroups, i18n("This list box shows keyboard layouts available in your system.\n"
|
|
|
|
|
TQWhatsThis::add(lbGroups, i18n("This list box shows keyboard layouts available in your system.\n"
|
|
|
|
|
"Select a layout and click \"Change Icon...\" button to change the icon for a layout.\n"
|
|
|
|
|
"If you have configured a non-default icon, you can reset the icon to default with \"Use Default Icon\" button.\n"
|
|
|
|
|
"The layout shown is bold is the default layout. Use \"Set as default\" button "
|
|
|
|
|
"to set the default layout."));
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *btnLayout = new QVBoxLayout(groupsLayout);
|
|
|
|
|
TQVBoxLayout *btnLayout = new TQVBoxLayout(groupsLayout);
|
|
|
|
|
btnLayout->setSpacing(2);
|
|
|
|
|
|
|
|
|
|
btnChangeIcon = new QPushButton(i18n("Cha&nge Icon..."), page);
|
|
|
|
|
QObject::connect(btnChangeIcon, SIGNAL(clicked()), this, SLOT(slotPickIcon()));
|
|
|
|
|
btnLayout->addWidget(btnChangeIcon, 0, Qt::AlignTop);
|
|
|
|
|
QWhatsThis::add(btnChangeIcon, i18n("Click this button to change the icon for the "
|
|
|
|
|
btnChangeIcon = new TQPushButton(i18n("Cha&nge Icon..."), page);
|
|
|
|
|
TQObject::connect(btnChangeIcon, SIGNAL(clicked()), this, SLOT(slotPickIcon()));
|
|
|
|
|
btnLayout->addWidget(btnChangeIcon, 0, TQt::AlignTop);
|
|
|
|
|
TQWhatsThis::add(btnChangeIcon, i18n("Click this button to change the icon for the "
|
|
|
|
|
"layout selected in the list box to the left."));
|
|
|
|
|
|
|
|
|
|
btnSetDefaultIcon = new QPushButton(i18n("Use &Default Icon"), page);
|
|
|
|
|
QObject::connect(btnSetDefaultIcon, SIGNAL(clicked()), this, SLOT(slotSetDefaultIcon()));
|
|
|
|
|
btnLayout->addWidget(btnSetDefaultIcon, 0, Qt::AlignTop);
|
|
|
|
|
QWhatsThis::add(btnSetDefaultIcon, i18n("Click this button to use default icon for the "
|
|
|
|
|
btnSetDefaultIcon = new TQPushButton(i18n("Use &Default Icon"), page);
|
|
|
|
|
TQObject::connect(btnSetDefaultIcon, SIGNAL(clicked()), this, SLOT(slotSetDefaultIcon()));
|
|
|
|
|
btnLayout->addWidget(btnSetDefaultIcon, 0, TQt::AlignTop);
|
|
|
|
|
TQWhatsThis::add(btnSetDefaultIcon, i18n("Click this button to use default icon for the "
|
|
|
|
|
"layout selected in the list box to the left."));
|
|
|
|
|
|
|
|
|
|
btnSetDefaultGroup = new QPushButton(i18n("&Set as Default"), page);
|
|
|
|
|
QObject::connect(btnSetDefaultGroup, SIGNAL(clicked()), this, SLOT(slotSetDefaultGroup()));
|
|
|
|
|
btnLayout->addWidget(btnSetDefaultGroup, 0, Qt::AlignTop);
|
|
|
|
|
QWhatsThis::add(btnSetDefaultGroup, i18n("Click this button to set the layout selected "
|
|
|
|
|
btnSetDefaultGroup = new TQPushButton(i18n("&Set as Default"), page);
|
|
|
|
|
TQObject::connect(btnSetDefaultGroup, SIGNAL(clicked()), this, SLOT(slotSetDefaultGroup()));
|
|
|
|
|
btnLayout->addWidget(btnSetDefaultGroup, 0, TQt::AlignTop);
|
|
|
|
|
TQWhatsThis::add(btnSetDefaultGroup, i18n("Click this button to set the layout selected "
|
|
|
|
|
"in the list box to the left as the default"));
|
|
|
|
|
|
|
|
|
|
btnLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum,
|
|
|
|
|
QSizePolicy::MinimumExpanding));
|
|
|
|
|
btnLayout->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Minimum,
|
|
|
|
|
TQSizePolicy::MinimumExpanding));
|
|
|
|
|
|
|
|
|
|
lbl = new QLabel(i18n("Layout &icon style:"), page);
|
|
|
|
|
lbl = new TQLabel(i18n("Layout &icon style:"), page);
|
|
|
|
|
vlayout->addWidget(lbl);
|
|
|
|
|
|
|
|
|
|
cbxIconType = new QComboBox(page);
|
|
|
|
|
cbxIconType = new TQComboBox(page);
|
|
|
|
|
cbxIconType->setEditable(false);
|
|
|
|
|
cbxIconType->insertItem(i18n("Country flag"));
|
|
|
|
|
cbxIconType->insertItem(i18n("Language code"));
|
|
|
|
|
cbxIconType->insertItem(i18n("Flag and code"));
|
|
|
|
|
QObject::connect(cbxIconType, SIGNAL(activated(int)), this, SLOT(slotIconTypeSelected(int)));
|
|
|
|
|
TQObject::connect(cbxIconType, SIGNAL(activated(int)), this, SLOT(slotIconTypeSelected(int)));
|
|
|
|
|
vlayout->addWidget(cbxIconType);
|
|
|
|
|
lbl->setBuddy(cbxIconType);
|
|
|
|
|
QWhatsThis::add(cbxIconType, i18n("<p>Select the style of icons representing the "
|
|
|
|
|
TQWhatsThis::add(cbxIconType, i18n("<p>Select the style of icons representing the "
|
|
|
|
|
"current keyboard layout.\n"
|
|
|
|
|
"You can choose from the following styles:"
|
|
|
|
|
"<ul><li><b>Country flag</b> - displays the corresponding country flag"
|
|
|
|
@ -178,17 +178,17 @@ void KBConfigDlg::setupGeneralPage()
|
|
|
|
|
"<li><b>Flag and code</b> - displays the language code superimposed over the country flag."
|
|
|
|
|
"</ul></p>"));
|
|
|
|
|
|
|
|
|
|
lbl = new QLabel(i18n("&Layout applies to:"), page);
|
|
|
|
|
lbl = new TQLabel(i18n("&Layout applies to:"), page);
|
|
|
|
|
vlayout->addWidget(lbl);
|
|
|
|
|
|
|
|
|
|
cbxGroupScope = new QComboBox(page);
|
|
|
|
|
cbxGroupScope = new TQComboBox(page);
|
|
|
|
|
cbxGroupScope->setEditable(false);
|
|
|
|
|
cbxGroupScope->insertItem(i18n("All windows"));
|
|
|
|
|
cbxGroupScope->insertItem(i18n("Windows of one application"));
|
|
|
|
|
cbxGroupScope->insertItem(i18n("One window"));
|
|
|
|
|
vlayout->addWidget(cbxGroupScope);
|
|
|
|
|
lbl->setBuddy(cbxGroupScope);
|
|
|
|
|
QWhatsThis::add(cbxGroupScope, i18n("<p>Select what windows the currently selected "
|
|
|
|
|
TQWhatsThis::add(cbxGroupScope, i18n("<p>Select what windows the currently selected "
|
|
|
|
|
"keyboard layout applies to:\n"
|
|
|
|
|
"<ul><li><b>All windows</b> - one layout applies to all windows on your desktop\n"
|
|
|
|
|
"<li><b>Windows of one application</b> - layout applies to one application; each "
|
|
|
|
@ -196,30 +196,30 @@ void KBConfigDlg::setupGeneralPage()
|
|
|
|
|
"<li><b>One window</b> - layout applies to one window only; each window can have its own layout. "
|
|
|
|
|
"When you switch between windows, layout follows the active window.</ul></p>"));
|
|
|
|
|
|
|
|
|
|
chkToggleMode = new QCheckBox(i18n("Use \"&Toggle Mode\""), page);
|
|
|
|
|
chkToggleMode = new TQCheckBox(i18n("Use \"&Toggle Mode\""), page);
|
|
|
|
|
vlayout->addWidget(chkToggleMode);
|
|
|
|
|
QWhatsThis::add(chkToggleMode, i18n("Toggle mode is useful when you have more than two keyboard "
|
|
|
|
|
TQWhatsThis::add(chkToggleMode, i18n("Toggle mode is useful when you have more than two keyboard "
|
|
|
|
|
"layouts defined. When toggle mode is on your normal layout switch key toggles between two most frequently used layouts. "
|
|
|
|
|
"To activate other layouts use KKBSwitch's tray popup menu"));
|
|
|
|
|
|
|
|
|
|
/*chkPerwindowGroup = new QCheckBox(i18n("Use &per-window layout"), page);
|
|
|
|
|
/*chkPerwindowGroup = new TQCheckBox(i18n("Use &per-window layout"), page);
|
|
|
|
|
vlayout->addWidget(chkPerwindowGroup);
|
|
|
|
|
QWhatsThis::add(chkPerwindowGroup, i18n("When this checkbox is checked, "
|
|
|
|
|
TQWhatsThis::add(chkPerwindowGroup, i18n("When this checkbox is checked, "
|
|
|
|
|
"each window has its own current keyboard layout. When it's unchecked, "
|
|
|
|
|
"the current layout affects all windows"));*/
|
|
|
|
|
|
|
|
|
|
chkAutostart = new QCheckBox(i18n("A&utostart"), page);
|
|
|
|
|
chkAutostart = new TQCheckBox(i18n("A&utostart"), page);
|
|
|
|
|
vlayout->addWidget(chkAutostart);
|
|
|
|
|
QWhatsThis::add(chkAutostart, i18n("When this checkbox is checked, KKBSwitch "
|
|
|
|
|
TQWhatsThis::add(chkAutostart, i18n("When this checkbox is checked, KKBSwitch "
|
|
|
|
|
"will start automatically when you log in"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KBConfigDlg::setupShortcutsPage()
|
|
|
|
|
{
|
|
|
|
|
QVBox *box = addVBoxPage(i18n("Sho&rtcuts"));
|
|
|
|
|
chkUseShortcuts = new QCheckBox(i18n("Use shortcuts to &activate keyboard layouts"), box);
|
|
|
|
|
TQVBox *box = addVBoxPage(i18n("Sho&rtcuts"));
|
|
|
|
|
chkUseShortcuts = new TQCheckBox(i18n("Use shortcuts to &activate keyboard layouts"), box);
|
|
|
|
|
connect(chkUseShortcuts, SIGNAL(toggled(bool)), this, SLOT(slotUseShortcutsToggled(bool)));
|
|
|
|
|
QWhatsThis::add(chkUseShortcuts, i18n("Check this checkbox to be able to quickly "
|
|
|
|
|
TQWhatsThis::add(chkUseShortcuts, i18n("Check this checkbox to be able to quickly "
|
|
|
|
|
"activate any keyboard layout with keyboard shorcuts. Once this checkbox "
|
|
|
|
|
"is checked, you can adjust the shortcuts at the key chooser pane below. "
|
|
|
|
|
"Especially useful if you have three or four keyboard layouts configured"));
|
|
|
|
@ -256,11 +256,11 @@ void KBConfigDlg::showConfig(){
|
|
|
|
|
/** Fire up "Pick Icon" dialog */
|
|
|
|
|
void KBConfigDlg::slotPickIcon(){
|
|
|
|
|
int index = lbGroups->currentItem();
|
|
|
|
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
|
|
|
|
TQApplication::setOverrideCursor(TQCursor(TQt::WaitCursor));
|
|
|
|
|
KBPickIconDlg dlg(m_iconpaths[index], *(lbGroups->pixmap(index)), this);
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
TQApplication::restoreOverrideCursor();
|
|
|
|
|
if (dlg.exec()) {
|
|
|
|
|
QString path = dlg.getIconPath();
|
|
|
|
|
TQString path = dlg.getIconPath();
|
|
|
|
|
KBGroup *group = m_kbconf->getGroup(index);
|
|
|
|
|
if (!path.isEmpty() && path != group->getIconPath()) {
|
|
|
|
|
kapp->config()->writeEntry(group->getName()/*KBConfig::entryForGroup(index)*/, path);
|
|
|
|
@ -277,7 +277,7 @@ void KBConfigDlg::slotSetDefaultGroup()
|
|
|
|
|
BoldListBoxItem *item = dynamic_cast<BoldListBoxItem*>(lbGroups->item(m_default_groupno));
|
|
|
|
|
item->setBold(false);
|
|
|
|
|
m_default_groupno = new_default_group;
|
|
|
|
|
// NB: don't use selectedItem(); it's not present in Qt 3.0, and
|
|
|
|
|
// NB: don't use selectedItem(); it's not present in TQt 3.0, and
|
|
|
|
|
// we want to maintain compatibility with it
|
|
|
|
|
int curitem = lbGroups->currentItem();
|
|
|
|
|
if (curitem > -1) { // should not be -1, but just in case
|
|
|
|
@ -298,15 +298,15 @@ void KBConfigDlg::slotLayoutSelected(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** No descriptions */
|
|
|
|
|
void KBConfigDlg::slotListBoxExecuted(QListBoxItem *){
|
|
|
|
|
void KBConfigDlg::slotListBoxExecuted(TQListBoxItem *){
|
|
|
|
|
if (iconTypeShowsFlag(KBConfig::IconStyle(cbxIconType->currentItem())))
|
|
|
|
|
slotPickIcon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** No descriptions */
|
|
|
|
|
void KBConfigDlg::saveConfig(){
|
|
|
|
|
QString path;
|
|
|
|
|
const QPixmap *pix;
|
|
|
|
|
TQString path;
|
|
|
|
|
const TQPixmap *pix;
|
|
|
|
|
KConfig *conf = kapp->config();
|
|
|
|
|
conf->setGroup(ICONS_SECTION);
|
|
|
|
|
for (int i = 0; i < m_kbconf->groupCount(); i++) {
|
|
|
|
@ -353,10 +353,10 @@ void KBConfigDlg::slotIconTypeSelected(int index)
|
|
|
|
|
|
|
|
|
|
void KBConfigDlg::redrawIcons(KBConfig::IconStyle icon_style)
|
|
|
|
|
{
|
|
|
|
|
QValueVector<QPixmap> pixlist;
|
|
|
|
|
TQValueVector<TQPixmap> pixlist;
|
|
|
|
|
m_kbconf->drawIcons(icon_style, &pixlist, &m_iconpaths);
|
|
|
|
|
int curIndex = lbGroups->currentItem();
|
|
|
|
|
// NB: don't use count(), use size(); count() is not present in Qt 3.0, and
|
|
|
|
|
// NB: don't use count(), use size(); count() is not present in TQt 3.0, and
|
|
|
|
|
// we want to maintain compatibility with it
|
|
|
|
|
for (unsigned int i = 0; i < pixlist.size(); i++) {
|
|
|
|
|
BoldListBoxItem *curItem = dynamic_cast<BoldListBoxItem*>(lbGroups->item(i));
|
|
|
|
|