kdeui: simplify KGlobaSettings and do not setup mouse from it

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-22 23:32:43 +07:00
parent 948a17ffb0
commit 24f8640acd
14 changed files with 67 additions and 120 deletions

View file

@ -37,7 +37,7 @@ class KListWidget::KListWidgetPrivate
void _k_slotItemEntered(QListWidgetItem*);
void _k_slotOnViewport();
void _k_slotSettingsChanged(int);
void _k_slotMouseChanged();
void _k_slotAutoSelect();
void _k_slotEmitExecute(QListWidgetItem *item);
@ -58,8 +58,8 @@ KListWidget::KListWidget( QWidget *parent )
this, SLOT(_k_slotOnViewport()) );
connect( this, SIGNAL(itemEntered(QListWidgetItem*)),
this, SLOT(_k_slotItemEntered(QListWidgetItem*)) );
d->_k_slotSettingsChanged(KGlobalSettings::SETTINGS_MOUSE);
connect( KGlobalSettings::self(), SIGNAL(settingsChanged(int)), SLOT(_k_slotSettingsChanged(int)) );
d->_k_slotMouseChanged();
connect( KGlobalSettings::self(), SIGNAL(mouseChanged()), SLOT(_k_slotMouseChanged()) );
d->m_pAutoSelect = new QTimer( this );
connect( d->m_pAutoSelect, SIGNAL(timeout()),
@ -93,10 +93,8 @@ void KListWidget::KListWidgetPrivate::_k_slotOnViewport()
}
void KListWidget::KListWidgetPrivate::_k_slotSettingsChanged(int category)
void KListWidget::KListWidgetPrivate::_k_slotMouseChanged()
{
if (category != KGlobalSettings::SETTINGS_MOUSE)
return;
m_bUseSingle = KGlobalSettings::singleClick();
q->disconnect(q, SIGNAL(itemClicked(QListWidgetItem*)));

View file

@ -103,7 +103,7 @@ private:
Q_PRIVATE_SLOT(d, void _k_slotItemEntered(QListWidgetItem*))
Q_PRIVATE_SLOT(d, void _k_slotOnViewport())
Q_PRIVATE_SLOT(d, void _k_slotSettingsChanged(int))
Q_PRIVATE_SLOT(d, void _k_slotMouseChanged())
Q_PRIVATE_SLOT(d, void _k_slotAutoSelect())
Q_PRIVATE_SLOT(d, void _k_slotEmitExecute(QListWidgetItem*))
};

View file

@ -49,12 +49,12 @@
#include "qplatformdefs.h"
#ifdef Q_WS_X11
#include <X11/Xlib.h>
# include <X11/Xlib.h>
#ifdef HAVE_XCURSOR
#include <X11/Xcursor/Xcursor.h>
# include <X11/Xcursor/Xcursor.h>
#endif
#include "fixx11h.h"
#include <QtGui/qx11info_x11.h>
# include "fixx11h.h"
# include <QtGui/qx11info_x11.h>
#endif
#include <stdlib.h>
@ -71,7 +71,6 @@ class KGlobalSettings::Private
QPalette createNewApplicationPalette(const KSharedConfigPtr &config);
void _k_slotNotifyChange(int, int);
void propagateQtSettings();
void kdisplaySetPalette();
void kdisplaySetStyle();
void kdisplaySetFont();
@ -112,7 +111,6 @@ void KGlobalSettings::activate(ActivateOptions options)
if (options & ApplySettings) {
d->kdisplaySetStyle(); // implies palette setup
d->kdisplaySetFont();
d->propagateQtSettings();
}
}
}
@ -451,29 +449,16 @@ void KGlobalSettings::Private::_k_slotNotifyChange(int changeType, int arg)
}
break;
}
case SettingsChanged: {
case LocaleChanged: {
KGlobal::config()->reparseConfiguration();
SettingsCategory category = static_cast<SettingsCategory>(arg);
switch (category) {
case SETTINGS_MOUSE: {
propagateQtSettings();
break;
}
case SETTINGS_LOCALE: {
KGlobal::locale()->reparseConfiguration();
// KLocale is reponsible for both so event for locale and language change
// is send
QEvent localeevent(QEvent::LocaleChange);
QApplication::sendEvent(qApp, &localeevent);
QEvent languageevent(QEvent::LanguageChange);
QApplication::sendEvent(qApp, &languageevent);
break;
}
default: {
break;
}
}
emit q->settingsChanged(category);
KGlobal::locale()->reparseConfiguration();
// KLocale is reponsible for both so event for locale and language change
// is send
QEvent localeevent(QEvent::LocaleChange);
QApplication::sendEvent(qApp, &localeevent);
QEvent languageevent(QEvent::LanguageChange);
QApplication::sendEvent(qApp, &languageevent);
emit q->localeChanged();
break;
}
case IconChanged: {
@ -482,8 +467,22 @@ void KGlobalSettings::Private::_k_slotNotifyChange(int changeType, int arg)
emit q->iconChanged(arg);
break;
}
case CursorChanged: {
emit q->cursorChanged();
case MouseChanged: {
KGlobal::config()->reparseConfiguration();
emit q->mouseChanged();
break;
}
case NaturalSortingChanged: {
KGlobal::config()->reparseConfiguration();
emit q->naturalSortingChanged();
break;
}
case PathsChanged: {
emit q->pathsChanged();
break;
}
case ShortcutsChanged: {
emit q->shortcutsChanged();
break;
}
case BlockShortcuts: {
@ -491,10 +490,6 @@ void KGlobalSettings::Private::_k_slotNotifyChange(int changeType, int arg)
emit q->blockShortcuts(arg); // see kwin
break;
}
case NaturalSortingChanged: {
emit q->naturalSortingChanged();
break;
}
default: {
kWarning() << "Unknown type of change in KGlobalSettings::slotNotifyChange: " << changeType;
}
@ -605,25 +600,4 @@ void KGlobalSettings::Private::kdisplaySetStyle()
}
}
void KGlobalSettings::Private::propagateQtSettings()
{
KConfigGroup cg( KGlobal::config(), "KDE" );
int num = cg.readEntry("CursorBlinkRate", QApplication::cursorFlashTime());
if ((num != 0) && (num < 200))
num = 200;
if (num > 2000)
num = 2000;
QApplication::setCursorFlashTime(num);
num = cg.readEntry("DoubleClickInterval", QApplication::doubleClickInterval());
QApplication::setDoubleClickInterval(num);
num = cg.readEntry("StartDragTime", QApplication::startDragTime());
QApplication::setStartDragTime(num);
num = cg.readEntry("StartDragDist", QApplication::startDragDistance());
QApplication::setStartDragDistance(num);
num = cg.readEntry("WheelScrollLines", QApplication::wheelScrollLines());
QApplication::setWheelScrollLines(num);
bool showIcons = cg.readEntry("ShowIconsInMenuItems", !QApplication::testAttribute(Qt::AA_DontShowIconsInMenus));
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus, !showIcons);
}
#include "moc_kglobalsettings.cpp"

View file

@ -447,8 +447,9 @@ public:
*/
enum ChangeType {
PaletteChanged = 0, FontChanged, StyleChanged,
SettingsChanged, IconChanged, CursorChanged,
ToolbarStyleChanged, BlockShortcuts, NaturalSortingChanged
IconChanged, MouseChanged, LocaleChanged,
ToolbarStyleChanged, PathsChanged, NaturalSortingChanged,
ShortcutsChanged, BlockShortcuts
};
/**
@ -486,14 +487,6 @@ public:
*/
void activate(ActivateOptions options);
/**
* Valid values for the settingsChanged signal
*/
enum SettingsCategory {
SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
SETTINGS_SHORTCUTS, SETTINGS_LOCALE, SETTINGS_STYLE
};
Q_SIGNALS:
/**
* Emitted when the application has changed its palette due to a KControl request.
@ -546,14 +539,6 @@ Q_SIGNALS:
*/
void toolbarAppearanceChanged(int);
/**
* Emitted when the global settings have been changed.
* KGlobalSettings takes care of calling reparseConfiguration on KGlobal::config()
* so that applications/classes using this only have to re-read the configuration
* @param category the category among the SettingsCategory enum.
*/
void settingsChanged(int category);
/**
* Emitted when the global icon settings have been changed.
* @param group the new group
@ -561,9 +546,24 @@ Q_SIGNALS:
void iconChanged(int group);
/**
* Emitted when the cursor theme has been changed.
* Emitted when the mouse settings have been changed.
*/
void cursorChanged();
void mouseChanged();
/**
* Emitted when the locale settings have been changed.
*/
void localeChanged();
/**
* Emitted when the paths settings have been changed.
*/
void pathsChanged();
/**
* Emitted when the shortcut settings have been changed.
*/
void shortcutsChanged();
/**
* Emitted by BlockShortcuts

View file

@ -32,7 +32,6 @@ int main(int argc, char **argv)
KCmdLineOptions options;
options.add("p", ki18n("emit paletteChanged()"));
options.add("f", ki18n("emit fontChanged()"));
options.add("ps", ki18n("emit settingsChanged(SETTINGS_PATH)"));
KCmdLineArgs::addCmdLineOptions( options );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
@ -48,10 +47,6 @@ int main(int argc, char **argv)
kDebug() << "emitChange(FontChanged)";
KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged);
return 0;
} else if (args->isSet("ps")) {
kDebug() << "emitChange(SettingsChanged)";
KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_PATHS);
return 0;
}
KCmdLineArgs::usage("No action specified");

View file

@ -52,7 +52,6 @@ void KGlobalSettingsTest::initTestCase()
QSignalSpy palette_spy( settings, SIGNAL(kdisplayPaletteChanged()) ); \
QSignalSpy font_spy( settings, SIGNAL(kdisplayFontChanged()) ); \
QSignalSpy style_spy( settings, SIGNAL(kdisplayStyleChanged()) ); \
QSignalSpy settings_spy( settings, SIGNAL(settingsChanged(int)) ); \
QSignalSpy appearance_spy( settings, SIGNAL(appearanceChanged()) )
static void callClient( const QString& opt, const char* signalToWaitFor ) {
@ -69,7 +68,6 @@ void KGlobalSettingsTest::testPaletteChange()
QCOMPARE(palette_spy.size(), 1);
QCOMPARE(font_spy.size(), 0);
QCOMPARE(style_spy.size(), 0);
QCOMPARE(settings_spy.size(), 0);
QCOMPARE(appearance_spy.size(), 1);
}
@ -80,18 +78,5 @@ void KGlobalSettingsTest::testFontChange()
QCOMPARE(palette_spy.size(), 0);
QCOMPARE(font_spy.size(), 1);
QCOMPARE(style_spy.size(), 0);
QCOMPARE(settings_spy.size(), 0);
QCOMPARE(appearance_spy.size(), 1);
}
void KGlobalSettingsTest::testSettingsChange()
{
CREATE_ALL_SPYS;
callClient("--ps", SIGNAL(settingsChanged(int)));
QCOMPARE(palette_spy.size(), 0);
QCOMPARE(font_spy.size(), 0);
QCOMPARE(style_spy.size(), 0);
QCOMPARE(settings_spy.size(), 1);
QCOMPARE(settings_spy.at(0).at(0).toInt(), (int)KGlobalSettings::SETTINGS_PATHS);
QCOMPARE(appearance_spy.size(), 0);
}

View file

@ -29,7 +29,6 @@ private Q_SLOTS:
void initTestCase();
void testPaletteChange();
void testFontChange();
void testSettingsChange();
};

View file

@ -94,10 +94,8 @@ public:
delete style.data();
}
void _k_slotSettingsChanged(int category)
void _k_slotStyleChanged()
{
Q_UNUSED(category);
if (clearButton) {
clearButton->setAnimationsEnabled(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects);
}
@ -255,7 +253,7 @@ void KLineEdit::init()
mode == KGlobalSettings::CompletionAuto);
connect( this, SIGNAL(selectionChanged()), this, SLOT(slotRestoreSelectionColors()));
connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)), this, SLOT(_k_slotSettingsChanged(int)));
connect(KGlobalSettings::self(), SIGNAL(kdisplayStyleChanged()), this, SLOT(_k_slotStyleChanged()));
const QPalette p = palette();
if ( !d->previousHighlightedTextColor.isValid() )

View file

@ -619,7 +619,7 @@ private:
friend class KLineEditPrivate;
KLineEditPrivate *const d;
Q_PRIVATE_SLOT( d, void _k_slotSettingsChanged( int category ) )
Q_PRIVATE_SLOT( d, void _k_slotStyleChanged() )
Q_PRIVATE_SLOT( d, void _k_textChanged(const QString&) )
};

View file

@ -236,8 +236,8 @@ void KMainWindowPrivate::init(KMainWindow *_q)
helpMenu = 0;
//actionCollection()->setWidget( this );
QObject::connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
q, SLOT(_k_slotSettingsChanged(int)));
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayStyleChanged()),
q, SLOT(_k_slotStyleChanged()));
// force KMWSessionManager creation - someone a better idea?
ksm->dummyInit();
@ -1012,10 +1012,8 @@ KStatusBar *KMainWindow::statusBar()
return sb;
}
void KMainWindowPrivate::_k_slotSettingsChanged(int category)
void KMainWindowPrivate::_k_slotStyleChanged()
{
Q_UNUSED(category);
// This slot will be called when the style KCM changes settings that need
// to be set on the already running applications.

View file

@ -625,7 +625,7 @@ protected:
KMainWindowPrivate * const k_ptr;
private:
Q_PRIVATE_SLOT(k_func(), void _k_slotSettingsChanged(int))
Q_PRIVATE_SLOT(k_func(), void _k_slotStyleChanged())
Q_PRIVATE_SLOT(k_func(), void _k_slotSaveAutoSaveSize())
};

View file

@ -58,7 +58,7 @@ public:
// This slot will be called when the style KCM changes settings that need
// to be set on the already running applications.
void _k_slotSettingsChanged(int category);
void _k_slotStyleChanged();
void _k_slotSaveAutoSaveSize();
void init(KMainWindow *_q);

View file

@ -54,14 +54,14 @@ public:
bool m_dragEnabled;
QPoint startPos;
void slotSettingsChanged( int );
void slotToolbarAppearanceChanged( int );
void slotPressedInternal();
void slotClickedInternal();
void slotDelayedMenuTimeout();
void readSettings();
};
void KPushButton::KPushButtonPrivate::slotSettingsChanged( int /* category */ )
void KPushButton::KPushButtonPrivate::slotToolbarAppearanceChanged( int /* arg */ )
{
readSettings();
parent->setIcon( item.icon() );
@ -156,8 +156,8 @@ void KPushButton::init( const KGuiItem &item )
setWhatsThis(item.whatsThis());
connect( KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
SLOT(slotSettingsChanged(int)) );
connect( KGlobalSettings::self(), SIGNAL(toolbarAppearanceChanged(int)),
SLOT(slotToolbarAppearanceChanged(int)) );
}
bool KPushButton::isDragEnabled() const

View file

@ -171,7 +171,7 @@ private:
class KPushButtonPrivate;
KPushButtonPrivate * const d;
Q_PRIVATE_SLOT(d, void slotSettingsChanged( int ))
Q_PRIVATE_SLOT(d, void slotToolbarAppearanceChanged( int ))
Q_PRIVATE_SLOT(d, void slotPressedInternal())
Q_PRIVATE_SLOT(d, void slotClickedInternal())
Q_PRIVATE_SLOT(d, void slotDelayedMenuTimeout())