Move service classes to separate namespace
This commit is contained in:
parent
2874177bc4
commit
4edb231c4e
@ -22,7 +22,7 @@ int main(int argc, char *argv[])
|
|||||||
a.setQuitOnLastWindowClosed(false);
|
a.setQuitOnLastWindowClosed(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
AppTranslator appTranslator({"screentranslator"});
|
service::AppTranslator appTranslator({"screentranslator"});
|
||||||
appTranslator.retranslate();
|
appTranslator.retranslate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ int main(int argc, char *argv[])
|
|||||||
parser.process(a);
|
parser.process(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
SingleApplication guard;
|
service::SingleApplication guard;
|
||||||
if (!guard.isValid())
|
if (!guard.isValid())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
AppTranslator::AppTranslator(const QStringList &translationFiles)
|
AppTranslator::AppTranslator(const QStringList &translationFiles)
|
||||||
: translationFiles_(translationFiles)
|
: translationFiles_(translationFiles)
|
||||||
{
|
{
|
||||||
@ -49,3 +51,5 @@ QStringList AppTranslator::searchPaths() const
|
|||||||
QLatin1String(":/translations"),
|
QLatin1String(":/translations"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
class AppTranslator
|
class AppTranslator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -13,3 +15,5 @@ private:
|
|||||||
QStringList searchPaths() const;
|
QStringList searchPaths() const;
|
||||||
QStringList translationFiles_;
|
QStringList translationFiles_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
QHash<QPair<quint32, quint32>, QAction *> GlobalAction::actions_;
|
QHash<QPair<quint32, quint32>, QAction *> GlobalAction::actions_;
|
||||||
|
|
||||||
void GlobalAction::init()
|
void GlobalAction::init()
|
||||||
@ -70,12 +72,15 @@ void GlobalAction::triggerHotKey(quint32 nativeKey, quint32 nativeMods)
|
|||||||
if (action && action->isEnabled())
|
if (action && action->isEnabled())
|
||||||
action->activate(QAction::Trigger);
|
action->activate(QAction::Trigger);
|
||||||
}
|
}
|
||||||
|
} // namespace service
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <xcb/xcb_event.h>
|
#include <xcb/xcb_event.h>
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
static bool error = false;
|
static bool error = false;
|
||||||
|
|
||||||
static int customHandler(Display *display, XErrorEvent *event)
|
static int customHandler(Display *display, XErrorEvent *event)
|
||||||
@ -169,6 +174,8 @@ quint32 GlobalAction::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
bool GlobalAction::registerHotKey(quint32 nativeKey, quint32 nativeMods)
|
bool GlobalAction::registerHotKey(quint32 nativeKey, quint32 nativeMods)
|
||||||
{
|
{
|
||||||
return RegisterHotKey(0, nativeMods ^ nativeKey, nativeMods, nativeKey);
|
return RegisterHotKey(0, nativeMods ^ nativeKey, nativeMods, nativeKey);
|
||||||
@ -319,6 +326,8 @@ quint32 GlobalAction::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
|||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
static bool isInited = false;
|
static bool isInited = false;
|
||||||
static QHash<QPair<quint32, quint32>, EventHotKeyRef> hotkeyRefs;
|
static QHash<QPair<quint32, quint32>, EventHotKeyRef> hotkeyRefs;
|
||||||
|
|
||||||
@ -479,3 +488,5 @@ quint32 GlobalAction::nativeModifiers(Qt::KeyboardModifiers modifiers)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // ifdef Q_OS_MAC
|
#endif // ifdef Q_OS_MAC
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <QAbstractNativeEventFilter>
|
#include <QAbstractNativeEventFilter>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
class GlobalAction : public QAbstractNativeEventFilter
|
class GlobalAction : public QAbstractNativeEventFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -27,3 +29,5 @@ private:
|
|||||||
|
|
||||||
friend struct ActionAdapter;
|
friend struct ActionAdapter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -15,6 +15,8 @@ static QString fileName(const QString &baseName)
|
|||||||
QDir::separator() + name + QLatin1String(".lock");
|
QDir::separator() + name + QLatin1String(".lock");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
SingleApplication::SingleApplication(const QString &baseName)
|
SingleApplication::SingleApplication(const QString &baseName)
|
||||||
: lockFile_(fileName(baseName))
|
: lockFile_(fileName(baseName))
|
||||||
{
|
{
|
||||||
@ -29,3 +31,5 @@ bool SingleApplication::isValid() const
|
|||||||
{
|
{
|
||||||
return lockFile_.isLocked();
|
return lockFile_.isLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QLockFile>
|
#include <QLockFile>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
class SingleApplication
|
class SingleApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -12,3 +14,5 @@ public:
|
|||||||
private:
|
private:
|
||||||
QLockFile lockFile_;
|
QLockFile lockFile_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
enum class Action { Save, Restore };
|
enum class Action { Save, Restore };
|
||||||
@ -116,3 +118,5 @@ void WidgetState::restore(QWidget *widget)
|
|||||||
SOFT_ASSERT(!widget->objectName().isEmpty(), return );
|
SOFT_ASSERT(!widget->objectName().isEmpty(), return );
|
||||||
apply(widget, Action::Restore);
|
apply(widget, Action::Restore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
class WidgetState : public QObject
|
class WidgetState : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -12,3 +14,5 @@ public:
|
|||||||
static void save(QWidget *widget);
|
static void save(QWidget *widget);
|
||||||
static void restore(QWidget *widget);
|
static void restore(QWidget *widget);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace service
|
||||||
|
@ -88,7 +88,7 @@ SettingsEditor::SettingsEditor(Manager &manager, update::Loader &updater)
|
|||||||
connect(ui->applyUpdates, &QPushButton::clicked, //
|
connect(ui->applyUpdates, &QPushButton::clicked, //
|
||||||
&updater_, &update::Loader::applyUserActions);
|
&updater_, &update::Loader::applyUserActions);
|
||||||
|
|
||||||
new WidgetState(this);
|
new service::WidgetState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsEditor::~SettingsEditor()
|
SettingsEditor::~SettingsEditor()
|
||||||
|
@ -89,7 +89,7 @@ Translator::Translator(Manager &manager, const Settings &settings)
|
|||||||
|
|
||||||
view_->setMinimumSize(200, 200);
|
view_->setMinimumSize(200, 200);
|
||||||
|
|
||||||
new WidgetState(this);
|
new service::WidgetState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Translator::~Translator() = default;
|
Translator::~Translator() = default;
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
using GlobalAction = service::GlobalAction;
|
||||||
|
|
||||||
TrayIcon::TrayIcon(Manager &manager, const Settings &settings)
|
TrayIcon::TrayIcon(Manager &manager, const Settings &settings)
|
||||||
: manager_(manager)
|
: manager_(manager)
|
||||||
, settings_(settings)
|
, settings_(settings)
|
||||||
|
Loading…
Reference in New Issue
Block a user