Krita Source Code Documentation
Loading...
Searching...
No Matches
klanguagebutton.cpp File Reference
#include "klanguagebutton.h"
#include <QMenu>
#include <QLayout>
#include <QPushButton>
#include <QDir>
#include <QFile>
#include <QLocale>
#include <klocalizedstring.h>
#include <kconfig.h>
#include <kconfiggroup.h>

Go to the source code of this file.

Classes

class  KLanguageButtonPrivate
 

Functions

static void checkInsertPos (QMenu *popup, const QString &str, int &index)
 

Function Documentation

◆ checkInsertPos()

static void checkInsertPos ( QMenu * popup,
const QString & str,
int & index )
static

Definition at line 21 of file klanguagebutton.cpp.

22{
23 if (index != -1) {
24 return;
25 }
26
27 int a = 0;
28 const QList<QAction *> actions = popup->actions();
29 int b = actions.count();
30
31 while (a < b) {
32 int w = (a + b) / 2;
33 QAction *ac = actions[ w ];
34 int j = str.localeAwareCompare(ac->text());
35 if (j > 0) {
36 a = w + 1;
37 } else {
38 b = w;
39 }
40 }
41
42 index = a; // it doesn't really matter ... a == b here.
43
44 Q_ASSERT(a == b);
45}