This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge remote-tracking branch 'origin/master' into new-panel-api

Conflicts:
	razorqt-panel/plugin-kbindicator/razorkbindicator.cpp
  • Loading branch information...
SokoloffA committed Mar 12, 2013
2 parents 6ab4ed1 + c9f1219 commit 928ff656d716ac2ad807cbb787e1dc0298f51a55
@@ -351,22 +351,23 @@ QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
const QString pixmaps(QLatin1String("/usr/share/pixmaps"));
QDir currentDir(pixmaps);
+ QIconDirInfo dirInfo(pixmaps);
if (currentDir.exists(iconName + pngext)) {
PixmapEntry *iconEntry = new PixmapEntry;
- iconEntry->dir = pixmaps;
+ iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + pngext);
- // Notice we ensure that pixmap entries allways come before
+ // Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards
entries.prepend(iconEntry);
} else if (m_supportsSvg &&
currentDir.exists(iconName + svgext)) {
ScalableEntry *iconEntry = new ScalableEntry;
- iconEntry->dir = pixmaps;
+ iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + svgext);
entries.append(iconEntry);
} else if (currentDir.exists(iconName + xpmext)) {
PixmapEntry *iconEntry = new PixmapEntry;
- iconEntry->dir = pixmaps;
+ iconEntry->dir = dirInfo;
iconEntry->filename = currentDir.filePath(iconName + xpmext);
// Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards
@@ -27,7 +27,8 @@ LoginData::LoginData(QLightDM::Greeter *greeter) :
m_StatefilePath = XdgDirs::cacheHome(true) + "/" + DATA_DIR + "/state";
}
-LoginData::~LoginData() {
+LoginData::~LoginData()
+{
}
int LoginData::numberOfUsers()
@@ -42,7 +43,6 @@ int LoginData::numberOfSessions()
QString LoginData::userFullName(int user_index)
{
-
return data(user_index, m_UsersModel, Qt::DisplayRole);
}
@@ -63,7 +63,8 @@ QString LoginData::sessionName(int session_index)
int LoginData::userSession(QString user_name)
{
- for (int i = 0; i < numberOfUsers(); i++) {
+ for (int i = 0; i < numberOfUsers(); i++)
+ {
if (userName(i) == user_name)
{
return userSession(i);
@@ -141,7 +142,7 @@ QString LoginData::data(int index, QAbstractListModel& model, int role)
{
if (0 <= index && index < model.rowCount(QModelIndex()))
{
- QModelIndex modelIndex = m_UsersModel.index(index, 0);
+ QModelIndex modelIndex = model.index(index, 0);
return model.data(modelIndex, role).toString();
}
else
@@ -157,4 +158,4 @@ Msg::Msg()
void Msg::show(const QString msg)
{
QMessageBox::information(NULL, "", msg);
-}
+}
@@ -19,8 +19,8 @@
#define LAST_USER_KEY "last-user"
#define CONFIG_FILE "/etc/lightdm/lightdm-razor-greeter.conf"
-class LoginData : public QObject {
-
+class LoginData : public QObject
+{
Q_OBJECT
public:
@@ -43,7 +43,7 @@ class LoginData : public QObject {
QString getLastUser();
void setLastUser(QString user);
-
+
private:
QString data(int index, QAbstractListModel& model, int role);
QLightDM::Greeter *m_Greeter;
@@ -59,5 +59,5 @@ class Msg
static void show(const QString msg);
};
-#endif /* STATE_H */
+#endif /* LOGIN_DATA_H */
@@ -63,9 +63,9 @@ LoginForm::LoginForm(QWidget *parent) :
}
LoginForm::~LoginForm()
- {
+{
delete ui;
- }
+}
void LoginForm::setFocus(Qt::FocusReason reason)
{
@@ -89,7 +89,7 @@ void LoginForm::setupAppearence()
setStyleSheet(razorTheme.qss("razor-lightdm-greeter/razor-lightdm-greeter"));
QPixmap icon(QString(SHARE_DIR) + "/graphics/rqt-2.svg");
ui->iconLabel->setPixmap(icon.scaled(ui->iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
-
+
ui->hostnameLabel->setText(m_Greeter.hostname());
}
@@ -138,7 +138,7 @@ void LoginForm::initializeControls()
if (m_Greeter.showManualLoginHint())
{
ui->userCombo->setCurrentIndex(m_otherUserComboIndex);
-}
+ }
else
{
ui->userCombo->setCurrentIndex(m_LoginData.suggestedUser());
@@ -150,9 +150,9 @@ void LoginForm::initializeControls()
ui->otherUserInput->clear();
QStringList completions;
for (int i = 0; i < m_LoginData.numberOfUsers(); i++)
-{
+ {
completions << m_LoginData.userName(i);
-}
+ }
QCompleter *completer = new QCompleter(completions, ui->otherUserInput);
completer->setCompletionMode(QCompleter::InlineCompletion);
ui->otherUserInput->setCompleter(completer);
@@ -162,7 +162,7 @@ void LoginForm::initializeControls()
}
void LoginForm::setSessionCombo(int session_index)
- {
+{
if (0 <= session_index && session_index < ui->sessionCombo->count())
{
ui->sessionCombo->setCurrentIndex(session_index);
@@ -44,7 +44,7 @@ class LoginForm : public QWidget
public:
explicit LoginForm(QWidget *parent = 0);
~LoginForm();
-
+
virtual void setFocus(Qt::FocusReason reason);
public slots:
@@ -54,9 +54,9 @@ public slots:
void clearAll();
void leaveClicked();
void razorPowerFinished();
-
+
void onPrompt(QString prompt, QLightDM::Greeter::PromptType promptType);
-
+
void authenticationComplete();
private:
@@ -5,19 +5,16 @@ set(PLUGIN "panelkbindicator")
set(HEADERS
razorkbindicator.h
- razorkbindicatoreventfilter.h
razorkbindicatorconfiguration.h
)
set(SOURCES
razorkbindicator.cpp
- razorkbindicatoreventfilter.cpp
razorkbindicatorconfiguration.cpp
)
set(MOCS
razorkbindicator.h
- razorkbindicatoreventfilter.h
razorkbindicatorconfiguration.h
)
@@ -27,43 +27,52 @@
#include "razorkbindicator.h"
-#include <QtGui/QLabel>
-
-#include "razorkbindicatoreventfilter.h"
+#include <X11/XKBlib.h>
+#include <QtGui/QLabel>
+#include <QtGui/QX11Info>
Q_EXPORT_PLUGIN2(panelkbindicator, RazorKbIndicatorLibrary)
-
RazorKbIndicator::RazorKbIndicator(const IRazorPanelPluginStartupInfo &startupInfo):
QObject(),
IRazorPanelPlugin(startupInfo),
- content(new QLabel()),
- eventFilter(RazorKbIndicatorEventFilter::instance())
+ mContent(new QLabel())
{
- connect(eventFilter, SIGNAL(indicatorsChanged(uint,uint)), this, SLOT(setIndicators(uint,uint)));
- content->setAlignment(Qt::AlignCenter);
+ connect(this, SIGNAL(indicatorsChanged(uint,uint)), this, SLOT(setIndicators(uint,uint)));
+ mContent->setAlignment(Qt::AlignCenter);
+
+ int code;
+ int major = XkbMajorVersion;
+ int minor = XkbMinorVersion;
+ int XkbErrorBase;
+
+ mDisplay = QX11Info::display();
+
+ if (XkbLibraryVersion(&major, &minor))
+ if (XkbQueryExtension(mDisplay, &code, &mXkbEventBase, &XkbErrorBase, &major, &minor))
+ if (XkbUseExtension(mDisplay, &major, &minor))
+ XkbSelectEvents(mDisplay, XkbUseCoreKbd, XkbIndicatorStateNotifyMask, XkbIndicatorStateNotifyMask);
settingsChanged();
- content->setEnabled(eventFilter->getLockStatus(bit));
realign();
}
RazorKbIndicator::~RazorKbIndicator()
{
- delete content;
+ delete mContent;
}
QWidget *RazorKbIndicator::widget()
{
- return content;
+ return mContent;
}
void RazorKbIndicator::settingsChanged()
{
- bit = settings()->value("bit", 0).toInt();
- content->setText(settings()->value("text", QString("C")).toString());
- content->setEnabled(eventFilter->getLockStatus(bit));
+ mBit = settings()->value("bit", 0).toInt();
+ mContent->setText(settings()->value("text", QString("C")).toString());
+ mContent->setEnabled(getLockStatus(mBit));
}
QDialog *RazorKbIndicator::configureDialog()
@@ -73,11 +82,32 @@ QDialog *RazorKbIndicator::configureDialog()
void RazorKbIndicator::realign()
{
- content->setMinimumSize(panel()->lineSize(), panel()->lineSize());
+ mContent->setMinimumSize(panel()->lineSize(), panel()->lineSize());
}
void RazorKbIndicator::setIndicators(unsigned int changed, unsigned int state)
{
- if (changed & (1 << bit))
- content->setEnabled(state & (1 << bit));
+ if (changed & (1 << mBit))
+ mContent->setEnabled(state & (1 << mBit));
+}
+
+bool RazorKbIndicator::getLockStatus(int bit)
+{
+ bool state = false;
+ if (mDisplay)
+ {
+ unsigned n;
+ XkbGetIndicatorState(mDisplay, XkbUseCoreKbd, &n);
+ state = (n & (1 << bit));
+ }
+ return state;
+}
+
+void RazorKbIndicator::x11EventFilter(XEvent* event)
+{
+ XkbEvent* xkbEvent = reinterpret_cast<XkbEvent*>(event);
+
+ if (xkbEvent->type == mXkbEventBase + XkbEventCode)
+ if (xkbEvent->any.xkb_type == XkbIndicatorStateNotify)
+ emit indicatorsChanged(xkbEvent->indicators.changed, xkbEvent->indicators.state);
}
@@ -33,7 +33,6 @@
class QLabel;
-class RazorKbIndicatorEventFilter;
class RazorKbIndicator : public QObject, public IRazorPanelPlugin
{
@@ -50,17 +49,25 @@ class RazorKbIndicator : public QObject, public IRazorPanelPlugin
QDialog *configureDialog();
virtual void realign();
+signals:
+ void indicatorsChanged(unsigned int, unsigned int);
+
protected slots:
virtual void settingsChanged();
void setIndicators(unsigned int, unsigned int);
+protected:
+ bool getLockStatus(int mBit);
+ virtual void x11EventFilter(XEvent* event);
+
private:
- QLabel *content;
+ QLabel *mContent;
- int bit;
+ int mBit;
- RazorKbIndicatorEventFilter *eventFilter;
+ Display *mDisplay;
+ int mXkbEventBase;
};
Oops, something went wrong.

0 comments on commit 928ff65

Please sign in to comment.