mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
kcontrol: stub keyboard KCM keyboard layout options
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
54df6ed55d
commit
ec442d8ad1
7 changed files with 328 additions and 151 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
set(keyboardconfig_SRCS
|
||||
keyboardconfig.cpp
|
||||
keyboardlayoutdialog.cpp
|
||||
keyboardoptionsdialog.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(kcm_keyboard ${keyboardconfig_SRCS})
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
|
||||
#include "keyboardconfig.h"
|
||||
#include "keyboardlayoutdialog.h"
|
||||
#include "keyboardoptionsdialog.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QX11Info>
|
||||
|
@ -43,6 +45,7 @@ static QList<KKeyboardType> kLayoutsFromConfig()
|
|||
KConfigGroup kconfiggroup(&kconfig, "Keyboard");
|
||||
const KKeyboardType defaultlayout = KKeyboardLayout::defaultLayout();
|
||||
const QByteArray layoutsmodel = kconfiggroup.readEntry("LayoutsModel", defaultlayout.model);
|
||||
const QByteArray layoutsoptions = kconfiggroup.readEntry("LayoutsOptions", defaultlayout.option);
|
||||
const QStringList layoutslayouts = kconfiggroup.readEntry(
|
||||
"LayoutsLayouts",
|
||||
QStringList() << QString::fromLatin1(defaultlayout.layout.constData(), defaultlayout.layout.size())
|
||||
|
@ -59,6 +62,7 @@ static QList<KKeyboardType> kLayoutsFromConfig()
|
|||
if (i < layoutsvariants.size()) {
|
||||
kkeyboardtype.variant = layoutsvariants.at(i).toLatin1();
|
||||
}
|
||||
kkeyboardtype.option = layoutsoptions;
|
||||
result.append(kkeyboardtype);
|
||||
}
|
||||
return result;
|
||||
|
@ -126,144 +130,6 @@ static void kApplyKeyboardConfig()
|
|||
XkbFreeKeyboard(xkbkeyboard, 0, true);
|
||||
}
|
||||
|
||||
class KCMKeyboardDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KCMKeyboardDialog(const QList<KKeyboardType> &filter, QWidget *parent);
|
||||
~KCMKeyboardDialog();
|
||||
|
||||
KKeyboardType keyboardType() const;
|
||||
void setKeyboardType(const KKeyboardType &layout);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotLayoutIndexChanged(const int index);
|
||||
void slotVariantIndexChanged(const int index);
|
||||
|
||||
private:
|
||||
bool filterLayout(const QByteArray &layout, const QByteArray &variant) const;
|
||||
|
||||
QList<KKeyboardType> m_filter;
|
||||
KKeyboardType m_keyboardtype;
|
||||
QWidget* m_widget;
|
||||
QGridLayout* m_layout;
|
||||
QLabel* m_layoutslabel;
|
||||
QComboBox* m_layoutsbox;
|
||||
QLabel* m_variantslabel;
|
||||
QComboBox* m_variantsbox;
|
||||
};
|
||||
|
||||
KCMKeyboardDialog::KCMKeyboardDialog(const QList<KKeyboardType> &filter, QWidget *parent)
|
||||
: KDialog(parent),
|
||||
m_filter(filter),
|
||||
m_keyboardtype(KKeyboardLayout::defaultLayout()),
|
||||
m_widget(nullptr),
|
||||
m_layout(nullptr),
|
||||
m_layoutslabel(nullptr),
|
||||
m_layoutsbox(nullptr),
|
||||
m_variantslabel(nullptr),
|
||||
m_variantsbox(nullptr)
|
||||
{
|
||||
setCaption(i18n("Keyboard Layout"));
|
||||
setButtons(KDialog::Ok | KDialog::Cancel);
|
||||
|
||||
m_widget = new QWidget(this);
|
||||
m_layout = new QGridLayout(m_widget);
|
||||
|
||||
m_layoutslabel = new QLabel(m_widget);
|
||||
m_layoutslabel->setText(i18n("Layout:"));
|
||||
m_layout->addWidget(m_layoutslabel, 0, 0);
|
||||
m_layoutsbox = new QComboBox(m_widget);
|
||||
m_layoutsbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
foreach (const QByteArray &layoutlayout, KKeyboardLayout::layoutNames()) {
|
||||
m_layoutsbox->addItem(KKeyboardLayout::layoutDescription(layoutlayout), layoutlayout);
|
||||
}
|
||||
connect(
|
||||
m_layoutsbox, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(slotLayoutIndexChanged(int))
|
||||
);
|
||||
m_layout->addWidget(m_layoutsbox, 0, 1);
|
||||
|
||||
m_variantslabel = new QLabel(m_widget);
|
||||
m_variantslabel->setText(i18n("Variant:"));
|
||||
m_layout->addWidget(m_variantslabel, 1, 0);
|
||||
m_variantsbox = new QComboBox(m_widget);
|
||||
m_variantsbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
connect(
|
||||
m_variantsbox, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(slotVariantIndexChanged(int))
|
||||
);
|
||||
m_layout->addWidget(m_variantsbox, 1, 1);
|
||||
|
||||
setMainWidget(m_widget);
|
||||
|
||||
adjustSize();
|
||||
KConfigGroup kconfiggroup(KGlobal::config(), "KCMKeyboardDialog");
|
||||
restoreDialogSize(kconfiggroup);
|
||||
}
|
||||
|
||||
KCMKeyboardDialog::~KCMKeyboardDialog()
|
||||
{
|
||||
KConfigGroup kconfiggroup(KGlobal::config(), "KCMKeyboardDialog");
|
||||
saveDialogSize(kconfiggroup);
|
||||
KGlobal::config()->sync();
|
||||
}
|
||||
|
||||
KKeyboardType KCMKeyboardDialog::keyboardType() const
|
||||
{
|
||||
return m_keyboardtype;
|
||||
}
|
||||
|
||||
void KCMKeyboardDialog::setKeyboardType(const KKeyboardType &layout)
|
||||
{
|
||||
m_keyboardtype = layout;
|
||||
m_variantsbox->blockSignals(true);
|
||||
const int layoutindex = m_layoutsbox->findData(m_keyboardtype.layout);
|
||||
if (layoutindex >= 0) {
|
||||
m_layoutsbox->setCurrentIndex(layoutindex);
|
||||
} else {
|
||||
kWarning() << "Could not find the keyboard layout" << m_keyboardtype.layout;
|
||||
}
|
||||
const int variantindex = m_variantsbox->findData(m_keyboardtype.variant);
|
||||
if (variantindex >= 0) {
|
||||
m_variantsbox->setCurrentIndex(variantindex);
|
||||
} else {
|
||||
kWarning() << "Could not find the keyboard variant" << m_keyboardtype.variant;
|
||||
}
|
||||
m_variantsbox->blockSignals(false);
|
||||
}
|
||||
|
||||
bool KCMKeyboardDialog::filterLayout(const QByteArray &layout, const QByteArray &variant) const
|
||||
{
|
||||
foreach (const KKeyboardType &filter, m_filter) {
|
||||
if (filter.layout == layout && filter.variant == variant) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void KCMKeyboardDialog::slotLayoutIndexChanged(const int index)
|
||||
{
|
||||
m_variantsbox->clear();
|
||||
const QByteArray layoutlayout = m_layoutsbox->itemData(index).toByteArray();
|
||||
// add "None"
|
||||
m_variantsbox->addItem(KKeyboardLayout::variantDescription(layoutlayout, QByteArray()), QByteArray());
|
||||
foreach (const QByteArray &layoutvariant, KKeyboardLayout::variantNames(layoutlayout)) {
|
||||
m_variantsbox->addItem(KKeyboardLayout::variantDescription(layoutlayout, layoutvariant), layoutvariant);
|
||||
}
|
||||
enableButtonOk(!filterLayout(layoutlayout, m_keyboardtype.variant));
|
||||
m_keyboardtype.layout = layoutlayout;
|
||||
}
|
||||
|
||||
void KCMKeyboardDialog::slotVariantIndexChanged(const int index)
|
||||
{
|
||||
const QByteArray layoutvariant = m_variantsbox->itemData(index).toByteArray();
|
||||
enableButtonOk(!filterLayout(m_keyboardtype.layout, layoutvariant));
|
||||
m_keyboardtype.variant = layoutvariant;
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
Q_DECL_EXPORT void kcminit_keyboard()
|
||||
|
@ -288,13 +154,13 @@ KCMKeyboard::KCMKeyboard(QWidget *parent, const QVariantList &args)
|
|||
m_layoutsmodelbox(nullptr),
|
||||
m_layoutstree(nullptr),
|
||||
m_layoutbuttonsbox(nullptr),
|
||||
m_layoutsbuttonsspacer(nullptr),
|
||||
m_layoutsaddbutton(nullptr),
|
||||
m_layoutseditbutton(nullptr),
|
||||
m_layoutsremovebutton(nullptr),
|
||||
m_layoutsupbutton(nullptr),
|
||||
m_layoutsdownbutton(nullptr),
|
||||
m_layoutsbuttonsspacer2(nullptr)
|
||||
m_layoutsbuttonsspacer(nullptr),
|
||||
m_layoutsavdancedbutton(nullptr)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
|
||||
|
@ -398,9 +264,6 @@ KCMKeyboard::KCMKeyboard(QWidget *parent, const QVariantList &args)
|
|||
m_layoutbuttonsbox = new KHBox(m_layoutsgroup);
|
||||
layoutgrouplayout->addWidget(m_layoutbuttonsbox, 2, 0, 1, 2);
|
||||
|
||||
m_layoutsbuttonsspacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
m_layoutbuttonsbox->layout()->addItem(m_layoutsbuttonsspacer);
|
||||
|
||||
m_layoutsaddbutton = new QPushButton(m_layoutbuttonsbox);
|
||||
m_layoutsaddbutton->setText(i18n("Add"));
|
||||
m_layoutsaddbutton->setIcon(KIcon("list-add"));
|
||||
|
@ -445,8 +308,16 @@ KCMKeyboard::KCMKeyboard(QWidget *parent, const QVariantList &args)
|
|||
this, SLOT(slotDownPressed())
|
||||
);
|
||||
|
||||
m_layoutsbuttonsspacer2 = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
m_layoutbuttonsbox->layout()->addItem(m_layoutsbuttonsspacer2);
|
||||
m_layoutsbuttonsspacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
m_layoutbuttonsbox->layout()->addItem(m_layoutsbuttonsspacer);
|
||||
|
||||
m_layoutsavdancedbutton = new QPushButton(m_layoutbuttonsbox);
|
||||
m_layoutsavdancedbutton->setText(i18n("Advanced"));
|
||||
m_layoutsavdancedbutton->setIcon(KIcon("configure"));
|
||||
connect(
|
||||
m_layoutsavdancedbutton, SIGNAL(pressed()),
|
||||
this, SLOT(slotAdvancedPressed())
|
||||
);
|
||||
}
|
||||
|
||||
void KCMKeyboard::load()
|
||||
|
@ -461,6 +332,7 @@ void KCMKeyboard::load()
|
|||
const QList<KKeyboardType> layouts = kLayoutsFromConfig();
|
||||
const KKeyboardType modellayout = (layouts.size() > 0 ? layouts.first() : KKeyboardLayout::defaultLayout());
|
||||
m_layoutmodel = modellayout.model;
|
||||
m_layoutoptions = modellayout.option;
|
||||
const int layoutsmodelindex = m_layoutsmodelbox->findData(m_layoutmodel);
|
||||
if (layoutsmodelindex >= 0) {
|
||||
m_layoutsmodelbox->setCurrentIndex(layoutsmodelindex);
|
||||
|
@ -488,6 +360,7 @@ void KCMKeyboard::save()
|
|||
layoutsvariants.append(layoutitem->data(1, Qt::UserRole).toString());
|
||||
}
|
||||
kconfiggroup.writeEntry("LayoutsModel", m_layoutmodel);
|
||||
kconfiggroup.writeEntry("LayoutsOptions", m_layoutoptions);
|
||||
kconfiggroup.writeEntry("LayoutsLayouts", layoutslayouts);
|
||||
kconfiggroup.writeEntry("LayoutsVariants", layoutsvariants);
|
||||
kconfig.sync();
|
||||
|
@ -549,7 +422,7 @@ void KCMKeyboard::slotItemSelectionChanged()
|
|||
void KCMKeyboard::slotAddPressed()
|
||||
{
|
||||
QList<KKeyboardType> layouts = kGetLayoutsFromTree(m_layoutstree, m_layoutmodel);
|
||||
KCMKeyboardDialog keyboarddialog(layouts, this);
|
||||
KCMKeyboardLayoutDialog keyboarddialog(layouts, this);
|
||||
keyboarddialog.setKeyboardType(KKeyboardLayout::defaultLayout());
|
||||
if (keyboarddialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
|
@ -569,7 +442,7 @@ void KCMKeyboard::slotEditPressed()
|
|||
QList<KKeyboardType> layouts = kGetLayoutsFromTree(m_layoutstree, m_layoutmodel);
|
||||
const KKeyboardType currentlayout = layouts.at(selectedrow);
|
||||
layouts.removeAt(selectedrow);
|
||||
KCMKeyboardDialog keyboarddialog(layouts, this);
|
||||
KCMKeyboardLayoutDialog keyboarddialog(layouts, this);
|
||||
keyboarddialog.setKeyboardType(currentlayout);
|
||||
if (keyboarddialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
|
@ -618,5 +491,14 @@ void KCMKeyboard::slotDownPressed()
|
|||
emit changed(true);
|
||||
}
|
||||
|
||||
void KCMKeyboard::slotAdvancedPressed()
|
||||
{
|
||||
KCMKeyboardOptionsDialog keyboarddialog(this);
|
||||
keyboarddialog.setOptions(m_layoutoptions);
|
||||
if (keyboarddialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
m_layoutoptions = keyboarddialog.options();
|
||||
}
|
||||
|
||||
#include "moc_keyboardconfig.cpp"
|
||||
#include "keyboardconfig.moc"
|
||||
|
|
|
@ -56,9 +56,11 @@ private Q_SLOTS:
|
|||
void slotRemovePressed();
|
||||
void slotUpPressed();
|
||||
void slotDownPressed();
|
||||
void slotAdvancedPressed();
|
||||
|
||||
private:
|
||||
QByteArray m_layoutmodel;
|
||||
QByteArray m_layoutoptions;
|
||||
QVBoxLayout* m_layout;
|
||||
|
||||
QGroupBox* m_repeatgroup;
|
||||
|
@ -72,13 +74,13 @@ private:
|
|||
QComboBox* m_layoutsmodelbox;
|
||||
QTreeWidget* m_layoutstree;
|
||||
KHBox* m_layoutbuttonsbox;
|
||||
QSpacerItem* m_layoutsbuttonsspacer;
|
||||
QPushButton* m_layoutsaddbutton;
|
||||
QPushButton* m_layoutseditbutton;
|
||||
QPushButton* m_layoutsremovebutton;
|
||||
QPushButton* m_layoutsupbutton;
|
||||
QPushButton* m_layoutsdownbutton;
|
||||
QSpacerItem* m_layoutsbuttonsspacer2;
|
||||
QSpacerItem* m_layoutsbuttonsspacer;
|
||||
QPushButton* m_layoutsavdancedbutton;
|
||||
};
|
||||
|
||||
#endif // kkeyboardconfig
|
||||
#endif // KEYBOARDCONFIG_H
|
||||
|
|
134
kcontrol/keyboard/keyboardlayoutdialog.cpp
Normal file
134
kcontrol/keyboard/keyboardlayoutdialog.cpp
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "keyboardlayoutdialog.h"
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
KCMKeyboardLayoutDialog::KCMKeyboardLayoutDialog(const QList<KKeyboardType> &filter, QWidget *parent)
|
||||
: KDialog(parent),
|
||||
m_filter(filter),
|
||||
m_keyboardtype(KKeyboardLayout::defaultLayout()),
|
||||
m_widget(nullptr),
|
||||
m_layout(nullptr),
|
||||
m_layoutslabel(nullptr),
|
||||
m_layoutsbox(nullptr),
|
||||
m_variantslabel(nullptr),
|
||||
m_variantsbox(nullptr)
|
||||
{
|
||||
setCaption(i18n("Keyboard Layout"));
|
||||
setButtons(KDialog::Ok | KDialog::Cancel);
|
||||
|
||||
m_widget = new QWidget(this);
|
||||
m_layout = new QGridLayout(m_widget);
|
||||
|
||||
m_layoutslabel = new QLabel(m_widget);
|
||||
m_layoutslabel->setText(i18n("Layout:"));
|
||||
m_layout->addWidget(m_layoutslabel, 0, 0);
|
||||
m_layoutsbox = new QComboBox(m_widget);
|
||||
m_layoutsbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
foreach (const QByteArray &layoutlayout, KKeyboardLayout::layoutNames()) {
|
||||
m_layoutsbox->addItem(KKeyboardLayout::layoutDescription(layoutlayout), layoutlayout);
|
||||
}
|
||||
connect(
|
||||
m_layoutsbox, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(slotLayoutIndexChanged(int))
|
||||
);
|
||||
m_layout->addWidget(m_layoutsbox, 0, 1);
|
||||
|
||||
m_variantslabel = new QLabel(m_widget);
|
||||
m_variantslabel->setText(i18n("Variant:"));
|
||||
m_layout->addWidget(m_variantslabel, 1, 0);
|
||||
m_variantsbox = new QComboBox(m_widget);
|
||||
m_variantsbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
connect(
|
||||
m_variantsbox, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(slotVariantIndexChanged(int))
|
||||
);
|
||||
m_layout->addWidget(m_variantsbox, 1, 1);
|
||||
|
||||
setMainWidget(m_widget);
|
||||
|
||||
adjustSize();
|
||||
KConfigGroup kconfiggroup(KGlobal::config(), "KCMKeyboardLayoutDialog");
|
||||
restoreDialogSize(kconfiggroup);
|
||||
}
|
||||
|
||||
KCMKeyboardLayoutDialog::~KCMKeyboardLayoutDialog()
|
||||
{
|
||||
KConfigGroup kconfiggroup(KGlobal::config(), "KCMKeyboardLayoutDialog");
|
||||
saveDialogSize(kconfiggroup);
|
||||
KGlobal::config()->sync();
|
||||
}
|
||||
|
||||
KKeyboardType KCMKeyboardLayoutDialog::keyboardType() const
|
||||
{
|
||||
return m_keyboardtype;
|
||||
}
|
||||
|
||||
void KCMKeyboardLayoutDialog::setKeyboardType(const KKeyboardType &layout)
|
||||
{
|
||||
m_keyboardtype = layout;
|
||||
m_variantsbox->blockSignals(true);
|
||||
const int layoutindex = m_layoutsbox->findData(m_keyboardtype.layout);
|
||||
if (layoutindex >= 0) {
|
||||
m_layoutsbox->setCurrentIndex(layoutindex);
|
||||
} else {
|
||||
kWarning() << "Could not find the keyboard layout" << m_keyboardtype.layout;
|
||||
}
|
||||
const int variantindex = m_variantsbox->findData(m_keyboardtype.variant);
|
||||
if (variantindex >= 0) {
|
||||
m_variantsbox->setCurrentIndex(variantindex);
|
||||
} else {
|
||||
kWarning() << "Could not find the keyboard variant" << m_keyboardtype.variant;
|
||||
}
|
||||
m_variantsbox->blockSignals(false);
|
||||
}
|
||||
|
||||
bool KCMKeyboardLayoutDialog::filterLayout(const QByteArray &layout, const QByteArray &variant) const
|
||||
{
|
||||
foreach (const KKeyboardType &filter, m_filter) {
|
||||
if (filter.layout == layout && filter.variant == variant) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void KCMKeyboardLayoutDialog::slotLayoutIndexChanged(const int index)
|
||||
{
|
||||
m_variantsbox->clear();
|
||||
const QByteArray layoutlayout = m_layoutsbox->itemData(index).toByteArray();
|
||||
// add "None"
|
||||
m_variantsbox->addItem(KKeyboardLayout::variantDescription(layoutlayout, QByteArray()), QByteArray());
|
||||
foreach (const QByteArray &layoutvariant, KKeyboardLayout::variantNames(layoutlayout)) {
|
||||
m_variantsbox->addItem(KKeyboardLayout::variantDescription(layoutlayout, layoutvariant), layoutvariant);
|
||||
}
|
||||
enableButtonOk(!filterLayout(layoutlayout, m_keyboardtype.variant));
|
||||
m_keyboardtype.layout = layoutlayout;
|
||||
}
|
||||
|
||||
void KCMKeyboardLayoutDialog::slotVariantIndexChanged(const int index)
|
||||
{
|
||||
const QByteArray layoutvariant = m_variantsbox->itemData(index).toByteArray();
|
||||
enableButtonOk(!filterLayout(m_keyboardtype.layout, layoutvariant));
|
||||
m_keyboardtype.variant = layoutvariant;
|
||||
}
|
||||
|
||||
#include "moc_keyboardlayoutdialog.cpp"
|
55
kcontrol/keyboard/keyboardlayoutdialog.h
Normal file
55
kcontrol/keyboard/keyboardlayoutdialog.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KEYBOARDLAYOUTDIALOG_H
|
||||
#define KEYBOARDLAYOUTDIALOG_H
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <kdialog.h>
|
||||
#include <kkeyboardlayout.h>
|
||||
|
||||
class KCMKeyboardLayoutDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KCMKeyboardLayoutDialog(const QList<KKeyboardType> &filter, QWidget *parent);
|
||||
~KCMKeyboardLayoutDialog();
|
||||
|
||||
KKeyboardType keyboardType() const;
|
||||
void setKeyboardType(const KKeyboardType &layout);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotLayoutIndexChanged(const int index);
|
||||
void slotVariantIndexChanged(const int index);
|
||||
|
||||
private:
|
||||
bool filterLayout(const QByteArray &layout, const QByteArray &variant) const;
|
||||
|
||||
QList<KKeyboardType> m_filter;
|
||||
KKeyboardType m_keyboardtype;
|
||||
QWidget* m_widget;
|
||||
QGridLayout* m_layout;
|
||||
QLabel* m_layoutslabel;
|
||||
QComboBox* m_layoutsbox;
|
||||
QLabel* m_variantslabel;
|
||||
QComboBox* m_variantsbox;
|
||||
};
|
||||
|
||||
#endif // KEYBOARDLAYOUTDIALOG_H
|
61
kcontrol/keyboard/keyboardoptionsdialog.cpp
Normal file
61
kcontrol/keyboard/keyboardoptionsdialog.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "keyboardoptionsdialog.h"
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
KCMKeyboardOptionsDialog::KCMKeyboardOptionsDialog(QWidget *parent)
|
||||
: KDialog(parent),
|
||||
m_widget(nullptr),
|
||||
m_layout(nullptr)
|
||||
{
|
||||
setCaption(i18n("Keyboard Options"));
|
||||
setButtons(KDialog::Ok | KDialog::Cancel);
|
||||
|
||||
m_widget = new QWidget(this);
|
||||
m_layout = new QGridLayout(m_widget);
|
||||
|
||||
setMainWidget(m_widget);
|
||||
|
||||
// TODO:
|
||||
|
||||
adjustSize();
|
||||
KConfigGroup kconfiggroup(KGlobal::config(), "KCMKeyboardOptionsDialog");
|
||||
restoreDialogSize(kconfiggroup);
|
||||
}
|
||||
|
||||
KCMKeyboardOptionsDialog::~KCMKeyboardOptionsDialog()
|
||||
{
|
||||
KConfigGroup kconfiggroup(KGlobal::config(), "KCMKeyboardOptionsDialog");
|
||||
saveDialogSize(kconfiggroup);
|
||||
KGlobal::config()->sync();
|
||||
}
|
||||
|
||||
QByteArray KCMKeyboardOptionsDialog::options() const
|
||||
{
|
||||
return m_options;
|
||||
}
|
||||
|
||||
void KCMKeyboardOptionsDialog::setOptions(const QByteArray &options)
|
||||
{
|
||||
m_options = options;
|
||||
}
|
||||
|
||||
#include "moc_keyboardoptionsdialog.cpp"
|
41
kcontrol/keyboard/keyboardoptionsdialog.h
Normal file
41
kcontrol/keyboard/keyboardoptionsdialog.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KEYBOARDOPTIONSDIALOG_H
|
||||
#define KEYBOARDOPTIONSDIALOG_H
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <kdialog.h>
|
||||
|
||||
class KCMKeyboardOptionsDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KCMKeyboardOptionsDialog(QWidget *parent);
|
||||
~KCMKeyboardOptionsDialog();
|
||||
|
||||
QByteArray options() const;
|
||||
void setOptions(const QByteArray &options);
|
||||
|
||||
private:
|
||||
QWidget* m_widget;
|
||||
QGridLayout* m_layout;
|
||||
QByteArray m_options;
|
||||
};
|
||||
|
||||
#endif // KEYBOARDOPTIONSDIALOG_H
|
Loading…
Add table
Reference in a new issue