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