Skip to content

Commit

Permalink
Minor code cleanup, add some tooltips.
Browse files Browse the repository at this point in the history
  • Loading branch information
jahnf committed May 14, 2019
1 parent 8183b93 commit a5829ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion preferencesdlg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace {
#define CURSOR_PATH ":/icons/cursors/"
static std::map<const QString, const QPair<const QString, const Qt::CursorShape>> cursorMap {
static const std::map<const QString, const QPair<const QString, const Qt::CursorShape>> cursorMap {
{ "", {"No Cursor", Qt::BlankCursor}},
{ CURSOR_PATH "cursor-arrow.png", {"Arrow Cursor", Qt::ArrowCursor}},
{ CURSOR_PATH "cursor-busy.png", {"Busy Cursor", Qt::BusyCursor}},
Expand Down Expand Up @@ -82,8 +82,10 @@ PreferencesDialog::PreferencesDialog(Settings* settings, Spotlight* spotlight, Q
grid->addWidget(cursorCb, 4, 1);

auto closeBtn = new QPushButton(tr("&Close"), this);
closeBtn->setToolTip(tr("Close the preferences dialog."));
connect(closeBtn, &QPushButton::clicked, [this](){ this->close(); });
auto defaultsBtn = new QPushButton(tr("&Reset Defaults"), this);
defaultsBtn->setToolTip(tr("Reset all settings to their default value."));
connect(defaultsBtn, &QPushButton::clicked, settings, &Settings::setDefaults);

auto btnHBox = new QHBoxLayout;
Expand All @@ -110,6 +112,7 @@ QWidget* PreferencesDialog::createConnectedStateWidget(Spotlight* spotlight)
auto vbox = new QVBoxLayout(group);
auto lbl = new QLabel(deviceText.arg(spotlight->anySpotlightDeviceConnected() ? "True"
: "False"), this);
lbl->setToolTip(tr("Connection status of the spotlight device."));

vbox->addWidget(lbl);
connect(spotlight, &Spotlight::anySpotlightDeviceConnectedChanged, [lbl](bool connected) {
Expand Down
5 changes: 3 additions & 2 deletions spotlight.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ bool Spotlight::setupDevEventInotify()
const int wd = inotify_add_watch( fd, "/dev/input", IN_CREATE | IN_DELETE );
// TODO check if wd >=0... else error
auto notifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(notifier, &QSocketNotifier::activated, [this](int fd)
connect(notifier, &QSocketNotifier::activated, [this, wd](int fd)
{
int bytesAvaibable = 0;
if( ioctl( fd, FIONREAD, &bytesAvaibable ) < 0 || bytesAvaibable <= 0 ) {
Expand All @@ -206,7 +206,8 @@ bool Spotlight::setupDevEventInotify()
const char* const end = at + bytesRead;
while( at < end )
{
const inotify_event* event = reinterpret_cast<const inotify_event*>( at );
inotify_event const * const event = reinterpret_cast<const inotify_event*>( at );

if( (event->mask & (IN_CREATE )) && QString(event->name).startsWith("event") )
{
const auto devicePath = QString("/dev/input/").append(event->name);
Expand Down

0 comments on commit a5829ba

Please sign in to comment.