Apply tab to spaces filter to src folder
This commit is contained in:
parent
4902b8674c
commit
deea23f866
|
@ -21,5 +21,5 @@ if (WIN32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ((NOT ${CMAKE_SYSTEM_NAME} MATCHES "IRIX") AND (NOT ${DISABLE_TESTS}))
|
if ((NOT ${CMAKE_SYSTEM_NAME} MATCHES "IRIX") AND (NOT ${DISABLE_TESTS}))
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -19,6 +19,6 @@ add_subdirectory(synergys)
|
||||||
add_subdirectory(syntool)
|
add_subdirectory(syntool)
|
||||||
|
|
||||||
if (BUILD_SERVICE)
|
if (BUILD_SERVICE)
|
||||||
add_subdirectory(synergyd)
|
add_subdirectory(synergyd)
|
||||||
endif (BUILD_SERVICE)
|
endif (BUILD_SERVICE)
|
||||||
|
|
||||||
|
|
|
@ -15,57 +15,57 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
set(sources
|
set(sources
|
||||||
synergyc.cpp
|
synergyc.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
file(GLOB arch_headers "MSWindows*.h")
|
file(GLOB arch_headers "MSWindows*.h")
|
||||||
file(GLOB arch_sources "MSWindows*.cpp")
|
file(GLOB arch_sources "MSWindows*.cpp")
|
||||||
list(APPEND sources
|
list(APPEND sources
|
||||||
resource.h
|
resource.h
|
||||||
synergyc.ico
|
synergyc.ico
|
||||||
synergyc.rc
|
synergyc.rc
|
||||||
tb_error.ico
|
tb_error.ico
|
||||||
tb_idle.ico
|
tb_idle.ico
|
||||||
tb_run.ico
|
tb_run.ico
|
||||||
tb_wait.ico
|
tb_wait.ico
|
||||||
)
|
)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
file(GLOB arch_headers "OSX*.h")
|
file(GLOB arch_headers "OSX*.h")
|
||||||
file(GLOB arch_sources "OSX*.cpp")
|
file(GLOB arch_sources "OSX*.cpp")
|
||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
file(GLOB arch_headers "XWindows*.h")
|
file(GLOB arch_headers "XWindows*.h")
|
||||||
file(GLOB arch_sources "XWindows*.cpp")
|
file(GLOB arch_sources "XWindows*.cpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND sources ${arch_sources})
|
list(APPEND sources ${arch_sources})
|
||||||
list(APPEND headers ${arch_headers})
|
list(APPEND headers ${arch_headers})
|
||||||
|
|
||||||
if (SYNERGY_ADD_HEADERS)
|
if (SYNERGY_ADD_HEADERS)
|
||||||
list(APPEND sources ${headers})
|
list(APPEND sources ${headers})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../
|
../
|
||||||
../../lib/
|
../../lib/
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
include_directories(
|
include_directories(
|
||||||
../../..
|
../../..
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(synergyc ${sources})
|
add_executable(synergyc ${sources})
|
||||||
target_link_libraries(synergyc
|
target_link_libraries(synergyc
|
||||||
arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS})
|
arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS})
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
else ()
|
else ()
|
||||||
if (CONF_CPACK)
|
if (CONF_CPACK)
|
||||||
install(TARGETS
|
install(TARGETS
|
||||||
synergyc
|
synergyc
|
||||||
COMPONENT core
|
COMPONENT core
|
||||||
DESTINATION bin)
|
DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -35,342 +35,342 @@
|
||||||
|
|
||||||
const UINT MSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] =
|
const UINT MSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] =
|
||||||
{
|
{
|
||||||
IDI_TASKBAR_NOT_RUNNING,
|
IDI_TASKBAR_NOT_RUNNING,
|
||||||
IDI_TASKBAR_NOT_WORKING,
|
IDI_TASKBAR_NOT_WORKING,
|
||||||
IDI_TASKBAR_NOT_CONNECTED,
|
IDI_TASKBAR_NOT_CONNECTED,
|
||||||
IDI_TASKBAR_NOT_CONNECTED,
|
IDI_TASKBAR_NOT_CONNECTED,
|
||||||
IDI_TASKBAR_CONNECTED
|
IDI_TASKBAR_CONNECTED
|
||||||
};
|
};
|
||||||
|
|
||||||
MSWindowsClientTaskBarReceiver::MSWindowsClientTaskBarReceiver(
|
MSWindowsClientTaskBarReceiver::MSWindowsClientTaskBarReceiver(
|
||||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||||
ClientTaskBarReceiver(events),
|
ClientTaskBarReceiver(events),
|
||||||
m_appInstance(appInstance),
|
m_appInstance(appInstance),
|
||||||
m_window(NULL),
|
m_window(NULL),
|
||||||
m_logBuffer(logBuffer)
|
m_logBuffer(logBuffer)
|
||||||
{
|
{
|
||||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||||
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
||||||
}
|
}
|
||||||
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
||||||
|
|
||||||
// don't create the window yet. we'll create it on demand. this
|
// don't create the window yet. we'll create it on demand. this
|
||||||
// has the side benefit of being created in the thread used for
|
// has the side benefit of being created in the thread used for
|
||||||
// the task bar. that's good because it means the existence of
|
// the task bar. that's good because it means the existence of
|
||||||
// the window won't prevent changing the main thread's desktop.
|
// the window won't prevent changing the main thread's desktop.
|
||||||
|
|
||||||
// add ourself to the task bar
|
// add ourself to the task bar
|
||||||
ARCH->addReceiver(this);
|
ARCH->addReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
MSWindowsClientTaskBarReceiver::~MSWindowsClientTaskBarReceiver()
|
MSWindowsClientTaskBarReceiver::~MSWindowsClientTaskBarReceiver()
|
||||||
{
|
{
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::cleanup()
|
MSWindowsClientTaskBarReceiver::cleanup()
|
||||||
{
|
{
|
||||||
ARCH->removeReceiver(this);
|
ARCH->removeReceiver(this);
|
||||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||||
deleteIcon(m_icon[i]);
|
deleteIcon(m_icon[i]);
|
||||||
}
|
}
|
||||||
DestroyMenu(m_menu);
|
DestroyMenu(m_menu);
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::showStatus()
|
MSWindowsClientTaskBarReceiver::showStatus()
|
||||||
{
|
{
|
||||||
// create the window
|
// create the window
|
||||||
createWindow();
|
createWindow();
|
||||||
|
|
||||||
// lock self while getting status
|
// lock self while getting status
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
// get the current status
|
// get the current status
|
||||||
std::string status = getToolTip();
|
std::string status = getToolTip();
|
||||||
|
|
||||||
// done getting status
|
// done getting status
|
||||||
unlock();
|
unlock();
|
||||||
|
|
||||||
// update dialog
|
// update dialog
|
||||||
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
||||||
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
||||||
|
|
||||||
if (!IsWindowVisible(m_window)) {
|
if (!IsWindowVisible(m_window)) {
|
||||||
// position it by the mouse
|
// position it by the mouse
|
||||||
POINT cursorPos;
|
POINT cursorPos;
|
||||||
GetCursorPos(&cursorPos);
|
GetCursorPos(&cursorPos);
|
||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
GetWindowRect(m_window, &windowRect);
|
GetWindowRect(m_window, &windowRect);
|
||||||
int x = cursorPos.x;
|
int x = cursorPos.x;
|
||||||
int y = cursorPos.y;
|
int y = cursorPos.y;
|
||||||
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
||||||
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
||||||
int ww = windowRect.right - windowRect.left;
|
int ww = windowRect.right - windowRect.left;
|
||||||
int wh = windowRect.bottom - windowRect.top;
|
int wh = windowRect.bottom - windowRect.top;
|
||||||
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
||||||
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
||||||
if (fw < 1) {
|
if (fw < 1) {
|
||||||
fw = 1;
|
fw = 1;
|
||||||
}
|
}
|
||||||
if (fh < 1) {
|
if (fh < 1) {
|
||||||
fh = 1;
|
fh = 1;
|
||||||
}
|
}
|
||||||
if (x + ww - fw > sw) {
|
if (x + ww - fw > sw) {
|
||||||
x -= ww - fw;
|
x -= ww - fw;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
x -= fw;
|
x -= fw;
|
||||||
}
|
}
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
if (y + wh - fh > sh) {
|
if (y + wh - fh > sh) {
|
||||||
y -= wh - fh;
|
y -= wh - fh;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
y -= fh;
|
y -= fh;
|
||||||
}
|
}
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
||||||
SWP_SHOWWINDOW);
|
SWP_SHOWWINDOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::runMenu(int x, int y)
|
MSWindowsClientTaskBarReceiver::runMenu(int x, int y)
|
||||||
{
|
{
|
||||||
// do popup menu. we need a window to pass to TrackPopupMenu().
|
// do popup menu. we need a window to pass to TrackPopupMenu().
|
||||||
// the SetForegroundWindow() and SendMessage() calls around
|
// the SetForegroundWindow() and SendMessage() calls around
|
||||||
// TrackPopupMenu() are to get the menu to be dismissed when
|
// TrackPopupMenu() are to get the menu to be dismissed when
|
||||||
// another window gets activated and are just one of those
|
// another window gets activated and are just one of those
|
||||||
// win32 weirdnesses.
|
// win32 weirdnesses.
|
||||||
createWindow();
|
createWindow();
|
||||||
SetForegroundWindow(m_window);
|
SetForegroundWindow(m_window);
|
||||||
HMENU menu = GetSubMenu(m_menu, 0);
|
HMENU menu = GetSubMenu(m_menu, 0);
|
||||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||||
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||||
int n = TrackPopupMenu(menu,
|
int n = TrackPopupMenu(menu,
|
||||||
TPM_NONOTIFY |
|
TPM_NONOTIFY |
|
||||||
TPM_RETURNCMD |
|
TPM_RETURNCMD |
|
||||||
TPM_LEFTBUTTON |
|
TPM_LEFTBUTTON |
|
||||||
TPM_RIGHTBUTTON,
|
TPM_RIGHTBUTTON,
|
||||||
x, y, 0, m_window, NULL);
|
x, y, 0, m_window, NULL);
|
||||||
SendMessage(m_window, WM_NULL, 0, 0);
|
SendMessage(m_window, WM_NULL, 0, 0);
|
||||||
|
|
||||||
// perform the requested operation
|
// perform the requested operation
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case IDC_TASKBAR_STATUS:
|
case IDC_TASKBAR_STATUS:
|
||||||
showStatus();
|
showStatus();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG:
|
case IDC_TASKBAR_LOG:
|
||||||
copyLog();
|
copyLog();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_SHOW_LOG:
|
case IDC_TASKBAR_SHOW_LOG:
|
||||||
ARCH->showConsole(true);
|
ARCH->showConsole(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||||
CLOG->setFilter(kERROR);
|
CLOG->setFilter(kERROR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||||
CLOG->setFilter(kWARNING);
|
CLOG->setFilter(kWARNING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||||
CLOG->setFilter(kNOTE);
|
CLOG->setFilter(kNOTE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||||
CLOG->setFilter(kINFO);
|
CLOG->setFilter(kINFO);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||||
CLOG->setFilter(kDEBUG);
|
CLOG->setFilter(kDEBUG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||||
CLOG->setFilter(kDEBUG1);
|
CLOG->setFilter(kDEBUG1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||||
CLOG->setFilter(kDEBUG2);
|
CLOG->setFilter(kDEBUG2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_QUIT:
|
case IDC_TASKBAR_QUIT:
|
||||||
quit();
|
quit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::primaryAction()
|
MSWindowsClientTaskBarReceiver::primaryAction()
|
||||||
{
|
{
|
||||||
showStatus();
|
showStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
const IArchTaskBarReceiver::Icon
|
const IArchTaskBarReceiver::Icon
|
||||||
MSWindowsClientTaskBarReceiver::getIcon() const
|
MSWindowsClientTaskBarReceiver::getIcon() const
|
||||||
{
|
{
|
||||||
return static_cast<Icon>(m_icon[getStatus()]);
|
return static_cast<Icon>(m_icon[getStatus()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::copyLog() const
|
MSWindowsClientTaskBarReceiver::copyLog() const
|
||||||
{
|
{
|
||||||
if (m_logBuffer != NULL) {
|
if (m_logBuffer != NULL) {
|
||||||
// collect log buffer
|
// collect log buffer
|
||||||
String data;
|
String data;
|
||||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||||
index != m_logBuffer->end(); ++index) {
|
index != m_logBuffer->end(); ++index) {
|
||||||
data += *index;
|
data += *index;
|
||||||
data += "\n";
|
data += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy log to clipboard
|
// copy log to clipboard
|
||||||
if (!data.empty()) {
|
if (!data.empty()) {
|
||||||
MSWindowsClipboard clipboard(m_window);
|
MSWindowsClipboard clipboard(m_window);
|
||||||
clipboard.open(0);
|
clipboard.open(0);
|
||||||
clipboard.emptyUnowned();
|
clipboard.emptyUnowned();
|
||||||
clipboard.add(IClipboard::kText, data);
|
clipboard.add(IClipboard::kText, data);
|
||||||
clipboard.close();
|
clipboard.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::onStatusChanged()
|
MSWindowsClientTaskBarReceiver::onStatusChanged()
|
||||||
{
|
{
|
||||||
if (IsWindowVisible(m_window)) {
|
if (IsWindowVisible(m_window)) {
|
||||||
showStatus();
|
showStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HICON
|
HICON
|
||||||
MSWindowsClientTaskBarReceiver::loadIcon(UINT id)
|
MSWindowsClientTaskBarReceiver::loadIcon(UINT id)
|
||||||
{
|
{
|
||||||
HANDLE icon = LoadImage(m_appInstance,
|
HANDLE icon = LoadImage(m_appInstance,
|
||||||
MAKEINTRESOURCE(id),
|
MAKEINTRESOURCE(id),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
0, 0,
|
0, 0,
|
||||||
LR_DEFAULTCOLOR);
|
LR_DEFAULTCOLOR);
|
||||||
return static_cast<HICON>(icon);
|
return static_cast<HICON>(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::deleteIcon(HICON icon)
|
MSWindowsClientTaskBarReceiver::deleteIcon(HICON icon)
|
||||||
{
|
{
|
||||||
if (icon != NULL) {
|
if (icon != NULL) {
|
||||||
DestroyIcon(icon);
|
DestroyIcon(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::createWindow()
|
MSWindowsClientTaskBarReceiver::createWindow()
|
||||||
{
|
{
|
||||||
// ignore if already created
|
// ignore if already created
|
||||||
if (m_window != NULL) {
|
if (m_window != NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the status dialog
|
// get the status dialog
|
||||||
m_window = CreateDialogParam(m_appInstance,
|
m_window = CreateDialogParam(m_appInstance,
|
||||||
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
||||||
NULL,
|
NULL,
|
||||||
(DLGPROC)&MSWindowsClientTaskBarReceiver::staticDlgProc,
|
(DLGPROC)&MSWindowsClientTaskBarReceiver::staticDlgProc,
|
||||||
reinterpret_cast<LPARAM>(
|
reinterpret_cast<LPARAM>(
|
||||||
static_cast<void*>(this)));
|
static_cast<void*>(this)));
|
||||||
|
|
||||||
// window should appear on top of everything, including (especially)
|
// window should appear on top of everything, including (especially)
|
||||||
// the task bar.
|
// the task bar.
|
||||||
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
||||||
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||||
|
|
||||||
// tell the task bar about this dialog
|
// tell the task bar about this dialog
|
||||||
ArchTaskBarWindows::addDialog(m_window);
|
ArchTaskBarWindows::addDialog(m_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsClientTaskBarReceiver::destroyWindow()
|
MSWindowsClientTaskBarReceiver::destroyWindow()
|
||||||
{
|
{
|
||||||
if (m_window != NULL) {
|
if (m_window != NULL) {
|
||||||
ArchTaskBarWindows::removeDialog(m_window);
|
ArchTaskBarWindows::removeDialog(m_window);
|
||||||
DestroyWindow(m_window);
|
DestroyWindow(m_window);
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd,
|
MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM)
|
UINT msg, WPARAM wParam, LPARAM)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
// use default focus
|
// use default focus
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
// hide when another window is activated
|
// hide when another window is activated
|
||||||
if (LOWORD(wParam) == WA_INACTIVE) {
|
if (LOWORD(wParam) == WA_INACTIVE) {
|
||||||
ShowWindow(hwnd, SW_HIDE);
|
ShowWindow(hwnd, SW_HIDE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK
|
BOOL CALLBACK
|
||||||
MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd,
|
MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM lParam)
|
UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver*
|
// if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver*
|
||||||
// and put it in the extra window data then forward the call.
|
// and put it in the extra window data then forward the call.
|
||||||
MSWindowsClientTaskBarReceiver* self = NULL;
|
MSWindowsClientTaskBarReceiver* self = NULL;
|
||||||
if (msg == WM_INITDIALOG) {
|
if (msg == WM_INITDIALOG) {
|
||||||
self = static_cast<MSWindowsClientTaskBarReceiver*>(
|
self = static_cast<MSWindowsClientTaskBarReceiver*>(
|
||||||
reinterpret_cast<void*>(lParam));
|
reinterpret_cast<void*>(lParam));
|
||||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) lParam);
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) lParam);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// get the extra window data and forward the call
|
// get the extra window data and forward the call
|
||||||
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||||
if (data != 0) {
|
if (data != 0) {
|
||||||
self = (MSWindowsClientTaskBarReceiver*) data;
|
self = (MSWindowsClientTaskBarReceiver*) data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// forward the message
|
// forward the message
|
||||||
if (self != NULL) {
|
if (self != NULL) {
|
||||||
return self->dlgProc(hwnd, msg, wParam, lParam);
|
return self->dlgProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
ArchMiscWindows::setIcons(
|
ArchMiscWindows::setIcons(
|
||||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
32, 32, LR_SHARED),
|
32, 32, LR_SHARED),
|
||||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
16, 16, LR_SHARED));
|
16, 16, LR_SHARED));
|
||||||
|
|
||||||
return new MSWindowsClientTaskBarReceiver(
|
return new MSWindowsClientTaskBarReceiver(
|
||||||
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,40 +29,40 @@ class IEventQueue;
|
||||||
//! Implementation of ClientTaskBarReceiver for Microsoft Windows
|
//! Implementation of ClientTaskBarReceiver for Microsoft Windows
|
||||||
class MSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
class MSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
MSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
MSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~MSWindowsClientTaskBarReceiver();
|
virtual ~MSWindowsClientTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
virtual void showStatus();
|
virtual void showStatus();
|
||||||
virtual void runMenu(int x, int y);
|
virtual void runMenu(int x, int y);
|
||||||
virtual void primaryAction();
|
virtual void primaryAction();
|
||||||
virtual const Icon getIcon() const;
|
virtual const Icon getIcon() const;
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void copyLog() const;
|
void copyLog() const;
|
||||||
|
|
||||||
// ClientTaskBarReceiver overrides
|
// ClientTaskBarReceiver overrides
|
||||||
virtual void onStatusChanged();
|
virtual void onStatusChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HICON loadIcon(UINT);
|
HICON loadIcon(UINT);
|
||||||
void deleteIcon(HICON);
|
void deleteIcon(HICON);
|
||||||
void createWindow();
|
void createWindow();
|
||||||
void destroyWindow();
|
void destroyWindow();
|
||||||
|
|
||||||
BOOL dlgProc(HWND hwnd,
|
BOOL dlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
static BOOL CALLBACK
|
static BOOL CALLBACK
|
||||||
staticDlgProc(HWND hwnd,
|
staticDlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HINSTANCE m_appInstance;
|
HINSTANCE m_appInstance;
|
||||||
HWND m_window;
|
HWND m_window;
|
||||||
HMENU m_menu;
|
HMENU m_menu;
|
||||||
HICON m_icon[kMaxState];
|
HICON m_icon[kMaxState];
|
||||||
const BufferedLogOutputter* m_logBuffer;
|
const BufferedLogOutputter* m_logBuffer;
|
||||||
|
|
||||||
static const UINT s_stateToIconID[];
|
static const UINT s_stateToIconID[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,42 +28,42 @@ OSXClientTaskBarReceiver::OSXClientTaskBarReceiver(
|
||||||
IEventQueue* events) :
|
IEventQueue* events) :
|
||||||
ClientTaskBarReceiver(events)
|
ClientTaskBarReceiver(events)
|
||||||
{
|
{
|
||||||
// add ourself to the task bar
|
// add ourself to the task bar
|
||||||
ARCH->addReceiver(this);
|
ARCH->addReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSXClientTaskBarReceiver::~OSXClientTaskBarReceiver()
|
OSXClientTaskBarReceiver::~OSXClientTaskBarReceiver()
|
||||||
{
|
{
|
||||||
ARCH->removeReceiver(this);
|
ARCH->removeReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OSXClientTaskBarReceiver::showStatus()
|
OSXClientTaskBarReceiver::showStatus()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OSXClientTaskBarReceiver::runMenu(int, int)
|
OSXClientTaskBarReceiver::runMenu(int, int)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OSXClientTaskBarReceiver::primaryAction()
|
OSXClientTaskBarReceiver::primaryAction()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const IArchTaskBarReceiver::Icon
|
const IArchTaskBarReceiver::Icon
|
||||||
OSXClientTaskBarReceiver::getIcon() const
|
OSXClientTaskBarReceiver::getIcon() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
return new OSXClientTaskBarReceiver(logBuffer, events);
|
return new OSXClientTaskBarReceiver(logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@ class IEventQueue;
|
||||||
//! Implementation of ClientTaskBarReceiver for OS X
|
//! Implementation of ClientTaskBarReceiver for OS X
|
||||||
class OSXClientTaskBarReceiver : public ClientTaskBarReceiver {
|
class OSXClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
OSXClientTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
OSXClientTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~OSXClientTaskBarReceiver();
|
virtual ~OSXClientTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
virtual void showStatus();
|
virtual void showStatus();
|
||||||
virtual void runMenu(int x, int y);
|
virtual void runMenu(int x, int y);
|
||||||
virtual void primaryAction();
|
virtual void primaryAction();
|
||||||
virtual const Icon getIcon() const;
|
virtual const Icon getIcon() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,45 +24,45 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
CXWindowsClientTaskBarReceiver::CXWindowsClientTaskBarReceiver(
|
CXWindowsClientTaskBarReceiver::CXWindowsClientTaskBarReceiver(
|
||||||
const BufferedLogOutputter*,
|
const BufferedLogOutputter*,
|
||||||
IEventQueue* events) :
|
IEventQueue* events) :
|
||||||
ClientTaskBarReceiver(events)
|
ClientTaskBarReceiver(events)
|
||||||
{
|
{
|
||||||
// add ourself to the task bar
|
// add ourself to the task bar
|
||||||
ARCH->addReceiver(this);
|
ARCH->addReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CXWindowsClientTaskBarReceiver::~CXWindowsClientTaskBarReceiver()
|
CXWindowsClientTaskBarReceiver::~CXWindowsClientTaskBarReceiver()
|
||||||
{
|
{
|
||||||
ARCH->removeReceiver(this);
|
ARCH->removeReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsClientTaskBarReceiver::showStatus()
|
CXWindowsClientTaskBarReceiver::showStatus()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsClientTaskBarReceiver::runMenu(int, int)
|
CXWindowsClientTaskBarReceiver::runMenu(int, int)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsClientTaskBarReceiver::primaryAction()
|
CXWindowsClientTaskBarReceiver::primaryAction()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const IArchTaskBarReceiver::Icon
|
const IArchTaskBarReceiver::Icon
|
||||||
CXWindowsClientTaskBarReceiver::getIcon() const
|
CXWindowsClientTaskBarReceiver::getIcon() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
return new CXWindowsClientTaskBarReceiver(logBuffer, events);
|
return new CXWindowsClientTaskBarReceiver(logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,13 @@ class IEventQueue;
|
||||||
//! Implementation of ClientTaskBarReceiver for X Windows
|
//! Implementation of ClientTaskBarReceiver for X Windows
|
||||||
class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
CXWindowsClientTaskBarReceiver(
|
CXWindowsClientTaskBarReceiver(
|
||||||
const BufferedLogOutputter*, IEventQueue* events);
|
const BufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~CXWindowsClientTaskBarReceiver();
|
virtual ~CXWindowsClientTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
virtual void showStatus();
|
virtual void showStatus();
|
||||||
virtual void runMenu(int x, int y);
|
virtual void runMenu(int x, int y);
|
||||||
virtual void primaryAction();
|
virtual void primaryAction();
|
||||||
virtual const Icon getIcon() const;
|
virtual const Icon getIcon() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,16 +35,16 @@ int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
// record window instance for tray icon, etc
|
// record window instance for tray icon, etc
|
||||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Arch arch;
|
Arch arch;
|
||||||
arch.init();
|
arch.init();
|
||||||
|
|
||||||
Log log;
|
Log log;
|
||||||
EventQueue events;
|
EventQueue events;
|
||||||
|
|
||||||
ClientApp app(&events, createTaskBarReceiver);
|
ClientApp app(&events, createTaskBarReceiver);
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ file(GLOB headers "*.h")
|
||||||
file(GLOB sources "*.cpp")
|
file(GLOB sources "*.cpp")
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../
|
../
|
||||||
../../lib/
|
../../lib/
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
include_directories(
|
include_directories(
|
||||||
../../..
|
../../..
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
@ -35,11 +35,11 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(synergyd
|
target_link_libraries(synergyd
|
||||||
arch base common io ipc mt net platform synergy shared ${libs} ${OPENSSL_LIBS})
|
arch base common io ipc mt net platform synergy shared ${libs} ${OPENSSL_LIBS})
|
||||||
|
|
||||||
if (CONF_CPACK)
|
if (CONF_CPACK)
|
||||||
install(TARGETS
|
install(TARGETS
|
||||||
synergyd
|
synergyd
|
||||||
COMPONENT core
|
COMPONENT core
|
||||||
DESTINATION bin)
|
DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
int
|
int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
DaemonApp app;
|
DaemonApp app;
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif SYSAPI_WIN32
|
#elif SYSAPI_WIN32
|
||||||
|
@ -37,8 +37,8 @@ main(int argc, char** argv)
|
||||||
int WINAPI
|
int WINAPI
|
||||||
WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||||
{
|
{
|
||||||
DaemonApp app;
|
DaemonApp app;
|
||||||
return app.run(__argc, __argv);
|
return app.run(__argc, __argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,57 +15,57 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
set(sources
|
set(sources
|
||||||
synergys.cpp
|
synergys.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
file(GLOB arch_headers "MSWindows*.h")
|
file(GLOB arch_headers "MSWindows*.h")
|
||||||
file(GLOB arch_sources "MSWindows*.cpp")
|
file(GLOB arch_sources "MSWindows*.cpp")
|
||||||
list(APPEND sources
|
list(APPEND sources
|
||||||
resource.h
|
resource.h
|
||||||
synergys.ico
|
synergys.ico
|
||||||
synergys.rc
|
synergys.rc
|
||||||
tb_error.ico
|
tb_error.ico
|
||||||
tb_idle.ico
|
tb_idle.ico
|
||||||
tb_run.ico
|
tb_run.ico
|
||||||
tb_wait.ico
|
tb_wait.ico
|
||||||
)
|
)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
file(GLOB arch_headers "OSX*.h")
|
file(GLOB arch_headers "OSX*.h")
|
||||||
file(GLOB arch_sources "OSX*.cpp")
|
file(GLOB arch_sources "OSX*.cpp")
|
||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
file(GLOB arch_headers "XWindows*.h")
|
file(GLOB arch_headers "XWindows*.h")
|
||||||
file(GLOB arch_sources "XWindows*.cpp")
|
file(GLOB arch_sources "XWindows*.cpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND sources ${arch_sources})
|
list(APPEND sources ${arch_sources})
|
||||||
list(APPEND headers ${arch_headers})
|
list(APPEND headers ${arch_headers})
|
||||||
|
|
||||||
if (SYNERGY_ADD_HEADERS)
|
if (SYNERGY_ADD_HEADERS)
|
||||||
list(APPEND sources ${headers})
|
list(APPEND sources ${headers})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../
|
../
|
||||||
../../lib/
|
../../lib/
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
include_directories(
|
include_directories(
|
||||||
../../..
|
../../..
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(synergys ${sources})
|
add_executable(synergys ${sources})
|
||||||
target_link_libraries(synergys
|
target_link_libraries(synergys
|
||||||
arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS})
|
arch base client common io mt net ipc platform server synergy ${libs} ${OPENSSL_LIBS})
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
else ()
|
else ()
|
||||||
if (CONF_CPACK)
|
if (CONF_CPACK)
|
||||||
install(TARGETS
|
install(TARGETS
|
||||||
synergys
|
synergys
|
||||||
COMPONENT core
|
COMPONENT core
|
||||||
DESTINATION bin)
|
DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -36,373 +36,373 @@
|
||||||
|
|
||||||
const UINT MSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] =
|
const UINT MSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] =
|
||||||
{
|
{
|
||||||
IDI_TASKBAR_NOT_RUNNING,
|
IDI_TASKBAR_NOT_RUNNING,
|
||||||
IDI_TASKBAR_NOT_WORKING,
|
IDI_TASKBAR_NOT_WORKING,
|
||||||
IDI_TASKBAR_NOT_CONNECTED,
|
IDI_TASKBAR_NOT_CONNECTED,
|
||||||
IDI_TASKBAR_CONNECTED
|
IDI_TASKBAR_CONNECTED
|
||||||
};
|
};
|
||||||
|
|
||||||
MSWindowsServerTaskBarReceiver::MSWindowsServerTaskBarReceiver(
|
MSWindowsServerTaskBarReceiver::MSWindowsServerTaskBarReceiver(
|
||||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||||
ServerTaskBarReceiver(events),
|
ServerTaskBarReceiver(events),
|
||||||
m_events(events),
|
m_events(events),
|
||||||
m_appInstance(appInstance),
|
m_appInstance(appInstance),
|
||||||
m_window(NULL),
|
m_window(NULL),
|
||||||
m_logBuffer(logBuffer)
|
m_logBuffer(logBuffer)
|
||||||
{
|
{
|
||||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||||
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
||||||
}
|
}
|
||||||
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
||||||
|
|
||||||
// don't create the window yet. we'll create it on demand. this
|
// don't create the window yet. we'll create it on demand. this
|
||||||
// has the side benefit of being created in the thread used for
|
// has the side benefit of being created in the thread used for
|
||||||
// the task bar. that's good because it means the existence of
|
// the task bar. that's good because it means the existence of
|
||||||
// the window won't prevent changing the main thread's desktop.
|
// the window won't prevent changing the main thread's desktop.
|
||||||
|
|
||||||
// add ourself to the task bar
|
// add ourself to the task bar
|
||||||
ARCH->addReceiver(this);
|
ARCH->addReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::cleanup()
|
MSWindowsServerTaskBarReceiver::cleanup()
|
||||||
{
|
{
|
||||||
ARCH->removeReceiver(this);
|
ARCH->removeReceiver(this);
|
||||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||||
deleteIcon(m_icon[i]);
|
deleteIcon(m_icon[i]);
|
||||||
}
|
}
|
||||||
DestroyMenu(m_menu);
|
DestroyMenu(m_menu);
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
MSWindowsServerTaskBarReceiver::~MSWindowsServerTaskBarReceiver()
|
MSWindowsServerTaskBarReceiver::~MSWindowsServerTaskBarReceiver()
|
||||||
{
|
{
|
||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::showStatus()
|
MSWindowsServerTaskBarReceiver::showStatus()
|
||||||
{
|
{
|
||||||
// create the window
|
// create the window
|
||||||
createWindow();
|
createWindow();
|
||||||
|
|
||||||
// lock self while getting status
|
// lock self while getting status
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
// get the current status
|
// get the current status
|
||||||
std::string status = getToolTip();
|
std::string status = getToolTip();
|
||||||
|
|
||||||
// get the connect clients, if any
|
// get the connect clients, if any
|
||||||
const Clients& clients = getClients();
|
const Clients& clients = getClients();
|
||||||
|
|
||||||
// done getting status
|
// done getting status
|
||||||
unlock();
|
unlock();
|
||||||
|
|
||||||
// update dialog
|
// update dialog
|
||||||
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
||||||
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
||||||
child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS);
|
child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS);
|
||||||
SendMessage(child, LB_RESETCONTENT, 0, 0);
|
SendMessage(child, LB_RESETCONTENT, 0, 0);
|
||||||
for (Clients::const_iterator index = clients.begin();
|
for (Clients::const_iterator index = clients.begin();
|
||||||
index != clients.end(); ) {
|
index != clients.end(); ) {
|
||||||
const char* client = index->c_str();
|
const char* client = index->c_str();
|
||||||
if (++index == clients.end()) {
|
if (++index == clients.end()) {
|
||||||
SendMessage(child, LB_ADDSTRING, 0, (LPARAM)client);
|
SendMessage(child, LB_ADDSTRING, 0, (LPARAM)client);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SendMessage(child, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)client);
|
SendMessage(child, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsWindowVisible(m_window)) {
|
if (!IsWindowVisible(m_window)) {
|
||||||
// position it by the mouse
|
// position it by the mouse
|
||||||
POINT cursorPos;
|
POINT cursorPos;
|
||||||
GetCursorPos(&cursorPos);
|
GetCursorPos(&cursorPos);
|
||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
GetWindowRect(m_window, &windowRect);
|
GetWindowRect(m_window, &windowRect);
|
||||||
int x = cursorPos.x;
|
int x = cursorPos.x;
|
||||||
int y = cursorPos.y;
|
int y = cursorPos.y;
|
||||||
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
||||||
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
||||||
int ww = windowRect.right - windowRect.left;
|
int ww = windowRect.right - windowRect.left;
|
||||||
int wh = windowRect.bottom - windowRect.top;
|
int wh = windowRect.bottom - windowRect.top;
|
||||||
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
||||||
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
||||||
if (fw < 1) {
|
if (fw < 1) {
|
||||||
fw = 1;
|
fw = 1;
|
||||||
}
|
}
|
||||||
if (fh < 1) {
|
if (fh < 1) {
|
||||||
fh = 1;
|
fh = 1;
|
||||||
}
|
}
|
||||||
if (x + ww - fw > sw) {
|
if (x + ww - fw > sw) {
|
||||||
x -= ww - fw;
|
x -= ww - fw;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
x -= fw;
|
x -= fw;
|
||||||
}
|
}
|
||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
if (y + wh - fh > sh) {
|
if (y + wh - fh > sh) {
|
||||||
y -= wh - fh;
|
y -= wh - fh;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
y -= fh;
|
y -= fh;
|
||||||
}
|
}
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
||||||
SWP_SHOWWINDOW);
|
SWP_SHOWWINDOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
MSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
||||||
{
|
{
|
||||||
// do popup menu. we need a window to pass to TrackPopupMenu().
|
// do popup menu. we need a window to pass to TrackPopupMenu().
|
||||||
// the SetForegroundWindow() and SendMessage() calls around
|
// the SetForegroundWindow() and SendMessage() calls around
|
||||||
// TrackPopupMenu() are to get the menu to be dismissed when
|
// TrackPopupMenu() are to get the menu to be dismissed when
|
||||||
// another window gets activated and are just one of those
|
// another window gets activated and are just one of those
|
||||||
// win32 weirdnesses.
|
// win32 weirdnesses.
|
||||||
createWindow();
|
createWindow();
|
||||||
SetForegroundWindow(m_window);
|
SetForegroundWindow(m_window);
|
||||||
HMENU menu = GetSubMenu(m_menu, 0);
|
HMENU menu = GetSubMenu(m_menu, 0);
|
||||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||||
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||||
int n = TrackPopupMenu(menu,
|
int n = TrackPopupMenu(menu,
|
||||||
TPM_NONOTIFY |
|
TPM_NONOTIFY |
|
||||||
TPM_RETURNCMD |
|
TPM_RETURNCMD |
|
||||||
TPM_LEFTBUTTON |
|
TPM_LEFTBUTTON |
|
||||||
TPM_RIGHTBUTTON,
|
TPM_RIGHTBUTTON,
|
||||||
x, y, 0, m_window, NULL);
|
x, y, 0, m_window, NULL);
|
||||||
SendMessage(m_window, WM_NULL, 0, 0);
|
SendMessage(m_window, WM_NULL, 0, 0);
|
||||||
|
|
||||||
// perform the requested operation
|
// perform the requested operation
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case IDC_TASKBAR_STATUS:
|
case IDC_TASKBAR_STATUS:
|
||||||
showStatus();
|
showStatus();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG:
|
case IDC_TASKBAR_LOG:
|
||||||
copyLog();
|
copyLog();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_SHOW_LOG:
|
case IDC_TASKBAR_SHOW_LOG:
|
||||||
ARCH->showConsole(true);
|
ARCH->showConsole(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_RELOAD_CONFIG:
|
case IDC_RELOAD_CONFIG:
|
||||||
m_events->addEvent(Event(m_events->forServerApp().reloadConfig(),
|
m_events->addEvent(Event(m_events->forServerApp().reloadConfig(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_FORCE_RECONNECT:
|
case IDC_FORCE_RECONNECT:
|
||||||
m_events->addEvent(Event(m_events->forServerApp().forceReconnect(),
|
m_events->addEvent(Event(m_events->forServerApp().forceReconnect(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_SYNERGY_RESETSERVER:
|
case ID_SYNERGY_RESETSERVER:
|
||||||
m_events->addEvent(Event(m_events->forServerApp().resetServer(),
|
m_events->addEvent(Event(m_events->forServerApp().resetServer(),
|
||||||
m_events->getSystemTarget()));
|
m_events->getSystemTarget()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||||
CLOG->setFilter(kERROR);
|
CLOG->setFilter(kERROR);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||||
CLOG->setFilter(kWARNING);
|
CLOG->setFilter(kWARNING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||||
CLOG->setFilter(kNOTE);
|
CLOG->setFilter(kNOTE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||||
CLOG->setFilter(kINFO);
|
CLOG->setFilter(kINFO);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||||
CLOG->setFilter(kDEBUG);
|
CLOG->setFilter(kDEBUG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||||
CLOG->setFilter(kDEBUG1);
|
CLOG->setFilter(kDEBUG1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||||
CLOG->setFilter(kDEBUG2);
|
CLOG->setFilter(kDEBUG2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDC_TASKBAR_QUIT:
|
case IDC_TASKBAR_QUIT:
|
||||||
quit();
|
quit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::primaryAction()
|
MSWindowsServerTaskBarReceiver::primaryAction()
|
||||||
{
|
{
|
||||||
showStatus();
|
showStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
const IArchTaskBarReceiver::Icon
|
const IArchTaskBarReceiver::Icon
|
||||||
MSWindowsServerTaskBarReceiver::getIcon() const
|
MSWindowsServerTaskBarReceiver::getIcon() const
|
||||||
{
|
{
|
||||||
return static_cast<Icon>(m_icon[getStatus()]);
|
return static_cast<Icon>(m_icon[getStatus()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::copyLog() const
|
MSWindowsServerTaskBarReceiver::copyLog() const
|
||||||
{
|
{
|
||||||
if (m_logBuffer != NULL) {
|
if (m_logBuffer != NULL) {
|
||||||
// collect log buffer
|
// collect log buffer
|
||||||
String data;
|
String data;
|
||||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||||
index != m_logBuffer->end(); ++index) {
|
index != m_logBuffer->end(); ++index) {
|
||||||
data += *index;
|
data += *index;
|
||||||
data += "\n";
|
data += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy log to clipboard
|
// copy log to clipboard
|
||||||
if (!data.empty()) {
|
if (!data.empty()) {
|
||||||
MSWindowsClipboard clipboard(m_window);
|
MSWindowsClipboard clipboard(m_window);
|
||||||
clipboard.open(0);
|
clipboard.open(0);
|
||||||
clipboard.emptyUnowned();
|
clipboard.emptyUnowned();
|
||||||
clipboard.add(IClipboard::kText, data);
|
clipboard.add(IClipboard::kText, data);
|
||||||
clipboard.close();
|
clipboard.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::onStatusChanged()
|
MSWindowsServerTaskBarReceiver::onStatusChanged()
|
||||||
{
|
{
|
||||||
if (IsWindowVisible(m_window)) {
|
if (IsWindowVisible(m_window)) {
|
||||||
showStatus();
|
showStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HICON
|
HICON
|
||||||
MSWindowsServerTaskBarReceiver::loadIcon(UINT id)
|
MSWindowsServerTaskBarReceiver::loadIcon(UINT id)
|
||||||
{
|
{
|
||||||
HANDLE icon = LoadImage(m_appInstance,
|
HANDLE icon = LoadImage(m_appInstance,
|
||||||
MAKEINTRESOURCE(id),
|
MAKEINTRESOURCE(id),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
0, 0,
|
0, 0,
|
||||||
LR_DEFAULTCOLOR);
|
LR_DEFAULTCOLOR);
|
||||||
return static_cast<HICON>(icon);
|
return static_cast<HICON>(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::deleteIcon(HICON icon)
|
MSWindowsServerTaskBarReceiver::deleteIcon(HICON icon)
|
||||||
{
|
{
|
||||||
if (icon != NULL) {
|
if (icon != NULL) {
|
||||||
DestroyIcon(icon);
|
DestroyIcon(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::createWindow()
|
MSWindowsServerTaskBarReceiver::createWindow()
|
||||||
{
|
{
|
||||||
// ignore if already created
|
// ignore if already created
|
||||||
if (m_window != NULL) {
|
if (m_window != NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the status dialog
|
// get the status dialog
|
||||||
m_window = CreateDialogParam(m_appInstance,
|
m_window = CreateDialogParam(m_appInstance,
|
||||||
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
||||||
NULL,
|
NULL,
|
||||||
(DLGPROC)&MSWindowsServerTaskBarReceiver::staticDlgProc,
|
(DLGPROC)&MSWindowsServerTaskBarReceiver::staticDlgProc,
|
||||||
reinterpret_cast<LPARAM>(
|
reinterpret_cast<LPARAM>(
|
||||||
static_cast<void*>(this)));
|
static_cast<void*>(this)));
|
||||||
|
|
||||||
// window should appear on top of everything, including (especially)
|
// window should appear on top of everything, including (especially)
|
||||||
// the task bar.
|
// the task bar.
|
||||||
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
||||||
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||||
|
|
||||||
// tell the task bar about this dialog
|
// tell the task bar about this dialog
|
||||||
ArchTaskBarWindows::addDialog(m_window);
|
ArchTaskBarWindows::addDialog(m_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MSWindowsServerTaskBarReceiver::destroyWindow()
|
MSWindowsServerTaskBarReceiver::destroyWindow()
|
||||||
{
|
{
|
||||||
if (m_window != NULL) {
|
if (m_window != NULL) {
|
||||||
ArchTaskBarWindows::removeDialog(m_window);
|
ArchTaskBarWindows::removeDialog(m_window);
|
||||||
DestroyWindow(m_window);
|
DestroyWindow(m_window);
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd,
|
MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM)
|
UINT msg, WPARAM wParam, LPARAM)
|
||||||
{
|
{
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
// use default focus
|
// use default focus
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
// hide when another window is activated
|
// hide when another window is activated
|
||||||
if (LOWORD(wParam) == WA_INACTIVE) {
|
if (LOWORD(wParam) == WA_INACTIVE) {
|
||||||
ShowWindow(hwnd, SW_HIDE);
|
ShowWindow(hwnd, SW_HIDE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK
|
BOOL CALLBACK
|
||||||
MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd,
|
MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM lParam)
|
UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
// if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver*
|
// if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver*
|
||||||
// and put it in the extra window data then forward the call.
|
// and put it in the extra window data then forward the call.
|
||||||
MSWindowsServerTaskBarReceiver* self = NULL;
|
MSWindowsServerTaskBarReceiver* self = NULL;
|
||||||
if (msg == WM_INITDIALOG) {
|
if (msg == WM_INITDIALOG) {
|
||||||
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
||||||
reinterpret_cast<void*>(lParam));
|
reinterpret_cast<void*>(lParam));
|
||||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// get the extra window data and forward the call
|
// get the extra window data and forward the call
|
||||||
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||||
if (data != 0) {
|
if (data != 0) {
|
||||||
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
||||||
reinterpret_cast<void*>(data));
|
reinterpret_cast<void*>(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// forward the message
|
// forward the message
|
||||||
if (self != NULL) {
|
if (self != NULL) {
|
||||||
return self->dlgProc(hwnd, msg, wParam, lParam);
|
return self->dlgProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
ArchMiscWindows::setIcons(
|
ArchMiscWindows::setIcons(
|
||||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
32, 32, LR_SHARED),
|
32, 32, LR_SHARED),
|
||||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
16, 16, LR_SHARED));
|
16, 16, LR_SHARED));
|
||||||
|
|
||||||
return new MSWindowsServerTaskBarReceiver(
|
return new MSWindowsServerTaskBarReceiver(
|
||||||
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,41 +29,41 @@ class IEventQueue;
|
||||||
//! Implementation of ServerTaskBarReceiver for Microsoft Windows
|
//! Implementation of ServerTaskBarReceiver for Microsoft Windows
|
||||||
class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~MSWindowsServerTaskBarReceiver();
|
virtual ~MSWindowsServerTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
virtual void showStatus();
|
virtual void showStatus();
|
||||||
virtual void runMenu(int x, int y);
|
virtual void runMenu(int x, int y);
|
||||||
virtual void primaryAction();
|
virtual void primaryAction();
|
||||||
virtual const Icon getIcon() const;
|
virtual const Icon getIcon() const;
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void copyLog() const;
|
void copyLog() const;
|
||||||
|
|
||||||
// ServerTaskBarReceiver overrides
|
// ServerTaskBarReceiver overrides
|
||||||
virtual void onStatusChanged();
|
virtual void onStatusChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HICON loadIcon(UINT);
|
HICON loadIcon(UINT);
|
||||||
void deleteIcon(HICON);
|
void deleteIcon(HICON);
|
||||||
void createWindow();
|
void createWindow();
|
||||||
void destroyWindow();
|
void destroyWindow();
|
||||||
|
|
||||||
BOOL dlgProc(HWND hwnd,
|
BOOL dlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
static BOOL CALLBACK
|
static BOOL CALLBACK
|
||||||
staticDlgProc(HWND hwnd,
|
staticDlgProc(HWND hwnd,
|
||||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HINSTANCE m_appInstance;
|
HINSTANCE m_appInstance;
|
||||||
HWND m_window;
|
HWND m_window;
|
||||||
HMENU m_menu;
|
HMENU m_menu;
|
||||||
HICON m_icon[kMaxState];
|
HICON m_icon[kMaxState];
|
||||||
const BufferedLogOutputter* m_logBuffer;
|
const BufferedLogOutputter* m_logBuffer;
|
||||||
IEventQueue* m_events;
|
IEventQueue* m_events;
|
||||||
|
|
||||||
static const UINT s_stateToIconID[];
|
static const UINT s_stateToIconID[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,44 +24,44 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(
|
OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(
|
||||||
const BufferedLogOutputter*, IEventQueue* events) :
|
const BufferedLogOutputter*, IEventQueue* events) :
|
||||||
ServerTaskBarReceiver(events)
|
ServerTaskBarReceiver(events)
|
||||||
{
|
{
|
||||||
// add ourself to the task bar
|
// add ourself to the task bar
|
||||||
ARCH->addReceiver(this);
|
ARCH->addReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSXServerTaskBarReceiver::~OSXServerTaskBarReceiver()
|
OSXServerTaskBarReceiver::~OSXServerTaskBarReceiver()
|
||||||
{
|
{
|
||||||
ARCH->removeReceiver(this);
|
ARCH->removeReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OSXServerTaskBarReceiver::showStatus()
|
OSXServerTaskBarReceiver::showStatus()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OSXServerTaskBarReceiver::runMenu(int, int)
|
OSXServerTaskBarReceiver::runMenu(int, int)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
OSXServerTaskBarReceiver::primaryAction()
|
OSXServerTaskBarReceiver::primaryAction()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const IArchTaskBarReceiver::Icon
|
const IArchTaskBarReceiver::Icon
|
||||||
OSXServerTaskBarReceiver::getIcon() const
|
OSXServerTaskBarReceiver::getIcon() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
return new OSXServerTaskBarReceiver(logBuffer, events);
|
return new OSXServerTaskBarReceiver(logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ class BufferedLogOutputter;
|
||||||
//! Implementation of ServerTaskBarReceiver for OS X
|
//! Implementation of ServerTaskBarReceiver for OS X
|
||||||
class OSXServerTaskBarReceiver : public ServerTaskBarReceiver {
|
class OSXServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
OSXServerTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
OSXServerTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~OSXServerTaskBarReceiver();
|
virtual ~OSXServerTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
virtual void showStatus();
|
virtual void showStatus();
|
||||||
virtual void runMenu(int x, int y);
|
virtual void runMenu(int x, int y);
|
||||||
virtual void primaryAction();
|
virtual void primaryAction();
|
||||||
virtual const Icon getIcon() const;
|
virtual const Icon getIcon() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,44 +24,44 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
CXWindowsServerTaskBarReceiver::CXWindowsServerTaskBarReceiver(
|
CXWindowsServerTaskBarReceiver::CXWindowsServerTaskBarReceiver(
|
||||||
const BufferedLogOutputter*, IEventQueue* events) :
|
const BufferedLogOutputter*, IEventQueue* events) :
|
||||||
ServerTaskBarReceiver(events)
|
ServerTaskBarReceiver(events)
|
||||||
{
|
{
|
||||||
// add ourself to the task bar
|
// add ourself to the task bar
|
||||||
ARCH->addReceiver(this);
|
ARCH->addReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CXWindowsServerTaskBarReceiver::~CXWindowsServerTaskBarReceiver()
|
CXWindowsServerTaskBarReceiver::~CXWindowsServerTaskBarReceiver()
|
||||||
{
|
{
|
||||||
ARCH->removeReceiver(this);
|
ARCH->removeReceiver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsServerTaskBarReceiver::showStatus()
|
CXWindowsServerTaskBarReceiver::showStatus()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsServerTaskBarReceiver::runMenu(int, int)
|
CXWindowsServerTaskBarReceiver::runMenu(int, int)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CXWindowsServerTaskBarReceiver::primaryAction()
|
CXWindowsServerTaskBarReceiver::primaryAction()
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
const IArchTaskBarReceiver::Icon
|
const IArchTaskBarReceiver::Icon
|
||||||
CXWindowsServerTaskBarReceiver::getIcon() const
|
CXWindowsServerTaskBarReceiver::getIcon() const
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IArchTaskBarReceiver*
|
IArchTaskBarReceiver*
|
||||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||||
{
|
{
|
||||||
return new CXWindowsServerTaskBarReceiver(logBuffer, events);
|
return new CXWindowsServerTaskBarReceiver(logBuffer, events);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,13 @@ class IEventQueue;
|
||||||
//! Implementation of ServerTaskBarReceiver for X Windows
|
//! Implementation of ServerTaskBarReceiver for X Windows
|
||||||
class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||||
public:
|
public:
|
||||||
CXWindowsServerTaskBarReceiver(
|
CXWindowsServerTaskBarReceiver(
|
||||||
const BufferedLogOutputter*, IEventQueue* events);
|
const BufferedLogOutputter*, IEventQueue* events);
|
||||||
virtual ~CXWindowsServerTaskBarReceiver();
|
virtual ~CXWindowsServerTaskBarReceiver();
|
||||||
|
|
||||||
// IArchTaskBarReceiver overrides
|
// IArchTaskBarReceiver overrides
|
||||||
virtual void showStatus();
|
virtual void showStatus();
|
||||||
virtual void runMenu(int x, int y);
|
virtual void runMenu(int x, int y);
|
||||||
virtual void primaryAction();
|
virtual void primaryAction();
|
||||||
virtual const Icon getIcon() const;
|
virtual const Icon getIcon() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,16 +35,16 @@ int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
// record window instance for tray icon, etc
|
// record window instance for tray icon, etc
|
||||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Arch arch;
|
Arch arch;
|
||||||
arch.init();
|
arch.init();
|
||||||
|
|
||||||
Log log;
|
Log log;
|
||||||
EventQueue events;
|
EventQueue events;
|
||||||
|
|
||||||
ServerApp app(&events, createTaskBarReceiver);
|
ServerApp app(&events, createTaskBarReceiver);
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,26 +17,26 @@ file(GLOB headers "*.h")
|
||||||
file(GLOB sources "*.cpp")
|
file(GLOB sources "*.cpp")
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../
|
../
|
||||||
../../lib/
|
../../lib/
|
||||||
)
|
)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
include_directories(
|
include_directories(
|
||||||
../../..
|
../../..
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(syntool ${sources})
|
add_executable(syntool ${sources})
|
||||||
target_link_libraries(syntool
|
target_link_libraries(syntool
|
||||||
synergy arch base client common io ipc mt net platform server ${libs} ${OPENSSL_LIBS})
|
synergy arch base client common io ipc mt net platform server ${libs} ${OPENSSL_LIBS})
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
else ()
|
else ()
|
||||||
if (CONF_CPACK)
|
if (CONF_CPACK)
|
||||||
install(TARGETS
|
install(TARGETS
|
||||||
syntool
|
syntool
|
||||||
COMPONENT core
|
COMPONENT core
|
||||||
DESTINATION bin)
|
DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -22,10 +22,10 @@ int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
// record window instance for tray icon, etc
|
// record window instance for tray icon, etc
|
||||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ToolApp app;
|
ToolApp app;
|
||||||
return app.run(argc, argv);
|
return app.run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,21 +10,21 @@ file (GLOB LEGACY_GUI_SOURCE_FILES src/*.cpp src/*.h)
|
||||||
file (GLOB LEGACY_GUI_UI_FILES res/*.ui)
|
file (GLOB LEGACY_GUI_UI_FILES res/*.ui)
|
||||||
|
|
||||||
add_executable (synergyx
|
add_executable (synergyx
|
||||||
${LEGACY_GUI_SOURCE_FILES}
|
${LEGACY_GUI_SOURCE_FILES}
|
||||||
${LEGACY_GUI_UI_FILES}
|
${LEGACY_GUI_UI_FILES}
|
||||||
res/Synergy.qrc
|
res/Synergy.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories (../lib/shared ./src)
|
include_directories (../lib/shared ./src)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
include_directories ($ENV{BONJOUR_SDK_HOME}/Include)
|
include_directories ($ENV{BONJOUR_SDK_HOME}/Include)
|
||||||
find_library (DNSSD_LIB dnssd.lib
|
find_library (DNSSD_LIB dnssd.lib
|
||||||
HINTS ENV BONJOUR_SDK_HOME
|
HINTS ENV BONJOUR_SDK_HOME
|
||||||
PATH_SUFFIXES "Lib/x64")
|
PATH_SUFFIXES "Lib/x64")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
qt5_use_modules (synergyx Widgets Network)
|
qt5_use_modules (synergyx Widgets Network)
|
||||||
target_link_libraries (synergyx ${DNSSD_LIB} shared)
|
target_link_libraries (synergyx ${DNSSD_LIB} shared)
|
||||||
set_target_properties (synergyx PROPERTIES
|
set_target_properties (synergyx PROPERTIES
|
||||||
LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
|
LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
|
||||||
|
|
|
@ -30,13 +30,13 @@ class QString;
|
||||||
|
|
||||||
class AboutDialog : public QDialog, public Ui::AboutDialogBase
|
class AboutDialog : public QDialog, public Ui::AboutDialogBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AboutDialog(QWidget* parent, const QString& synergyApp = QString());
|
AboutDialog(QWidget* parent, const QString& synergyApp = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VersionChecker m_versionChecker;
|
VersionChecker m_versionChecker;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,128 +23,128 @@
|
||||||
|
|
||||||
const char* Action::m_ActionTypeNames[] =
|
const char* Action::m_ActionTypeNames[] =
|
||||||
{
|
{
|
||||||
"keyDown", "keyUp", "keystroke",
|
"keyDown", "keyUp", "keystroke",
|
||||||
"switchToScreen", "switchInDirection", "lockCursorToScreen",
|
"switchToScreen", "switchInDirection", "lockCursorToScreen",
|
||||||
"mouseDown", "mouseUp", "mousebutton"
|
"mouseDown", "mouseUp", "mousebutton"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* Action::m_SwitchDirectionNames[] = { "left", "right", "up", "down" };
|
const char* Action::m_SwitchDirectionNames[] = { "left", "right", "up", "down" };
|
||||||
const char* Action::m_LockCursorModeNames[] = { "toggle", "on", "off" };
|
const char* Action::m_LockCursorModeNames[] = { "toggle", "on", "off" };
|
||||||
|
|
||||||
Action::Action() :
|
Action::Action() :
|
||||||
m_KeySequence(),
|
m_KeySequence(),
|
||||||
m_Type(keystroke),
|
m_Type(keystroke),
|
||||||
m_TypeScreenNames(),
|
m_TypeScreenNames(),
|
||||||
m_SwitchScreenName(),
|
m_SwitchScreenName(),
|
||||||
m_SwitchDirection(switchLeft),
|
m_SwitchDirection(switchLeft),
|
||||||
m_LockCursorMode(lockCursorToggle),
|
m_LockCursorMode(lockCursorToggle),
|
||||||
m_ActiveOnRelease(false),
|
m_ActiveOnRelease(false),
|
||||||
m_HasScreens(false)
|
m_HasScreens(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Action::text() const
|
QString Action::text() const
|
||||||
{
|
{
|
||||||
QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type() ]) + "(";
|
QString text = QString(m_ActionTypeNames[keySequence().isMouseButton() ? type() + 6 : type() ]) + "(";
|
||||||
|
|
||||||
switch (type())
|
switch (type())
|
||||||
{
|
{
|
||||||
case keyDown:
|
case keyDown:
|
||||||
case keyUp:
|
case keyUp:
|
||||||
case keystroke:
|
case keystroke:
|
||||||
{
|
{
|
||||||
text += keySequence().toString();
|
text += keySequence().toString();
|
||||||
|
|
||||||
if (!keySequence().isMouseButton())
|
if (!keySequence().isMouseButton())
|
||||||
{
|
{
|
||||||
const QStringList& screens = typeScreenNames();
|
const QStringList& screens = typeScreenNames();
|
||||||
if (haveScreens() && !screens.isEmpty())
|
if (haveScreens() && !screens.isEmpty())
|
||||||
{
|
{
|
||||||
text += ",";
|
text += ",";
|
||||||
|
|
||||||
for (int i = 0; i < screens.size(); i++)
|
for (int i = 0; i < screens.size(); i++)
|
||||||
{
|
{
|
||||||
text += screens[i];
|
text += screens[i];
|
||||||
if (i != screens.size() - 1)
|
if (i != screens.size() - 1)
|
||||||
text += ":";
|
text += ":";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
text += ",*";
|
text += ",*";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case switchToScreen:
|
case switchToScreen:
|
||||||
text += switchScreenName();
|
text += switchScreenName();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case switchInDirection:
|
case switchInDirection:
|
||||||
text += m_SwitchDirectionNames[m_SwitchDirection];
|
text += m_SwitchDirectionNames[m_SwitchDirection];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lockCursorToScreen:
|
case lockCursorToScreen:
|
||||||
text += m_LockCursorModeNames[m_LockCursorMode];
|
text += m_LockCursorModeNames[m_LockCursorMode];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(0);
|
Q_ASSERT(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
text += ")";
|
text += ")";
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::loadSettings(QSettings& settings)
|
void Action::loadSettings(QSettings& settings)
|
||||||
{
|
{
|
||||||
keySequence().loadSettings(settings);
|
keySequence().loadSettings(settings);
|
||||||
setType(settings.value("type", keyDown).toInt());
|
setType(settings.value("type", keyDown).toInt());
|
||||||
|
|
||||||
typeScreenNames().clear();
|
typeScreenNames().clear();
|
||||||
int numTypeScreens = settings.beginReadArray("typeScreenNames");
|
int numTypeScreens = settings.beginReadArray("typeScreenNames");
|
||||||
for (int i = 0; i < numTypeScreens; i++)
|
for (int i = 0; i < numTypeScreens; i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
typeScreenNames().append(settings.value("typeScreenName").toString());
|
typeScreenNames().append(settings.value("typeScreenName").toString());
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
setSwitchScreenName(settings.value("switchScreenName").toString());
|
setSwitchScreenName(settings.value("switchScreenName").toString());
|
||||||
setSwitchDirection(settings.value("switchInDirection", switchLeft).toInt());
|
setSwitchDirection(settings.value("switchInDirection", switchLeft).toInt());
|
||||||
setLockCursorMode(settings.value("lockCursorToScreen", lockCursorToggle).toInt());
|
setLockCursorMode(settings.value("lockCursorToScreen", lockCursorToggle).toInt());
|
||||||
setActiveOnRelease(settings.value("activeOnRelease", false).toBool());
|
setActiveOnRelease(settings.value("activeOnRelease", false).toBool());
|
||||||
setHaveScreens(settings.value("hasScreens", false).toBool());
|
setHaveScreens(settings.value("hasScreens", false).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::saveSettings(QSettings& settings) const
|
void Action::saveSettings(QSettings& settings) const
|
||||||
{
|
{
|
||||||
keySequence().saveSettings(settings);
|
keySequence().saveSettings(settings);
|
||||||
settings.setValue("type", type());
|
settings.setValue("type", type());
|
||||||
|
|
||||||
settings.beginWriteArray("typeScreenNames");
|
settings.beginWriteArray("typeScreenNames");
|
||||||
for (int i = 0; i < typeScreenNames().size(); i++)
|
for (int i = 0; i < typeScreenNames().size(); i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
settings.setValue("typeScreenName", typeScreenNames()[i]);
|
settings.setValue("typeScreenName", typeScreenNames()[i]);
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
settings.setValue("switchScreenName", switchScreenName());
|
settings.setValue("switchScreenName", switchScreenName());
|
||||||
settings.setValue("switchInDirection", switchDirection());
|
settings.setValue("switchInDirection", switchDirection());
|
||||||
settings.setValue("lockCursorToScreen", lockCursorMode());
|
settings.setValue("lockCursorToScreen", lockCursorMode());
|
||||||
settings.setValue("activeOnRelease", activeOnRelease());
|
settings.setValue("activeOnRelease", activeOnRelease());
|
||||||
settings.setValue("hasScreens", haveScreens());
|
settings.setValue("hasScreens", haveScreens());
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream& operator<<(QTextStream& outStream, const Action& action)
|
QTextStream& operator<<(QTextStream& outStream, const Action& action)
|
||||||
{
|
{
|
||||||
if (action.activeOnRelease())
|
if (action.activeOnRelease())
|
||||||
outStream << ";";
|
outStream << ";";
|
||||||
|
|
||||||
outStream << action.text();
|
outStream << action.text();
|
||||||
|
|
||||||
return outStream;
|
return outStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,54 +32,54 @@ class QTextStream;
|
||||||
|
|
||||||
class Action
|
class Action
|
||||||
{
|
{
|
||||||
friend class ActionDialog;
|
friend class ActionDialog;
|
||||||
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
||||||
enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown };
|
enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown };
|
||||||
enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff };
|
enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Action();
|
Action();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString text() const;
|
QString text() const;
|
||||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||||
void loadSettings(QSettings& settings);
|
void loadSettings(QSettings& settings);
|
||||||
void saveSettings(QSettings& settings) const;
|
void saveSettings(QSettings& settings) const;
|
||||||
int type() const { return m_Type; }
|
int type() const { return m_Type; }
|
||||||
const QStringList& typeScreenNames() const { return m_TypeScreenNames; }
|
const QStringList& typeScreenNames() const { return m_TypeScreenNames; }
|
||||||
const QString& switchScreenName() const { return m_SwitchScreenName; }
|
const QString& switchScreenName() const { return m_SwitchScreenName; }
|
||||||
int switchDirection() const { return m_SwitchDirection; }
|
int switchDirection() const { return m_SwitchDirection; }
|
||||||
int lockCursorMode() const { return m_LockCursorMode; }
|
int lockCursorMode() const { return m_LockCursorMode; }
|
||||||
bool activeOnRelease() const { return m_ActiveOnRelease; }
|
bool activeOnRelease() const { return m_ActiveOnRelease; }
|
||||||
bool haveScreens() const { return m_HasScreens; }
|
bool haveScreens() const { return m_HasScreens; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KeySequence& keySequence() { return m_KeySequence; }
|
KeySequence& keySequence() { return m_KeySequence; }
|
||||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||||
void setType(int t) { m_Type = t; }
|
void setType(int t) { m_Type = t; }
|
||||||
QStringList& typeScreenNames() { return m_TypeScreenNames; }
|
QStringList& typeScreenNames() { return m_TypeScreenNames; }
|
||||||
void setSwitchScreenName(const QString& n) { m_SwitchScreenName = n; }
|
void setSwitchScreenName(const QString& n) { m_SwitchScreenName = n; }
|
||||||
void setSwitchDirection(int d) { m_SwitchDirection = d; }
|
void setSwitchDirection(int d) { m_SwitchDirection = d; }
|
||||||
void setLockCursorMode(int m) { m_LockCursorMode = m; }
|
void setLockCursorMode(int m) { m_LockCursorMode = m; }
|
||||||
void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; }
|
void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; }
|
||||||
void setHaveScreens(bool b) { m_HasScreens = b; }
|
void setHaveScreens(bool b) { m_HasScreens = b; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeySequence m_KeySequence;
|
KeySequence m_KeySequence;
|
||||||
int m_Type;
|
int m_Type;
|
||||||
QStringList m_TypeScreenNames;
|
QStringList m_TypeScreenNames;
|
||||||
QString m_SwitchScreenName;
|
QString m_SwitchScreenName;
|
||||||
int m_SwitchDirection;
|
int m_SwitchDirection;
|
||||||
int m_LockCursorMode;
|
int m_LockCursorMode;
|
||||||
bool m_ActiveOnRelease;
|
bool m_ActiveOnRelease;
|
||||||
bool m_HasScreens;
|
bool m_HasScreens;
|
||||||
|
|
||||||
static const char* m_ActionTypeNames[];
|
static const char* m_ActionTypeNames[];
|
||||||
static const char* m_SwitchDirectionNames[];
|
static const char* m_SwitchDirectionNames[];
|
||||||
static const char* m_LockCursorModeNames[];
|
static const char* m_LockCursorModeNames[];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<Action> ActionList;
|
typedef QList<Action> ActionList;
|
||||||
|
|
|
@ -27,83 +27,83 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action) :
|
ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action) :
|
||||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::ActionDialogBase(),
|
Ui::ActionDialogBase(),
|
||||||
m_ServerConfig(config),
|
m_ServerConfig(config),
|
||||||
m_Hotkey(hotkey),
|
m_Hotkey(hotkey),
|
||||||
m_Action(action),
|
m_Action(action),
|
||||||
m_pButtonGroupType(new QButtonGroup(this))
|
m_pButtonGroupType(new QButtonGroup(this))
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
||||||
// at the button id of the checked radio button
|
// at the button id of the checked radio button
|
||||||
QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen };
|
QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen };
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
||||||
m_pButtonGroupType->addButton(typeButtons[i], i);
|
m_pButtonGroupType->addButton(typeButtons[i], i);
|
||||||
|
|
||||||
m_pKeySequenceWidgetHotkey->setText(m_Action.keySequence().toString());
|
m_pKeySequenceWidgetHotkey->setText(m_Action.keySequence().toString());
|
||||||
m_pKeySequenceWidgetHotkey->setKeySequence(m_Action.keySequence());
|
m_pKeySequenceWidgetHotkey->setKeySequence(m_Action.keySequence());
|
||||||
m_pButtonGroupType->button(m_Action.type())->setChecked(true);
|
m_pButtonGroupType->button(m_Action.type())->setChecked(true);
|
||||||
m_pComboSwitchInDirection->setCurrentIndex(m_Action.switchDirection());
|
m_pComboSwitchInDirection->setCurrentIndex(m_Action.switchDirection());
|
||||||
m_pComboLockCursorToScreen->setCurrentIndex(m_Action.lockCursorMode());
|
m_pComboLockCursorToScreen->setCurrentIndex(m_Action.lockCursorMode());
|
||||||
|
|
||||||
if (m_Action.activeOnRelease())
|
if (m_Action.activeOnRelease())
|
||||||
m_pRadioHotkeyReleased->setChecked(true);
|
m_pRadioHotkeyReleased->setChecked(true);
|
||||||
else
|
else
|
||||||
m_pRadioHotkeyPressed->setChecked(true);
|
m_pRadioHotkeyPressed->setChecked(true);
|
||||||
|
|
||||||
m_pGroupBoxScreens->setChecked(m_Action.haveScreens());
|
m_pGroupBoxScreens->setChecked(m_Action.haveScreens());
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
foreach(const Screen& screen, serverConfig().screens())
|
foreach(const Screen& screen, serverConfig().screens())
|
||||||
if (!screen.isNull())
|
if (!screen.isNull())
|
||||||
{
|
{
|
||||||
QListWidgetItem *pListItem = new QListWidgetItem(screen.name());
|
QListWidgetItem *pListItem = new QListWidgetItem(screen.name());
|
||||||
m_pListScreens->addItem(pListItem);
|
m_pListScreens->addItem(pListItem);
|
||||||
if (m_Action.typeScreenNames().indexOf(screen.name()) != -1)
|
if (m_Action.typeScreenNames().indexOf(screen.name()) != -1)
|
||||||
m_pListScreens->setCurrentItem(pListItem);
|
m_pListScreens->setCurrentItem(pListItem);
|
||||||
|
|
||||||
m_pComboSwitchToScreen->addItem(screen.name());
|
m_pComboSwitchToScreen->addItem(screen.name());
|
||||||
if (screen.name() == m_Action.switchScreenName())
|
if (screen.name() == m_Action.switchScreenName())
|
||||||
m_pComboSwitchToScreen->setCurrentIndex(idx);
|
m_pComboSwitchToScreen->setCurrentIndex(idx);
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionDialog::accept()
|
void ActionDialog::accept()
|
||||||
{
|
{
|
||||||
if (!sequenceWidget()->valid() && m_pButtonGroupType->checkedId() >= 0 && m_pButtonGroupType->checkedId() < 3)
|
if (!sequenceWidget()->valid() && m_pButtonGroupType->checkedId() >= 0 && m_pButtonGroupType->checkedId() < 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_Action.setKeySequence(sequenceWidget()->keySequence());
|
m_Action.setKeySequence(sequenceWidget()->keySequence());
|
||||||
m_Action.setType(m_pButtonGroupType->checkedId());
|
m_Action.setType(m_pButtonGroupType->checkedId());
|
||||||
m_Action.setHaveScreens(m_pGroupBoxScreens->isChecked());
|
m_Action.setHaveScreens(m_pGroupBoxScreens->isChecked());
|
||||||
|
|
||||||
m_Action.typeScreenNames().clear();
|
m_Action.typeScreenNames().clear();
|
||||||
foreach(const QListWidgetItem* pItem, m_pListScreens->selectedItems())
|
foreach(const QListWidgetItem* pItem, m_pListScreens->selectedItems())
|
||||||
m_Action.typeScreenNames().append(pItem->text());
|
m_Action.typeScreenNames().append(pItem->text());
|
||||||
|
|
||||||
m_Action.setSwitchScreenName(m_pComboSwitchToScreen->currentText());
|
m_Action.setSwitchScreenName(m_pComboSwitchToScreen->currentText());
|
||||||
m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex());
|
m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex());
|
||||||
m_Action.setLockCursorMode(m_pComboLockCursorToScreen->currentIndex());
|
m_Action.setLockCursorMode(m_pComboLockCursorToScreen->currentIndex());
|
||||||
m_Action.setActiveOnRelease(m_pRadioHotkeyReleased->isChecked());
|
m_Action.setActiveOnRelease(m_pRadioHotkeyReleased->isChecked());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionDialog::on_m_pKeySequenceWidgetHotkey_keySequenceChanged()
|
void ActionDialog::on_m_pKeySequenceWidgetHotkey_keySequenceChanged()
|
||||||
{
|
{
|
||||||
if (sequenceWidget()->keySequence().isMouseButton())
|
if (sequenceWidget()->keySequence().isMouseButton())
|
||||||
{
|
{
|
||||||
m_pGroupBoxScreens->setEnabled(false);
|
m_pGroupBoxScreens->setEnabled(false);
|
||||||
m_pListScreens->setEnabled(false);
|
m_pListScreens->setEnabled(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_pGroupBoxScreens->setEnabled(true);
|
m_pGroupBoxScreens->setEnabled(true);
|
||||||
m_pListScreens->setEnabled(true);
|
m_pListScreens->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,25 +32,25 @@ class ServerConfig;
|
||||||
|
|
||||||
class ActionDialog : public QDialog, public Ui::ActionDialogBase
|
class ActionDialog : public QDialog, public Ui::ActionDialogBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action);
|
ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void accept();
|
void accept();
|
||||||
void on_m_pKeySequenceWidgetHotkey_keySequenceChanged();
|
void on_m_pKeySequenceWidgetHotkey_keySequenceChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
||||||
const ServerConfig& serverConfig() const { return m_ServerConfig; }
|
const ServerConfig& serverConfig() const { return m_ServerConfig; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ServerConfig& m_ServerConfig;
|
const ServerConfig& m_ServerConfig;
|
||||||
Hotkey& m_Hotkey;
|
Hotkey& m_Hotkey;
|
||||||
Action& m_Action;
|
Action& m_Action;
|
||||||
|
|
||||||
QButtonGroup* m_pButtonGroupType;
|
QButtonGroup* m_pButtonGroupType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,109 +15,109 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig,
|
ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig,
|
||||||
LicenseManager& licenseManager) :
|
LicenseManager& licenseManager) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ActivationDialog),
|
ui(new Ui::ActivationDialog),
|
||||||
m_appConfig(&appConfig),
|
m_appConfig(&appConfig),
|
||||||
m_LicenseManager (&licenseManager)
|
m_LicenseManager (&licenseManager)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
refreshSerialKey();
|
refreshSerialKey();
|
||||||
time_t currentTime = ::time(0);
|
time_t currentTime = ::time(0);
|
||||||
if (!m_LicenseManager->serialKey().isExpired(currentTime)) {
|
if (!m_LicenseManager->serialKey().isExpired(currentTime)) {
|
||||||
ui->m_trialWidget->hide();
|
ui->m_trialWidget->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationDialog::refreshSerialKey()
|
void ActivationDialog::refreshSerialKey()
|
||||||
{
|
{
|
||||||
ui->m_pTextEditSerialKey->setText(m_appConfig->serialKey());
|
ui->m_pTextEditSerialKey->setText(m_appConfig->serialKey());
|
||||||
ui->m_pTextEditSerialKey->setFocus();
|
ui->m_pTextEditSerialKey->setFocus();
|
||||||
ui->m_pTextEditSerialKey->moveCursor(QTextCursor::End);
|
ui->m_pTextEditSerialKey->moveCursor(QTextCursor::End);
|
||||||
ui->m_trialLabel->setText(tr("<html><head/><body><p>Your trial has "
|
ui->m_trialLabel->setText(tr("<html><head/><body><p>Your trial has "
|
||||||
"expired. <a href=\"https://symless.com/"
|
"expired. <a href=\"https://symless.com/"
|
||||||
"synergy/trial/thanks?id=%1\"><span "
|
"synergy/trial/thanks?id=%1\"><span "
|
||||||
"style=\"text-decoration: underline; "
|
"style=\"text-decoration: underline; "
|
||||||
"color:#0000ff;\">Buy now!</span></a>"
|
"color:#0000ff;\">Buy now!</span></a>"
|
||||||
"</p></body></html>")
|
"</p></body></html>")
|
||||||
.arg (m_appConfig->serialKey()));
|
.arg (m_appConfig->serialKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ActivationDialog::~ActivationDialog()
|
ActivationDialog::~ActivationDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationDialog::reject()
|
void ActivationDialog::reject()
|
||||||
{
|
{
|
||||||
if (m_LicenseManager->activeEdition() == kUnregistered) {
|
if (m_LicenseManager->activeEdition() == kUnregistered) {
|
||||||
CancelActivationDialog cancelActivationDialog(this);
|
CancelActivationDialog cancelActivationDialog(this);
|
||||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||||
m_LicenseManager->skipActivation();
|
m_LicenseManager->skipActivation();
|
||||||
m_appConfig->activationHasRun(true);
|
m_appConfig->activationHasRun(true);
|
||||||
m_appConfig->saveSettings();
|
m_appConfig->saveSettings();
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationDialog::accept()
|
void ActivationDialog::accept()
|
||||||
{
|
{
|
||||||
QMessageBox message;
|
QMessageBox message;
|
||||||
m_appConfig->activationHasRun(true);
|
m_appConfig->activationHasRun(true);
|
||||||
m_appConfig->saveSettings();
|
m_appConfig->saveSettings();
|
||||||
|
|
||||||
std::pair<bool, QString> result;
|
std::pair<bool, QString> result;
|
||||||
try {
|
try {
|
||||||
SerialKey serialKey (ui->m_pTextEditSerialKey->toPlainText().
|
SerialKey serialKey (ui->m_pTextEditSerialKey->toPlainText().
|
||||||
trimmed().toStdString());
|
trimmed().toStdString());
|
||||||
result = m_LicenseManager->setSerialKey(serialKey);
|
result = m_LicenseManager->setSerialKey(serialKey);
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
message.critical(this, "Unknown Error",
|
message.critical(this, "Unknown Error",
|
||||||
tr("An error occurred while trying to activate Synergy. "
|
tr("An error occurred while trying to activate Synergy. "
|
||||||
"Please contact the helpdesk, and provide the "
|
"Please contact the helpdesk, and provide the "
|
||||||
"following information:\n\n%1").arg(e.what()));
|
"following information:\n\n%1").arg(e.what()));
|
||||||
refreshSerialKey();
|
refreshSerialKey();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.first) {
|
if (!result.first) {
|
||||||
message.critical(this, "Activation failed",
|
message.critical(this, "Activation failed",
|
||||||
tr("%1").arg(result.second));
|
tr("%1").arg(result.second));
|
||||||
refreshSerialKey();
|
refreshSerialKey();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LicenseManager->notifyActivation("serial:" + m_appConfig->serialKey());
|
m_LicenseManager->notifyActivation("serial:" + m_appConfig->serialKey());
|
||||||
Edition edition = m_LicenseManager->activeEdition();
|
Edition edition = m_LicenseManager->activeEdition();
|
||||||
time_t daysLeft = m_LicenseManager->serialKey().daysLeft(::time(0));
|
time_t daysLeft = m_LicenseManager->serialKey().daysLeft(::time(0));
|
||||||
if (edition != kUnregistered) {
|
if (edition != kUnregistered) {
|
||||||
QString thanksMessage = tr("Thanks for trying %1! %5\n\n%2 day%3 of "
|
QString thanksMessage = tr("Thanks for trying %1! %5\n\n%2 day%3 of "
|
||||||
"your trial remain%4").
|
"your trial remain%4").
|
||||||
arg (m_LicenseManager->getEditionName(edition)).
|
arg (m_LicenseManager->getEditionName(edition)).
|
||||||
arg (daysLeft).
|
arg (daysLeft).
|
||||||
arg ((daysLeft == 1) ? "" : "s").
|
arg ((daysLeft == 1) ? "" : "s").
|
||||||
arg ((daysLeft == 1) ? "s" : "");
|
arg ((daysLeft == 1) ? "s" : "");
|
||||||
|
|
||||||
if (edition == kPro) {
|
if (edition == kPro) {
|
||||||
thanksMessage = thanksMessage.arg("If you're using SSL, "
|
thanksMessage = thanksMessage.arg("If you're using SSL, "
|
||||||
"remember to activate all of your devices.");
|
"remember to activate all of your devices.");
|
||||||
} else {
|
} else {
|
||||||
thanksMessage = thanksMessage.arg("");
|
thanksMessage = thanksMessage.arg("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_LicenseManager->serialKey().isTrial()) {
|
if (m_LicenseManager->serialKey().isTrial()) {
|
||||||
message.information(this, "Thanks!", thanksMessage);
|
message.information(this, "Thanks!", thanksMessage);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
message.information(this, "Activated!",
|
message.information(this, "Activated!",
|
||||||
tr("Thanks for activating %1!").arg
|
tr("Thanks for activating %1!").arg
|
||||||
(m_LicenseManager->getEditionName(edition)));
|
(m_LicenseManager->getEditionName(edition)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,24 +12,24 @@ class AppConfig;
|
||||||
|
|
||||||
class ActivationDialog : public QDialog
|
class ActivationDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActivationDialog(QWidget *parent, AppConfig& appConfig,
|
ActivationDialog(QWidget *parent, AppConfig& appConfig,
|
||||||
LicenseManager& licenseManager);
|
LicenseManager& licenseManager);
|
||||||
~ActivationDialog();
|
~ActivationDialog();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void reject();
|
void reject();
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void refreshSerialKey();
|
void refreshSerialKey();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ActivationDialog *ui;
|
Ui::ActivationDialog *ui;
|
||||||
AppConfig* m_appConfig;
|
AppConfig* m_appConfig;
|
||||||
LicenseManager* m_LicenseManager;
|
LicenseManager* m_LicenseManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACTIVATIONDIALOG_H
|
#endif // ACTIVATIONDIALOG_H
|
||||||
|
|
|
@ -20,41 +20,41 @@
|
||||||
#include "CoreInterface.h"
|
#include "CoreInterface.h"
|
||||||
|
|
||||||
ActivationNotifier::ActivationNotifier(QObject *parent) :
|
ActivationNotifier::ActivationNotifier(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationNotifier::setIdentity(QString identity)
|
void ActivationNotifier::setIdentity(QString identity)
|
||||||
{
|
{
|
||||||
m_Identity = identity;
|
m_Identity = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationNotifier::setUpdateInfo(QString const& fromVersion,
|
void ActivationNotifier::setUpdateInfo(QString const& fromVersion,
|
||||||
QString const& toVersion,
|
QString const& toVersion,
|
||||||
QString const& serialKey)
|
QString const& serialKey)
|
||||||
{
|
{
|
||||||
m_fromVersion = fromVersion;
|
m_fromVersion = fromVersion;
|
||||||
m_toVersion = toVersion;
|
m_toVersion = toVersion;
|
||||||
m_serialKey = serialKey;
|
m_serialKey = serialKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationNotifier::notify()
|
void ActivationNotifier::notify()
|
||||||
{
|
{
|
||||||
CoreInterface coreInterface;
|
CoreInterface coreInterface;
|
||||||
try {
|
try {
|
||||||
coreInterface.notifyActivation(m_Identity);
|
coreInterface.notifyActivation(m_Identity);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
// catch all exceptions and fails silently
|
// catch all exceptions and fails silently
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivationNotifier::notifyUpdate()
|
void ActivationNotifier::notifyUpdate()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
CoreInterface coreInterface;
|
CoreInterface coreInterface;
|
||||||
coreInterface.notifyUpdate(m_fromVersion, m_toVersion,
|
coreInterface.notifyUpdate(m_fromVersion, m_toVersion,
|
||||||
m_serialKey);
|
m_serialKey);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,24 +24,24 @@ class ActivationNotifier : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ActivationNotifier(QObject *parent = 0);
|
explicit ActivationNotifier(QObject *parent = 0);
|
||||||
|
|
||||||
void setIdentity(QString identity);
|
void setIdentity(QString identity);
|
||||||
void setUpdateInfo(QString const& fromVersion,
|
void setUpdateInfo(QString const& fromVersion,
|
||||||
QString const& toVersion, QString const& serialKey);
|
QString const& toVersion, QString const& serialKey);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void notify();
|
void notify();
|
||||||
void notifyUpdate();
|
void notifyUpdate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_Identity;
|
QString m_Identity;
|
||||||
QString m_fromVersion;
|
QString m_fromVersion;
|
||||||
QString m_toVersion;
|
QString m_toVersion;
|
||||||
QString m_serialKey;
|
QString m_serialKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ACTIVATIONNOTIFIER_H
|
#endif // ACTIVATIONNOTIFIER_H
|
||||||
|
|
|
@ -22,108 +22,108 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
AddClientDialog::AddClientDialog(const QString& clientName, QWidget* parent) :
|
AddClientDialog::AddClientDialog(const QString& clientName, QWidget* parent) :
|
||||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::AddClientDialog(),
|
Ui::AddClientDialog(),
|
||||||
m_AddResult(kAddClientIgnore),
|
m_AddResult(kAddClientIgnore),
|
||||||
m_IgnoreAutoConfigClient(false)
|
m_IgnoreAutoConfigClient(false)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
m_pLabelHead->setText("A client wants to connect. "
|
m_pLabelHead->setText("A client wants to connect. "
|
||||||
"Please choose a location for " + clientName + ".");
|
"Please choose a location for " + clientName + ".");
|
||||||
|
|
||||||
QIcon icon(":res/icons/64x64/video-display.png");
|
QIcon icon(":res/icons/64x64/video-display.png");
|
||||||
QSize IconSize(32,32);
|
QSize IconSize(32,32);
|
||||||
|
|
||||||
m_pButtonLeft = new QPushButton(this);
|
m_pButtonLeft = new QPushButton(this);
|
||||||
m_pButtonLeft->setIcon(icon);
|
m_pButtonLeft->setIcon(icon);
|
||||||
m_pButtonLeft->setIconSize(IconSize);
|
m_pButtonLeft->setIconSize(IconSize);
|
||||||
gridLayout->addWidget(m_pButtonLeft, 2, 0, 1, 1, Qt::AlignCenter);
|
gridLayout->addWidget(m_pButtonLeft, 2, 0, 1, 1, Qt::AlignCenter);
|
||||||
connect(m_pButtonLeft, SIGNAL(clicked()), this, SLOT(handleButtonLeft()));
|
connect(m_pButtonLeft, SIGNAL(clicked()), this, SLOT(handleButtonLeft()));
|
||||||
|
|
||||||
m_pButtonUp = new QPushButton(this);
|
m_pButtonUp = new QPushButton(this);
|
||||||
m_pButtonUp->setIcon(icon);
|
m_pButtonUp->setIcon(icon);
|
||||||
m_pButtonUp->setIconSize(IconSize);
|
m_pButtonUp->setIconSize(IconSize);
|
||||||
gridLayout->addWidget(m_pButtonUp, 1, 1, 1, 1, Qt::AlignCenter);
|
gridLayout->addWidget(m_pButtonUp, 1, 1, 1, 1, Qt::AlignCenter);
|
||||||
connect(m_pButtonUp, SIGNAL(clicked()), this, SLOT(handleButtonUp()));
|
connect(m_pButtonUp, SIGNAL(clicked()), this, SLOT(handleButtonUp()));
|
||||||
|
|
||||||
m_pButtonRight = new QPushButton(this);
|
m_pButtonRight = new QPushButton(this);
|
||||||
m_pButtonRight->setIcon(icon);
|
m_pButtonRight->setIcon(icon);
|
||||||
m_pButtonRight->setIconSize(IconSize);
|
m_pButtonRight->setIconSize(IconSize);
|
||||||
gridLayout->addWidget(m_pButtonRight, 2, 2, 1, 1, Qt::AlignCenter);
|
gridLayout->addWidget(m_pButtonRight, 2, 2, 1, 1, Qt::AlignCenter);
|
||||||
connect(m_pButtonRight, SIGNAL(clicked()), this, SLOT(handleButtonRight()));
|
connect(m_pButtonRight, SIGNAL(clicked()), this, SLOT(handleButtonRight()));
|
||||||
|
|
||||||
m_pButtonDown = new QPushButton(this);
|
m_pButtonDown = new QPushButton(this);
|
||||||
m_pButtonDown->setIcon(icon);
|
m_pButtonDown->setIcon(icon);
|
||||||
m_pButtonDown->setIconSize(IconSize);
|
m_pButtonDown->setIconSize(IconSize);
|
||||||
gridLayout->addWidget(m_pButtonDown, 3, 1, 1, 1, Qt::AlignCenter);
|
gridLayout->addWidget(m_pButtonDown, 3, 1, 1, 1, Qt::AlignCenter);
|
||||||
connect(m_pButtonDown, SIGNAL(clicked()), this, SLOT(handleButtonDown()));
|
connect(m_pButtonDown, SIGNAL(clicked()), this, SLOT(handleButtonDown()));
|
||||||
|
|
||||||
m_pLabelCenter = new QLabel(this);
|
m_pLabelCenter = new QLabel(this);
|
||||||
m_pLabelCenter->setPixmap(QPixmap(":res/icons/64x64/video-display.png"));
|
m_pLabelCenter->setPixmap(QPixmap(":res/icons/64x64/video-display.png"));
|
||||||
gridLayout->addWidget(m_pLabelCenter, 2, 1, 1, 1, Qt::AlignCenter);
|
gridLayout->addWidget(m_pLabelCenter, 2, 1, 1, 1, Qt::AlignCenter);
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
m_pDialogButtonBox->setLayoutDirection(Qt::RightToLeft);
|
m_pDialogButtonBox->setLayoutDirection(Qt::RightToLeft);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QPushButton* advanced = m_pDialogButtonBox->addButton("Advanced",
|
QPushButton* advanced = m_pDialogButtonBox->addButton("Advanced",
|
||||||
QDialogButtonBox::HelpRole);
|
QDialogButtonBox::HelpRole);
|
||||||
connect(advanced, SIGNAL(clicked()), this, SLOT(handleButtonAdvanced()));
|
connect(advanced, SIGNAL(clicked()), this, SLOT(handleButtonAdvanced()));
|
||||||
}
|
}
|
||||||
|
|
||||||
AddClientDialog::~AddClientDialog()
|
AddClientDialog::~AddClientDialog()
|
||||||
{
|
{
|
||||||
delete m_pButtonUp;
|
delete m_pButtonUp;
|
||||||
delete m_pButtonDown;
|
delete m_pButtonDown;
|
||||||
delete m_pButtonLeft;
|
delete m_pButtonLeft;
|
||||||
delete m_pButtonRight;
|
delete m_pButtonRight;
|
||||||
delete m_pLabelCenter;
|
delete m_pLabelCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::changeEvent(QEvent *e)
|
void AddClientDialog::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
QDialog::changeEvent(e);
|
QDialog::changeEvent(e);
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
case QEvent::LanguageChange:
|
case QEvent::LanguageChange:
|
||||||
retranslateUi(this);
|
retranslateUi(this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonLeft()
|
void AddClientDialog::handleButtonLeft()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientLeft;
|
m_AddResult = kAddClientLeft;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonUp()
|
void AddClientDialog::handleButtonUp()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientUp;
|
m_AddResult = kAddClientUp;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonRight()
|
void AddClientDialog::handleButtonRight()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientRight;
|
m_AddResult = kAddClientRight;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonDown()
|
void AddClientDialog::handleButtonDown()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientDown;
|
m_AddResult = kAddClientDown;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonAdvanced()
|
void AddClientDialog::handleButtonAdvanced()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientOther;
|
m_AddResult = kAddClientOther;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::on_m_pCheckBoxIgnoreClient_toggled(bool checked)
|
void AddClientDialog::on_m_pCheckBoxIgnoreClient_toggled(bool checked)
|
||||||
{
|
{
|
||||||
m_IgnoreAutoConfigClient = checked;
|
m_IgnoreAutoConfigClient = checked;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,43 +26,43 @@ class QPushButton;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kAddClientRight,
|
kAddClientRight,
|
||||||
kAddClientLeft,
|
kAddClientLeft,
|
||||||
kAddClientUp,
|
kAddClientUp,
|
||||||
kAddClientDown,
|
kAddClientDown,
|
||||||
kAddClientOther,
|
kAddClientOther,
|
||||||
kAddClientIgnore
|
kAddClientIgnore
|
||||||
};
|
};
|
||||||
|
|
||||||
class AddClientDialog : public QDialog, public Ui::AddClientDialog
|
class AddClientDialog : public QDialog, public Ui::AddClientDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AddClientDialog(const QString& clientName, QWidget* parent = 0);
|
AddClientDialog(const QString& clientName, QWidget* parent = 0);
|
||||||
~AddClientDialog();
|
~AddClientDialog();
|
||||||
|
|
||||||
int addResult() { return m_AddResult; }
|
int addResult() { return m_AddResult; }
|
||||||
bool ignoreAutoConfigClient() { return m_IgnoreAutoConfigClient; }
|
bool ignoreAutoConfigClient() { return m_IgnoreAutoConfigClient; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_pCheckBoxIgnoreClient_toggled(bool checked);
|
void on_m_pCheckBoxIgnoreClient_toggled(bool checked);
|
||||||
void handleButtonLeft();
|
void handleButtonLeft();
|
||||||
void handleButtonUp();
|
void handleButtonUp();
|
||||||
void handleButtonRight();
|
void handleButtonRight();
|
||||||
void handleButtonDown();
|
void handleButtonDown();
|
||||||
void handleButtonAdvanced();
|
void handleButtonAdvanced();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPushButton* m_pButtonLeft;
|
QPushButton* m_pButtonLeft;
|
||||||
QPushButton* m_pButtonUp;
|
QPushButton* m_pButtonUp;
|
||||||
QPushButton* m_pButtonRight;
|
QPushButton* m_pButtonRight;
|
||||||
QPushButton* m_pButtonDown;
|
QPushButton* m_pButtonDown;
|
||||||
QLabel* m_pLabelCenter;
|
QLabel* m_pLabelCenter;
|
||||||
int m_AddResult;
|
int m_AddResult;
|
||||||
bool m_IgnoreAutoConfigClient;
|
bool m_IgnoreAutoConfigClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ADDCLIENTDIALOG_H
|
#endif // ADDCLIENTDIALOG_H
|
||||||
|
|
|
@ -39,38 +39,38 @@ const ElevateMode defaultElevateMode = ElevateAsNeeded;
|
||||||
|
|
||||||
static const char* logLevelNames[] =
|
static const char* logLevelNames[] =
|
||||||
{
|
{
|
||||||
"ERROR",
|
"ERROR",
|
||||||
"WARNING",
|
"WARNING",
|
||||||
"NOTE",
|
"NOTE",
|
||||||
"INFO",
|
"INFO",
|
||||||
"DEBUG",
|
"DEBUG",
|
||||||
"DEBUG1",
|
"DEBUG1",
|
||||||
"DEBUG2"
|
"DEBUG2"
|
||||||
};
|
};
|
||||||
|
|
||||||
AppConfig::AppConfig(QSettings* settings) :
|
AppConfig::AppConfig(QSettings* settings) :
|
||||||
m_pSettings(settings),
|
m_pSettings(settings),
|
||||||
m_ScreenName(),
|
m_ScreenName(),
|
||||||
m_Port(24800),
|
m_Port(24800),
|
||||||
m_Interface(),
|
m_Interface(),
|
||||||
m_LogLevel(0),
|
m_LogLevel(0),
|
||||||
m_WizardLastRun(0),
|
m_WizardLastRun(0),
|
||||||
m_ProcessMode(DEFAULT_PROCESS_MODE),
|
m_ProcessMode(DEFAULT_PROCESS_MODE),
|
||||||
m_AutoConfig(true),
|
m_AutoConfig(true),
|
||||||
m_ElevateMode(defaultElevateMode),
|
m_ElevateMode(defaultElevateMode),
|
||||||
m_AutoConfigPrompted(false),
|
m_AutoConfigPrompted(false),
|
||||||
m_CryptoEnabled(false),
|
m_CryptoEnabled(false),
|
||||||
m_AutoHide(false),
|
m_AutoHide(false),
|
||||||
m_LastExpiringWarningTime(0)
|
m_LastExpiringWarningTime(0)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_pSettings);
|
Q_ASSERT(m_pSettings);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
AppConfig::~AppConfig()
|
AppConfig::~AppConfig()
|
||||||
{
|
{
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &AppConfig::screenName() const { return m_ScreenName; }
|
const QString &AppConfig::screenName() const { return m_ScreenName; }
|
||||||
|
@ -88,44 +88,44 @@ const QString &AppConfig::logFilename() const { return m_LogFilename; }
|
||||||
QString AppConfig::synergyLogDir() const
|
QString AppConfig::synergyLogDir() const
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// on windows, we want to log to program files
|
// on windows, we want to log to program files
|
||||||
return synergyProgramDir() + "log/";
|
return synergyProgramDir() + "log/";
|
||||||
#else
|
#else
|
||||||
// on unix, we'll log to the standard log dir
|
// on unix, we'll log to the standard log dir
|
||||||
return "/var/log/";
|
return "/var/log/";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppConfig::synergyProgramDir() const
|
QString AppConfig::synergyProgramDir() const
|
||||||
{
|
{
|
||||||
// synergy binaries should be in the same dir.
|
// synergy binaries should be in the same dir.
|
||||||
return QCoreApplication::applicationDirPath() + "/";
|
return QCoreApplication::applicationDirPath() + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::persistLogDir()
|
void AppConfig::persistLogDir()
|
||||||
{
|
{
|
||||||
QDir dir = synergyLogDir();
|
QDir dir = synergyLogDir();
|
||||||
|
|
||||||
// persist the log directory
|
// persist the log directory
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
{
|
{
|
||||||
dir.mkpath(dir.path());
|
dir.mkpath(dir.path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString AppConfig::logFilenameCmd() const
|
const QString AppConfig::logFilenameCmd() const
|
||||||
{
|
{
|
||||||
QString filename = m_LogFilename;
|
QString filename = m_LogFilename;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// wrap in quotes in case username contains spaces.
|
// wrap in quotes in case username contains spaces.
|
||||||
filename = QString("\"%1\"").arg(filename);
|
filename = QString("\"%1\"").arg(filename);
|
||||||
#endif
|
#endif
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppConfig::logLevelText() const
|
QString AppConfig::logLevelText() const
|
||||||
{
|
{
|
||||||
return logLevelNames[logLevel()];
|
return logLevelNames[logLevel()];
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessMode AppConfig::processMode() const { return m_ProcessMode; }
|
ProcessMode AppConfig::processMode() const { return m_ProcessMode; }
|
||||||
|
@ -140,78 +140,78 @@ bool AppConfig::autoConfig() const { return m_AutoConfig; }
|
||||||
|
|
||||||
void AppConfig::loadSettings()
|
void AppConfig::loadSettings()
|
||||||
{
|
{
|
||||||
m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString();
|
m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString();
|
||||||
m_Port = settings().value("port", 24800).toInt();
|
m_Port = settings().value("port", 24800).toInt();
|
||||||
m_Interface = settings().value("interface").toString();
|
m_Interface = settings().value("interface").toString();
|
||||||
m_LogLevel = settings().value("logLevel", 3).toInt(); // level 3: INFO
|
m_LogLevel = settings().value("logLevel", 3).toInt(); // level 3: INFO
|
||||||
m_LogToFile = settings().value("logToFile", false).toBool();
|
m_LogToFile = settings().value("logToFile", false).toBool();
|
||||||
m_LogFilename = settings().value("logFilename", synergyLogDir() + "synergy.log").toString();
|
m_LogFilename = settings().value("logFilename", synergyLogDir() + "synergy.log").toString();
|
||||||
m_WizardLastRun = settings().value("wizardLastRun", 0).toInt();
|
m_WizardLastRun = settings().value("wizardLastRun", 0).toInt();
|
||||||
m_Language = settings().value("language", QLocale::system().name()).toString();
|
m_Language = settings().value("language", QLocale::system().name()).toString();
|
||||||
m_StartedBefore = settings().value("startedBefore", false).toBool();
|
m_StartedBefore = settings().value("startedBefore", false).toBool();
|
||||||
m_AutoConfig = settings().value("autoConfig", true).toBool();
|
m_AutoConfig = settings().value("autoConfig", true).toBool();
|
||||||
QVariant elevateMode = settings().value("elevateModeEnum");
|
QVariant elevateMode = settings().value("elevateModeEnum");
|
||||||
if (!elevateMode.isValid()) {
|
if (!elevateMode.isValid()) {
|
||||||
elevateMode = settings().value ("elevateMode",
|
elevateMode = settings().value ("elevateMode",
|
||||||
QVariant(static_cast<int>(defaultElevateMode)));
|
QVariant(static_cast<int>(defaultElevateMode)));
|
||||||
}
|
}
|
||||||
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
||||||
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
||||||
m_Edition = static_cast<Edition>(settings().value("edition", kUnregistered).toInt());
|
m_Edition = static_cast<Edition>(settings().value("edition", kUnregistered).toInt());
|
||||||
m_ActivateEmail = settings().value("activateEmail", "").toString();
|
m_ActivateEmail = settings().value("activateEmail", "").toString();
|
||||||
m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool();
|
m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool();
|
||||||
m_AutoHide = settings().value("autoHide", false).toBool();
|
m_AutoHide = settings().value("autoHide", false).toBool();
|
||||||
m_Serialkey = settings().value("serialKey", "").toString().trimmed();
|
m_Serialkey = settings().value("serialKey", "").toString().trimmed();
|
||||||
m_lastVersion = settings().value("lastVersion", "Unknown").toString();
|
m_lastVersion = settings().value("lastVersion", "Unknown").toString();
|
||||||
m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt();
|
m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt();
|
||||||
m_ActivationHasRun = settings().value("activationHasRun", false).toBool();
|
m_ActivationHasRun = settings().value("activationHasRun", false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::saveSettings()
|
void AppConfig::saveSettings()
|
||||||
{
|
{
|
||||||
settings().setValue("screenName", m_ScreenName);
|
settings().setValue("screenName", m_ScreenName);
|
||||||
settings().setValue("port", m_Port);
|
settings().setValue("port", m_Port);
|
||||||
settings().setValue("interface", m_Interface);
|
settings().setValue("interface", m_Interface);
|
||||||
settings().setValue("logLevel", m_LogLevel);
|
settings().setValue("logLevel", m_LogLevel);
|
||||||
settings().setValue("logToFile", m_LogToFile);
|
settings().setValue("logToFile", m_LogToFile);
|
||||||
settings().setValue("logFilename", m_LogFilename);
|
settings().setValue("logFilename", m_LogFilename);
|
||||||
settings().setValue("wizardLastRun", kWizardVersion);
|
settings().setValue("wizardLastRun", kWizardVersion);
|
||||||
settings().setValue("language", m_Language);
|
settings().setValue("language", m_Language);
|
||||||
settings().setValue("startedBefore", m_StartedBefore);
|
settings().setValue("startedBefore", m_StartedBefore);
|
||||||
settings().setValue("autoConfig", m_AutoConfig);
|
settings().setValue("autoConfig", m_AutoConfig);
|
||||||
// Refer to enum ElevateMode declaration for insight in to why this
|
// Refer to enum ElevateMode declaration for insight in to why this
|
||||||
// flag is mapped this way
|
// flag is mapped this way
|
||||||
settings().setValue("elevateMode", m_ElevateMode == ElevateAlways);
|
settings().setValue("elevateMode", m_ElevateMode == ElevateAlways);
|
||||||
settings().setValue("elevateModeEnum", static_cast<int>(m_ElevateMode));
|
settings().setValue("elevateModeEnum", static_cast<int>(m_ElevateMode));
|
||||||
settings().setValue("autoConfigPrompted", m_AutoConfigPrompted);
|
settings().setValue("autoConfigPrompted", m_AutoConfigPrompted);
|
||||||
settings().setValue("edition", m_Edition);
|
settings().setValue("edition", m_Edition);
|
||||||
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
||||||
settings().setValue("autoHide", m_AutoHide);
|
settings().setValue("autoHide", m_AutoHide);
|
||||||
settings().setValue("serialKey", m_Serialkey);
|
settings().setValue("serialKey", m_Serialkey);
|
||||||
settings().setValue("lastVersion", m_lastVersion);
|
settings().setValue("lastVersion", m_lastVersion);
|
||||||
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
||||||
settings().setValue("activationHasRun", m_ActivationHasRun);
|
settings().setValue("activationHasRun", m_ActivationHasRun);
|
||||||
settings().sync();
|
settings().sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppConfig::activationHasRun() const
|
bool AppConfig::activationHasRun() const
|
||||||
{
|
{
|
||||||
return m_ActivationHasRun;
|
return m_ActivationHasRun;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppConfig& AppConfig::activationHasRun(bool value)
|
AppConfig& AppConfig::activationHasRun(bool value)
|
||||||
{
|
{
|
||||||
m_ActivationHasRun = value;
|
m_ActivationHasRun = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppConfig::lastVersion() const
|
QString AppConfig::lastVersion() const
|
||||||
{
|
{
|
||||||
return m_lastVersion;
|
return m_lastVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::setLastVersion(QString version) {
|
void AppConfig::setLastVersion(QString version) {
|
||||||
m_lastVersion = version;
|
m_lastVersion = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings &AppConfig::settings() { return *m_pSettings; }
|
QSettings &AppConfig::settings() { return *m_pSettings; }
|
||||||
|
@ -238,31 +238,31 @@ void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; }
|
||||||
|
|
||||||
void AppConfig::setAutoConfig(bool autoConfig)
|
void AppConfig::setAutoConfig(bool autoConfig)
|
||||||
{
|
{
|
||||||
m_AutoConfig = autoConfig;
|
m_AutoConfig = autoConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; }
|
bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; }
|
||||||
|
|
||||||
void AppConfig::setAutoConfigPrompted(bool prompted)
|
void AppConfig::setAutoConfigPrompted(bool prompted)
|
||||||
{
|
{
|
||||||
m_AutoConfigPrompted = prompted;
|
m_AutoConfigPrompted = prompted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::setEdition(Edition e) {
|
void AppConfig::setEdition(Edition e) {
|
||||||
m_Edition = e;
|
m_Edition = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Edition AppConfig::edition() const { return m_Edition; }
|
Edition AppConfig::edition() const { return m_Edition; }
|
||||||
|
|
||||||
QString AppConfig::setSerialKey(QString serial) {
|
QString AppConfig::setSerialKey(QString serial) {
|
||||||
using std::swap;
|
using std::swap;
|
||||||
swap (serial, m_Serialkey);
|
swap (serial, m_Serialkey);
|
||||||
return serial;
|
return serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::clearSerialKey()
|
void AppConfig::clearSerialKey()
|
||||||
{
|
{
|
||||||
m_Serialkey.clear();
|
m_Serialkey.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppConfig::serialKey() { return m_Serialkey; }
|
QString AppConfig::serialKey() { return m_Serialkey; }
|
||||||
|
@ -277,16 +277,16 @@ QString AppConfig::synergycName() const { return m_SynergycName; }
|
||||||
|
|
||||||
ElevateMode AppConfig::elevateMode()
|
ElevateMode AppConfig::elevateMode()
|
||||||
{
|
{
|
||||||
return m_ElevateMode;
|
return m_ElevateMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::setCryptoEnabled(bool e) {
|
void AppConfig::setCryptoEnabled(bool e) {
|
||||||
m_CryptoEnabled = e;
|
m_CryptoEnabled = e;
|
||||||
emit sslToggled(e);
|
emit sslToggled(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppConfig::getCryptoEnabled() const {
|
bool AppConfig::getCryptoEnabled() const {
|
||||||
return (edition() == kPro) && m_CryptoEnabled;
|
return (edition() == kPro) && m_CryptoEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
||||||
|
|
|
@ -46,114 +46,114 @@ class QSettings;
|
||||||
class SettingsDialog;
|
class SettingsDialog;
|
||||||
|
|
||||||
enum ProcessMode {
|
enum ProcessMode {
|
||||||
Service,
|
Service,
|
||||||
Desktop
|
Desktop
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppConfig: public QObject
|
class AppConfig: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class SettingsDialog;
|
friend class SettingsDialog;
|
||||||
friend class MainWindow;
|
friend class MainWindow;
|
||||||
friend class SetupWizard;
|
friend class SetupWizard;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AppConfig(QSettings* settings);
|
AppConfig(QSettings* settings);
|
||||||
~AppConfig();
|
~AppConfig();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QString& screenName() const;
|
const QString& screenName() const;
|
||||||
int port() const;
|
int port() const;
|
||||||
const QString& networkInterface() const;
|
const QString& networkInterface() const;
|
||||||
int logLevel() const;
|
int logLevel() const;
|
||||||
bool logToFile() const;
|
bool logToFile() const;
|
||||||
const QString& logFilename() const;
|
const QString& logFilename() const;
|
||||||
const QString logFilenameCmd() const;
|
const QString logFilenameCmd() const;
|
||||||
QString logLevelText() const;
|
QString logLevelText() const;
|
||||||
ProcessMode processMode() const;
|
ProcessMode processMode() const;
|
||||||
bool wizardShouldRun() const;
|
bool wizardShouldRun() const;
|
||||||
const QString& language() const;
|
const QString& language() const;
|
||||||
bool startedBefore() const;
|
bool startedBefore() const;
|
||||||
bool autoConfig() const;
|
bool autoConfig() const;
|
||||||
void setAutoConfig(bool autoConfig);
|
void setAutoConfig(bool autoConfig);
|
||||||
bool autoConfigPrompted();
|
bool autoConfigPrompted();
|
||||||
void setAutoConfigPrompted(bool prompted);
|
void setAutoConfigPrompted(bool prompted);
|
||||||
void setEdition(Edition);
|
void setEdition(Edition);
|
||||||
Edition edition() const;
|
Edition edition() const;
|
||||||
QString setSerialKey(QString serial);
|
QString setSerialKey(QString serial);
|
||||||
void clearSerialKey();
|
void clearSerialKey();
|
||||||
QString serialKey();
|
QString serialKey();
|
||||||
int lastExpiringWarningTime() const;
|
int lastExpiringWarningTime() const;
|
||||||
void setLastExpiringWarningTime(int t);
|
void setLastExpiringWarningTime(int t);
|
||||||
|
|
||||||
QString synergysName() const;
|
QString synergysName() const;
|
||||||
QString synergycName() const;
|
QString synergycName() const;
|
||||||
QString synergyProgramDir() const;
|
QString synergyProgramDir() const;
|
||||||
QString synergyLogDir() const;
|
QString synergyLogDir() const;
|
||||||
|
|
||||||
bool detectPath(const QString& name, QString& path);
|
bool detectPath(const QString& name, QString& path);
|
||||||
void persistLogDir();
|
void persistLogDir();
|
||||||
ElevateMode elevateMode();
|
ElevateMode elevateMode();
|
||||||
|
|
||||||
void setCryptoEnabled(bool e);
|
void setCryptoEnabled(bool e);
|
||||||
bool getCryptoEnabled() const;
|
bool getCryptoEnabled() const;
|
||||||
|
|
||||||
void setAutoHide(bool b);
|
void setAutoHide(bool b);
|
||||||
bool getAutoHide();
|
bool getAutoHide();
|
||||||
|
|
||||||
bool activationHasRun() const;
|
bool activationHasRun() const;
|
||||||
AppConfig& activationHasRun(bool value);
|
AppConfig& activationHasRun(bool value);
|
||||||
|
|
||||||
QString lastVersion() const;
|
QString lastVersion() const;
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
void setLastVersion(QString version);
|
void setLastVersion(QString version);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSettings& settings();
|
QSettings& settings();
|
||||||
void setScreenName(const QString& s);
|
void setScreenName(const QString& s);
|
||||||
void setPort(int i);
|
void setPort(int i);
|
||||||
void setNetworkInterface(const QString& s);
|
void setNetworkInterface(const QString& s);
|
||||||
void setLogLevel(int i);
|
void setLogLevel(int i);
|
||||||
void setLogToFile(bool b);
|
void setLogToFile(bool b);
|
||||||
void setLogFilename(const QString& s);
|
void setLogFilename(const QString& s);
|
||||||
void setWizardHasRun();
|
void setWizardHasRun();
|
||||||
void setLanguage(const QString language);
|
void setLanguage(const QString language);
|
||||||
void setStartedBefore(bool b);
|
void setStartedBefore(bool b);
|
||||||
void setElevateMode(ElevateMode em);
|
void setElevateMode(ElevateMode em);
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings* m_pSettings;
|
QSettings* m_pSettings;
|
||||||
QString m_ScreenName;
|
QString m_ScreenName;
|
||||||
int m_Port;
|
int m_Port;
|
||||||
QString m_Interface;
|
QString m_Interface;
|
||||||
int m_LogLevel;
|
int m_LogLevel;
|
||||||
bool m_LogToFile;
|
bool m_LogToFile;
|
||||||
QString m_LogFilename;
|
QString m_LogFilename;
|
||||||
int m_WizardLastRun;
|
int m_WizardLastRun;
|
||||||
ProcessMode m_ProcessMode;
|
ProcessMode m_ProcessMode;
|
||||||
QString m_Language;
|
QString m_Language;
|
||||||
bool m_StartedBefore;
|
bool m_StartedBefore;
|
||||||
bool m_AutoConfig;
|
bool m_AutoConfig;
|
||||||
ElevateMode m_ElevateMode;
|
ElevateMode m_ElevateMode;
|
||||||
bool m_AutoConfigPrompted;
|
bool m_AutoConfigPrompted;
|
||||||
Edition m_Edition;
|
Edition m_Edition;
|
||||||
QString m_ActivateEmail;
|
QString m_ActivateEmail;
|
||||||
bool m_CryptoEnabled;
|
bool m_CryptoEnabled;
|
||||||
bool m_AutoHide;
|
bool m_AutoHide;
|
||||||
QString m_Serialkey;
|
QString m_Serialkey;
|
||||||
QString m_lastVersion;
|
QString m_lastVersion;
|
||||||
int m_LastExpiringWarningTime;
|
int m_LastExpiringWarningTime;
|
||||||
bool m_ActivationHasRun;
|
bool m_ActivationHasRun;
|
||||||
|
|
||||||
static const char m_SynergysName[];
|
static const char m_SynergysName[];
|
||||||
static const char m_SynergycName[];
|
static const char m_SynergycName[];
|
||||||
static const char m_SynergyLogDir[];
|
static const char m_SynergyLogDir[];
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sslToggled(bool enabled);
|
void sslToggled(bool enabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,27 +20,27 @@
|
||||||
|
|
||||||
const char* BaseConfig::m_ModifierNames[] =
|
const char* BaseConfig::m_ModifierNames[] =
|
||||||
{
|
{
|
||||||
"shift",
|
"shift",
|
||||||
"ctrl",
|
"ctrl",
|
||||||
"alt",
|
"alt",
|
||||||
"meta",
|
"meta",
|
||||||
"super",
|
"super",
|
||||||
"none"
|
"none"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* BaseConfig::m_FixNames[] =
|
const char* BaseConfig::m_FixNames[] =
|
||||||
{
|
{
|
||||||
"halfDuplexCapsLock",
|
"halfDuplexCapsLock",
|
||||||
"halfDuplexNumLock",
|
"halfDuplexNumLock",
|
||||||
"halfDuplexScrollLock",
|
"halfDuplexScrollLock",
|
||||||
"xtestIsXineramaUnaware"
|
"xtestIsXineramaUnaware"
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* BaseConfig::m_SwitchCornerNames[] =
|
const char* BaseConfig::m_SwitchCornerNames[] =
|
||||||
{
|
{
|
||||||
"top-left",
|
"top-left",
|
||||||
"top-right",
|
"top-right",
|
||||||
"bottom-left",
|
"bottom-left",
|
||||||
"bottom-right"
|
"bottom-right"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,66 +26,66 @@
|
||||||
|
|
||||||
class BaseConfig
|
class BaseConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Modifier { DefaultMod = -1, Shift, Ctrl, Alt, Meta, Super, None, NumModifiers };
|
enum Modifier { DefaultMod = -1, Shift, Ctrl, Alt, Meta, Super, None, NumModifiers };
|
||||||
enum SwitchCorner { TopLeft, TopRight, BottomLeft, BottomRight, NumSwitchCorners };
|
enum SwitchCorner { TopLeft, TopRight, BottomLeft, BottomRight, NumSwitchCorners };
|
||||||
enum Fix { CapsLock, NumLock, ScrollLock, XTest, NumFixes };
|
enum Fix { CapsLock, NumLock, ScrollLock, XTest, NumFixes };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseConfig() {}
|
BaseConfig() {}
|
||||||
virtual ~BaseConfig() {}
|
virtual ~BaseConfig() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt)
|
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt)
|
||||||
{
|
{
|
||||||
int entries = settings.beginReadArray(arrayName + "Array");
|
int entries = settings.beginReadArray(arrayName + "Array");
|
||||||
array.clear();
|
array.clear();
|
||||||
for (int i = 0; i < entries; i++)
|
for (int i = 0; i < entries; i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
QVariant v = settings.value(arrayName, deflt);
|
QVariant v = settings.value(arrayName, deflt);
|
||||||
array.append(v.value<T2>());
|
array.append(v.value<T2>());
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt, int entries)
|
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt, int entries)
|
||||||
{
|
{
|
||||||
Q_ASSERT(array.size() >= entries);
|
Q_ASSERT(array.size() >= entries);
|
||||||
settings.beginReadArray(arrayName + "Array");
|
settings.beginReadArray(arrayName + "Array");
|
||||||
for (int i = 0; i < entries; i++)
|
for (int i = 0; i < entries; i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
QVariant v = settings.value(arrayName, deflt);
|
QVariant v = settings.value(arrayName, deflt);
|
||||||
array[i] = v.value<T2>();
|
array[i] = v.value<T2>();
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void writeSettings(QSettings& settings, const T& array, const QString& arrayName) const
|
void writeSettings(QSettings& settings, const T& array, const QString& arrayName) const
|
||||||
{
|
{
|
||||||
settings.beginWriteArray(arrayName + "Array");
|
settings.beginWriteArray(arrayName + "Array");
|
||||||
for (int i = 0; i < array.size(); i++)
|
for (int i = 0; i < array.size(); i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
settings.setValue(arrayName, array[i]);
|
settings.setValue(arrayName, array[i]);
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const char* modifierName(int idx) { return m_ModifierNames[idx]; }
|
static const char* modifierName(int idx) { return m_ModifierNames[idx]; }
|
||||||
static const char* fixName(int idx) { return m_FixNames[idx]; }
|
static const char* fixName(int idx) { return m_FixNames[idx]; }
|
||||||
static const char* switchCornerName(int idx) { return m_SwitchCornerNames[idx]; }
|
static const char* switchCornerName(int idx) { return m_SwitchCornerNames[idx]; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char* m_ModifierNames[];
|
static const char* m_ModifierNames[];
|
||||||
static const char* m_FixNames[];
|
static const char* m_FixNames[];
|
||||||
static const char* m_SwitchCornerNames[];
|
static const char* m_SwitchCornerNames[];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
#include "ui_CancelActivationDialog.h"
|
#include "ui_CancelActivationDialog.h"
|
||||||
|
|
||||||
CancelActivationDialog::CancelActivationDialog(QWidget *parent) :
|
CancelActivationDialog::CancelActivationDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::CancelActivationDialog)
|
ui(new Ui::CancelActivationDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CancelActivationDialog::~CancelActivationDialog()
|
CancelActivationDialog::~CancelActivationDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,14 +9,14 @@ class CancelActivationDialog;
|
||||||
|
|
||||||
class CancelActivationDialog : public QDialog
|
class CancelActivationDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CancelActivationDialog(QWidget *parent = 0);
|
explicit CancelActivationDialog(QWidget *parent = 0);
|
||||||
~CancelActivationDialog();
|
~CancelActivationDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CancelActivationDialog *ui;
|
Ui::CancelActivationDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CANCELACTIVATIONDIALOG_H
|
#endif // CANCELACTIVATIONDIALOG_H
|
||||||
|
|
|
@ -21,43 +21,43 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
CommandProcess::CommandProcess(QString cmd, QStringList arguments, QString input) :
|
CommandProcess::CommandProcess(QString cmd, QStringList arguments, QString input) :
|
||||||
m_Command(cmd),
|
m_Command(cmd),
|
||||||
m_Arguments(arguments),
|
m_Arguments(arguments),
|
||||||
m_Input(input)
|
m_Input(input)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CommandProcess::run()
|
QString CommandProcess::run()
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setReadChannel(QProcess::StandardOutput);
|
process.setReadChannel(QProcess::StandardOutput);
|
||||||
process.start(m_Command, m_Arguments);
|
process.start(m_Command, m_Arguments);
|
||||||
bool success = process.waitForStarted();
|
bool success = process.waitForStarted();
|
||||||
|
|
||||||
QString output, error;
|
QString output, error;
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
if (!m_Input.isEmpty()) {
|
if (!m_Input.isEmpty()) {
|
||||||
process.write(m_Input.toStdString().c_str());
|
process.write(m_Input.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.waitForFinished()) {
|
if (process.waitForFinished()) {
|
||||||
output = process.readAllStandardOutput().trimmed();
|
output = process.readAllStandardOutput().trimmed();
|
||||||
error = process.readAllStandardError().trimmed();
|
error = process.readAllStandardError().trimmed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = process.exitCode();
|
int code = process.exitCode();
|
||||||
if (!error.isEmpty() || !success || code != 0)
|
if (!error.isEmpty() || !success || code != 0)
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
QString("Code: %1\nError: %2")
|
QString("Code: %1\nError: %2")
|
||||||
.arg(process.exitCode())
|
.arg(process.exitCode())
|
||||||
.arg(error.isEmpty() ? "Unknown" : error)
|
.arg(error.isEmpty() ? "Unknown" : error)
|
||||||
.toStdString());
|
.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
emit finished();
|
emit finished();
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,21 +23,21 @@
|
||||||
|
|
||||||
class CommandProcess : public QObject
|
class CommandProcess : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CommandProcess(QString cmd, QStringList arguments, QString input = "");
|
CommandProcess(QString cmd, QStringList arguments, QString input = "");
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QString run();
|
QString run();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_Command;
|
QString m_Command;
|
||||||
QStringList m_Arguments;
|
QStringList m_Arguments;
|
||||||
QString m_Input;
|
QString m_Input;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COMMANDTHREAD_H
|
#endif // COMMANDTHREAD_H
|
||||||
|
|
|
@ -40,57 +40,57 @@ CoreInterface::CoreInterface()
|
||||||
|
|
||||||
QString CoreInterface::getProfileDir()
|
QString CoreInterface::getProfileDir()
|
||||||
{
|
{
|
||||||
QStringList args("--get-profile-dir");
|
QStringList args("--get-profile-dir");
|
||||||
return run(args);
|
return run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreInterface::getInstalledDir()
|
QString CoreInterface::getInstalledDir()
|
||||||
{
|
{
|
||||||
QStringList args("--get-installed-dir");
|
QStringList args("--get-installed-dir");
|
||||||
return run(args);
|
return run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreInterface::getArch()
|
QString CoreInterface::getArch()
|
||||||
{
|
{
|
||||||
QStringList args("--get-arch");
|
QStringList args("--get-arch");
|
||||||
return run(args);
|
return run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreInterface::getSerialKeyFilePath()
|
QString CoreInterface::getSerialKeyFilePath()
|
||||||
{
|
{
|
||||||
QString filename = getProfileDir() + QDir::separator() + kSerialKeyFilename;
|
QString filename = getProfileDir() + QDir::separator() + kSerialKeyFilename;
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreInterface::notifyUpdate (QString const& fromVersion,
|
QString CoreInterface::notifyUpdate (QString const& fromVersion,
|
||||||
QString const& toVersion,
|
QString const& toVersion,
|
||||||
QString const& serialKey) {
|
QString const& serialKey) {
|
||||||
QStringList args("--notify-update");
|
QStringList args("--notify-update");
|
||||||
QString input(fromVersion + ":" + toVersion + ":" + serialKey);
|
QString input(fromVersion + ":" + toVersion + ":" + serialKey);
|
||||||
input.append("\n");
|
input.append("\n");
|
||||||
return run(args, input);
|
return run(args, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreInterface::notifyActivation(const QString& identity)
|
QString CoreInterface::notifyActivation(const QString& identity)
|
||||||
{
|
{
|
||||||
QStringList args("--notify-activation");
|
QStringList args("--notify-activation");
|
||||||
|
|
||||||
QString input(identity + ":" + hash(getFirstMacAddress()));
|
QString input(identity + ":" + hash(getFirstMacAddress()));
|
||||||
QString os= getOSInformation();
|
QString os= getOSInformation();
|
||||||
if (!os.isEmpty()) {
|
if (!os.isEmpty()) {
|
||||||
input.append(":").append(os);
|
input.append(":").append(os);
|
||||||
}
|
}
|
||||||
input.append("\n");
|
input.append("\n");
|
||||||
|
|
||||||
return run(args, input);
|
return run(args, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreInterface::run(const QStringList& args, const QString& input)
|
QString CoreInterface::run(const QStringList& args, const QString& input)
|
||||||
{
|
{
|
||||||
QString program(
|
QString program(
|
||||||
QCoreApplication::applicationDirPath()
|
QCoreApplication::applicationDirPath()
|
||||||
+ "/" + kCoreBinary);
|
+ "/" + kCoreBinary);
|
||||||
|
|
||||||
CommandProcess commandProcess(program, args, input);
|
CommandProcess commandProcess(program, args, input);
|
||||||
return commandProcess.run();
|
return commandProcess.run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,15 @@
|
||||||
class CoreInterface
|
class CoreInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CoreInterface();
|
CoreInterface();
|
||||||
|
|
||||||
QString getProfileDir();
|
QString getProfileDir();
|
||||||
QString getInstalledDir();
|
QString getInstalledDir();
|
||||||
QString getArch();
|
QString getArch();
|
||||||
QString getSerialKeyFilePath();
|
QString getSerialKeyFilePath();
|
||||||
QString notifyActivation(const QString& identity);
|
QString notifyActivation(const QString& identity);
|
||||||
QString notifyUpdate (QString const& fromVersion,
|
QString notifyUpdate (QString const& fromVersion,
|
||||||
QString const& toVersion,
|
QString const& toVersion,
|
||||||
QString const& serialKey);
|
QString const& serialKey);
|
||||||
QString run(const QStringList& args, const QString& input = "");
|
QString run(const QStringList& args, const QString& input = "");
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
#include "DataDownloader.h"
|
#include "DataDownloader.h"
|
||||||
|
|
||||||
DataDownloader::DataDownloader(QObject* parent) :
|
DataDownloader::DataDownloader(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_IsFinished(false)
|
m_IsFinished(false)
|
||||||
{
|
{
|
||||||
connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply*)),
|
connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply*)),
|
||||||
SLOT(complete(QNetworkReply*)));
|
SLOT(complete(QNetworkReply*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
DataDownloader::~DataDownloader()
|
DataDownloader::~DataDownloader()
|
||||||
|
@ -31,27 +31,27 @@ DataDownloader::~DataDownloader()
|
||||||
|
|
||||||
void DataDownloader::complete(QNetworkReply* reply)
|
void DataDownloader::complete(QNetworkReply* reply)
|
||||||
{
|
{
|
||||||
m_Data = reply->readAll();
|
m_Data = reply->readAll();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
if (!m_Data.isEmpty()) {
|
if (!m_Data.isEmpty()) {
|
||||||
m_IsFinished = true;
|
m_IsFinished = true;
|
||||||
emit isComplete();
|
emit isComplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray DataDownloader::data() const
|
QByteArray DataDownloader::data() const
|
||||||
{
|
{
|
||||||
return m_Data;
|
return m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataDownloader::cancel()
|
void DataDownloader::cancel()
|
||||||
{
|
{
|
||||||
m_pReply->abort();
|
m_pReply->abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataDownloader::download(QUrl url)
|
void DataDownloader::download(QUrl url)
|
||||||
{
|
{
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
m_pReply = m_NetworkManager.get(request);
|
m_pReply = m_NetworkManager.get(request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,28 +26,28 @@
|
||||||
|
|
||||||
class DataDownloader : public QObject
|
class DataDownloader : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DataDownloader(QObject* parent = 0);
|
explicit DataDownloader(QObject* parent = 0);
|
||||||
virtual ~DataDownloader();
|
virtual ~DataDownloader();
|
||||||
|
|
||||||
QByteArray data() const;
|
QByteArray data() const;
|
||||||
void cancel();
|
void cancel();
|
||||||
void download(QUrl url);
|
void download(QUrl url);
|
||||||
bool isFinished() const { return m_IsFinished; }
|
bool isFinished() const { return m_IsFinished; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void isComplete();
|
void isComplete();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void complete(QNetworkReply* reply);
|
void complete(QNetworkReply* reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager m_NetworkManager;
|
QNetworkAccessManager m_NetworkManager;
|
||||||
QByteArray m_Data;
|
QByteArray m_Data;
|
||||||
QNetworkReply* m_pReply;
|
QNetworkReply* m_pReply;
|
||||||
bool m_IsFinished;
|
bool m_IsFinished;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATADOWNLOADER_H
|
#endif // DATADOWNLOADER_H
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
#include "ui_FailedLoginDialog.h"
|
#include "ui_FailedLoginDialog.h"
|
||||||
|
|
||||||
FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message):
|
FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message):
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::FailedLoginDialog)
|
ui(new Ui::FailedLoginDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->messageLabel->setText(ui->messageLabel->text().arg(message));
|
ui->messageLabel->setText(ui->messageLabel->text().arg(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
FailedLoginDialog::~FailedLoginDialog()
|
FailedLoginDialog::~FailedLoginDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,14 @@ class FailedLoginDialog;
|
||||||
|
|
||||||
class FailedLoginDialog : public QDialog
|
class FailedLoginDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FailedLoginDialog(QWidget *parent = 0, QString message = "");
|
explicit FailedLoginDialog(QWidget *parent = 0, QString message = "");
|
||||||
~FailedLoginDialog();
|
~FailedLoginDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FailedLoginDialog *ui;
|
Ui::FailedLoginDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FAILEDLOGINDIALOG_H
|
#endif // FAILEDLOGINDIALOG_H
|
||||||
|
|
|
@ -29,121 +29,121 @@ static const char kTrustedClientsFilename[] = "TrustedClients.txt";
|
||||||
|
|
||||||
Fingerprint::Fingerprint(const QString& filename)
|
Fingerprint::Fingerprint(const QString& filename)
|
||||||
{
|
{
|
||||||
m_Filename = filename;
|
m_Filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fingerprint::trust(const QString& fingerprintText, bool append)
|
void Fingerprint::trust(const QString& fingerprintText, bool append)
|
||||||
{
|
{
|
||||||
Fingerprint::persistDirectory();
|
Fingerprint::persistDirectory();
|
||||||
|
|
||||||
QIODevice::OpenMode openMode;
|
QIODevice::OpenMode openMode;
|
||||||
if (append) {
|
if (append) {
|
||||||
openMode = QIODevice::Append;
|
openMode = QIODevice::Append;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
openMode = QIODevice::WriteOnly;
|
openMode = QIODevice::WriteOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(filePath());
|
QFile file(filePath());
|
||||||
if (file.open(openMode))
|
if (file.open(openMode))
|
||||||
{
|
{
|
||||||
QTextStream out(&file);
|
QTextStream out(&file);
|
||||||
out << fingerprintText << "\n";
|
out << fingerprintText << "\n";
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Fingerprint::fileExists() const
|
bool Fingerprint::fileExists() const
|
||||||
{
|
{
|
||||||
QString dirName = Fingerprint::directoryPath();
|
QString dirName = Fingerprint::directoryPath();
|
||||||
if (!QDir(dirName).exists()) {
|
if (!QDir(dirName).exists()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(filePath());
|
QFile file(filePath());
|
||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Fingerprint::isTrusted(const QString& fingerprintText)
|
bool Fingerprint::isTrusted(const QString& fingerprintText)
|
||||||
{
|
{
|
||||||
QStringList list = readList();
|
QStringList list = readList();
|
||||||
foreach (QString trusted, list)
|
foreach (QString trusted, list)
|
||||||
{
|
{
|
||||||
if (trusted == fingerprintText) {
|
if (trusted == fingerprintText) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Fingerprint::readList(const int readTo)
|
QStringList Fingerprint::readList(const int readTo)
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
QString dirName = Fingerprint::directoryPath();
|
QString dirName = Fingerprint::directoryPath();
|
||||||
if (!QDir(dirName).exists()) {
|
if (!QDir(dirName).exists()) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile file(filePath());
|
QFile file(filePath());
|
||||||
|
|
||||||
if (file.open(QIODevice::ReadOnly))
|
if (file.open(QIODevice::ReadOnly))
|
||||||
{
|
{
|
||||||
QTextStream in(&file);
|
QTextStream in(&file);
|
||||||
while (!in.atEnd())
|
while (!in.atEnd())
|
||||||
{
|
{
|
||||||
list.append(in.readLine());
|
list.append(in.readLine());
|
||||||
if (list.size() == readTo) {
|
if (list.size() == readTo) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Fingerprint::readFirst()
|
QString Fingerprint::readFirst()
|
||||||
{
|
{
|
||||||
QStringList list = readList(1);
|
QStringList list = readList(1);
|
||||||
return list.at(0);
|
return list.at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Fingerprint::filePath() const
|
QString Fingerprint::filePath() const
|
||||||
{
|
{
|
||||||
QString dir = Fingerprint::directoryPath();
|
QString dir = Fingerprint::directoryPath();
|
||||||
return QString("%1/%2").arg(dir).arg(m_Filename);
|
return QString("%1/%2").arg(dir).arg(m_Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fingerprint::persistDirectory()
|
void Fingerprint::persistDirectory()
|
||||||
{
|
{
|
||||||
QDir dir(Fingerprint::directoryPath());
|
QDir dir(Fingerprint::directoryPath());
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.mkpath(".");
|
dir.mkpath(".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Fingerprint::directoryPath()
|
QString Fingerprint::directoryPath()
|
||||||
{
|
{
|
||||||
CoreInterface coreInterface;
|
CoreInterface coreInterface;
|
||||||
QString profileDir = coreInterface.getProfileDir();
|
QString profileDir = coreInterface.getProfileDir();
|
||||||
|
|
||||||
return QString("%1/%2")
|
return QString("%1/%2")
|
||||||
.arg(profileDir)
|
.arg(profileDir)
|
||||||
.arg(kDirName);
|
.arg(kDirName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fingerprint Fingerprint::local()
|
Fingerprint Fingerprint::local()
|
||||||
{
|
{
|
||||||
return Fingerprint(kLocalFilename);
|
return Fingerprint(kLocalFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fingerprint Fingerprint::trustedServers()
|
Fingerprint Fingerprint::trustedServers()
|
||||||
{
|
{
|
||||||
return Fingerprint(kTrustedServersFilename);
|
return Fingerprint(kTrustedServersFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Fingerprint Fingerprint::trustedClients()
|
Fingerprint Fingerprint::trustedClients()
|
||||||
{
|
{
|
||||||
return Fingerprint(kTrustedClientsFilename);
|
return Fingerprint(kTrustedClientsFilename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,25 +22,25 @@
|
||||||
class Fingerprint
|
class Fingerprint
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Fingerprint(const QString& filename);
|
Fingerprint(const QString& filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void trust(const QString& fingerprintText, bool append = true);
|
void trust(const QString& fingerprintText, bool append = true);
|
||||||
bool isTrusted(const QString& fingerprintText);
|
bool isTrusted(const QString& fingerprintText);
|
||||||
QStringList readList(const int readTo = -1);
|
QStringList readList(const int readTo = -1);
|
||||||
QString readFirst();
|
QString readFirst();
|
||||||
QString filePath() const;
|
QString filePath() const;
|
||||||
bool fileExists() const;
|
bool fileExists() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Fingerprint local();
|
static Fingerprint local();
|
||||||
static Fingerprint trustedServers();
|
static Fingerprint trustedServers();
|
||||||
static Fingerprint trustedClients();
|
static Fingerprint trustedClients();
|
||||||
static QString directoryPath();
|
static QString directoryPath();
|
||||||
static QString localFingerprint();
|
static QString localFingerprint();
|
||||||
static bool localFingerprintExists();
|
static bool localFingerprintExists();
|
||||||
static void persistDirectory();
|
static void persistDirectory();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_Filename;
|
QString m_Filename;
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,55 +21,55 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
Hotkey::Hotkey() :
|
Hotkey::Hotkey() :
|
||||||
m_KeySequence(),
|
m_KeySequence(),
|
||||||
m_Actions()
|
m_Actions()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Hotkey::text() const
|
QString Hotkey::text() const
|
||||||
{
|
{
|
||||||
QString text = keySequence().toString();
|
QString text = keySequence().toString();
|
||||||
|
|
||||||
if (keySequence().isMouseButton())
|
if (keySequence().isMouseButton())
|
||||||
return "mousebutton(" + text + ")";
|
return "mousebutton(" + text + ")";
|
||||||
|
|
||||||
return "keystroke(" + text + ")";
|
return "keystroke(" + text + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkey::loadSettings(QSettings& settings)
|
void Hotkey::loadSettings(QSettings& settings)
|
||||||
{
|
{
|
||||||
keySequence().loadSettings(settings);
|
keySequence().loadSettings(settings);
|
||||||
|
|
||||||
actions().clear();
|
actions().clear();
|
||||||
int num = settings.beginReadArray("actions");
|
int num = settings.beginReadArray("actions");
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
Action a;
|
Action a;
|
||||||
a.loadSettings(settings);
|
a.loadSettings(settings);
|
||||||
actions().append(a);
|
actions().append(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkey::saveSettings(QSettings& settings) const
|
void Hotkey::saveSettings(QSettings& settings) const
|
||||||
{
|
{
|
||||||
keySequence().saveSettings(settings);
|
keySequence().saveSettings(settings);
|
||||||
|
|
||||||
settings.beginWriteArray("actions");
|
settings.beginWriteArray("actions");
|
||||||
for (int i = 0; i < actions().size(); i++)
|
for (int i = 0; i < actions().size(); i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
actions()[i].saveSettings(settings);
|
actions()[i].saveSettings(settings);
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey)
|
QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < hotkey.actions().size(); i++)
|
for (int i = 0; i < hotkey.actions().size(); i++)
|
||||||
outStream << "\t" << hotkey.text() << " = " << hotkey.actions()[i] << endl;
|
outStream << "\t" << hotkey.text() << " = " << hotkey.actions()[i] << endl;
|
||||||
|
|
||||||
return outStream;
|
return outStream;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,30 +33,30 @@ class QSettings;
|
||||||
|
|
||||||
class Hotkey
|
class Hotkey
|
||||||
{
|
{
|
||||||
friend class HotkeyDialog;
|
friend class HotkeyDialog;
|
||||||
friend class ServerConfigDialog;
|
friend class ServerConfigDialog;
|
||||||
friend QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey);
|
friend QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Hotkey();
|
Hotkey();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString text() const;
|
QString text() const;
|
||||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||||
const ActionList& actions() const { return m_Actions; }
|
const ActionList& actions() const { return m_Actions; }
|
||||||
|
|
||||||
void loadSettings(QSettings& settings);
|
void loadSettings(QSettings& settings);
|
||||||
void saveSettings(QSettings& settings) const;
|
void saveSettings(QSettings& settings) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
KeySequence& keySequence() { return m_KeySequence; }
|
KeySequence& keySequence() { return m_KeySequence; }
|
||||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||||
ActionList& actions() { return m_Actions; }
|
ActionList& actions() { return m_Actions; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeySequence m_KeySequence;
|
KeySequence m_KeySequence;
|
||||||
ActionList m_Actions;
|
ActionList m_Actions;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<Hotkey> HotkeyList;
|
typedef QList<Hotkey> HotkeyList;
|
||||||
|
|
|
@ -22,20 +22,20 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
HotkeyDialog::HotkeyDialog (QWidget* parent, Hotkey& hotkey) :
|
HotkeyDialog::HotkeyDialog (QWidget* parent, Hotkey& hotkey) :
|
||||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::HotkeyDialogBase(),
|
Ui::HotkeyDialogBase(),
|
||||||
m_Hotkey(hotkey)
|
m_Hotkey(hotkey)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
m_pKeySequenceWidgetHotkey->setText(m_Hotkey.text());
|
m_pKeySequenceWidgetHotkey->setText(m_Hotkey.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HotkeyDialog::accept()
|
void HotkeyDialog::accept()
|
||||||
{
|
{
|
||||||
if (!sequenceWidget()->valid())
|
if (!sequenceWidget()->valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hotkey().setKeySequence(sequenceWidget()->keySequence());
|
hotkey().setKeySequence(sequenceWidget()->keySequence());
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,23 +27,23 @@
|
||||||
|
|
||||||
class HotkeyDialog : public QDialog, public Ui::HotkeyDialogBase
|
class HotkeyDialog : public QDialog, public Ui::HotkeyDialogBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HotkeyDialog(QWidget* parent, Hotkey& hotkey);
|
HotkeyDialog(QWidget* parent, Hotkey& hotkey);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Hotkey& hotkey() const { return m_Hotkey; }
|
const Hotkey& hotkey() const { return m_Hotkey; }
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
||||||
Hotkey& hotkey() { return m_Hotkey; }
|
Hotkey& hotkey() { return m_Hotkey; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Hotkey& m_Hotkey;
|
Hotkey& m_Hotkey;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "Ipc.h"
|
#include "Ipc.h"
|
||||||
|
|
||||||
const char* kIpcMsgHello = "IHEL%1i";
|
const char* kIpcMsgHello = "IHEL%1i";
|
||||||
const char* kIpcMsgLogLine = "ILOG%s";
|
const char* kIpcMsgLogLine = "ILOG%s";
|
||||||
const char* kIpcMsgCommand = "ICMD%s%1i";
|
const char* kIpcMsgCommand = "ICMD%s%1i";
|
||||||
const char* kIpcMsgShutdown = "ISDN";
|
const char* kIpcMsgShutdown = "ISDN";
|
||||||
|
|
|
@ -24,19 +24,19 @@
|
||||||
#define IPC_PORT 24801
|
#define IPC_PORT 24801
|
||||||
|
|
||||||
enum qIpcMessageType {
|
enum qIpcMessageType {
|
||||||
kIpcHello,
|
kIpcHello,
|
||||||
kIpcLogLine,
|
kIpcLogLine,
|
||||||
kIpcCommand,
|
kIpcCommand,
|
||||||
kIpcShutdown,
|
kIpcShutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum qIpcClientType {
|
enum qIpcClientType {
|
||||||
kIpcClientUnknown,
|
kIpcClientUnknown,
|
||||||
kIpcClientGui,
|
kIpcClientGui,
|
||||||
kIpcClientNode,
|
kIpcClientNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char* kIpcMsgHello;
|
extern const char* kIpcMsgHello;
|
||||||
extern const char* kIpcMsgLogLine;
|
extern const char* kIpcMsgLogLine;
|
||||||
extern const char* kIpcMsgCommand;
|
extern const char* kIpcMsgCommand;
|
||||||
extern const char* kIpcMsgShutdown;
|
extern const char* kIpcMsgShutdown;
|
||||||
|
|
|
@ -29,12 +29,12 @@ IpcClient::IpcClient() :
|
||||||
m_ReaderStarted(false),
|
m_ReaderStarted(false),
|
||||||
m_Enabled(false)
|
m_Enabled(false)
|
||||||
{
|
{
|
||||||
m_Socket = new QTcpSocket(this);
|
m_Socket = new QTcpSocket(this);
|
||||||
connect(m_Socket, SIGNAL(connected()), this, SLOT(connected()));
|
connect(m_Socket, SIGNAL(connected()), this, SLOT(connected()));
|
||||||
connect(m_Socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
|
connect(m_Socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
|
||||||
|
|
||||||
m_Reader = new IpcReader(m_Socket);
|
m_Reader = new IpcReader(m_Socket);
|
||||||
connect(m_Reader, SIGNAL(readLogLine(const QString&)), this, SLOT(handleReadLogLine(const QString&)));
|
connect(m_Reader, SIGNAL(readLogLine(const QString&)), this, SLOT(handleReadLogLine(const QString&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
IpcClient::~IpcClient()
|
IpcClient::~IpcClient()
|
||||||
|
@ -43,104 +43,104 @@ IpcClient::~IpcClient()
|
||||||
|
|
||||||
void IpcClient::connected()
|
void IpcClient::connected()
|
||||||
{
|
{
|
||||||
sendHello();
|
sendHello();
|
||||||
infoMessage("connection established");
|
infoMessage("connection established");
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcClient::connectToHost()
|
void IpcClient::connectToHost()
|
||||||
{
|
{
|
||||||
m_Enabled = true;
|
m_Enabled = true;
|
||||||
|
|
||||||
infoMessage("connecting to service...");
|
infoMessage("connecting to service...");
|
||||||
m_Socket->connectToHost(QHostAddress(QHostAddress::LocalHost), IPC_PORT);
|
m_Socket->connectToHost(QHostAddress(QHostAddress::LocalHost), IPC_PORT);
|
||||||
|
|
||||||
if (!m_ReaderStarted) {
|
if (!m_ReaderStarted) {
|
||||||
m_Reader->start();
|
m_Reader->start();
|
||||||
m_ReaderStarted = true;
|
m_ReaderStarted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcClient::disconnectFromHost()
|
void IpcClient::disconnectFromHost()
|
||||||
{
|
{
|
||||||
infoMessage("service disconnect");
|
infoMessage("service disconnect");
|
||||||
m_Reader->stop();
|
m_Reader->stop();
|
||||||
m_Socket->close();
|
m_Socket->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcClient::error(QAbstractSocket::SocketError error)
|
void IpcClient::error(QAbstractSocket::SocketError error)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case 0: text = "connection refused"; break;
|
case 0: text = "connection refused"; break;
|
||||||
case 1: text = "remote host closed"; break;
|
case 1: text = "remote host closed"; break;
|
||||||
default: text = QString("code=%1").arg(error); break;
|
default: text = QString("code=%1").arg(error); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorMessage(QString("ipc connection error, %1").arg(text));
|
errorMessage(QString("ipc connection error, %1").arg(text));
|
||||||
|
|
||||||
QTimer::singleShot(1000, this, SLOT(retryConnect()));
|
QTimer::singleShot(1000, this, SLOT(retryConnect()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcClient::retryConnect()
|
void IpcClient::retryConnect()
|
||||||
{
|
{
|
||||||
if (m_Enabled) {
|
if (m_Enabled) {
|
||||||
connectToHost();
|
connectToHost();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcClient::sendHello()
|
void IpcClient::sendHello()
|
||||||
{
|
{
|
||||||
QDataStream stream(m_Socket);
|
QDataStream stream(m_Socket);
|
||||||
stream.writeRawData(kIpcMsgHello, 4);
|
stream.writeRawData(kIpcMsgHello, 4);
|
||||||
|
|
||||||
char typeBuf[1];
|
char typeBuf[1];
|
||||||
typeBuf[0] = kIpcClientGui;
|
typeBuf[0] = kIpcClientGui;
|
||||||
stream.writeRawData(typeBuf, 1);
|
stream.writeRawData(typeBuf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcClient::sendCommand(const QString& command, ElevateMode const elevate)
|
void IpcClient::sendCommand(const QString& command, ElevateMode const elevate)
|
||||||
{
|
{
|
||||||
QDataStream stream(m_Socket);
|
QDataStream stream(m_Socket);
|
||||||
|
|
||||||
stream.writeRawData(kIpcMsgCommand, 4);
|
stream.writeRawData(kIpcMsgCommand, 4);
|
||||||
|
|
||||||
std::string stdStringCommand = command.toStdString();
|
std::string stdStringCommand = command.toStdString();
|
||||||
const char* charCommand = stdStringCommand.c_str();
|
const char* charCommand = stdStringCommand.c_str();
|
||||||
int length = strlen(charCommand);
|
int length = strlen(charCommand);
|
||||||
|
|
||||||
char lenBuf[4];
|
char lenBuf[4];
|
||||||
intToBytes(length, lenBuf, 4);
|
intToBytes(length, lenBuf, 4);
|
||||||
stream.writeRawData(lenBuf, 4);
|
stream.writeRawData(lenBuf, 4);
|
||||||
stream.writeRawData(charCommand, length);
|
stream.writeRawData(charCommand, length);
|
||||||
|
|
||||||
char elevateBuf[1];
|
char elevateBuf[1];
|
||||||
// Refer to enum ElevateMode documentation for why this flag is mapped this way
|
// Refer to enum ElevateMode documentation for why this flag is mapped this way
|
||||||
elevateBuf[0] = (elevate == ElevateAlways) ? 1 : 0;
|
elevateBuf[0] = (elevate == ElevateAlways) ? 1 : 0;
|
||||||
stream.writeRawData(elevateBuf, 1);
|
stream.writeRawData(elevateBuf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcClient::handleReadLogLine(const QString& text)
|
void IpcClient::handleReadLogLine(const QString& text)
|
||||||
{
|
{
|
||||||
readLogLine(text);
|
readLogLine(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: qt must have a built in way of converting int to bytes.
|
// TODO: qt must have a built in way of converting int to bytes.
|
||||||
void IpcClient::intToBytes(int value, char *buffer, int size)
|
void IpcClient::intToBytes(int value, char *buffer, int size)
|
||||||
{
|
{
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
buffer[0] = value & 0xff;
|
buffer[0] = value & 0xff;
|
||||||
}
|
}
|
||||||
else if (size == 2) {
|
else if (size == 2) {
|
||||||
buffer[0] = (value >> 8) & 0xff;
|
buffer[0] = (value >> 8) & 0xff;
|
||||||
buffer[1] = value & 0xff;
|
buffer[1] = value & 0xff;
|
||||||
}
|
}
|
||||||
else if (size == 4) {
|
else if (size == 4) {
|
||||||
buffer[0] = (value >> 24) & 0xff;
|
buffer[0] = (value >> 24) & 0xff;
|
||||||
buffer[1] = (value >> 16) & 0xff;
|
buffer[1] = (value >> 16) & 0xff;
|
||||||
buffer[2] = (value >> 8) & 0xff;
|
buffer[2] = (value >> 8) & 0xff;
|
||||||
buffer[3] = value & 0xff;
|
buffer[3] = value & 0xff;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO: other sizes, if needed.
|
// TODO: other sizes, if needed.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,36 +28,36 @@ class IpcReader;
|
||||||
|
|
||||||
class IpcClient : public QObject
|
class IpcClient : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IpcClient();
|
IpcClient();
|
||||||
virtual ~IpcClient();
|
virtual ~IpcClient();
|
||||||
|
|
||||||
void sendHello();
|
void sendHello();
|
||||||
void sendCommand(const QString& command, ElevateMode elevate);
|
void sendCommand(const QString& command, ElevateMode elevate);
|
||||||
void connectToHost();
|
void connectToHost();
|
||||||
void disconnectFromHost();
|
void disconnectFromHost();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void retryConnect();
|
void retryConnect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void intToBytes(int value, char* buffer, int size);
|
void intToBytes(int value, char* buffer, int size);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void connected();
|
void connected();
|
||||||
void error(QAbstractSocket::SocketError error);
|
void error(QAbstractSocket::SocketError error);
|
||||||
void handleReadLogLine(const QString& text);
|
void handleReadLogLine(const QString& text);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void readLogLine(const QString& text);
|
void readLogLine(const QString& text);
|
||||||
void infoMessage(const QString& text);
|
void infoMessage(const QString& text);
|
||||||
void errorMessage(const QString& text);
|
void errorMessage(const QString& text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTcpSocket* m_Socket;
|
QTcpSocket* m_Socket;
|
||||||
IpcReader* m_Reader;
|
IpcReader* m_Reader;
|
||||||
bool m_ReaderStarted;
|
bool m_ReaderStarted;
|
||||||
bool m_Enabled;
|
bool m_Enabled;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,98 +34,98 @@ IpcReader::~IpcReader()
|
||||||
|
|
||||||
void IpcReader::start()
|
void IpcReader::start()
|
||||||
{
|
{
|
||||||
connect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
connect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcReader::stop()
|
void IpcReader::stop()
|
||||||
{
|
{
|
||||||
disconnect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
disconnect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcReader::read()
|
void IpcReader::read()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_Mutex);
|
QMutexLocker locker(&m_Mutex);
|
||||||
std::cout << "ready read" << std::endl;
|
std::cout << "ready read" << std::endl;
|
||||||
|
|
||||||
while (m_Socket->bytesAvailable()) {
|
while (m_Socket->bytesAvailable()) {
|
||||||
std::cout << "bytes available" << std::endl;
|
std::cout << "bytes available" << std::endl;
|
||||||
|
|
||||||
char codeBuf[5];
|
char codeBuf[5];
|
||||||
readStream(codeBuf, 4);
|
readStream(codeBuf, 4);
|
||||||
codeBuf[4] = 0;
|
codeBuf[4] = 0;
|
||||||
std::cout << "ipc read: " << codeBuf << std::endl;
|
std::cout << "ipc read: " << codeBuf << std::endl;
|
||||||
|
|
||||||
if (memcmp(codeBuf, kIpcMsgLogLine, 4) == 0) {
|
if (memcmp(codeBuf, kIpcMsgLogLine, 4) == 0) {
|
||||||
std::cout << "reading log line" << std::endl;
|
std::cout << "reading log line" << std::endl;
|
||||||
|
|
||||||
char lenBuf[4];
|
char lenBuf[4];
|
||||||
readStream(lenBuf, 4);
|
readStream(lenBuf, 4);
|
||||||
int len = bytesToInt(lenBuf, 4);
|
int len = bytesToInt(lenBuf, 4);
|
||||||
|
|
||||||
char* data = new char[len];
|
char* data = new char[len];
|
||||||
readStream(data, len);
|
readStream(data, len);
|
||||||
QString line = QString::fromUtf8(data, len);
|
QString line = QString::fromUtf8(data, len);
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
||||||
readLogLine(line);
|
readLogLine(line);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cerr << "aborting, message invalid" << std::endl;
|
std::cerr << "aborting, message invalid" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "read done" << std::endl;
|
std::cout << "read done" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IpcReader::readStream(char* buffer, int length)
|
bool IpcReader::readStream(char* buffer, int length)
|
||||||
{
|
{
|
||||||
std::cout << "reading stream" << std::endl;
|
std::cout << "reading stream" << std::endl;
|
||||||
|
|
||||||
int read = 0;
|
int read = 0;
|
||||||
while (read < length) {
|
while (read < length) {
|
||||||
int ask = length - read;
|
int ask = length - read;
|
||||||
if (m_Socket->bytesAvailable() < ask) {
|
if (m_Socket->bytesAvailable() < ask) {
|
||||||
std::cout << "buffer too short, waiting" << std::endl;
|
std::cout << "buffer too short, waiting" << std::endl;
|
||||||
m_Socket->waitForReadyRead(-1);
|
m_Socket->waitForReadyRead(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int got = m_Socket->read(buffer, ask);
|
int got = m_Socket->read(buffer, ask);
|
||||||
read += got;
|
read += got;
|
||||||
|
|
||||||
std::cout << "> ask=" << ask << " got=" << got
|
std::cout << "> ask=" << ask << " got=" << got
|
||||||
<< " read=" << read << std::endl;
|
<< " read=" << read << std::endl;
|
||||||
|
|
||||||
if (got == -1) {
|
if (got == -1) {
|
||||||
std::cout << "socket ended, aborting" << std::endl;
|
std::cout << "socket ended, aborting" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (length - read > 0) {
|
else if (length - read > 0) {
|
||||||
std::cout << "more remains, seek to " << got << std::endl;
|
std::cout << "more remains, seek to " << got << std::endl;
|
||||||
buffer += got;
|
buffer += got;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IpcReader::bytesToInt(const char *buffer, int size)
|
int IpcReader::bytesToInt(const char *buffer, int size)
|
||||||
{
|
{
|
||||||
if (size == 1) {
|
if (size == 1) {
|
||||||
return (unsigned char)buffer[0];
|
return (unsigned char)buffer[0];
|
||||||
}
|
}
|
||||||
else if (size == 2) {
|
else if (size == 2) {
|
||||||
return
|
return
|
||||||
(((unsigned char)buffer[0]) << 8) +
|
(((unsigned char)buffer[0]) << 8) +
|
||||||
(unsigned char)buffer[1];
|
(unsigned char)buffer[1];
|
||||||
}
|
}
|
||||||
else if (size == 4) {
|
else if (size == 4) {
|
||||||
return
|
return
|
||||||
(((unsigned char)buffer[0]) << 24) +
|
(((unsigned char)buffer[0]) << 24) +
|
||||||
(((unsigned char)buffer[1]) << 16) +
|
(((unsigned char)buffer[1]) << 16) +
|
||||||
(((unsigned char)buffer[2]) << 8) +
|
(((unsigned char)buffer[2]) << 8) +
|
||||||
(unsigned char)buffer[3];
|
(unsigned char)buffer[3];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,25 +25,25 @@ class QTcpSocket;
|
||||||
|
|
||||||
class IpcReader : public QObject
|
class IpcReader : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IpcReader(QTcpSocket* socket);
|
IpcReader(QTcpSocket* socket);
|
||||||
virtual ~IpcReader();
|
virtual ~IpcReader();
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void readLogLine(const QString& text);
|
void readLogLine(const QString& text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool readStream(char* buffer, int length);
|
bool readStream(char* buffer, int length);
|
||||||
int bytesToInt(const char* buffer, int size);
|
int bytesToInt(const char* buffer, int size);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void read();
|
void read();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTcpSocket* m_Socket;
|
QTcpSocket* m_Socket;
|
||||||
QMutex m_Mutex;
|
QMutex m_Mutex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,213 +25,213 @@
|
||||||
// and is heavily modified for QSynergy
|
// and is heavily modified for QSynergy
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int key;
|
int key;
|
||||||
const char* name;
|
const char* name;
|
||||||
} keyname[] =
|
} keyname[] =
|
||||||
{
|
{
|
||||||
{ Qt::Key_Space, "Space" },
|
{ Qt::Key_Space, "Space" },
|
||||||
{ Qt::Key_Escape, "Escape" },
|
{ Qt::Key_Escape, "Escape" },
|
||||||
{ Qt::Key_Tab, "Tab" },
|
{ Qt::Key_Tab, "Tab" },
|
||||||
{ Qt::Key_Backtab, "LeftTab" },
|
{ Qt::Key_Backtab, "LeftTab" },
|
||||||
{ Qt::Key_Backspace, "BackSpace" },
|
{ Qt::Key_Backspace, "BackSpace" },
|
||||||
{ Qt::Key_Return, "Return" },
|
{ Qt::Key_Return, "Return" },
|
||||||
{ Qt::Key_Insert, "Insert" },
|
{ Qt::Key_Insert, "Insert" },
|
||||||
{ Qt::Key_Delete, "Delete" },
|
{ Qt::Key_Delete, "Delete" },
|
||||||
{ Qt::Key_Pause, "Pause" },
|
{ Qt::Key_Pause, "Pause" },
|
||||||
{ Qt::Key_Print, "Print" },
|
{ Qt::Key_Print, "Print" },
|
||||||
{ Qt::Key_SysReq, "SysReq" },
|
{ Qt::Key_SysReq, "SysReq" },
|
||||||
{ Qt::Key_Home, "Home" },
|
{ Qt::Key_Home, "Home" },
|
||||||
{ Qt::Key_End, "End" },
|
{ Qt::Key_End, "End" },
|
||||||
{ Qt::Key_Left, "Left" },
|
{ Qt::Key_Left, "Left" },
|
||||||
{ Qt::Key_Up, "Up" },
|
{ Qt::Key_Up, "Up" },
|
||||||
{ Qt::Key_Right, "Right" },
|
{ Qt::Key_Right, "Right" },
|
||||||
{ Qt::Key_Down, "Down" },
|
{ Qt::Key_Down, "Down" },
|
||||||
{ Qt::Key_PageUp, "PageUp" },
|
{ Qt::Key_PageUp, "PageUp" },
|
||||||
{ Qt::Key_PageDown, "PageDown" },
|
{ Qt::Key_PageDown, "PageDown" },
|
||||||
{ Qt::Key_CapsLock, "CapsLock" },
|
{ Qt::Key_CapsLock, "CapsLock" },
|
||||||
{ Qt::Key_NumLock, "NumLock" },
|
{ Qt::Key_NumLock, "NumLock" },
|
||||||
{ Qt::Key_ScrollLock, "ScrollLock" },
|
{ Qt::Key_ScrollLock, "ScrollLock" },
|
||||||
{ Qt::Key_Menu, "Menu" },
|
{ Qt::Key_Menu, "Menu" },
|
||||||
{ Qt::Key_Help, "Help" },
|
{ Qt::Key_Help, "Help" },
|
||||||
{ Qt::Key_Enter, "KP_Enter" },
|
{ Qt::Key_Enter, "KP_Enter" },
|
||||||
{ Qt::Key_Clear, "Clear" },
|
{ Qt::Key_Clear, "Clear" },
|
||||||
|
|
||||||
{ Qt::Key_Back, "WWWBack" },
|
{ Qt::Key_Back, "WWWBack" },
|
||||||
{ Qt::Key_Forward, "WWWForward" },
|
{ Qt::Key_Forward, "WWWForward" },
|
||||||
{ Qt::Key_Stop, "WWWStop" },
|
{ Qt::Key_Stop, "WWWStop" },
|
||||||
{ Qt::Key_Refresh, "WWWRefresh" },
|
{ Qt::Key_Refresh, "WWWRefresh" },
|
||||||
{ Qt::Key_VolumeDown, "AudioDown" },
|
{ Qt::Key_VolumeDown, "AudioDown" },
|
||||||
{ Qt::Key_VolumeMute, "AudioMute" },
|
{ Qt::Key_VolumeMute, "AudioMute" },
|
||||||
{ Qt::Key_VolumeUp, "AudioUp" },
|
{ Qt::Key_VolumeUp, "AudioUp" },
|
||||||
{ Qt::Key_MediaPlay, "AudioPlay" },
|
{ Qt::Key_MediaPlay, "AudioPlay" },
|
||||||
{ Qt::Key_MediaStop, "AudioStop" },
|
{ Qt::Key_MediaStop, "AudioStop" },
|
||||||
{ Qt::Key_MediaPrevious,"AudioPrev" },
|
{ Qt::Key_MediaPrevious,"AudioPrev" },
|
||||||
{ Qt::Key_MediaNext, "AudioNext" },
|
{ Qt::Key_MediaNext, "AudioNext" },
|
||||||
{ Qt::Key_HomePage, "WWWHome" },
|
{ Qt::Key_HomePage, "WWWHome" },
|
||||||
{ Qt::Key_Favorites, "WWWFavorites" },
|
{ Qt::Key_Favorites, "WWWFavorites" },
|
||||||
{ Qt::Key_Search, "WWWSearch" },
|
{ Qt::Key_Search, "WWWSearch" },
|
||||||
{ Qt::Key_Standby, "Sleep" },
|
{ Qt::Key_Standby, "Sleep" },
|
||||||
{ Qt::Key_LaunchMail, "AppMail" },
|
{ Qt::Key_LaunchMail, "AppMail" },
|
||||||
{ Qt::Key_LaunchMedia, "AppMedia" },
|
{ Qt::Key_LaunchMedia, "AppMedia" },
|
||||||
{ Qt::Key_Launch0, "AppUser1" },
|
{ Qt::Key_Launch0, "AppUser1" },
|
||||||
{ Qt::Key_Launch1, "AppUser2" },
|
{ Qt::Key_Launch1, "AppUser2" },
|
||||||
{ Qt::Key_Select, "Select" },
|
{ Qt::Key_Select, "Select" },
|
||||||
|
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
KeySequence::KeySequence() :
|
KeySequence::KeySequence() :
|
||||||
m_Sequence(),
|
m_Sequence(),
|
||||||
m_Modifiers(0),
|
m_Modifiers(0),
|
||||||
m_IsValid(false)
|
m_IsValid(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeySequence::isMouseButton() const
|
bool KeySequence::isMouseButton() const
|
||||||
{
|
{
|
||||||
return !m_Sequence.isEmpty() && m_Sequence.last() < Qt::Key_Space;
|
return !m_Sequence.isEmpty() && m_Sequence.last() < Qt::Key_Space;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KeySequence::toString() const
|
QString KeySequence::toString() const
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
for (int i = 0; i < m_Sequence.size(); i++)
|
for (int i = 0; i < m_Sequence.size(); i++)
|
||||||
{
|
{
|
||||||
result += keyToString(m_Sequence[i]);
|
result += keyToString(m_Sequence[i]);
|
||||||
|
|
||||||
if (i != m_Sequence.size() - 1)
|
if (i != m_Sequence.size() - 1)
|
||||||
result += "+";
|
result += "+";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeySequence::appendMouseButton(int button)
|
bool KeySequence::appendMouseButton(int button)
|
||||||
{
|
{
|
||||||
return appendKey(button, 0);
|
return appendKey(button, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeySequence::appendKey(int key, int modifiers)
|
bool KeySequence::appendKey(int key, int modifiers)
|
||||||
{
|
{
|
||||||
if (m_Sequence.size() == 4)
|
if (m_Sequence.size() == 4)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
case Qt::Key_AltGr:
|
case Qt::Key_AltGr:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case Qt::Key_Control:
|
case Qt::Key_Control:
|
||||||
case Qt::Key_Alt:
|
case Qt::Key_Alt:
|
||||||
case Qt::Key_Shift:
|
case Qt::Key_Shift:
|
||||||
case Qt::Key_Meta:
|
case Qt::Key_Meta:
|
||||||
case Qt::Key_Menu:
|
case Qt::Key_Menu:
|
||||||
{
|
{
|
||||||
int mod = modifiers & (~m_Modifiers);
|
int mod = modifiers & (~m_Modifiers);
|
||||||
if (mod)
|
if (mod)
|
||||||
{
|
{
|
||||||
m_Sequence.append(mod);
|
m_Sequence.append(mod);
|
||||||
m_Modifiers |= mod;
|
m_Modifiers |= mod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// see if we can handle this key, if not, don't accept it
|
// see if we can handle this key, if not, don't accept it
|
||||||
if (keyToString(key).isEmpty())
|
if (keyToString(key).isEmpty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_Sequence.append(key);
|
m_Sequence.append(key);
|
||||||
setValid(true);
|
setValid(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequence::loadSettings(QSettings& settings)
|
void KeySequence::loadSettings(QSettings& settings)
|
||||||
{
|
{
|
||||||
sequence().clear();
|
sequence().clear();
|
||||||
int num = settings.beginReadArray("keys");
|
int num = settings.beginReadArray("keys");
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
sequence().append(settings.value("key", 0).toInt());
|
sequence().append(settings.value("key", 0).toInt());
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
|
|
||||||
setModifiers(0);
|
setModifiers(0);
|
||||||
setValid(true);
|
setValid(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequence::saveSettings(QSettings& settings) const
|
void KeySequence::saveSettings(QSettings& settings) const
|
||||||
{
|
{
|
||||||
settings.beginWriteArray("keys");
|
settings.beginWriteArray("keys");
|
||||||
for (int i = 0; i < sequence().size(); i++)
|
for (int i = 0; i < sequence().size(); i++)
|
||||||
{
|
{
|
||||||
settings.setArrayIndex(i);
|
settings.setArrayIndex(i);
|
||||||
settings.setValue("key", sequence()[i]);
|
settings.setValue("key", sequence()[i]);
|
||||||
}
|
}
|
||||||
settings.endArray();
|
settings.endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KeySequence::keyToString(int key)
|
QString KeySequence::keyToString(int key)
|
||||||
{
|
{
|
||||||
// nothing there?
|
// nothing there?
|
||||||
if (key == 0)
|
if (key == 0)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
// a hack to handle mouse buttons as if they were keys
|
// a hack to handle mouse buttons as if they were keys
|
||||||
if (key < Qt::Key_Space)
|
if (key < Qt::Key_Space)
|
||||||
{
|
{
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
case Qt::LeftButton: return "1";
|
case Qt::LeftButton: return "1";
|
||||||
case Qt::RightButton: return "2";
|
case Qt::RightButton: return "2";
|
||||||
case Qt::MidButton: return "3";
|
case Qt::MidButton: return "3";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "4"; // qt only knows three mouse buttons, so assume it's an unknown fourth one
|
return "4"; // qt only knows three mouse buttons, so assume it's an unknown fourth one
|
||||||
}
|
}
|
||||||
|
|
||||||
// modifiers?
|
// modifiers?
|
||||||
if (key & Qt::ShiftModifier)
|
if (key & Qt::ShiftModifier)
|
||||||
return "Shift";
|
return "Shift";
|
||||||
|
|
||||||
if (key & Qt::ControlModifier)
|
if (key & Qt::ControlModifier)
|
||||||
return "Control";
|
return "Control";
|
||||||
|
|
||||||
if (key & Qt::AltModifier)
|
if (key & Qt::AltModifier)
|
||||||
return "Alt";
|
return "Alt";
|
||||||
|
|
||||||
if (key & Qt::MetaModifier)
|
if (key & Qt::MetaModifier)
|
||||||
return "Meta";
|
return "Meta";
|
||||||
|
|
||||||
// treat key pad like normal keys (FIXME: we should have another lookup table for keypad keys instead)
|
// treat key pad like normal keys (FIXME: we should have another lookup table for keypad keys instead)
|
||||||
key &= ~Qt::KeypadModifier;
|
key &= ~Qt::KeypadModifier;
|
||||||
|
|
||||||
// a printable 7 bit character?
|
// a printable 7 bit character?
|
||||||
if (key < 0x80 && key != Qt::Key_Space)
|
if (key < 0x80 && key != Qt::Key_Space)
|
||||||
return QChar(key & 0x7f).toLower();
|
return QChar(key & 0x7f).toLower();
|
||||||
|
|
||||||
// a function key?
|
// a function key?
|
||||||
if (key >= Qt::Key_F1 && key <= Qt::Key_F35)
|
if (key >= Qt::Key_F1 && key <= Qt::Key_F35)
|
||||||
return QString::fromUtf8("F%1").arg(key - Qt::Key_F1 + 1);
|
return QString::fromUtf8("F%1").arg(key - Qt::Key_F1 + 1);
|
||||||
|
|
||||||
// a special key?
|
// a special key?
|
||||||
int i=0;
|
int i=0;
|
||||||
while (keyname[i].name)
|
while (keyname[i].name)
|
||||||
{
|
{
|
||||||
if (key == keyname[i].key)
|
if (key == keyname[i].key)
|
||||||
return QString::fromUtf8(keyname[i].name);
|
return QString::fromUtf8(keyname[i].name);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// representable in ucs2?
|
// representable in ucs2?
|
||||||
if (key < 0x10000)
|
if (key < 0x10000)
|
||||||
return QString("\\u%1").arg(QChar(key).toLower().unicode(), 4, 16, QChar('0'));
|
return QString("\\u%1").arg(QChar(key).toLower().unicode(), 4, 16, QChar('0'));
|
||||||
|
|
||||||
// give up, synergy probably won't handle this
|
// give up, synergy probably won't handle this
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,31 +27,31 @@ class QSettings;
|
||||||
|
|
||||||
class KeySequence
|
class KeySequence
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeySequence();
|
KeySequence();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
bool appendKey(int modifiers, int key);
|
bool appendKey(int modifiers, int key);
|
||||||
bool appendMouseButton(int button);
|
bool appendMouseButton(int button);
|
||||||
bool isMouseButton() const;
|
bool isMouseButton() const;
|
||||||
bool valid() const { return m_IsValid; }
|
bool valid() const { return m_IsValid; }
|
||||||
int modifiers() const { return m_Modifiers; }
|
int modifiers() const { return m_Modifiers; }
|
||||||
void saveSettings(QSettings& settings) const;
|
void saveSettings(QSettings& settings) const;
|
||||||
void loadSettings(QSettings& settings);
|
void loadSettings(QSettings& settings);
|
||||||
const QList<int>& sequence() const { return m_Sequence; }
|
const QList<int>& sequence() const { return m_Sequence; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setValid(bool b) { m_IsValid = b; }
|
void setValid(bool b) { m_IsValid = b; }
|
||||||
void setModifiers(int i) { m_Modifiers = i; }
|
void setModifiers(int i) { m_Modifiers = i; }
|
||||||
QList<int>& sequence() { return m_Sequence; }
|
QList<int>& sequence() { return m_Sequence; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<int> m_Sequence;
|
QList<int> m_Sequence;
|
||||||
int m_Modifiers;
|
int m_Modifiers;
|
||||||
bool m_IsValid;
|
bool m_IsValid;
|
||||||
|
|
||||||
static QString keyToString(int key);
|
static QString keyToString(int key);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,124 +22,124 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
||||||
KeySequenceWidget::KeySequenceWidget(QWidget* parent, const KeySequence& seq) :
|
KeySequenceWidget::KeySequenceWidget(QWidget* parent, const KeySequence& seq) :
|
||||||
QPushButton(parent),
|
QPushButton(parent),
|
||||||
m_KeySequence(seq),
|
m_KeySequence(seq),
|
||||||
m_BackupSequence(seq),
|
m_BackupSequence(seq),
|
||||||
m_Status(Stopped),
|
m_Status(Stopped),
|
||||||
m_MousePrefix("mousebutton("),
|
m_MousePrefix("mousebutton("),
|
||||||
m_MousePostfix(")"),
|
m_MousePostfix(")"),
|
||||||
m_KeyPrefix("keystroke("),
|
m_KeyPrefix("keystroke("),
|
||||||
m_KeyPostfix(")")
|
m_KeyPostfix(")")
|
||||||
{
|
{
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
updateOutput();
|
updateOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequenceWidget::setKeySequence(const KeySequence& seq)
|
void KeySequenceWidget::setKeySequence(const KeySequence& seq)
|
||||||
{
|
{
|
||||||
keySequence() = seq;
|
keySequence() = seq;
|
||||||
backupSequence() = seq;
|
backupSequence() = seq;
|
||||||
|
|
||||||
setStatus(Stopped);
|
setStatus(Stopped);
|
||||||
updateOutput();
|
updateOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequenceWidget::mousePressEvent(QMouseEvent* event)
|
void KeySequenceWidget::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
if (status() == Stopped)
|
if (status() == Stopped)
|
||||||
{
|
{
|
||||||
startRecording();
|
startRecording();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_KeySequence.appendMouseButton(event->button()))
|
if (m_KeySequence.appendMouseButton(event->button()))
|
||||||
stopRecording();
|
stopRecording();
|
||||||
|
|
||||||
updateOutput();
|
updateOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequenceWidget::startRecording()
|
void KeySequenceWidget::startRecording()
|
||||||
{
|
{
|
||||||
keySequence() = KeySequence();
|
keySequence() = KeySequence();
|
||||||
setDown(true);
|
setDown(true);
|
||||||
setFocus();
|
setFocus();
|
||||||
grabKeyboard();
|
grabKeyboard();
|
||||||
setStatus(Recording);
|
setStatus(Recording);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequenceWidget::stopRecording()
|
void KeySequenceWidget::stopRecording()
|
||||||
{
|
{
|
||||||
if (!keySequence().valid())
|
if (!keySequence().valid())
|
||||||
{
|
{
|
||||||
keySequence() = backupSequence();
|
keySequence() = backupSequence();
|
||||||
updateOutput();
|
updateOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
setDown(false);
|
setDown(false);
|
||||||
focusNextChild();
|
focusNextChild();
|
||||||
releaseKeyboard();
|
releaseKeyboard();
|
||||||
setStatus(Stopped);
|
setStatus(Stopped);
|
||||||
emit keySequenceChanged();
|
emit keySequenceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeySequenceWidget::event(QEvent* event)
|
bool KeySequenceWidget::event(QEvent* event)
|
||||||
{
|
{
|
||||||
if (status() == Recording)
|
if (status() == Recording)
|
||||||
{
|
{
|
||||||
switch(event->type())
|
switch(event->type())
|
||||||
{
|
{
|
||||||
case QEvent::KeyPress:
|
case QEvent::KeyPress:
|
||||||
keyPressEvent(static_cast<QKeyEvent*>(event));
|
keyPressEvent(static_cast<QKeyEvent*>(event));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case QEvent::ShortcutOverride:
|
case QEvent::ShortcutOverride:
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case QEvent::FocusOut:
|
case QEvent::FocusOut:
|
||||||
stopRecording();
|
stopRecording();
|
||||||
if (!valid())
|
if (!valid())
|
||||||
{
|
{
|
||||||
keySequence() = backupSequence();
|
keySequence() = backupSequence();
|
||||||
updateOutput();
|
updateOutput();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPushButton::event(event);
|
return QPushButton::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequenceWidget::keyPressEvent(QKeyEvent* event)
|
void KeySequenceWidget::keyPressEvent(QKeyEvent* event)
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
if (status() == Stopped)
|
if (status() == Stopped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_KeySequence.appendKey(event->key(), event->modifiers()))
|
if (m_KeySequence.appendKey(event->key(), event->modifiers()))
|
||||||
stopRecording();
|
stopRecording();
|
||||||
|
|
||||||
updateOutput();
|
updateOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeySequenceWidget::updateOutput()
|
void KeySequenceWidget::updateOutput()
|
||||||
{
|
{
|
||||||
QString s;
|
QString s;
|
||||||
|
|
||||||
if (m_KeySequence.isMouseButton())
|
if (m_KeySequence.isMouseButton())
|
||||||
s = mousePrefix() + m_KeySequence.toString() + mousePostfix();
|
s = mousePrefix() + m_KeySequence.toString() + mousePostfix();
|
||||||
else
|
else
|
||||||
s = keyPrefix() + m_KeySequence.toString() + keyPostfix();
|
s = keyPrefix() + m_KeySequence.toString() + keyPostfix();
|
||||||
|
|
||||||
setText(s);
|
setText(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,55 +26,55 @@
|
||||||
|
|
||||||
class KeySequenceWidget : public QPushButton
|
class KeySequenceWidget : public QPushButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KeySequenceWidget(QWidget* parent, const KeySequence& seq = KeySequence());
|
KeySequenceWidget(QWidget* parent, const KeySequence& seq = KeySequence());
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void keySequenceChanged();
|
void keySequenceChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QString& mousePrefix() const { return m_MousePrefix; }
|
const QString& mousePrefix() const { return m_MousePrefix; }
|
||||||
const QString& mousePostfix() const { return m_MousePostfix; }
|
const QString& mousePostfix() const { return m_MousePostfix; }
|
||||||
const QString& keyPrefix() const { return m_KeyPrefix; }
|
const QString& keyPrefix() const { return m_KeyPrefix; }
|
||||||
const QString& keyPostfix() const { return m_KeyPostfix; }
|
const QString& keyPostfix() const { return m_KeyPostfix; }
|
||||||
|
|
||||||
void setMousePrefix(const QString& s) { m_MousePrefix = s; }
|
void setMousePrefix(const QString& s) { m_MousePrefix = s; }
|
||||||
void setMousePostfix(const QString& s) { m_MousePostfix = s; }
|
void setMousePostfix(const QString& s) { m_MousePostfix = s; }
|
||||||
void setKeyPrefix(const QString& s) { m_KeyPrefix = s; }
|
void setKeyPrefix(const QString& s) { m_KeyPrefix = s; }
|
||||||
void setKeyPostfix(const QString& s) { m_KeyPostfix = s; }
|
void setKeyPostfix(const QString& s) { m_KeyPostfix = s; }
|
||||||
|
|
||||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||||
const KeySequence& backupSequence() const { return m_BackupSequence; }
|
const KeySequence& backupSequence() const { return m_BackupSequence; }
|
||||||
void setKeySequence(const KeySequence& seq);
|
void setKeySequence(const KeySequence& seq);
|
||||||
|
|
||||||
bool valid() const { return keySequence().valid(); }
|
bool valid() const { return keySequence().valid(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent*);
|
void mousePressEvent(QMouseEvent*);
|
||||||
void keyPressEvent(QKeyEvent*);
|
void keyPressEvent(QKeyEvent*);
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
void appendToSequence(int key);
|
void appendToSequence(int key);
|
||||||
void updateOutput();
|
void updateOutput();
|
||||||
void startRecording();
|
void startRecording();
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
KeySequence& keySequence() { return m_KeySequence; }
|
KeySequence& keySequence() { return m_KeySequence; }
|
||||||
KeySequence& backupSequence() { return m_BackupSequence; }
|
KeySequence& backupSequence() { return m_BackupSequence; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Status { Stopped, Recording };
|
enum Status { Stopped, Recording };
|
||||||
void setStatus(Status s) { m_Status = s; }
|
void setStatus(Status s) { m_Status = s; }
|
||||||
Status status() const { return m_Status; }
|
Status status() const { return m_Status; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeySequence m_KeySequence;
|
KeySequence m_KeySequence;
|
||||||
KeySequence m_BackupSequence;
|
KeySequence m_BackupSequence;
|
||||||
Status m_Status;
|
Status m_Status;
|
||||||
QString m_MousePrefix;
|
QString m_MousePrefix;
|
||||||
QString m_MousePostfix;
|
QString m_MousePostfix;
|
||||||
QString m_KeyPrefix;
|
QString m_KeyPrefix;
|
||||||
QString m_KeyPostfix;
|
QString m_KeyPostfix;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,28 +26,28 @@ class AppConfig;
|
||||||
|
|
||||||
class LicenseManager: public QObject
|
class LicenseManager: public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LicenseManager(AppConfig* appConfig);
|
LicenseManager(AppConfig* appConfig);
|
||||||
std::pair<bool, QString> setSerialKey(SerialKey serialKey,
|
std::pair<bool, QString> setSerialKey(SerialKey serialKey,
|
||||||
bool acceptExpired = false);
|
bool acceptExpired = false);
|
||||||
void refresh();
|
void refresh();
|
||||||
Edition activeEdition() const;
|
Edition activeEdition() const;
|
||||||
QString activeEditionName() const;
|
QString activeEditionName() const;
|
||||||
SerialKey serialKey() const;
|
SerialKey serialKey() const;
|
||||||
void skipActivation();
|
void skipActivation();
|
||||||
void notifyUpdate(QString fromVersion, QString toVersion);
|
void notifyUpdate(QString fromVersion, QString toVersion);
|
||||||
static QString getEditionName(Edition edition, bool trial = false);
|
static QString getEditionName(Edition edition, bool trial = false);
|
||||||
void notifyActivation(QString identity);
|
void notifyActivation(QString identity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppConfig* m_AppConfig;
|
AppConfig* m_AppConfig;
|
||||||
SerialKey m_serialKey;
|
SerialKey m_serialKey;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void serialKeyChanged (SerialKey) const;
|
void serialKeyChanged (SerialKey) const;
|
||||||
void editionChanged (Edition) const;
|
void editionChanged (Edition) const;
|
||||||
void beginTrial (bool expiring) const;
|
void beginTrial (bool expiring) const;
|
||||||
void endTrial (bool expired) const;
|
void endTrial (bool expired) const;
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -62,179 +62,179 @@ class LicenseManager;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class QSynergyApplication;
|
friend class QSynergyApplication;
|
||||||
friend class SetupWizard;
|
friend class SetupWizard;
|
||||||
friend class ActivationDialog;
|
friend class ActivationDialog;
|
||||||
friend class SettingsDialog;
|
friend class SettingsDialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum qSynergyState
|
enum qSynergyState
|
||||||
{
|
{
|
||||||
synergyDisconnected,
|
synergyDisconnected,
|
||||||
synergyConnecting,
|
synergyConnecting,
|
||||||
synergyConnected,
|
synergyConnected,
|
||||||
synergyTransfering
|
synergyTransfering
|
||||||
};
|
};
|
||||||
|
|
||||||
enum qSynergyType
|
enum qSynergyType
|
||||||
{
|
{
|
||||||
synergyClient,
|
synergyClient,
|
||||||
synergyServer
|
synergyServer
|
||||||
};
|
};
|
||||||
|
|
||||||
enum qLevel {
|
enum qLevel {
|
||||||
Error,
|
Error,
|
||||||
Info
|
Info
|
||||||
};
|
};
|
||||||
|
|
||||||
enum qRuningState {
|
enum qRuningState {
|
||||||
kStarted,
|
kStarted,
|
||||||
kStopped
|
kStopped
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QSettings& settings, AppConfig& appConfig,
|
MainWindow(QSettings& settings, AppConfig& appConfig,
|
||||||
LicenseManager& licenseManager);
|
LicenseManager& licenseManager);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
int synergyType() const { return m_pGroupClient->isChecked() ? synergyClient : synergyServer; }
|
int synergyType() const { return m_pGroupClient->isChecked() ? synergyClient : synergyServer; }
|
||||||
int synergyState() const { return m_SynergyState; }
|
int synergyState() const { return m_SynergyState; }
|
||||||
QString hostname() const { return m_pLineEditHostname->text(); }
|
QString hostname() const { return m_pLineEditHostname->text(); }
|
||||||
QString configFilename();
|
QString configFilename();
|
||||||
QString address();
|
QString address();
|
||||||
QString appPath(const QString& name);
|
QString appPath(const QString& name);
|
||||||
void open();
|
void open();
|
||||||
void clearLog();
|
void clearLog();
|
||||||
VersionChecker& versionChecker() { return m_VersionChecker; }
|
VersionChecker& versionChecker() { return m_VersionChecker; }
|
||||||
QString getScreenName();
|
QString getScreenName();
|
||||||
ServerConfig& serverConfig() { return m_ServerConfig; }
|
ServerConfig& serverConfig() { return m_ServerConfig; }
|
||||||
void showConfigureServer(const QString& message);
|
void showConfigureServer(const QString& message);
|
||||||
void showConfigureServer() { showConfigureServer(""); }
|
void showConfigureServer() { showConfigureServer(""); }
|
||||||
void autoAddScreen(const QString name);
|
void autoAddScreen(const QString name);
|
||||||
void updateZeroconfService();
|
void updateZeroconfService();
|
||||||
void serverDetected(const QString name);
|
void serverDetected(const QString name);
|
||||||
void updateLocalFingerprint();
|
void updateLocalFingerprint();
|
||||||
LicenseManager& licenseManager() const;
|
LicenseManager& licenseManager() const;
|
||||||
|
|
||||||
int raiseActivationDialog();
|
int raiseActivationDialog();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setEdition(Edition edition);
|
void setEdition(Edition edition);
|
||||||
void beginTrial(bool isExpiring);
|
void beginTrial(bool isExpiring);
|
||||||
void endTrial(bool isExpired);
|
void endTrial(bool isExpired);
|
||||||
void appendLogRaw(const QString& text);
|
void appendLogRaw(const QString& text);
|
||||||
void appendLogInfo(const QString& text);
|
void appendLogInfo(const QString& text);
|
||||||
void appendLogDebug(const QString& text);
|
void appendLogDebug(const QString& text);
|
||||||
void appendLogError(const QString& text);
|
void appendLogError(const QString& text);
|
||||||
void startSynergy();
|
void startSynergy();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void sslToggled(bool enabled);
|
void sslToggled(bool enabled);
|
||||||
void on_m_pGroupClient_toggled(bool on);
|
void on_m_pGroupClient_toggled(bool on);
|
||||||
void on_m_pGroupServer_toggled(bool on);
|
void on_m_pGroupServer_toggled(bool on);
|
||||||
bool on_m_pButtonBrowseConfigFile_clicked();
|
bool on_m_pButtonBrowseConfigFile_clicked();
|
||||||
void on_m_pButtonConfigureServer_clicked();
|
void on_m_pButtonConfigureServer_clicked();
|
||||||
bool on_m_pActionSave_triggered();
|
bool on_m_pActionSave_triggered();
|
||||||
void on_m_pActionAbout_triggered();
|
void on_m_pActionAbout_triggered();
|
||||||
void on_m_pActionSettings_triggered();
|
void on_m_pActionSettings_triggered();
|
||||||
void on_m_pActivate_triggered();
|
void on_m_pActivate_triggered();
|
||||||
void synergyFinished(int exitCode, QProcess::ExitStatus);
|
void synergyFinished(int exitCode, QProcess::ExitStatus);
|
||||||
void trayActivated(QSystemTrayIcon::ActivationReason reason);
|
void trayActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
void stopSynergy();
|
void stopSynergy();
|
||||||
void logOutput();
|
void logOutput();
|
||||||
void logError();
|
void logError();
|
||||||
void updateFound(const QString& version);
|
void updateFound(const QString& version);
|
||||||
void bonjourInstallFinished();
|
void bonjourInstallFinished();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSettings& settings() { return m_Settings; }
|
QSettings& settings() { return m_Settings; }
|
||||||
AppConfig& appConfig() { return *m_AppConfig; }
|
AppConfig& appConfig() { return *m_AppConfig; }
|
||||||
QProcess* synergyProcess() { return m_pSynergy; }
|
QProcess* synergyProcess() { return m_pSynergy; }
|
||||||
void setSynergyProcess(QProcess* p) { m_pSynergy = p; }
|
void setSynergyProcess(QProcess* p) { m_pSynergy = p; }
|
||||||
void initConnections();
|
void initConnections();
|
||||||
void createMenuBar();
|
void createMenuBar();
|
||||||
void createStatusBar();
|
void createStatusBar();
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
void setIcon(qSynergyState state);
|
void setIcon(qSynergyState state);
|
||||||
void setSynergyState(qSynergyState state);
|
void setSynergyState(qSynergyState state);
|
||||||
bool checkForApp(int which, QString& app);
|
bool checkForApp(int which, QString& app);
|
||||||
bool clientArgs(QStringList& args, QString& app);
|
bool clientArgs(QStringList& args, QString& app);
|
||||||
bool serverArgs(QStringList& args, QString& app);
|
bool serverArgs(QStringList& args, QString& app);
|
||||||
void setStatus(const QString& status);
|
void setStatus(const QString& status);
|
||||||
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
||||||
void onModeChanged(bool startDesktop, bool applyService);
|
void onModeChanged(bool startDesktop, bool applyService);
|
||||||
void updateFromLogLine(const QString& line);
|
void updateFromLogLine(const QString& line);
|
||||||
QString getIPAddresses();
|
QString getIPAddresses();
|
||||||
void stopService();
|
void stopService();
|
||||||
void stopDesktop();
|
void stopDesktop();
|
||||||
void changeEvent(QEvent* event);
|
void changeEvent(QEvent* event);
|
||||||
void retranslateMenuBar();
|
void retranslateMenuBar();
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
bool isServiceRunning(QString name);
|
bool isServiceRunning(QString name);
|
||||||
#else
|
#else
|
||||||
bool isServiceRunning();
|
bool isServiceRunning();
|
||||||
#endif
|
#endif
|
||||||
bool isBonjourRunning();
|
bool isBonjourRunning();
|
||||||
void downloadBonjour();
|
void downloadBonjour();
|
||||||
void promptAutoConfig();
|
void promptAutoConfig();
|
||||||
QString getProfileRootForArg();
|
QString getProfileRootForArg();
|
||||||
void checkConnected(const QString& line);
|
void checkConnected(const QString& line);
|
||||||
void checkLicense(const QString& line);
|
void checkLicense(const QString& line);
|
||||||
void checkFingerprint(const QString& line);
|
void checkFingerprint(const QString& line);
|
||||||
bool autoHide();
|
bool autoHide();
|
||||||
QString getTimeStamp();
|
QString getTimeStamp();
|
||||||
void restartSynergy();
|
void restartSynergy();
|
||||||
void proofreadInfo();
|
void proofreadInfo();
|
||||||
|
|
||||||
void showEvent (QShowEvent*);
|
void showEvent (QShowEvent*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings& m_Settings;
|
QSettings& m_Settings;
|
||||||
AppConfig* m_AppConfig;
|
AppConfig* m_AppConfig;
|
||||||
LicenseManager* m_LicenseManager;
|
LicenseManager* m_LicenseManager;
|
||||||
QProcess* m_pSynergy;
|
QProcess* m_pSynergy;
|
||||||
int m_SynergyState;
|
int m_SynergyState;
|
||||||
ServerConfig m_ServerConfig;
|
ServerConfig m_ServerConfig;
|
||||||
QTemporaryFile* m_pTempConfigFile;
|
QTemporaryFile* m_pTempConfigFile;
|
||||||
QSystemTrayIcon* m_pTrayIcon;
|
QSystemTrayIcon* m_pTrayIcon;
|
||||||
QMenu* m_pTrayIconMenu;
|
QMenu* m_pTrayIconMenu;
|
||||||
bool m_AlreadyHidden;
|
bool m_AlreadyHidden;
|
||||||
VersionChecker m_VersionChecker;
|
VersionChecker m_VersionChecker;
|
||||||
IpcClient m_IpcClient;
|
IpcClient m_IpcClient;
|
||||||
QMenuBar* m_pMenuBar;
|
QMenuBar* m_pMenuBar;
|
||||||
QMenu* m_pMenuFile;
|
QMenu* m_pMenuFile;
|
||||||
QMenu* m_pMenuEdit;
|
QMenu* m_pMenuEdit;
|
||||||
QMenu* m_pMenuWindow;
|
QMenu* m_pMenuWindow;
|
||||||
QMenu* m_pMenuHelp;
|
QMenu* m_pMenuHelp;
|
||||||
ZeroconfService* m_pZeroconfService;
|
ZeroconfService* m_pZeroconfService;
|
||||||
DataDownloader* m_pDataDownloader;
|
DataDownloader* m_pDataDownloader;
|
||||||
QMessageBox* m_DownloadMessageBox;
|
QMessageBox* m_DownloadMessageBox;
|
||||||
QAbstractButton* m_pCancelButton;
|
QAbstractButton* m_pCancelButton;
|
||||||
QMutex m_UpdateZeroconfMutex;
|
QMutex m_UpdateZeroconfMutex;
|
||||||
bool m_SuppressAutoConfigWarning;
|
bool m_SuppressAutoConfigWarning;
|
||||||
CommandProcess* m_BonjourInstall;
|
CommandProcess* m_BonjourInstall;
|
||||||
bool m_SuppressEmptyServerWarning;
|
bool m_SuppressEmptyServerWarning;
|
||||||
qRuningState m_ExpectedRunningState;
|
qRuningState m_ExpectedRunningState;
|
||||||
QMutex m_StopDesktopMutex;
|
QMutex m_StopDesktopMutex;
|
||||||
SslCertificate* m_pSslCertificate;
|
SslCertificate* m_pSslCertificate;
|
||||||
bool m_ActivationDialogRunning;
|
bool m_ActivationDialogRunning;
|
||||||
QStringList m_PendingClientNames;
|
QStringList m_PendingClientNames;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_pCheckBoxAutoConfig_toggled(bool checked);
|
void on_m_pCheckBoxAutoConfig_toggled(bool checked);
|
||||||
void on_m_pComboServerList_currentIndexChanged(QString );
|
void on_m_pComboServerList_currentIndexChanged(QString );
|
||||||
void on_m_pButtonApply_clicked();
|
void on_m_pButtonApply_clicked();
|
||||||
void installBonjour();
|
void installBonjour();
|
||||||
void on_windowShown();
|
void on_windowShown();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void windowShown();
|
void windowShown();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,26 +23,26 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
NewScreenWidget::NewScreenWidget(QWidget* parent) :
|
NewScreenWidget::NewScreenWidget(QWidget* parent) :
|
||||||
QLabel(parent)
|
QLabel(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewScreenWidget::mousePressEvent(QMouseEvent* event)
|
void NewScreenWidget::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
Screen newScreen(tr("Unnamed"));
|
Screen newScreen(tr("Unnamed"));
|
||||||
|
|
||||||
QByteArray itemData;
|
QByteArray itemData;
|
||||||
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
||||||
dataStream << -1 << -1 << newScreen;
|
dataStream << -1 << -1 << newScreen;
|
||||||
|
|
||||||
QMimeData* pMimeData = new QMimeData;
|
QMimeData* pMimeData = new QMimeData;
|
||||||
pMimeData->setData(ScreenSetupModel::mimeType(), itemData);
|
pMimeData->setData(ScreenSetupModel::mimeType(), itemData);
|
||||||
|
|
||||||
QDrag* pDrag = new QDrag(this);
|
QDrag* pDrag = new QDrag(this);
|
||||||
pDrag->setMimeData(pMimeData);
|
pDrag->setMimeData(pMimeData);
|
||||||
pDrag->setPixmap(*pixmap());
|
pDrag->setPixmap(*pixmap());
|
||||||
pDrag->setHotSpot(event->pos());
|
pDrag->setHotSpot(event->pos());
|
||||||
|
|
||||||
pDrag->exec(Qt::CopyAction, Qt::CopyAction);
|
pDrag->exec(Qt::CopyAction, Qt::CopyAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,13 @@ class QWidget;
|
||||||
|
|
||||||
class NewScreenWidget : public QLabel
|
class NewScreenWidget : public QLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NewScreenWidget(QWidget* parent);
|
NewScreenWidget(QWidget* parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,11 +18,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
enum qProcessorArch {
|
enum qProcessorArch {
|
||||||
kProcessorArchWin32,
|
kProcessorArchWin32,
|
||||||
kProcessorArchWin64,
|
kProcessorArchWin64,
|
||||||
kProcessorArchMac32,
|
kProcessorArchMac32,
|
||||||
kProcessorArchMac64,
|
kProcessorArchMac64,
|
||||||
kProcessorArchLinux32,
|
kProcessorArchLinux32,
|
||||||
kProcessorArchLinux64,
|
kProcessorArchLinux64,
|
||||||
kProcessorArchUnknown
|
kProcessorArchUnknown
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,48 +25,48 @@
|
||||||
QSynergyApplication* QSynergyApplication::s_Instance = NULL;
|
QSynergyApplication* QSynergyApplication::s_Instance = NULL;
|
||||||
|
|
||||||
QSynergyApplication::QSynergyApplication(int& argc, char** argv) :
|
QSynergyApplication::QSynergyApplication(int& argc, char** argv) :
|
||||||
QApplication(argc, argv),
|
QApplication(argc, argv),
|
||||||
m_Translator(NULL)
|
m_Translator(NULL)
|
||||||
{
|
{
|
||||||
s_Instance = this;
|
s_Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSynergyApplication::~QSynergyApplication()
|
QSynergyApplication::~QSynergyApplication()
|
||||||
{
|
{
|
||||||
delete m_Translator;
|
delete m_Translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynergyApplication::commitData(QSessionManager&)
|
void QSynergyApplication::commitData(QSessionManager&)
|
||||||
{
|
{
|
||||||
foreach(QWidget* widget, topLevelWidgets())
|
foreach(QWidget* widget, topLevelWidgets())
|
||||||
{
|
{
|
||||||
MainWindow* mainWindow = qobject_cast<MainWindow*>(widget);
|
MainWindow* mainWindow = qobject_cast<MainWindow*>(widget);
|
||||||
if (mainWindow)
|
if (mainWindow)
|
||||||
mainWindow->saveSettings();
|
mainWindow->saveSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSynergyApplication* QSynergyApplication::getInstance()
|
QSynergyApplication* QSynergyApplication::getInstance()
|
||||||
{
|
{
|
||||||
return s_Instance;
|
return s_Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynergyApplication::switchTranslator(QString lang)
|
void QSynergyApplication::switchTranslator(QString lang)
|
||||||
{
|
{
|
||||||
if (m_Translator != NULL)
|
if (m_Translator != NULL)
|
||||||
{
|
{
|
||||||
removeTranslator(m_Translator);
|
removeTranslator(m_Translator);
|
||||||
delete m_Translator;
|
delete m_Translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
QResource locale(":/res/lang/gui_" + lang + ".qm");
|
QResource locale(":/res/lang/gui_" + lang + ".qm");
|
||||||
m_Translator = new QTranslator();
|
m_Translator = new QTranslator();
|
||||||
m_Translator->load(locale.data(), locale.size());
|
m_Translator->load(locale.data(), locale.size());
|
||||||
installTranslator(m_Translator);
|
installTranslator(m_Translator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynergyApplication::setTranslator(QTranslator* translator)
|
void QSynergyApplication::setTranslator(QTranslator* translator)
|
||||||
{
|
{
|
||||||
m_Translator = translator;
|
m_Translator = translator;
|
||||||
installTranslator(m_Translator);
|
installTranslator(m_Translator);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,21 +26,21 @@ class QSessionManager;
|
||||||
|
|
||||||
class QSynergyApplication : public QApplication
|
class QSynergyApplication : public QApplication
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QSynergyApplication(int& argc, char** argv);
|
QSynergyApplication(int& argc, char** argv);
|
||||||
~QSynergyApplication();
|
~QSynergyApplication();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void commitData(QSessionManager& manager);
|
void commitData(QSessionManager& manager);
|
||||||
void switchTranslator(QString lang);
|
void switchTranslator(QString lang);
|
||||||
void setTranslator(QTranslator* translator);
|
void setTranslator(QTranslator* translator);
|
||||||
|
|
||||||
static QSynergyApplication* getInstance();
|
static QSynergyApplication* getInstance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTranslator* m_Translator;
|
QTranslator* m_Translator;
|
||||||
|
|
||||||
static QSynergyApplication* s_Instance;
|
static QSynergyApplication* s_Instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,85 +32,85 @@
|
||||||
|
|
||||||
void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData)
|
void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < comboBox->count(); ++i)
|
for (int i = 0; i < comboBox->count(); ++i)
|
||||||
{
|
{
|
||||||
if (comboBox->itemData(i) == itemData)
|
if (comboBox->itemData(i) == itemData)
|
||||||
{
|
{
|
||||||
comboBox->setCurrentIndex(i);
|
comboBox->setCurrentIndex(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString hash(const QString& string)
|
QString hash(const QString& string)
|
||||||
{
|
{
|
||||||
QByteArray data = string.toUtf8();
|
QByteArray data = string.toUtf8();
|
||||||
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5);
|
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5);
|
||||||
return hash.toHex();
|
return hash.toHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getFirstMacAddress()
|
QString getFirstMacAddress()
|
||||||
{
|
{
|
||||||
QString mac;
|
QString mac;
|
||||||
foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces())
|
foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces())
|
||||||
{
|
{
|
||||||
mac = interface.hardwareAddress();
|
mac = interface.hardwareAddress();
|
||||||
if (mac.size() != 0)
|
if (mac.size() != 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mac;
|
return mac;
|
||||||
}
|
}
|
||||||
|
|
||||||
qProcessorArch getProcessorArch()
|
qProcessorArch getProcessorArch()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
SYSTEM_INFO systemInfo;
|
SYSTEM_INFO systemInfo;
|
||||||
GetNativeSystemInfo(&systemInfo);
|
GetNativeSystemInfo(&systemInfo);
|
||||||
|
|
||||||
switch (systemInfo.wProcessorArchitecture) {
|
switch (systemInfo.wProcessorArchitecture) {
|
||||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||||
return kProcessorArchWin32;
|
return kProcessorArchWin32;
|
||||||
case PROCESSOR_ARCHITECTURE_IA64:
|
case PROCESSOR_ARCHITECTURE_IA64:
|
||||||
return kProcessorArchWin64;
|
return kProcessorArchWin64;
|
||||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||||
return kProcessorArchWin64;
|
return kProcessorArchWin64;
|
||||||
default:
|
default:
|
||||||
return kProcessorArchUnknown;
|
return kProcessorArchUnknown;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
return kProcessorArchLinux32;
|
return kProcessorArchLinux32;
|
||||||
#else
|
#else
|
||||||
return kProcessorArchLinux64;
|
return kProcessorArchLinux64;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return kProcessorArchUnknown;
|
return kProcessorArchUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getOSInformation()
|
QString getOSInformation()
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
result = "Linux";
|
result = "Linux";
|
||||||
try {
|
try {
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments.append("/etc/os-release");
|
arguments.append("/etc/os-release");
|
||||||
CommandProcess cp("/bin/cat", arguments);
|
CommandProcess cp("/bin/cat", arguments);
|
||||||
QString output = cp.run();
|
QString output = cp.run();
|
||||||
|
|
||||||
QRegExp resultRegex(".*PRETTY_NAME=\"([^\"]+)\".*");
|
QRegExp resultRegex(".*PRETTY_NAME=\"([^\"]+)\".*");
|
||||||
if (resultRegex.exactMatch(output)) {
|
if (resultRegex.exactMatch(output)) {
|
||||||
result = resultRegex.cap(1);
|
result = resultRegex.cap(1);
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,126 +22,126 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
Screen::Screen() :
|
Screen::Screen() :
|
||||||
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
||||||
m_Swapped(false)
|
m_Swapped(false)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Screen::Screen(const QString& name) :
|
Screen::Screen(const QString& name) :
|
||||||
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
||||||
m_Swapped(false)
|
m_Swapped(false)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::init()
|
void Screen::init()
|
||||||
{
|
{
|
||||||
name().clear();
|
name().clear();
|
||||||
aliases().clear();
|
aliases().clear();
|
||||||
modifiers().clear();
|
modifiers().clear();
|
||||||
switchCorners().clear();
|
switchCorners().clear();
|
||||||
fixes().clear();
|
fixes().clear();
|
||||||
setSwitchCornerSize(0);
|
setSwitchCornerSize(0);
|
||||||
|
|
||||||
// m_Modifiers, m_SwitchCorners and m_Fixes are QLists we use like fixed-size arrays,
|
// m_Modifiers, m_SwitchCorners and m_Fixes are QLists we use like fixed-size arrays,
|
||||||
// thus we need to make sure to fill them with the required number of elements.
|
// thus we need to make sure to fill them with the required number of elements.
|
||||||
for (int i = 0; i < NumModifiers; i++)
|
for (int i = 0; i < NumModifiers; i++)
|
||||||
modifiers() << i;
|
modifiers() << i;
|
||||||
|
|
||||||
for (int i = 0; i < NumSwitchCorners; i++)
|
for (int i = 0; i < NumSwitchCorners; i++)
|
||||||
switchCorners() << false;
|
switchCorners() << false;
|
||||||
|
|
||||||
for (int i = 0; i < NumFixes; i++)
|
for (int i = 0; i < NumFixes; i++)
|
||||||
fixes() << false;
|
fixes() << false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::loadSettings(QSettings& settings)
|
void Screen::loadSettings(QSettings& settings)
|
||||||
{
|
{
|
||||||
setName(settings.value("name").toString());
|
setName(settings.value("name").toString());
|
||||||
|
|
||||||
if (name().isEmpty())
|
if (name().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setSwitchCornerSize(settings.value("switchCornerSize").toInt());
|
setSwitchCornerSize(settings.value("switchCornerSize").toInt());
|
||||||
|
|
||||||
readSettings(settings, aliases(), "alias", QString(""));
|
readSettings(settings, aliases(), "alias", QString(""));
|
||||||
readSettings(settings, modifiers(), "modifier", static_cast<int>(DefaultMod), NumModifiers);
|
readSettings(settings, modifiers(), "modifier", static_cast<int>(DefaultMod), NumModifiers);
|
||||||
readSettings(settings, switchCorners(), "switchCorner", false, NumSwitchCorners);
|
readSettings(settings, switchCorners(), "switchCorner", false, NumSwitchCorners);
|
||||||
readSettings(settings, fixes(), "fix", false, NumFixes);
|
readSettings(settings, fixes(), "fix", false, NumFixes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::saveSettings(QSettings& settings) const
|
void Screen::saveSettings(QSettings& settings) const
|
||||||
{
|
{
|
||||||
settings.setValue("name", name());
|
settings.setValue("name", name());
|
||||||
|
|
||||||
if (name().isEmpty())
|
if (name().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
settings.setValue("switchCornerSize", switchCornerSize());
|
settings.setValue("switchCornerSize", switchCornerSize());
|
||||||
|
|
||||||
writeSettings(settings, aliases(), "alias");
|
writeSettings(settings, aliases(), "alias");
|
||||||
writeSettings(settings, modifiers(), "modifier");
|
writeSettings(settings, modifiers(), "modifier");
|
||||||
writeSettings(settings, switchCorners(), "switchCorner");
|
writeSettings(settings, switchCorners(), "switchCorner");
|
||||||
writeSettings(settings, fixes(), "fix");
|
writeSettings(settings, fixes(), "fix");
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream& Screen::writeScreensSection(QTextStream& outStream) const
|
QTextStream& Screen::writeScreensSection(QTextStream& outStream) const
|
||||||
{
|
{
|
||||||
outStream << "\t" << name() << ":" << endl;
|
outStream << "\t" << name() << ":" << endl;
|
||||||
|
|
||||||
for (int i = 0; i < modifiers().size(); i++)
|
for (int i = 0; i < modifiers().size(); i++)
|
||||||
if (modifier(i) != i)
|
if (modifier(i) != i)
|
||||||
outStream << "\t\t" << modifierName(i) << " = " << modifierName(modifier(i)) << endl;
|
outStream << "\t\t" << modifierName(i) << " = " << modifierName(modifier(i)) << endl;
|
||||||
|
|
||||||
for (int i = 0; i < fixes().size(); i++)
|
for (int i = 0; i < fixes().size(); i++)
|
||||||
outStream << "\t\t" << fixName(i) << " = " << (fixes()[i] ? "true" : "false") << endl;
|
outStream << "\t\t" << fixName(i) << " = " << (fixes()[i] ? "true" : "false") << endl;
|
||||||
|
|
||||||
outStream << "\t\t" << "switchCorners = none ";
|
outStream << "\t\t" << "switchCorners = none ";
|
||||||
for (int i = 0; i < switchCorners().size(); i++)
|
for (int i = 0; i < switchCorners().size(); i++)
|
||||||
if (switchCorners()[i])
|
if (switchCorners()[i])
|
||||||
outStream << "+" << switchCornerName(i) << " ";
|
outStream << "+" << switchCornerName(i) << " ";
|
||||||
outStream << endl;
|
outStream << endl;
|
||||||
|
|
||||||
outStream << "\t\t" << "switchCornerSize = " << switchCornerSize() << endl;
|
outStream << "\t\t" << "switchCornerSize = " << switchCornerSize() << endl;
|
||||||
|
|
||||||
return outStream;
|
return outStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream& Screen::writeAliasesSection(QTextStream& outStream) const
|
QTextStream& Screen::writeAliasesSection(QTextStream& outStream) const
|
||||||
{
|
{
|
||||||
if (!aliases().isEmpty())
|
if (!aliases().isEmpty())
|
||||||
{
|
{
|
||||||
outStream << "\t" << name() << ":" << endl;
|
outStream << "\t" << name() << ":" << endl;
|
||||||
|
|
||||||
foreach (const QString& alias, aliases())
|
foreach (const QString& alias, aliases())
|
||||||
outStream << "\t\t" << alias << endl;
|
outStream << "\t\t" << alias << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return outStream;
|
return outStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream& operator<<(QDataStream& outStream, const Screen& screen)
|
QDataStream& operator<<(QDataStream& outStream, const Screen& screen)
|
||||||
{
|
{
|
||||||
return outStream
|
return outStream
|
||||||
<< screen.name()
|
<< screen.name()
|
||||||
<< screen.switchCornerSize()
|
<< screen.switchCornerSize()
|
||||||
<< screen.aliases()
|
<< screen.aliases()
|
||||||
<< screen.modifiers()
|
<< screen.modifiers()
|
||||||
<< screen.switchCorners()
|
<< screen.switchCorners()
|
||||||
<< screen.fixes()
|
<< screen.fixes()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream& operator>>(QDataStream& inStream, Screen& screen)
|
QDataStream& operator>>(QDataStream& inStream, Screen& screen)
|
||||||
{
|
{
|
||||||
return inStream
|
return inStream
|
||||||
>> screen.m_Name
|
>> screen.m_Name
|
||||||
>> screen.m_SwitchCornerSize
|
>> screen.m_SwitchCornerSize
|
||||||
>> screen.m_Aliases
|
>> screen.m_Aliases
|
||||||
>> screen.m_Modifiers
|
>> screen.m_Modifiers
|
||||||
>> screen.m_SwitchCorners
|
>> screen.m_SwitchCorners
|
||||||
>> screen.m_Fixes
|
>> screen.m_Fixes
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,66 +34,66 @@ class ScreenSettingsDialog;
|
||||||
|
|
||||||
class Screen : public BaseConfig
|
class Screen : public BaseConfig
|
||||||
{
|
{
|
||||||
friend QDataStream& operator<<(QDataStream& outStream, const Screen& screen);
|
friend QDataStream& operator<<(QDataStream& outStream, const Screen& screen);
|
||||||
friend QDataStream& operator>>(QDataStream& inStream, Screen& screen);
|
friend QDataStream& operator>>(QDataStream& inStream, Screen& screen);
|
||||||
friend class ScreenSettingsDialog;
|
friend class ScreenSettingsDialog;
|
||||||
friend class ScreenSetupModel;
|
friend class ScreenSetupModel;
|
||||||
friend class ScreenSetupView;
|
friend class ScreenSetupView;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Screen();
|
Screen();
|
||||||
Screen(const QString& name);
|
Screen(const QString& name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QPixmap* pixmap() const { return &m_Pixmap; }
|
const QPixmap* pixmap() const { return &m_Pixmap; }
|
||||||
const QString& name() const { return m_Name; }
|
const QString& name() const { return m_Name; }
|
||||||
const QStringList& aliases() const { return m_Aliases; }
|
const QStringList& aliases() const { return m_Aliases; }
|
||||||
|
|
||||||
bool isNull() const { return m_Name.isEmpty(); }
|
bool isNull() const { return m_Name.isEmpty(); }
|
||||||
int modifier(int m) const { return m_Modifiers[m] == DefaultMod ? m : m_Modifiers[m]; }
|
int modifier(int m) const { return m_Modifiers[m] == DefaultMod ? m : m_Modifiers[m]; }
|
||||||
const QList<int>& modifiers() const { return m_Modifiers; }
|
const QList<int>& modifiers() const { return m_Modifiers; }
|
||||||
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
||||||
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
||||||
int switchCornerSize() const { return m_SwitchCornerSize; }
|
int switchCornerSize() const { return m_SwitchCornerSize; }
|
||||||
bool fix(Fix f) const { return m_Fixes[f]; }
|
bool fix(Fix f) const { return m_Fixes[f]; }
|
||||||
const QList<bool>& fixes() const { return m_Fixes; }
|
const QList<bool>& fixes() const { return m_Fixes; }
|
||||||
|
|
||||||
void loadSettings(QSettings& settings);
|
void loadSettings(QSettings& settings);
|
||||||
void saveSettings(QSettings& settings) const;
|
void saveSettings(QSettings& settings) const;
|
||||||
QTextStream& writeScreensSection(QTextStream& outStream) const;
|
QTextStream& writeScreensSection(QTextStream& outStream) const;
|
||||||
QTextStream& writeAliasesSection(QTextStream& outStream) const;
|
QTextStream& writeAliasesSection(QTextStream& outStream) const;
|
||||||
|
|
||||||
bool swapped() const { return m_Swapped; }
|
bool swapped() const { return m_Swapped; }
|
||||||
QString& name() { return m_Name; }
|
QString& name() { return m_Name; }
|
||||||
void setName(const QString& name) { m_Name = name; }
|
void setName(const QString& name) { m_Name = name; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void init();
|
void init();
|
||||||
QPixmap* pixmap() { return &m_Pixmap; }
|
QPixmap* pixmap() { return &m_Pixmap; }
|
||||||
|
|
||||||
void setPixmap(const QPixmap& pixmap) { m_Pixmap = pixmap; }
|
void setPixmap(const QPixmap& pixmap) { m_Pixmap = pixmap; }
|
||||||
QStringList& aliases() { return m_Aliases; }
|
QStringList& aliases() { return m_Aliases; }
|
||||||
void setModifier(int m, int n) { m_Modifiers[m] = n; }
|
void setModifier(int m, int n) { m_Modifiers[m] = n; }
|
||||||
QList<int>& modifiers() { return m_Modifiers; }
|
QList<int>& modifiers() { return m_Modifiers; }
|
||||||
void addAlias(const QString& alias) { m_Aliases.append(alias); }
|
void addAlias(const QString& alias) { m_Aliases.append(alias); }
|
||||||
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
||||||
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
||||||
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
||||||
void setFix(int f, bool on) { m_Fixes[f] = on; }
|
void setFix(int f, bool on) { m_Fixes[f] = on; }
|
||||||
QList<bool>& fixes() { return m_Fixes; }
|
QList<bool>& fixes() { return m_Fixes; }
|
||||||
void setSwapped(bool on) { m_Swapped = on; }
|
void setSwapped(bool on) { m_Swapped = on; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap m_Pixmap;
|
QPixmap m_Pixmap;
|
||||||
QString m_Name;
|
QString m_Name;
|
||||||
|
|
||||||
QStringList m_Aliases;
|
QStringList m_Aliases;
|
||||||
QList<int> m_Modifiers;
|
QList<int> m_Modifiers;
|
||||||
QList<bool> m_SwitchCorners;
|
QList<bool> m_SwitchCorners;
|
||||||
int m_SwitchCornerSize;
|
int m_SwitchCornerSize;
|
||||||
QList<bool> m_Fixes;
|
QList<bool> m_Fixes;
|
||||||
|
|
||||||
bool m_Swapped;
|
bool m_Swapped;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<Screen> ScreenList;
|
typedef QList<Screen> ScreenList;
|
||||||
|
|
|
@ -24,114 +24,114 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) :
|
ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) :
|
||||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::ScreenSettingsDialogBase(),
|
Ui::ScreenSettingsDialogBase(),
|
||||||
m_pScreen(pScreen)
|
m_pScreen(pScreen)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
QRegExp validScreenName("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive);
|
QRegExp validScreenName("[a-z0-9\\._-]{,255}", Qt::CaseInsensitive);
|
||||||
|
|
||||||
m_pLineEditName->setText(m_pScreen->name());
|
m_pLineEditName->setText(m_pScreen->name());
|
||||||
m_pLineEditName->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
m_pLineEditName->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
||||||
m_pLineEditName->selectAll();
|
m_pLineEditName->selectAll();
|
||||||
|
|
||||||
m_pLineEditAlias->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
m_pLineEditAlias->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
||||||
|
|
||||||
for (int i = 0; i < m_pScreen->aliases().count(); i++)
|
for (int i = 0; i < m_pScreen->aliases().count(); i++)
|
||||||
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
|
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
|
||||||
|
|
||||||
m_pComboBoxShift->setCurrentIndex(m_pScreen->modifier(Screen::Shift));
|
m_pComboBoxShift->setCurrentIndex(m_pScreen->modifier(Screen::Shift));
|
||||||
m_pComboBoxCtrl->setCurrentIndex(m_pScreen->modifier(Screen::Ctrl));
|
m_pComboBoxCtrl->setCurrentIndex(m_pScreen->modifier(Screen::Ctrl));
|
||||||
m_pComboBoxAlt->setCurrentIndex(m_pScreen->modifier(Screen::Alt));
|
m_pComboBoxAlt->setCurrentIndex(m_pScreen->modifier(Screen::Alt));
|
||||||
m_pComboBoxMeta->setCurrentIndex(m_pScreen->modifier(Screen::Meta));
|
m_pComboBoxMeta->setCurrentIndex(m_pScreen->modifier(Screen::Meta));
|
||||||
m_pComboBoxSuper->setCurrentIndex(m_pScreen->modifier(Screen::Super));
|
m_pComboBoxSuper->setCurrentIndex(m_pScreen->modifier(Screen::Super));
|
||||||
|
|
||||||
m_pCheckBoxCornerTopLeft->setChecked(m_pScreen->switchCorner(Screen::TopLeft));
|
m_pCheckBoxCornerTopLeft->setChecked(m_pScreen->switchCorner(Screen::TopLeft));
|
||||||
m_pCheckBoxCornerTopRight->setChecked(m_pScreen->switchCorner(Screen::TopRight));
|
m_pCheckBoxCornerTopRight->setChecked(m_pScreen->switchCorner(Screen::TopRight));
|
||||||
m_pCheckBoxCornerBottomLeft->setChecked(m_pScreen->switchCorner(Screen::BottomLeft));
|
m_pCheckBoxCornerBottomLeft->setChecked(m_pScreen->switchCorner(Screen::BottomLeft));
|
||||||
m_pCheckBoxCornerBottomRight->setChecked(m_pScreen->switchCorner(Screen::BottomRight));
|
m_pCheckBoxCornerBottomRight->setChecked(m_pScreen->switchCorner(Screen::BottomRight));
|
||||||
m_pSpinBoxSwitchCornerSize->setValue(m_pScreen->switchCornerSize());
|
m_pSpinBoxSwitchCornerSize->setValue(m_pScreen->switchCornerSize());
|
||||||
|
|
||||||
m_pCheckBoxCapsLock->setChecked(m_pScreen->fix(Screen::CapsLock));
|
m_pCheckBoxCapsLock->setChecked(m_pScreen->fix(Screen::CapsLock));
|
||||||
m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::NumLock));
|
m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::NumLock));
|
||||||
m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::ScrollLock));
|
m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::ScrollLock));
|
||||||
m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::XTest));
|
m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::XTest));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSettingsDialog::accept()
|
void ScreenSettingsDialog::accept()
|
||||||
{
|
{
|
||||||
if (m_pLineEditName->text().isEmpty())
|
if (m_pLineEditName->text().isEmpty())
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("Screen name is empty"),
|
this, tr("Screen name is empty"),
|
||||||
tr("The screen name cannot be empty. "
|
tr("The screen name cannot be empty. "
|
||||||
"Please either fill in a name or cancel the dialog."));
|
"Please either fill in a name or cancel the dialog."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pScreen->init();
|
m_pScreen->init();
|
||||||
|
|
||||||
m_pScreen->setName(m_pLineEditName->text());
|
m_pScreen->setName(m_pLineEditName->text());
|
||||||
|
|
||||||
for (int i = 0; i < m_pListAliases->count(); i++)
|
for (int i = 0; i < m_pListAliases->count(); i++)
|
||||||
{
|
{
|
||||||
QString alias(m_pListAliases->item(i)->text());
|
QString alias(m_pListAliases->item(i)->text());
|
||||||
if (alias == m_pLineEditName->text())
|
if (alias == m_pLineEditName->text())
|
||||||
{
|
{
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this, tr("Screen name matches alias"),
|
this, tr("Screen name matches alias"),
|
||||||
tr("The screen name cannot be the same as an alias. "
|
tr("The screen name cannot be the same as an alias. "
|
||||||
"Please either remove the alias or change the screen name."));
|
"Please either remove the alias or change the screen name."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_pScreen->addAlias(alias);
|
m_pScreen->addAlias(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pScreen->setModifier(Screen::Shift, m_pComboBoxShift->currentIndex());
|
m_pScreen->setModifier(Screen::Shift, m_pComboBoxShift->currentIndex());
|
||||||
m_pScreen->setModifier(Screen::Ctrl, m_pComboBoxCtrl->currentIndex());
|
m_pScreen->setModifier(Screen::Ctrl, m_pComboBoxCtrl->currentIndex());
|
||||||
m_pScreen->setModifier(Screen::Alt, m_pComboBoxAlt->currentIndex());
|
m_pScreen->setModifier(Screen::Alt, m_pComboBoxAlt->currentIndex());
|
||||||
m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex());
|
m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex());
|
||||||
m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex());
|
m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex());
|
||||||
|
|
||||||
m_pScreen->setSwitchCorner(Screen::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
m_pScreen->setSwitchCorner(Screen::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
||||||
m_pScreen->setSwitchCorner(Screen::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
m_pScreen->setSwitchCorner(Screen::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
||||||
m_pScreen->setSwitchCorner(Screen::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
m_pScreen->setSwitchCorner(Screen::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
||||||
m_pScreen->setSwitchCorner(Screen::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
m_pScreen->setSwitchCorner(Screen::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
||||||
m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
||||||
|
|
||||||
m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked());
|
m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked());
|
||||||
m_pScreen->setFix(Screen::NumLock, m_pCheckBoxNumLock->isChecked());
|
m_pScreen->setFix(Screen::NumLock, m_pCheckBoxNumLock->isChecked());
|
||||||
m_pScreen->setFix(Screen::ScrollLock, m_pCheckBoxScrollLock->isChecked());
|
m_pScreen->setFix(Screen::ScrollLock, m_pCheckBoxScrollLock->isChecked());
|
||||||
m_pScreen->setFix(Screen::XTest, m_pCheckBoxXTest->isChecked());
|
m_pScreen->setFix(Screen::XTest, m_pCheckBoxXTest->isChecked());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSettingsDialog::on_m_pButtonAddAlias_clicked()
|
void ScreenSettingsDialog::on_m_pButtonAddAlias_clicked()
|
||||||
{
|
{
|
||||||
if (!m_pLineEditAlias->text().isEmpty() && m_pListAliases->findItems(m_pLineEditAlias->text(), Qt::MatchFixedString).isEmpty())
|
if (!m_pLineEditAlias->text().isEmpty() && m_pListAliases->findItems(m_pLineEditAlias->text(), Qt::MatchFixedString).isEmpty())
|
||||||
{
|
{
|
||||||
new QListWidgetItem(m_pLineEditAlias->text(), m_pListAliases);
|
new QListWidgetItem(m_pLineEditAlias->text(), m_pListAliases);
|
||||||
m_pLineEditAlias->clear();
|
m_pLineEditAlias->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSettingsDialog::on_m_pLineEditAlias_textChanged(const QString& text)
|
void ScreenSettingsDialog::on_m_pLineEditAlias_textChanged(const QString& text)
|
||||||
{
|
{
|
||||||
m_pButtonAddAlias->setEnabled(!text.isEmpty());
|
m_pButtonAddAlias->setEnabled(!text.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSettingsDialog::on_m_pButtonRemoveAlias_clicked()
|
void ScreenSettingsDialog::on_m_pButtonRemoveAlias_clicked()
|
||||||
{
|
{
|
||||||
QList<QListWidgetItem*> items = m_pListAliases->selectedItems();
|
QList<QListWidgetItem*> items = m_pListAliases->selectedItems();
|
||||||
|
|
||||||
for (int i = 0; i < items.count(); i++)
|
for (int i = 0; i < items.count(); i++)
|
||||||
delete items[i];
|
delete items[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSettingsDialog::on_m_pListAliases_itemSelectionChanged()
|
void ScreenSettingsDialog::on_m_pListAliases_itemSelectionChanged()
|
||||||
{
|
{
|
||||||
m_pButtonRemoveAlias->setEnabled(!m_pListAliases->selectedItems().isEmpty());
|
m_pButtonRemoveAlias->setEnabled(!m_pListAliases->selectedItems().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,22 +31,22 @@ class Screen;
|
||||||
|
|
||||||
class ScreenSettingsDialog : public QDialog, public Ui::ScreenSettingsDialogBase
|
class ScreenSettingsDialog : public QDialog, public Ui::ScreenSettingsDialogBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenSettingsDialog(QWidget* parent, Screen* pScreen = NULL);
|
ScreenSettingsDialog(QWidget* parent, Screen* pScreen = NULL);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void accept();
|
void accept();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_pButtonAddAlias_clicked();
|
void on_m_pButtonAddAlias_clicked();
|
||||||
void on_m_pButtonRemoveAlias_clicked();
|
void on_m_pButtonRemoveAlias_clicked();
|
||||||
void on_m_pLineEditAlias_textChanged(const QString& text);
|
void on_m_pLineEditAlias_textChanged(const QString& text);
|
||||||
void on_m_pListAliases_itemSelectionChanged();
|
void on_m_pListAliases_itemSelectionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Screen* m_pScreen;
|
Screen* m_pScreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,119 +25,119 @@
|
||||||
const QString ScreenSetupModel::m_MimeType = "application/x-qsynergy-screen";
|
const QString ScreenSetupModel::m_MimeType = "application/x-qsynergy-screen";
|
||||||
|
|
||||||
ScreenSetupModel::ScreenSetupModel(ScreenList& screens, int numColumns, int numRows) :
|
ScreenSetupModel::ScreenSetupModel(ScreenList& screens, int numColumns, int numRows) :
|
||||||
QAbstractTableModel(NULL),
|
QAbstractTableModel(NULL),
|
||||||
m_Screens(screens),
|
m_Screens(screens),
|
||||||
m_NumColumns(numColumns),
|
m_NumColumns(numColumns),
|
||||||
m_NumRows(numRows)
|
m_NumRows(numRows)
|
||||||
{
|
{
|
||||||
if (m_NumColumns * m_NumRows > screens.size())
|
if (m_NumColumns * m_NumRows > screens.size())
|
||||||
qFatal("Not enough elements (%u) in screens QList for %d columns and %d rows", screens.size(), m_NumColumns, m_NumRows);
|
qFatal("Not enough elements (%u) in screens QList for %d columns and %d rows", screens.size(), m_NumColumns, m_NumRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ScreenSetupModel::data(const QModelIndex& index, int role) const
|
QVariant ScreenSetupModel::data(const QModelIndex& index, int role) const
|
||||||
{
|
{
|
||||||
if (index.isValid() && index.row() < m_NumRows && index.column() < m_NumColumns)
|
if (index.isValid() && index.row() < m_NumRows && index.column() < m_NumColumns)
|
||||||
{
|
{
|
||||||
switch(role)
|
switch(role)
|
||||||
{
|
{
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
if (screen(index).isNull())
|
if (screen(index).isNull())
|
||||||
break;
|
break;
|
||||||
return QIcon(*screen(index).pixmap());
|
return QIcon(*screen(index).pixmap());
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
if (screen(index).isNull())
|
if (screen(index).isNull())
|
||||||
break;
|
break;
|
||||||
return QString(tr(
|
return QString(tr(
|
||||||
"<center>Screen: <b>%1</b></center>"
|
"<center>Screen: <b>%1</b></center>"
|
||||||
"<br>Double click to edit settings"
|
"<br>Double click to edit settings"
|
||||||
"<br>Drag screen to the trashcan to remove it")).arg(screen(index).name());
|
"<br>Drag screen to the trashcan to remove it")).arg(screen(index).name());
|
||||||
|
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
if (screen(index).isNull())
|
if (screen(index).isNull())
|
||||||
break;
|
break;
|
||||||
return screen(index).name();
|
return screen(index).name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags ScreenSetupModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags ScreenSetupModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
if (!index.isValid() || index.row() >= m_NumRows || index.column() >= m_NumColumns)
|
if (!index.isValid() || index.row() >= m_NumRows || index.column() >= m_NumColumns)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!screen(index).isNull())
|
if (!screen(index).isNull())
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
|
return Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
|
||||||
|
|
||||||
return Qt::ItemIsDropEnabled;
|
return Qt::ItemIsDropEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::DropActions ScreenSetupModel::supportedDropActions() const
|
Qt::DropActions ScreenSetupModel::supportedDropActions() const
|
||||||
{
|
{
|
||||||
return Qt::MoveAction | Qt::CopyAction;
|
return Qt::MoveAction | Qt::CopyAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ScreenSetupModel::mimeTypes() const
|
QStringList ScreenSetupModel::mimeTypes() const
|
||||||
{
|
{
|
||||||
return QStringList() << m_MimeType;
|
return QStringList() << m_MimeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData* ScreenSetupModel::mimeData(const QModelIndexList& indexes) const
|
QMimeData* ScreenSetupModel::mimeData(const QModelIndexList& indexes) const
|
||||||
{
|
{
|
||||||
QMimeData* pMimeData = new QMimeData();
|
QMimeData* pMimeData = new QMimeData();
|
||||||
QByteArray encodedData;
|
QByteArray encodedData;
|
||||||
|
|
||||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||||
|
|
||||||
foreach (const QModelIndex& index, indexes)
|
foreach (const QModelIndex& index, indexes)
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
stream << index.column() << index.row() << screen(index);
|
stream << index.column() << index.row() << screen(index);
|
||||||
|
|
||||||
pMimeData->setData(m_MimeType, encodedData);
|
pMimeData->setData(m_MimeType, encodedData);
|
||||||
|
|
||||||
return pMimeData;
|
return pMimeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScreenSetupModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent)
|
bool ScreenSetupModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent)
|
||||||
{
|
{
|
||||||
if (action == Qt::IgnoreAction)
|
if (action == Qt::IgnoreAction)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!data->hasFormat(m_MimeType))
|
if (!data->hasFormat(m_MimeType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!parent.isValid() || row != -1 || column != -1)
|
if (!parent.isValid() || row != -1 || column != -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QByteArray encodedData = data->data(m_MimeType);
|
QByteArray encodedData = data->data(m_MimeType);
|
||||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||||
|
|
||||||
int sourceColumn = -1;
|
int sourceColumn = -1;
|
||||||
int sourceRow = -1;
|
int sourceRow = -1;
|
||||||
|
|
||||||
stream >> sourceColumn;
|
stream >> sourceColumn;
|
||||||
stream >> sourceRow;
|
stream >> sourceRow;
|
||||||
|
|
||||||
// don't drop screen onto itself
|
// don't drop screen onto itself
|
||||||
if (sourceColumn == parent.column() && sourceRow == parent.row())
|
if (sourceColumn == parent.column() && sourceRow == parent.row())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Screen droppedScreen;
|
Screen droppedScreen;
|
||||||
stream >> droppedScreen;
|
stream >> droppedScreen;
|
||||||
|
|
||||||
Screen oldScreen = screen(parent.column(), parent.row());
|
Screen oldScreen = screen(parent.column(), parent.row());
|
||||||
if (!oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1)
|
if (!oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1)
|
||||||
{
|
{
|
||||||
// mark the screen so it isn't deleted after the dragndrop succeeded
|
// mark the screen so it isn't deleted after the dragndrop succeeded
|
||||||
// see ScreenSetupView::startDrag()
|
// see ScreenSetupView::startDrag()
|
||||||
oldScreen.setSwapped(true);
|
oldScreen.setSwapped(true);
|
||||||
screen(sourceColumn, sourceRow) = oldScreen;
|
screen(sourceColumn, sourceRow) = oldScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen(parent.column(), parent.row()) = droppedScreen;
|
screen(parent.column(), parent.row()) = droppedScreen;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,39 +32,39 @@ class ServerConfigDialog;
|
||||||
|
|
||||||
class ScreenSetupModel : public QAbstractTableModel
|
class ScreenSetupModel : public QAbstractTableModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
friend class ScreenSetupView;
|
friend class ScreenSetupView;
|
||||||
friend class ServerConfigDialog;
|
friend class ServerConfigDialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenSetupModel(ScreenList& screens, int numColumns, int numRows);
|
ScreenSetupModel(ScreenList& screens, int numColumns, int numRows);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const QString& mimeType() { return m_MimeType; }
|
static const QString& mimeType() { return m_MimeType; }
|
||||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||||
int rowCount() const { return m_NumRows; }
|
int rowCount() const { return m_NumRows; }
|
||||||
int columnCount() const { return m_NumColumns; }
|
int columnCount() const { return m_NumColumns; }
|
||||||
int rowCount(const QModelIndex&) const { return rowCount(); }
|
int rowCount(const QModelIndex&) const { return rowCount(); }
|
||||||
int columnCount(const QModelIndex&) const { return columnCount(); }
|
int columnCount(const QModelIndex&) const { return columnCount(); }
|
||||||
Qt::DropActions supportedDropActions() const;
|
Qt::DropActions supportedDropActions() const;
|
||||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
QStringList mimeTypes() const;
|
QStringList mimeTypes() const;
|
||||||
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
|
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
|
||||||
const Screen& screen(const QModelIndex& index) const { return screen(index.column(), index.row()); }
|
const Screen& screen(const QModelIndex& index) const { return screen(index.column(), index.row()); }
|
||||||
Screen& screen(const QModelIndex& index) { return screen(index.column(), index.row()); }
|
Screen& screen(const QModelIndex& index) { return screen(index.column(), index.row()); }
|
||||||
const Screen& screen(int column, int row) const { return m_Screens[row * m_NumColumns + column]; }
|
const Screen& screen(int column, int row) const { return m_Screens[row * m_NumColumns + column]; }
|
||||||
Screen& screen(int column, int row) { return m_Screens[row * m_NumColumns + column]; }
|
Screen& screen(int column, int row) { return m_Screens[row * m_NumColumns + column]; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScreenList& m_Screens;
|
ScreenList& m_Screens;
|
||||||
const int m_NumColumns;
|
const int m_NumColumns;
|
||||||
const int m_NumRows;
|
const int m_NumRows;
|
||||||
|
|
||||||
static const QString m_MimeType;
|
static const QString m_MimeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,138 +24,138 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
ScreenSetupView::ScreenSetupView(QWidget* parent) :
|
ScreenSetupView::ScreenSetupView(QWidget* parent) :
|
||||||
QTableView(parent)
|
QTableView(parent)
|
||||||
{
|
{
|
||||||
setDropIndicatorShown(true);
|
setDropIndicatorShown(true);
|
||||||
setDragDropMode(DragDrop);
|
setDragDropMode(DragDrop);
|
||||||
setSelectionMode(SingleSelection);
|
setSelectionMode(SingleSelection);
|
||||||
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
setIconSize(QSize(64, 64));
|
setIconSize(QSize(64, 64));
|
||||||
horizontalHeader()->hide();
|
horizontalHeader()->hide();
|
||||||
verticalHeader()->hide();
|
verticalHeader()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSetupView::setModel(ScreenSetupModel* model)
|
void ScreenSetupView::setModel(ScreenSetupModel* model)
|
||||||
{
|
{
|
||||||
QTableView::setModel(model);
|
QTableView::setModel(model);
|
||||||
setTableSize();
|
setTableSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenSetupModel* ScreenSetupView::model() const
|
ScreenSetupModel* ScreenSetupView::model() const
|
||||||
{
|
{
|
||||||
return qobject_cast<ScreenSetupModel*>(QTableView::model());
|
return qobject_cast<ScreenSetupModel*>(QTableView::model());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSetupView::setTableSize()
|
void ScreenSetupView::setTableSize()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < model()->columnCount(); i++)
|
for (int i = 0; i < model()->columnCount(); i++)
|
||||||
setColumnWidth(i, width() / model()->columnCount());
|
setColumnWidth(i, width() / model()->columnCount());
|
||||||
|
|
||||||
for (int i = 0; i < model()->rowCount(); i++)
|
for (int i = 0; i < model()->rowCount(); i++)
|
||||||
setRowHeight(i, height() / model()->rowCount());
|
setRowHeight(i, height() / model()->rowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSetupView::resizeEvent(QResizeEvent* event)
|
void ScreenSetupView::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
setTableSize();
|
setTableSize();
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent* event)
|
void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton)
|
if (event->buttons() & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
int col = columnAt(event->pos().x());
|
int col = columnAt(event->pos().x());
|
||||||
int row = rowAt(event->pos().y());
|
int row = rowAt(event->pos().y());
|
||||||
|
|
||||||
if (!model()->screen(col, row).isNull())
|
if (!model()->screen(col, row).isNull())
|
||||||
{
|
{
|
||||||
ScreenSettingsDialog dlg(this, &model()->screen(col, row));
|
ScreenSettingsDialog dlg(this, &model()->screen(col, row));
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSetupView::dragEnterEvent(QDragEnterEvent* event)
|
void ScreenSetupView::dragEnterEvent(QDragEnterEvent* event)
|
||||||
{
|
{
|
||||||
// we accept anything that enters us by a drag as long as the
|
// we accept anything that enters us by a drag as long as the
|
||||||
// mime type is okay. anything else is dealt with in dragMoveEvent()
|
// mime type is okay. anything else is dealt with in dragMoveEvent()
|
||||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||||
event->accept();
|
event->accept();
|
||||||
else
|
else
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenSetupView::dragMoveEvent(QDragMoveEvent* event)
|
void ScreenSetupView::dragMoveEvent(QDragMoveEvent* event)
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||||
{
|
{
|
||||||
// where does the event come from? myself or someone else?
|
// where does the event come from? myself or someone else?
|
||||||
if (event->source() == this)
|
if (event->source() == this)
|
||||||
{
|
{
|
||||||
// myself is ok, but then it must be a move action, never a copy
|
// myself is ok, but then it must be a move action, never a copy
|
||||||
event->setDropAction(Qt::MoveAction);
|
event->setDropAction(Qt::MoveAction);
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int col = columnAt(event->pos().x());
|
int col = columnAt(event->pos().x());
|
||||||
int row = rowAt(event->pos().y());
|
int row = rowAt(event->pos().y());
|
||||||
|
|
||||||
// a drop from outside is not allowed if there's a screen already there.
|
// a drop from outside is not allowed if there's a screen already there.
|
||||||
if (!model()->screen(col, row).isNull())
|
if (!model()->screen(col, row).isNull())
|
||||||
event->ignore();
|
event->ignore();
|
||||||
else
|
else
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is reimplemented from QAbstractItemView::startDrag()
|
// this is reimplemented from QAbstractItemView::startDrag()
|
||||||
void ScreenSetupView::startDrag(Qt::DropActions)
|
void ScreenSetupView::startDrag(Qt::DropActions)
|
||||||
{
|
{
|
||||||
QModelIndexList indexes = selectedIndexes();
|
QModelIndexList indexes = selectedIndexes();
|
||||||
|
|
||||||
if (indexes.count() != 1)
|
if (indexes.count() != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMimeData* pData = model()->mimeData(indexes);
|
QMimeData* pData = model()->mimeData(indexes);
|
||||||
if (pData == NULL)
|
if (pData == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPixmap pixmap = *model()->screen(indexes[0]).pixmap();
|
QPixmap pixmap = *model()->screen(indexes[0]).pixmap();
|
||||||
QDrag* pDrag = new QDrag(this);
|
QDrag* pDrag = new QDrag(this);
|
||||||
pDrag->setPixmap(pixmap);
|
pDrag->setPixmap(pixmap);
|
||||||
pDrag->setMimeData(pData);
|
pDrag->setMimeData(pData);
|
||||||
pDrag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2));
|
pDrag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2));
|
||||||
|
|
||||||
if (pDrag->exec(Qt::MoveAction, Qt::MoveAction) == Qt::MoveAction)
|
if (pDrag->exec(Qt::MoveAction, Qt::MoveAction) == Qt::MoveAction)
|
||||||
{
|
{
|
||||||
selectionModel()->clear();
|
selectionModel()->clear();
|
||||||
|
|
||||||
// make sure to only delete the drag source if screens weren't swapped
|
// make sure to only delete the drag source if screens weren't swapped
|
||||||
// see ScreenSetupModel::dropMimeData
|
// see ScreenSetupModel::dropMimeData
|
||||||
if (!model()->screen(indexes[0]).swapped())
|
if (!model()->screen(indexes[0]).swapped())
|
||||||
model()->screen(indexes[0]) = Screen();
|
model()->screen(indexes[0]) = Screen();
|
||||||
else
|
else
|
||||||
model()->screen(indexes[0]).setSwapped(false);
|
model()->screen(indexes[0]).setSwapped(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStyleOptionViewItem ScreenSetupView::viewOptions() const
|
QStyleOptionViewItem ScreenSetupView::viewOptions() const
|
||||||
{
|
{
|
||||||
QStyleOptionViewItem option = QTableView::viewOptions();
|
QStyleOptionViewItem option = QTableView::viewOptions();
|
||||||
option.showDecorationSelected = true;
|
option.showDecorationSelected = true;
|
||||||
option.decorationPosition = QStyleOptionViewItem::Top;
|
option.decorationPosition = QStyleOptionViewItem::Top;
|
||||||
option.displayAlignment = Qt::AlignCenter;
|
option.displayAlignment = Qt::AlignCenter;
|
||||||
option.textElideMode = Qt::ElideMiddle;
|
option.textElideMode = Qt::ElideMiddle;
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,24 +33,24 @@ class ScreenSetupModel;
|
||||||
|
|
||||||
class ScreenSetupView : public QTableView
|
class ScreenSetupView : public QTableView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenSetupView(QWidget* parent);
|
ScreenSetupView(QWidget* parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setModel(ScreenSetupModel* model);
|
void setModel(ScreenSetupModel* model);
|
||||||
ScreenSetupModel* model() const;
|
ScreenSetupModel* model() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseDoubleClickEvent(QMouseEvent*);
|
void mouseDoubleClickEvent(QMouseEvent*);
|
||||||
void setTableSize();
|
void setTableSize();
|
||||||
void resizeEvent(QResizeEvent*);
|
void resizeEvent(QResizeEvent*);
|
||||||
void dragEnterEvent(QDragEnterEvent* event);
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
void dragMoveEvent(QDragMoveEvent* event);
|
void dragMoveEvent(QDragMoveEvent* event);
|
||||||
void startDrag(Qt::DropActions supportedActions);
|
void startDrag(Qt::DropActions supportedActions);
|
||||||
QStyleOptionViewItem viewOptions() const;
|
QStyleOptionViewItem viewOptions() const;
|
||||||
void scrollTo(const QModelIndex&, ScrollHint) {}
|
void scrollTo(const QModelIndex&, ScrollHint) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,376 +28,376 @@
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
const char* name;
|
const char* name;
|
||||||
} neighbourDirs[] =
|
} neighbourDirs[] =
|
||||||
{
|
{
|
||||||
{ 1, 0, "right" },
|
{ 1, 0, "right" },
|
||||||
{ -1, 0, "left" },
|
{ -1, 0, "left" },
|
||||||
{ 0, -1, "up" },
|
{ 0, -1, "up" },
|
||||||
{ 0, 1, "down" },
|
{ 0, 1, "down" },
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const int serverDefaultIndex = 7;
|
const int serverDefaultIndex = 7;
|
||||||
|
|
||||||
ServerConfig::ServerConfig(QSettings* settings, int numColumns, int numRows ,
|
ServerConfig::ServerConfig(QSettings* settings, int numColumns, int numRows ,
|
||||||
QString serverName, MainWindow* mainWindow) :
|
QString serverName, MainWindow* mainWindow) :
|
||||||
m_pSettings(settings),
|
m_pSettings(settings),
|
||||||
m_Screens(),
|
m_Screens(),
|
||||||
m_NumColumns(numColumns),
|
m_NumColumns(numColumns),
|
||||||
m_NumRows(numRows),
|
m_NumRows(numRows),
|
||||||
m_ServerName(serverName),
|
m_ServerName(serverName),
|
||||||
m_IgnoreAutoConfigClient(false),
|
m_IgnoreAutoConfigClient(false),
|
||||||
m_EnableDragAndDrop(false),
|
m_EnableDragAndDrop(false),
|
||||||
m_ClipboardSharing(true),
|
m_ClipboardSharing(true),
|
||||||
m_pMainWindow(mainWindow)
|
m_pMainWindow(mainWindow)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_pSettings);
|
Q_ASSERT(m_pSettings);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerConfig::~ServerConfig()
|
ServerConfig::~ServerConfig()
|
||||||
{
|
{
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerConfig::save(const QString& fileName) const
|
bool ServerConfig::save(const QString& fileName) const
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
save(file);
|
save(file);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfig::save(QFile& file) const
|
void ServerConfig::save(QFile& file) const
|
||||||
{
|
{
|
||||||
QTextStream outStream(&file);
|
QTextStream outStream(&file);
|
||||||
outStream << *this;
|
outStream << *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfig::init()
|
void ServerConfig::init()
|
||||||
{
|
{
|
||||||
switchCorners().clear();
|
switchCorners().clear();
|
||||||
screens().clear();
|
screens().clear();
|
||||||
|
|
||||||
// m_NumSwitchCorners is used as a fixed size array. See Screen::init()
|
// m_NumSwitchCorners is used as a fixed size array. See Screen::init()
|
||||||
for (int i = 0; i < NumSwitchCorners; i++)
|
for (int i = 0; i < NumSwitchCorners; i++)
|
||||||
switchCorners() << false;
|
switchCorners() << false;
|
||||||
|
|
||||||
// There must always be screen objects for each cell in the screens QList. Unused screens
|
// There must always be screen objects for each cell in the screens QList. Unused screens
|
||||||
// are identified by having an empty name.
|
// are identified by having an empty name.
|
||||||
for (int i = 0; i < numColumns() * numRows(); i++)
|
for (int i = 0; i < numColumns() * numRows(); i++)
|
||||||
addScreen(Screen());
|
addScreen(Screen());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfig::saveSettings()
|
void ServerConfig::saveSettings()
|
||||||
{
|
{
|
||||||
settings().beginGroup("internalConfig");
|
settings().beginGroup("internalConfig");
|
||||||
settings().remove("");
|
settings().remove("");
|
||||||
|
|
||||||
settings().setValue("numColumns", numColumns());
|
settings().setValue("numColumns", numColumns());
|
||||||
settings().setValue("numRows", numRows());
|
settings().setValue("numRows", numRows());
|
||||||
|
|
||||||
settings().setValue("hasHeartbeat", hasHeartbeat());
|
settings().setValue("hasHeartbeat", hasHeartbeat());
|
||||||
settings().setValue("heartbeat", heartbeat());
|
settings().setValue("heartbeat", heartbeat());
|
||||||
settings().setValue("relativeMouseMoves", relativeMouseMoves());
|
settings().setValue("relativeMouseMoves", relativeMouseMoves());
|
||||||
settings().setValue("screenSaverSync", screenSaverSync());
|
settings().setValue("screenSaverSync", screenSaverSync());
|
||||||
settings().setValue("win32KeepForeground", win32KeepForeground());
|
settings().setValue("win32KeepForeground", win32KeepForeground());
|
||||||
settings().setValue("hasSwitchDelay", hasSwitchDelay());
|
settings().setValue("hasSwitchDelay", hasSwitchDelay());
|
||||||
settings().setValue("switchDelay", switchDelay());
|
settings().setValue("switchDelay", switchDelay());
|
||||||
settings().setValue("hasSwitchDoubleTap", hasSwitchDoubleTap());
|
settings().setValue("hasSwitchDoubleTap", hasSwitchDoubleTap());
|
||||||
settings().setValue("switchDoubleTap", switchDoubleTap());
|
settings().setValue("switchDoubleTap", switchDoubleTap());
|
||||||
settings().setValue("switchCornerSize", switchCornerSize());
|
settings().setValue("switchCornerSize", switchCornerSize());
|
||||||
settings().setValue("ignoreAutoConfigClient", ignoreAutoConfigClient());
|
settings().setValue("ignoreAutoConfigClient", ignoreAutoConfigClient());
|
||||||
settings().setValue("enableDragAndDrop", enableDragAndDrop());
|
settings().setValue("enableDragAndDrop", enableDragAndDrop());
|
||||||
|
|
||||||
writeSettings(settings(), switchCorners(), "switchCorner");
|
writeSettings(settings(), switchCorners(), "switchCorner");
|
||||||
|
|
||||||
settings().beginWriteArray("screens");
|
settings().beginWriteArray("screens");
|
||||||
for (int i = 0; i < screens().size(); i++)
|
for (int i = 0; i < screens().size(); i++)
|
||||||
{
|
{
|
||||||
settings().setArrayIndex(i);
|
settings().setArrayIndex(i);
|
||||||
screens()[i].saveSettings(settings());
|
screens()[i].saveSettings(settings());
|
||||||
}
|
}
|
||||||
settings().endArray();
|
settings().endArray();
|
||||||
|
|
||||||
settings().beginWriteArray("hotkeys");
|
settings().beginWriteArray("hotkeys");
|
||||||
for (int i = 0; i < hotkeys().size(); i++)
|
for (int i = 0; i < hotkeys().size(); i++)
|
||||||
{
|
{
|
||||||
settings().setArrayIndex(i);
|
settings().setArrayIndex(i);
|
||||||
hotkeys()[i].saveSettings(settings());
|
hotkeys()[i].saveSettings(settings());
|
||||||
}
|
}
|
||||||
settings().endArray();
|
settings().endArray();
|
||||||
|
|
||||||
settings().endGroup();
|
settings().endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfig::loadSettings()
|
void ServerConfig::loadSettings()
|
||||||
{
|
{
|
||||||
settings().beginGroup("internalConfig");
|
settings().beginGroup("internalConfig");
|
||||||
|
|
||||||
setNumColumns(settings().value("numColumns", 5).toInt());
|
setNumColumns(settings().value("numColumns", 5).toInt());
|
||||||
setNumRows(settings().value("numRows", 3).toInt());
|
setNumRows(settings().value("numRows", 3).toInt());
|
||||||
|
|
||||||
// we need to know the number of columns and rows before we can set up ourselves
|
// we need to know the number of columns and rows before we can set up ourselves
|
||||||
init();
|
init();
|
||||||
|
|
||||||
haveHeartbeat(settings().value("hasHeartbeat", false).toBool());
|
haveHeartbeat(settings().value("hasHeartbeat", false).toBool());
|
||||||
setHeartbeat(settings().value("heartbeat", 5000).toInt());
|
setHeartbeat(settings().value("heartbeat", 5000).toInt());
|
||||||
setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool());
|
setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool());
|
||||||
setScreenSaverSync(settings().value("screenSaverSync", true).toBool());
|
setScreenSaverSync(settings().value("screenSaverSync", true).toBool());
|
||||||
setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool());
|
setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool());
|
||||||
haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool());
|
haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool());
|
||||||
setSwitchDelay(settings().value("switchDelay", 250).toInt());
|
setSwitchDelay(settings().value("switchDelay", 250).toInt());
|
||||||
haveSwitchDoubleTap(settings().value("hasSwitchDoubleTap", false).toBool());
|
haveSwitchDoubleTap(settings().value("hasSwitchDoubleTap", false).toBool());
|
||||||
setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt());
|
setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt());
|
||||||
setSwitchCornerSize(settings().value("switchCornerSize").toInt());
|
setSwitchCornerSize(settings().value("switchCornerSize").toInt());
|
||||||
setIgnoreAutoConfigClient(settings().value("ignoreAutoConfigClient").toBool());
|
setIgnoreAutoConfigClient(settings().value("ignoreAutoConfigClient").toBool());
|
||||||
setEnableDragAndDrop(settings().value("enableDragAndDrop", true).toBool());
|
setEnableDragAndDrop(settings().value("enableDragAndDrop", true).toBool());
|
||||||
|
|
||||||
readSettings(settings(), switchCorners(), "switchCorner", false, NumSwitchCorners);
|
readSettings(settings(), switchCorners(), "switchCorner", false, NumSwitchCorners);
|
||||||
|
|
||||||
int numScreens = settings().beginReadArray("screens");
|
int numScreens = settings().beginReadArray("screens");
|
||||||
Q_ASSERT(numScreens <= screens().size());
|
Q_ASSERT(numScreens <= screens().size());
|
||||||
for (int i = 0; i < numScreens; i++)
|
for (int i = 0; i < numScreens; i++)
|
||||||
{
|
{
|
||||||
settings().setArrayIndex(i);
|
settings().setArrayIndex(i);
|
||||||
screens()[i].loadSettings(settings());
|
screens()[i].loadSettings(settings());
|
||||||
}
|
}
|
||||||
settings().endArray();
|
settings().endArray();
|
||||||
|
|
||||||
int numHotkeys = settings().beginReadArray("hotkeys");
|
int numHotkeys = settings().beginReadArray("hotkeys");
|
||||||
for (int i = 0; i < numHotkeys; i++)
|
for (int i = 0; i < numHotkeys; i++)
|
||||||
{
|
{
|
||||||
settings().setArrayIndex(i);
|
settings().setArrayIndex(i);
|
||||||
Hotkey h;
|
Hotkey h;
|
||||||
h.loadSettings(settings());
|
h.loadSettings(settings());
|
||||||
hotkeys().append(h);
|
hotkeys().append(h);
|
||||||
}
|
}
|
||||||
settings().endArray();
|
settings().endArray();
|
||||||
|
|
||||||
settings().endGroup();
|
settings().endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerConfig::adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const
|
int ServerConfig::adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const
|
||||||
{
|
{
|
||||||
if (screens()[idx].isNull())
|
if (screens()[idx].isNull())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// if we're at the left or right end of the table, don't find results going further left or right
|
// if we're at the left or right end of the table, don't find results going further left or right
|
||||||
if ((deltaColumn > 0 && (idx+1) % numColumns() == 0)
|
if ((deltaColumn > 0 && (idx+1) % numColumns() == 0)
|
||||||
|| (deltaColumn < 0 && idx % numColumns() == 0))
|
|| (deltaColumn < 0 && idx % numColumns() == 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int arrayPos = idx + deltaColumn + deltaRow * numColumns();
|
int arrayPos = idx + deltaColumn + deltaRow * numColumns();
|
||||||
|
|
||||||
if (arrayPos >= screens().size() || arrayPos < 0)
|
if (arrayPos >= screens().size() || arrayPos < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return arrayPos;
|
return arrayPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config)
|
QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config)
|
||||||
{
|
{
|
||||||
outStream << "section: screens" << endl;
|
outStream << "section: screens" << endl;
|
||||||
|
|
||||||
foreach (const Screen& s, config.screens())
|
foreach (const Screen& s, config.screens())
|
||||||
if (!s.isNull())
|
if (!s.isNull())
|
||||||
s.writeScreensSection(outStream);
|
s.writeScreensSection(outStream);
|
||||||
|
|
||||||
outStream << "end" << endl << endl;
|
outStream << "end" << endl << endl;
|
||||||
|
|
||||||
outStream << "section: aliases" << endl;
|
outStream << "section: aliases" << endl;
|
||||||
|
|
||||||
foreach (const Screen& s, config.screens())
|
foreach (const Screen& s, config.screens())
|
||||||
if (!s.isNull())
|
if (!s.isNull())
|
||||||
s.writeAliasesSection(outStream);
|
s.writeAliasesSection(outStream);
|
||||||
|
|
||||||
outStream << "end" << endl << endl;
|
outStream << "end" << endl << endl;
|
||||||
|
|
||||||
outStream << "section: links" << endl;
|
outStream << "section: links" << endl;
|
||||||
|
|
||||||
for (int i = 0; i < config.screens().size(); i++)
|
for (int i = 0; i < config.screens().size(); i++)
|
||||||
if (!config.screens()[i].isNull())
|
if (!config.screens()[i].isNull())
|
||||||
{
|
{
|
||||||
outStream << "\t" << config.screens()[i].name() << ":" << endl;
|
outStream << "\t" << config.screens()[i].name() << ":" << endl;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++)
|
for (unsigned int j = 0; j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++)
|
||||||
{
|
{
|
||||||
int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, neighbourDirs[j].y);
|
int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, neighbourDirs[j].y);
|
||||||
if (idx != -1 && !config.screens()[idx].isNull())
|
if (idx != -1 && !config.screens()[idx].isNull())
|
||||||
outStream << "\t\t" << neighbourDirs[j].name << " = " << config.screens()[idx].name() << endl;
|
outStream << "\t\t" << neighbourDirs[j].name << " = " << config.screens()[idx].name() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outStream << "end" << endl << endl;
|
outStream << "end" << endl << endl;
|
||||||
|
|
||||||
outStream << "section: options" << endl;
|
outStream << "section: options" << endl;
|
||||||
|
|
||||||
if (config.hasHeartbeat())
|
if (config.hasHeartbeat())
|
||||||
outStream << "\t" << "heartbeat = " << config.heartbeat() << endl;
|
outStream << "\t" << "heartbeat = " << config.heartbeat() << endl;
|
||||||
|
|
||||||
outStream << "\t" << "relativeMouseMoves = " << (config.relativeMouseMoves() ? "true" : "false") << endl;
|
outStream << "\t" << "relativeMouseMoves = " << (config.relativeMouseMoves() ? "true" : "false") << endl;
|
||||||
outStream << "\t" << "screenSaverSync = " << (config.screenSaverSync() ? "true" : "false") << endl;
|
outStream << "\t" << "screenSaverSync = " << (config.screenSaverSync() ? "true" : "false") << endl;
|
||||||
outStream << "\t" << "win32KeepForeground = " << (config.win32KeepForeground() ? "true" : "false") << endl;
|
outStream << "\t" << "win32KeepForeground = " << (config.win32KeepForeground() ? "true" : "false") << endl;
|
||||||
outStream << "\t" << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << endl;
|
outStream << "\t" << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << endl;
|
||||||
|
|
||||||
if (config.hasSwitchDelay())
|
if (config.hasSwitchDelay())
|
||||||
outStream << "\t" << "switchDelay = " << config.switchDelay() << endl;
|
outStream << "\t" << "switchDelay = " << config.switchDelay() << endl;
|
||||||
|
|
||||||
if (config.hasSwitchDoubleTap())
|
if (config.hasSwitchDoubleTap())
|
||||||
outStream << "\t" << "switchDoubleTap = " << config.switchDoubleTap() << endl;
|
outStream << "\t" << "switchDoubleTap = " << config.switchDoubleTap() << endl;
|
||||||
|
|
||||||
outStream << "\t" << "switchCorners = none ";
|
outStream << "\t" << "switchCorners = none ";
|
||||||
for (int i = 0; i < config.switchCorners().size(); i++)
|
for (int i = 0; i < config.switchCorners().size(); i++)
|
||||||
if (config.switchCorners()[i])
|
if (config.switchCorners()[i])
|
||||||
outStream << "+" << config.switchCornerName(i) << " ";
|
outStream << "+" << config.switchCornerName(i) << " ";
|
||||||
outStream << endl;
|
outStream << endl;
|
||||||
|
|
||||||
outStream << "\t" << "switchCornerSize = " << config.switchCornerSize() << endl;
|
outStream << "\t" << "switchCornerSize = " << config.switchCornerSize() << endl;
|
||||||
|
|
||||||
foreach(const Hotkey& hotkey, config.hotkeys())
|
foreach(const Hotkey& hotkey, config.hotkeys())
|
||||||
outStream << hotkey;
|
outStream << hotkey;
|
||||||
|
|
||||||
outStream << "end" << endl << endl;
|
outStream << "end" << endl << endl;
|
||||||
|
|
||||||
return outStream;
|
return outStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerConfig::numScreens() const
|
int ServerConfig::numScreens() const
|
||||||
{
|
{
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
|
|
||||||
foreach(const Screen& s, screens())
|
foreach(const Screen& s, screens())
|
||||||
if (!s.isNull())
|
if (!s.isNull())
|
||||||
rval++;
|
rval++;
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerConfig::autoAddScreen(const QString name)
|
int ServerConfig::autoAddScreen(const QString name)
|
||||||
{
|
{
|
||||||
int serverIndex = -1;
|
int serverIndex = -1;
|
||||||
int targetIndex = -1;
|
int targetIndex = -1;
|
||||||
if (!findScreenName(m_ServerName, serverIndex)) {
|
if (!findScreenName(m_ServerName, serverIndex)) {
|
||||||
if (!fixNoServer(m_ServerName, serverIndex)) {
|
if (!fixNoServer(m_ServerName, serverIndex)) {
|
||||||
return kAutoAddScreenManualServer;
|
return kAutoAddScreenManualServer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (findScreenName(name, targetIndex)) {
|
if (findScreenName(name, targetIndex)) {
|
||||||
// already exists.
|
// already exists.
|
||||||
return kAutoAddScreenIgnore;
|
return kAutoAddScreenIgnore;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = showAddClientDialog(name);
|
int result = showAddClientDialog(name);
|
||||||
|
|
||||||
if (result == kAddClientIgnore) {
|
if (result == kAddClientIgnore) {
|
||||||
return kAutoAddScreenIgnore;
|
return kAutoAddScreenIgnore;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == kAddClientOther) {
|
if (result == kAddClientOther) {
|
||||||
addToFirstEmptyGrid(name);
|
addToFirstEmptyGrid(name);
|
||||||
return kAutoAddScreenManualClient;
|
return kAutoAddScreenManualClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
int startIndex = serverIndex;
|
int startIndex = serverIndex;
|
||||||
int offset = 1;
|
int offset = 1;
|
||||||
int dirIndex = 0;
|
int dirIndex = 0;
|
||||||
|
|
||||||
if (result == kAddClientLeft) {
|
if (result == kAddClientLeft) {
|
||||||
offset = -1;
|
offset = -1;
|
||||||
dirIndex = 1;
|
dirIndex = 1;
|
||||||
}
|
}
|
||||||
else if (result == kAddClientUp) {
|
else if (result == kAddClientUp) {
|
||||||
offset = -5;
|
offset = -5;
|
||||||
dirIndex = 2;
|
dirIndex = 2;
|
||||||
}
|
}
|
||||||
else if (result == kAddClientDown) {
|
else if (result == kAddClientDown) {
|
||||||
offset = 5;
|
offset = 5;
|
||||||
dirIndex = 3;
|
dirIndex = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
int idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
||||||
neighbourDirs[dirIndex].y);
|
neighbourDirs[dirIndex].y);
|
||||||
while (idx != -1) {
|
while (idx != -1) {
|
||||||
if (screens()[idx].isNull()) {
|
if (screens()[idx].isNull()) {
|
||||||
m_Screens[idx].setName(name);
|
m_Screens[idx].setName(name);
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
startIndex += offset;
|
startIndex += offset;
|
||||||
idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
||||||
neighbourDirs[dirIndex].y);
|
neighbourDirs[dirIndex].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
addToFirstEmptyGrid(name);
|
addToFirstEmptyGrid(name);
|
||||||
return kAutoAddScreenManualClient;
|
return kAutoAddScreenManualClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
return kAutoAddScreenOk;
|
return kAutoAddScreenOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerConfig::findScreenName(const QString& name, int& index)
|
bool ServerConfig::findScreenName(const QString& name, int& index)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int i = 0; i < screens().size(); i++) {
|
for (int i = 0; i < screens().size(); i++) {
|
||||||
if (!screens()[i].isNull() &&
|
if (!screens()[i].isNull() &&
|
||||||
screens()[i].name().compare(name) == 0) {
|
screens()[i].name().compare(name) == 0) {
|
||||||
index = i;
|
index = i;
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerConfig::fixNoServer(const QString& name, int& index)
|
bool ServerConfig::fixNoServer(const QString& name, int& index)
|
||||||
{
|
{
|
||||||
bool fixed = false;
|
bool fixed = false;
|
||||||
if (screens()[serverDefaultIndex].isNull()) {
|
if (screens()[serverDefaultIndex].isNull()) {
|
||||||
m_Screens[serverDefaultIndex].setName(name);
|
m_Screens[serverDefaultIndex].setName(name);
|
||||||
index = serverDefaultIndex;
|
index = serverDefaultIndex;
|
||||||
fixed = true;
|
fixed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fixed;
|
return fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServerConfig::showAddClientDialog(const QString& clientName)
|
int ServerConfig::showAddClientDialog(const QString& clientName)
|
||||||
{
|
{
|
||||||
int result = kAddClientIgnore;
|
int result = kAddClientIgnore;
|
||||||
|
|
||||||
if (!m_pMainWindow->isActiveWindow()) {
|
if (!m_pMainWindow->isActiveWindow()) {
|
||||||
m_pMainWindow->showNormal();
|
m_pMainWindow->showNormal();
|
||||||
m_pMainWindow->activateWindow();
|
m_pMainWindow->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
AddClientDialog addClientDialog(clientName, m_pMainWindow);
|
AddClientDialog addClientDialog(clientName, m_pMainWindow);
|
||||||
addClientDialog.exec();
|
addClientDialog.exec();
|
||||||
result = addClientDialog.addResult();
|
result = addClientDialog.addResult();
|
||||||
m_IgnoreAutoConfigClient = addClientDialog.ignoreAutoConfigClient();
|
m_IgnoreAutoConfigClient = addClientDialog.ignoreAutoConfigClient();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void::ServerConfig::addToFirstEmptyGrid(const QString &clientName)
|
void::ServerConfig::addToFirstEmptyGrid(const QString &clientName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < screens().size(); i++) {
|
for (int i = 0; i < screens().size(); i++) {
|
||||||
if (screens()[i].isNull()) {
|
if (screens()[i].isNull()) {
|
||||||
m_Screens[i].setName(clientName);
|
m_Screens[i].setName(clientName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,106 +35,106 @@ class MainWindow;
|
||||||
|
|
||||||
class ServerConfig : public BaseConfig
|
class ServerConfig : public BaseConfig
|
||||||
{
|
{
|
||||||
friend class ServerConfigDialog;
|
friend class ServerConfigDialog;
|
||||||
friend QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config);
|
friend QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerConfig(QSettings* settings, int numColumns, int numRows,
|
ServerConfig(QSettings* settings, int numColumns, int numRows,
|
||||||
QString serverName, MainWindow* mainWindow);
|
QString serverName, MainWindow* mainWindow);
|
||||||
~ServerConfig();
|
~ServerConfig();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const ScreenList& screens() const { return m_Screens; }
|
const ScreenList& screens() const { return m_Screens; }
|
||||||
int numColumns() const { return m_NumColumns; }
|
int numColumns() const { return m_NumColumns; }
|
||||||
int numRows() const { return m_NumRows; }
|
int numRows() const { return m_NumRows; }
|
||||||
bool hasHeartbeat() const { return m_HasHeartbeat; }
|
bool hasHeartbeat() const { return m_HasHeartbeat; }
|
||||||
int heartbeat() const { return m_Heartbeat; }
|
int heartbeat() const { return m_Heartbeat; }
|
||||||
bool relativeMouseMoves() const { return m_RelativeMouseMoves; }
|
bool relativeMouseMoves() const { return m_RelativeMouseMoves; }
|
||||||
bool screenSaverSync() const { return m_ScreenSaverSync; }
|
bool screenSaverSync() const { return m_ScreenSaverSync; }
|
||||||
bool win32KeepForeground() const { return m_Win32KeepForeground; }
|
bool win32KeepForeground() const { return m_Win32KeepForeground; }
|
||||||
bool hasSwitchDelay() const { return m_HasSwitchDelay; }
|
bool hasSwitchDelay() const { return m_HasSwitchDelay; }
|
||||||
int switchDelay() const { return m_SwitchDelay; }
|
int switchDelay() const { return m_SwitchDelay; }
|
||||||
bool hasSwitchDoubleTap() const { return m_HasSwitchDoubleTap; }
|
bool hasSwitchDoubleTap() const { return m_HasSwitchDoubleTap; }
|
||||||
int switchDoubleTap() const { return m_SwitchDoubleTap; }
|
int switchDoubleTap() const { return m_SwitchDoubleTap; }
|
||||||
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
||||||
int switchCornerSize() const { return m_SwitchCornerSize; }
|
int switchCornerSize() const { return m_SwitchCornerSize; }
|
||||||
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
||||||
const HotkeyList& hotkeys() const { return m_Hotkeys; }
|
const HotkeyList& hotkeys() const { return m_Hotkeys; }
|
||||||
bool ignoreAutoConfigClient() const { return m_IgnoreAutoConfigClient; }
|
bool ignoreAutoConfigClient() const { return m_IgnoreAutoConfigClient; }
|
||||||
bool enableDragAndDrop() const { return m_EnableDragAndDrop; }
|
bool enableDragAndDrop() const { return m_EnableDragAndDrop; }
|
||||||
bool clipboardSharing() const { return m_ClipboardSharing; }
|
bool clipboardSharing() const { return m_ClipboardSharing; }
|
||||||
|
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
bool save(const QString& fileName) const;
|
bool save(const QString& fileName) const;
|
||||||
void save(QFile& file) const;
|
void save(QFile& file) const;
|
||||||
int numScreens() const;
|
int numScreens() const;
|
||||||
int autoAddScreen(const QString name);
|
int autoAddScreen(const QString name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSettings& settings() { return *m_pSettings; }
|
QSettings& settings() { return *m_pSettings; }
|
||||||
ScreenList& screens() { return m_Screens; }
|
ScreenList& screens() { return m_Screens; }
|
||||||
void setScreens(const ScreenList& screens) { m_Screens = screens; }
|
void setScreens(const ScreenList& screens) { m_Screens = screens; }
|
||||||
void addScreen(const Screen& screen) { m_Screens.append(screen); }
|
void addScreen(const Screen& screen) { m_Screens.append(screen); }
|
||||||
void setNumColumns(int n) { m_NumColumns = n; }
|
void setNumColumns(int n) { m_NumColumns = n; }
|
||||||
void setNumRows(int n) { m_NumRows = n; }
|
void setNumRows(int n) { m_NumRows = n; }
|
||||||
void haveHeartbeat(bool on) { m_HasHeartbeat = on; }
|
void haveHeartbeat(bool on) { m_HasHeartbeat = on; }
|
||||||
void setHeartbeat(int val) { m_Heartbeat = val; }
|
void setHeartbeat(int val) { m_Heartbeat = val; }
|
||||||
void setRelativeMouseMoves(bool on) { m_RelativeMouseMoves = on; }
|
void setRelativeMouseMoves(bool on) { m_RelativeMouseMoves = on; }
|
||||||
void setScreenSaverSync(bool on) { m_ScreenSaverSync = on; }
|
void setScreenSaverSync(bool on) { m_ScreenSaverSync = on; }
|
||||||
void setWin32KeepForeground(bool on) { m_Win32KeepForeground = on; }
|
void setWin32KeepForeground(bool on) { m_Win32KeepForeground = on; }
|
||||||
void haveSwitchDelay(bool on) { m_HasSwitchDelay = on; }
|
void haveSwitchDelay(bool on) { m_HasSwitchDelay = on; }
|
||||||
void setSwitchDelay(int val) { m_SwitchDelay = val; }
|
void setSwitchDelay(int val) { m_SwitchDelay = val; }
|
||||||
void haveSwitchDoubleTap(bool on) { m_HasSwitchDoubleTap = on; }
|
void haveSwitchDoubleTap(bool on) { m_HasSwitchDoubleTap = on; }
|
||||||
void setSwitchDoubleTap(int val) { m_SwitchDoubleTap = val; }
|
void setSwitchDoubleTap(int val) { m_SwitchDoubleTap = val; }
|
||||||
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
||||||
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
||||||
void setIgnoreAutoConfigClient(bool on) { m_IgnoreAutoConfigClient = on; }
|
void setIgnoreAutoConfigClient(bool on) { m_IgnoreAutoConfigClient = on; }
|
||||||
void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; }
|
void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; }
|
||||||
void setClipboardSharing(bool on) { m_ClipboardSharing = on; }
|
void setClipboardSharing(bool on) { m_ClipboardSharing = on; }
|
||||||
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
||||||
HotkeyList& hotkeys() { return m_Hotkeys; }
|
HotkeyList& hotkeys() { return m_Hotkeys; }
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
|
int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool findScreenName(const QString& name, int& index);
|
bool findScreenName(const QString& name, int& index);
|
||||||
bool fixNoServer(const QString& name, int& index);
|
bool fixNoServer(const QString& name, int& index);
|
||||||
int showAddClientDialog(const QString& clientName);
|
int showAddClientDialog(const QString& clientName);
|
||||||
void addToFirstEmptyGrid(const QString& clientName);
|
void addToFirstEmptyGrid(const QString& clientName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings* m_pSettings;
|
QSettings* m_pSettings;
|
||||||
ScreenList m_Screens;
|
ScreenList m_Screens;
|
||||||
int m_NumColumns;
|
int m_NumColumns;
|
||||||
int m_NumRows;
|
int m_NumRows;
|
||||||
bool m_HasHeartbeat;
|
bool m_HasHeartbeat;
|
||||||
int m_Heartbeat;
|
int m_Heartbeat;
|
||||||
bool m_RelativeMouseMoves;
|
bool m_RelativeMouseMoves;
|
||||||
bool m_ScreenSaverSync;
|
bool m_ScreenSaverSync;
|
||||||
bool m_Win32KeepForeground;
|
bool m_Win32KeepForeground;
|
||||||
bool m_HasSwitchDelay;
|
bool m_HasSwitchDelay;
|
||||||
int m_SwitchDelay;
|
int m_SwitchDelay;
|
||||||
bool m_HasSwitchDoubleTap;
|
bool m_HasSwitchDoubleTap;
|
||||||
int m_SwitchDoubleTap;
|
int m_SwitchDoubleTap;
|
||||||
int m_SwitchCornerSize;
|
int m_SwitchCornerSize;
|
||||||
QList<bool> m_SwitchCorners;
|
QList<bool> m_SwitchCorners;
|
||||||
HotkeyList m_Hotkeys;
|
HotkeyList m_Hotkeys;
|
||||||
QString m_ServerName;
|
QString m_ServerName;
|
||||||
bool m_IgnoreAutoConfigClient;
|
bool m_IgnoreAutoConfigClient;
|
||||||
bool m_EnableDragAndDrop;
|
bool m_EnableDragAndDrop;
|
||||||
bool m_ClipboardSharing;
|
bool m_ClipboardSharing;
|
||||||
MainWindow* m_pMainWindow;
|
MainWindow* m_pMainWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config);
|
QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
kAutoAddScreenOk,
|
kAutoAddScreenOk,
|
||||||
kAutoAddScreenManualServer,
|
kAutoAddScreenManualServer,
|
||||||
kAutoAddScreenManualClient,
|
kAutoAddScreenManualClient,
|
||||||
kAutoAddScreenIgnore
|
kAutoAddScreenIgnore
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,194 +26,194 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, const QString& defaultScreenName) :
|
ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, const QString& defaultScreenName) :
|
||||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::ServerConfigDialogBase(),
|
Ui::ServerConfigDialogBase(),
|
||||||
m_OrigServerConfig(config),
|
m_OrigServerConfig(config),
|
||||||
m_ServerConfig(config),
|
m_ServerConfig(config),
|
||||||
m_ScreenSetupModel(serverConfig().screens(), serverConfig().numColumns(), serverConfig().numRows()),
|
m_ScreenSetupModel(serverConfig().screens(), serverConfig().numColumns(), serverConfig().numRows()),
|
||||||
m_Message("")
|
m_Message("")
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
|
m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
|
||||||
m_pSpinBoxHeartbeat->setValue(serverConfig().heartbeat());
|
m_pSpinBoxHeartbeat->setValue(serverConfig().heartbeat());
|
||||||
|
|
||||||
m_pCheckBoxRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
|
m_pCheckBoxRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
|
||||||
m_pCheckBoxScreenSaverSync->setChecked(serverConfig().screenSaverSync());
|
m_pCheckBoxScreenSaverSync->setChecked(serverConfig().screenSaverSync());
|
||||||
m_pCheckBoxWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
|
m_pCheckBoxWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
|
||||||
|
|
||||||
m_pCheckBoxSwitchDelay->setChecked(serverConfig().hasSwitchDelay());
|
m_pCheckBoxSwitchDelay->setChecked(serverConfig().hasSwitchDelay());
|
||||||
m_pSpinBoxSwitchDelay->setValue(serverConfig().switchDelay());
|
m_pSpinBoxSwitchDelay->setValue(serverConfig().switchDelay());
|
||||||
|
|
||||||
m_pCheckBoxSwitchDoubleTap->setChecked(serverConfig().hasSwitchDoubleTap());
|
m_pCheckBoxSwitchDoubleTap->setChecked(serverConfig().hasSwitchDoubleTap());
|
||||||
m_pSpinBoxSwitchDoubleTap->setValue(serverConfig().switchDoubleTap());
|
m_pSpinBoxSwitchDoubleTap->setValue(serverConfig().switchDoubleTap());
|
||||||
|
|
||||||
m_pCheckBoxCornerTopLeft->setChecked(serverConfig().switchCorner(BaseConfig::TopLeft));
|
m_pCheckBoxCornerTopLeft->setChecked(serverConfig().switchCorner(BaseConfig::TopLeft));
|
||||||
m_pCheckBoxCornerTopRight->setChecked(serverConfig().switchCorner(BaseConfig::TopRight));
|
m_pCheckBoxCornerTopRight->setChecked(serverConfig().switchCorner(BaseConfig::TopRight));
|
||||||
m_pCheckBoxCornerBottomLeft->setChecked(serverConfig().switchCorner(BaseConfig::BottomLeft));
|
m_pCheckBoxCornerBottomLeft->setChecked(serverConfig().switchCorner(BaseConfig::BottomLeft));
|
||||||
m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(BaseConfig::BottomRight));
|
m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(BaseConfig::BottomRight));
|
||||||
m_pSpinBoxSwitchCornerSize->setValue(serverConfig().switchCornerSize());
|
m_pSpinBoxSwitchCornerSize->setValue(serverConfig().switchCornerSize());
|
||||||
|
|
||||||
m_pCheckBoxIgnoreAutoConfigClient->setChecked(serverConfig().ignoreAutoConfigClient());
|
m_pCheckBoxIgnoreAutoConfigClient->setChecked(serverConfig().ignoreAutoConfigClient());
|
||||||
|
|
||||||
m_pCheckBoxEnableDragAndDrop->setChecked(serverConfig().enableDragAndDrop());
|
m_pCheckBoxEnableDragAndDrop->setChecked(serverConfig().enableDragAndDrop());
|
||||||
|
|
||||||
m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing());
|
m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing());
|
||||||
|
|
||||||
foreach(const Hotkey& hotkey, serverConfig().hotkeys())
|
foreach(const Hotkey& hotkey, serverConfig().hotkeys())
|
||||||
m_pListHotkeys->addItem(hotkey.text());
|
m_pListHotkeys->addItem(hotkey.text());
|
||||||
|
|
||||||
m_pScreenSetupView->setModel(&m_ScreenSetupModel);
|
m_pScreenSetupView->setModel(&m_ScreenSetupModel);
|
||||||
|
|
||||||
if (serverConfig().numScreens() == 0)
|
if (serverConfig().numScreens() == 0)
|
||||||
model().screen(serverConfig().numColumns() / 2, serverConfig().numRows() / 2) = Screen(defaultScreenName);
|
model().screen(serverConfig().numColumns() / 2, serverConfig().numRows() / 2) = Screen(defaultScreenName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::showEvent(QShowEvent* event)
|
void ServerConfigDialog::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
QDialog::show();
|
QDialog::show();
|
||||||
|
|
||||||
if (!m_Message.isEmpty())
|
if (!m_Message.isEmpty())
|
||||||
{
|
{
|
||||||
// TODO: ideally this massage box should pop up after the dialog is shown
|
// TODO: ideally this massage box should pop up after the dialog is shown
|
||||||
QMessageBox::information(this, tr("Configure server"), m_Message);
|
QMessageBox::information(this, tr("Configure server"), m_Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::accept()
|
void ServerConfigDialog::accept()
|
||||||
{
|
{
|
||||||
serverConfig().haveHeartbeat(m_pCheckBoxHeartbeat->isChecked());
|
serverConfig().haveHeartbeat(m_pCheckBoxHeartbeat->isChecked());
|
||||||
serverConfig().setHeartbeat(m_pSpinBoxHeartbeat->value());
|
serverConfig().setHeartbeat(m_pSpinBoxHeartbeat->value());
|
||||||
|
|
||||||
serverConfig().setRelativeMouseMoves(m_pCheckBoxRelativeMouseMoves->isChecked());
|
serverConfig().setRelativeMouseMoves(m_pCheckBoxRelativeMouseMoves->isChecked());
|
||||||
serverConfig().setScreenSaverSync(m_pCheckBoxScreenSaverSync->isChecked());
|
serverConfig().setScreenSaverSync(m_pCheckBoxScreenSaverSync->isChecked());
|
||||||
serverConfig().setWin32KeepForeground(m_pCheckBoxWin32KeepForeground->isChecked());
|
serverConfig().setWin32KeepForeground(m_pCheckBoxWin32KeepForeground->isChecked());
|
||||||
|
|
||||||
serverConfig().haveSwitchDelay(m_pCheckBoxSwitchDelay->isChecked());
|
serverConfig().haveSwitchDelay(m_pCheckBoxSwitchDelay->isChecked());
|
||||||
serverConfig().setSwitchDelay(m_pSpinBoxSwitchDelay->value());
|
serverConfig().setSwitchDelay(m_pSpinBoxSwitchDelay->value());
|
||||||
|
|
||||||
serverConfig().haveSwitchDoubleTap(m_pCheckBoxSwitchDoubleTap->isChecked());
|
serverConfig().haveSwitchDoubleTap(m_pCheckBoxSwitchDoubleTap->isChecked());
|
||||||
serverConfig().setSwitchDoubleTap(m_pSpinBoxSwitchDoubleTap->value());
|
serverConfig().setSwitchDoubleTap(m_pSpinBoxSwitchDoubleTap->value());
|
||||||
|
|
||||||
serverConfig().setSwitchCorner(BaseConfig::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
serverConfig().setSwitchCorner(BaseConfig::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
||||||
serverConfig().setSwitchCorner(BaseConfig::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
serverConfig().setSwitchCorner(BaseConfig::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
||||||
serverConfig().setSwitchCorner(BaseConfig::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
serverConfig().setSwitchCorner(BaseConfig::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
||||||
serverConfig().setSwitchCorner(BaseConfig::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
serverConfig().setSwitchCorner(BaseConfig::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
||||||
serverConfig().setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
serverConfig().setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
||||||
serverConfig().setIgnoreAutoConfigClient(m_pCheckBoxIgnoreAutoConfigClient->isChecked());
|
serverConfig().setIgnoreAutoConfigClient(m_pCheckBoxIgnoreAutoConfigClient->isChecked());
|
||||||
serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked());
|
serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked());
|
||||||
serverConfig().setClipboardSharing(m_pCheckBoxEnableClipboard->isChecked());
|
serverConfig().setClipboardSharing(m_pCheckBoxEnableClipboard->isChecked());
|
||||||
|
|
||||||
// now that the dialog has been accepted, copy the new server config to the original one,
|
// now that the dialog has been accepted, copy the new server config to the original one,
|
||||||
// which is a reference to the one in MainWindow.
|
// which is a reference to the one in MainWindow.
|
||||||
setOrigServerConfig(serverConfig());
|
setOrigServerConfig(serverConfig());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pButtonNewHotkey_clicked()
|
void ServerConfigDialog::on_m_pButtonNewHotkey_clicked()
|
||||||
{
|
{
|
||||||
Hotkey hotkey;
|
Hotkey hotkey;
|
||||||
HotkeyDialog dlg(this, hotkey);
|
HotkeyDialog dlg(this, hotkey);
|
||||||
if (dlg.exec() == QDialog::Accepted)
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
serverConfig().hotkeys().append(hotkey);
|
serverConfig().hotkeys().append(hotkey);
|
||||||
m_pListHotkeys->addItem(hotkey.text());
|
m_pListHotkeys->addItem(hotkey.text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pButtonEditHotkey_clicked()
|
void ServerConfigDialog::on_m_pButtonEditHotkey_clicked()
|
||||||
{
|
{
|
||||||
int idx = m_pListHotkeys->currentRow();
|
int idx = m_pListHotkeys->currentRow();
|
||||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||||
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||||
HotkeyDialog dlg(this, hotkey);
|
HotkeyDialog dlg(this, hotkey);
|
||||||
if (dlg.exec() == QDialog::Accepted)
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
m_pListHotkeys->currentItem()->setText(hotkey.text());
|
m_pListHotkeys->currentItem()->setText(hotkey.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pButtonRemoveHotkey_clicked()
|
void ServerConfigDialog::on_m_pButtonRemoveHotkey_clicked()
|
||||||
{
|
{
|
||||||
int idx = m_pListHotkeys->currentRow();
|
int idx = m_pListHotkeys->currentRow();
|
||||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||||
serverConfig().hotkeys().removeAt(idx);
|
serverConfig().hotkeys().removeAt(idx);
|
||||||
m_pListActions->clear();
|
m_pListActions->clear();
|
||||||
delete m_pListHotkeys->item(idx);
|
delete m_pListHotkeys->item(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pListHotkeys_itemSelectionChanged()
|
void ServerConfigDialog::on_m_pListHotkeys_itemSelectionChanged()
|
||||||
{
|
{
|
||||||
bool itemsSelected = !m_pListHotkeys->selectedItems().isEmpty();
|
bool itemsSelected = !m_pListHotkeys->selectedItems().isEmpty();
|
||||||
m_pButtonEditHotkey->setEnabled(itemsSelected);
|
m_pButtonEditHotkey->setEnabled(itemsSelected);
|
||||||
m_pButtonRemoveHotkey->setEnabled(itemsSelected);
|
m_pButtonRemoveHotkey->setEnabled(itemsSelected);
|
||||||
m_pButtonNewAction->setEnabled(itemsSelected);
|
m_pButtonNewAction->setEnabled(itemsSelected);
|
||||||
|
|
||||||
if (itemsSelected && serverConfig().hotkeys().size() > 0)
|
if (itemsSelected && serverConfig().hotkeys().size() > 0)
|
||||||
{
|
{
|
||||||
m_pListActions->clear();
|
m_pListActions->clear();
|
||||||
|
|
||||||
int idx = m_pListHotkeys->row(m_pListHotkeys->selectedItems()[0]);
|
int idx = m_pListHotkeys->row(m_pListHotkeys->selectedItems()[0]);
|
||||||
|
|
||||||
// There's a bug somewhere around here: We get idx == 1 right after we deleted the next to last item, so idx can
|
// There's a bug somewhere around here: We get idx == 1 right after we deleted the next to last item, so idx can
|
||||||
// only possibly be 0. GDB shows we got called indirectly from the delete line in
|
// only possibly be 0. GDB shows we got called indirectly from the delete line in
|
||||||
// on_m_pButtonRemoveHotkey_clicked() above, but the delete is of course necessary and seems correct.
|
// on_m_pButtonRemoveHotkey_clicked() above, but the delete is of course necessary and seems correct.
|
||||||
// The while() is a generalized workaround for all that and shouldn't be required.
|
// The while() is a generalized workaround for all that and shouldn't be required.
|
||||||
while (idx >= 0 && idx >= serverConfig().hotkeys().size())
|
while (idx >= 0 && idx >= serverConfig().hotkeys().size())
|
||||||
idx--;
|
idx--;
|
||||||
|
|
||||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||||
|
|
||||||
const Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
const Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||||
foreach(const Action& action, hotkey.actions())
|
foreach(const Action& action, hotkey.actions())
|
||||||
m_pListActions->addItem(action.text());
|
m_pListActions->addItem(action.text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pButtonNewAction_clicked()
|
void ServerConfigDialog::on_m_pButtonNewAction_clicked()
|
||||||
{
|
{
|
||||||
int idx = m_pListHotkeys->currentRow();
|
int idx = m_pListHotkeys->currentRow();
|
||||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||||
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||||
|
|
||||||
Action action;
|
Action action;
|
||||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||||
if (dlg.exec() == QDialog::Accepted)
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
hotkey.actions().append(action);
|
hotkey.actions().append(action);
|
||||||
m_pListActions->addItem(action.text());
|
m_pListActions->addItem(action.text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pButtonEditAction_clicked()
|
void ServerConfigDialog::on_m_pButtonEditAction_clicked()
|
||||||
{
|
{
|
||||||
int idxHotkey = m_pListHotkeys->currentRow();
|
int idxHotkey = m_pListHotkeys->currentRow();
|
||||||
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
||||||
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
||||||
|
|
||||||
int idxAction = m_pListActions->currentRow();
|
int idxAction = m_pListActions->currentRow();
|
||||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||||
Action& action = hotkey.actions()[idxAction];
|
Action& action = hotkey.actions()[idxAction];
|
||||||
|
|
||||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||||
if (dlg.exec() == QDialog::Accepted)
|
if (dlg.exec() == QDialog::Accepted)
|
||||||
m_pListActions->currentItem()->setText(action.text());
|
m_pListActions->currentItem()->setText(action.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pButtonRemoveAction_clicked()
|
void ServerConfigDialog::on_m_pButtonRemoveAction_clicked()
|
||||||
{
|
{
|
||||||
int idxHotkey = m_pListHotkeys->currentRow();
|
int idxHotkey = m_pListHotkeys->currentRow();
|
||||||
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
||||||
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
||||||
|
|
||||||
int idxAction = m_pListActions->currentRow();
|
int idxAction = m_pListActions->currentRow();
|
||||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||||
|
|
||||||
hotkey.actions().removeAt(idxAction);
|
hotkey.actions().removeAt(idxAction);
|
||||||
delete m_pListActions->currentItem();
|
delete m_pListActions->currentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConfigDialog::on_m_pListActions_itemSelectionChanged()
|
void ServerConfigDialog::on_m_pListActions_itemSelectionChanged()
|
||||||
{
|
{
|
||||||
m_pButtonEditAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
m_pButtonEditAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
||||||
m_pButtonRemoveAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
m_pButtonRemoveAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,37 +29,37 @@
|
||||||
|
|
||||||
class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase
|
class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerConfigDialog(QWidget* parent, ServerConfig& config, const QString& defaultScreenName);
|
ServerConfigDialog(QWidget* parent, ServerConfig& config, const QString& defaultScreenName);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void accept();
|
void accept();
|
||||||
void showEvent(QShowEvent* event);
|
void showEvent(QShowEvent* event);
|
||||||
void message(const QString& message) { m_Message = message; }
|
void message(const QString& message) { m_Message = message; }
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void on_m_pButtonNewHotkey_clicked();
|
void on_m_pButtonNewHotkey_clicked();
|
||||||
void on_m_pListHotkeys_itemSelectionChanged();
|
void on_m_pListHotkeys_itemSelectionChanged();
|
||||||
void on_m_pButtonEditHotkey_clicked();
|
void on_m_pButtonEditHotkey_clicked();
|
||||||
void on_m_pButtonRemoveHotkey_clicked();
|
void on_m_pButtonRemoveHotkey_clicked();
|
||||||
|
|
||||||
void on_m_pButtonNewAction_clicked();
|
void on_m_pButtonNewAction_clicked();
|
||||||
void on_m_pListActions_itemSelectionChanged();
|
void on_m_pListActions_itemSelectionChanged();
|
||||||
void on_m_pButtonEditAction_clicked();
|
void on_m_pButtonEditAction_clicked();
|
||||||
void on_m_pButtonRemoveAction_clicked();
|
void on_m_pButtonRemoveAction_clicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ServerConfig& serverConfig() { return m_ServerConfig; }
|
ServerConfig& serverConfig() { return m_ServerConfig; }
|
||||||
void setOrigServerConfig(const ServerConfig& s) { m_OrigServerConfig = s; }
|
void setOrigServerConfig(const ServerConfig& s) { m_OrigServerConfig = s; }
|
||||||
ScreenSetupModel& model() { return m_ScreenSetupModel; }
|
ScreenSetupModel& model() { return m_ScreenSetupModel; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ServerConfig& m_OrigServerConfig;
|
ServerConfig& m_OrigServerConfig;
|
||||||
ServerConfig m_ServerConfig;
|
ServerConfig m_ServerConfig;
|
||||||
ScreenSetupModel m_ScreenSetupModel;
|
ScreenSetupModel m_ScreenSetupModel;
|
||||||
QString m_Message;
|
QString m_Message;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,120 +36,120 @@
|
||||||
static const char networkSecurity[] = "ns";
|
static const char networkSecurity[] = "ns";
|
||||||
|
|
||||||
SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||||
Ui::SettingsDialogBase(),
|
Ui::SettingsDialogBase(),
|
||||||
m_appConfig(config)
|
m_appConfig(config)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
||||||
|
|
||||||
m_pLineEditScreenName->setText(appConfig().screenName());
|
m_pLineEditScreenName->setText(appConfig().screenName());
|
||||||
m_pSpinBoxPort->setValue(appConfig().port());
|
m_pSpinBoxPort->setValue(appConfig().port());
|
||||||
m_pLineEditInterface->setText(appConfig().networkInterface());
|
m_pLineEditInterface->setText(appConfig().networkInterface());
|
||||||
m_pComboLogLevel->setCurrentIndex(appConfig().logLevel());
|
m_pComboLogLevel->setCurrentIndex(appConfig().logLevel());
|
||||||
m_pCheckBoxLogToFile->setChecked(appConfig().logToFile());
|
m_pCheckBoxLogToFile->setChecked(appConfig().logToFile());
|
||||||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||||
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
||||||
m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide());
|
m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide());
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
m_pComboElevate->setCurrentIndex(static_cast<int>(appConfig().elevateMode()));
|
m_pComboElevate->setCurrentIndex(static_cast<int>(appConfig().elevateMode()));
|
||||||
|
|
||||||
m_pCheckBoxAutoHide->hide();
|
m_pCheckBoxAutoHide->hide();
|
||||||
#else
|
#else
|
||||||
// elevate checkbox is only useful on ms windows.
|
// elevate checkbox is only useful on ms windows.
|
||||||
m_pLabelElevate->hide();
|
m_pLabelElevate->hide();
|
||||||
m_pComboElevate->hide();
|
m_pComboElevate->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled());
|
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled());
|
||||||
m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.edition() == kPro);
|
m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.edition() == kPro);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::accept()
|
void SettingsDialog::accept()
|
||||||
{
|
{
|
||||||
appConfig().setScreenName(m_pLineEditScreenName->text());
|
appConfig().setScreenName(m_pLineEditScreenName->text());
|
||||||
appConfig().setPort(m_pSpinBoxPort->value());
|
appConfig().setPort(m_pSpinBoxPort->value());
|
||||||
appConfig().setNetworkInterface(m_pLineEditInterface->text());
|
appConfig().setNetworkInterface(m_pLineEditInterface->text());
|
||||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
||||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||||
appConfig().saveSettings();
|
appConfig().saveSettings();
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::reject()
|
void SettingsDialog::reject()
|
||||||
{
|
{
|
||||||
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
||||||
QSynergyApplication::getInstance()->switchTranslator(appConfig().language());
|
QSynergyApplication::getInstance()->switchTranslator(appConfig().language());
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::changeEvent(QEvent* event)
|
void SettingsDialog::changeEvent(QEvent* event)
|
||||||
{
|
{
|
||||||
if (event != 0)
|
if (event != 0)
|
||||||
{
|
{
|
||||||
switch (event->type())
|
switch (event->type())
|
||||||
{
|
{
|
||||||
case QEvent::LanguageChange:
|
case QEvent::LanguageChange:
|
||||||
{
|
{
|
||||||
int logLevelIndex = m_pComboLogLevel->currentIndex();
|
int logLevelIndex = m_pComboLogLevel->currentIndex();
|
||||||
|
|
||||||
m_pComboLanguage->blockSignals(true);
|
m_pComboLanguage->blockSignals(true);
|
||||||
retranslateUi(this);
|
retranslateUi(this);
|
||||||
m_pComboLanguage->blockSignals(false);
|
m_pComboLanguage->blockSignals(false);
|
||||||
|
|
||||||
m_pComboLogLevel->setCurrentIndex(logLevelIndex);
|
m_pComboLogLevel->setCurrentIndex(logLevelIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
QDialog::changeEvent(event);
|
QDialog::changeEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_m_pCheckBoxLogToFile_stateChanged(int i)
|
void SettingsDialog::on_m_pCheckBoxLogToFile_stateChanged(int i)
|
||||||
{
|
{
|
||||||
bool checked = i == 2;
|
bool checked = i == 2;
|
||||||
|
|
||||||
m_pLineEditLogFilename->setEnabled(checked);
|
m_pLineEditLogFilename->setEnabled(checked);
|
||||||
m_pButtonBrowseLog->setEnabled(checked);
|
m_pButtonBrowseLog->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_m_pButtonBrowseLog_clicked()
|
void SettingsDialog::on_m_pButtonBrowseLog_clicked()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(
|
QString fileName = QFileDialog::getSaveFileName(
|
||||||
this, tr("Save log file to..."),
|
this, tr("Save log file to..."),
|
||||||
m_pLineEditLogFilename->text(),
|
m_pLineEditLogFilename->text(),
|
||||||
"Logs (*.log *.txt)");
|
"Logs (*.log *.txt)");
|
||||||
|
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
{
|
{
|
||||||
m_pLineEditLogFilename->setText(fileName);
|
m_pLineEditLogFilename->setText(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
|
void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
||||||
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked)
|
void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked)
|
||||||
{
|
{
|
||||||
m_appConfig.setCryptoEnabled(checked);
|
m_appConfig.setCryptoEnabled(checked);
|
||||||
m_appConfig.saveSettings();
|
m_appConfig.saveSettings();
|
||||||
if (checked) {
|
if (checked) {
|
||||||
SslCertificate sslCertificate;
|
SslCertificate sslCertificate;
|
||||||
sslCertificate.generateCertificate();
|
sslCertificate.generateCertificate();
|
||||||
MainWindow& mainWindow = dynamic_cast<MainWindow&> (*this->parent());
|
MainWindow& mainWindow = dynamic_cast<MainWindow&> (*this->parent());
|
||||||
mainWindow.updateLocalFingerprint();
|
mainWindow.updateLocalFingerprint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,29 +29,29 @@ class AppConfig;
|
||||||
|
|
||||||
class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
|
class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SettingsDialog(QWidget* parent, AppConfig& config);
|
SettingsDialog(QWidget* parent, AppConfig& config);
|
||||||
static QString browseForSynergyc(QWidget* parent, const QString& programDir, const QString& synergycName);
|
static QString browseForSynergyc(QWidget* parent, const QString& programDir, const QString& synergycName);
|
||||||
static QString browseForSynergys(QWidget* parent, const QString& programDir, const QString& synergysName);
|
static QString browseForSynergys(QWidget* parent, const QString& programDir, const QString& synergysName);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void accept();
|
void accept();
|
||||||
void reject();
|
void reject();
|
||||||
void changeEvent(QEvent* event);
|
void changeEvent(QEvent* event);
|
||||||
AppConfig& appConfig() { return m_appConfig; }
|
AppConfig& appConfig() { return m_appConfig; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppConfig& m_appConfig;
|
AppConfig& m_appConfig;
|
||||||
SynergyLocale m_Locale;
|
SynergyLocale m_Locale;
|
||||||
CoreInterface m_CoreInterface;
|
CoreInterface m_CoreInterface;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_pCheckBoxEnableCrypto_toggled(bool checked);
|
void on_m_pCheckBoxEnableCrypto_toggled(bool checked);
|
||||||
void on_m_pComboLanguage_currentIndexChanged(int index);
|
void on_m_pComboLanguage_currentIndexChanged(int index);
|
||||||
void on_m_pCheckBoxLogToFile_stateChanged(int );
|
void on_m_pCheckBoxLogToFile_stateChanged(int );
|
||||||
void on_m_pButtonBrowseLog_clicked();
|
void on_m_pButtonBrowseLog_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -27,34 +27,34 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
|
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
|
||||||
m_MainWindow(mainWindow),
|
m_MainWindow(mainWindow),
|
||||||
m_StartMain(startMain)
|
m_StartMain(startMain)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
|
||||||
// the mac style needs a little more room because of the
|
// the mac style needs a little more room because of the
|
||||||
// graphic on the left.
|
// graphic on the left.
|
||||||
resize(600, 500);
|
resize(600, 500);
|
||||||
setMinimumSize(size());
|
setMinimumSize(size());
|
||||||
|
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
|
|
||||||
// when areo is disabled on windows, the next/back buttons
|
// when areo is disabled on windows, the next/back buttons
|
||||||
// are hidden (must be a qt bug) -- resizing the window
|
// are hidden (must be a qt bug) -- resizing the window
|
||||||
// to +1 of the original height seems to fix this.
|
// to +1 of the original height seems to fix this.
|
||||||
// NOTE: calling setMinimumSize after this will break
|
// NOTE: calling setMinimumSize after this will break
|
||||||
// it again, so don't do that.
|
// it again, so don't do that.
|
||||||
resize(size().width(), size().height() + 1);
|
resize(size().width(), size().height() + 1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect(m_pServerRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupServer, SLOT(setChecked(bool)));
|
connect(m_pServerRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupServer, SLOT(setChecked(bool)));
|
||||||
connect(m_pClientRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupClient, SLOT(setChecked(bool)));
|
connect(m_pClientRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupClient, SLOT(setChecked(bool)));
|
||||||
|
|
||||||
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
||||||
setIndexFromItemData(m_pComboLanguage, m_MainWindow.appConfig().language());
|
setIndexFromItemData(m_pComboLanguage, m_MainWindow.appConfig().language());
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupWizard::~SetupWizard()
|
SetupWizard::~SetupWizard()
|
||||||
|
@ -62,91 +62,91 @@ SetupWizard::~SetupWizard()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetupWizard::validateCurrentPage()
|
bool SetupWizard::validateCurrentPage()
|
||||||
{
|
{
|
||||||
QMessageBox message;
|
QMessageBox message;
|
||||||
message.setWindowTitle(tr("Setup Synergy"));
|
message.setWindowTitle(tr("Setup Synergy"));
|
||||||
message.setIcon(QMessageBox::Information);
|
message.setIcon(QMessageBox::Information);
|
||||||
|
|
||||||
if (currentPage() == m_pNodePage)
|
if (currentPage() == m_pNodePage)
|
||||||
{
|
{
|
||||||
bool result = m_pClientRadioButton->isChecked() ||
|
bool result = m_pClientRadioButton->isChecked() ||
|
||||||
m_pServerRadioButton->isChecked();
|
m_pServerRadioButton->isChecked();
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
message.setText(tr("Please select an option."));
|
message.setText(tr("Please select an option."));
|
||||||
message.exec();
|
message.exec();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizard::changeEvent(QEvent* event)
|
void SetupWizard::changeEvent(QEvent* event)
|
||||||
{
|
{
|
||||||
if (event != 0)
|
if (event != 0)
|
||||||
{
|
{
|
||||||
switch (event->type())
|
switch (event->type())
|
||||||
{
|
{
|
||||||
case QEvent::LanguageChange:
|
case QEvent::LanguageChange:
|
||||||
{
|
{
|
||||||
m_pComboLanguage->blockSignals(true);
|
m_pComboLanguage->blockSignals(true);
|
||||||
retranslateUi(this);
|
retranslateUi(this);
|
||||||
m_pComboLanguage->blockSignals(false);
|
m_pComboLanguage->blockSignals(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
QWizard::changeEvent(event);
|
QWizard::changeEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizard::accept()
|
void SetupWizard::accept()
|
||||||
{
|
{
|
||||||
AppConfig& appConfig = m_MainWindow.appConfig();
|
AppConfig& appConfig = m_MainWindow.appConfig();
|
||||||
|
|
||||||
appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
appConfig.setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||||
|
|
||||||
appConfig.setWizardHasRun();
|
appConfig.setWizardHasRun();
|
||||||
appConfig.saveSettings();
|
appConfig.saveSettings();
|
||||||
|
|
||||||
QSettings& settings = m_MainWindow.settings();
|
QSettings& settings = m_MainWindow.settings();
|
||||||
if (m_pServerRadioButton->isChecked())
|
if (m_pServerRadioButton->isChecked())
|
||||||
{
|
{
|
||||||
settings.setValue("groupServerChecked", true);
|
settings.setValue("groupServerChecked", true);
|
||||||
settings.setValue("groupClientChecked", false);
|
settings.setValue("groupClientChecked", false);
|
||||||
}
|
}
|
||||||
if (m_pClientRadioButton->isChecked())
|
if (m_pClientRadioButton->isChecked())
|
||||||
{
|
{
|
||||||
settings.setValue("groupClientChecked", true);
|
settings.setValue("groupClientChecked", true);
|
||||||
settings.setValue("groupServerChecked", false);
|
settings.setValue("groupServerChecked", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWizard::accept();
|
QWizard::accept();
|
||||||
|
|
||||||
if (m_StartMain)
|
if (m_StartMain)
|
||||||
{
|
{
|
||||||
m_MainWindow.updateZeroconfService();
|
m_MainWindow.updateZeroconfService();
|
||||||
m_MainWindow.open();
|
m_MainWindow.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizard::reject()
|
void SetupWizard::reject()
|
||||||
{
|
{
|
||||||
QSynergyApplication::getInstance()->switchTranslator(m_MainWindow.appConfig().language());
|
QSynergyApplication::getInstance()->switchTranslator(m_MainWindow.appConfig().language());
|
||||||
|
|
||||||
if (m_StartMain)
|
if (m_StartMain)
|
||||||
{
|
{
|
||||||
m_MainWindow.open();
|
m_MainWindow.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWizard::reject();
|
QWizard::reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index)
|
void SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
||||||
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,27 +27,27 @@ class MainWindow;
|
||||||
|
|
||||||
class SetupWizard : public QWizard, public Ui::SetupWizardBase
|
class SetupWizard : public QWizard, public Ui::SetupWizardBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum {
|
enum {
|
||||||
kMaximiumLoginAttemps = 3
|
kMaximiumLoginAttemps = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SetupWizard(MainWindow& mainWindow, bool startMain);
|
SetupWizard(MainWindow& mainWindow, bool startMain);
|
||||||
virtual ~SetupWizard();
|
virtual ~SetupWizard();
|
||||||
bool validateCurrentPage();
|
bool validateCurrentPage();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent* event);
|
void changeEvent(QEvent* event);
|
||||||
void accept();
|
void accept();
|
||||||
void reject();
|
void reject();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MainWindow& m_MainWindow;
|
MainWindow& m_MainWindow;
|
||||||
bool m_StartMain;
|
bool m_StartMain;
|
||||||
SynergyLocale m_Locale;
|
SynergyLocale m_Locale;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_m_pComboLanguage_currentIndexChanged(int index);
|
void on_m_pComboLanguage_currentIndexChanged(int index);
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,144 +35,144 @@ static const char kConfigFile[] = "OpenSSL\\synergy.conf";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SslCertificate::SslCertificate(QObject *parent) :
|
SslCertificate::SslCertificate(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
m_ProfileDir = m_CoreInterface.getProfileDir();
|
m_ProfileDir = m_CoreInterface.getProfileDir();
|
||||||
if (m_ProfileDir.isEmpty()) {
|
if (m_ProfileDir.isEmpty()) {
|
||||||
emit error(tr("Failed to get profile directory."));
|
emit error(tr("Failed to get profile directory."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SslCertificate::runTool(const QStringList& args)
|
bool SslCertificate::runTool(const QStringList& args)
|
||||||
{
|
{
|
||||||
QString program;
|
QString program;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
program = QCoreApplication::applicationDirPath();
|
program = QCoreApplication::applicationDirPath();
|
||||||
program.append("\\").append(kWinOpenSslBinary);
|
program.append("\\").append(kWinOpenSslBinary);
|
||||||
#else
|
#else
|
||||||
program = kUnixOpenSslCommand;
|
program = kUnixOpenSslCommand;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
QStringList environment;
|
QStringList environment;
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
environment << QString("OPENSSL_CONF=%1\\%2")
|
environment << QString("OPENSSL_CONF=%1\\%2")
|
||||||
.arg(QCoreApplication::applicationDirPath())
|
.arg(QCoreApplication::applicationDirPath())
|
||||||
.arg(kConfigFile);
|
.arg(kConfigFile);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.setEnvironment(environment);
|
process.setEnvironment(environment);
|
||||||
process.start(program, args);
|
process.start(program, args);
|
||||||
|
|
||||||
bool success = process.waitForStarted();
|
bool success = process.waitForStarted();
|
||||||
|
|
||||||
QString standardError;
|
QString standardError;
|
||||||
if (success && process.waitForFinished())
|
if (success && process.waitForFinished())
|
||||||
{
|
{
|
||||||
m_ToolOutput = process.readAllStandardOutput().trimmed();
|
m_ToolOutput = process.readAllStandardOutput().trimmed();
|
||||||
standardError = process.readAllStandardError().trimmed();
|
standardError = process.readAllStandardError().trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = process.exitCode();
|
int code = process.exitCode();
|
||||||
if (!success || code != 0)
|
if (!success || code != 0)
|
||||||
{
|
{
|
||||||
emit error(
|
emit error(
|
||||||
QString("SSL tool failed: %1\n\nCode: %2\nError: %3")
|
QString("SSL tool failed: %1\n\nCode: %2\nError: %3")
|
||||||
.arg(program)
|
.arg(program)
|
||||||
.arg(process.exitCode())
|
.arg(process.exitCode())
|
||||||
.arg(standardError.isEmpty() ? "Unknown" : standardError));
|
.arg(standardError.isEmpty() ? "Unknown" : standardError));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SslCertificate::generateCertificate()
|
void SslCertificate::generateCertificate()
|
||||||
{
|
{
|
||||||
QString sslDirPath = QString("%1%2%3")
|
QString sslDirPath = QString("%1%2%3")
|
||||||
.arg(m_ProfileDir)
|
.arg(m_ProfileDir)
|
||||||
.arg(QDir::separator())
|
.arg(QDir::separator())
|
||||||
.arg(kSslDir);
|
.arg(kSslDir);
|
||||||
|
|
||||||
QString filename = QString("%1%2%3")
|
QString filename = QString("%1%2%3")
|
||||||
.arg(sslDirPath)
|
.arg(sslDirPath)
|
||||||
.arg(QDir::separator())
|
.arg(QDir::separator())
|
||||||
.arg(kCertificateFilename);
|
.arg(kCertificateFilename);
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
|
||||||
// self signed certificate
|
// self signed certificate
|
||||||
arguments.append("req");
|
arguments.append("req");
|
||||||
arguments.append("-x509");
|
arguments.append("-x509");
|
||||||
arguments.append("-nodes");
|
arguments.append("-nodes");
|
||||||
|
|
||||||
// valide duration
|
// valide duration
|
||||||
arguments.append("-days");
|
arguments.append("-days");
|
||||||
arguments.append(kCertificateLifetime);
|
arguments.append(kCertificateLifetime);
|
||||||
|
|
||||||
// subject information
|
// subject information
|
||||||
arguments.append("-subj");
|
arguments.append("-subj");
|
||||||
|
|
||||||
QString subInfo(kCertificateSubjectInfo);
|
QString subInfo(kCertificateSubjectInfo);
|
||||||
arguments.append(subInfo);
|
arguments.append(subInfo);
|
||||||
|
|
||||||
// private key
|
// private key
|
||||||
arguments.append("-newkey");
|
arguments.append("-newkey");
|
||||||
arguments.append("rsa:1024");
|
arguments.append("rsa:1024");
|
||||||
|
|
||||||
QDir sslDir(sslDirPath);
|
QDir sslDir(sslDirPath);
|
||||||
if (!sslDir.exists()) {
|
if (!sslDir.exists()) {
|
||||||
sslDir.mkpath(".");
|
sslDir.mkpath(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// key output filename
|
// key output filename
|
||||||
arguments.append("-keyout");
|
arguments.append("-keyout");
|
||||||
arguments.append(filename);
|
arguments.append(filename);
|
||||||
|
|
||||||
// certificate output filename
|
// certificate output filename
|
||||||
arguments.append("-out");
|
arguments.append("-out");
|
||||||
arguments.append(filename);
|
arguments.append(filename);
|
||||||
|
|
||||||
if (!runTool(arguments)) {
|
if (!runTool(arguments)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit info(tr("SSL certificate generated."));
|
emit info(tr("SSL certificate generated."));
|
||||||
}
|
}
|
||||||
|
|
||||||
generateFingerprint(filename);
|
generateFingerprint(filename);
|
||||||
|
|
||||||
emit generateFinished();
|
emit generateFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SslCertificate::generateFingerprint(const QString& certificateFilename)
|
void SslCertificate::generateFingerprint(const QString& certificateFilename)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments.append("x509");
|
arguments.append("x509");
|
||||||
arguments.append("-fingerprint");
|
arguments.append("-fingerprint");
|
||||||
arguments.append("-sha1");
|
arguments.append("-sha1");
|
||||||
arguments.append("-noout");
|
arguments.append("-noout");
|
||||||
arguments.append("-in");
|
arguments.append("-in");
|
||||||
arguments.append(certificateFilename);
|
arguments.append(certificateFilename);
|
||||||
|
|
||||||
if (!runTool(arguments)) {
|
if (!runTool(arguments)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the fingerprint from the tool output
|
// find the fingerprint from the tool output
|
||||||
int i = m_ToolOutput.indexOf("=");
|
int i = m_ToolOutput.indexOf("=");
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
i++;
|
i++;
|
||||||
QString fingerprint = m_ToolOutput.mid(
|
QString fingerprint = m_ToolOutput.mid(
|
||||||
i, m_ToolOutput.size() - i);
|
i, m_ToolOutput.size() - i);
|
||||||
|
|
||||||
Fingerprint::local().trust(fingerprint, false);
|
Fingerprint::local().trust(fingerprint, false);
|
||||||
emit info(tr("SSL fingerprint generated."));
|
emit info(tr("SSL fingerprint generated."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit error(tr("Failed to find SSL fingerprint."));
|
emit error(tr("Failed to find SSL fingerprint."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,22 +26,22 @@ class SslCertificate : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SslCertificate(QObject *parent = 0);
|
explicit SslCertificate(QObject *parent = 0);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void generateCertificate();
|
void generateCertificate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void error(QString e);
|
void error(QString e);
|
||||||
void info(QString i);
|
void info(QString i);
|
||||||
void generateFinished();
|
void generateFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool runTool(const QStringList& args);
|
bool runTool(const QStringList& args);
|
||||||
void generateFingerprint(const QString& certificateFilename);
|
void generateFingerprint(const QString& certificateFilename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_ProfileDir;
|
QString m_ProfileDir;
|
||||||
QString m_ToolOutput;
|
QString m_ToolOutput;
|
||||||
CoreInterface m_CoreInterface;
|
CoreInterface m_CoreInterface;
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,46 +23,46 @@
|
||||||
|
|
||||||
SynergyLocale::SynergyLocale()
|
SynergyLocale::SynergyLocale()
|
||||||
{
|
{
|
||||||
loadLanguages();
|
loadLanguages();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynergyLocale::loadLanguages()
|
void SynergyLocale::loadLanguages()
|
||||||
{
|
{
|
||||||
QResource resource(":/res/lang/Languages.xml");
|
QResource resource(":/res/lang/Languages.xml");
|
||||||
QByteArray bytes(reinterpret_cast<const char*>(resource.data()), resource.size());
|
QByteArray bytes(reinterpret_cast<const char*>(resource.data()), resource.size());
|
||||||
QXmlStreamReader xml(bytes);
|
QXmlStreamReader xml(bytes);
|
||||||
|
|
||||||
while (!xml.atEnd())
|
while (!xml.atEnd())
|
||||||
{
|
{
|
||||||
QXmlStreamReader::TokenType token = xml.readNext();
|
QXmlStreamReader::TokenType token = xml.readNext();
|
||||||
if (xml.hasError())
|
if (xml.hasError())
|
||||||
{
|
{
|
||||||
qCritical() << xml.errorString();
|
qCritical() << xml.errorString();
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xml.name() == "language" && token == QXmlStreamReader::StartElement)
|
if (xml.name() == "language" && token == QXmlStreamReader::StartElement)
|
||||||
{
|
{
|
||||||
QXmlStreamAttributes attributes = xml.attributes();
|
QXmlStreamAttributes attributes = xml.attributes();
|
||||||
addLanguage(
|
addLanguage(
|
||||||
attributes.value("ietfCode").toString(),
|
attributes.value("ietfCode").toString(),
|
||||||
attributes.value("name").toString());
|
attributes.value("name").toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynergyLocale::addLanguage(const QString& ietfCode, const QString& name)
|
void SynergyLocale::addLanguage(const QString& ietfCode, const QString& name)
|
||||||
{
|
{
|
||||||
m_Languages.push_back(SynergyLocale::Language(ietfCode, name));
|
m_Languages.push_back(SynergyLocale::Language(ietfCode, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynergyLocale::fillLanguageComboBox(QComboBox* comboBox)
|
void SynergyLocale::fillLanguageComboBox(QComboBox* comboBox)
|
||||||
{
|
{
|
||||||
comboBox->blockSignals(true);
|
comboBox->blockSignals(true);
|
||||||
QVector<SynergyLocale::Language>::iterator it;
|
QVector<SynergyLocale::Language>::iterator it;
|
||||||
for (it = m_Languages.begin(); it != m_Languages.end(); ++it)
|
for (it = m_Languages.begin(); it != m_Languages.end(); ++it)
|
||||||
{
|
{
|
||||||
comboBox->addItem((*it).m_Name, (*it).m_IetfCode);
|
comboBox->addItem((*it).m_Name, (*it).m_IetfCode);
|
||||||
}
|
}
|
||||||
comboBox->blockSignals(false);
|
comboBox->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,26 +23,26 @@
|
||||||
|
|
||||||
class SynergyLocale
|
class SynergyLocale
|
||||||
{
|
{
|
||||||
class Language
|
class Language
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Language() { }
|
Language() { }
|
||||||
Language(const QString& IetfCode, const QString& name)
|
Language(const QString& IetfCode, const QString& name)
|
||||||
: m_IetfCode(IetfCode), m_Name(name) { }
|
: m_IetfCode(IetfCode), m_Name(name) { }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString m_IetfCode;
|
QString m_IetfCode;
|
||||||
QString m_Name;
|
QString m_Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SynergyLocale();
|
SynergyLocale();
|
||||||
void fillLanguageComboBox(QComboBox* comboBox);
|
void fillLanguageComboBox(QComboBox* comboBox);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadLanguages();
|
void loadLanguages();
|
||||||
void addLanguage(const QString& IetfCode, const QString& name);
|
void addLanguage(const QString& IetfCode, const QString& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<Language> m_Languages;
|
QVector<Language> m_Languages;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,20 +24,20 @@
|
||||||
|
|
||||||
void TrashScreenWidget::dragEnterEvent(QDragEnterEvent* event)
|
void TrashScreenWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||||
{
|
{
|
||||||
event->setDropAction(Qt::MoveAction);
|
event->setDropAction(Qt::MoveAction);
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrashScreenWidget::dropEvent(QDropEvent* event)
|
void TrashScreenWidget::dropEvent(QDropEvent* event)
|
||||||
{
|
{
|
||||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
else
|
else
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,14 @@ class QDropEvent;
|
||||||
|
|
||||||
class TrashScreenWidget : public QLabel
|
class TrashScreenWidget : public QLabel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrashScreenWidget(QWidget* parent) : QLabel(parent) {}
|
TrashScreenWidget(QWidget* parent) : QLabel(parent) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void dragEnterEvent(QDragEnterEvent* event);
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
void dropEvent(QDropEvent* event);
|
void dropEvent(QDropEvent* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,79 +29,79 @@
|
||||||
|
|
||||||
VersionChecker::VersionChecker()
|
VersionChecker::VersionChecker()
|
||||||
{
|
{
|
||||||
m_manager = new QNetworkAccessManager(this);
|
m_manager = new QNetworkAccessManager(this);
|
||||||
|
|
||||||
connect(m_manager, SIGNAL(finished(QNetworkReply*)),
|
connect(m_manager, SIGNAL(finished(QNetworkReply*)),
|
||||||
this, SLOT(replyFinished(QNetworkReply*)));
|
this, SLOT(replyFinished(QNetworkReply*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionChecker::~VersionChecker()
|
VersionChecker::~VersionChecker()
|
||||||
{
|
{
|
||||||
delete m_manager;
|
delete m_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionChecker::checkLatest()
|
void VersionChecker::checkLatest()
|
||||||
{
|
{
|
||||||
m_manager->get(QNetworkRequest(QUrl(VERSION_URL)));
|
m_manager->get(QNetworkRequest(QUrl(VERSION_URL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionChecker::replyFinished(QNetworkReply* reply)
|
void VersionChecker::replyFinished(QNetworkReply* reply)
|
||||||
{
|
{
|
||||||
QString newestVersion = QString(reply->readAll());
|
QString newestVersion = QString(reply->readAll());
|
||||||
if (!newestVersion.isEmpty())
|
if (!newestVersion.isEmpty())
|
||||||
{
|
{
|
||||||
QString currentVersion = getVersion();
|
QString currentVersion = getVersion();
|
||||||
if (currentVersion != "Unknown") {
|
if (currentVersion != "Unknown") {
|
||||||
if (compareVersions(currentVersion, newestVersion) > 0)
|
if (compareVersions(currentVersion, newestVersion) > 0)
|
||||||
emit updateFound(newestVersion);
|
emit updateFound(newestVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int VersionChecker::compareVersions(const QString& left, const QString& right)
|
int VersionChecker::compareVersions(const QString& left, const QString& right)
|
||||||
{
|
{
|
||||||
if (left.compare(right) == 0)
|
if (left.compare(right) == 0)
|
||||||
return 0; // versions are same.
|
return 0; // versions are same.
|
||||||
|
|
||||||
QStringList leftSplit = left.split(QRegExp("\\."));
|
QStringList leftSplit = left.split(QRegExp("\\."));
|
||||||
if (leftSplit.size() != 3)
|
if (leftSplit.size() != 3)
|
||||||
return 1; // assume right wins.
|
return 1; // assume right wins.
|
||||||
|
|
||||||
QStringList rightSplit = right.split(QRegExp("\\."));
|
QStringList rightSplit = right.split(QRegExp("\\."));
|
||||||
if (rightSplit.size() != 3)
|
if (rightSplit.size() != 3)
|
||||||
return -1; // assume left wins.
|
return -1; // assume left wins.
|
||||||
|
|
||||||
int leftMajor = leftSplit.at(0).toInt();
|
int leftMajor = leftSplit.at(0).toInt();
|
||||||
int leftMinor = leftSplit.at(1).toInt();
|
int leftMinor = leftSplit.at(1).toInt();
|
||||||
int leftRev = leftSplit.at(2).toInt();
|
int leftRev = leftSplit.at(2).toInt();
|
||||||
|
|
||||||
int rightMajor = rightSplit.at(0).toInt();
|
int rightMajor = rightSplit.at(0).toInt();
|
||||||
int rightMinor = rightSplit.at(1).toInt();
|
int rightMinor = rightSplit.at(1).toInt();
|
||||||
int rightRev = rightSplit.at(2).toInt();
|
int rightRev = rightSplit.at(2).toInt();
|
||||||
|
|
||||||
bool rightWins =
|
bool rightWins =
|
||||||
(rightMajor > leftMajor) ||
|
(rightMajor > leftMajor) ||
|
||||||
((rightMajor >= leftMajor) && (rightMinor > leftMinor)) ||
|
((rightMajor >= leftMajor) && (rightMinor > leftMinor)) ||
|
||||||
((rightMajor >= leftMajor) && (rightMinor >= leftMinor) && (rightRev > leftRev));
|
((rightMajor >= leftMajor) && (rightMinor >= leftMinor) && (rightRev > leftRev));
|
||||||
|
|
||||||
return rightWins ? 1 : -1;
|
return rightWins ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VersionChecker::getVersion()
|
QString VersionChecker::getVersion()
|
||||||
{
|
{
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.start(m_app, QStringList() << "--version");
|
process.start(m_app, QStringList() << "--version");
|
||||||
|
|
||||||
process.setReadChannel(QProcess::StandardOutput);
|
process.setReadChannel(QProcess::StandardOutput);
|
||||||
if (process.waitForStarted() && process.waitForFinished())
|
if (process.waitForStarted() && process.waitForFinished())
|
||||||
{
|
{
|
||||||
QRegExp rx(VERSION_REGEX);
|
QRegExp rx(VERSION_REGEX);
|
||||||
QString text = process.readLine();
|
QString text = process.readLine();
|
||||||
if (rx.indexIn(text) != -1)
|
if (rx.indexIn(text) != -1)
|
||||||
{
|
{
|
||||||
return rx.cap(1);
|
return rx.cap(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tr("Unknown");
|
return tr("Unknown");
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,19 +26,19 @@ class QNetworkReply;
|
||||||
|
|
||||||
class VersionChecker : public QObject
|
class VersionChecker : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VersionChecker();
|
VersionChecker();
|
||||||
virtual ~VersionChecker();
|
virtual ~VersionChecker();
|
||||||
void checkLatest();
|
void checkLatest();
|
||||||
QString getVersion();
|
QString getVersion();
|
||||||
void setApp(const QString& app) { m_app = app; }
|
void setApp(const QString& app) { m_app = app; }
|
||||||
int compareVersions(const QString& left, const QString& right);
|
int compareVersions(const QString& left, const QString& right);
|
||||||
public slots:
|
public slots:
|
||||||
void replyFinished(QNetworkReply* reply);
|
void replyFinished(QNetworkReply* reply);
|
||||||
signals:
|
signals:
|
||||||
void updateFound(const QString& version);
|
void updateFound(const QString& version);
|
||||||
private:
|
private:
|
||||||
QNetworkAccessManager* m_manager;
|
QNetworkAccessManager* m_manager;
|
||||||
QString m_app;
|
QString m_app;
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,58 +27,58 @@
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WebClient::getEdition (int& edition, QString& errorOut) {
|
WebClient::getEdition (int& edition, QString& errorOut) {
|
||||||
QString responseJson = request();
|
QString responseJson = request();
|
||||||
|
|
||||||
/* TODO: This is horrible and should be ripped out as soon as we move
|
/* TODO: This is horrible and should be ripped out as soon as we move
|
||||||
* to Qt 5. See issue #5630
|
* to Qt 5. See issue #5630
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
|
QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
|
||||||
if (resultRegex.exactMatch (responseJson)) {
|
if (resultRegex.exactMatch (responseJson)) {
|
||||||
QString boolString = resultRegex.cap(1);
|
QString boolString = resultRegex.cap(1);
|
||||||
if (boolString == "true") {
|
if (boolString == "true") {
|
||||||
QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
|
QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
|
||||||
if (editionRegex.exactMatch(responseJson)) {
|
if (editionRegex.exactMatch(responseJson)) {
|
||||||
QString e = editionRegex.cap(1);
|
QString e = editionRegex.cap(1);
|
||||||
edition = e.toInt();
|
edition = e.toInt();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error ("Unrecognised server response.");
|
throw std::runtime_error ("Unrecognised server response.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errorOut = tr("Login failed. Invalid email address or password.");
|
errorOut = tr("Login failed. Invalid email address or password.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
|
QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
|
||||||
if (errorRegex.exactMatch (responseJson)) {
|
if (errorRegex.exactMatch (responseJson)) {
|
||||||
errorOut = errorRegex.cap(1).replace("\\n", "\n");
|
errorOut = errorRegex.cap(1).replace("\\n", "\n");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error ("Unrecognised server response.");
|
throw std::runtime_error ("Unrecognised server response.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WebClient::setEmail (QString email, QString& errorOut) {
|
WebClient::setEmail (QString email, QString& errorOut) {
|
||||||
if (email.isEmpty()) {
|
if (email.isEmpty()) {
|
||||||
errorOut = tr("Your email address cannot be left blank.");
|
errorOut = tr("Your email address cannot be left blank.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
m_Email = email;
|
m_Email = email;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
WebClient::setPassword (QString password, QString&) {
|
WebClient::setPassword (QString password, QString&) {
|
||||||
m_Password = password;
|
m_Password = password;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
WebClient::request() {
|
WebClient::request() {
|
||||||
QStringList args("--login-auth");
|
QStringList args("--login-auth");
|
||||||
QString credentials (m_Email + ":" + hash(m_Password) + "\n");
|
QString credentials (m_Email + ":" + hash(m_Password) + "\n");
|
||||||
return m_CoreInterface.run (args, credentials);
|
return m_CoreInterface.run (args, credentials);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,21 +29,21 @@ class QStringList;
|
||||||
|
|
||||||
class WebClient : public QObject
|
class WebClient : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool getEdition (int& edition, QString& errorOut);
|
bool getEdition (int& edition, QString& errorOut);
|
||||||
bool setEmail (QString email, QString& errorOut);
|
bool setEmail (QString email, QString& errorOut);
|
||||||
bool setPassword (QString password, QString& errorOut);
|
bool setPassword (QString password, QString& errorOut);
|
||||||
signals:
|
signals:
|
||||||
void error(QString e);
|
void error(QString e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString request();
|
QString request();
|
||||||
|
|
||||||
QString m_Email;
|
QString m_Email;
|
||||||
QString m_Password;
|
QString m_Password;
|
||||||
CoreInterface m_CoreInterface;
|
CoreInterface m_CoreInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WEBCLIENT_H
|
#endif // WEBCLIENT_H
|
||||||
|
|
|
@ -20,73 +20,73 @@
|
||||||
#include <QtCore/QSocketNotifier>
|
#include <QtCore/QSocketNotifier>
|
||||||
|
|
||||||
ZeroconfBrowser::ZeroconfBrowser(QObject* parent) :
|
ZeroconfBrowser::ZeroconfBrowser(QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_DnsServiceRef(0),
|
m_DnsServiceRef(0),
|
||||||
m_pSocket(0)
|
m_pSocket(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroconfBrowser::~ZeroconfBrowser()
|
ZeroconfBrowser::~ZeroconfBrowser()
|
||||||
{
|
{
|
||||||
if (m_pSocket) {
|
if (m_pSocket) {
|
||||||
delete m_pSocket;
|
delete m_pSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_DnsServiceRef) {
|
if (m_DnsServiceRef) {
|
||||||
DNSServiceRefDeallocate(m_DnsServiceRef);
|
DNSServiceRefDeallocate(m_DnsServiceRef);
|
||||||
m_DnsServiceRef = 0;
|
m_DnsServiceRef = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZeroconfBrowser::browseForType(const QString& type)
|
void ZeroconfBrowser::browseForType(const QString& type)
|
||||||
{
|
{
|
||||||
DNSServiceErrorType err = DNSServiceBrowse(&m_DnsServiceRef, 0, 0,
|
DNSServiceErrorType err = DNSServiceBrowse(&m_DnsServiceRef, 0, 0,
|
||||||
type.toUtf8().constData(), 0, browseReply, this);
|
type.toUtf8().constData(), 0, browseReply, this);
|
||||||
|
|
||||||
if (err != kDNSServiceErr_NoError) {
|
if (err != kDNSServiceErr_NoError) {
|
||||||
emit error(err);
|
emit error(err);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int sockFD = DNSServiceRefSockFD(m_DnsServiceRef);
|
int sockFD = DNSServiceRefSockFD(m_DnsServiceRef);
|
||||||
if (sockFD == -1) {
|
if (sockFD == -1) {
|
||||||
emit error(kDNSServiceErr_Invalid);
|
emit error(kDNSServiceErr_Invalid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_pSocket = new QSocketNotifier(sockFD, QSocketNotifier::Read, this);
|
m_pSocket = new QSocketNotifier(sockFD, QSocketNotifier::Read, this);
|
||||||
connect(m_pSocket, SIGNAL(activated(int)), this,
|
connect(m_pSocket, SIGNAL(activated(int)), this,
|
||||||
SLOT(socketReadyRead()));
|
SLOT(socketReadyRead()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZeroconfBrowser::socketReadyRead()
|
void ZeroconfBrowser::socketReadyRead()
|
||||||
{
|
{
|
||||||
DNSServiceErrorType err = DNSServiceProcessResult(m_DnsServiceRef);
|
DNSServiceErrorType err = DNSServiceProcessResult(m_DnsServiceRef);
|
||||||
if (err != kDNSServiceErr_NoError) {
|
if (err != kDNSServiceErr_NoError) {
|
||||||
emit error(err);
|
emit error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZeroconfBrowser::browseReply(DNSServiceRef, DNSServiceFlags flags,
|
void ZeroconfBrowser::browseReply(DNSServiceRef, DNSServiceFlags flags,
|
||||||
quint32, DNSServiceErrorType errorCode, const char* serviceName,
|
quint32, DNSServiceErrorType errorCode, const char* serviceName,
|
||||||
const char* regType, const char* replyDomain, void* context)
|
const char* regType, const char* replyDomain, void* context)
|
||||||
{
|
{
|
||||||
ZeroconfBrowser* browser = static_cast<ZeroconfBrowser*>(context);
|
ZeroconfBrowser* browser = static_cast<ZeroconfBrowser*>(context);
|
||||||
if (errorCode != kDNSServiceErr_NoError) {
|
if (errorCode != kDNSServiceErr_NoError) {
|
||||||
emit browser->error(errorCode);
|
emit browser->error(errorCode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ZeroconfRecord record(serviceName, regType, replyDomain);
|
ZeroconfRecord record(serviceName, regType, replyDomain);
|
||||||
if (flags & kDNSServiceFlagsAdd) {
|
if (flags & kDNSServiceFlagsAdd) {
|
||||||
if (!browser->m_Records.contains(record)) {
|
if (!browser->m_Records.contains(record)) {
|
||||||
browser->m_Records.append(record);
|
browser->m_Records.append(record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
browser->m_Records.removeAll(record);
|
browser->m_Records.removeAll(record);
|
||||||
}
|
}
|
||||||
if (!(flags & kDNSServiceFlagsMoreComing)) {
|
if (!(flags & kDNSServiceFlagsMoreComing)) {
|
||||||
emit browser->currentRecordsChanged(browser->m_Records);
|
emit browser->currentRecordsChanged(browser->m_Records);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue