ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AutoRun Class Reference

#include <src/ckb/autorun.h>

+ Collaboration diagram for AutoRun:

Static Public Member Functions

static bool available ()
 
static bool once ()
 
static bool isEnabled ()
 
static void enable ()
 
static void disable ()
 

Detailed Description

Definition at line 8 of file autorun.h.

Member Function Documentation

bool AutoRun::available ( )
static

Definition at line 20 of file autorun.cpp.

Referenced by disable(), enable(), and SettingsWidget::SettingsWidget().

20  {
21  // Allow autostart if the program is located in a system path
22 #ifdef Q_OS_LINUX
23  return QDir::root().absoluteFilePath(QStandardPaths::findExecutable("ckb")) == qApp->applicationFilePath();
24 #elif defined(Q_OS_MACX)
25  return qApp->applicationFilePath().startsWith("/Applications/ckb.app", Qt::CaseInsensitive);
26 #endif
27 }

+ Here is the caller graph for this function:

void AutoRun::disable ( )
static

Definition at line 53 of file autorun.cpp.

References available().

Referenced by SettingsWidget::on_loginItemBox_clicked().

53  {
54  if(!available())
55  return;
56  // Remove file
57  QFile::remove(path.absoluteFilePath(file));
58 }
static bool available()
Definition: autorun.cpp:20

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AutoRun::enable ( )
static

Definition at line 42 of file autorun.cpp.

References available(), and CkbSettings::set().

Referenced by SettingsWidget::on_loginItemBox_clicked(), and SettingsWidget::SettingsWidget().

42  {
43  if(!available())
44  return;
45  // Copy file into place
46  if(!path.exists())
47  QDir::home().mkpath(path.absolutePath());
48  QFile::copy(internalFile, path.absoluteFilePath(file));
49  // Mark once() as done
51 }
static bool available()
Definition: autorun.cpp:20
static void set(const QString &key, const QVariant &value)
static const QString settingPath
Definition: autorun.cpp:18

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AutoRun::isEnabled ( )
static

Definition at line 33 of file autorun.cpp.

References CkbSettings::set().

Referenced by SettingsWidget::SettingsWidget().

33  {
34  // Check if the file exists. If not, autostart is disabled.
35  if(!path.exists() || !path.exists(file))
36  return false;
37  // If autostart is enabled, set the flag from once() (in case it hasn't been done yet)
39  return true;
40 }
static void set(const QString &key, const QVariant &value)
static const QString settingPath
Definition: autorun.cpp:18

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AutoRun::once ( )
static

Definition at line 29 of file autorun.cpp.

References CkbSettings::get().

Referenced by SettingsWidget::SettingsWidget().

29  {
30  return CkbSettings::get(settingPath).toBool();
31 }
static QVariant get(const QString &key, const QVariant &defaultValue=QVariant())
static const QString settingPath
Definition: autorun.cpp:18

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: