Hotkey and Power Button handling

This commit is contained in:
Victor Tran 2016-06-13 21:40:01 +10:00
parent 1f29fc110d
commit 5466dd9435
12 changed files with 467 additions and 89 deletions

View file

@ -17,6 +17,8 @@ EndSessionWait::EndSessionWait(shutdownType type, QWidget *parent) :
case logout:
ui->label->setText("Log out");
break;
case dummy:
ui->label->setText("Dummy");
}
this->type = type;
@ -30,67 +32,69 @@ EndSessionWait::~EndSessionWait()
void EndSessionWait::showFullScreen() {
QDialog::showFullScreen();
QProcess p;
p.start("wmctrl -lp");
p.waitForStarted();
while (p.state() != 0) {
QApplication::processEvents();
}
QList<WmWindow*> *wlist = new QList<WmWindow*>();
QString output(p.readAllStandardOutput());
for (QString window : output.split("\n")) {
QStringList parts = window.split(" ");
parts.removeAll("");
if (parts.length() >= 4) {
if (parts[2].toInt() != QCoreApplication::applicationPid()) {
WmWindow *w = new WmWindow(this);
w->setPID(parts[2].toInt());
QString title;
for (int i = 4; i != parts.length(); i++) {
title = title.append(" " + parts[i]);
}
title = title.remove(0, 1);
w->setTitle(title);
wlist->append(w);
}
}
}
for (WmWindow* window : *wlist) {
p.start("wmctrl -c " + window->title());
p.waitForStarted();
while (p.state() != 0) {
QApplication::processEvents();
}
}
bool appsOpen = true;
while (appsOpen) {
appsOpen = false;
if (this->type != dummy) {
QProcess p;
p.start("wmctrl -lp");
p.waitForStarted();
while (p.state() != 0) {
QApplication::processEvents();
}
QList<WmWindow*> *wlist = new QList<WmWindow*>();
QString output(p.readAllStandardOutput());
for (QString window : output.split("\n")) {
QStringList parts = window.split(" ");
parts.removeAll("");
if (parts.length() >= 4) {
if (parts[2].toInt() != QCoreApplication::applicationPid()) {
appsOpen = true;
WmWindow *w = new WmWindow(this);
w->setPID(parts[2].toInt());
QString title;
for (int i = 4; i != parts.length(); i++) {
title = title.append(" " + parts[i]);
}
title = title.remove(0, 1);
w->setTitle(title);
wlist->append(w);
}
}
}
QApplication::processEvents();
}
performEndSession();
for (WmWindow* window : *wlist) {
p.start("wmctrl -c " + window->title());
p.waitForStarted();
while (p.state() != 0) {
QApplication::processEvents();
}
}
bool appsOpen = true;
while (appsOpen) {
appsOpen = false;
p.start("wmctrl -lp");
p.waitForStarted();
while (p.state() != 0) {
QApplication::processEvents();
}
QString output(p.readAllStandardOutput());
for (QString window : output.split("\n")) {
QStringList parts = window.split(" ");
parts.removeAll("");
if (parts.length() >= 4) {
if (parts[2].toInt() != QCoreApplication::applicationPid()) {
appsOpen = true;
}
}
}
QApplication::processEvents();
}
performEndSession();
}
}
void EndSessionWait::on_pushButton_clicked()

View file

@ -25,7 +25,8 @@ public:
enum shutdownType {
powerOff,
reboot,
logout
logout,
dummy //FOR TESTING
};
explicit EndSessionWait(shutdownType type, QWidget *parent = 0);

104
hotkeyhud.cpp Normal file
View file

@ -0,0 +1,104 @@
#include "hotkeyhud.h"
#include "ui_hotkeyhud.h"
HotkeyHud::HotkeyHud(QWidget *parent) :
QDialog(parent),
ui(new Ui::HotkeyHud)
{
ui->setupUi(this);
}
HotkeyHud::~HotkeyHud()
{
delete ui;
}
void HotkeyHud::setGeometry(int x, int y, int w, int h) { //Use wmctrl command because KWin has a problem with moving windows offscreen.
QDialog::setGeometry(x, y, w, h);
QProcess::execute("wmctrl -r " + this->windowTitle() + " -e 0," +
QString::number(x) + "," + QString::number(y) + "," +
QString::number(w) + "," + QString::number(h));
}
void HotkeyHud::setGeometry(QRect geometry) {
this->setGeometry(geometry.x(), geometry.y(), geometry.width(), geometry.height());
}
void HotkeyHud::paintEvent(QPaintEvent *event) {
QPainter painter(this);
painter.setPen(this->palette().color(QPalette::WindowText));
painter.drawLine(0, this->height() - 1, this->width(), this->height() - 1);
event->accept();
}
void HotkeyHud::show() {
QDialog::show();
if (!isShowing) {
QRect screenGeometry = QApplication::desktop()->screenGeometry();
this->setGeometry(screenGeometry.x(), screenGeometry.y() - this->height(), screenGeometry.width(), this->height());
QPropertyAnimation *anim = new QPropertyAnimation(this, "geometry");
anim->setStartValue(this->geometry());
anim->setEndValue(QRect(screenGeometry.x(), screenGeometry.y(), screenGeometry.width(), this->height()));
anim->setDuration(100);
anim->setEasingCurve(QEasingCurve::OutCubic);
anim->start();
connect(anim, &QPropertyAnimation::finished, [=](){
this->repaint();
});
}
if (timeout == NULL) {
timeout = new QTimer();
timeout->setSingleShot(true);
timeout->setInterval(5000);
connect(timeout, SIGNAL(timeout()), this, SLOT(Timeout()));
}
timeout->start();
isShowing = true;
}
void HotkeyHud::show(QIcon icon, QString control, int value) {
ui->icon->setPixmap(icon.pixmap(32));
ui->control->setText(control);
ui->slider->setValue(value);
ui->value->setText(QString::number(value) + "%");
ui->explanation->setVisible(false);
ui->slider->setVisible(true);
ui->value->setVisible(true);
this->show();
}
void HotkeyHud::show(QIcon icon, QString control, QString explanation) {
ui->icon->setPixmap(icon.pixmap(32));
ui->control->setText(control);
ui->explanation->setText(explanation);
ui->slider->setVisible(false);
ui->value->setVisible(false);
ui->explanation->setVisible(true);
this->show();
}
void HotkeyHud::Timeout() {
timeout->deleteLater();
timeout = NULL;
this->close();
}
void HotkeyHud::close() {
QRect screenGeometry = QApplication::desktop()->screenGeometry();
QPropertyAnimation *anim = new QPropertyAnimation(this, "geometry");
anim->setStartValue(this->geometry());
anim->setEndValue(QRect(screenGeometry.x(), screenGeometry.y() - this->height(), screenGeometry.width(), this->height()));
anim->setDuration(500);
anim->setEasingCurve(QEasingCurve::InCubic);
connect(anim, &QPropertyAnimation::finished, [=]() {
QDialog::close();
isShowing = false;
});
anim->start();
}

45
hotkeyhud.h Normal file
View file

@ -0,0 +1,45 @@
#ifndef HOTKEYHUD_H
#define HOTKEYHUD_H
#include <QDialog>
#include <QPropertyAnimation>
#include <QTimer>
#include <QProcess>
#include <QPainter>
#include <QDesktopWidget>
#include <QPaintEvent>
namespace Ui {
class HotkeyHud;
}
class HotkeyHud : public QDialog
{
Q_OBJECT
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
public:
explicit HotkeyHud(QWidget *parent = 0);
~HotkeyHud();
void show(QIcon icon, QString control, int value);
void show(QIcon icon, QString control, QString explanation);
void close();
void setGeometry(int x, int y, int w, int h);
void setGeometry(QRect geometry);
private slots:
void Timeout();
private:
Ui::HotkeyHud *ui;
void paintEvent(QPaintEvent* event);
void show();
bool isShowing = false;
QTimer* timeout = NULL;
};
#endif // HOTKEYHUD_H

71
hotkeyhud.ui Normal file
View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HotkeyHud</class>
<widget class="QDialog" name="HotkeyHud">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>544</width>
<height>42</height>
</rect>
</property>
<property name="windowTitle">
<string>HotkeyHud</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="icon">
<property name="text">
<string>Icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="control">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Volume</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="slider">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="explanation">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Explanation</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="value">
<property name="text">
<string>0%</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -527,44 +527,53 @@ void InfoPaneDropdown::on_redshiftIntensity_valueChanged(int value)
}
void InfoPaneDropdown::newNotificationReceived(int id, QString summary, QString body, QIcon icon) {
QFrame* frame = new QFrame();
QHBoxLayout* layout = new QHBoxLayout();
layout->setMargin(0);
frame->setLayout(layout);
if (notificationFrames.keys().contains(id)) { //Notification already exists, update it.
QFrame* frame = notificationFrames.value(id);
frame->property("summaryLabel").value<QLabel*>()->setText(summary);
frame->property("bodyLabel").value<QLabel*>()->setText(body);
} else {
QFrame* frame = new QFrame();
QHBoxLayout* layout = new QHBoxLayout();
layout->setMargin(0);
frame->setLayout(layout);
QLabel* iconLabel = new QLabel();
iconLabel->setPixmap(icon.pixmap(22, 22));
layout->addWidget(iconLabel);
QLabel* iconLabel = new QLabel();
iconLabel->setPixmap(icon.pixmap(22, 22));
layout->addWidget(iconLabel);
QLabel* sumLabel = new QLabel();
sumLabel->setText(summary);
QFont font = sumLabel->font();
font.setBold(true);
sumLabel->setFont(font);
layout->addWidget(sumLabel);
QLabel* sumLabel = new QLabel();
sumLabel->setText(summary);
QFont font = sumLabel->font();
font.setBold(true);
sumLabel->setFont(font);
layout->addWidget(sumLabel);
QLabel* bodyLabel = new QLabel();
bodyLabel->setText(body);
bodyLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
layout->addWidget(bodyLabel);
QLabel* bodyLabel = new QLabel();
bodyLabel->setText(body);
bodyLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
layout->addWidget(bodyLabel);
QLabel* dateLabel = new QLabel();
dateLabel->setText(QDateTime::currentDateTime().toString("HH:mm:ss"));
layout->addWidget(dateLabel);
QLabel* dateLabel = new QLabel();
dateLabel->setText(QDateTime::currentDateTime().toString("HH:mm:ss"));
layout->addWidget(dateLabel);
QPushButton* button = new QPushButton();
button->setIcon(QIcon::fromTheme("window-close"));
connect(button, &QPushButton::clicked, [=]() {
emit closeNotification(id);
});
layout->addWidget(button);
QPushButton* button = new QPushButton();
button->setIcon(QIcon::fromTheme("window-close"));
connect(button, &QPushButton::clicked, [=]() {
emit closeNotification(id);
});
layout->addWidget(button);
ui->notificationsList->layout()->addWidget(frame);
ui->noNotifications->setVisible(false);
ui->clearAllNotifications->setVisible(true);
notificationFrames.insert(id, frame);
ui->notificationsList->layout()->addWidget(frame);
ui->noNotifications->setVisible(false);
ui->clearAllNotifications->setVisible(true);
frame->setProperty("summaryLabel", QVariant::fromValue(sumLabel));
frame->setProperty("bodyLabel", QVariant::fromValue(bodyLabel));
emit numNotificationsChanged(notificationFrames.count());
notificationFrames.insert(id, frame);
emit numNotificationsChanged(notificationFrames.count());
}
}
void InfoPaneDropdown::removeNotification(int id) {

View file

@ -323,7 +323,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>6</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
@ -920,7 +920,7 @@
</widget>
<widget class="QWidget" name="tab_7">
<attribute name="icon">
<iconset theme="thewave" resource="resources.qrc">
<iconset theme="thewave">
<normaloff>:/icons/thewave.svg</normaloff>:/icons/thewave.svg</iconset>
</attribute>
<attribute name="title">
@ -1236,7 +1236,7 @@
</font>
</property>
<property name="text">
<string>theShell 2.0</string>
<string>theShell 2.1</string>
</property>
</widget>
</item>
@ -1828,14 +1828,14 @@
<second>0</second>
<year>1969</year>
<month>12</month>
<day>8</day>
<day>7</day>
</datetime>
</property>
<property name="date">
<date>
<year>1969</year>
<month>12</month>
<day>8</day>
<day>7</day>
</date>
</property>
<property name="displayFormat">

View file

@ -496,7 +496,7 @@ void MainWindow::on_volumeFrame_MouseEnter()
if (line.contains("[off]")) {
ui->volumeSlider->setValue(0);
} else {
QString percent = line.mid(line.indexOf("\[") + 1, 3).remove("\%");
QString percent = line.mid(line.indexOf("\[") + 1, 3).remove("\%").remove("\]");
ui->volumeSlider->setValue(percent.toInt());
ui->volumeSlider->setMaximum(100);
}
@ -564,7 +564,6 @@ void MainWindow::on_volumeSlider_valueChanged(int value)
void MainWindow::on_brightnessFrame_MouseEnter()
{
ui->brightnessSlider->setVisible(true);
//ui->volumeSlider->resize(0, 0);
QPropertyAnimation* anim = new QPropertyAnimation(ui->brightnessSlider, "geometry");
anim->setStartValue(ui->brightnessSlider->geometry());
QRect endGeometry = ui->brightnessSlider->geometry();

View file

@ -1,8 +1,34 @@
#include "nativeeventfilter.h"
extern void EndSession(EndSessionWait::shutdownType type);
NativeEventFilter::NativeEventFilter(QObject* parent) : QObject(parent)
{
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "Inhibit");
message.setArguments(QList<QVariant>() << "handle-power-key" << "theShell" << "theShell Handles Hardware Power Keys" << "block");
QDBusReply<QDBusUnixFileDescriptor> reply = QDBusConnection::systemBus().call(message);
powerInhibit = reply;
Hotkeys = new HotkeyHud();
Hotkeys->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
Hotkeys->setAttribute(Qt::WA_ShowWithoutActivating, true);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_MonBrightnessUp), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_MonBrightnessDown), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_AudioLowerVolume), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_AudioRaiseVolume), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_AudioMute), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_Eject), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
XGrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_PowerOff), AnyModifier, RootWindow(QX11Info::display(), 0), true, GrabModeAsync, GrabModeAsync);
}
NativeEventFilter::~NativeEventFilter() {
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_MonBrightnessUp), AnyModifier, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_MonBrightnessDown), AnyModifier, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_AudioLowerVolume), AnyModifier, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_AudioRaiseVolume), AnyModifier, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_AudioMute), AnyModifier, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_Eject), AnyModifier, QX11Info::appRootWindow());
XUngrabKey(QX11Info::display(), XKeysymToKeycode(QX11Info::display(), XF86XK_PowerOff), AnyModifier, QX11Info::appRootWindow());
}
bool NativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
@ -20,6 +46,102 @@ bool NativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *mes
if (client->type == type) {
emit SysTrayEvent(client->data.data32[1], client->data.data32[2], client->data.data32[3], client->data.data32[4]);
}
} else if (event->response_type == XCB_KEY_PRESS) {
if (lastPress.restart() > 100) {
xcb_key_press_event_t* button = static_cast<xcb_key_press_event_t*>(message);
//Get Current Brightness
QProcess* backlight = new QProcess(this);
backlight->start("xbacklight -get");
backlight->waitForFinished();
float currentBrightness = ceil(QString(backlight->readAll()).toFloat());
delete backlight;
//Get Current Volume
QProcess* mixer = new QProcess(this);
mixer->start("amixer");
mixer->waitForFinished();
QString output(mixer->readAll());
delete mixer;
int volume;
int limit;
bool readLine = false;
for (QString line : output.split("\n")) {
if (line.startsWith(" ") && readLine) {
if (line.startsWith(" Front Left:")) {
if (line.contains("[off]")) {
volume = 0;
} else {
QString percent = line.mid(line.indexOf("\[") + 1, 3).remove("\%").remove("]");
volume = percent.toInt();
}
} else if (line.startsWith(" Limits:")) {
limit = line.split(" ").last().toInt();
}
} else {
if (line.contains("'Master'")) {
readLine = true;
} else {
readLine = false;
}
}
}
if (button->detail == XKeysymToKeycode(QX11Info::display(), XF86XK_MonBrightnessUp)) { //Increase brightness by 10%
currentBrightness = currentBrightness + 10;
if (currentBrightness > 100) currentBrightness = 100;
QProcess* backlightAdj = new QProcess(this);
backlightAdj->start("xbacklight -set " + QString::number(currentBrightness));
connect(backlightAdj, SIGNAL(finished(int)), backlightAdj, SLOT(deleteLater()));
Hotkeys->show(QIcon::fromTheme("video-display"), "Brightness", (int) currentBrightness);
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XF86XK_MonBrightnessDown)) { //Decrease brightness by 10%
currentBrightness = currentBrightness - 10;
if (currentBrightness < 0) currentBrightness = 0;
QProcess* backlightAdj = new QProcess(this);
backlightAdj->start("xbacklight -set " + QString::number(currentBrightness));
connect(backlightAdj, SIGNAL(finished(int)), backlightAdj, SLOT(deleteLater()));
Hotkeys->show(QIcon::fromTheme("video-display"), "Brightness", (int) currentBrightness);
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XF86XK_AudioRaiseVolume)) { //Increase Volume by 5%
volume = volume + 5;
if (volume > 100) volume = 100;
QProcess* volumeAdj = new QProcess(this);
volumeAdj->start("amixer set Master " + QString::number(limit * (volume / (float) 100)) + " on");
connect(volumeAdj, SIGNAL(finished(int)), volumeAdj, SLOT(deleteLater()));
Hotkeys->show(QIcon::fromTheme("audio-volume-high"), "Volume", volume);
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XF86XK_AudioLowerVolume)) { //Decrease Volume by 5%
volume = volume - 5;
if (volume < 0) volume = 0;
QProcess* volumeAdj = new QProcess(this);
volumeAdj->start("amixer set Master " + QString::number(limit * (volume / (float) 100)) + " on");
connect(volumeAdj, SIGNAL(finished(int)), volumeAdj, SLOT(deleteLater()));
Hotkeys->show(QIcon::fromTheme("audio-volume-high"), "Volume", volume);
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XF86XK_AudioMute)) { //Set Volume to 0%
volume = 0;
QProcess* volumeAdj = new QProcess(this);
volumeAdj->start("amixer set Master off");
connect(volumeAdj, SIGNAL(finished(int)), volumeAdj, SLOT(deleteLater()));
Hotkeys->show(QIcon::fromTheme("audio-volume-high"), "Volume", volume);
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XF86XK_Eject)) { //Eject Disc
QProcess* eject = new QProcess(this);
eject->start("eject");
connect(eject, SIGNAL(finished(int)), eject, SLOT(deleteLater()));
Hotkeys->show(QIcon::fromTheme("media-eject"), "Eject", "Attempting to eject disc...");
} else if (button->detail == XKeysymToKeycode(QX11Info::display(), XF86XK_PowerOff)) { //Power Off
if (QMessageBox::question(Hotkeys, "Power Off", "Are you sure you wish to close all applications and power off the computer?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
EndSession(EndSessionWait::powerOff);
}
}
}
}
}
return false;

View file

@ -6,12 +6,28 @@
#include <xcb/xcb.h>
#include <xcb/xcb_atom.h>
#include <QX11Info>
#include <QProcess>
#include <QTime>
#include <math.h>
#include <QIcon>
#include "hotkeyhud.h"
#include "endsessionwait.h"
#include <QDBusUnixFileDescriptor>
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDBusReply>
#include <QDebug>
#include <QMessageBox>
#include <X11/XF86keysym.h>
#include <X11/Xlib.h>
class NativeEventFilter : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
public:
explicit NativeEventFilter(QObject* parent = 0);
~NativeEventFilter();
signals:
void SysTrayEvent(long opcode, long data2, long data3, long data4);
@ -19,6 +35,10 @@ public slots:
private:
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
QTime lastPress;
HotkeyHud* Hotkeys;
QDBusUnixFileDescriptor powerInhibit;
};
#endif // NATIVEEVENTFILTER_H

View file

@ -45,7 +45,8 @@ SOURCES += main.cpp\
segfaultdialog.cpp \
globalfilter.cpp \
systrayicons.cpp \
nativeeventfilter.cpp
nativeeventfilter.cpp \
hotkeyhud.cpp
HEADERS += mainwindow.h \
window.h \
@ -78,7 +79,8 @@ HEADERS += mainwindow.h \
segfaultdialog.h \
globalfilter.h \
systrayicons.h \
nativeeventfilter.h
nativeeventfilter.h \
hotkeyhud.h
FORMS += mainwindow.ui \
menu.ui \
@ -91,7 +93,8 @@ FORMS += mainwindow.ui \
loginsplash.ui \
choosebackground.ui \
touchkeyboard.ui \
segfaultdialog.ui
segfaultdialog.ui \
hotkeyhud.ui
DISTFILES += \
org.freedesktop.Notifications.xml \

View file

@ -247,7 +247,7 @@ void theWaveWorker::processSpeech(QString speech, bool voiceFeedback) {
QNetworkRequest request;
QUrl requestUrl("https://en.wikipedia.org/w/api.php?action=query&titles=" + speech.replace(" ", "%20") + "&format=xml&prop=extracts&redirects=true&exintro=true");
request.setUrl(requestUrl);
request.setHeader(QNetworkRequest::UserAgentHeader, "theWave/2.0 (vicr12345@gmail.com)");
request.setHeader(QNetworkRequest::UserAgentHeader, "theWave/2.1 (vicr12345@gmail.com)");
QNetworkAccessManager networkManager;
connect(&networkManager, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkReply* NetworkReply = networkManager.get(request);