Apply tab to spaces filter to src folder
This commit is contained in:
parent
4902b8674c
commit
deea23f866
|
@ -21,5 +21,5 @@ if (WIN32)
|
|||
endif()
|
||||
|
||||
if ((NOT ${CMAKE_SYSTEM_NAME} MATCHES "IRIX") AND (NOT ${DISABLE_TESTS}))
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
|
|
@ -19,6 +19,6 @@ add_subdirectory(synergys)
|
|||
add_subdirectory(syntool)
|
||||
|
||||
if (BUILD_SERVICE)
|
||||
add_subdirectory(synergyd)
|
||||
add_subdirectory(synergyd)
|
||||
endif (BUILD_SERVICE)
|
||||
|
||||
|
|
|
@ -15,57 +15,57 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(sources
|
||||
synergyc.cpp
|
||||
synergyc.cpp
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
file(GLOB arch_headers "MSWindows*.h")
|
||||
file(GLOB arch_sources "MSWindows*.cpp")
|
||||
list(APPEND sources
|
||||
resource.h
|
||||
synergyc.ico
|
||||
synergyc.rc
|
||||
tb_error.ico
|
||||
tb_idle.ico
|
||||
tb_run.ico
|
||||
tb_wait.ico
|
||||
)
|
||||
file(GLOB arch_headers "MSWindows*.h")
|
||||
file(GLOB arch_sources "MSWindows*.cpp")
|
||||
list(APPEND sources
|
||||
resource.h
|
||||
synergyc.ico
|
||||
synergyc.rc
|
||||
tb_error.ico
|
||||
tb_idle.ico
|
||||
tb_run.ico
|
||||
tb_wait.ico
|
||||
)
|
||||
elseif (APPLE)
|
||||
file(GLOB arch_headers "OSX*.h")
|
||||
file(GLOB arch_sources "OSX*.cpp")
|
||||
file(GLOB arch_headers "OSX*.h")
|
||||
file(GLOB arch_sources "OSX*.cpp")
|
||||
elseif (UNIX)
|
||||
file(GLOB arch_headers "XWindows*.h")
|
||||
file(GLOB arch_sources "XWindows*.cpp")
|
||||
file(GLOB arch_headers "XWindows*.h")
|
||||
file(GLOB arch_sources "XWindows*.cpp")
|
||||
endif()
|
||||
|
||||
list(APPEND sources ${arch_sources})
|
||||
list(APPEND headers ${arch_headers})
|
||||
|
||||
if (SYNERGY_ADD_HEADERS)
|
||||
list(APPEND sources ${headers})
|
||||
list(APPEND sources ${headers})
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
../
|
||||
../../lib/
|
||||
../
|
||||
../../lib/
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(synergyc ${sources})
|
||||
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)
|
||||
else ()
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
synergyc
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
synergyc
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -35,342 +35,342 @@
|
|||
|
||||
const UINT MSWindowsClientTaskBarReceiver::s_stateToIconID[kMaxState] =
|
||||
{
|
||||
IDI_TASKBAR_NOT_RUNNING,
|
||||
IDI_TASKBAR_NOT_WORKING,
|
||||
IDI_TASKBAR_NOT_CONNECTED,
|
||||
IDI_TASKBAR_NOT_CONNECTED,
|
||||
IDI_TASKBAR_CONNECTED
|
||||
IDI_TASKBAR_NOT_RUNNING,
|
||||
IDI_TASKBAR_NOT_WORKING,
|
||||
IDI_TASKBAR_NOT_CONNECTED,
|
||||
IDI_TASKBAR_NOT_CONNECTED,
|
||||
IDI_TASKBAR_CONNECTED
|
||||
};
|
||||
|
||||
MSWindowsClientTaskBarReceiver::MSWindowsClientTaskBarReceiver(
|
||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
ClientTaskBarReceiver(events),
|
||||
m_appInstance(appInstance),
|
||||
m_window(NULL),
|
||||
m_logBuffer(logBuffer)
|
||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
ClientTaskBarReceiver(events),
|
||||
m_appInstance(appInstance),
|
||||
m_window(NULL),
|
||||
m_logBuffer(logBuffer)
|
||||
{
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
||||
}
|
||||
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
||||
}
|
||||
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
||||
|
||||
// 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
|
||||
// the task bar. that's good because it means the existence of
|
||||
// the window won't prevent changing the main thread's desktop.
|
||||
// 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
|
||||
// the task bar. that's good because it means the existence of
|
||||
// the window won't prevent changing the main thread's desktop.
|
||||
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
MSWindowsClientTaskBarReceiver::~MSWindowsClientTaskBarReceiver()
|
||||
{
|
||||
cleanup();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::cleanup()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
deleteIcon(m_icon[i]);
|
||||
}
|
||||
DestroyMenu(m_menu);
|
||||
destroyWindow();
|
||||
ARCH->removeReceiver(this);
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
deleteIcon(m_icon[i]);
|
||||
}
|
||||
DestroyMenu(m_menu);
|
||||
destroyWindow();
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::showStatus()
|
||||
{
|
||||
// create the window
|
||||
createWindow();
|
||||
// create the window
|
||||
createWindow();
|
||||
|
||||
// lock self while getting status
|
||||
lock();
|
||||
// lock self while getting status
|
||||
lock();
|
||||
|
||||
// get the current status
|
||||
std::string status = getToolTip();
|
||||
// get the current status
|
||||
std::string status = getToolTip();
|
||||
|
||||
// done getting status
|
||||
unlock();
|
||||
// done getting status
|
||||
unlock();
|
||||
|
||||
// update dialog
|
||||
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
||||
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
||||
// update dialog
|
||||
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
||||
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
||||
|
||||
if (!IsWindowVisible(m_window)) {
|
||||
// position it by the mouse
|
||||
POINT cursorPos;
|
||||
GetCursorPos(&cursorPos);
|
||||
RECT windowRect;
|
||||
GetWindowRect(m_window, &windowRect);
|
||||
int x = cursorPos.x;
|
||||
int y = cursorPos.y;
|
||||
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
||||
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
||||
int ww = windowRect.right - windowRect.left;
|
||||
int wh = windowRect.bottom - windowRect.top;
|
||||
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
||||
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
||||
if (fw < 1) {
|
||||
fw = 1;
|
||||
}
|
||||
if (fh < 1) {
|
||||
fh = 1;
|
||||
}
|
||||
if (x + ww - fw > sw) {
|
||||
x -= ww - fw;
|
||||
}
|
||||
else {
|
||||
x -= fw;
|
||||
}
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
if (y + wh - fh > sh) {
|
||||
y -= wh - fh;
|
||||
}
|
||||
else {
|
||||
y -= fh;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
||||
SWP_SHOWWINDOW);
|
||||
}
|
||||
if (!IsWindowVisible(m_window)) {
|
||||
// position it by the mouse
|
||||
POINT cursorPos;
|
||||
GetCursorPos(&cursorPos);
|
||||
RECT windowRect;
|
||||
GetWindowRect(m_window, &windowRect);
|
||||
int x = cursorPos.x;
|
||||
int y = cursorPos.y;
|
||||
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
||||
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
||||
int ww = windowRect.right - windowRect.left;
|
||||
int wh = windowRect.bottom - windowRect.top;
|
||||
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
||||
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
||||
if (fw < 1) {
|
||||
fw = 1;
|
||||
}
|
||||
if (fh < 1) {
|
||||
fh = 1;
|
||||
}
|
||||
if (x + ww - fw > sw) {
|
||||
x -= ww - fw;
|
||||
}
|
||||
else {
|
||||
x -= fw;
|
||||
}
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
if (y + wh - fh > sh) {
|
||||
y -= wh - fh;
|
||||
}
|
||||
else {
|
||||
y -= fh;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
||||
SWP_SHOWWINDOW);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::runMenu(int x, int y)
|
||||
{
|
||||
// do popup menu. we need a window to pass to TrackPopupMenu().
|
||||
// the SetForegroundWindow() and SendMessage() calls around
|
||||
// TrackPopupMenu() are to get the menu to be dismissed when
|
||||
// another window gets activated and are just one of those
|
||||
// win32 weirdnesses.
|
||||
createWindow();
|
||||
SetForegroundWindow(m_window);
|
||||
HMENU menu = GetSubMenu(m_menu, 0);
|
||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||
int n = TrackPopupMenu(menu,
|
||||
TPM_NONOTIFY |
|
||||
TPM_RETURNCMD |
|
||||
TPM_LEFTBUTTON |
|
||||
TPM_RIGHTBUTTON,
|
||||
x, y, 0, m_window, NULL);
|
||||
SendMessage(m_window, WM_NULL, 0, 0);
|
||||
// do popup menu. we need a window to pass to TrackPopupMenu().
|
||||
// the SetForegroundWindow() and SendMessage() calls around
|
||||
// TrackPopupMenu() are to get the menu to be dismissed when
|
||||
// another window gets activated and are just one of those
|
||||
// win32 weirdnesses.
|
||||
createWindow();
|
||||
SetForegroundWindow(m_window);
|
||||
HMENU menu = GetSubMenu(m_menu, 0);
|
||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||
int n = TrackPopupMenu(menu,
|
||||
TPM_NONOTIFY |
|
||||
TPM_RETURNCMD |
|
||||
TPM_LEFTBUTTON |
|
||||
TPM_RIGHTBUTTON,
|
||||
x, y, 0, m_window, NULL);
|
||||
SendMessage(m_window, WM_NULL, 0, 0);
|
||||
|
||||
// perform the requested operation
|
||||
switch (n) {
|
||||
case IDC_TASKBAR_STATUS:
|
||||
showStatus();
|
||||
break;
|
||||
// perform the requested operation
|
||||
switch (n) {
|
||||
case IDC_TASKBAR_STATUS:
|
||||
showStatus();
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG:
|
||||
copyLog();
|
||||
break;
|
||||
case IDC_TASKBAR_LOG:
|
||||
copyLog();
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_SHOW_LOG:
|
||||
ARCH->showConsole(true);
|
||||
break;
|
||||
case IDC_TASKBAR_SHOW_LOG:
|
||||
ARCH->showConsole(true);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||
CLOG->setFilter(kERROR);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||
CLOG->setFilter(kERROR);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||
CLOG->setFilter(kWARNING);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||
CLOG->setFilter(kWARNING);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||
CLOG->setFilter(kNOTE);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||
CLOG->setFilter(kNOTE);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||
CLOG->setFilter(kINFO);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||
CLOG->setFilter(kINFO);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||
CLOG->setFilter(kDEBUG);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||
CLOG->setFilter(kDEBUG);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||
CLOG->setFilter(kDEBUG1);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||
CLOG->setFilter(kDEBUG1);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||
CLOG->setFilter(kDEBUG2);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||
CLOG->setFilter(kDEBUG2);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_QUIT:
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
case IDC_TASKBAR_QUIT:
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::primaryAction()
|
||||
{
|
||||
showStatus();
|
||||
showStatus();
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
MSWindowsClientTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return static_cast<Icon>(m_icon[getStatus()]);
|
||||
return static_cast<Icon>(m_icon[getStatus()]);
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::copyLog() const
|
||||
{
|
||||
if (m_logBuffer != NULL) {
|
||||
// collect log buffer
|
||||
String data;
|
||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
index != m_logBuffer->end(); ++index) {
|
||||
data += *index;
|
||||
data += "\n";
|
||||
}
|
||||
if (m_logBuffer != NULL) {
|
||||
// collect log buffer
|
||||
String data;
|
||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
index != m_logBuffer->end(); ++index) {
|
||||
data += *index;
|
||||
data += "\n";
|
||||
}
|
||||
|
||||
// copy log to clipboard
|
||||
if (!data.empty()) {
|
||||
MSWindowsClipboard clipboard(m_window);
|
||||
clipboard.open(0);
|
||||
clipboard.emptyUnowned();
|
||||
clipboard.add(IClipboard::kText, data);
|
||||
clipboard.close();
|
||||
}
|
||||
}
|
||||
// copy log to clipboard
|
||||
if (!data.empty()) {
|
||||
MSWindowsClipboard clipboard(m_window);
|
||||
clipboard.open(0);
|
||||
clipboard.emptyUnowned();
|
||||
clipboard.add(IClipboard::kText, data);
|
||||
clipboard.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::onStatusChanged()
|
||||
{
|
||||
if (IsWindowVisible(m_window)) {
|
||||
showStatus();
|
||||
}
|
||||
if (IsWindowVisible(m_window)) {
|
||||
showStatus();
|
||||
}
|
||||
}
|
||||
|
||||
HICON
|
||||
MSWindowsClientTaskBarReceiver::loadIcon(UINT id)
|
||||
{
|
||||
HANDLE icon = LoadImage(m_appInstance,
|
||||
MAKEINTRESOURCE(id),
|
||||
IMAGE_ICON,
|
||||
0, 0,
|
||||
LR_DEFAULTCOLOR);
|
||||
return static_cast<HICON>(icon);
|
||||
HANDLE icon = LoadImage(m_appInstance,
|
||||
MAKEINTRESOURCE(id),
|
||||
IMAGE_ICON,
|
||||
0, 0,
|
||||
LR_DEFAULTCOLOR);
|
||||
return static_cast<HICON>(icon);
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::deleteIcon(HICON icon)
|
||||
{
|
||||
if (icon != NULL) {
|
||||
DestroyIcon(icon);
|
||||
}
|
||||
if (icon != NULL) {
|
||||
DestroyIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::createWindow()
|
||||
{
|
||||
// ignore if already created
|
||||
if (m_window != NULL) {
|
||||
return;
|
||||
}
|
||||
// ignore if already created
|
||||
if (m_window != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the status dialog
|
||||
m_window = CreateDialogParam(m_appInstance,
|
||||
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
||||
NULL,
|
||||
(DLGPROC)&MSWindowsClientTaskBarReceiver::staticDlgProc,
|
||||
reinterpret_cast<LPARAM>(
|
||||
static_cast<void*>(this)));
|
||||
// get the status dialog
|
||||
m_window = CreateDialogParam(m_appInstance,
|
||||
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
||||
NULL,
|
||||
(DLGPROC)&MSWindowsClientTaskBarReceiver::staticDlgProc,
|
||||
reinterpret_cast<LPARAM>(
|
||||
static_cast<void*>(this)));
|
||||
|
||||
// window should appear on top of everything, including (especially)
|
||||
// the task bar.
|
||||
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
||||
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||
// window should appear on top of everything, including (especially)
|
||||
// the task bar.
|
||||
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
||||
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||
|
||||
// tell the task bar about this dialog
|
||||
ArchTaskBarWindows::addDialog(m_window);
|
||||
// tell the task bar about this dialog
|
||||
ArchTaskBarWindows::addDialog(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsClientTaskBarReceiver::destroyWindow()
|
||||
{
|
||||
if (m_window != NULL) {
|
||||
ArchTaskBarWindows::removeDialog(m_window);
|
||||
DestroyWindow(m_window);
|
||||
m_window = NULL;
|
||||
}
|
||||
if (m_window != NULL) {
|
||||
ArchTaskBarWindows::removeDialog(m_window);
|
||||
DestroyWindow(m_window);
|
||||
m_window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
MSWindowsClientTaskBarReceiver::dlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM)
|
||||
UINT msg, WPARAM wParam, LPARAM)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
// use default focus
|
||||
return TRUE;
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
// use default focus
|
||||
return TRUE;
|
||||
|
||||
case WM_ACTIVATE:
|
||||
// hide when another window is activated
|
||||
if (LOWORD(wParam) == WA_INACTIVE) {
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
case WM_ACTIVATE:
|
||||
// hide when another window is activated
|
||||
if (LOWORD(wParam) == WA_INACTIVE) {
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK
|
||||
MSWindowsClientTaskBarReceiver::staticDlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver*
|
||||
// and put it in the extra window data then forward the call.
|
||||
MSWindowsClientTaskBarReceiver* self = NULL;
|
||||
if (msg == WM_INITDIALOG) {
|
||||
self = static_cast<MSWindowsClientTaskBarReceiver*>(
|
||||
reinterpret_cast<void*>(lParam));
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) lParam);
|
||||
}
|
||||
else {
|
||||
// get the extra window data and forward the call
|
||||
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if (data != 0) {
|
||||
self = (MSWindowsClientTaskBarReceiver*) data;
|
||||
}
|
||||
}
|
||||
// if msg is WM_INITDIALOG, extract the MSWindowsClientTaskBarReceiver*
|
||||
// and put it in the extra window data then forward the call.
|
||||
MSWindowsClientTaskBarReceiver* self = NULL;
|
||||
if (msg == WM_INITDIALOG) {
|
||||
self = static_cast<MSWindowsClientTaskBarReceiver*>(
|
||||
reinterpret_cast<void*>(lParam));
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) lParam);
|
||||
}
|
||||
else {
|
||||
// get the extra window data and forward the call
|
||||
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if (data != 0) {
|
||||
self = (MSWindowsClientTaskBarReceiver*) data;
|
||||
}
|
||||
}
|
||||
|
||||
// forward the message
|
||||
if (self != NULL) {
|
||||
return self->dlgProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
else {
|
||||
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
||||
}
|
||||
// forward the message
|
||||
if (self != NULL) {
|
||||
return self->dlgProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
else {
|
||||
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
ArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
32, 32, LR_SHARED),
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
16, 16, LR_SHARED));
|
||||
ArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
32, 32, LR_SHARED),
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
16, 16, LR_SHARED));
|
||||
|
||||
return new MSWindowsClientTaskBarReceiver(
|
||||
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||
return new MSWindowsClientTaskBarReceiver(
|
||||
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||
}
|
||||
|
|
|
@ -29,40 +29,40 @@ class IEventQueue;
|
|||
//! Implementation of ClientTaskBarReceiver for Microsoft Windows
|
||||
class MSWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||
public:
|
||||
MSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~MSWindowsClientTaskBarReceiver();
|
||||
MSWindowsClientTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~MSWindowsClientTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
void cleanup();
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
void cleanup();
|
||||
|
||||
protected:
|
||||
void copyLog() const;
|
||||
void copyLog() const;
|
||||
|
||||
// ClientTaskBarReceiver overrides
|
||||
virtual void onStatusChanged();
|
||||
// ClientTaskBarReceiver overrides
|
||||
virtual void onStatusChanged();
|
||||
|
||||
private:
|
||||
HICON loadIcon(UINT);
|
||||
void deleteIcon(HICON);
|
||||
void createWindow();
|
||||
void destroyWindow();
|
||||
HICON loadIcon(UINT);
|
||||
void deleteIcon(HICON);
|
||||
void createWindow();
|
||||
void destroyWindow();
|
||||
|
||||
BOOL dlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
static BOOL CALLBACK
|
||||
staticDlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL dlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
static BOOL CALLBACK
|
||||
staticDlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
HINSTANCE m_appInstance;
|
||||
HWND m_window;
|
||||
HMENU m_menu;
|
||||
HICON m_icon[kMaxState];
|
||||
const BufferedLogOutputter* m_logBuffer;
|
||||
HINSTANCE m_appInstance;
|
||||
HWND m_window;
|
||||
HMENU m_menu;
|
||||
HICON m_icon[kMaxState];
|
||||
const BufferedLogOutputter* m_logBuffer;
|
||||
|
||||
static const UINT s_stateToIconID[];
|
||||
static const UINT s_stateToIconID[];
|
||||
};
|
||||
|
|
|
@ -28,42 +28,42 @@ OSXClientTaskBarReceiver::OSXClientTaskBarReceiver(
|
|||
IEventQueue* events) :
|
||||
ClientTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
OSXClientTaskBarReceiver::~OSXClientTaskBarReceiver()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
ARCH->removeReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
OSXClientTaskBarReceiver::showStatus()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
OSXClientTaskBarReceiver::runMenu(int, int)
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
OSXClientTaskBarReceiver::primaryAction()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
OSXClientTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
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
|
||||
class OSXClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||
public:
|
||||
OSXClientTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~OSXClientTaskBarReceiver();
|
||||
OSXClientTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~OSXClientTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
};
|
||||
|
|
|
@ -24,45 +24,45 @@
|
|||
//
|
||||
|
||||
CXWindowsClientTaskBarReceiver::CXWindowsClientTaskBarReceiver(
|
||||
const BufferedLogOutputter*,
|
||||
IEventQueue* events) :
|
||||
ClientTaskBarReceiver(events)
|
||||
const BufferedLogOutputter*,
|
||||
IEventQueue* events) :
|
||||
ClientTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
CXWindowsClientTaskBarReceiver::~CXWindowsClientTaskBarReceiver()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
ARCH->removeReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsClientTaskBarReceiver::showStatus()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsClientTaskBarReceiver::runMenu(int, int)
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsClientTaskBarReceiver::primaryAction()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
CXWindowsClientTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
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
|
||||
class CXWindowsClientTaskBarReceiver : public ClientTaskBarReceiver {
|
||||
public:
|
||||
CXWindowsClientTaskBarReceiver(
|
||||
const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CXWindowsClientTaskBarReceiver();
|
||||
CXWindowsClientTaskBarReceiver(
|
||||
const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CXWindowsClientTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
};
|
||||
|
|
|
@ -35,16 +35,16 @@ int
|
|||
main(int argc, char** argv)
|
||||
{
|
||||
#if SYSAPI_WIN32
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
Log log;
|
||||
EventQueue events;
|
||||
Log log;
|
||||
EventQueue events;
|
||||
|
||||
ClientApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
ClientApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ file(GLOB headers "*.h")
|
|||
file(GLOB sources "*.cpp")
|
||||
|
||||
include_directories(
|
||||
../
|
||||
../../lib/
|
||||
../
|
||||
../../lib/
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
|
@ -35,11 +35,11 @@ else()
|
|||
endif()
|
||||
|
||||
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)
|
||||
install(TARGETS
|
||||
synergyd
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
install(TARGETS
|
||||
synergyd
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
DaemonApp app;
|
||||
return app.run(argc, argv);
|
||||
DaemonApp app;
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
||||
#elif SYSAPI_WIN32
|
||||
|
@ -37,8 +37,8 @@ main(int argc, char** argv)
|
|||
int WINAPI
|
||||
WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
|
||||
{
|
||||
DaemonApp app;
|
||||
return app.run(__argc, __argv);
|
||||
DaemonApp app;
|
||||
return app.run(__argc, __argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,57 +15,57 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(sources
|
||||
synergys.cpp
|
||||
synergys.cpp
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
file(GLOB arch_headers "MSWindows*.h")
|
||||
file(GLOB arch_sources "MSWindows*.cpp")
|
||||
list(APPEND sources
|
||||
resource.h
|
||||
synergys.ico
|
||||
synergys.rc
|
||||
tb_error.ico
|
||||
tb_idle.ico
|
||||
tb_run.ico
|
||||
tb_wait.ico
|
||||
)
|
||||
file(GLOB arch_headers "MSWindows*.h")
|
||||
file(GLOB arch_sources "MSWindows*.cpp")
|
||||
list(APPEND sources
|
||||
resource.h
|
||||
synergys.ico
|
||||
synergys.rc
|
||||
tb_error.ico
|
||||
tb_idle.ico
|
||||
tb_run.ico
|
||||
tb_wait.ico
|
||||
)
|
||||
elseif (APPLE)
|
||||
file(GLOB arch_headers "OSX*.h")
|
||||
file(GLOB arch_sources "OSX*.cpp")
|
||||
file(GLOB arch_headers "OSX*.h")
|
||||
file(GLOB arch_sources "OSX*.cpp")
|
||||
elseif (UNIX)
|
||||
file(GLOB arch_headers "XWindows*.h")
|
||||
file(GLOB arch_sources "XWindows*.cpp")
|
||||
file(GLOB arch_headers "XWindows*.h")
|
||||
file(GLOB arch_sources "XWindows*.cpp")
|
||||
endif()
|
||||
|
||||
list(APPEND sources ${arch_sources})
|
||||
list(APPEND headers ${arch_headers})
|
||||
|
||||
if (SYNERGY_ADD_HEADERS)
|
||||
list(APPEND sources ${headers})
|
||||
list(APPEND sources ${headers})
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
../
|
||||
../../lib/
|
||||
../
|
||||
../../lib/
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(synergys ${sources})
|
||||
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)
|
||||
else ()
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
synergys
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
synergys
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -36,373 +36,373 @@
|
|||
|
||||
const UINT MSWindowsServerTaskBarReceiver::s_stateToIconID[kMaxState] =
|
||||
{
|
||||
IDI_TASKBAR_NOT_RUNNING,
|
||||
IDI_TASKBAR_NOT_WORKING,
|
||||
IDI_TASKBAR_NOT_CONNECTED,
|
||||
IDI_TASKBAR_CONNECTED
|
||||
IDI_TASKBAR_NOT_RUNNING,
|
||||
IDI_TASKBAR_NOT_WORKING,
|
||||
IDI_TASKBAR_NOT_CONNECTED,
|
||||
IDI_TASKBAR_CONNECTED
|
||||
};
|
||||
|
||||
MSWindowsServerTaskBarReceiver::MSWindowsServerTaskBarReceiver(
|
||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events),
|
||||
m_events(events),
|
||||
m_appInstance(appInstance),
|
||||
m_window(NULL),
|
||||
m_logBuffer(logBuffer)
|
||||
HINSTANCE appInstance, const BufferedLogOutputter* logBuffer, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events),
|
||||
m_events(events),
|
||||
m_appInstance(appInstance),
|
||||
m_window(NULL),
|
||||
m_logBuffer(logBuffer)
|
||||
{
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
||||
}
|
||||
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
m_icon[i] = loadIcon(s_stateToIconID[i]);
|
||||
}
|
||||
m_menu = LoadMenu(m_appInstance, MAKEINTRESOURCE(IDR_TASKBAR));
|
||||
|
||||
// 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
|
||||
// the task bar. that's good because it means the existence of
|
||||
// the window won't prevent changing the main thread's desktop.
|
||||
// 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
|
||||
// the task bar. that's good because it means the existence of
|
||||
// the window won't prevent changing the main thread's desktop.
|
||||
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::cleanup()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
deleteIcon(m_icon[i]);
|
||||
}
|
||||
DestroyMenu(m_menu);
|
||||
destroyWindow();
|
||||
ARCH->removeReceiver(this);
|
||||
for (UInt32 i = 0; i < kMaxState; ++i) {
|
||||
deleteIcon(m_icon[i]);
|
||||
}
|
||||
DestroyMenu(m_menu);
|
||||
destroyWindow();
|
||||
}
|
||||
|
||||
MSWindowsServerTaskBarReceiver::~MSWindowsServerTaskBarReceiver()
|
||||
{
|
||||
cleanup();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::showStatus()
|
||||
{
|
||||
// create the window
|
||||
createWindow();
|
||||
// create the window
|
||||
createWindow();
|
||||
|
||||
// lock self while getting status
|
||||
lock();
|
||||
// lock self while getting status
|
||||
lock();
|
||||
|
||||
// get the current status
|
||||
std::string status = getToolTip();
|
||||
// get the current status
|
||||
std::string status = getToolTip();
|
||||
|
||||
// get the connect clients, if any
|
||||
const Clients& clients = getClients();
|
||||
// get the connect clients, if any
|
||||
const Clients& clients = getClients();
|
||||
|
||||
// done getting status
|
||||
unlock();
|
||||
// done getting status
|
||||
unlock();
|
||||
|
||||
// update dialog
|
||||
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
||||
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
||||
child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS);
|
||||
SendMessage(child, LB_RESETCONTENT, 0, 0);
|
||||
for (Clients::const_iterator index = clients.begin();
|
||||
index != clients.end(); ) {
|
||||
const char* client = index->c_str();
|
||||
if (++index == clients.end()) {
|
||||
SendMessage(child, LB_ADDSTRING, 0, (LPARAM)client);
|
||||
}
|
||||
else {
|
||||
SendMessage(child, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)client);
|
||||
}
|
||||
}
|
||||
// update dialog
|
||||
HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS);
|
||||
SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str());
|
||||
child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_CLIENTS);
|
||||
SendMessage(child, LB_RESETCONTENT, 0, 0);
|
||||
for (Clients::const_iterator index = clients.begin();
|
||||
index != clients.end(); ) {
|
||||
const char* client = index->c_str();
|
||||
if (++index == clients.end()) {
|
||||
SendMessage(child, LB_ADDSTRING, 0, (LPARAM)client);
|
||||
}
|
||||
else {
|
||||
SendMessage(child, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)client);
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsWindowVisible(m_window)) {
|
||||
// position it by the mouse
|
||||
POINT cursorPos;
|
||||
GetCursorPos(&cursorPos);
|
||||
RECT windowRect;
|
||||
GetWindowRect(m_window, &windowRect);
|
||||
int x = cursorPos.x;
|
||||
int y = cursorPos.y;
|
||||
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
||||
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
||||
int ww = windowRect.right - windowRect.left;
|
||||
int wh = windowRect.bottom - windowRect.top;
|
||||
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
||||
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
||||
if (fw < 1) {
|
||||
fw = 1;
|
||||
}
|
||||
if (fh < 1) {
|
||||
fh = 1;
|
||||
}
|
||||
if (x + ww - fw > sw) {
|
||||
x -= ww - fw;
|
||||
}
|
||||
else {
|
||||
x -= fw;
|
||||
}
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
if (y + wh - fh > sh) {
|
||||
y -= wh - fh;
|
||||
}
|
||||
else {
|
||||
y -= fh;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
||||
SWP_SHOWWINDOW);
|
||||
}
|
||||
if (!IsWindowVisible(m_window)) {
|
||||
// position it by the mouse
|
||||
POINT cursorPos;
|
||||
GetCursorPos(&cursorPos);
|
||||
RECT windowRect;
|
||||
GetWindowRect(m_window, &windowRect);
|
||||
int x = cursorPos.x;
|
||||
int y = cursorPos.y;
|
||||
int fw = GetSystemMetrics(SM_CXDLGFRAME);
|
||||
int fh = GetSystemMetrics(SM_CYDLGFRAME);
|
||||
int ww = windowRect.right - windowRect.left;
|
||||
int wh = windowRect.bottom - windowRect.top;
|
||||
int sw = GetSystemMetrics(SM_CXFULLSCREEN);
|
||||
int sh = GetSystemMetrics(SM_CYFULLSCREEN);
|
||||
if (fw < 1) {
|
||||
fw = 1;
|
||||
}
|
||||
if (fh < 1) {
|
||||
fh = 1;
|
||||
}
|
||||
if (x + ww - fw > sw) {
|
||||
x -= ww - fw;
|
||||
}
|
||||
else {
|
||||
x -= fw;
|
||||
}
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
if (y + wh - fh > sh) {
|
||||
y -= wh - fh;
|
||||
}
|
||||
else {
|
||||
y -= fh;
|
||||
}
|
||||
if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh,
|
||||
SWP_SHOWWINDOW);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::runMenu(int x, int y)
|
||||
{
|
||||
// do popup menu. we need a window to pass to TrackPopupMenu().
|
||||
// the SetForegroundWindow() and SendMessage() calls around
|
||||
// TrackPopupMenu() are to get the menu to be dismissed when
|
||||
// another window gets activated and are just one of those
|
||||
// win32 weirdnesses.
|
||||
createWindow();
|
||||
SetForegroundWindow(m_window);
|
||||
HMENU menu = GetSubMenu(m_menu, 0);
|
||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||
int n = TrackPopupMenu(menu,
|
||||
TPM_NONOTIFY |
|
||||
TPM_RETURNCMD |
|
||||
TPM_LEFTBUTTON |
|
||||
TPM_RIGHTBUTTON,
|
||||
x, y, 0, m_window, NULL);
|
||||
SendMessage(m_window, WM_NULL, 0, 0);
|
||||
// do popup menu. we need a window to pass to TrackPopupMenu().
|
||||
// the SetForegroundWindow() and SendMessage() calls around
|
||||
// TrackPopupMenu() are to get the menu to be dismissed when
|
||||
// another window gets activated and are just one of those
|
||||
// win32 weirdnesses.
|
||||
createWindow();
|
||||
SetForegroundWindow(m_window);
|
||||
HMENU menu = GetSubMenu(m_menu, 0);
|
||||
SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE);
|
||||
HMENU logLevelMenu = GetSubMenu(menu, 3);
|
||||
CheckMenuRadioItem(logLevelMenu, 0, 6,
|
||||
CLOG->getFilter() - kERROR, MF_BYPOSITION);
|
||||
int n = TrackPopupMenu(menu,
|
||||
TPM_NONOTIFY |
|
||||
TPM_RETURNCMD |
|
||||
TPM_LEFTBUTTON |
|
||||
TPM_RIGHTBUTTON,
|
||||
x, y, 0, m_window, NULL);
|
||||
SendMessage(m_window, WM_NULL, 0, 0);
|
||||
|
||||
// perform the requested operation
|
||||
switch (n) {
|
||||
case IDC_TASKBAR_STATUS:
|
||||
showStatus();
|
||||
break;
|
||||
// perform the requested operation
|
||||
switch (n) {
|
||||
case IDC_TASKBAR_STATUS:
|
||||
showStatus();
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG:
|
||||
copyLog();
|
||||
break;
|
||||
case IDC_TASKBAR_LOG:
|
||||
copyLog();
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_SHOW_LOG:
|
||||
ARCH->showConsole(true);
|
||||
break;
|
||||
case IDC_TASKBAR_SHOW_LOG:
|
||||
ARCH->showConsole(true);
|
||||
break;
|
||||
|
||||
case IDC_RELOAD_CONFIG:
|
||||
m_events->addEvent(Event(m_events->forServerApp().reloadConfig(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
case IDC_RELOAD_CONFIG:
|
||||
m_events->addEvent(Event(m_events->forServerApp().reloadConfig(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
case IDC_FORCE_RECONNECT:
|
||||
m_events->addEvent(Event(m_events->forServerApp().forceReconnect(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
case IDC_FORCE_RECONNECT:
|
||||
m_events->addEvent(Event(m_events->forServerApp().forceReconnect(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
case ID_SYNERGY_RESETSERVER:
|
||||
m_events->addEvent(Event(m_events->forServerApp().resetServer(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
case ID_SYNERGY_RESETSERVER:
|
||||
m_events->addEvent(Event(m_events->forServerApp().resetServer(),
|
||||
m_events->getSystemTarget()));
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||
CLOG->setFilter(kERROR);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_ERROR:
|
||||
CLOG->setFilter(kERROR);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||
CLOG->setFilter(kWARNING);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_WARNING:
|
||||
CLOG->setFilter(kWARNING);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||
CLOG->setFilter(kNOTE);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_NOTE:
|
||||
CLOG->setFilter(kNOTE);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||
CLOG->setFilter(kINFO);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_INFO:
|
||||
CLOG->setFilter(kINFO);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||
CLOG->setFilter(kDEBUG);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG:
|
||||
CLOG->setFilter(kDEBUG);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||
CLOG->setFilter(kDEBUG1);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG1:
|
||||
CLOG->setFilter(kDEBUG1);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||
CLOG->setFilter(kDEBUG2);
|
||||
break;
|
||||
case IDC_TASKBAR_LOG_LEVEL_DEBUG2:
|
||||
CLOG->setFilter(kDEBUG2);
|
||||
break;
|
||||
|
||||
case IDC_TASKBAR_QUIT:
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
case IDC_TASKBAR_QUIT:
|
||||
quit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::primaryAction()
|
||||
{
|
||||
showStatus();
|
||||
showStatus();
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
MSWindowsServerTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return static_cast<Icon>(m_icon[getStatus()]);
|
||||
return static_cast<Icon>(m_icon[getStatus()]);
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::copyLog() const
|
||||
{
|
||||
if (m_logBuffer != NULL) {
|
||||
// collect log buffer
|
||||
String data;
|
||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
index != m_logBuffer->end(); ++index) {
|
||||
data += *index;
|
||||
data += "\n";
|
||||
}
|
||||
if (m_logBuffer != NULL) {
|
||||
// collect log buffer
|
||||
String data;
|
||||
for (BufferedLogOutputter::const_iterator index = m_logBuffer->begin();
|
||||
index != m_logBuffer->end(); ++index) {
|
||||
data += *index;
|
||||
data += "\n";
|
||||
}
|
||||
|
||||
// copy log to clipboard
|
||||
if (!data.empty()) {
|
||||
MSWindowsClipboard clipboard(m_window);
|
||||
clipboard.open(0);
|
||||
clipboard.emptyUnowned();
|
||||
clipboard.add(IClipboard::kText, data);
|
||||
clipboard.close();
|
||||
}
|
||||
}
|
||||
// copy log to clipboard
|
||||
if (!data.empty()) {
|
||||
MSWindowsClipboard clipboard(m_window);
|
||||
clipboard.open(0);
|
||||
clipboard.emptyUnowned();
|
||||
clipboard.add(IClipboard::kText, data);
|
||||
clipboard.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::onStatusChanged()
|
||||
{
|
||||
if (IsWindowVisible(m_window)) {
|
||||
showStatus();
|
||||
}
|
||||
if (IsWindowVisible(m_window)) {
|
||||
showStatus();
|
||||
}
|
||||
}
|
||||
|
||||
HICON
|
||||
MSWindowsServerTaskBarReceiver::loadIcon(UINT id)
|
||||
{
|
||||
HANDLE icon = LoadImage(m_appInstance,
|
||||
MAKEINTRESOURCE(id),
|
||||
IMAGE_ICON,
|
||||
0, 0,
|
||||
LR_DEFAULTCOLOR);
|
||||
return static_cast<HICON>(icon);
|
||||
HANDLE icon = LoadImage(m_appInstance,
|
||||
MAKEINTRESOURCE(id),
|
||||
IMAGE_ICON,
|
||||
0, 0,
|
||||
LR_DEFAULTCOLOR);
|
||||
return static_cast<HICON>(icon);
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::deleteIcon(HICON icon)
|
||||
{
|
||||
if (icon != NULL) {
|
||||
DestroyIcon(icon);
|
||||
}
|
||||
if (icon != NULL) {
|
||||
DestroyIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::createWindow()
|
||||
{
|
||||
// ignore if already created
|
||||
if (m_window != NULL) {
|
||||
return;
|
||||
}
|
||||
// ignore if already created
|
||||
if (m_window != NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the status dialog
|
||||
m_window = CreateDialogParam(m_appInstance,
|
||||
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
||||
NULL,
|
||||
(DLGPROC)&MSWindowsServerTaskBarReceiver::staticDlgProc,
|
||||
reinterpret_cast<LPARAM>(
|
||||
static_cast<void*>(this)));
|
||||
// get the status dialog
|
||||
m_window = CreateDialogParam(m_appInstance,
|
||||
MAKEINTRESOURCE(IDD_TASKBAR_STATUS),
|
||||
NULL,
|
||||
(DLGPROC)&MSWindowsServerTaskBarReceiver::staticDlgProc,
|
||||
reinterpret_cast<LPARAM>(
|
||||
static_cast<void*>(this)));
|
||||
|
||||
// window should appear on top of everything, including (especially)
|
||||
// the task bar.
|
||||
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
||||
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||
// window should appear on top of everything, including (especially)
|
||||
// the task bar.
|
||||
LONG_PTR style = GetWindowLongPtr(m_window, GWL_EXSTYLE);
|
||||
style |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
|
||||
SetWindowLongPtr(m_window, GWL_EXSTYLE, style);
|
||||
|
||||
// tell the task bar about this dialog
|
||||
ArchTaskBarWindows::addDialog(m_window);
|
||||
// tell the task bar about this dialog
|
||||
ArchTaskBarWindows::addDialog(m_window);
|
||||
}
|
||||
|
||||
void
|
||||
MSWindowsServerTaskBarReceiver::destroyWindow()
|
||||
{
|
||||
if (m_window != NULL) {
|
||||
ArchTaskBarWindows::removeDialog(m_window);
|
||||
DestroyWindow(m_window);
|
||||
m_window = NULL;
|
||||
}
|
||||
if (m_window != NULL) {
|
||||
ArchTaskBarWindows::removeDialog(m_window);
|
||||
DestroyWindow(m_window);
|
||||
m_window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
MSWindowsServerTaskBarReceiver::dlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM)
|
||||
UINT msg, WPARAM wParam, LPARAM)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
// use default focus
|
||||
return TRUE;
|
||||
switch (msg) {
|
||||
case WM_INITDIALOG:
|
||||
// use default focus
|
||||
return TRUE;
|
||||
|
||||
case WM_ACTIVATE:
|
||||
// hide when another window is activated
|
||||
if (LOWORD(wParam) == WA_INACTIVE) {
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
case WM_ACTIVATE:
|
||||
// hide when another window is activated
|
||||
if (LOWORD(wParam) == WA_INACTIVE) {
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK
|
||||
MSWindowsServerTaskBarReceiver::staticDlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver*
|
||||
// and put it in the extra window data then forward the call.
|
||||
MSWindowsServerTaskBarReceiver* self = NULL;
|
||||
if (msg == WM_INITDIALOG) {
|
||||
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
||||
reinterpret_cast<void*>(lParam));
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
|
||||
}
|
||||
else {
|
||||
// get the extra window data and forward the call
|
||||
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if (data != 0) {
|
||||
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
||||
reinterpret_cast<void*>(data));
|
||||
}
|
||||
}
|
||||
// if msg is WM_INITDIALOG, extract the MSWindowsServerTaskBarReceiver*
|
||||
// and put it in the extra window data then forward the call.
|
||||
MSWindowsServerTaskBarReceiver* self = NULL;
|
||||
if (msg == WM_INITDIALOG) {
|
||||
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
||||
reinterpret_cast<void*>(lParam));
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
|
||||
}
|
||||
else {
|
||||
// get the extra window data and forward the call
|
||||
LONG_PTR data = GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
if (data != 0) {
|
||||
self = static_cast<MSWindowsServerTaskBarReceiver*>(
|
||||
reinterpret_cast<void*>(data));
|
||||
}
|
||||
}
|
||||
|
||||
// forward the message
|
||||
if (self != NULL) {
|
||||
return self->dlgProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
else {
|
||||
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
||||
}
|
||||
// forward the message
|
||||
if (self != NULL) {
|
||||
return self->dlgProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
else {
|
||||
return (msg == WM_INITDIALOG) ? TRUE : FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
createTaskBarReceiver(const BufferedLogOutputter* logBuffer, IEventQueue* events)
|
||||
{
|
||||
ArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
32, 32, LR_SHARED),
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
16, 16, LR_SHARED));
|
||||
ArchMiscWindows::setIcons(
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
32, 32, LR_SHARED),
|
||||
(HICON)LoadImage(ArchMiscWindows::instanceWin32(),
|
||||
MAKEINTRESOURCE(IDI_SYNERGY),
|
||||
IMAGE_ICON,
|
||||
16, 16, LR_SHARED));
|
||||
|
||||
return new MSWindowsServerTaskBarReceiver(
|
||||
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||
return new MSWindowsServerTaskBarReceiver(
|
||||
MSWindowsScreen::getWindowInstance(), logBuffer, events);
|
||||
}
|
||||
|
|
|
@ -29,41 +29,41 @@ class IEventQueue;
|
|||
//! Implementation of ServerTaskBarReceiver for Microsoft Windows
|
||||
class MSWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||
public:
|
||||
MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~MSWindowsServerTaskBarReceiver();
|
||||
MSWindowsServerTaskBarReceiver(HINSTANCE, const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~MSWindowsServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
void cleanup();
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
void cleanup();
|
||||
|
||||
protected:
|
||||
void copyLog() const;
|
||||
void copyLog() const;
|
||||
|
||||
// ServerTaskBarReceiver overrides
|
||||
virtual void onStatusChanged();
|
||||
// ServerTaskBarReceiver overrides
|
||||
virtual void onStatusChanged();
|
||||
|
||||
private:
|
||||
HICON loadIcon(UINT);
|
||||
void deleteIcon(HICON);
|
||||
void createWindow();
|
||||
void destroyWindow();
|
||||
HICON loadIcon(UINT);
|
||||
void deleteIcon(HICON);
|
||||
void createWindow();
|
||||
void destroyWindow();
|
||||
|
||||
BOOL dlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
static BOOL CALLBACK
|
||||
staticDlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
BOOL dlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
static BOOL CALLBACK
|
||||
staticDlgProc(HWND hwnd,
|
||||
UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
HINSTANCE m_appInstance;
|
||||
HWND m_window;
|
||||
HMENU m_menu;
|
||||
HICON m_icon[kMaxState];
|
||||
const BufferedLogOutputter* m_logBuffer;
|
||||
IEventQueue* m_events;
|
||||
HINSTANCE m_appInstance;
|
||||
HWND m_window;
|
||||
HMENU m_menu;
|
||||
HICON m_icon[kMaxState];
|
||||
const BufferedLogOutputter* m_logBuffer;
|
||||
IEventQueue* m_events;
|
||||
|
||||
static const UINT s_stateToIconID[];
|
||||
static const UINT s_stateToIconID[];
|
||||
};
|
||||
|
|
|
@ -24,44 +24,44 @@
|
|||
//
|
||||
|
||||
OSXServerTaskBarReceiver::OSXServerTaskBarReceiver(
|
||||
const BufferedLogOutputter*, IEventQueue* events) :
|
||||
const BufferedLogOutputter*, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
OSXServerTaskBarReceiver::~OSXServerTaskBarReceiver()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
ARCH->removeReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
OSXServerTaskBarReceiver::showStatus()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
OSXServerTaskBarReceiver::runMenu(int, int)
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
OSXServerTaskBarReceiver::primaryAction()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
OSXServerTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
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
|
||||
class OSXServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||
public:
|
||||
OSXServerTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~OSXServerTaskBarReceiver();
|
||||
OSXServerTaskBarReceiver(const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~OSXServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
};
|
||||
|
|
|
@ -24,44 +24,44 @@
|
|||
//
|
||||
|
||||
CXWindowsServerTaskBarReceiver::CXWindowsServerTaskBarReceiver(
|
||||
const BufferedLogOutputter*, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events)
|
||||
const BufferedLogOutputter*, IEventQueue* events) :
|
||||
ServerTaskBarReceiver(events)
|
||||
{
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
// add ourself to the task bar
|
||||
ARCH->addReceiver(this);
|
||||
}
|
||||
|
||||
CXWindowsServerTaskBarReceiver::~CXWindowsServerTaskBarReceiver()
|
||||
{
|
||||
ARCH->removeReceiver(this);
|
||||
ARCH->removeReceiver(this);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsServerTaskBarReceiver::showStatus()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsServerTaskBarReceiver::runMenu(int, int)
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsServerTaskBarReceiver::primaryAction()
|
||||
{
|
||||
// do nothing
|
||||
// do nothing
|
||||
}
|
||||
|
||||
const IArchTaskBarReceiver::Icon
|
||||
CXWindowsServerTaskBarReceiver::getIcon() const
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchTaskBarReceiver*
|
||||
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
|
||||
class CXWindowsServerTaskBarReceiver : public ServerTaskBarReceiver {
|
||||
public:
|
||||
CXWindowsServerTaskBarReceiver(
|
||||
const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CXWindowsServerTaskBarReceiver();
|
||||
CXWindowsServerTaskBarReceiver(
|
||||
const BufferedLogOutputter*, IEventQueue* events);
|
||||
virtual ~CXWindowsServerTaskBarReceiver();
|
||||
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
// IArchTaskBarReceiver overrides
|
||||
virtual void showStatus();
|
||||
virtual void runMenu(int x, int y);
|
||||
virtual void primaryAction();
|
||||
virtual const Icon getIcon() const;
|
||||
};
|
||||
|
|
|
@ -35,16 +35,16 @@ int
|
|||
main(int argc, char** argv)
|
||||
{
|
||||
#if SYSAPI_WIN32
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
Arch arch;
|
||||
arch.init();
|
||||
|
||||
Log log;
|
||||
EventQueue events;
|
||||
Log log;
|
||||
EventQueue events;
|
||||
|
||||
ServerApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
ServerApp app(&events, createTaskBarReceiver);
|
||||
return app.run(argc, argv);
|
||||
}
|
||||
|
|
|
@ -17,26 +17,26 @@ file(GLOB headers "*.h")
|
|||
file(GLOB sources "*.cpp")
|
||||
|
||||
include_directories(
|
||||
../
|
||||
../../lib/
|
||||
../
|
||||
../../lib/
|
||||
)
|
||||
|
||||
if (UNIX)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
include_directories(
|
||||
../../..
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(syntool ${sources})
|
||||
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)
|
||||
else ()
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
syntool
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
if (CONF_CPACK)
|
||||
install(TARGETS
|
||||
syntool
|
||||
COMPONENT core
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -22,10 +22,10 @@ int
|
|||
main(int argc, char** argv)
|
||||
{
|
||||
#if SYSAPI_WIN32
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
// record window instance for tray icon, etc
|
||||
ArchMiscWindows::setInstanceWin32(GetModuleHandle(NULL));
|
||||
#endif
|
||||
|
||||
ToolApp app;
|
||||
return app.run(argc, argv);
|
||||
ToolApp app;
|
||||
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)
|
||||
|
||||
add_executable (synergyx
|
||||
${LEGACY_GUI_SOURCE_FILES}
|
||||
${LEGACY_GUI_UI_FILES}
|
||||
res/Synergy.qrc
|
||||
${LEGACY_GUI_SOURCE_FILES}
|
||||
${LEGACY_GUI_UI_FILES}
|
||||
res/Synergy.qrc
|
||||
)
|
||||
|
||||
include_directories (../lib/shared ./src)
|
||||
|
||||
if (WIN32)
|
||||
include_directories ($ENV{BONJOUR_SDK_HOME}/Include)
|
||||
find_library (DNSSD_LIB dnssd.lib
|
||||
HINTS ENV BONJOUR_SDK_HOME
|
||||
PATH_SUFFIXES "Lib/x64")
|
||||
include_directories ($ENV{BONJOUR_SDK_HOME}/Include)
|
||||
find_library (DNSSD_LIB dnssd.lib
|
||||
HINTS ENV BONJOUR_SDK_HOME
|
||||
PATH_SUFFIXES "Lib/x64")
|
||||
endif()
|
||||
|
||||
qt5_use_modules (synergyx Widgets Network)
|
||||
target_link_libraries (synergyx ${DNSSD_LIB} shared)
|
||||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AboutDialog(QWidget* parent, const QString& synergyApp = QString());
|
||||
public:
|
||||
AboutDialog(QWidget* parent, const QString& synergyApp = QString());
|
||||
|
||||
private:
|
||||
VersionChecker m_versionChecker;
|
||||
private:
|
||||
VersionChecker m_versionChecker;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,128 +23,128 @@
|
|||
|
||||
const char* Action::m_ActionTypeNames[] =
|
||||
{
|
||||
"keyDown", "keyUp", "keystroke",
|
||||
"switchToScreen", "switchInDirection", "lockCursorToScreen",
|
||||
"mouseDown", "mouseUp", "mousebutton"
|
||||
"keyDown", "keyUp", "keystroke",
|
||||
"switchToScreen", "switchInDirection", "lockCursorToScreen",
|
||||
"mouseDown", "mouseUp", "mousebutton"
|
||||
};
|
||||
|
||||
const char* Action::m_SwitchDirectionNames[] = { "left", "right", "up", "down" };
|
||||
const char* Action::m_LockCursorModeNames[] = { "toggle", "on", "off" };
|
||||
|
||||
Action::Action() :
|
||||
m_KeySequence(),
|
||||
m_Type(keystroke),
|
||||
m_TypeScreenNames(),
|
||||
m_SwitchScreenName(),
|
||||
m_SwitchDirection(switchLeft),
|
||||
m_LockCursorMode(lockCursorToggle),
|
||||
m_ActiveOnRelease(false),
|
||||
m_HasScreens(false)
|
||||
m_KeySequence(),
|
||||
m_Type(keystroke),
|
||||
m_TypeScreenNames(),
|
||||
m_SwitchScreenName(),
|
||||
m_SwitchDirection(switchLeft),
|
||||
m_LockCursorMode(lockCursorToggle),
|
||||
m_ActiveOnRelease(false),
|
||||
m_HasScreens(false)
|
||||
{
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
case keyDown:
|
||||
case keyUp:
|
||||
case keystroke:
|
||||
{
|
||||
text += keySequence().toString();
|
||||
switch (type())
|
||||
{
|
||||
case keyDown:
|
||||
case keyUp:
|
||||
case keystroke:
|
||||
{
|
||||
text += keySequence().toString();
|
||||
|
||||
if (!keySequence().isMouseButton())
|
||||
{
|
||||
const QStringList& screens = typeScreenNames();
|
||||
if (haveScreens() && !screens.isEmpty())
|
||||
{
|
||||
text += ",";
|
||||
if (!keySequence().isMouseButton())
|
||||
{
|
||||
const QStringList& screens = typeScreenNames();
|
||||
if (haveScreens() && !screens.isEmpty())
|
||||
{
|
||||
text += ",";
|
||||
|
||||
for (int i = 0; i < screens.size(); i++)
|
||||
{
|
||||
text += screens[i];
|
||||
if (i != screens.size() - 1)
|
||||
text += ":";
|
||||
}
|
||||
}
|
||||
else
|
||||
text += ",*";
|
||||
}
|
||||
}
|
||||
break;
|
||||
for (int i = 0; i < screens.size(); i++)
|
||||
{
|
||||
text += screens[i];
|
||||
if (i != screens.size() - 1)
|
||||
text += ":";
|
||||
}
|
||||
}
|
||||
else
|
||||
text += ",*";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case switchToScreen:
|
||||
text += switchScreenName();
|
||||
break;
|
||||
case switchToScreen:
|
||||
text += switchScreenName();
|
||||
break;
|
||||
|
||||
case switchInDirection:
|
||||
text += m_SwitchDirectionNames[m_SwitchDirection];
|
||||
break;
|
||||
case switchInDirection:
|
||||
text += m_SwitchDirectionNames[m_SwitchDirection];
|
||||
break;
|
||||
|
||||
case lockCursorToScreen:
|
||||
text += m_LockCursorModeNames[m_LockCursorMode];
|
||||
break;
|
||||
case lockCursorToScreen:
|
||||
text += m_LockCursorModeNames[m_LockCursorMode];
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Q_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
|
||||
text += ")";
|
||||
text += ")";
|
||||
|
||||
return text;
|
||||
return text;
|
||||
}
|
||||
|
||||
void Action::loadSettings(QSettings& settings)
|
||||
{
|
||||
keySequence().loadSettings(settings);
|
||||
setType(settings.value("type", keyDown).toInt());
|
||||
keySequence().loadSettings(settings);
|
||||
setType(settings.value("type", keyDown).toInt());
|
||||
|
||||
typeScreenNames().clear();
|
||||
int numTypeScreens = settings.beginReadArray("typeScreenNames");
|
||||
for (int i = 0; i < numTypeScreens; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
typeScreenNames().append(settings.value("typeScreenName").toString());
|
||||
}
|
||||
settings.endArray();
|
||||
typeScreenNames().clear();
|
||||
int numTypeScreens = settings.beginReadArray("typeScreenNames");
|
||||
for (int i = 0; i < numTypeScreens; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
typeScreenNames().append(settings.value("typeScreenName").toString());
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
setSwitchScreenName(settings.value("switchScreenName").toString());
|
||||
setSwitchDirection(settings.value("switchInDirection", switchLeft).toInt());
|
||||
setLockCursorMode(settings.value("lockCursorToScreen", lockCursorToggle).toInt());
|
||||
setActiveOnRelease(settings.value("activeOnRelease", false).toBool());
|
||||
setHaveScreens(settings.value("hasScreens", false).toBool());
|
||||
setSwitchScreenName(settings.value("switchScreenName").toString());
|
||||
setSwitchDirection(settings.value("switchInDirection", switchLeft).toInt());
|
||||
setLockCursorMode(settings.value("lockCursorToScreen", lockCursorToggle).toInt());
|
||||
setActiveOnRelease(settings.value("activeOnRelease", false).toBool());
|
||||
setHaveScreens(settings.value("hasScreens", false).toBool());
|
||||
}
|
||||
|
||||
void Action::saveSettings(QSettings& settings) const
|
||||
{
|
||||
keySequence().saveSettings(settings);
|
||||
settings.setValue("type", type());
|
||||
keySequence().saveSettings(settings);
|
||||
settings.setValue("type", type());
|
||||
|
||||
settings.beginWriteArray("typeScreenNames");
|
||||
for (int i = 0; i < typeScreenNames().size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue("typeScreenName", typeScreenNames()[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
settings.beginWriteArray("typeScreenNames");
|
||||
for (int i = 0; i < typeScreenNames().size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue("typeScreenName", typeScreenNames()[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
settings.setValue("switchScreenName", switchScreenName());
|
||||
settings.setValue("switchInDirection", switchDirection());
|
||||
settings.setValue("lockCursorToScreen", lockCursorMode());
|
||||
settings.setValue("activeOnRelease", activeOnRelease());
|
||||
settings.setValue("hasScreens", haveScreens());
|
||||
settings.setValue("switchScreenName", switchScreenName());
|
||||
settings.setValue("switchInDirection", switchDirection());
|
||||
settings.setValue("lockCursorToScreen", lockCursorMode());
|
||||
settings.setValue("activeOnRelease", activeOnRelease());
|
||||
settings.setValue("hasScreens", haveScreens());
|
||||
}
|
||||
|
||||
QTextStream& operator<<(QTextStream& outStream, const Action& action)
|
||||
{
|
||||
if (action.activeOnRelease())
|
||||
outStream << ";";
|
||||
if (action.activeOnRelease())
|
||||
outStream << ";";
|
||||
|
||||
outStream << action.text();
|
||||
outStream << action.text();
|
||||
|
||||
return outStream;
|
||||
return outStream;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,54 +32,54 @@ class QTextStream;
|
|||
|
||||
class Action
|
||||
{
|
||||
friend class ActionDialog;
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
||||
friend class ActionDialog;
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const Action& action);
|
||||
|
||||
public:
|
||||
enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
||||
enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown };
|
||||
enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff };
|
||||
public:
|
||||
enum ActionType { keyDown, keyUp, keystroke, switchToScreen, switchInDirection, lockCursorToScreen, mouseDown, mouseUp, mousebutton };
|
||||
enum SwitchDirection { switchLeft, switchRight, switchUp, switchDown };
|
||||
enum LockCursorMode { lockCursorToggle, lockCursonOn, lockCursorOff };
|
||||
|
||||
public:
|
||||
Action();
|
||||
public:
|
||||
Action();
|
||||
|
||||
public:
|
||||
QString text() const;
|
||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||
void loadSettings(QSettings& settings);
|
||||
void saveSettings(QSettings& settings) const;
|
||||
int type() const { return m_Type; }
|
||||
const QStringList& typeScreenNames() const { return m_TypeScreenNames; }
|
||||
const QString& switchScreenName() const { return m_SwitchScreenName; }
|
||||
int switchDirection() const { return m_SwitchDirection; }
|
||||
int lockCursorMode() const { return m_LockCursorMode; }
|
||||
bool activeOnRelease() const { return m_ActiveOnRelease; }
|
||||
bool haveScreens() const { return m_HasScreens; }
|
||||
public:
|
||||
QString text() const;
|
||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||
void loadSettings(QSettings& settings);
|
||||
void saveSettings(QSettings& settings) const;
|
||||
int type() const { return m_Type; }
|
||||
const QStringList& typeScreenNames() const { return m_TypeScreenNames; }
|
||||
const QString& switchScreenName() const { return m_SwitchScreenName; }
|
||||
int switchDirection() const { return m_SwitchDirection; }
|
||||
int lockCursorMode() const { return m_LockCursorMode; }
|
||||
bool activeOnRelease() const { return m_ActiveOnRelease; }
|
||||
bool haveScreens() const { return m_HasScreens; }
|
||||
|
||||
protected:
|
||||
KeySequence& keySequence() { return m_KeySequence; }
|
||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||
void setType(int t) { m_Type = t; }
|
||||
QStringList& typeScreenNames() { return m_TypeScreenNames; }
|
||||
void setSwitchScreenName(const QString& n) { m_SwitchScreenName = n; }
|
||||
void setSwitchDirection(int d) { m_SwitchDirection = d; }
|
||||
void setLockCursorMode(int m) { m_LockCursorMode = m; }
|
||||
void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; }
|
||||
void setHaveScreens(bool b) { m_HasScreens = b; }
|
||||
protected:
|
||||
KeySequence& keySequence() { return m_KeySequence; }
|
||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||
void setType(int t) { m_Type = t; }
|
||||
QStringList& typeScreenNames() { return m_TypeScreenNames; }
|
||||
void setSwitchScreenName(const QString& n) { m_SwitchScreenName = n; }
|
||||
void setSwitchDirection(int d) { m_SwitchDirection = d; }
|
||||
void setLockCursorMode(int m) { m_LockCursorMode = m; }
|
||||
void setActiveOnRelease(bool b) { m_ActiveOnRelease = b; }
|
||||
void setHaveScreens(bool b) { m_HasScreens = b; }
|
||||
|
||||
private:
|
||||
KeySequence m_KeySequence;
|
||||
int m_Type;
|
||||
QStringList m_TypeScreenNames;
|
||||
QString m_SwitchScreenName;
|
||||
int m_SwitchDirection;
|
||||
int m_LockCursorMode;
|
||||
bool m_ActiveOnRelease;
|
||||
bool m_HasScreens;
|
||||
private:
|
||||
KeySequence m_KeySequence;
|
||||
int m_Type;
|
||||
QStringList m_TypeScreenNames;
|
||||
QString m_SwitchScreenName;
|
||||
int m_SwitchDirection;
|
||||
int m_LockCursorMode;
|
||||
bool m_ActiveOnRelease;
|
||||
bool m_HasScreens;
|
||||
|
||||
static const char* m_ActionTypeNames[];
|
||||
static const char* m_SwitchDirectionNames[];
|
||||
static const char* m_LockCursorModeNames[];
|
||||
static const char* m_ActionTypeNames[];
|
||||
static const char* m_SwitchDirectionNames[];
|
||||
static const char* m_LockCursorModeNames[];
|
||||
};
|
||||
|
||||
typedef QList<Action> ActionList;
|
||||
|
|
|
@ -27,83 +27,83 @@
|
|||
#include <QtGui>
|
||||
|
||||
ActionDialog::ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ActionDialogBase(),
|
||||
m_ServerConfig(config),
|
||||
m_Hotkey(hotkey),
|
||||
m_Action(action),
|
||||
m_pButtonGroupType(new QButtonGroup(this))
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ActionDialogBase(),
|
||||
m_ServerConfig(config),
|
||||
m_Hotkey(hotkey),
|
||||
m_Action(action),
|
||||
m_pButtonGroupType(new QButtonGroup(this))
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
||||
// at the button id of the checked radio button
|
||||
QRadioButton* const typeButtons[] = { m_pRadioPress, m_pRadioRelease, m_pRadioPressAndRelease, m_pRadioSwitchToScreen, m_pRadioSwitchInDirection, m_pRadioLockCursorToScreen };
|
||||
// work around Qt Designer's lack of a QButtonGroup; we need it to get
|
||||
// at the button id of the checked radio button
|
||||
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++)
|
||||
m_pButtonGroupType->addButton(typeButtons[i], i);
|
||||
for (unsigned int i = 0; i < sizeof(typeButtons) / sizeof(typeButtons[0]); i++)
|
||||
m_pButtonGroupType->addButton(typeButtons[i], i);
|
||||
|
||||
m_pKeySequenceWidgetHotkey->setText(m_Action.keySequence().toString());
|
||||
m_pKeySequenceWidgetHotkey->setKeySequence(m_Action.keySequence());
|
||||
m_pButtonGroupType->button(m_Action.type())->setChecked(true);
|
||||
m_pComboSwitchInDirection->setCurrentIndex(m_Action.switchDirection());
|
||||
m_pComboLockCursorToScreen->setCurrentIndex(m_Action.lockCursorMode());
|
||||
m_pKeySequenceWidgetHotkey->setText(m_Action.keySequence().toString());
|
||||
m_pKeySequenceWidgetHotkey->setKeySequence(m_Action.keySequence());
|
||||
m_pButtonGroupType->button(m_Action.type())->setChecked(true);
|
||||
m_pComboSwitchInDirection->setCurrentIndex(m_Action.switchDirection());
|
||||
m_pComboLockCursorToScreen->setCurrentIndex(m_Action.lockCursorMode());
|
||||
|
||||
if (m_Action.activeOnRelease())
|
||||
m_pRadioHotkeyReleased->setChecked(true);
|
||||
else
|
||||
m_pRadioHotkeyPressed->setChecked(true);
|
||||
if (m_Action.activeOnRelease())
|
||||
m_pRadioHotkeyReleased->setChecked(true);
|
||||
else
|
||||
m_pRadioHotkeyPressed->setChecked(true);
|
||||
|
||||
m_pGroupBoxScreens->setChecked(m_Action.haveScreens());
|
||||
m_pGroupBoxScreens->setChecked(m_Action.haveScreens());
|
||||
|
||||
int idx = 0;
|
||||
foreach(const Screen& screen, serverConfig().screens())
|
||||
if (!screen.isNull())
|
||||
{
|
||||
QListWidgetItem *pListItem = new QListWidgetItem(screen.name());
|
||||
m_pListScreens->addItem(pListItem);
|
||||
if (m_Action.typeScreenNames().indexOf(screen.name()) != -1)
|
||||
m_pListScreens->setCurrentItem(pListItem);
|
||||
int idx = 0;
|
||||
foreach(const Screen& screen, serverConfig().screens())
|
||||
if (!screen.isNull())
|
||||
{
|
||||
QListWidgetItem *pListItem = new QListWidgetItem(screen.name());
|
||||
m_pListScreens->addItem(pListItem);
|
||||
if (m_Action.typeScreenNames().indexOf(screen.name()) != -1)
|
||||
m_pListScreens->setCurrentItem(pListItem);
|
||||
|
||||
m_pComboSwitchToScreen->addItem(screen.name());
|
||||
if (screen.name() == m_Action.switchScreenName())
|
||||
m_pComboSwitchToScreen->setCurrentIndex(idx);
|
||||
m_pComboSwitchToScreen->addItem(screen.name());
|
||||
if (screen.name() == m_Action.switchScreenName())
|
||||
m_pComboSwitchToScreen->setCurrentIndex(idx);
|
||||
|
||||
idx++;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
void ActionDialog::accept()
|
||||
{
|
||||
if (!sequenceWidget()->valid() && m_pButtonGroupType->checkedId() >= 0 && m_pButtonGroupType->checkedId() < 3)
|
||||
return;
|
||||
if (!sequenceWidget()->valid() && m_pButtonGroupType->checkedId() >= 0 && m_pButtonGroupType->checkedId() < 3)
|
||||
return;
|
||||
|
||||
m_Action.setKeySequence(sequenceWidget()->keySequence());
|
||||
m_Action.setType(m_pButtonGroupType->checkedId());
|
||||
m_Action.setHaveScreens(m_pGroupBoxScreens->isChecked());
|
||||
m_Action.setKeySequence(sequenceWidget()->keySequence());
|
||||
m_Action.setType(m_pButtonGroupType->checkedId());
|
||||
m_Action.setHaveScreens(m_pGroupBoxScreens->isChecked());
|
||||
|
||||
m_Action.typeScreenNames().clear();
|
||||
foreach(const QListWidgetItem* pItem, m_pListScreens->selectedItems())
|
||||
m_Action.typeScreenNames().append(pItem->text());
|
||||
m_Action.typeScreenNames().clear();
|
||||
foreach(const QListWidgetItem* pItem, m_pListScreens->selectedItems())
|
||||
m_Action.typeScreenNames().append(pItem->text());
|
||||
|
||||
m_Action.setSwitchScreenName(m_pComboSwitchToScreen->currentText());
|
||||
m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex());
|
||||
m_Action.setLockCursorMode(m_pComboLockCursorToScreen->currentIndex());
|
||||
m_Action.setActiveOnRelease(m_pRadioHotkeyReleased->isChecked());
|
||||
m_Action.setSwitchScreenName(m_pComboSwitchToScreen->currentText());
|
||||
m_Action.setSwitchDirection(m_pComboSwitchInDirection->currentIndex());
|
||||
m_Action.setLockCursorMode(m_pComboLockCursorToScreen->currentIndex());
|
||||
m_Action.setActiveOnRelease(m_pRadioHotkeyReleased->isChecked());
|
||||
|
||||
QDialog::accept();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void ActionDialog::on_m_pKeySequenceWidgetHotkey_keySequenceChanged()
|
||||
{
|
||||
if (sequenceWidget()->keySequence().isMouseButton())
|
||||
{
|
||||
m_pGroupBoxScreens->setEnabled(false);
|
||||
m_pListScreens->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pGroupBoxScreens->setEnabled(true);
|
||||
m_pListScreens->setEnabled(true);
|
||||
}
|
||||
if (sequenceWidget()->keySequence().isMouseButton())
|
||||
{
|
||||
m_pGroupBoxScreens->setEnabled(false);
|
||||
m_pListScreens->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pGroupBoxScreens->setEnabled(true);
|
||||
m_pListScreens->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,25 +32,25 @@ class ServerConfig;
|
|||
|
||||
class ActionDialog : public QDialog, public Ui::ActionDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action);
|
||||
public:
|
||||
ActionDialog(QWidget* parent, ServerConfig& config, Hotkey& hotkey, Action& action);
|
||||
|
||||
protected slots:
|
||||
void accept();
|
||||
void on_m_pKeySequenceWidgetHotkey_keySequenceChanged();
|
||||
protected slots:
|
||||
void accept();
|
||||
void on_m_pKeySequenceWidgetHotkey_keySequenceChanged();
|
||||
|
||||
protected:
|
||||
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
||||
const ServerConfig& serverConfig() const { return m_ServerConfig; }
|
||||
protected:
|
||||
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
||||
const ServerConfig& serverConfig() const { return m_ServerConfig; }
|
||||
|
||||
private:
|
||||
const ServerConfig& m_ServerConfig;
|
||||
Hotkey& m_Hotkey;
|
||||
Action& m_Action;
|
||||
private:
|
||||
const ServerConfig& m_ServerConfig;
|
||||
Hotkey& m_Hotkey;
|
||||
Action& m_Action;
|
||||
|
||||
QButtonGroup* m_pButtonGroupType;
|
||||
QButtonGroup* m_pButtonGroupType;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,109 +15,109 @@
|
|||
#include <iostream>
|
||||
|
||||
ActivationDialog::ActivationDialog(QWidget* parent, AppConfig& appConfig,
|
||||
LicenseManager& licenseManager) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ActivationDialog),
|
||||
m_appConfig(&appConfig),
|
||||
m_LicenseManager (&licenseManager)
|
||||
LicenseManager& licenseManager) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ActivationDialog),
|
||||
m_appConfig(&appConfig),
|
||||
m_LicenseManager (&licenseManager)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
refreshSerialKey();
|
||||
time_t currentTime = ::time(0);
|
||||
if (!m_LicenseManager->serialKey().isExpired(currentTime)) {
|
||||
ui->m_trialWidget->hide();
|
||||
}
|
||||
ui->setupUi(this);
|
||||
refreshSerialKey();
|
||||
time_t currentTime = ::time(0);
|
||||
if (!m_LicenseManager->serialKey().isExpired(currentTime)) {
|
||||
ui->m_trialWidget->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivationDialog::refreshSerialKey()
|
||||
{
|
||||
ui->m_pTextEditSerialKey->setText(m_appConfig->serialKey());
|
||||
ui->m_pTextEditSerialKey->setFocus();
|
||||
ui->m_pTextEditSerialKey->moveCursor(QTextCursor::End);
|
||||
ui->m_trialLabel->setText(tr("<html><head/><body><p>Your trial has "
|
||||
"expired. <a href=\"https://symless.com/"
|
||||
"synergy/trial/thanks?id=%1\"><span "
|
||||
"style=\"text-decoration: underline; "
|
||||
"color:#0000ff;\">Buy now!</span></a>"
|
||||
"</p></body></html>")
|
||||
.arg (m_appConfig->serialKey()));
|
||||
ui->m_pTextEditSerialKey->setText(m_appConfig->serialKey());
|
||||
ui->m_pTextEditSerialKey->setFocus();
|
||||
ui->m_pTextEditSerialKey->moveCursor(QTextCursor::End);
|
||||
ui->m_trialLabel->setText(tr("<html><head/><body><p>Your trial has "
|
||||
"expired. <a href=\"https://symless.com/"
|
||||
"synergy/trial/thanks?id=%1\"><span "
|
||||
"style=\"text-decoration: underline; "
|
||||
"color:#0000ff;\">Buy now!</span></a>"
|
||||
"</p></body></html>")
|
||||
.arg (m_appConfig->serialKey()));
|
||||
}
|
||||
|
||||
ActivationDialog::~ActivationDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ActivationDialog::reject()
|
||||
{
|
||||
if (m_LicenseManager->activeEdition() == kUnregistered) {
|
||||
CancelActivationDialog cancelActivationDialog(this);
|
||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||
m_LicenseManager->skipActivation();
|
||||
m_appConfig->activationHasRun(true);
|
||||
m_appConfig->saveSettings();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
QDialog::reject();
|
||||
if (m_LicenseManager->activeEdition() == kUnregistered) {
|
||||
CancelActivationDialog cancelActivationDialog(this);
|
||||
if (QDialog::Accepted == cancelActivationDialog.exec()) {
|
||||
m_LicenseManager->skipActivation();
|
||||
m_appConfig->activationHasRun(true);
|
||||
m_appConfig->saveSettings();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void ActivationDialog::accept()
|
||||
{
|
||||
QMessageBox message;
|
||||
m_appConfig->activationHasRun(true);
|
||||
m_appConfig->saveSettings();
|
||||
QMessageBox message;
|
||||
m_appConfig->activationHasRun(true);
|
||||
m_appConfig->saveSettings();
|
||||
|
||||
std::pair<bool, QString> result;
|
||||
try {
|
||||
SerialKey serialKey (ui->m_pTextEditSerialKey->toPlainText().
|
||||
trimmed().toStdString());
|
||||
result = m_LicenseManager->setSerialKey(serialKey);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
message.critical(this, "Unknown Error",
|
||||
tr("An error occurred while trying to activate Synergy. "
|
||||
"Please contact the helpdesk, and provide the "
|
||||
"following information:\n\n%1").arg(e.what()));
|
||||
refreshSerialKey();
|
||||
return;
|
||||
}
|
||||
std::pair<bool, QString> result;
|
||||
try {
|
||||
SerialKey serialKey (ui->m_pTextEditSerialKey->toPlainText().
|
||||
trimmed().toStdString());
|
||||
result = m_LicenseManager->setSerialKey(serialKey);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
message.critical(this, "Unknown Error",
|
||||
tr("An error occurred while trying to activate Synergy. "
|
||||
"Please contact the helpdesk, and provide the "
|
||||
"following information:\n\n%1").arg(e.what()));
|
||||
refreshSerialKey();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result.first) {
|
||||
message.critical(this, "Activation failed",
|
||||
tr("%1").arg(result.second));
|
||||
refreshSerialKey();
|
||||
return;
|
||||
}
|
||||
if (!result.first) {
|
||||
message.critical(this, "Activation failed",
|
||||
tr("%1").arg(result.second));
|
||||
refreshSerialKey();
|
||||
return;
|
||||
}
|
||||
|
||||
m_LicenseManager->notifyActivation("serial:" + m_appConfig->serialKey());
|
||||
Edition edition = m_LicenseManager->activeEdition();
|
||||
time_t daysLeft = m_LicenseManager->serialKey().daysLeft(::time(0));
|
||||
if (edition != kUnregistered) {
|
||||
QString thanksMessage = tr("Thanks for trying %1! %5\n\n%2 day%3 of "
|
||||
"your trial remain%4").
|
||||
arg (m_LicenseManager->getEditionName(edition)).
|
||||
arg (daysLeft).
|
||||
arg ((daysLeft == 1) ? "" : "s").
|
||||
arg ((daysLeft == 1) ? "s" : "");
|
||||
m_LicenseManager->notifyActivation("serial:" + m_appConfig->serialKey());
|
||||
Edition edition = m_LicenseManager->activeEdition();
|
||||
time_t daysLeft = m_LicenseManager->serialKey().daysLeft(::time(0));
|
||||
if (edition != kUnregistered) {
|
||||
QString thanksMessage = tr("Thanks for trying %1! %5\n\n%2 day%3 of "
|
||||
"your trial remain%4").
|
||||
arg (m_LicenseManager->getEditionName(edition)).
|
||||
arg (daysLeft).
|
||||
arg ((daysLeft == 1) ? "" : "s").
|
||||
arg ((daysLeft == 1) ? "s" : "");
|
||||
|
||||
if (edition == kPro) {
|
||||
thanksMessage = thanksMessage.arg("If you're using SSL, "
|
||||
"remember to activate all of your devices.");
|
||||
} else {
|
||||
thanksMessage = thanksMessage.arg("");
|
||||
}
|
||||
if (edition == kPro) {
|
||||
thanksMessage = thanksMessage.arg("If you're using SSL, "
|
||||
"remember to activate all of your devices.");
|
||||
} else {
|
||||
thanksMessage = thanksMessage.arg("");
|
||||
}
|
||||
|
||||
if (m_LicenseManager->serialKey().isTrial()) {
|
||||
message.information(this, "Thanks!", thanksMessage);
|
||||
}
|
||||
else {
|
||||
message.information(this, "Activated!",
|
||||
tr("Thanks for activating %1!").arg
|
||||
(m_LicenseManager->getEditionName(edition)));
|
||||
}
|
||||
}
|
||||
if (m_LicenseManager->serialKey().isTrial()) {
|
||||
message.information(this, "Thanks!", thanksMessage);
|
||||
}
|
||||
else {
|
||||
message.information(this, "Activated!",
|
||||
tr("Thanks for activating %1!").arg
|
||||
(m_LicenseManager->getEditionName(edition)));
|
||||
}
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
|
|
@ -12,24 +12,24 @@ class AppConfig;
|
|||
|
||||
class ActivationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ActivationDialog(QWidget *parent, AppConfig& appConfig,
|
||||
LicenseManager& licenseManager);
|
||||
~ActivationDialog();
|
||||
ActivationDialog(QWidget *parent, AppConfig& appConfig,
|
||||
LicenseManager& licenseManager);
|
||||
~ActivationDialog();
|
||||
|
||||
public slots:
|
||||
void reject();
|
||||
void accept();
|
||||
void reject();
|
||||
void accept();
|
||||
|
||||
protected:
|
||||
void refreshSerialKey();
|
||||
void refreshSerialKey();
|
||||
|
||||
private:
|
||||
Ui::ActivationDialog *ui;
|
||||
AppConfig* m_appConfig;
|
||||
LicenseManager* m_LicenseManager;
|
||||
Ui::ActivationDialog *ui;
|
||||
AppConfig* m_appConfig;
|
||||
LicenseManager* m_LicenseManager;
|
||||
};
|
||||
|
||||
#endif // ACTIVATIONDIALOG_H
|
||||
|
|
|
@ -20,41 +20,41 @@
|
|||
#include "CoreInterface.h"
|
||||
|
||||
ActivationNotifier::ActivationNotifier(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void ActivationNotifier::setIdentity(QString identity)
|
||||
{
|
||||
m_Identity = identity;
|
||||
m_Identity = identity;
|
||||
}
|
||||
|
||||
void ActivationNotifier::setUpdateInfo(QString const& fromVersion,
|
||||
QString const& toVersion,
|
||||
QString const& serialKey)
|
||||
QString const& toVersion,
|
||||
QString const& serialKey)
|
||||
{
|
||||
m_fromVersion = fromVersion;
|
||||
m_toVersion = toVersion;
|
||||
m_serialKey = serialKey;
|
||||
m_fromVersion = fromVersion;
|
||||
m_toVersion = toVersion;
|
||||
m_serialKey = serialKey;
|
||||
}
|
||||
|
||||
void ActivationNotifier::notify()
|
||||
{
|
||||
CoreInterface coreInterface;
|
||||
try {
|
||||
coreInterface.notifyActivation(m_Identity);
|
||||
}
|
||||
catch (...) {
|
||||
// catch all exceptions and fails silently
|
||||
}
|
||||
CoreInterface coreInterface;
|
||||
try {
|
||||
coreInterface.notifyActivation(m_Identity);
|
||||
}
|
||||
catch (...) {
|
||||
// catch all exceptions and fails silently
|
||||
}
|
||||
}
|
||||
|
||||
void ActivationNotifier::notifyUpdate()
|
||||
{
|
||||
try {
|
||||
CoreInterface coreInterface;
|
||||
coreInterface.notifyUpdate(m_fromVersion, m_toVersion,
|
||||
m_serialKey);
|
||||
} catch (...) {
|
||||
}
|
||||
try {
|
||||
CoreInterface coreInterface;
|
||||
coreInterface.notifyUpdate(m_fromVersion, m_toVersion,
|
||||
m_serialKey);
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,24 +24,24 @@ class ActivationNotifier : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ActivationNotifier(QObject *parent = 0);
|
||||
explicit ActivationNotifier(QObject *parent = 0);
|
||||
|
||||
void setIdentity(QString identity);
|
||||
void setUpdateInfo(QString const& fromVersion,
|
||||
QString const& toVersion, QString const& serialKey);
|
||||
void setIdentity(QString identity);
|
||||
void setUpdateInfo(QString const& fromVersion,
|
||||
QString const& toVersion, QString const& serialKey);
|
||||
|
||||
public slots:
|
||||
void notify();
|
||||
void notifyUpdate();
|
||||
void notify();
|
||||
void notifyUpdate();
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void finished();
|
||||
|
||||
private:
|
||||
QString m_Identity;
|
||||
QString m_fromVersion;
|
||||
QString m_toVersion;
|
||||
QString m_serialKey;
|
||||
QString m_Identity;
|
||||
QString m_fromVersion;
|
||||
QString m_toVersion;
|
||||
QString m_serialKey;
|
||||
};
|
||||
|
||||
#endif // ACTIVATIONNOTIFIER_H
|
||||
|
|
|
@ -22,108 +22,108 @@
|
|||
#include <QLabel>
|
||||
|
||||
AddClientDialog::AddClientDialog(const QString& clientName, QWidget* parent) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::AddClientDialog(),
|
||||
m_AddResult(kAddClientIgnore),
|
||||
m_IgnoreAutoConfigClient(false)
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::AddClientDialog(),
|
||||
m_AddResult(kAddClientIgnore),
|
||||
m_IgnoreAutoConfigClient(false)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
m_pLabelHead->setText("A client wants to connect. "
|
||||
"Please choose a location for " + clientName + ".");
|
||||
m_pLabelHead->setText("A client wants to connect. "
|
||||
"Please choose a location for " + clientName + ".");
|
||||
|
||||
QIcon icon(":res/icons/64x64/video-display.png");
|
||||
QSize IconSize(32,32);
|
||||
QIcon icon(":res/icons/64x64/video-display.png");
|
||||
QSize IconSize(32,32);
|
||||
|
||||
m_pButtonLeft = new QPushButton(this);
|
||||
m_pButtonLeft->setIcon(icon);
|
||||
m_pButtonLeft->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonLeft, 2, 0, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonLeft, SIGNAL(clicked()), this, SLOT(handleButtonLeft()));
|
||||
m_pButtonLeft = new QPushButton(this);
|
||||
m_pButtonLeft->setIcon(icon);
|
||||
m_pButtonLeft->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonLeft, 2, 0, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonLeft, SIGNAL(clicked()), this, SLOT(handleButtonLeft()));
|
||||
|
||||
m_pButtonUp = new QPushButton(this);
|
||||
m_pButtonUp->setIcon(icon);
|
||||
m_pButtonUp->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonUp, 1, 1, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonUp, SIGNAL(clicked()), this, SLOT(handleButtonUp()));
|
||||
m_pButtonUp = new QPushButton(this);
|
||||
m_pButtonUp->setIcon(icon);
|
||||
m_pButtonUp->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonUp, 1, 1, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonUp, SIGNAL(clicked()), this, SLOT(handleButtonUp()));
|
||||
|
||||
m_pButtonRight = new QPushButton(this);
|
||||
m_pButtonRight->setIcon(icon);
|
||||
m_pButtonRight->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonRight, 2, 2, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonRight, SIGNAL(clicked()), this, SLOT(handleButtonRight()));
|
||||
m_pButtonRight = new QPushButton(this);
|
||||
m_pButtonRight->setIcon(icon);
|
||||
m_pButtonRight->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonRight, 2, 2, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonRight, SIGNAL(clicked()), this, SLOT(handleButtonRight()));
|
||||
|
||||
m_pButtonDown = new QPushButton(this);
|
||||
m_pButtonDown->setIcon(icon);
|
||||
m_pButtonDown->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonDown, 3, 1, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonDown, SIGNAL(clicked()), this, SLOT(handleButtonDown()));
|
||||
m_pButtonDown = new QPushButton(this);
|
||||
m_pButtonDown->setIcon(icon);
|
||||
m_pButtonDown->setIconSize(IconSize);
|
||||
gridLayout->addWidget(m_pButtonDown, 3, 1, 1, 1, Qt::AlignCenter);
|
||||
connect(m_pButtonDown, SIGNAL(clicked()), this, SLOT(handleButtonDown()));
|
||||
|
||||
m_pLabelCenter = new QLabel(this);
|
||||
m_pLabelCenter->setPixmap(QPixmap(":res/icons/64x64/video-display.png"));
|
||||
gridLayout->addWidget(m_pLabelCenter, 2, 1, 1, 1, Qt::AlignCenter);
|
||||
m_pLabelCenter = new QLabel(this);
|
||||
m_pLabelCenter->setPixmap(QPixmap(":res/icons/64x64/video-display.png"));
|
||||
gridLayout->addWidget(m_pLabelCenter, 2, 1, 1, 1, Qt::AlignCenter);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
m_pDialogButtonBox->setLayoutDirection(Qt::RightToLeft);
|
||||
m_pDialogButtonBox->setLayoutDirection(Qt::RightToLeft);
|
||||
#endif
|
||||
|
||||
QPushButton* advanced = m_pDialogButtonBox->addButton("Advanced",
|
||||
QDialogButtonBox::HelpRole);
|
||||
connect(advanced, SIGNAL(clicked()), this, SLOT(handleButtonAdvanced()));
|
||||
QPushButton* advanced = m_pDialogButtonBox->addButton("Advanced",
|
||||
QDialogButtonBox::HelpRole);
|
||||
connect(advanced, SIGNAL(clicked()), this, SLOT(handleButtonAdvanced()));
|
||||
}
|
||||
|
||||
AddClientDialog::~AddClientDialog()
|
||||
{
|
||||
delete m_pButtonUp;
|
||||
delete m_pButtonDown;
|
||||
delete m_pButtonLeft;
|
||||
delete m_pButtonRight;
|
||||
delete m_pLabelCenter;
|
||||
delete m_pButtonUp;
|
||||
delete m_pButtonDown;
|
||||
delete m_pButtonLeft;
|
||||
delete m_pButtonRight;
|
||||
delete m_pLabelCenter;
|
||||
}
|
||||
|
||||
void AddClientDialog::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AddClientDialog::handleButtonLeft()
|
||||
{
|
||||
m_AddResult = kAddClientLeft;
|
||||
close();
|
||||
m_AddResult = kAddClientLeft;
|
||||
close();
|
||||
}
|
||||
|
||||
void AddClientDialog::handleButtonUp()
|
||||
{
|
||||
m_AddResult = kAddClientUp;
|
||||
close();
|
||||
m_AddResult = kAddClientUp;
|
||||
close();
|
||||
}
|
||||
|
||||
void AddClientDialog::handleButtonRight()
|
||||
{
|
||||
m_AddResult = kAddClientRight;
|
||||
close();
|
||||
m_AddResult = kAddClientRight;
|
||||
close();
|
||||
}
|
||||
|
||||
void AddClientDialog::handleButtonDown()
|
||||
{
|
||||
m_AddResult = kAddClientDown;
|
||||
close();
|
||||
m_AddResult = kAddClientDown;
|
||||
close();
|
||||
}
|
||||
|
||||
void AddClientDialog::handleButtonAdvanced()
|
||||
{
|
||||
m_AddResult = kAddClientOther;
|
||||
close();
|
||||
m_AddResult = kAddClientOther;
|
||||
close();
|
||||
}
|
||||
|
||||
void AddClientDialog::on_m_pCheckBoxIgnoreClient_toggled(bool checked)
|
||||
{
|
||||
m_IgnoreAutoConfigClient = checked;
|
||||
m_IgnoreAutoConfigClient = checked;
|
||||
}
|
||||
|
|
|
@ -26,43 +26,43 @@ class QPushButton;
|
|||
class QLabel;
|
||||
|
||||
enum {
|
||||
kAddClientRight,
|
||||
kAddClientLeft,
|
||||
kAddClientUp,
|
||||
kAddClientDown,
|
||||
kAddClientOther,
|
||||
kAddClientIgnore
|
||||
kAddClientRight,
|
||||
kAddClientLeft,
|
||||
kAddClientUp,
|
||||
kAddClientDown,
|
||||
kAddClientOther,
|
||||
kAddClientIgnore
|
||||
};
|
||||
|
||||
class AddClientDialog : public QDialog, public Ui::AddClientDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
AddClientDialog(const QString& clientName, QWidget* parent = 0);
|
||||
~AddClientDialog();
|
||||
AddClientDialog(const QString& clientName, QWidget* parent = 0);
|
||||
~AddClientDialog();
|
||||
|
||||
int addResult() { return m_AddResult; }
|
||||
bool ignoreAutoConfigClient() { return m_IgnoreAutoConfigClient; }
|
||||
int addResult() { return m_AddResult; }
|
||||
bool ignoreAutoConfigClient() { return m_IgnoreAutoConfigClient; }
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void on_m_pCheckBoxIgnoreClient_toggled(bool checked);
|
||||
void handleButtonLeft();
|
||||
void handleButtonUp();
|
||||
void handleButtonRight();
|
||||
void handleButtonDown();
|
||||
void handleButtonAdvanced();
|
||||
void on_m_pCheckBoxIgnoreClient_toggled(bool checked);
|
||||
void handleButtonLeft();
|
||||
void handleButtonUp();
|
||||
void handleButtonRight();
|
||||
void handleButtonDown();
|
||||
void handleButtonAdvanced();
|
||||
|
||||
private:
|
||||
QPushButton* m_pButtonLeft;
|
||||
QPushButton* m_pButtonUp;
|
||||
QPushButton* m_pButtonRight;
|
||||
QPushButton* m_pButtonDown;
|
||||
QLabel* m_pLabelCenter;
|
||||
int m_AddResult;
|
||||
bool m_IgnoreAutoConfigClient;
|
||||
QPushButton* m_pButtonLeft;
|
||||
QPushButton* m_pButtonUp;
|
||||
QPushButton* m_pButtonRight;
|
||||
QPushButton* m_pButtonDown;
|
||||
QLabel* m_pLabelCenter;
|
||||
int m_AddResult;
|
||||
bool m_IgnoreAutoConfigClient;
|
||||
};
|
||||
|
||||
#endif // ADDCLIENTDIALOG_H
|
||||
|
|
|
@ -39,38 +39,38 @@ const ElevateMode defaultElevateMode = ElevateAsNeeded;
|
|||
|
||||
static const char* logLevelNames[] =
|
||||
{
|
||||
"ERROR",
|
||||
"WARNING",
|
||||
"NOTE",
|
||||
"INFO",
|
||||
"DEBUG",
|
||||
"DEBUG1",
|
||||
"DEBUG2"
|
||||
"ERROR",
|
||||
"WARNING",
|
||||
"NOTE",
|
||||
"INFO",
|
||||
"DEBUG",
|
||||
"DEBUG1",
|
||||
"DEBUG2"
|
||||
};
|
||||
|
||||
AppConfig::AppConfig(QSettings* settings) :
|
||||
m_pSettings(settings),
|
||||
m_ScreenName(),
|
||||
m_Port(24800),
|
||||
m_Interface(),
|
||||
m_LogLevel(0),
|
||||
m_WizardLastRun(0),
|
||||
m_ProcessMode(DEFAULT_PROCESS_MODE),
|
||||
m_AutoConfig(true),
|
||||
m_ElevateMode(defaultElevateMode),
|
||||
m_AutoConfigPrompted(false),
|
||||
m_CryptoEnabled(false),
|
||||
m_AutoHide(false),
|
||||
m_LastExpiringWarningTime(0)
|
||||
m_pSettings(settings),
|
||||
m_ScreenName(),
|
||||
m_Port(24800),
|
||||
m_Interface(),
|
||||
m_LogLevel(0),
|
||||
m_WizardLastRun(0),
|
||||
m_ProcessMode(DEFAULT_PROCESS_MODE),
|
||||
m_AutoConfig(true),
|
||||
m_ElevateMode(defaultElevateMode),
|
||||
m_AutoConfigPrompted(false),
|
||||
m_CryptoEnabled(false),
|
||||
m_AutoHide(false),
|
||||
m_LastExpiringWarningTime(0)
|
||||
{
|
||||
Q_ASSERT(m_pSettings);
|
||||
Q_ASSERT(m_pSettings);
|
||||
|
||||
loadSettings();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
AppConfig::~AppConfig()
|
||||
{
|
||||
saveSettings();
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
const QString &AppConfig::screenName() const { return m_ScreenName; }
|
||||
|
@ -88,44 +88,44 @@ const QString &AppConfig::logFilename() const { return m_LogFilename; }
|
|||
QString AppConfig::synergyLogDir() const
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
// on windows, we want to log to program files
|
||||
return synergyProgramDir() + "log/";
|
||||
// on windows, we want to log to program files
|
||||
return synergyProgramDir() + "log/";
|
||||
#else
|
||||
// on unix, we'll log to the standard log dir
|
||||
return "/var/log/";
|
||||
// on unix, we'll log to the standard log dir
|
||||
return "/var/log/";
|
||||
#endif
|
||||
}
|
||||
|
||||
QString AppConfig::synergyProgramDir() const
|
||||
{
|
||||
// synergy binaries should be in the same dir.
|
||||
return QCoreApplication::applicationDirPath() + "/";
|
||||
// synergy binaries should be in the same dir.
|
||||
return QCoreApplication::applicationDirPath() + "/";
|
||||
}
|
||||
|
||||
void AppConfig::persistLogDir()
|
||||
{
|
||||
QDir dir = synergyLogDir();
|
||||
QDir dir = synergyLogDir();
|
||||
|
||||
// persist the log directory
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkpath(dir.path());
|
||||
}
|
||||
// persist the log directory
|
||||
if (!dir.exists())
|
||||
{
|
||||
dir.mkpath(dir.path());
|
||||
}
|
||||
}
|
||||
|
||||
const QString AppConfig::logFilenameCmd() const
|
||||
{
|
||||
QString filename = m_LogFilename;
|
||||
QString filename = m_LogFilename;
|
||||
#if defined(Q_OS_WIN)
|
||||
// wrap in quotes in case username contains spaces.
|
||||
filename = QString("\"%1\"").arg(filename);
|
||||
// wrap in quotes in case username contains spaces.
|
||||
filename = QString("\"%1\"").arg(filename);
|
||||
#endif
|
||||
return filename;
|
||||
return filename;
|
||||
}
|
||||
|
||||
QString AppConfig::logLevelText() const
|
||||
{
|
||||
return logLevelNames[logLevel()];
|
||||
return logLevelNames[logLevel()];
|
||||
}
|
||||
|
||||
ProcessMode AppConfig::processMode() const { return m_ProcessMode; }
|
||||
|
@ -140,78 +140,78 @@ bool AppConfig::autoConfig() const { return m_AutoConfig; }
|
|||
|
||||
void AppConfig::loadSettings()
|
||||
{
|
||||
m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString();
|
||||
m_Port = settings().value("port", 24800).toInt();
|
||||
m_Interface = settings().value("interface").toString();
|
||||
m_LogLevel = settings().value("logLevel", 3).toInt(); // level 3: INFO
|
||||
m_LogToFile = settings().value("logToFile", false).toBool();
|
||||
m_LogFilename = settings().value("logFilename", synergyLogDir() + "synergy.log").toString();
|
||||
m_WizardLastRun = settings().value("wizardLastRun", 0).toInt();
|
||||
m_Language = settings().value("language", QLocale::system().name()).toString();
|
||||
m_StartedBefore = settings().value("startedBefore", false).toBool();
|
||||
m_AutoConfig = settings().value("autoConfig", true).toBool();
|
||||
QVariant elevateMode = settings().value("elevateModeEnum");
|
||||
if (!elevateMode.isValid()) {
|
||||
elevateMode = settings().value ("elevateMode",
|
||||
QVariant(static_cast<int>(defaultElevateMode)));
|
||||
}
|
||||
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
||||
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
||||
m_Edition = static_cast<Edition>(settings().value("edition", kUnregistered).toInt());
|
||||
m_ActivateEmail = settings().value("activateEmail", "").toString();
|
||||
m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool();
|
||||
m_AutoHide = settings().value("autoHide", false).toBool();
|
||||
m_Serialkey = settings().value("serialKey", "").toString().trimmed();
|
||||
m_lastVersion = settings().value("lastVersion", "Unknown").toString();
|
||||
m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt();
|
||||
m_ActivationHasRun = settings().value("activationHasRun", false).toBool();
|
||||
m_ScreenName = settings().value("screenName", QHostInfo::localHostName()).toString();
|
||||
m_Port = settings().value("port", 24800).toInt();
|
||||
m_Interface = settings().value("interface").toString();
|
||||
m_LogLevel = settings().value("logLevel", 3).toInt(); // level 3: INFO
|
||||
m_LogToFile = settings().value("logToFile", false).toBool();
|
||||
m_LogFilename = settings().value("logFilename", synergyLogDir() + "synergy.log").toString();
|
||||
m_WizardLastRun = settings().value("wizardLastRun", 0).toInt();
|
||||
m_Language = settings().value("language", QLocale::system().name()).toString();
|
||||
m_StartedBefore = settings().value("startedBefore", false).toBool();
|
||||
m_AutoConfig = settings().value("autoConfig", true).toBool();
|
||||
QVariant elevateMode = settings().value("elevateModeEnum");
|
||||
if (!elevateMode.isValid()) {
|
||||
elevateMode = settings().value ("elevateMode",
|
||||
QVariant(static_cast<int>(defaultElevateMode)));
|
||||
}
|
||||
m_ElevateMode = static_cast<ElevateMode>(elevateMode.toInt());
|
||||
m_AutoConfigPrompted = settings().value("autoConfigPrompted", false).toBool();
|
||||
m_Edition = static_cast<Edition>(settings().value("edition", kUnregistered).toInt());
|
||||
m_ActivateEmail = settings().value("activateEmail", "").toString();
|
||||
m_CryptoEnabled = settings().value("cryptoEnabled", true).toBool();
|
||||
m_AutoHide = settings().value("autoHide", false).toBool();
|
||||
m_Serialkey = settings().value("serialKey", "").toString().trimmed();
|
||||
m_lastVersion = settings().value("lastVersion", "Unknown").toString();
|
||||
m_LastExpiringWarningTime = settings().value("lastExpiringWarningTime", 0).toInt();
|
||||
m_ActivationHasRun = settings().value("activationHasRun", false).toBool();
|
||||
}
|
||||
|
||||
void AppConfig::saveSettings()
|
||||
{
|
||||
settings().setValue("screenName", m_ScreenName);
|
||||
settings().setValue("port", m_Port);
|
||||
settings().setValue("interface", m_Interface);
|
||||
settings().setValue("logLevel", m_LogLevel);
|
||||
settings().setValue("logToFile", m_LogToFile);
|
||||
settings().setValue("logFilename", m_LogFilename);
|
||||
settings().setValue("wizardLastRun", kWizardVersion);
|
||||
settings().setValue("language", m_Language);
|
||||
settings().setValue("startedBefore", m_StartedBefore);
|
||||
settings().setValue("autoConfig", m_AutoConfig);
|
||||
// Refer to enum ElevateMode declaration for insight in to why this
|
||||
// flag is mapped this way
|
||||
settings().setValue("elevateMode", m_ElevateMode == ElevateAlways);
|
||||
settings().setValue("elevateModeEnum", static_cast<int>(m_ElevateMode));
|
||||
settings().setValue("autoConfigPrompted", m_AutoConfigPrompted);
|
||||
settings().setValue("edition", m_Edition);
|
||||
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
||||
settings().setValue("autoHide", m_AutoHide);
|
||||
settings().setValue("serialKey", m_Serialkey);
|
||||
settings().setValue("lastVersion", m_lastVersion);
|
||||
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
||||
settings().setValue("activationHasRun", m_ActivationHasRun);
|
||||
settings().sync();
|
||||
settings().setValue("screenName", m_ScreenName);
|
||||
settings().setValue("port", m_Port);
|
||||
settings().setValue("interface", m_Interface);
|
||||
settings().setValue("logLevel", m_LogLevel);
|
||||
settings().setValue("logToFile", m_LogToFile);
|
||||
settings().setValue("logFilename", m_LogFilename);
|
||||
settings().setValue("wizardLastRun", kWizardVersion);
|
||||
settings().setValue("language", m_Language);
|
||||
settings().setValue("startedBefore", m_StartedBefore);
|
||||
settings().setValue("autoConfig", m_AutoConfig);
|
||||
// Refer to enum ElevateMode declaration for insight in to why this
|
||||
// flag is mapped this way
|
||||
settings().setValue("elevateMode", m_ElevateMode == ElevateAlways);
|
||||
settings().setValue("elevateModeEnum", static_cast<int>(m_ElevateMode));
|
||||
settings().setValue("autoConfigPrompted", m_AutoConfigPrompted);
|
||||
settings().setValue("edition", m_Edition);
|
||||
settings().setValue("cryptoEnabled", m_CryptoEnabled);
|
||||
settings().setValue("autoHide", m_AutoHide);
|
||||
settings().setValue("serialKey", m_Serialkey);
|
||||
settings().setValue("lastVersion", m_lastVersion);
|
||||
settings().setValue("lastExpiringWarningTime", m_LastExpiringWarningTime);
|
||||
settings().setValue("activationHasRun", m_ActivationHasRun);
|
||||
settings().sync();
|
||||
}
|
||||
|
||||
bool AppConfig::activationHasRun() const
|
||||
{
|
||||
return m_ActivationHasRun;
|
||||
return m_ActivationHasRun;
|
||||
}
|
||||
|
||||
AppConfig& AppConfig::activationHasRun(bool value)
|
||||
{
|
||||
m_ActivationHasRun = value;
|
||||
return *this;
|
||||
m_ActivationHasRun = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QString AppConfig::lastVersion() const
|
||||
{
|
||||
return m_lastVersion;
|
||||
return m_lastVersion;
|
||||
}
|
||||
|
||||
void AppConfig::setLastVersion(QString version) {
|
||||
m_lastVersion = version;
|
||||
m_lastVersion = version;
|
||||
}
|
||||
|
||||
QSettings &AppConfig::settings() { return *m_pSettings; }
|
||||
|
@ -238,31 +238,31 @@ void AppConfig::setElevateMode(ElevateMode em) { m_ElevateMode = em; }
|
|||
|
||||
void AppConfig::setAutoConfig(bool autoConfig)
|
||||
{
|
||||
m_AutoConfig = autoConfig;
|
||||
m_AutoConfig = autoConfig;
|
||||
}
|
||||
|
||||
bool AppConfig::autoConfigPrompted() { return m_AutoConfigPrompted; }
|
||||
|
||||
void AppConfig::setAutoConfigPrompted(bool prompted)
|
||||
{
|
||||
m_AutoConfigPrompted = prompted;
|
||||
m_AutoConfigPrompted = prompted;
|
||||
}
|
||||
|
||||
void AppConfig::setEdition(Edition e) {
|
||||
m_Edition = e;
|
||||
m_Edition = e;
|
||||
}
|
||||
|
||||
Edition AppConfig::edition() const { return m_Edition; }
|
||||
|
||||
QString AppConfig::setSerialKey(QString serial) {
|
||||
using std::swap;
|
||||
swap (serial, m_Serialkey);
|
||||
return serial;
|
||||
using std::swap;
|
||||
swap (serial, m_Serialkey);
|
||||
return serial;
|
||||
}
|
||||
|
||||
void AppConfig::clearSerialKey()
|
||||
{
|
||||
m_Serialkey.clear();
|
||||
m_Serialkey.clear();
|
||||
}
|
||||
|
||||
QString AppConfig::serialKey() { return m_Serialkey; }
|
||||
|
@ -277,16 +277,16 @@ QString AppConfig::synergycName() const { return m_SynergycName; }
|
|||
|
||||
ElevateMode AppConfig::elevateMode()
|
||||
{
|
||||
return m_ElevateMode;
|
||||
return m_ElevateMode;
|
||||
}
|
||||
|
||||
void AppConfig::setCryptoEnabled(bool e) {
|
||||
m_CryptoEnabled = e;
|
||||
emit sslToggled(e);
|
||||
m_CryptoEnabled = e;
|
||||
emit sslToggled(e);
|
||||
}
|
||||
|
||||
bool AppConfig::getCryptoEnabled() const {
|
||||
return (edition() == kPro) && m_CryptoEnabled;
|
||||
return (edition() == kPro) && m_CryptoEnabled;
|
||||
}
|
||||
|
||||
void AppConfig::setAutoHide(bool b) { m_AutoHide = b; }
|
||||
|
|
|
@ -46,114 +46,114 @@ class QSettings;
|
|||
class SettingsDialog;
|
||||
|
||||
enum ProcessMode {
|
||||
Service,
|
||||
Desktop
|
||||
Service,
|
||||
Desktop
|
||||
};
|
||||
|
||||
class AppConfig: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
friend class SettingsDialog;
|
||||
friend class MainWindow;
|
||||
friend class SetupWizard;
|
||||
friend class SettingsDialog;
|
||||
friend class MainWindow;
|
||||
friend class SetupWizard;
|
||||
|
||||
public:
|
||||
AppConfig(QSettings* settings);
|
||||
~AppConfig();
|
||||
public:
|
||||
AppConfig(QSettings* settings);
|
||||
~AppConfig();
|
||||
|
||||
public:
|
||||
const QString& screenName() const;
|
||||
int port() const;
|
||||
const QString& networkInterface() const;
|
||||
int logLevel() const;
|
||||
bool logToFile() const;
|
||||
const QString& logFilename() const;
|
||||
const QString logFilenameCmd() const;
|
||||
QString logLevelText() const;
|
||||
ProcessMode processMode() const;
|
||||
bool wizardShouldRun() const;
|
||||
const QString& language() const;
|
||||
bool startedBefore() const;
|
||||
bool autoConfig() const;
|
||||
void setAutoConfig(bool autoConfig);
|
||||
bool autoConfigPrompted();
|
||||
void setAutoConfigPrompted(bool prompted);
|
||||
void setEdition(Edition);
|
||||
Edition edition() const;
|
||||
QString setSerialKey(QString serial);
|
||||
void clearSerialKey();
|
||||
QString serialKey();
|
||||
int lastExpiringWarningTime() const;
|
||||
void setLastExpiringWarningTime(int t);
|
||||
public:
|
||||
const QString& screenName() const;
|
||||
int port() const;
|
||||
const QString& networkInterface() const;
|
||||
int logLevel() const;
|
||||
bool logToFile() const;
|
||||
const QString& logFilename() const;
|
||||
const QString logFilenameCmd() const;
|
||||
QString logLevelText() const;
|
||||
ProcessMode processMode() const;
|
||||
bool wizardShouldRun() const;
|
||||
const QString& language() const;
|
||||
bool startedBefore() const;
|
||||
bool autoConfig() const;
|
||||
void setAutoConfig(bool autoConfig);
|
||||
bool autoConfigPrompted();
|
||||
void setAutoConfigPrompted(bool prompted);
|
||||
void setEdition(Edition);
|
||||
Edition edition() const;
|
||||
QString setSerialKey(QString serial);
|
||||
void clearSerialKey();
|
||||
QString serialKey();
|
||||
int lastExpiringWarningTime() const;
|
||||
void setLastExpiringWarningTime(int t);
|
||||
|
||||
QString synergysName() const;
|
||||
QString synergycName() const;
|
||||
QString synergyProgramDir() const;
|
||||
QString synergyLogDir() const;
|
||||
QString synergysName() const;
|
||||
QString synergycName() const;
|
||||
QString synergyProgramDir() const;
|
||||
QString synergyLogDir() const;
|
||||
|
||||
bool detectPath(const QString& name, QString& path);
|
||||
void persistLogDir();
|
||||
ElevateMode elevateMode();
|
||||
bool detectPath(const QString& name, QString& path);
|
||||
void persistLogDir();
|
||||
ElevateMode elevateMode();
|
||||
|
||||
void setCryptoEnabled(bool e);
|
||||
bool getCryptoEnabled() const;
|
||||
void setCryptoEnabled(bool e);
|
||||
bool getCryptoEnabled() const;
|
||||
|
||||
void setAutoHide(bool b);
|
||||
bool getAutoHide();
|
||||
void setAutoHide(bool b);
|
||||
bool getAutoHide();
|
||||
|
||||
bool activationHasRun() const;
|
||||
AppConfig& activationHasRun(bool value);
|
||||
bool activationHasRun() const;
|
||||
AppConfig& activationHasRun(bool value);
|
||||
|
||||
QString lastVersion() const;
|
||||
QString lastVersion() const;
|
||||
|
||||
void saveSettings();
|
||||
void setLastVersion(QString version);
|
||||
void saveSettings();
|
||||
void setLastVersion(QString version);
|
||||
|
||||
protected:
|
||||
QSettings& settings();
|
||||
void setScreenName(const QString& s);
|
||||
void setPort(int i);
|
||||
void setNetworkInterface(const QString& s);
|
||||
void setLogLevel(int i);
|
||||
void setLogToFile(bool b);
|
||||
void setLogFilename(const QString& s);
|
||||
void setWizardHasRun();
|
||||
void setLanguage(const QString language);
|
||||
void setStartedBefore(bool b);
|
||||
void setElevateMode(ElevateMode em);
|
||||
void loadSettings();
|
||||
QSettings& settings();
|
||||
void setScreenName(const QString& s);
|
||||
void setPort(int i);
|
||||
void setNetworkInterface(const QString& s);
|
||||
void setLogLevel(int i);
|
||||
void setLogToFile(bool b);
|
||||
void setLogFilename(const QString& s);
|
||||
void setWizardHasRun();
|
||||
void setLanguage(const QString language);
|
||||
void setStartedBefore(bool b);
|
||||
void setElevateMode(ElevateMode em);
|
||||
void loadSettings();
|
||||
|
||||
private:
|
||||
QSettings* m_pSettings;
|
||||
QString m_ScreenName;
|
||||
int m_Port;
|
||||
QString m_Interface;
|
||||
int m_LogLevel;
|
||||
bool m_LogToFile;
|
||||
QString m_LogFilename;
|
||||
int m_WizardLastRun;
|
||||
ProcessMode m_ProcessMode;
|
||||
QString m_Language;
|
||||
bool m_StartedBefore;
|
||||
bool m_AutoConfig;
|
||||
ElevateMode m_ElevateMode;
|
||||
bool m_AutoConfigPrompted;
|
||||
Edition m_Edition;
|
||||
QString m_ActivateEmail;
|
||||
bool m_CryptoEnabled;
|
||||
bool m_AutoHide;
|
||||
QString m_Serialkey;
|
||||
QString m_lastVersion;
|
||||
int m_LastExpiringWarningTime;
|
||||
bool m_ActivationHasRun;
|
||||
private:
|
||||
QSettings* m_pSettings;
|
||||
QString m_ScreenName;
|
||||
int m_Port;
|
||||
QString m_Interface;
|
||||
int m_LogLevel;
|
||||
bool m_LogToFile;
|
||||
QString m_LogFilename;
|
||||
int m_WizardLastRun;
|
||||
ProcessMode m_ProcessMode;
|
||||
QString m_Language;
|
||||
bool m_StartedBefore;
|
||||
bool m_AutoConfig;
|
||||
ElevateMode m_ElevateMode;
|
||||
bool m_AutoConfigPrompted;
|
||||
Edition m_Edition;
|
||||
QString m_ActivateEmail;
|
||||
bool m_CryptoEnabled;
|
||||
bool m_AutoHide;
|
||||
QString m_Serialkey;
|
||||
QString m_lastVersion;
|
||||
int m_LastExpiringWarningTime;
|
||||
bool m_ActivationHasRun;
|
||||
|
||||
static const char m_SynergysName[];
|
||||
static const char m_SynergycName[];
|
||||
static const char m_SynergyLogDir[];
|
||||
static const char m_SynergysName[];
|
||||
static const char m_SynergycName[];
|
||||
static const char m_SynergyLogDir[];
|
||||
|
||||
signals:
|
||||
void sslToggled(bool enabled);
|
||||
signals:
|
||||
void sslToggled(bool enabled);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,27 +20,27 @@
|
|||
|
||||
const char* BaseConfig::m_ModifierNames[] =
|
||||
{
|
||||
"shift",
|
||||
"ctrl",
|
||||
"alt",
|
||||
"meta",
|
||||
"super",
|
||||
"none"
|
||||
"shift",
|
||||
"ctrl",
|
||||
"alt",
|
||||
"meta",
|
||||
"super",
|
||||
"none"
|
||||
};
|
||||
|
||||
const char* BaseConfig::m_FixNames[] =
|
||||
{
|
||||
"halfDuplexCapsLock",
|
||||
"halfDuplexNumLock",
|
||||
"halfDuplexScrollLock",
|
||||
"xtestIsXineramaUnaware"
|
||||
"halfDuplexCapsLock",
|
||||
"halfDuplexNumLock",
|
||||
"halfDuplexScrollLock",
|
||||
"xtestIsXineramaUnaware"
|
||||
};
|
||||
|
||||
const char* BaseConfig::m_SwitchCornerNames[] =
|
||||
{
|
||||
"top-left",
|
||||
"top-right",
|
||||
"bottom-left",
|
||||
"bottom-right"
|
||||
"top-left",
|
||||
"top-right",
|
||||
"bottom-left",
|
||||
"bottom-right"
|
||||
};
|
||||
|
||||
|
|
|
@ -26,66 +26,66 @@
|
|||
|
||||
class BaseConfig
|
||||
{
|
||||
public:
|
||||
enum Modifier { DefaultMod = -1, Shift, Ctrl, Alt, Meta, Super, None, NumModifiers };
|
||||
enum SwitchCorner { TopLeft, TopRight, BottomLeft, BottomRight, NumSwitchCorners };
|
||||
enum Fix { CapsLock, NumLock, ScrollLock, XTest, NumFixes };
|
||||
public:
|
||||
enum Modifier { DefaultMod = -1, Shift, Ctrl, Alt, Meta, Super, None, NumModifiers };
|
||||
enum SwitchCorner { TopLeft, TopRight, BottomLeft, BottomRight, NumSwitchCorners };
|
||||
enum Fix { CapsLock, NumLock, ScrollLock, XTest, NumFixes };
|
||||
|
||||
protected:
|
||||
BaseConfig() {}
|
||||
virtual ~BaseConfig() {}
|
||||
protected:
|
||||
BaseConfig() {}
|
||||
virtual ~BaseConfig() {}
|
||||
|
||||
protected:
|
||||
template<typename T1, typename T2>
|
||||
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt)
|
||||
{
|
||||
int entries = settings.beginReadArray(arrayName + "Array");
|
||||
array.clear();
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
QVariant v = settings.value(arrayName, deflt);
|
||||
array.append(v.value<T2>());
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
protected:
|
||||
template<typename T1, typename T2>
|
||||
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt)
|
||||
{
|
||||
int entries = settings.beginReadArray(arrayName + "Array");
|
||||
array.clear();
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
QVariant v = settings.value(arrayName, deflt);
|
||||
array.append(v.value<T2>());
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt, int entries)
|
||||
{
|
||||
Q_ASSERT(array.size() >= entries);
|
||||
settings.beginReadArray(arrayName + "Array");
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
QVariant v = settings.value(arrayName, deflt);
|
||||
array[i] = v.value<T2>();
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
template<typename T1, typename T2>
|
||||
void readSettings(QSettings& settings, T1& array, const QString& arrayName, const T2& deflt, int entries)
|
||||
{
|
||||
Q_ASSERT(array.size() >= entries);
|
||||
settings.beginReadArray(arrayName + "Array");
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
QVariant v = settings.value(arrayName, deflt);
|
||||
array[i] = v.value<T2>();
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void writeSettings(QSettings& settings, const T& array, const QString& arrayName) const
|
||||
{
|
||||
settings.beginWriteArray(arrayName + "Array");
|
||||
for (int i = 0; i < array.size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue(arrayName, array[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
template<typename T>
|
||||
void writeSettings(QSettings& settings, const T& array, const QString& arrayName) const
|
||||
{
|
||||
settings.beginWriteArray(arrayName + "Array");
|
||||
for (int i = 0; i < array.size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue(arrayName, array[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
static const char* modifierName(int idx) { return m_ModifierNames[idx]; }
|
||||
static const char* fixName(int idx) { return m_FixNames[idx]; }
|
||||
static const char* switchCornerName(int idx) { return m_SwitchCornerNames[idx]; }
|
||||
public:
|
||||
static const char* modifierName(int idx) { return m_ModifierNames[idx]; }
|
||||
static const char* fixName(int idx) { return m_FixNames[idx]; }
|
||||
static const char* switchCornerName(int idx) { return m_SwitchCornerNames[idx]; }
|
||||
|
||||
private:
|
||||
static const char* m_ModifierNames[];
|
||||
static const char* m_FixNames[];
|
||||
static const char* m_SwitchCornerNames[];
|
||||
private:
|
||||
static const char* m_ModifierNames[];
|
||||
static const char* m_FixNames[];
|
||||
static const char* m_SwitchCornerNames[];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
#include "ui_CancelActivationDialog.h"
|
||||
|
||||
CancelActivationDialog::CancelActivationDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CancelActivationDialog)
|
||||
QDialog(parent),
|
||||
ui(new Ui::CancelActivationDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CancelActivationDialog::~CancelActivationDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
|
|
@ -9,14 +9,14 @@ class CancelActivationDialog;
|
|||
|
||||
class CancelActivationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CancelActivationDialog(QWidget *parent = 0);
|
||||
~CancelActivationDialog();
|
||||
|
||||
explicit CancelActivationDialog(QWidget *parent = 0);
|
||||
~CancelActivationDialog();
|
||||
|
||||
private:
|
||||
Ui::CancelActivationDialog *ui;
|
||||
Ui::CancelActivationDialog *ui;
|
||||
};
|
||||
|
||||
#endif // CANCELACTIVATIONDIALOG_H
|
||||
|
|
|
@ -21,43 +21,43 @@
|
|||
#include <stdexcept>
|
||||
|
||||
CommandProcess::CommandProcess(QString cmd, QStringList arguments, QString input) :
|
||||
m_Command(cmd),
|
||||
m_Arguments(arguments),
|
||||
m_Input(input)
|
||||
m_Command(cmd),
|
||||
m_Arguments(arguments),
|
||||
m_Input(input)
|
||||
{
|
||||
}
|
||||
|
||||
QString CommandProcess::run()
|
||||
{
|
||||
QProcess process;
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
process.start(m_Command, m_Arguments);
|
||||
bool success = process.waitForStarted();
|
||||
QProcess process;
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
process.start(m_Command, m_Arguments);
|
||||
bool success = process.waitForStarted();
|
||||
|
||||
QString output, error;
|
||||
if (success)
|
||||
{
|
||||
if (!m_Input.isEmpty()) {
|
||||
process.write(m_Input.toStdString().c_str());
|
||||
}
|
||||
QString output, error;
|
||||
if (success)
|
||||
{
|
||||
if (!m_Input.isEmpty()) {
|
||||
process.write(m_Input.toStdString().c_str());
|
||||
}
|
||||
|
||||
if (process.waitForFinished()) {
|
||||
output = process.readAllStandardOutput().trimmed();
|
||||
error = process.readAllStandardError().trimmed();
|
||||
}
|
||||
}
|
||||
if (process.waitForFinished()) {
|
||||
output = process.readAllStandardOutput().trimmed();
|
||||
error = process.readAllStandardError().trimmed();
|
||||
}
|
||||
}
|
||||
|
||||
int code = process.exitCode();
|
||||
if (!error.isEmpty() || !success || code != 0)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
QString("Code: %1\nError: %2")
|
||||
.arg(process.exitCode())
|
||||
.arg(error.isEmpty() ? "Unknown" : error)
|
||||
.toStdString());
|
||||
}
|
||||
int code = process.exitCode();
|
||||
if (!error.isEmpty() || !success || code != 0)
|
||||
{
|
||||
throw std::runtime_error(
|
||||
QString("Code: %1\nError: %2")
|
||||
.arg(process.exitCode())
|
||||
.arg(error.isEmpty() ? "Unknown" : error)
|
||||
.toStdString());
|
||||
}
|
||||
|
||||
emit finished();
|
||||
emit finished();
|
||||
|
||||
return output;
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -23,21 +23,21 @@
|
|||
|
||||
class CommandProcess : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CommandProcess(QString cmd, QStringList arguments, QString input = "");
|
||||
CommandProcess(QString cmd, QStringList arguments, QString input = "");
|
||||
|
||||
signals:
|
||||
void finished();
|
||||
void finished();
|
||||
|
||||
public slots:
|
||||
QString run();
|
||||
QString run();
|
||||
|
||||
private:
|
||||
QString m_Command;
|
||||
QStringList m_Arguments;
|
||||
QString m_Input;
|
||||
QString m_Command;
|
||||
QStringList m_Arguments;
|
||||
QString m_Input;
|
||||
};
|
||||
|
||||
#endif // COMMANDTHREAD_H
|
||||
|
|
|
@ -40,57 +40,57 @@ CoreInterface::CoreInterface()
|
|||
|
||||
QString CoreInterface::getProfileDir()
|
||||
{
|
||||
QStringList args("--get-profile-dir");
|
||||
return run(args);
|
||||
QStringList args("--get-profile-dir");
|
||||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::getInstalledDir()
|
||||
{
|
||||
QStringList args("--get-installed-dir");
|
||||
return run(args);
|
||||
QStringList args("--get-installed-dir");
|
||||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::getArch()
|
||||
{
|
||||
QStringList args("--get-arch");
|
||||
return run(args);
|
||||
QStringList args("--get-arch");
|
||||
return run(args);
|
||||
}
|
||||
|
||||
QString CoreInterface::getSerialKeyFilePath()
|
||||
{
|
||||
QString filename = getProfileDir() + QDir::separator() + kSerialKeyFilename;
|
||||
return filename;
|
||||
QString filename = getProfileDir() + QDir::separator() + kSerialKeyFilename;
|
||||
return filename;
|
||||
}
|
||||
|
||||
QString CoreInterface::notifyUpdate (QString const& fromVersion,
|
||||
QString const& toVersion,
|
||||
QString const& serialKey) {
|
||||
QStringList args("--notify-update");
|
||||
QString input(fromVersion + ":" + toVersion + ":" + serialKey);
|
||||
input.append("\n");
|
||||
return run(args, input);
|
||||
QString const& toVersion,
|
||||
QString const& serialKey) {
|
||||
QStringList args("--notify-update");
|
||||
QString input(fromVersion + ":" + toVersion + ":" + serialKey);
|
||||
input.append("\n");
|
||||
return run(args, input);
|
||||
}
|
||||
|
||||
QString CoreInterface::notifyActivation(const QString& identity)
|
||||
{
|
||||
QStringList args("--notify-activation");
|
||||
QStringList args("--notify-activation");
|
||||
|
||||
QString input(identity + ":" + hash(getFirstMacAddress()));
|
||||
QString os= getOSInformation();
|
||||
if (!os.isEmpty()) {
|
||||
input.append(":").append(os);
|
||||
}
|
||||
input.append("\n");
|
||||
QString input(identity + ":" + hash(getFirstMacAddress()));
|
||||
QString os= getOSInformation();
|
||||
if (!os.isEmpty()) {
|
||||
input.append(":").append(os);
|
||||
}
|
||||
input.append("\n");
|
||||
|
||||
return run(args, input);
|
||||
return run(args, input);
|
||||
}
|
||||
|
||||
QString CoreInterface::run(const QStringList& args, const QString& input)
|
||||
{
|
||||
QString program(
|
||||
QCoreApplication::applicationDirPath()
|
||||
+ "/" + kCoreBinary);
|
||||
QString program(
|
||||
QCoreApplication::applicationDirPath()
|
||||
+ "/" + kCoreBinary);
|
||||
|
||||
CommandProcess commandProcess(program, args, input);
|
||||
return commandProcess.run();
|
||||
CommandProcess commandProcess(program, args, input);
|
||||
return commandProcess.run();
|
||||
}
|
||||
|
|
|
@ -22,15 +22,15 @@
|
|||
class CoreInterface
|
||||
{
|
||||
public:
|
||||
CoreInterface();
|
||||
CoreInterface();
|
||||
|
||||
QString getProfileDir();
|
||||
QString getInstalledDir();
|
||||
QString getArch();
|
||||
QString getSerialKeyFilePath();
|
||||
QString notifyActivation(const QString& identity);
|
||||
QString notifyUpdate (QString const& fromVersion,
|
||||
QString const& toVersion,
|
||||
QString const& serialKey);
|
||||
QString run(const QStringList& args, const QString& input = "");
|
||||
QString getProfileDir();
|
||||
QString getInstalledDir();
|
||||
QString getArch();
|
||||
QString getSerialKeyFilePath();
|
||||
QString notifyActivation(const QString& identity);
|
||||
QString notifyUpdate (QString const& fromVersion,
|
||||
QString const& toVersion,
|
||||
QString const& serialKey);
|
||||
QString run(const QStringList& args, const QString& input = "");
|
||||
};
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
#include "DataDownloader.h"
|
||||
|
||||
DataDownloader::DataDownloader(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_IsFinished(false)
|
||||
QObject(parent),
|
||||
m_IsFinished(false)
|
||||
{
|
||||
connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(complete(QNetworkReply*)));
|
||||
connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(complete(QNetworkReply*)));
|
||||
}
|
||||
|
||||
DataDownloader::~DataDownloader()
|
||||
|
@ -31,27 +31,27 @@ DataDownloader::~DataDownloader()
|
|||
|
||||
void DataDownloader::complete(QNetworkReply* reply)
|
||||
{
|
||||
m_Data = reply->readAll();
|
||||
reply->deleteLater();
|
||||
m_Data = reply->readAll();
|
||||
reply->deleteLater();
|
||||
|
||||
if (!m_Data.isEmpty()) {
|
||||
m_IsFinished = true;
|
||||
emit isComplete();
|
||||
}
|
||||
if (!m_Data.isEmpty()) {
|
||||
m_IsFinished = true;
|
||||
emit isComplete();
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray DataDownloader::data() const
|
||||
{
|
||||
return m_Data;
|
||||
return m_Data;
|
||||
}
|
||||
|
||||
void DataDownloader::cancel()
|
||||
{
|
||||
m_pReply->abort();
|
||||
m_pReply->abort();
|
||||
}
|
||||
|
||||
void DataDownloader::download(QUrl url)
|
||||
{
|
||||
QNetworkRequest request(url);
|
||||
m_pReply = m_NetworkManager.get(request);
|
||||
QNetworkRequest request(url);
|
||||
m_pReply = m_NetworkManager.get(request);
|
||||
}
|
||||
|
|
|
@ -26,28 +26,28 @@
|
|||
|
||||
class DataDownloader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DataDownloader(QObject* parent = 0);
|
||||
virtual ~DataDownloader();
|
||||
explicit DataDownloader(QObject* parent = 0);
|
||||
virtual ~DataDownloader();
|
||||
|
||||
QByteArray data() const;
|
||||
void cancel();
|
||||
void download(QUrl url);
|
||||
bool isFinished() const { return m_IsFinished; }
|
||||
QByteArray data() const;
|
||||
void cancel();
|
||||
void download(QUrl url);
|
||||
bool isFinished() const { return m_IsFinished; }
|
||||
|
||||
signals:
|
||||
void isComplete();
|
||||
void isComplete();
|
||||
|
||||
private slots:
|
||||
void complete(QNetworkReply* reply);
|
||||
void complete(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QNetworkAccessManager m_NetworkManager;
|
||||
QByteArray m_Data;
|
||||
QNetworkReply* m_pReply;
|
||||
bool m_IsFinished;
|
||||
QNetworkAccessManager m_NetworkManager;
|
||||
QByteArray m_Data;
|
||||
QNetworkReply* m_pReply;
|
||||
bool m_IsFinished;
|
||||
};
|
||||
|
||||
#endif // DATADOWNLOADER_H
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#include "ui_FailedLoginDialog.h"
|
||||
|
||||
FailedLoginDialog::FailedLoginDialog(QWidget *parent, QString message):
|
||||
QDialog(parent),
|
||||
ui(new Ui::FailedLoginDialog)
|
||||
QDialog(parent),
|
||||
ui(new Ui::FailedLoginDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->messageLabel->setText(ui->messageLabel->text().arg(message));
|
||||
ui->setupUi(this);
|
||||
ui->messageLabel->setText(ui->messageLabel->text().arg(message));
|
||||
}
|
||||
|
||||
FailedLoginDialog::~FailedLoginDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ class FailedLoginDialog;
|
|||
|
||||
class FailedLoginDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FailedLoginDialog(QWidget *parent = 0, QString message = "");
|
||||
~FailedLoginDialog();
|
||||
|
||||
explicit FailedLoginDialog(QWidget *parent = 0, QString message = "");
|
||||
~FailedLoginDialog();
|
||||
|
||||
private:
|
||||
Ui::FailedLoginDialog *ui;
|
||||
Ui::FailedLoginDialog *ui;
|
||||
};
|
||||
|
||||
#endif // FAILEDLOGINDIALOG_H
|
||||
|
|
|
@ -29,121 +29,121 @@ static const char kTrustedClientsFilename[] = "TrustedClients.txt";
|
|||
|
||||
Fingerprint::Fingerprint(const QString& filename)
|
||||
{
|
||||
m_Filename = filename;
|
||||
m_Filename = filename;
|
||||
}
|
||||
|
||||
void Fingerprint::trust(const QString& fingerprintText, bool append)
|
||||
{
|
||||
Fingerprint::persistDirectory();
|
||||
Fingerprint::persistDirectory();
|
||||
|
||||
QIODevice::OpenMode openMode;
|
||||
if (append) {
|
||||
openMode = QIODevice::Append;
|
||||
}
|
||||
else {
|
||||
openMode = QIODevice::WriteOnly;
|
||||
}
|
||||
QIODevice::OpenMode openMode;
|
||||
if (append) {
|
||||
openMode = QIODevice::Append;
|
||||
}
|
||||
else {
|
||||
openMode = QIODevice::WriteOnly;
|
||||
}
|
||||
|
||||
QFile file(filePath());
|
||||
if (file.open(openMode))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
out << fingerprintText << "\n";
|
||||
file.close();
|
||||
}
|
||||
QFile file(filePath());
|
||||
if (file.open(openMode))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
out << fingerprintText << "\n";
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool Fingerprint::fileExists() const
|
||||
{
|
||||
QString dirName = Fingerprint::directoryPath();
|
||||
if (!QDir(dirName).exists()) {
|
||||
return false;
|
||||
}
|
||||
QString dirName = Fingerprint::directoryPath();
|
||||
if (!QDir(dirName).exists()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QFile file(filePath());
|
||||
return file.exists();
|
||||
QFile file(filePath());
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
bool Fingerprint::isTrusted(const QString& fingerprintText)
|
||||
{
|
||||
QStringList list = readList();
|
||||
foreach (QString trusted, list)
|
||||
{
|
||||
if (trusted == fingerprintText) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
QStringList list = readList();
|
||||
foreach (QString trusted, list)
|
||||
{
|
||||
if (trusted == fingerprintText) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList Fingerprint::readList(const int readTo)
|
||||
{
|
||||
QStringList list;
|
||||
QStringList list;
|
||||
|
||||
QString dirName = Fingerprint::directoryPath();
|
||||
if (!QDir(dirName).exists()) {
|
||||
return list;
|
||||
}
|
||||
QString dirName = Fingerprint::directoryPath();
|
||||
if (!QDir(dirName).exists()) {
|
||||
return list;
|
||||
}
|
||||
|
||||
QFile file(filePath());
|
||||
QFile file(filePath());
|
||||
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QTextStream in(&file);
|
||||
while (!in.atEnd())
|
||||
{
|
||||
list.append(in.readLine());
|
||||
if (list.size() == readTo) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
if (file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QTextStream in(&file);
|
||||
while (!in.atEnd())
|
||||
{
|
||||
list.append(in.readLine());
|
||||
if (list.size() == readTo) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
QString Fingerprint::readFirst()
|
||||
{
|
||||
QStringList list = readList(1);
|
||||
return list.at(0);
|
||||
QStringList list = readList(1);
|
||||
return list.at(0);
|
||||
}
|
||||
|
||||
QString Fingerprint::filePath() const
|
||||
{
|
||||
QString dir = Fingerprint::directoryPath();
|
||||
return QString("%1/%2").arg(dir).arg(m_Filename);
|
||||
QString dir = Fingerprint::directoryPath();
|
||||
return QString("%1/%2").arg(dir).arg(m_Filename);
|
||||
}
|
||||
|
||||
void Fingerprint::persistDirectory()
|
||||
{
|
||||
QDir dir(Fingerprint::directoryPath());
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
QDir dir(Fingerprint::directoryPath());
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
}
|
||||
|
||||
QString Fingerprint::directoryPath()
|
||||
{
|
||||
CoreInterface coreInterface;
|
||||
QString profileDir = coreInterface.getProfileDir();
|
||||
CoreInterface coreInterface;
|
||||
QString profileDir = coreInterface.getProfileDir();
|
||||
|
||||
return QString("%1/%2")
|
||||
.arg(profileDir)
|
||||
.arg(kDirName);
|
||||
return QString("%1/%2")
|
||||
.arg(profileDir)
|
||||
.arg(kDirName);
|
||||
}
|
||||
|
||||
Fingerprint Fingerprint::local()
|
||||
{
|
||||
return Fingerprint(kLocalFilename);
|
||||
return Fingerprint(kLocalFilename);
|
||||
}
|
||||
|
||||
Fingerprint Fingerprint::trustedServers()
|
||||
{
|
||||
return Fingerprint(kTrustedServersFilename);
|
||||
return Fingerprint(kTrustedServersFilename);
|
||||
}
|
||||
|
||||
Fingerprint Fingerprint::trustedClients()
|
||||
{
|
||||
return Fingerprint(kTrustedClientsFilename);
|
||||
return Fingerprint(kTrustedClientsFilename);
|
||||
}
|
||||
|
|
|
@ -22,25 +22,25 @@
|
|||
class Fingerprint
|
||||
{
|
||||
private:
|
||||
Fingerprint(const QString& filename);
|
||||
Fingerprint(const QString& filename);
|
||||
|
||||
public:
|
||||
void trust(const QString& fingerprintText, bool append = true);
|
||||
bool isTrusted(const QString& fingerprintText);
|
||||
QStringList readList(const int readTo = -1);
|
||||
QString readFirst();
|
||||
QString filePath() const;
|
||||
bool fileExists() const;
|
||||
void trust(const QString& fingerprintText, bool append = true);
|
||||
bool isTrusted(const QString& fingerprintText);
|
||||
QStringList readList(const int readTo = -1);
|
||||
QString readFirst();
|
||||
QString filePath() const;
|
||||
bool fileExists() const;
|
||||
|
||||
public:
|
||||
static Fingerprint local();
|
||||
static Fingerprint trustedServers();
|
||||
static Fingerprint trustedClients();
|
||||
static QString directoryPath();
|
||||
static QString localFingerprint();
|
||||
static bool localFingerprintExists();
|
||||
static void persistDirectory();
|
||||
static Fingerprint local();
|
||||
static Fingerprint trustedServers();
|
||||
static Fingerprint trustedClients();
|
||||
static QString directoryPath();
|
||||
static QString localFingerprint();
|
||||
static bool localFingerprintExists();
|
||||
static void persistDirectory();
|
||||
|
||||
private:
|
||||
QString m_Filename;
|
||||
QString m_Filename;
|
||||
};
|
||||
|
|
|
@ -21,55 +21,55 @@
|
|||
#include <QSettings>
|
||||
|
||||
Hotkey::Hotkey() :
|
||||
m_KeySequence(),
|
||||
m_Actions()
|
||||
m_KeySequence(),
|
||||
m_Actions()
|
||||
{
|
||||
}
|
||||
|
||||
QString Hotkey::text() const
|
||||
{
|
||||
QString text = keySequence().toString();
|
||||
QString text = keySequence().toString();
|
||||
|
||||
if (keySequence().isMouseButton())
|
||||
return "mousebutton(" + text + ")";
|
||||
if (keySequence().isMouseButton())
|
||||
return "mousebutton(" + text + ")";
|
||||
|
||||
return "keystroke(" + text + ")";
|
||||
return "keystroke(" + text + ")";
|
||||
}
|
||||
|
||||
void Hotkey::loadSettings(QSettings& settings)
|
||||
{
|
||||
keySequence().loadSettings(settings);
|
||||
keySequence().loadSettings(settings);
|
||||
|
||||
actions().clear();
|
||||
int num = settings.beginReadArray("actions");
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
Action a;
|
||||
a.loadSettings(settings);
|
||||
actions().append(a);
|
||||
}
|
||||
actions().clear();
|
||||
int num = settings.beginReadArray("actions");
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
Action a;
|
||||
a.loadSettings(settings);
|
||||
actions().append(a);
|
||||
}
|
||||
|
||||
settings.endArray();
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
void Hotkey::saveSettings(QSettings& settings) const
|
||||
{
|
||||
keySequence().saveSettings(settings);
|
||||
keySequence().saveSettings(settings);
|
||||
|
||||
settings.beginWriteArray("actions");
|
||||
for (int i = 0; i < actions().size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
actions()[i].saveSettings(settings);
|
||||
}
|
||||
settings.endArray();
|
||||
settings.beginWriteArray("actions");
|
||||
for (int i = 0; i < actions().size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
actions()[i].saveSettings(settings);
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey)
|
||||
{
|
||||
for (int i = 0; i < hotkey.actions().size(); i++)
|
||||
outStream << "\t" << hotkey.text() << " = " << hotkey.actions()[i] << endl;
|
||||
for (int i = 0; i < hotkey.actions().size(); i++)
|
||||
outStream << "\t" << hotkey.text() << " = " << hotkey.actions()[i] << endl;
|
||||
|
||||
return outStream;
|
||||
return outStream;
|
||||
}
|
||||
|
|
|
@ -33,30 +33,30 @@ class QSettings;
|
|||
|
||||
class Hotkey
|
||||
{
|
||||
friend class HotkeyDialog;
|
||||
friend class ServerConfigDialog;
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey);
|
||||
friend class HotkeyDialog;
|
||||
friend class ServerConfigDialog;
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey);
|
||||
|
||||
public:
|
||||
Hotkey();
|
||||
public:
|
||||
Hotkey();
|
||||
|
||||
public:
|
||||
QString text() const;
|
||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||
const ActionList& actions() const { return m_Actions; }
|
||||
public:
|
||||
QString text() const;
|
||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||
const ActionList& actions() const { return m_Actions; }
|
||||
|
||||
void loadSettings(QSettings& settings);
|
||||
void saveSettings(QSettings& settings) const;
|
||||
void loadSettings(QSettings& settings);
|
||||
void saveSettings(QSettings& settings) const;
|
||||
|
||||
protected:
|
||||
KeySequence& keySequence() { return m_KeySequence; }
|
||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||
ActionList& actions() { return m_Actions; }
|
||||
protected:
|
||||
KeySequence& keySequence() { return m_KeySequence; }
|
||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||
ActionList& actions() { return m_Actions; }
|
||||
|
||||
|
||||
private:
|
||||
KeySequence m_KeySequence;
|
||||
ActionList m_Actions;
|
||||
private:
|
||||
KeySequence m_KeySequence;
|
||||
ActionList m_Actions;
|
||||
};
|
||||
|
||||
typedef QList<Hotkey> HotkeyList;
|
||||
|
|
|
@ -22,20 +22,20 @@
|
|||
#include <QtGui>
|
||||
|
||||
HotkeyDialog::HotkeyDialog (QWidget* parent, Hotkey& hotkey) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::HotkeyDialogBase(),
|
||||
m_Hotkey(hotkey)
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::HotkeyDialogBase(),
|
||||
m_Hotkey(hotkey)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
m_pKeySequenceWidgetHotkey->setText(m_Hotkey.text());
|
||||
m_pKeySequenceWidgetHotkey->setText(m_Hotkey.text());
|
||||
}
|
||||
|
||||
void HotkeyDialog::accept()
|
||||
{
|
||||
if (!sequenceWidget()->valid())
|
||||
return;
|
||||
if (!sequenceWidget()->valid())
|
||||
return;
|
||||
|
||||
hotkey().setKeySequence(sequenceWidget()->keySequence());
|
||||
QDialog::accept();
|
||||
hotkey().setKeySequence(sequenceWidget()->keySequence());
|
||||
QDialog::accept();
|
||||
}
|
||||
|
|
|
@ -27,23 +27,23 @@
|
|||
|
||||
class HotkeyDialog : public QDialog, public Ui::HotkeyDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HotkeyDialog(QWidget* parent, Hotkey& hotkey);
|
||||
public:
|
||||
HotkeyDialog(QWidget* parent, Hotkey& hotkey);
|
||||
|
||||
public:
|
||||
const Hotkey& hotkey() const { return m_Hotkey; }
|
||||
public:
|
||||
const Hotkey& hotkey() const { return m_Hotkey; }
|
||||
|
||||
protected slots:
|
||||
void accept();
|
||||
protected slots:
|
||||
void accept();
|
||||
|
||||
protected:
|
||||
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
||||
Hotkey& hotkey() { return m_Hotkey; }
|
||||
protected:
|
||||
const KeySequenceWidget* sequenceWidget() const { return m_pKeySequenceWidgetHotkey; }
|
||||
Hotkey& hotkey() { return m_Hotkey; }
|
||||
|
||||
private:
|
||||
Hotkey& m_Hotkey;
|
||||
private:
|
||||
Hotkey& m_Hotkey;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "Ipc.h"
|
||||
|
||||
const char* kIpcMsgHello = "IHEL%1i";
|
||||
const char* kIpcMsgLogLine = "ILOG%s";
|
||||
const char* kIpcMsgCommand = "ICMD%s%1i";
|
||||
const char* kIpcMsgShutdown = "ISDN";
|
||||
const char* kIpcMsgHello = "IHEL%1i";
|
||||
const char* kIpcMsgLogLine = "ILOG%s";
|
||||
const char* kIpcMsgCommand = "ICMD%s%1i";
|
||||
const char* kIpcMsgShutdown = "ISDN";
|
||||
|
|
|
@ -24,19 +24,19 @@
|
|||
#define IPC_PORT 24801
|
||||
|
||||
enum qIpcMessageType {
|
||||
kIpcHello,
|
||||
kIpcLogLine,
|
||||
kIpcCommand,
|
||||
kIpcShutdown,
|
||||
kIpcHello,
|
||||
kIpcLogLine,
|
||||
kIpcCommand,
|
||||
kIpcShutdown,
|
||||
};
|
||||
|
||||
enum qIpcClientType {
|
||||
kIpcClientUnknown,
|
||||
kIpcClientGui,
|
||||
kIpcClientNode,
|
||||
kIpcClientUnknown,
|
||||
kIpcClientGui,
|
||||
kIpcClientNode,
|
||||
};
|
||||
|
||||
extern const char* kIpcMsgHello;
|
||||
extern const char* kIpcMsgLogLine;
|
||||
extern const char* kIpcMsgCommand;
|
||||
extern const char* kIpcMsgShutdown;
|
||||
extern const char* kIpcMsgHello;
|
||||
extern const char* kIpcMsgLogLine;
|
||||
extern const char* kIpcMsgCommand;
|
||||
extern const char* kIpcMsgShutdown;
|
||||
|
|
|
@ -29,12 +29,12 @@ IpcClient::IpcClient() :
|
|||
m_ReaderStarted(false),
|
||||
m_Enabled(false)
|
||||
{
|
||||
m_Socket = new QTcpSocket(this);
|
||||
connect(m_Socket, SIGNAL(connected()), this, SLOT(connected()));
|
||||
connect(m_Socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
|
||||
m_Socket = new QTcpSocket(this);
|
||||
connect(m_Socket, SIGNAL(connected()), this, SLOT(connected()));
|
||||
connect(m_Socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
|
||||
|
||||
m_Reader = new IpcReader(m_Socket);
|
||||
connect(m_Reader, SIGNAL(readLogLine(const QString&)), this, SLOT(handleReadLogLine(const QString&)));
|
||||
m_Reader = new IpcReader(m_Socket);
|
||||
connect(m_Reader, SIGNAL(readLogLine(const QString&)), this, SLOT(handleReadLogLine(const QString&)));
|
||||
}
|
||||
|
||||
IpcClient::~IpcClient()
|
||||
|
@ -43,104 +43,104 @@ IpcClient::~IpcClient()
|
|||
|
||||
void IpcClient::connected()
|
||||
{
|
||||
sendHello();
|
||||
infoMessage("connection established");
|
||||
sendHello();
|
||||
infoMessage("connection established");
|
||||
}
|
||||
|
||||
void IpcClient::connectToHost()
|
||||
{
|
||||
m_Enabled = true;
|
||||
m_Enabled = true;
|
||||
|
||||
infoMessage("connecting to service...");
|
||||
m_Socket->connectToHost(QHostAddress(QHostAddress::LocalHost), IPC_PORT);
|
||||
infoMessage("connecting to service...");
|
||||
m_Socket->connectToHost(QHostAddress(QHostAddress::LocalHost), IPC_PORT);
|
||||
|
||||
if (!m_ReaderStarted) {
|
||||
m_Reader->start();
|
||||
m_ReaderStarted = true;
|
||||
}
|
||||
if (!m_ReaderStarted) {
|
||||
m_Reader->start();
|
||||
m_ReaderStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IpcClient::disconnectFromHost()
|
||||
{
|
||||
infoMessage("service disconnect");
|
||||
m_Reader->stop();
|
||||
m_Socket->close();
|
||||
infoMessage("service disconnect");
|
||||
m_Reader->stop();
|
||||
m_Socket->close();
|
||||
}
|
||||
|
||||
void IpcClient::error(QAbstractSocket::SocketError error)
|
||||
{
|
||||
QString text;
|
||||
switch (error) {
|
||||
case 0: text = "connection refused"; break;
|
||||
case 1: text = "remote host closed"; break;
|
||||
default: text = QString("code=%1").arg(error); break;
|
||||
}
|
||||
QString text;
|
||||
switch (error) {
|
||||
case 0: text = "connection refused"; break;
|
||||
case 1: text = "remote host closed"; 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()
|
||||
{
|
||||
if (m_Enabled) {
|
||||
connectToHost();
|
||||
}
|
||||
if (m_Enabled) {
|
||||
connectToHost();
|
||||
}
|
||||
}
|
||||
|
||||
void IpcClient::sendHello()
|
||||
{
|
||||
QDataStream stream(m_Socket);
|
||||
stream.writeRawData(kIpcMsgHello, 4);
|
||||
QDataStream stream(m_Socket);
|
||||
stream.writeRawData(kIpcMsgHello, 4);
|
||||
|
||||
char typeBuf[1];
|
||||
typeBuf[0] = kIpcClientGui;
|
||||
stream.writeRawData(typeBuf, 1);
|
||||
char typeBuf[1];
|
||||
typeBuf[0] = kIpcClientGui;
|
||||
stream.writeRawData(typeBuf, 1);
|
||||
}
|
||||
|
||||
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();
|
||||
const char* charCommand = stdStringCommand.c_str();
|
||||
int length = strlen(charCommand);
|
||||
std::string stdStringCommand = command.toStdString();
|
||||
const char* charCommand = stdStringCommand.c_str();
|
||||
int length = strlen(charCommand);
|
||||
|
||||
char lenBuf[4];
|
||||
intToBytes(length, lenBuf, 4);
|
||||
stream.writeRawData(lenBuf, 4);
|
||||
stream.writeRawData(charCommand, length);
|
||||
char lenBuf[4];
|
||||
intToBytes(length, lenBuf, 4);
|
||||
stream.writeRawData(lenBuf, 4);
|
||||
stream.writeRawData(charCommand, length);
|
||||
|
||||
char elevateBuf[1];
|
||||
char elevateBuf[1];
|
||||
// Refer to enum ElevateMode documentation for why this flag is mapped this way
|
||||
elevateBuf[0] = (elevate == ElevateAlways) ? 1 : 0;
|
||||
stream.writeRawData(elevateBuf, 1);
|
||||
elevateBuf[0] = (elevate == ElevateAlways) ? 1 : 0;
|
||||
stream.writeRawData(elevateBuf, 1);
|
||||
}
|
||||
|
||||
void IpcClient::handleReadLogLine(const QString& text)
|
||||
{
|
||||
readLogLine(text);
|
||||
readLogLine(text);
|
||||
}
|
||||
|
||||
// TODO: qt must have a built in way of converting int to bytes.
|
||||
void IpcClient::intToBytes(int value, char *buffer, int size)
|
||||
{
|
||||
if (size == 1) {
|
||||
buffer[0] = value & 0xff;
|
||||
}
|
||||
else if (size == 2) {
|
||||
buffer[0] = (value >> 8) & 0xff;
|
||||
buffer[1] = value & 0xff;
|
||||
}
|
||||
else if (size == 4) {
|
||||
buffer[0] = (value >> 24) & 0xff;
|
||||
buffer[1] = (value >> 16) & 0xff;
|
||||
buffer[2] = (value >> 8) & 0xff;
|
||||
buffer[3] = value & 0xff;
|
||||
}
|
||||
else {
|
||||
// TODO: other sizes, if needed.
|
||||
}
|
||||
if (size == 1) {
|
||||
buffer[0] = value & 0xff;
|
||||
}
|
||||
else if (size == 2) {
|
||||
buffer[0] = (value >> 8) & 0xff;
|
||||
buffer[1] = value & 0xff;
|
||||
}
|
||||
else if (size == 4) {
|
||||
buffer[0] = (value >> 24) & 0xff;
|
||||
buffer[1] = (value >> 16) & 0xff;
|
||||
buffer[2] = (value >> 8) & 0xff;
|
||||
buffer[3] = value & 0xff;
|
||||
}
|
||||
else {
|
||||
// TODO: other sizes, if needed.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,36 +28,36 @@ class IpcReader;
|
|||
|
||||
class IpcClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IpcClient();
|
||||
virtual ~IpcClient();
|
||||
IpcClient();
|
||||
virtual ~IpcClient();
|
||||
|
||||
void sendHello();
|
||||
void sendCommand(const QString& command, ElevateMode elevate);
|
||||
void connectToHost();
|
||||
void disconnectFromHost();
|
||||
void sendHello();
|
||||
void sendCommand(const QString& command, ElevateMode elevate);
|
||||
void connectToHost();
|
||||
void disconnectFromHost();
|
||||
|
||||
public slots:
|
||||
void retryConnect();
|
||||
void retryConnect();
|
||||
|
||||
private:
|
||||
void intToBytes(int value, char* buffer, int size);
|
||||
void intToBytes(int value, char* buffer, int size);
|
||||
|
||||
private slots:
|
||||
void connected();
|
||||
void error(QAbstractSocket::SocketError error);
|
||||
void handleReadLogLine(const QString& text);
|
||||
void connected();
|
||||
void error(QAbstractSocket::SocketError error);
|
||||
void handleReadLogLine(const QString& text);
|
||||
|
||||
signals:
|
||||
void readLogLine(const QString& text);
|
||||
void infoMessage(const QString& text);
|
||||
void errorMessage(const QString& text);
|
||||
void readLogLine(const QString& text);
|
||||
void infoMessage(const QString& text);
|
||||
void errorMessage(const QString& text);
|
||||
|
||||
private:
|
||||
QTcpSocket* m_Socket;
|
||||
IpcReader* m_Reader;
|
||||
bool m_ReaderStarted;
|
||||
bool m_Enabled;
|
||||
QTcpSocket* m_Socket;
|
||||
IpcReader* m_Reader;
|
||||
bool m_ReaderStarted;
|
||||
bool m_Enabled;
|
||||
};
|
||||
|
|
|
@ -34,98 +34,98 @@ IpcReader::~IpcReader()
|
|||
|
||||
void IpcReader::start()
|
||||
{
|
||||
connect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
||||
connect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
||||
}
|
||||
|
||||
void IpcReader::stop()
|
||||
{
|
||||
disconnect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
||||
disconnect(m_Socket, SIGNAL(readyRead()), this, SLOT(read()));
|
||||
}
|
||||
|
||||
void IpcReader::read()
|
||||
{
|
||||
QMutexLocker locker(&m_Mutex);
|
||||
std::cout << "ready read" << std::endl;
|
||||
QMutexLocker locker(&m_Mutex);
|
||||
std::cout << "ready read" << std::endl;
|
||||
|
||||
while (m_Socket->bytesAvailable()) {
|
||||
std::cout << "bytes available" << std::endl;
|
||||
while (m_Socket->bytesAvailable()) {
|
||||
std::cout << "bytes available" << std::endl;
|
||||
|
||||
char codeBuf[5];
|
||||
readStream(codeBuf, 4);
|
||||
codeBuf[4] = 0;
|
||||
std::cout << "ipc read: " << codeBuf << std::endl;
|
||||
char codeBuf[5];
|
||||
readStream(codeBuf, 4);
|
||||
codeBuf[4] = 0;
|
||||
std::cout << "ipc read: " << codeBuf << std::endl;
|
||||
|
||||
if (memcmp(codeBuf, kIpcMsgLogLine, 4) == 0) {
|
||||
std::cout << "reading log line" << std::endl;
|
||||
if (memcmp(codeBuf, kIpcMsgLogLine, 4) == 0) {
|
||||
std::cout << "reading log line" << std::endl;
|
||||
|
||||
char lenBuf[4];
|
||||
readStream(lenBuf, 4);
|
||||
int len = bytesToInt(lenBuf, 4);
|
||||
char lenBuf[4];
|
||||
readStream(lenBuf, 4);
|
||||
int len = bytesToInt(lenBuf, 4);
|
||||
|
||||
char* data = new char[len];
|
||||
readStream(data, len);
|
||||
QString line = QString::fromUtf8(data, len);
|
||||
delete[] data;
|
||||
char* data = new char[len];
|
||||
readStream(data, len);
|
||||
QString line = QString::fromUtf8(data, len);
|
||||
delete[] data;
|
||||
|
||||
readLogLine(line);
|
||||
}
|
||||
else {
|
||||
std::cerr << "aborting, message invalid" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
readLogLine(line);
|
||||
}
|
||||
else {
|
||||
std::cerr << "aborting, message invalid" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "read done" << std::endl;
|
||||
std::cout << "read done" << std::endl;
|
||||
}
|
||||
|
||||
bool IpcReader::readStream(char* buffer, int length)
|
||||
{
|
||||
std::cout << "reading stream" << std::endl;
|
||||
std::cout << "reading stream" << std::endl;
|
||||
|
||||
int read = 0;
|
||||
while (read < length) {
|
||||
int ask = length - read;
|
||||
if (m_Socket->bytesAvailable() < ask) {
|
||||
std::cout << "buffer too short, waiting" << std::endl;
|
||||
m_Socket->waitForReadyRead(-1);
|
||||
}
|
||||
int read = 0;
|
||||
while (read < length) {
|
||||
int ask = length - read;
|
||||
if (m_Socket->bytesAvailable() < ask) {
|
||||
std::cout << "buffer too short, waiting" << std::endl;
|
||||
m_Socket->waitForReadyRead(-1);
|
||||
}
|
||||
|
||||
int got = m_Socket->read(buffer, ask);
|
||||
read += got;
|
||||
int got = m_Socket->read(buffer, ask);
|
||||
read += got;
|
||||
|
||||
std::cout << "> ask=" << ask << " got=" << got
|
||||
<< " read=" << read << std::endl;
|
||||
std::cout << "> ask=" << ask << " got=" << got
|
||||
<< " read=" << read << std::endl;
|
||||
|
||||
if (got == -1) {
|
||||
std::cout << "socket ended, aborting" << std::endl;
|
||||
return false;
|
||||
}
|
||||
else if (length - read > 0) {
|
||||
std::cout << "more remains, seek to " << got << std::endl;
|
||||
buffer += got;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (got == -1) {
|
||||
std::cout << "socket ended, aborting" << std::endl;
|
||||
return false;
|
||||
}
|
||||
else if (length - read > 0) {
|
||||
std::cout << "more remains, seek to " << got << std::endl;
|
||||
buffer += got;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int IpcReader::bytesToInt(const char *buffer, int size)
|
||||
{
|
||||
if (size == 1) {
|
||||
return (unsigned char)buffer[0];
|
||||
}
|
||||
else if (size == 2) {
|
||||
return
|
||||
(((unsigned char)buffer[0]) << 8) +
|
||||
(unsigned char)buffer[1];
|
||||
}
|
||||
else if (size == 4) {
|
||||
return
|
||||
(((unsigned char)buffer[0]) << 24) +
|
||||
(((unsigned char)buffer[1]) << 16) +
|
||||
(((unsigned char)buffer[2]) << 8) +
|
||||
(unsigned char)buffer[3];
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
if (size == 1) {
|
||||
return (unsigned char)buffer[0];
|
||||
}
|
||||
else if (size == 2) {
|
||||
return
|
||||
(((unsigned char)buffer[0]) << 8) +
|
||||
(unsigned char)buffer[1];
|
||||
}
|
||||
else if (size == 4) {
|
||||
return
|
||||
(((unsigned char)buffer[0]) << 24) +
|
||||
(((unsigned char)buffer[1]) << 16) +
|
||||
(((unsigned char)buffer[2]) << 8) +
|
||||
(unsigned char)buffer[3];
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,25 +25,25 @@ class QTcpSocket;
|
|||
|
||||
class IpcReader : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
IpcReader(QTcpSocket* socket);
|
||||
virtual ~IpcReader();
|
||||
void start();
|
||||
void stop();
|
||||
IpcReader(QTcpSocket* socket);
|
||||
virtual ~IpcReader();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void readLogLine(const QString& text);
|
||||
void readLogLine(const QString& text);
|
||||
|
||||
private:
|
||||
bool readStream(char* buffer, int length);
|
||||
int bytesToInt(const char* buffer, int size);
|
||||
bool readStream(char* buffer, int length);
|
||||
int bytesToInt(const char* buffer, int size);
|
||||
|
||||
private slots:
|
||||
void read();
|
||||
void read();
|
||||
|
||||
private:
|
||||
QTcpSocket* m_Socket;
|
||||
QMutex m_Mutex;
|
||||
QTcpSocket* m_Socket;
|
||||
QMutex m_Mutex;
|
||||
};
|
||||
|
|
|
@ -25,213 +25,213 @@
|
|||
// and is heavily modified for QSynergy
|
||||
static const struct
|
||||
{
|
||||
int key;
|
||||
const char* name;
|
||||
int key;
|
||||
const char* name;
|
||||
} keyname[] =
|
||||
{
|
||||
{ Qt::Key_Space, "Space" },
|
||||
{ Qt::Key_Escape, "Escape" },
|
||||
{ Qt::Key_Tab, "Tab" },
|
||||
{ Qt::Key_Backtab, "LeftTab" },
|
||||
{ Qt::Key_Backspace, "BackSpace" },
|
||||
{ Qt::Key_Return, "Return" },
|
||||
{ Qt::Key_Insert, "Insert" },
|
||||
{ Qt::Key_Delete, "Delete" },
|
||||
{ Qt::Key_Pause, "Pause" },
|
||||
{ Qt::Key_Print, "Print" },
|
||||
{ Qt::Key_SysReq, "SysReq" },
|
||||
{ Qt::Key_Home, "Home" },
|
||||
{ Qt::Key_End, "End" },
|
||||
{ Qt::Key_Left, "Left" },
|
||||
{ Qt::Key_Up, "Up" },
|
||||
{ Qt::Key_Right, "Right" },
|
||||
{ Qt::Key_Down, "Down" },
|
||||
{ Qt::Key_PageUp, "PageUp" },
|
||||
{ Qt::Key_PageDown, "PageDown" },
|
||||
{ Qt::Key_CapsLock, "CapsLock" },
|
||||
{ Qt::Key_NumLock, "NumLock" },
|
||||
{ Qt::Key_ScrollLock, "ScrollLock" },
|
||||
{ Qt::Key_Menu, "Menu" },
|
||||
{ Qt::Key_Help, "Help" },
|
||||
{ Qt::Key_Enter, "KP_Enter" },
|
||||
{ Qt::Key_Clear, "Clear" },
|
||||
{ Qt::Key_Space, "Space" },
|
||||
{ Qt::Key_Escape, "Escape" },
|
||||
{ Qt::Key_Tab, "Tab" },
|
||||
{ Qt::Key_Backtab, "LeftTab" },
|
||||
{ Qt::Key_Backspace, "BackSpace" },
|
||||
{ Qt::Key_Return, "Return" },
|
||||
{ Qt::Key_Insert, "Insert" },
|
||||
{ Qt::Key_Delete, "Delete" },
|
||||
{ Qt::Key_Pause, "Pause" },
|
||||
{ Qt::Key_Print, "Print" },
|
||||
{ Qt::Key_SysReq, "SysReq" },
|
||||
{ Qt::Key_Home, "Home" },
|
||||
{ Qt::Key_End, "End" },
|
||||
{ Qt::Key_Left, "Left" },
|
||||
{ Qt::Key_Up, "Up" },
|
||||
{ Qt::Key_Right, "Right" },
|
||||
{ Qt::Key_Down, "Down" },
|
||||
{ Qt::Key_PageUp, "PageUp" },
|
||||
{ Qt::Key_PageDown, "PageDown" },
|
||||
{ Qt::Key_CapsLock, "CapsLock" },
|
||||
{ Qt::Key_NumLock, "NumLock" },
|
||||
{ Qt::Key_ScrollLock, "ScrollLock" },
|
||||
{ Qt::Key_Menu, "Menu" },
|
||||
{ Qt::Key_Help, "Help" },
|
||||
{ Qt::Key_Enter, "KP_Enter" },
|
||||
{ Qt::Key_Clear, "Clear" },
|
||||
|
||||
{ Qt::Key_Back, "WWWBack" },
|
||||
{ Qt::Key_Forward, "WWWForward" },
|
||||
{ Qt::Key_Stop, "WWWStop" },
|
||||
{ Qt::Key_Refresh, "WWWRefresh" },
|
||||
{ Qt::Key_VolumeDown, "AudioDown" },
|
||||
{ Qt::Key_VolumeMute, "AudioMute" },
|
||||
{ Qt::Key_VolumeUp, "AudioUp" },
|
||||
{ Qt::Key_MediaPlay, "AudioPlay" },
|
||||
{ Qt::Key_MediaStop, "AudioStop" },
|
||||
{ Qt::Key_MediaPrevious,"AudioPrev" },
|
||||
{ Qt::Key_MediaNext, "AudioNext" },
|
||||
{ Qt::Key_HomePage, "WWWHome" },
|
||||
{ Qt::Key_Favorites, "WWWFavorites" },
|
||||
{ Qt::Key_Search, "WWWSearch" },
|
||||
{ Qt::Key_Standby, "Sleep" },
|
||||
{ Qt::Key_LaunchMail, "AppMail" },
|
||||
{ Qt::Key_LaunchMedia, "AppMedia" },
|
||||
{ Qt::Key_Launch0, "AppUser1" },
|
||||
{ Qt::Key_Launch1, "AppUser2" },
|
||||
{ Qt::Key_Select, "Select" },
|
||||
{ Qt::Key_Back, "WWWBack" },
|
||||
{ Qt::Key_Forward, "WWWForward" },
|
||||
{ Qt::Key_Stop, "WWWStop" },
|
||||
{ Qt::Key_Refresh, "WWWRefresh" },
|
||||
{ Qt::Key_VolumeDown, "AudioDown" },
|
||||
{ Qt::Key_VolumeMute, "AudioMute" },
|
||||
{ Qt::Key_VolumeUp, "AudioUp" },
|
||||
{ Qt::Key_MediaPlay, "AudioPlay" },
|
||||
{ Qt::Key_MediaStop, "AudioStop" },
|
||||
{ Qt::Key_MediaPrevious,"AudioPrev" },
|
||||
{ Qt::Key_MediaNext, "AudioNext" },
|
||||
{ Qt::Key_HomePage, "WWWHome" },
|
||||
{ Qt::Key_Favorites, "WWWFavorites" },
|
||||
{ Qt::Key_Search, "WWWSearch" },
|
||||
{ Qt::Key_Standby, "Sleep" },
|
||||
{ Qt::Key_LaunchMail, "AppMail" },
|
||||
{ Qt::Key_LaunchMedia, "AppMedia" },
|
||||
{ Qt::Key_Launch0, "AppUser1" },
|
||||
{ Qt::Key_Launch1, "AppUser2" },
|
||||
{ Qt::Key_Select, "Select" },
|
||||
|
||||
{ 0, 0 }
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
KeySequence::KeySequence() :
|
||||
m_Sequence(),
|
||||
m_Modifiers(0),
|
||||
m_IsValid(false)
|
||||
m_Sequence(),
|
||||
m_Modifiers(0),
|
||||
m_IsValid(false)
|
||||
{
|
||||
}
|
||||
|
||||
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 result;
|
||||
QString result;
|
||||
|
||||
for (int i = 0; i < m_Sequence.size(); i++)
|
||||
{
|
||||
result += keyToString(m_Sequence[i]);
|
||||
for (int i = 0; i < m_Sequence.size(); i++)
|
||||
{
|
||||
result += keyToString(m_Sequence[i]);
|
||||
|
||||
if (i != m_Sequence.size() - 1)
|
||||
result += "+";
|
||||
}
|
||||
if (i != m_Sequence.size() - 1)
|
||||
result += "+";
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool KeySequence::appendMouseButton(int button)
|
||||
{
|
||||
return appendKey(button, 0);
|
||||
return appendKey(button, 0);
|
||||
}
|
||||
|
||||
bool KeySequence::appendKey(int key, int modifiers)
|
||||
{
|
||||
if (m_Sequence.size() == 4)
|
||||
return true;
|
||||
if (m_Sequence.size() == 4)
|
||||
return true;
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case Qt::Key_AltGr:
|
||||
return false;
|
||||
switch(key)
|
||||
{
|
||||
case Qt::Key_AltGr:
|
||||
return false;
|
||||
|
||||
case Qt::Key_Control:
|
||||
case Qt::Key_Alt:
|
||||
case Qt::Key_Shift:
|
||||
case Qt::Key_Meta:
|
||||
case Qt::Key_Menu:
|
||||
{
|
||||
int mod = modifiers & (~m_Modifiers);
|
||||
if (mod)
|
||||
{
|
||||
m_Sequence.append(mod);
|
||||
m_Modifiers |= mod;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Control:
|
||||
case Qt::Key_Alt:
|
||||
case Qt::Key_Shift:
|
||||
case Qt::Key_Meta:
|
||||
case Qt::Key_Menu:
|
||||
{
|
||||
int mod = modifiers & (~m_Modifiers);
|
||||
if (mod)
|
||||
{
|
||||
m_Sequence.append(mod);
|
||||
m_Modifiers |= mod;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// see if we can handle this key, if not, don't accept it
|
||||
if (keyToString(key).isEmpty())
|
||||
break;
|
||||
default:
|
||||
// see if we can handle this key, if not, don't accept it
|
||||
if (keyToString(key).isEmpty())
|
||||
break;
|
||||
|
||||
m_Sequence.append(key);
|
||||
setValid(true);
|
||||
return true;
|
||||
}
|
||||
m_Sequence.append(key);
|
||||
setValid(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void KeySequence::loadSettings(QSettings& settings)
|
||||
{
|
||||
sequence().clear();
|
||||
int num = settings.beginReadArray("keys");
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
sequence().append(settings.value("key", 0).toInt());
|
||||
}
|
||||
settings.endArray();
|
||||
sequence().clear();
|
||||
int num = settings.beginReadArray("keys");
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
sequence().append(settings.value("key", 0).toInt());
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
setModifiers(0);
|
||||
setValid(true);
|
||||
setModifiers(0);
|
||||
setValid(true);
|
||||
}
|
||||
|
||||
void KeySequence::saveSettings(QSettings& settings) const
|
||||
{
|
||||
settings.beginWriteArray("keys");
|
||||
for (int i = 0; i < sequence().size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue("key", sequence()[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
settings.beginWriteArray("keys");
|
||||
for (int i = 0; i < sequence().size(); i++)
|
||||
{
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue("key", sequence()[i]);
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
QString KeySequence::keyToString(int key)
|
||||
{
|
||||
// nothing there?
|
||||
if (key == 0)
|
||||
return "";
|
||||
// nothing there?
|
||||
if (key == 0)
|
||||
return "";
|
||||
|
||||
// a hack to handle mouse buttons as if they were keys
|
||||
if (key < Qt::Key_Space)
|
||||
{
|
||||
switch(key)
|
||||
{
|
||||
case Qt::LeftButton: return "1";
|
||||
case Qt::RightButton: return "2";
|
||||
case Qt::MidButton: return "3";
|
||||
}
|
||||
// a hack to handle mouse buttons as if they were keys
|
||||
if (key < Qt::Key_Space)
|
||||
{
|
||||
switch(key)
|
||||
{
|
||||
case Qt::LeftButton: return "1";
|
||||
case Qt::RightButton: return "2";
|
||||
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?
|
||||
if (key & Qt::ShiftModifier)
|
||||
return "Shift";
|
||||
// modifiers?
|
||||
if (key & Qt::ShiftModifier)
|
||||
return "Shift";
|
||||
|
||||
if (key & Qt::ControlModifier)
|
||||
return "Control";
|
||||
if (key & Qt::ControlModifier)
|
||||
return "Control";
|
||||
|
||||
if (key & Qt::AltModifier)
|
||||
return "Alt";
|
||||
if (key & Qt::AltModifier)
|
||||
return "Alt";
|
||||
|
||||
if (key & Qt::MetaModifier)
|
||||
return "Meta";
|
||||
if (key & Qt::MetaModifier)
|
||||
return "Meta";
|
||||
|
||||
// treat key pad like normal keys (FIXME: we should have another lookup table for keypad keys instead)
|
||||
key &= ~Qt::KeypadModifier;
|
||||
// treat key pad like normal keys (FIXME: we should have another lookup table for keypad keys instead)
|
||||
key &= ~Qt::KeypadModifier;
|
||||
|
||||
// a printable 7 bit character?
|
||||
if (key < 0x80 && key != Qt::Key_Space)
|
||||
return QChar(key & 0x7f).toLower();
|
||||
// a printable 7 bit character?
|
||||
if (key < 0x80 && key != Qt::Key_Space)
|
||||
return QChar(key & 0x7f).toLower();
|
||||
|
||||
// a function key?
|
||||
if (key >= Qt::Key_F1 && key <= Qt::Key_F35)
|
||||
return QString::fromUtf8("F%1").arg(key - Qt::Key_F1 + 1);
|
||||
// a function key?
|
||||
if (key >= Qt::Key_F1 && key <= Qt::Key_F35)
|
||||
return QString::fromUtf8("F%1").arg(key - Qt::Key_F1 + 1);
|
||||
|
||||
// a special key?
|
||||
int i=0;
|
||||
while (keyname[i].name)
|
||||
{
|
||||
if (key == keyname[i].key)
|
||||
return QString::fromUtf8(keyname[i].name);
|
||||
i++;
|
||||
}
|
||||
// a special key?
|
||||
int i=0;
|
||||
while (keyname[i].name)
|
||||
{
|
||||
if (key == keyname[i].key)
|
||||
return QString::fromUtf8(keyname[i].name);
|
||||
i++;
|
||||
}
|
||||
|
||||
// representable in ucs2?
|
||||
if (key < 0x10000)
|
||||
return QString("\\u%1").arg(QChar(key).toLower().unicode(), 4, 16, QChar('0'));
|
||||
// representable in ucs2?
|
||||
if (key < 0x10000)
|
||||
return QString("\\u%1").arg(QChar(key).toLower().unicode(), 4, 16, QChar('0'));
|
||||
|
||||
// give up, synergy probably won't handle this
|
||||
return "";
|
||||
// give up, synergy probably won't handle this
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -27,31 +27,31 @@ class QSettings;
|
|||
|
||||
class KeySequence
|
||||
{
|
||||
public:
|
||||
KeySequence();
|
||||
public:
|
||||
KeySequence();
|
||||
|
||||
public:
|
||||
QString toString() const;
|
||||
bool appendKey(int modifiers, int key);
|
||||
bool appendMouseButton(int button);
|
||||
bool isMouseButton() const;
|
||||
bool valid() const { return m_IsValid; }
|
||||
int modifiers() const { return m_Modifiers; }
|
||||
void saveSettings(QSettings& settings) const;
|
||||
void loadSettings(QSettings& settings);
|
||||
const QList<int>& sequence() const { return m_Sequence; }
|
||||
public:
|
||||
QString toString() const;
|
||||
bool appendKey(int modifiers, int key);
|
||||
bool appendMouseButton(int button);
|
||||
bool isMouseButton() const;
|
||||
bool valid() const { return m_IsValid; }
|
||||
int modifiers() const { return m_Modifiers; }
|
||||
void saveSettings(QSettings& settings) const;
|
||||
void loadSettings(QSettings& settings);
|
||||
const QList<int>& sequence() const { return m_Sequence; }
|
||||
|
||||
private:
|
||||
void setValid(bool b) { m_IsValid = b; }
|
||||
void setModifiers(int i) { m_Modifiers = i; }
|
||||
QList<int>& sequence() { return m_Sequence; }
|
||||
private:
|
||||
void setValid(bool b) { m_IsValid = b; }
|
||||
void setModifiers(int i) { m_Modifiers = i; }
|
||||
QList<int>& sequence() { return m_Sequence; }
|
||||
|
||||
private:
|
||||
QList<int> m_Sequence;
|
||||
int m_Modifiers;
|
||||
bool m_IsValid;
|
||||
private:
|
||||
QList<int> m_Sequence;
|
||||
int m_Modifiers;
|
||||
bool m_IsValid;
|
||||
|
||||
static QString keyToString(int key);
|
||||
static QString keyToString(int key);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,124 +22,124 @@
|
|||
#include <QMouseEvent>
|
||||
|
||||
KeySequenceWidget::KeySequenceWidget(QWidget* parent, const KeySequence& seq) :
|
||||
QPushButton(parent),
|
||||
m_KeySequence(seq),
|
||||
m_BackupSequence(seq),
|
||||
m_Status(Stopped),
|
||||
m_MousePrefix("mousebutton("),
|
||||
m_MousePostfix(")"),
|
||||
m_KeyPrefix("keystroke("),
|
||||
m_KeyPostfix(")")
|
||||
QPushButton(parent),
|
||||
m_KeySequence(seq),
|
||||
m_BackupSequence(seq),
|
||||
m_Status(Stopped),
|
||||
m_MousePrefix("mousebutton("),
|
||||
m_MousePostfix(")"),
|
||||
m_KeyPrefix("keystroke("),
|
||||
m_KeyPostfix(")")
|
||||
{
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
updateOutput();
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
updateOutput();
|
||||
}
|
||||
|
||||
void KeySequenceWidget::setKeySequence(const KeySequence& seq)
|
||||
{
|
||||
keySequence() = seq;
|
||||
backupSequence() = seq;
|
||||
keySequence() = seq;
|
||||
backupSequence() = seq;
|
||||
|
||||
setStatus(Stopped);
|
||||
updateOutput();
|
||||
setStatus(Stopped);
|
||||
updateOutput();
|
||||
}
|
||||
|
||||
void KeySequenceWidget::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
event->accept();
|
||||
|
||||
if (status() == Stopped)
|
||||
{
|
||||
startRecording();
|
||||
return;
|
||||
}
|
||||
if (status() == Stopped)
|
||||
{
|
||||
startRecording();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_KeySequence.appendMouseButton(event->button()))
|
||||
stopRecording();
|
||||
if (m_KeySequence.appendMouseButton(event->button()))
|
||||
stopRecording();
|
||||
|
||||
updateOutput();
|
||||
updateOutput();
|
||||
}
|
||||
|
||||
void KeySequenceWidget::startRecording()
|
||||
{
|
||||
keySequence() = KeySequence();
|
||||
setDown(true);
|
||||
setFocus();
|
||||
grabKeyboard();
|
||||
setStatus(Recording);
|
||||
keySequence() = KeySequence();
|
||||
setDown(true);
|
||||
setFocus();
|
||||
grabKeyboard();
|
||||
setStatus(Recording);
|
||||
}
|
||||
|
||||
void KeySequenceWidget::stopRecording()
|
||||
{
|
||||
if (!keySequence().valid())
|
||||
{
|
||||
keySequence() = backupSequence();
|
||||
updateOutput();
|
||||
}
|
||||
if (!keySequence().valid())
|
||||
{
|
||||
keySequence() = backupSequence();
|
||||
updateOutput();
|
||||
}
|
||||
|
||||
setDown(false);
|
||||
focusNextChild();
|
||||
releaseKeyboard();
|
||||
setStatus(Stopped);
|
||||
emit keySequenceChanged();
|
||||
setDown(false);
|
||||
focusNextChild();
|
||||
releaseKeyboard();
|
||||
setStatus(Stopped);
|
||||
emit keySequenceChanged();
|
||||
}
|
||||
|
||||
bool KeySequenceWidget::event(QEvent* event)
|
||||
{
|
||||
if (status() == Recording)
|
||||
{
|
||||
switch(event->type())
|
||||
{
|
||||
case QEvent::KeyPress:
|
||||
keyPressEvent(static_cast<QKeyEvent*>(event));
|
||||
return true;
|
||||
if (status() == Recording)
|
||||
{
|
||||
switch(event->type())
|
||||
{
|
||||
case QEvent::KeyPress:
|
||||
keyPressEvent(static_cast<QKeyEvent*>(event));
|
||||
return true;
|
||||
|
||||
case QEvent::MouseButtonRelease:
|
||||
event->accept();
|
||||
return true;
|
||||
case QEvent::MouseButtonRelease:
|
||||
event->accept();
|
||||
return true;
|
||||
|
||||
case QEvent::ShortcutOverride:
|
||||
event->accept();
|
||||
return true;
|
||||
case QEvent::ShortcutOverride:
|
||||
event->accept();
|
||||
return true;
|
||||
|
||||
case QEvent::FocusOut:
|
||||
stopRecording();
|
||||
if (!valid())
|
||||
{
|
||||
keySequence() = backupSequence();
|
||||
updateOutput();
|
||||
}
|
||||
break;
|
||||
case QEvent::FocusOut:
|
||||
stopRecording();
|
||||
if (!valid())
|
||||
{
|
||||
keySequence() = backupSequence();
|
||||
updateOutput();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return QPushButton::event(event);
|
||||
return QPushButton::event(event);
|
||||
}
|
||||
|
||||
void KeySequenceWidget::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
event->accept();
|
||||
|
||||
if (status() == Stopped)
|
||||
return;
|
||||
if (status() == Stopped)
|
||||
return;
|
||||
|
||||
if (m_KeySequence.appendKey(event->key(), event->modifiers()))
|
||||
stopRecording();
|
||||
if (m_KeySequence.appendKey(event->key(), event->modifiers()))
|
||||
stopRecording();
|
||||
|
||||
updateOutput();
|
||||
updateOutput();
|
||||
}
|
||||
|
||||
void KeySequenceWidget::updateOutput()
|
||||
{
|
||||
QString s;
|
||||
QString s;
|
||||
|
||||
if (m_KeySequence.isMouseButton())
|
||||
s = mousePrefix() + m_KeySequence.toString() + mousePostfix();
|
||||
else
|
||||
s = keyPrefix() + m_KeySequence.toString() + keyPostfix();
|
||||
if (m_KeySequence.isMouseButton())
|
||||
s = mousePrefix() + m_KeySequence.toString() + mousePostfix();
|
||||
else
|
||||
s = keyPrefix() + m_KeySequence.toString() + keyPostfix();
|
||||
|
||||
setText(s);
|
||||
setText(s);
|
||||
}
|
||||
|
|
|
@ -26,55 +26,55 @@
|
|||
|
||||
class KeySequenceWidget : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KeySequenceWidget(QWidget* parent, const KeySequence& seq = KeySequence());
|
||||
public:
|
||||
KeySequenceWidget(QWidget* parent, const KeySequence& seq = KeySequence());
|
||||
|
||||
signals:
|
||||
void keySequenceChanged();
|
||||
signals:
|
||||
void keySequenceChanged();
|
||||
|
||||
public:
|
||||
const QString& mousePrefix() const { return m_MousePrefix; }
|
||||
const QString& mousePostfix() const { return m_MousePostfix; }
|
||||
const QString& keyPrefix() const { return m_KeyPrefix; }
|
||||
const QString& keyPostfix() const { return m_KeyPostfix; }
|
||||
public:
|
||||
const QString& mousePrefix() const { return m_MousePrefix; }
|
||||
const QString& mousePostfix() const { return m_MousePostfix; }
|
||||
const QString& keyPrefix() const { return m_KeyPrefix; }
|
||||
const QString& keyPostfix() const { return m_KeyPostfix; }
|
||||
|
||||
void setMousePrefix(const QString& s) { m_MousePrefix = s; }
|
||||
void setMousePostfix(const QString& s) { m_MousePostfix = s; }
|
||||
void setKeyPrefix(const QString& s) { m_KeyPrefix = s; }
|
||||
void setKeyPostfix(const QString& s) { m_KeyPostfix = s; }
|
||||
void setMousePrefix(const QString& s) { m_MousePrefix = s; }
|
||||
void setMousePostfix(const QString& s) { m_MousePostfix = s; }
|
||||
void setKeyPrefix(const QString& s) { m_KeyPrefix = s; }
|
||||
void setKeyPostfix(const QString& s) { m_KeyPostfix = s; }
|
||||
|
||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||
const KeySequence& backupSequence() const { return m_BackupSequence; }
|
||||
void setKeySequence(const KeySequence& seq);
|
||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||
const KeySequence& backupSequence() const { return m_BackupSequence; }
|
||||
void setKeySequence(const KeySequence& seq);
|
||||
|
||||
bool valid() const { return keySequence().valid(); }
|
||||
bool valid() const { return keySequence().valid(); }
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
bool event(QEvent* event);
|
||||
void appendToSequence(int key);
|
||||
void updateOutput();
|
||||
void startRecording();
|
||||
void stopRecording();
|
||||
KeySequence& keySequence() { return m_KeySequence; }
|
||||
KeySequence& backupSequence() { return m_BackupSequence; }
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
bool event(QEvent* event);
|
||||
void appendToSequence(int key);
|
||||
void updateOutput();
|
||||
void startRecording();
|
||||
void stopRecording();
|
||||
KeySequence& keySequence() { return m_KeySequence; }
|
||||
KeySequence& backupSequence() { return m_BackupSequence; }
|
||||
|
||||
private:
|
||||
enum Status { Stopped, Recording };
|
||||
void setStatus(Status s) { m_Status = s; }
|
||||
Status status() const { return m_Status; }
|
||||
private:
|
||||
enum Status { Stopped, Recording };
|
||||
void setStatus(Status s) { m_Status = s; }
|
||||
Status status() const { return m_Status; }
|
||||
|
||||
private:
|
||||
KeySequence m_KeySequence;
|
||||
KeySequence m_BackupSequence;
|
||||
Status m_Status;
|
||||
QString m_MousePrefix;
|
||||
QString m_MousePostfix;
|
||||
QString m_KeyPrefix;
|
||||
QString m_KeyPostfix;
|
||||
private:
|
||||
KeySequence m_KeySequence;
|
||||
KeySequence m_BackupSequence;
|
||||
Status m_Status;
|
||||
QString m_MousePrefix;
|
||||
QString m_MousePostfix;
|
||||
QString m_KeyPrefix;
|
||||
QString m_KeyPostfix;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,28 +26,28 @@ class AppConfig;
|
|||
|
||||
class LicenseManager: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LicenseManager(AppConfig* appConfig);
|
||||
std::pair<bool, QString> setSerialKey(SerialKey serialKey,
|
||||
bool acceptExpired = false);
|
||||
void refresh();
|
||||
Edition activeEdition() const;
|
||||
QString activeEditionName() const;
|
||||
SerialKey serialKey() const;
|
||||
void skipActivation();
|
||||
void notifyUpdate(QString fromVersion, QString toVersion);
|
||||
static QString getEditionName(Edition edition, bool trial = false);
|
||||
void notifyActivation(QString identity);
|
||||
LicenseManager(AppConfig* appConfig);
|
||||
std::pair<bool, QString> setSerialKey(SerialKey serialKey,
|
||||
bool acceptExpired = false);
|
||||
void refresh();
|
||||
Edition activeEdition() const;
|
||||
QString activeEditionName() const;
|
||||
SerialKey serialKey() const;
|
||||
void skipActivation();
|
||||
void notifyUpdate(QString fromVersion, QString toVersion);
|
||||
static QString getEditionName(Edition edition, bool trial = false);
|
||||
void notifyActivation(QString identity);
|
||||
|
||||
private:
|
||||
AppConfig* m_AppConfig;
|
||||
SerialKey m_serialKey;
|
||||
AppConfig* m_AppConfig;
|
||||
SerialKey m_serialKey;
|
||||
|
||||
signals:
|
||||
void serialKeyChanged (SerialKey) const;
|
||||
void editionChanged (Edition) const;
|
||||
void beginTrial (bool expiring) const;
|
||||
void endTrial (bool expired) const;
|
||||
void serialKeyChanged (SerialKey) const;
|
||||
void editionChanged (Edition) const;
|
||||
void beginTrial (bool expiring) 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
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
friend class QSynergyApplication;
|
||||
friend class SetupWizard;
|
||||
friend class ActivationDialog;
|
||||
friend class SettingsDialog;
|
||||
friend class QSynergyApplication;
|
||||
friend class SetupWizard;
|
||||
friend class ActivationDialog;
|
||||
friend class SettingsDialog;
|
||||
|
||||
public:
|
||||
enum qSynergyState
|
||||
{
|
||||
synergyDisconnected,
|
||||
synergyConnecting,
|
||||
synergyConnected,
|
||||
synergyTransfering
|
||||
};
|
||||
public:
|
||||
enum qSynergyState
|
||||
{
|
||||
synergyDisconnected,
|
||||
synergyConnecting,
|
||||
synergyConnected,
|
||||
synergyTransfering
|
||||
};
|
||||
|
||||
enum qSynergyType
|
||||
{
|
||||
synergyClient,
|
||||
synergyServer
|
||||
};
|
||||
enum qSynergyType
|
||||
{
|
||||
synergyClient,
|
||||
synergyServer
|
||||
};
|
||||
|
||||
enum qLevel {
|
||||
Error,
|
||||
Info
|
||||
};
|
||||
enum qLevel {
|
||||
Error,
|
||||
Info
|
||||
};
|
||||
|
||||
enum qRuningState {
|
||||
kStarted,
|
||||
kStopped
|
||||
};
|
||||
enum qRuningState {
|
||||
kStarted,
|
||||
kStopped
|
||||
};
|
||||
|
||||
public:
|
||||
MainWindow(QSettings& settings, AppConfig& appConfig,
|
||||
LicenseManager& licenseManager);
|
||||
~MainWindow();
|
||||
public:
|
||||
MainWindow(QSettings& settings, AppConfig& appConfig,
|
||||
LicenseManager& licenseManager);
|
||||
~MainWindow();
|
||||
|
||||
public:
|
||||
void setVisible(bool visible);
|
||||
int synergyType() const { return m_pGroupClient->isChecked() ? synergyClient : synergyServer; }
|
||||
int synergyState() const { return m_SynergyState; }
|
||||
QString hostname() const { return m_pLineEditHostname->text(); }
|
||||
QString configFilename();
|
||||
QString address();
|
||||
QString appPath(const QString& name);
|
||||
void open();
|
||||
void clearLog();
|
||||
VersionChecker& versionChecker() { return m_VersionChecker; }
|
||||
QString getScreenName();
|
||||
ServerConfig& serverConfig() { return m_ServerConfig; }
|
||||
void showConfigureServer(const QString& message);
|
||||
void showConfigureServer() { showConfigureServer(""); }
|
||||
void autoAddScreen(const QString name);
|
||||
void updateZeroconfService();
|
||||
void serverDetected(const QString name);
|
||||
void updateLocalFingerprint();
|
||||
LicenseManager& licenseManager() const;
|
||||
public:
|
||||
void setVisible(bool visible);
|
||||
int synergyType() const { return m_pGroupClient->isChecked() ? synergyClient : synergyServer; }
|
||||
int synergyState() const { return m_SynergyState; }
|
||||
QString hostname() const { return m_pLineEditHostname->text(); }
|
||||
QString configFilename();
|
||||
QString address();
|
||||
QString appPath(const QString& name);
|
||||
void open();
|
||||
void clearLog();
|
||||
VersionChecker& versionChecker() { return m_VersionChecker; }
|
||||
QString getScreenName();
|
||||
ServerConfig& serverConfig() { return m_ServerConfig; }
|
||||
void showConfigureServer(const QString& message);
|
||||
void showConfigureServer() { showConfigureServer(""); }
|
||||
void autoAddScreen(const QString name);
|
||||
void updateZeroconfService();
|
||||
void serverDetected(const QString name);
|
||||
void updateLocalFingerprint();
|
||||
LicenseManager& licenseManager() const;
|
||||
|
||||
int raiseActivationDialog();
|
||||
int raiseActivationDialog();
|
||||
|
||||
public slots:
|
||||
void setEdition(Edition edition);
|
||||
void beginTrial(bool isExpiring);
|
||||
void endTrial(bool isExpired);
|
||||
void appendLogRaw(const QString& text);
|
||||
void appendLogInfo(const QString& text);
|
||||
void appendLogDebug(const QString& text);
|
||||
void appendLogError(const QString& text);
|
||||
void startSynergy();
|
||||
void setEdition(Edition edition);
|
||||
void beginTrial(bool isExpiring);
|
||||
void endTrial(bool isExpired);
|
||||
void appendLogRaw(const QString& text);
|
||||
void appendLogInfo(const QString& text);
|
||||
void appendLogDebug(const QString& text);
|
||||
void appendLogError(const QString& text);
|
||||
void startSynergy();
|
||||
|
||||
protected slots:
|
||||
void sslToggled(bool enabled);
|
||||
void on_m_pGroupClient_toggled(bool on);
|
||||
void on_m_pGroupServer_toggled(bool on);
|
||||
bool on_m_pButtonBrowseConfigFile_clicked();
|
||||
void on_m_pButtonConfigureServer_clicked();
|
||||
bool on_m_pActionSave_triggered();
|
||||
void on_m_pActionAbout_triggered();
|
||||
void on_m_pActionSettings_triggered();
|
||||
void on_m_pActivate_triggered();
|
||||
void synergyFinished(int exitCode, QProcess::ExitStatus);
|
||||
void trayActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
void stopSynergy();
|
||||
void logOutput();
|
||||
void logError();
|
||||
void updateFound(const QString& version);
|
||||
void bonjourInstallFinished();
|
||||
protected slots:
|
||||
void sslToggled(bool enabled);
|
||||
void on_m_pGroupClient_toggled(bool on);
|
||||
void on_m_pGroupServer_toggled(bool on);
|
||||
bool on_m_pButtonBrowseConfigFile_clicked();
|
||||
void on_m_pButtonConfigureServer_clicked();
|
||||
bool on_m_pActionSave_triggered();
|
||||
void on_m_pActionAbout_triggered();
|
||||
void on_m_pActionSettings_triggered();
|
||||
void on_m_pActivate_triggered();
|
||||
void synergyFinished(int exitCode, QProcess::ExitStatus);
|
||||
void trayActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
void stopSynergy();
|
||||
void logOutput();
|
||||
void logError();
|
||||
void updateFound(const QString& version);
|
||||
void bonjourInstallFinished();
|
||||
|
||||
protected:
|
||||
QSettings& settings() { return m_Settings; }
|
||||
AppConfig& appConfig() { return *m_AppConfig; }
|
||||
QProcess* synergyProcess() { return m_pSynergy; }
|
||||
void setSynergyProcess(QProcess* p) { m_pSynergy = p; }
|
||||
void initConnections();
|
||||
void createMenuBar();
|
||||
void createStatusBar();
|
||||
void createTrayIcon();
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void setIcon(qSynergyState state);
|
||||
void setSynergyState(qSynergyState state);
|
||||
bool checkForApp(int which, QString& app);
|
||||
bool clientArgs(QStringList& args, QString& app);
|
||||
bool serverArgs(QStringList& args, QString& app);
|
||||
void setStatus(const QString& status);
|
||||
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
||||
void onModeChanged(bool startDesktop, bool applyService);
|
||||
void updateFromLogLine(const QString& line);
|
||||
QString getIPAddresses();
|
||||
void stopService();
|
||||
void stopDesktop();
|
||||
void changeEvent(QEvent* event);
|
||||
void retranslateMenuBar();
|
||||
protected:
|
||||
QSettings& settings() { return m_Settings; }
|
||||
AppConfig& appConfig() { return *m_AppConfig; }
|
||||
QProcess* synergyProcess() { return m_pSynergy; }
|
||||
void setSynergyProcess(QProcess* p) { m_pSynergy = p; }
|
||||
void initConnections();
|
||||
void createMenuBar();
|
||||
void createStatusBar();
|
||||
void createTrayIcon();
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void setIcon(qSynergyState state);
|
||||
void setSynergyState(qSynergyState state);
|
||||
bool checkForApp(int which, QString& app);
|
||||
bool clientArgs(QStringList& args, QString& app);
|
||||
bool serverArgs(QStringList& args, QString& app);
|
||||
void setStatus(const QString& status);
|
||||
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
||||
void onModeChanged(bool startDesktop, bool applyService);
|
||||
void updateFromLogLine(const QString& line);
|
||||
QString getIPAddresses();
|
||||
void stopService();
|
||||
void stopDesktop();
|
||||
void changeEvent(QEvent* event);
|
||||
void retranslateMenuBar();
|
||||
#if defined(Q_OS_WIN)
|
||||
bool isServiceRunning(QString name);
|
||||
bool isServiceRunning(QString name);
|
||||
#else
|
||||
bool isServiceRunning();
|
||||
bool isServiceRunning();
|
||||
#endif
|
||||
bool isBonjourRunning();
|
||||
void downloadBonjour();
|
||||
void promptAutoConfig();
|
||||
QString getProfileRootForArg();
|
||||
void checkConnected(const QString& line);
|
||||
void checkLicense(const QString& line);
|
||||
void checkFingerprint(const QString& line);
|
||||
bool autoHide();
|
||||
QString getTimeStamp();
|
||||
void restartSynergy();
|
||||
void proofreadInfo();
|
||||
bool isBonjourRunning();
|
||||
void downloadBonjour();
|
||||
void promptAutoConfig();
|
||||
QString getProfileRootForArg();
|
||||
void checkConnected(const QString& line);
|
||||
void checkLicense(const QString& line);
|
||||
void checkFingerprint(const QString& line);
|
||||
bool autoHide();
|
||||
QString getTimeStamp();
|
||||
void restartSynergy();
|
||||
void proofreadInfo();
|
||||
|
||||
void showEvent (QShowEvent*);
|
||||
void showEvent (QShowEvent*);
|
||||
|
||||
private:
|
||||
QSettings& m_Settings;
|
||||
AppConfig* m_AppConfig;
|
||||
LicenseManager* m_LicenseManager;
|
||||
QProcess* m_pSynergy;
|
||||
int m_SynergyState;
|
||||
ServerConfig m_ServerConfig;
|
||||
QTemporaryFile* m_pTempConfigFile;
|
||||
QSystemTrayIcon* m_pTrayIcon;
|
||||
QMenu* m_pTrayIconMenu;
|
||||
bool m_AlreadyHidden;
|
||||
VersionChecker m_VersionChecker;
|
||||
IpcClient m_IpcClient;
|
||||
QMenuBar* m_pMenuBar;
|
||||
QMenu* m_pMenuFile;
|
||||
QMenu* m_pMenuEdit;
|
||||
QMenu* m_pMenuWindow;
|
||||
QMenu* m_pMenuHelp;
|
||||
ZeroconfService* m_pZeroconfService;
|
||||
DataDownloader* m_pDataDownloader;
|
||||
QMessageBox* m_DownloadMessageBox;
|
||||
QAbstractButton* m_pCancelButton;
|
||||
QMutex m_UpdateZeroconfMutex;
|
||||
bool m_SuppressAutoConfigWarning;
|
||||
CommandProcess* m_BonjourInstall;
|
||||
bool m_SuppressEmptyServerWarning;
|
||||
qRuningState m_ExpectedRunningState;
|
||||
QMutex m_StopDesktopMutex;
|
||||
SslCertificate* m_pSslCertificate;
|
||||
bool m_ActivationDialogRunning;
|
||||
QStringList m_PendingClientNames;
|
||||
private:
|
||||
QSettings& m_Settings;
|
||||
AppConfig* m_AppConfig;
|
||||
LicenseManager* m_LicenseManager;
|
||||
QProcess* m_pSynergy;
|
||||
int m_SynergyState;
|
||||
ServerConfig m_ServerConfig;
|
||||
QTemporaryFile* m_pTempConfigFile;
|
||||
QSystemTrayIcon* m_pTrayIcon;
|
||||
QMenu* m_pTrayIconMenu;
|
||||
bool m_AlreadyHidden;
|
||||
VersionChecker m_VersionChecker;
|
||||
IpcClient m_IpcClient;
|
||||
QMenuBar* m_pMenuBar;
|
||||
QMenu* m_pMenuFile;
|
||||
QMenu* m_pMenuEdit;
|
||||
QMenu* m_pMenuWindow;
|
||||
QMenu* m_pMenuHelp;
|
||||
ZeroconfService* m_pZeroconfService;
|
||||
DataDownloader* m_pDataDownloader;
|
||||
QMessageBox* m_DownloadMessageBox;
|
||||
QAbstractButton* m_pCancelButton;
|
||||
QMutex m_UpdateZeroconfMutex;
|
||||
bool m_SuppressAutoConfigWarning;
|
||||
CommandProcess* m_BonjourInstall;
|
||||
bool m_SuppressEmptyServerWarning;
|
||||
qRuningState m_ExpectedRunningState;
|
||||
QMutex m_StopDesktopMutex;
|
||||
SslCertificate* m_pSslCertificate;
|
||||
bool m_ActivationDialogRunning;
|
||||
QStringList m_PendingClientNames;
|
||||
|
||||
private slots:
|
||||
void on_m_pCheckBoxAutoConfig_toggled(bool checked);
|
||||
void on_m_pComboServerList_currentIndexChanged(QString );
|
||||
void on_m_pButtonApply_clicked();
|
||||
void installBonjour();
|
||||
void on_windowShown();
|
||||
void on_m_pCheckBoxAutoConfig_toggled(bool checked);
|
||||
void on_m_pComboServerList_currentIndexChanged(QString );
|
||||
void on_m_pButtonApply_clicked();
|
||||
void installBonjour();
|
||||
void on_windowShown();
|
||||
|
||||
signals:
|
||||
void windowShown();
|
||||
void windowShown();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,26 +23,26 @@
|
|||
#include <QtGui>
|
||||
|
||||
NewScreenWidget::NewScreenWidget(QWidget* parent) :
|
||||
QLabel(parent)
|
||||
QLabel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void NewScreenWidget::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
Screen newScreen(tr("Unnamed"));
|
||||
Screen newScreen(tr("Unnamed"));
|
||||
|
||||
QByteArray itemData;
|
||||
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
||||
dataStream << -1 << -1 << newScreen;
|
||||
QByteArray itemData;
|
||||
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
|
||||
dataStream << -1 << -1 << newScreen;
|
||||
|
||||
QMimeData* pMimeData = new QMimeData;
|
||||
pMimeData->setData(ScreenSetupModel::mimeType(), itemData);
|
||||
QMimeData* pMimeData = new QMimeData;
|
||||
pMimeData->setData(ScreenSetupModel::mimeType(), itemData);
|
||||
|
||||
QDrag* pDrag = new QDrag(this);
|
||||
pDrag->setMimeData(pMimeData);
|
||||
pDrag->setPixmap(*pixmap());
|
||||
pDrag->setHotSpot(event->pos());
|
||||
QDrag* pDrag = new QDrag(this);
|
||||
pDrag->setMimeData(pMimeData);
|
||||
pDrag->setPixmap(*pixmap());
|
||||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NewScreenWidget(QWidget* parent);
|
||||
public:
|
||||
NewScreenWidget(QWidget* parent);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
#pragma once
|
||||
|
||||
enum qProcessorArch {
|
||||
kProcessorArchWin32,
|
||||
kProcessorArchWin64,
|
||||
kProcessorArchMac32,
|
||||
kProcessorArchMac64,
|
||||
kProcessorArchLinux32,
|
||||
kProcessorArchLinux64,
|
||||
kProcessorArchUnknown
|
||||
kProcessorArchWin32,
|
||||
kProcessorArchWin64,
|
||||
kProcessorArchMac32,
|
||||
kProcessorArchMac64,
|
||||
kProcessorArchLinux32,
|
||||
kProcessorArchLinux64,
|
||||
kProcessorArchUnknown
|
||||
};
|
||||
|
|
|
@ -25,48 +25,48 @@
|
|||
QSynergyApplication* QSynergyApplication::s_Instance = NULL;
|
||||
|
||||
QSynergyApplication::QSynergyApplication(int& argc, char** argv) :
|
||||
QApplication(argc, argv),
|
||||
m_Translator(NULL)
|
||||
QApplication(argc, argv),
|
||||
m_Translator(NULL)
|
||||
{
|
||||
s_Instance = this;
|
||||
s_Instance = this;
|
||||
}
|
||||
|
||||
QSynergyApplication::~QSynergyApplication()
|
||||
{
|
||||
delete m_Translator;
|
||||
delete m_Translator;
|
||||
}
|
||||
|
||||
void QSynergyApplication::commitData(QSessionManager&)
|
||||
{
|
||||
foreach(QWidget* widget, topLevelWidgets())
|
||||
{
|
||||
MainWindow* mainWindow = qobject_cast<MainWindow*>(widget);
|
||||
if (mainWindow)
|
||||
mainWindow->saveSettings();
|
||||
}
|
||||
foreach(QWidget* widget, topLevelWidgets())
|
||||
{
|
||||
MainWindow* mainWindow = qobject_cast<MainWindow*>(widget);
|
||||
if (mainWindow)
|
||||
mainWindow->saveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
QSynergyApplication* QSynergyApplication::getInstance()
|
||||
{
|
||||
return s_Instance;
|
||||
return s_Instance;
|
||||
}
|
||||
|
||||
void QSynergyApplication::switchTranslator(QString lang)
|
||||
{
|
||||
if (m_Translator != NULL)
|
||||
{
|
||||
removeTranslator(m_Translator);
|
||||
delete m_Translator;
|
||||
}
|
||||
if (m_Translator != NULL)
|
||||
{
|
||||
removeTranslator(m_Translator);
|
||||
delete m_Translator;
|
||||
}
|
||||
|
||||
QResource locale(":/res/lang/gui_" + lang + ".qm");
|
||||
m_Translator = new QTranslator();
|
||||
m_Translator->load(locale.data(), locale.size());
|
||||
installTranslator(m_Translator);
|
||||
QResource locale(":/res/lang/gui_" + lang + ".qm");
|
||||
m_Translator = new QTranslator();
|
||||
m_Translator->load(locale.data(), locale.size());
|
||||
installTranslator(m_Translator);
|
||||
}
|
||||
|
||||
void QSynergyApplication::setTranslator(QTranslator* translator)
|
||||
{
|
||||
m_Translator = translator;
|
||||
installTranslator(m_Translator);
|
||||
m_Translator = translator;
|
||||
installTranslator(m_Translator);
|
||||
}
|
||||
|
|
|
@ -26,21 +26,21 @@ class QSessionManager;
|
|||
|
||||
class QSynergyApplication : public QApplication
|
||||
{
|
||||
public:
|
||||
QSynergyApplication(int& argc, char** argv);
|
||||
~QSynergyApplication();
|
||||
public:
|
||||
QSynergyApplication(int& argc, char** argv);
|
||||
~QSynergyApplication();
|
||||
|
||||
public:
|
||||
void commitData(QSessionManager& manager);
|
||||
void switchTranslator(QString lang);
|
||||
void setTranslator(QTranslator* translator);
|
||||
public:
|
||||
void commitData(QSessionManager& manager);
|
||||
void switchTranslator(QString lang);
|
||||
void setTranslator(QTranslator* translator);
|
||||
|
||||
static QSynergyApplication* getInstance();
|
||||
static QSynergyApplication* getInstance();
|
||||
|
||||
private:
|
||||
QTranslator* m_Translator;
|
||||
private:
|
||||
QTranslator* m_Translator;
|
||||
|
||||
static QSynergyApplication* s_Instance;
|
||||
static QSynergyApplication* s_Instance;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,85 +32,85 @@
|
|||
|
||||
void setIndexFromItemData(QComboBox* comboBox, const QVariant& itemData)
|
||||
{
|
||||
for (int i = 0; i < comboBox->count(); ++i)
|
||||
{
|
||||
if (comboBox->itemData(i) == itemData)
|
||||
{
|
||||
comboBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < comboBox->count(); ++i)
|
||||
{
|
||||
if (comboBox->itemData(i) == itemData)
|
||||
{
|
||||
comboBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString hash(const QString& string)
|
||||
{
|
||||
QByteArray data = string.toUtf8();
|
||||
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5);
|
||||
return hash.toHex();
|
||||
QByteArray data = string.toUtf8();
|
||||
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5);
|
||||
return hash.toHex();
|
||||
}
|
||||
|
||||
QString getFirstMacAddress()
|
||||
{
|
||||
QString mac;
|
||||
foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces())
|
||||
{
|
||||
mac = interface.hardwareAddress();
|
||||
if (mac.size() != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mac;
|
||||
QString mac;
|
||||
foreach (const QNetworkInterface &interface, QNetworkInterface::allInterfaces())
|
||||
{
|
||||
mac = interface.hardwareAddress();
|
||||
if (mac.size() != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mac;
|
||||
}
|
||||
|
||||
qProcessorArch getProcessorArch()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetNativeSystemInfo(&systemInfo);
|
||||
SYSTEM_INFO systemInfo;
|
||||
GetNativeSystemInfo(&systemInfo);
|
||||
|
||||
switch (systemInfo.wProcessorArchitecture) {
|
||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||
return kProcessorArchWin32;
|
||||
case PROCESSOR_ARCHITECTURE_IA64:
|
||||
return kProcessorArchWin64;
|
||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||
return kProcessorArchWin64;
|
||||
default:
|
||||
return kProcessorArchUnknown;
|
||||
}
|
||||
switch (systemInfo.wProcessorArchitecture) {
|
||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||
return kProcessorArchWin32;
|
||||
case PROCESSOR_ARCHITECTURE_IA64:
|
||||
return kProcessorArchWin64;
|
||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||
return kProcessorArchWin64;
|
||||
default:
|
||||
return kProcessorArchUnknown;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#ifdef __i386__
|
||||
return kProcessorArchLinux32;
|
||||
return kProcessorArchLinux32;
|
||||
#else
|
||||
return kProcessorArchLinux64;
|
||||
return kProcessorArchLinux64;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return kProcessorArchUnknown;
|
||||
return kProcessorArchUnknown;
|
||||
}
|
||||
|
||||
QString getOSInformation()
|
||||
{
|
||||
QString result;
|
||||
QString result;
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
result = "Linux";
|
||||
try {
|
||||
QStringList arguments;
|
||||
arguments.append("/etc/os-release");
|
||||
CommandProcess cp("/bin/cat", arguments);
|
||||
QString output = cp.run();
|
||||
result = "Linux";
|
||||
try {
|
||||
QStringList arguments;
|
||||
arguments.append("/etc/os-release");
|
||||
CommandProcess cp("/bin/cat", arguments);
|
||||
QString output = cp.run();
|
||||
|
||||
QRegExp resultRegex(".*PRETTY_NAME=\"([^\"]+)\".*");
|
||||
if (resultRegex.exactMatch(output)) {
|
||||
result = resultRegex.cap(1);
|
||||
}
|
||||
} catch (...) {
|
||||
}
|
||||
QRegExp resultRegex(".*PRETTY_NAME=\"([^\"]+)\".*");
|
||||
if (resultRegex.exactMatch(output)) {
|
||||
result = resultRegex.cap(1);
|
||||
}
|
||||
} catch (...) {
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -22,126 +22,126 @@
|
|||
#include <QtGui>
|
||||
|
||||
Screen::Screen() :
|
||||
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
||||
m_Swapped(false)
|
||||
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
||||
m_Swapped(false)
|
||||
{
|
||||
init();
|
||||
init();
|
||||
}
|
||||
|
||||
Screen::Screen(const QString& name) :
|
||||
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
||||
m_Swapped(false)
|
||||
m_Pixmap(QPixmap(":res/icons/64x64/video-display.png")),
|
||||
m_Swapped(false)
|
||||
{
|
||||
init();
|
||||
setName(name);
|
||||
init();
|
||||
setName(name);
|
||||
}
|
||||
|
||||
void Screen::init()
|
||||
{
|
||||
name().clear();
|
||||
aliases().clear();
|
||||
modifiers().clear();
|
||||
switchCorners().clear();
|
||||
fixes().clear();
|
||||
setSwitchCornerSize(0);
|
||||
name().clear();
|
||||
aliases().clear();
|
||||
modifiers().clear();
|
||||
switchCorners().clear();
|
||||
fixes().clear();
|
||||
setSwitchCornerSize(0);
|
||||
|
||||
// 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.
|
||||
for (int i = 0; i < NumModifiers; i++)
|
||||
modifiers() << i;
|
||||
// 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.
|
||||
for (int i = 0; i < NumModifiers; i++)
|
||||
modifiers() << i;
|
||||
|
||||
for (int i = 0; i < NumSwitchCorners; i++)
|
||||
switchCorners() << false;
|
||||
for (int i = 0; i < NumSwitchCorners; i++)
|
||||
switchCorners() << false;
|
||||
|
||||
for (int i = 0; i < NumFixes; i++)
|
||||
fixes() << false;
|
||||
for (int i = 0; i < NumFixes; i++)
|
||||
fixes() << false;
|
||||
}
|
||||
|
||||
void Screen::loadSettings(QSettings& settings)
|
||||
{
|
||||
setName(settings.value("name").toString());
|
||||
setName(settings.value("name").toString());
|
||||
|
||||
if (name().isEmpty())
|
||||
return;
|
||||
if (name().isEmpty())
|
||||
return;
|
||||
|
||||
setSwitchCornerSize(settings.value("switchCornerSize").toInt());
|
||||
setSwitchCornerSize(settings.value("switchCornerSize").toInt());
|
||||
|
||||
readSettings(settings, aliases(), "alias", QString(""));
|
||||
readSettings(settings, modifiers(), "modifier", static_cast<int>(DefaultMod), NumModifiers);
|
||||
readSettings(settings, switchCorners(), "switchCorner", false, NumSwitchCorners);
|
||||
readSettings(settings, fixes(), "fix", false, NumFixes);
|
||||
readSettings(settings, aliases(), "alias", QString(""));
|
||||
readSettings(settings, modifiers(), "modifier", static_cast<int>(DefaultMod), NumModifiers);
|
||||
readSettings(settings, switchCorners(), "switchCorner", false, NumSwitchCorners);
|
||||
readSettings(settings, fixes(), "fix", false, NumFixes);
|
||||
}
|
||||
|
||||
void Screen::saveSettings(QSettings& settings) const
|
||||
{
|
||||
settings.setValue("name", name());
|
||||
settings.setValue("name", name());
|
||||
|
||||
if (name().isEmpty())
|
||||
return;
|
||||
if (name().isEmpty())
|
||||
return;
|
||||
|
||||
settings.setValue("switchCornerSize", switchCornerSize());
|
||||
settings.setValue("switchCornerSize", switchCornerSize());
|
||||
|
||||
writeSettings(settings, aliases(), "alias");
|
||||
writeSettings(settings, modifiers(), "modifier");
|
||||
writeSettings(settings, switchCorners(), "switchCorner");
|
||||
writeSettings(settings, fixes(), "fix");
|
||||
writeSettings(settings, aliases(), "alias");
|
||||
writeSettings(settings, modifiers(), "modifier");
|
||||
writeSettings(settings, switchCorners(), "switchCorner");
|
||||
writeSettings(settings, fixes(), "fix");
|
||||
}
|
||||
|
||||
QTextStream& Screen::writeScreensSection(QTextStream& outStream) const
|
||||
{
|
||||
outStream << "\t" << name() << ":" << endl;
|
||||
outStream << "\t" << name() << ":" << endl;
|
||||
|
||||
for (int i = 0; i < modifiers().size(); i++)
|
||||
if (modifier(i) != i)
|
||||
outStream << "\t\t" << modifierName(i) << " = " << modifierName(modifier(i)) << endl;
|
||||
for (int i = 0; i < modifiers().size(); i++)
|
||||
if (modifier(i) != i)
|
||||
outStream << "\t\t" << modifierName(i) << " = " << modifierName(modifier(i)) << endl;
|
||||
|
||||
for (int i = 0; i < fixes().size(); i++)
|
||||
outStream << "\t\t" << fixName(i) << " = " << (fixes()[i] ? "true" : "false") << endl;
|
||||
for (int i = 0; i < fixes().size(); i++)
|
||||
outStream << "\t\t" << fixName(i) << " = " << (fixes()[i] ? "true" : "false") << endl;
|
||||
|
||||
outStream << "\t\t" << "switchCorners = none ";
|
||||
for (int i = 0; i < switchCorners().size(); i++)
|
||||
if (switchCorners()[i])
|
||||
outStream << "+" << switchCornerName(i) << " ";
|
||||
outStream << endl;
|
||||
outStream << "\t\t" << "switchCorners = none ";
|
||||
for (int i = 0; i < switchCorners().size(); i++)
|
||||
if (switchCorners()[i])
|
||||
outStream << "+" << switchCornerName(i) << " ";
|
||||
outStream << endl;
|
||||
|
||||
outStream << "\t\t" << "switchCornerSize = " << switchCornerSize() << endl;
|
||||
outStream << "\t\t" << "switchCornerSize = " << switchCornerSize() << endl;
|
||||
|
||||
return outStream;
|
||||
return outStream;
|
||||
}
|
||||
|
||||
QTextStream& Screen::writeAliasesSection(QTextStream& outStream) const
|
||||
{
|
||||
if (!aliases().isEmpty())
|
||||
{
|
||||
outStream << "\t" << name() << ":" << endl;
|
||||
if (!aliases().isEmpty())
|
||||
{
|
||||
outStream << "\t" << name() << ":" << endl;
|
||||
|
||||
foreach (const QString& alias, aliases())
|
||||
outStream << "\t\t" << alias << endl;
|
||||
}
|
||||
foreach (const QString& alias, aliases())
|
||||
outStream << "\t\t" << alias << endl;
|
||||
}
|
||||
|
||||
return outStream;
|
||||
return outStream;
|
||||
}
|
||||
|
||||
QDataStream& operator<<(QDataStream& outStream, const Screen& screen)
|
||||
{
|
||||
return outStream
|
||||
<< screen.name()
|
||||
<< screen.switchCornerSize()
|
||||
<< screen.aliases()
|
||||
<< screen.modifiers()
|
||||
<< screen.switchCorners()
|
||||
<< screen.fixes()
|
||||
;
|
||||
return outStream
|
||||
<< screen.name()
|
||||
<< screen.switchCornerSize()
|
||||
<< screen.aliases()
|
||||
<< screen.modifiers()
|
||||
<< screen.switchCorners()
|
||||
<< screen.fixes()
|
||||
;
|
||||
}
|
||||
|
||||
QDataStream& operator>>(QDataStream& inStream, Screen& screen)
|
||||
{
|
||||
return inStream
|
||||
>> screen.m_Name
|
||||
>> screen.m_SwitchCornerSize
|
||||
>> screen.m_Aliases
|
||||
>> screen.m_Modifiers
|
||||
>> screen.m_SwitchCorners
|
||||
>> screen.m_Fixes
|
||||
;
|
||||
return inStream
|
||||
>> screen.m_Name
|
||||
>> screen.m_SwitchCornerSize
|
||||
>> screen.m_Aliases
|
||||
>> screen.m_Modifiers
|
||||
>> screen.m_SwitchCorners
|
||||
>> screen.m_Fixes
|
||||
;
|
||||
}
|
||||
|
|
|
@ -34,66 +34,66 @@ class ScreenSettingsDialog;
|
|||
|
||||
class Screen : public BaseConfig
|
||||
{
|
||||
friend QDataStream& operator<<(QDataStream& outStream, const Screen& screen);
|
||||
friend QDataStream& operator>>(QDataStream& inStream, Screen& screen);
|
||||
friend class ScreenSettingsDialog;
|
||||
friend class ScreenSetupModel;
|
||||
friend class ScreenSetupView;
|
||||
friend QDataStream& operator<<(QDataStream& outStream, const Screen& screen);
|
||||
friend QDataStream& operator>>(QDataStream& inStream, Screen& screen);
|
||||
friend class ScreenSettingsDialog;
|
||||
friend class ScreenSetupModel;
|
||||
friend class ScreenSetupView;
|
||||
|
||||
public:
|
||||
Screen();
|
||||
Screen(const QString& name);
|
||||
public:
|
||||
Screen();
|
||||
Screen(const QString& name);
|
||||
|
||||
public:
|
||||
const QPixmap* pixmap() const { return &m_Pixmap; }
|
||||
const QString& name() const { return m_Name; }
|
||||
const QStringList& aliases() const { return m_Aliases; }
|
||||
public:
|
||||
const QPixmap* pixmap() const { return &m_Pixmap; }
|
||||
const QString& name() const { return m_Name; }
|
||||
const QStringList& aliases() const { return m_Aliases; }
|
||||
|
||||
bool isNull() const { return m_Name.isEmpty(); }
|
||||
int modifier(int m) const { return m_Modifiers[m] == DefaultMod ? m : m_Modifiers[m]; }
|
||||
const QList<int>& modifiers() const { return m_Modifiers; }
|
||||
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
||||
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
||||
int switchCornerSize() const { return m_SwitchCornerSize; }
|
||||
bool fix(Fix f) const { return m_Fixes[f]; }
|
||||
const QList<bool>& fixes() const { return m_Fixes; }
|
||||
bool isNull() const { return m_Name.isEmpty(); }
|
||||
int modifier(int m) const { return m_Modifiers[m] == DefaultMod ? m : m_Modifiers[m]; }
|
||||
const QList<int>& modifiers() const { return m_Modifiers; }
|
||||
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
||||
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
||||
int switchCornerSize() const { return m_SwitchCornerSize; }
|
||||
bool fix(Fix f) const { return m_Fixes[f]; }
|
||||
const QList<bool>& fixes() const { return m_Fixes; }
|
||||
|
||||
void loadSettings(QSettings& settings);
|
||||
void saveSettings(QSettings& settings) const;
|
||||
QTextStream& writeScreensSection(QTextStream& outStream) const;
|
||||
QTextStream& writeAliasesSection(QTextStream& outStream) const;
|
||||
void loadSettings(QSettings& settings);
|
||||
void saveSettings(QSettings& settings) const;
|
||||
QTextStream& writeScreensSection(QTextStream& outStream) const;
|
||||
QTextStream& writeAliasesSection(QTextStream& outStream) const;
|
||||
|
||||
bool swapped() const { return m_Swapped; }
|
||||
QString& name() { return m_Name; }
|
||||
void setName(const QString& name) { m_Name = name; }
|
||||
bool swapped() const { return m_Swapped; }
|
||||
QString& name() { return m_Name; }
|
||||
void setName(const QString& name) { m_Name = name; }
|
||||
|
||||
protected:
|
||||
void init();
|
||||
QPixmap* pixmap() { return &m_Pixmap; }
|
||||
protected:
|
||||
void init();
|
||||
QPixmap* pixmap() { return &m_Pixmap; }
|
||||
|
||||
void setPixmap(const QPixmap& pixmap) { m_Pixmap = pixmap; }
|
||||
QStringList& aliases() { return m_Aliases; }
|
||||
void setModifier(int m, int n) { m_Modifiers[m] = n; }
|
||||
QList<int>& modifiers() { return m_Modifiers; }
|
||||
void addAlias(const QString& alias) { m_Aliases.append(alias); }
|
||||
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
||||
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
||||
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
||||
void setFix(int f, bool on) { m_Fixes[f] = on; }
|
||||
QList<bool>& fixes() { return m_Fixes; }
|
||||
void setSwapped(bool on) { m_Swapped = on; }
|
||||
void setPixmap(const QPixmap& pixmap) { m_Pixmap = pixmap; }
|
||||
QStringList& aliases() { return m_Aliases; }
|
||||
void setModifier(int m, int n) { m_Modifiers[m] = n; }
|
||||
QList<int>& modifiers() { return m_Modifiers; }
|
||||
void addAlias(const QString& alias) { m_Aliases.append(alias); }
|
||||
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
||||
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
||||
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
||||
void setFix(int f, bool on) { m_Fixes[f] = on; }
|
||||
QList<bool>& fixes() { return m_Fixes; }
|
||||
void setSwapped(bool on) { m_Swapped = on; }
|
||||
|
||||
private:
|
||||
QPixmap m_Pixmap;
|
||||
QString m_Name;
|
||||
private:
|
||||
QPixmap m_Pixmap;
|
||||
QString m_Name;
|
||||
|
||||
QStringList m_Aliases;
|
||||
QList<int> m_Modifiers;
|
||||
QList<bool> m_SwitchCorners;
|
||||
int m_SwitchCornerSize;
|
||||
QList<bool> m_Fixes;
|
||||
QStringList m_Aliases;
|
||||
QList<int> m_Modifiers;
|
||||
QList<bool> m_SwitchCorners;
|
||||
int m_SwitchCornerSize;
|
||||
QList<bool> m_Fixes;
|
||||
|
||||
bool m_Swapped;
|
||||
bool m_Swapped;
|
||||
};
|
||||
|
||||
typedef QList<Screen> ScreenList;
|
||||
|
|
|
@ -24,114 +24,114 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ScreenSettingsDialogBase(),
|
||||
m_pScreen(pScreen)
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ScreenSettingsDialogBase(),
|
||||
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->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
||||
m_pLineEditName->selectAll();
|
||||
m_pLineEditName->setText(m_pScreen->name());
|
||||
m_pLineEditName->setValidator(new QRegExpValidator(validScreenName, m_pLineEditName));
|
||||
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++)
|
||||
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
|
||||
for (int i = 0; i < m_pScreen->aliases().count(); i++)
|
||||
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
|
||||
|
||||
m_pComboBoxShift->setCurrentIndex(m_pScreen->modifier(Screen::Shift));
|
||||
m_pComboBoxCtrl->setCurrentIndex(m_pScreen->modifier(Screen::Ctrl));
|
||||
m_pComboBoxAlt->setCurrentIndex(m_pScreen->modifier(Screen::Alt));
|
||||
m_pComboBoxMeta->setCurrentIndex(m_pScreen->modifier(Screen::Meta));
|
||||
m_pComboBoxSuper->setCurrentIndex(m_pScreen->modifier(Screen::Super));
|
||||
m_pComboBoxShift->setCurrentIndex(m_pScreen->modifier(Screen::Shift));
|
||||
m_pComboBoxCtrl->setCurrentIndex(m_pScreen->modifier(Screen::Ctrl));
|
||||
m_pComboBoxAlt->setCurrentIndex(m_pScreen->modifier(Screen::Alt));
|
||||
m_pComboBoxMeta->setCurrentIndex(m_pScreen->modifier(Screen::Meta));
|
||||
m_pComboBoxSuper->setCurrentIndex(m_pScreen->modifier(Screen::Super));
|
||||
|
||||
m_pCheckBoxCornerTopLeft->setChecked(m_pScreen->switchCorner(Screen::TopLeft));
|
||||
m_pCheckBoxCornerTopRight->setChecked(m_pScreen->switchCorner(Screen::TopRight));
|
||||
m_pCheckBoxCornerBottomLeft->setChecked(m_pScreen->switchCorner(Screen::BottomLeft));
|
||||
m_pCheckBoxCornerBottomRight->setChecked(m_pScreen->switchCorner(Screen::BottomRight));
|
||||
m_pSpinBoxSwitchCornerSize->setValue(m_pScreen->switchCornerSize());
|
||||
m_pCheckBoxCornerTopLeft->setChecked(m_pScreen->switchCorner(Screen::TopLeft));
|
||||
m_pCheckBoxCornerTopRight->setChecked(m_pScreen->switchCorner(Screen::TopRight));
|
||||
m_pCheckBoxCornerBottomLeft->setChecked(m_pScreen->switchCorner(Screen::BottomLeft));
|
||||
m_pCheckBoxCornerBottomRight->setChecked(m_pScreen->switchCorner(Screen::BottomRight));
|
||||
m_pSpinBoxSwitchCornerSize->setValue(m_pScreen->switchCornerSize());
|
||||
|
||||
m_pCheckBoxCapsLock->setChecked(m_pScreen->fix(Screen::CapsLock));
|
||||
m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::NumLock));
|
||||
m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::ScrollLock));
|
||||
m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::XTest));
|
||||
m_pCheckBoxCapsLock->setChecked(m_pScreen->fix(Screen::CapsLock));
|
||||
m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::NumLock));
|
||||
m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::ScrollLock));
|
||||
m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::XTest));
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::accept()
|
||||
{
|
||||
if (m_pLineEditName->text().isEmpty())
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this, tr("Screen name is empty"),
|
||||
tr("The screen name cannot be empty. "
|
||||
"Please either fill in a name or cancel the dialog."));
|
||||
return;
|
||||
}
|
||||
if (m_pLineEditName->text().isEmpty())
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this, tr("Screen name is empty"),
|
||||
tr("The screen name cannot be empty. "
|
||||
"Please either fill in a name or cancel the dialog."));
|
||||
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++)
|
||||
{
|
||||
QString alias(m_pListAliases->item(i)->text());
|
||||
if (alias == m_pLineEditName->text())
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this, tr("Screen name matches alias"),
|
||||
tr("The screen name cannot be the same as an alias. "
|
||||
"Please either remove the alias or change the screen name."));
|
||||
return;
|
||||
}
|
||||
m_pScreen->addAlias(alias);
|
||||
}
|
||||
for (int i = 0; i < m_pListAliases->count(); i++)
|
||||
{
|
||||
QString alias(m_pListAliases->item(i)->text());
|
||||
if (alias == m_pLineEditName->text())
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this, tr("Screen name matches alias"),
|
||||
tr("The screen name cannot be the same as an alias. "
|
||||
"Please either remove the alias or change the screen name."));
|
||||
return;
|
||||
}
|
||||
m_pScreen->addAlias(alias);
|
||||
}
|
||||
|
||||
m_pScreen->setModifier(Screen::Shift, m_pComboBoxShift->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Ctrl, m_pComboBoxCtrl->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Alt, m_pComboBoxAlt->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Shift, m_pComboBoxShift->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Ctrl, m_pComboBoxCtrl->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Alt, m_pComboBoxAlt->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Meta, m_pComboBoxMeta->currentIndex());
|
||||
m_pScreen->setModifier(Screen::Super, m_pComboBoxSuper->currentIndex());
|
||||
|
||||
m_pScreen->setSwitchCorner(Screen::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
||||
m_pScreen->setSwitchCorner(Screen::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
||||
m_pScreen->setSwitchCorner(Screen::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
||||
m_pScreen->setSwitchCorner(Screen::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
||||
m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
||||
m_pScreen->setSwitchCorner(Screen::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
||||
m_pScreen->setSwitchCorner(Screen::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
||||
m_pScreen->setSwitchCorner(Screen::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
||||
m_pScreen->setSwitchCorner(Screen::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
||||
m_pScreen->setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
||||
|
||||
m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked());
|
||||
m_pScreen->setFix(Screen::NumLock, m_pCheckBoxNumLock->isChecked());
|
||||
m_pScreen->setFix(Screen::ScrollLock, m_pCheckBoxScrollLock->isChecked());
|
||||
m_pScreen->setFix(Screen::XTest, m_pCheckBoxXTest->isChecked());
|
||||
m_pScreen->setFix(Screen::CapsLock, m_pCheckBoxCapsLock->isChecked());
|
||||
m_pScreen->setFix(Screen::NumLock, m_pCheckBoxNumLock->isChecked());
|
||||
m_pScreen->setFix(Screen::ScrollLock, m_pCheckBoxScrollLock->isChecked());
|
||||
m_pScreen->setFix(Screen::XTest, m_pCheckBoxXTest->isChecked());
|
||||
|
||||
QDialog::accept();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void ScreenSettingsDialog::on_m_pButtonAddAlias_clicked()
|
||||
{
|
||||
if (!m_pLineEditAlias->text().isEmpty() && m_pListAliases->findItems(m_pLineEditAlias->text(), Qt::MatchFixedString).isEmpty())
|
||||
{
|
||||
new QListWidgetItem(m_pLineEditAlias->text(), m_pListAliases);
|
||||
m_pLineEditAlias->clear();
|
||||
}
|
||||
if (!m_pLineEditAlias->text().isEmpty() && m_pListAliases->findItems(m_pLineEditAlias->text(), Qt::MatchFixedString).isEmpty())
|
||||
{
|
||||
new QListWidgetItem(m_pLineEditAlias->text(), m_pListAliases);
|
||||
m_pLineEditAlias->clear();
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
QList<QListWidgetItem*> items = m_pListAliases->selectedItems();
|
||||
QList<QListWidgetItem*> items = m_pListAliases->selectedItems();
|
||||
|
||||
for (int i = 0; i < items.count(); i++)
|
||||
delete items[i];
|
||||
for (int i = 0; i < items.count(); i++)
|
||||
delete items[i];
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScreenSettingsDialog(QWidget* parent, Screen* pScreen = NULL);
|
||||
public:
|
||||
ScreenSettingsDialog(QWidget* parent, Screen* pScreen = NULL);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
private slots:
|
||||
void on_m_pButtonAddAlias_clicked();
|
||||
void on_m_pButtonRemoveAlias_clicked();
|
||||
void on_m_pLineEditAlias_textChanged(const QString& text);
|
||||
void on_m_pListAliases_itemSelectionChanged();
|
||||
private slots:
|
||||
void on_m_pButtonAddAlias_clicked();
|
||||
void on_m_pButtonRemoveAlias_clicked();
|
||||
void on_m_pLineEditAlias_textChanged(const QString& text);
|
||||
void on_m_pListAliases_itemSelectionChanged();
|
||||
|
||||
private:
|
||||
Screen* m_pScreen;
|
||||
private:
|
||||
Screen* m_pScreen;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,119 +25,119 @@
|
|||
const QString ScreenSetupModel::m_MimeType = "application/x-qsynergy-screen";
|
||||
|
||||
ScreenSetupModel::ScreenSetupModel(ScreenList& screens, int numColumns, int numRows) :
|
||||
QAbstractTableModel(NULL),
|
||||
m_Screens(screens),
|
||||
m_NumColumns(numColumns),
|
||||
m_NumRows(numRows)
|
||||
QAbstractTableModel(NULL),
|
||||
m_Screens(screens),
|
||||
m_NumColumns(numColumns),
|
||||
m_NumRows(numRows)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
QVariant ScreenSetupModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (index.isValid() && index.row() < m_NumRows && index.column() < m_NumColumns)
|
||||
{
|
||||
switch(role)
|
||||
{
|
||||
case Qt::DecorationRole:
|
||||
if (screen(index).isNull())
|
||||
break;
|
||||
return QIcon(*screen(index).pixmap());
|
||||
if (index.isValid() && index.row() < m_NumRows && index.column() < m_NumColumns)
|
||||
{
|
||||
switch(role)
|
||||
{
|
||||
case Qt::DecorationRole:
|
||||
if (screen(index).isNull())
|
||||
break;
|
||||
return QIcon(*screen(index).pixmap());
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
if (screen(index).isNull())
|
||||
break;
|
||||
return QString(tr(
|
||||
"<center>Screen: <b>%1</b></center>"
|
||||
"<br>Double click to edit settings"
|
||||
"<br>Drag screen to the trashcan to remove it")).arg(screen(index).name());
|
||||
case Qt::ToolTipRole:
|
||||
if (screen(index).isNull())
|
||||
break;
|
||||
return QString(tr(
|
||||
"<center>Screen: <b>%1</b></center>"
|
||||
"<br>Double click to edit settings"
|
||||
"<br>Drag screen to the trashcan to remove it")).arg(screen(index).name());
|
||||
|
||||
case Qt::DisplayRole:
|
||||
if (screen(index).isNull())
|
||||
break;
|
||||
return screen(index).name();
|
||||
}
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
if (screen(index).isNull())
|
||||
break;
|
||||
return screen(index).name();
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Qt::ItemFlags ScreenSetupModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (!index.isValid() || index.row() >= m_NumRows || index.column() >= m_NumColumns)
|
||||
return 0;
|
||||
if (!index.isValid() || index.row() >= m_NumRows || index.column() >= m_NumColumns)
|
||||
return 0;
|
||||
|
||||
if (!screen(index).isNull())
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
|
||||
if (!screen(index).isNull())
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled;
|
||||
|
||||
return Qt::ItemIsDropEnabled;
|
||||
return Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
Qt::DropActions ScreenSetupModel::supportedDropActions() const
|
||||
{
|
||||
return Qt::MoveAction | Qt::CopyAction;
|
||||
return Qt::MoveAction | Qt::CopyAction;
|
||||
}
|
||||
|
||||
QStringList ScreenSetupModel::mimeTypes() const
|
||||
{
|
||||
return QStringList() << m_MimeType;
|
||||
return QStringList() << m_MimeType;
|
||||
}
|
||||
|
||||
QMimeData* ScreenSetupModel::mimeData(const QModelIndexList& indexes) const
|
||||
{
|
||||
QMimeData* pMimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
QMimeData* pMimeData = new QMimeData();
|
||||
QByteArray encodedData;
|
||||
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
QDataStream stream(&encodedData, QIODevice::WriteOnly);
|
||||
|
||||
foreach (const QModelIndex& index, indexes)
|
||||
if (index.isValid())
|
||||
stream << index.column() << index.row() << screen(index);
|
||||
foreach (const QModelIndex& index, indexes)
|
||||
if (index.isValid())
|
||||
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)
|
||||
{
|
||||
if (action == Qt::IgnoreAction)
|
||||
return true;
|
||||
if (action == Qt::IgnoreAction)
|
||||
return true;
|
||||
|
||||
if (!data->hasFormat(m_MimeType))
|
||||
return false;
|
||||
if (!data->hasFormat(m_MimeType))
|
||||
return false;
|
||||
|
||||
if (!parent.isValid() || row != -1 || column != -1)
|
||||
return false;
|
||||
if (!parent.isValid() || row != -1 || column != -1)
|
||||
return false;
|
||||
|
||||
QByteArray encodedData = data->data(m_MimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
QByteArray encodedData = data->data(m_MimeType);
|
||||
QDataStream stream(&encodedData, QIODevice::ReadOnly);
|
||||
|
||||
int sourceColumn = -1;
|
||||
int sourceRow = -1;
|
||||
int sourceColumn = -1;
|
||||
int sourceRow = -1;
|
||||
|
||||
stream >> sourceColumn;
|
||||
stream >> sourceRow;
|
||||
stream >> sourceColumn;
|
||||
stream >> sourceRow;
|
||||
|
||||
// don't drop screen onto itself
|
||||
if (sourceColumn == parent.column() && sourceRow == parent.row())
|
||||
return false;
|
||||
// don't drop screen onto itself
|
||||
if (sourceColumn == parent.column() && sourceRow == parent.row())
|
||||
return false;
|
||||
|
||||
Screen droppedScreen;
|
||||
stream >> droppedScreen;
|
||||
Screen droppedScreen;
|
||||
stream >> droppedScreen;
|
||||
|
||||
Screen oldScreen = screen(parent.column(), parent.row());
|
||||
if (!oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1)
|
||||
{
|
||||
// mark the screen so it isn't deleted after the dragndrop succeeded
|
||||
// see ScreenSetupView::startDrag()
|
||||
oldScreen.setSwapped(true);
|
||||
screen(sourceColumn, sourceRow) = oldScreen;
|
||||
}
|
||||
Screen oldScreen = screen(parent.column(), parent.row());
|
||||
if (!oldScreen.isNull() && sourceColumn != -1 && sourceRow != -1)
|
||||
{
|
||||
// mark the screen so it isn't deleted after the dragndrop succeeded
|
||||
// see ScreenSetupView::startDrag()
|
||||
oldScreen.setSwapped(true);
|
||||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
friend class ScreenSetupView;
|
||||
friend class ServerConfigDialog;
|
||||
friend class ScreenSetupView;
|
||||
friend class ServerConfigDialog;
|
||||
|
||||
public:
|
||||
ScreenSetupModel(ScreenList& screens, int numColumns, int numRows);
|
||||
public:
|
||||
ScreenSetupModel(ScreenList& screens, int numColumns, int numRows);
|
||||
|
||||
public:
|
||||
static const QString& mimeType() { return m_MimeType; }
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
int rowCount() const { return m_NumRows; }
|
||||
int columnCount() const { return m_NumColumns; }
|
||||
int rowCount(const QModelIndex&) const { return rowCount(); }
|
||||
int columnCount(const QModelIndex&) const { return columnCount(); }
|
||||
Qt::DropActions supportedDropActions() const;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
QStringList mimeTypes() const;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
||||
public:
|
||||
static const QString& mimeType() { return m_MimeType; }
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
||||
int rowCount() const { return m_NumRows; }
|
||||
int columnCount() const { return m_NumColumns; }
|
||||
int rowCount(const QModelIndex&) const { return rowCount(); }
|
||||
int columnCount(const QModelIndex&) const { return columnCount(); }
|
||||
Qt::DropActions supportedDropActions() const;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
QStringList mimeTypes() const;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const;
|
||||
|
||||
protected:
|
||||
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()); }
|
||||
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]; }
|
||||
Screen& screen(int column, int row) { return m_Screens[row * m_NumColumns + column]; }
|
||||
protected:
|
||||
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()); }
|
||||
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]; }
|
||||
Screen& screen(int column, int row) { return m_Screens[row * m_NumColumns + column]; }
|
||||
|
||||
private:
|
||||
ScreenList& m_Screens;
|
||||
const int m_NumColumns;
|
||||
const int m_NumRows;
|
||||
private:
|
||||
ScreenList& m_Screens;
|
||||
const int m_NumColumns;
|
||||
const int m_NumRows;
|
||||
|
||||
static const QString m_MimeType;
|
||||
static const QString m_MimeType;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,138 +24,138 @@
|
|||
#include <QtGui>
|
||||
|
||||
ScreenSetupView::ScreenSetupView(QWidget* parent) :
|
||||
QTableView(parent)
|
||||
QTableView(parent)
|
||||
{
|
||||
setDropIndicatorShown(true);
|
||||
setDragDropMode(DragDrop);
|
||||
setSelectionMode(SingleSelection);
|
||||
setDropIndicatorShown(true);
|
||||
setDragDropMode(DragDrop);
|
||||
setSelectionMode(SingleSelection);
|
||||
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
setIconSize(QSize(64, 64));
|
||||
horizontalHeader()->hide();
|
||||
verticalHeader()->hide();
|
||||
setIconSize(QSize(64, 64));
|
||||
horizontalHeader()->hide();
|
||||
verticalHeader()->hide();
|
||||
}
|
||||
|
||||
void ScreenSetupView::setModel(ScreenSetupModel* model)
|
||||
{
|
||||
QTableView::setModel(model);
|
||||
setTableSize();
|
||||
QTableView::setModel(model);
|
||||
setTableSize();
|
||||
}
|
||||
|
||||
ScreenSetupModel* ScreenSetupView::model() const
|
||||
{
|
||||
return qobject_cast<ScreenSetupModel*>(QTableView::model());
|
||||
return qobject_cast<ScreenSetupModel*>(QTableView::model());
|
||||
}
|
||||
|
||||
void ScreenSetupView::setTableSize()
|
||||
{
|
||||
for (int i = 0; i < model()->columnCount(); i++)
|
||||
setColumnWidth(i, width() / model()->columnCount());
|
||||
for (int i = 0; i < model()->columnCount(); i++)
|
||||
setColumnWidth(i, width() / model()->columnCount());
|
||||
|
||||
for (int i = 0; i < model()->rowCount(); i++)
|
||||
setRowHeight(i, height() / model()->rowCount());
|
||||
for (int i = 0; i < model()->rowCount(); i++)
|
||||
setRowHeight(i, height() / model()->rowCount());
|
||||
}
|
||||
|
||||
void ScreenSetupView::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
setTableSize();
|
||||
event->ignore();
|
||||
setTableSize();
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void ScreenSetupView::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
{
|
||||
int col = columnAt(event->pos().x());
|
||||
int row = rowAt(event->pos().y());
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
{
|
||||
int col = columnAt(event->pos().x());
|
||||
int row = rowAt(event->pos().y());
|
||||
|
||||
if (!model()->screen(col, row).isNull())
|
||||
{
|
||||
ScreenSettingsDialog dlg(this, &model()->screen(col, row));
|
||||
dlg.exec();
|
||||
}
|
||||
}
|
||||
else
|
||||
event->ignore();
|
||||
if (!model()->screen(col, row).isNull())
|
||||
{
|
||||
ScreenSettingsDialog dlg(this, &model()->screen(col, row));
|
||||
dlg.exec();
|
||||
}
|
||||
}
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void ScreenSetupView::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
// we accept anything that enters us by a drag as long as the
|
||||
// mime type is okay. anything else is dealt with in dragMoveEvent()
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
event->accept();
|
||||
else
|
||||
event->ignore();
|
||||
// we accept anything that enters us by a drag as long as the
|
||||
// mime type is okay. anything else is dealt with in dragMoveEvent()
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
event->accept();
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void ScreenSetupView::dragMoveEvent(QDragMoveEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
{
|
||||
// where does the event come from? myself or someone else?
|
||||
if (event->source() == this)
|
||||
{
|
||||
// myself is ok, but then it must be a move action, never a copy
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
int col = columnAt(event->pos().x());
|
||||
int row = rowAt(event->pos().y());
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
{
|
||||
// where does the event come from? myself or someone else?
|
||||
if (event->source() == this)
|
||||
{
|
||||
// myself is ok, but then it must be a move action, never a copy
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
int col = columnAt(event->pos().x());
|
||||
int row = rowAt(event->pos().y());
|
||||
|
||||
// a drop from outside is not allowed if there's a screen already there.
|
||||
if (!model()->screen(col, row).isNull())
|
||||
event->ignore();
|
||||
else
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
else
|
||||
event->ignore();
|
||||
// a drop from outside is not allowed if there's a screen already there.
|
||||
if (!model()->screen(col, row).isNull())
|
||||
event->ignore();
|
||||
else
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
// this is reimplemented from QAbstractItemView::startDrag()
|
||||
void ScreenSetupView::startDrag(Qt::DropActions)
|
||||
{
|
||||
QModelIndexList indexes = selectedIndexes();
|
||||
QModelIndexList indexes = selectedIndexes();
|
||||
|
||||
if (indexes.count() != 1)
|
||||
return;
|
||||
if (indexes.count() != 1)
|
||||
return;
|
||||
|
||||
QMimeData* pData = model()->mimeData(indexes);
|
||||
if (pData == NULL)
|
||||
return;
|
||||
QMimeData* pData = model()->mimeData(indexes);
|
||||
if (pData == NULL)
|
||||
return;
|
||||
|
||||
QPixmap pixmap = *model()->screen(indexes[0]).pixmap();
|
||||
QDrag* pDrag = new QDrag(this);
|
||||
pDrag->setPixmap(pixmap);
|
||||
pDrag->setMimeData(pData);
|
||||
pDrag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2));
|
||||
QPixmap pixmap = *model()->screen(indexes[0]).pixmap();
|
||||
QDrag* pDrag = new QDrag(this);
|
||||
pDrag->setPixmap(pixmap);
|
||||
pDrag->setMimeData(pData);
|
||||
pDrag->setHotSpot(QPoint(pixmap.width() / 2, pixmap.height() / 2));
|
||||
|
||||
if (pDrag->exec(Qt::MoveAction, Qt::MoveAction) == Qt::MoveAction)
|
||||
{
|
||||
selectionModel()->clear();
|
||||
if (pDrag->exec(Qt::MoveAction, Qt::MoveAction) == Qt::MoveAction)
|
||||
{
|
||||
selectionModel()->clear();
|
||||
|
||||
// make sure to only delete the drag source if screens weren't swapped
|
||||
// see ScreenSetupModel::dropMimeData
|
||||
if (!model()->screen(indexes[0]).swapped())
|
||||
model()->screen(indexes[0]) = Screen();
|
||||
else
|
||||
model()->screen(indexes[0]).setSwapped(false);
|
||||
}
|
||||
// make sure to only delete the drag source if screens weren't swapped
|
||||
// see ScreenSetupModel::dropMimeData
|
||||
if (!model()->screen(indexes[0]).swapped())
|
||||
model()->screen(indexes[0]) = Screen();
|
||||
else
|
||||
model()->screen(indexes[0]).setSwapped(false);
|
||||
}
|
||||
}
|
||||
|
||||
QStyleOptionViewItem ScreenSetupView::viewOptions() const
|
||||
{
|
||||
QStyleOptionViewItem option = QTableView::viewOptions();
|
||||
option.showDecorationSelected = true;
|
||||
option.decorationPosition = QStyleOptionViewItem::Top;
|
||||
option.displayAlignment = Qt::AlignCenter;
|
||||
option.textElideMode = Qt::ElideMiddle;
|
||||
return option;
|
||||
QStyleOptionViewItem option = QTableView::viewOptions();
|
||||
option.showDecorationSelected = true;
|
||||
option.decorationPosition = QStyleOptionViewItem::Top;
|
||||
option.displayAlignment = Qt::AlignCenter;
|
||||
option.textElideMode = Qt::ElideMiddle;
|
||||
return option;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,24 +33,24 @@ class ScreenSetupModel;
|
|||
|
||||
class ScreenSetupView : public QTableView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScreenSetupView(QWidget* parent);
|
||||
public:
|
||||
ScreenSetupView(QWidget* parent);
|
||||
|
||||
public:
|
||||
void setModel(ScreenSetupModel* model);
|
||||
ScreenSetupModel* model() const;
|
||||
public:
|
||||
void setModel(ScreenSetupModel* model);
|
||||
ScreenSetupModel* model() const;
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent*);
|
||||
void setTableSize();
|
||||
void resizeEvent(QResizeEvent*);
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dragMoveEvent(QDragMoveEvent* event);
|
||||
void startDrag(Qt::DropActions supportedActions);
|
||||
QStyleOptionViewItem viewOptions() const;
|
||||
void scrollTo(const QModelIndex&, ScrollHint) {}
|
||||
protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent*);
|
||||
void setTableSize();
|
||||
void resizeEvent(QResizeEvent*);
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dragMoveEvent(QDragMoveEvent* event);
|
||||
void startDrag(Qt::DropActions supportedActions);
|
||||
QStyleOptionViewItem viewOptions() const;
|
||||
void scrollTo(const QModelIndex&, ScrollHint) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,376 +28,376 @@
|
|||
|
||||
static const struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
const char* name;
|
||||
int x;
|
||||
int y;
|
||||
const char* name;
|
||||
} neighbourDirs[] =
|
||||
{
|
||||
{ 1, 0, "right" },
|
||||
{ -1, 0, "left" },
|
||||
{ 0, -1, "up" },
|
||||
{ 0, 1, "down" },
|
||||
{ 1, 0, "right" },
|
||||
{ -1, 0, "left" },
|
||||
{ 0, -1, "up" },
|
||||
{ 0, 1, "down" },
|
||||
|
||||
};
|
||||
|
||||
const int serverDefaultIndex = 7;
|
||||
|
||||
ServerConfig::ServerConfig(QSettings* settings, int numColumns, int numRows ,
|
||||
QString serverName, MainWindow* mainWindow) :
|
||||
m_pSettings(settings),
|
||||
m_Screens(),
|
||||
m_NumColumns(numColumns),
|
||||
m_NumRows(numRows),
|
||||
m_ServerName(serverName),
|
||||
m_IgnoreAutoConfigClient(false),
|
||||
m_EnableDragAndDrop(false),
|
||||
m_ClipboardSharing(true),
|
||||
m_pMainWindow(mainWindow)
|
||||
QString serverName, MainWindow* mainWindow) :
|
||||
m_pSettings(settings),
|
||||
m_Screens(),
|
||||
m_NumColumns(numColumns),
|
||||
m_NumRows(numRows),
|
||||
m_ServerName(serverName),
|
||||
m_IgnoreAutoConfigClient(false),
|
||||
m_EnableDragAndDrop(false),
|
||||
m_ClipboardSharing(true),
|
||||
m_pMainWindow(mainWindow)
|
||||
{
|
||||
Q_ASSERT(m_pSettings);
|
||||
Q_ASSERT(m_pSettings);
|
||||
|
||||
loadSettings();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
ServerConfig::~ServerConfig()
|
||||
{
|
||||
saveSettings();
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
bool ServerConfig::save(const QString& fileName) const
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return false;
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return false;
|
||||
|
||||
save(file);
|
||||
file.close();
|
||||
save(file);
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ServerConfig::save(QFile& file) const
|
||||
{
|
||||
QTextStream outStream(&file);
|
||||
outStream << *this;
|
||||
QTextStream outStream(&file);
|
||||
outStream << *this;
|
||||
}
|
||||
|
||||
void ServerConfig::init()
|
||||
{
|
||||
switchCorners().clear();
|
||||
screens().clear();
|
||||
switchCorners().clear();
|
||||
screens().clear();
|
||||
|
||||
// m_NumSwitchCorners is used as a fixed size array. See Screen::init()
|
||||
for (int i = 0; i < NumSwitchCorners; i++)
|
||||
switchCorners() << false;
|
||||
// m_NumSwitchCorners is used as a fixed size array. See Screen::init()
|
||||
for (int i = 0; i < NumSwitchCorners; i++)
|
||||
switchCorners() << false;
|
||||
|
||||
// There must always be screen objects for each cell in the screens QList. Unused screens
|
||||
// are identified by having an empty name.
|
||||
for (int i = 0; i < numColumns() * numRows(); i++)
|
||||
addScreen(Screen());
|
||||
// There must always be screen objects for each cell in the screens QList. Unused screens
|
||||
// are identified by having an empty name.
|
||||
for (int i = 0; i < numColumns() * numRows(); i++)
|
||||
addScreen(Screen());
|
||||
}
|
||||
|
||||
void ServerConfig::saveSettings()
|
||||
{
|
||||
settings().beginGroup("internalConfig");
|
||||
settings().remove("");
|
||||
settings().beginGroup("internalConfig");
|
||||
settings().remove("");
|
||||
|
||||
settings().setValue("numColumns", numColumns());
|
||||
settings().setValue("numRows", numRows());
|
||||
settings().setValue("numColumns", numColumns());
|
||||
settings().setValue("numRows", numRows());
|
||||
|
||||
settings().setValue("hasHeartbeat", hasHeartbeat());
|
||||
settings().setValue("heartbeat", heartbeat());
|
||||
settings().setValue("relativeMouseMoves", relativeMouseMoves());
|
||||
settings().setValue("screenSaverSync", screenSaverSync());
|
||||
settings().setValue("win32KeepForeground", win32KeepForeground());
|
||||
settings().setValue("hasSwitchDelay", hasSwitchDelay());
|
||||
settings().setValue("switchDelay", switchDelay());
|
||||
settings().setValue("hasSwitchDoubleTap", hasSwitchDoubleTap());
|
||||
settings().setValue("switchDoubleTap", switchDoubleTap());
|
||||
settings().setValue("switchCornerSize", switchCornerSize());
|
||||
settings().setValue("ignoreAutoConfigClient", ignoreAutoConfigClient());
|
||||
settings().setValue("enableDragAndDrop", enableDragAndDrop());
|
||||
settings().setValue("hasHeartbeat", hasHeartbeat());
|
||||
settings().setValue("heartbeat", heartbeat());
|
||||
settings().setValue("relativeMouseMoves", relativeMouseMoves());
|
||||
settings().setValue("screenSaverSync", screenSaverSync());
|
||||
settings().setValue("win32KeepForeground", win32KeepForeground());
|
||||
settings().setValue("hasSwitchDelay", hasSwitchDelay());
|
||||
settings().setValue("switchDelay", switchDelay());
|
||||
settings().setValue("hasSwitchDoubleTap", hasSwitchDoubleTap());
|
||||
settings().setValue("switchDoubleTap", switchDoubleTap());
|
||||
settings().setValue("switchCornerSize", switchCornerSize());
|
||||
settings().setValue("ignoreAutoConfigClient", ignoreAutoConfigClient());
|
||||
settings().setValue("enableDragAndDrop", enableDragAndDrop());
|
||||
|
||||
writeSettings(settings(), switchCorners(), "switchCorner");
|
||||
writeSettings(settings(), switchCorners(), "switchCorner");
|
||||
|
||||
settings().beginWriteArray("screens");
|
||||
for (int i = 0; i < screens().size(); i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
screens()[i].saveSettings(settings());
|
||||
}
|
||||
settings().endArray();
|
||||
settings().beginWriteArray("screens");
|
||||
for (int i = 0; i < screens().size(); i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
screens()[i].saveSettings(settings());
|
||||
}
|
||||
settings().endArray();
|
||||
|
||||
settings().beginWriteArray("hotkeys");
|
||||
for (int i = 0; i < hotkeys().size(); i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
hotkeys()[i].saveSettings(settings());
|
||||
}
|
||||
settings().endArray();
|
||||
settings().beginWriteArray("hotkeys");
|
||||
for (int i = 0; i < hotkeys().size(); i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
hotkeys()[i].saveSettings(settings());
|
||||
}
|
||||
settings().endArray();
|
||||
|
||||
settings().endGroup();
|
||||
settings().endGroup();
|
||||
}
|
||||
|
||||
void ServerConfig::loadSettings()
|
||||
{
|
||||
settings().beginGroup("internalConfig");
|
||||
settings().beginGroup("internalConfig");
|
||||
|
||||
setNumColumns(settings().value("numColumns", 5).toInt());
|
||||
setNumRows(settings().value("numRows", 3).toInt());
|
||||
setNumColumns(settings().value("numColumns", 5).toInt());
|
||||
setNumRows(settings().value("numRows", 3).toInt());
|
||||
|
||||
// we need to know the number of columns and rows before we can set up ourselves
|
||||
init();
|
||||
// we need to know the number of columns and rows before we can set up ourselves
|
||||
init();
|
||||
|
||||
haveHeartbeat(settings().value("hasHeartbeat", false).toBool());
|
||||
setHeartbeat(settings().value("heartbeat", 5000).toInt());
|
||||
setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool());
|
||||
setScreenSaverSync(settings().value("screenSaverSync", true).toBool());
|
||||
setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool());
|
||||
haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool());
|
||||
setSwitchDelay(settings().value("switchDelay", 250).toInt());
|
||||
haveSwitchDoubleTap(settings().value("hasSwitchDoubleTap", false).toBool());
|
||||
setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt());
|
||||
setSwitchCornerSize(settings().value("switchCornerSize").toInt());
|
||||
setIgnoreAutoConfigClient(settings().value("ignoreAutoConfigClient").toBool());
|
||||
setEnableDragAndDrop(settings().value("enableDragAndDrop", true).toBool());
|
||||
haveHeartbeat(settings().value("hasHeartbeat", false).toBool());
|
||||
setHeartbeat(settings().value("heartbeat", 5000).toInt());
|
||||
setRelativeMouseMoves(settings().value("relativeMouseMoves", false).toBool());
|
||||
setScreenSaverSync(settings().value("screenSaverSync", true).toBool());
|
||||
setWin32KeepForeground(settings().value("win32KeepForeground", false).toBool());
|
||||
haveSwitchDelay(settings().value("hasSwitchDelay", false).toBool());
|
||||
setSwitchDelay(settings().value("switchDelay", 250).toInt());
|
||||
haveSwitchDoubleTap(settings().value("hasSwitchDoubleTap", false).toBool());
|
||||
setSwitchDoubleTap(settings().value("switchDoubleTap", 250).toInt());
|
||||
setSwitchCornerSize(settings().value("switchCornerSize").toInt());
|
||||
setIgnoreAutoConfigClient(settings().value("ignoreAutoConfigClient").toBool());
|
||||
setEnableDragAndDrop(settings().value("enableDragAndDrop", true).toBool());
|
||||
|
||||
readSettings(settings(), switchCorners(), "switchCorner", false, NumSwitchCorners);
|
||||
readSettings(settings(), switchCorners(), "switchCorner", false, NumSwitchCorners);
|
||||
|
||||
int numScreens = settings().beginReadArray("screens");
|
||||
Q_ASSERT(numScreens <= screens().size());
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
screens()[i].loadSettings(settings());
|
||||
}
|
||||
settings().endArray();
|
||||
int numScreens = settings().beginReadArray("screens");
|
||||
Q_ASSERT(numScreens <= screens().size());
|
||||
for (int i = 0; i < numScreens; i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
screens()[i].loadSettings(settings());
|
||||
}
|
||||
settings().endArray();
|
||||
|
||||
int numHotkeys = settings().beginReadArray("hotkeys");
|
||||
for (int i = 0; i < numHotkeys; i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
Hotkey h;
|
||||
h.loadSettings(settings());
|
||||
hotkeys().append(h);
|
||||
}
|
||||
settings().endArray();
|
||||
int numHotkeys = settings().beginReadArray("hotkeys");
|
||||
for (int i = 0; i < numHotkeys; i++)
|
||||
{
|
||||
settings().setArrayIndex(i);
|
||||
Hotkey h;
|
||||
h.loadSettings(settings());
|
||||
hotkeys().append(h);
|
||||
}
|
||||
settings().endArray();
|
||||
|
||||
settings().endGroup();
|
||||
settings().endGroup();
|
||||
}
|
||||
|
||||
int ServerConfig::adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const
|
||||
{
|
||||
if (screens()[idx].isNull())
|
||||
return -1;
|
||||
if (screens()[idx].isNull())
|
||||
return -1;
|
||||
|
||||
// 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)
|
||||
|| (deltaColumn < 0 && idx % numColumns() == 0))
|
||||
return -1;
|
||||
// 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)
|
||||
|| (deltaColumn < 0 && idx % numColumns() == 0))
|
||||
return -1;
|
||||
|
||||
int arrayPos = idx + deltaColumn + deltaRow * numColumns();
|
||||
int arrayPos = idx + deltaColumn + deltaRow * numColumns();
|
||||
|
||||
if (arrayPos >= screens().size() || arrayPos < 0)
|
||||
return -1;
|
||||
if (arrayPos >= screens().size() || arrayPos < 0)
|
||||
return -1;
|
||||
|
||||
return arrayPos;
|
||||
return arrayPos;
|
||||
}
|
||||
|
||||
QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config)
|
||||
{
|
||||
outStream << "section: screens" << endl;
|
||||
outStream << "section: screens" << endl;
|
||||
|
||||
foreach (const Screen& s, config.screens())
|
||||
if (!s.isNull())
|
||||
s.writeScreensSection(outStream);
|
||||
foreach (const Screen& s, config.screens())
|
||||
if (!s.isNull())
|
||||
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())
|
||||
if (!s.isNull())
|
||||
s.writeAliasesSection(outStream);
|
||||
foreach (const Screen& s, config.screens())
|
||||
if (!s.isNull())
|
||||
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++)
|
||||
if (!config.screens()[i].isNull())
|
||||
{
|
||||
outStream << "\t" << config.screens()[i].name() << ":" << endl;
|
||||
for (int i = 0; i < config.screens().size(); i++)
|
||||
if (!config.screens()[i].isNull())
|
||||
{
|
||||
outStream << "\t" << config.screens()[i].name() << ":" << endl;
|
||||
|
||||
for (unsigned int j = 0; j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++)
|
||||
{
|
||||
int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, neighbourDirs[j].y);
|
||||
if (idx != -1 && !config.screens()[idx].isNull())
|
||||
outStream << "\t\t" << neighbourDirs[j].name << " = " << config.screens()[idx].name() << endl;
|
||||
}
|
||||
}
|
||||
for (unsigned int j = 0; j < sizeof(neighbourDirs) / sizeof(neighbourDirs[0]); j++)
|
||||
{
|
||||
int idx = config.adjacentScreenIndex(i, neighbourDirs[j].x, neighbourDirs[j].y);
|
||||
if (idx != -1 && !config.screens()[idx].isNull())
|
||||
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())
|
||||
outStream << "\t" << "heartbeat = " << config.heartbeat() << endl;
|
||||
if (config.hasHeartbeat())
|
||||
outStream << "\t" << "heartbeat = " << config.heartbeat() << endl;
|
||||
|
||||
outStream << "\t" << "relativeMouseMoves = " << (config.relativeMouseMoves() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "screenSaverSync = " << (config.screenSaverSync() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "win32KeepForeground = " << (config.win32KeepForeground() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "relativeMouseMoves = " << (config.relativeMouseMoves() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "screenSaverSync = " << (config.screenSaverSync() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "win32KeepForeground = " << (config.win32KeepForeground() ? "true" : "false") << endl;
|
||||
outStream << "\t" << "clipboardSharing = " << (config.clipboardSharing() ? "true" : "false") << endl;
|
||||
|
||||
if (config.hasSwitchDelay())
|
||||
outStream << "\t" << "switchDelay = " << config.switchDelay() << endl;
|
||||
if (config.hasSwitchDelay())
|
||||
outStream << "\t" << "switchDelay = " << config.switchDelay() << endl;
|
||||
|
||||
if (config.hasSwitchDoubleTap())
|
||||
outStream << "\t" << "switchDoubleTap = " << config.switchDoubleTap() << endl;
|
||||
if (config.hasSwitchDoubleTap())
|
||||
outStream << "\t" << "switchDoubleTap = " << config.switchDoubleTap() << endl;
|
||||
|
||||
outStream << "\t" << "switchCorners = none ";
|
||||
for (int i = 0; i < config.switchCorners().size(); i++)
|
||||
if (config.switchCorners()[i])
|
||||
outStream << "+" << config.switchCornerName(i) << " ";
|
||||
outStream << endl;
|
||||
outStream << "\t" << "switchCorners = none ";
|
||||
for (int i = 0; i < config.switchCorners().size(); i++)
|
||||
if (config.switchCorners()[i])
|
||||
outStream << "+" << config.switchCornerName(i) << " ";
|
||||
outStream << endl;
|
||||
|
||||
outStream << "\t" << "switchCornerSize = " << config.switchCornerSize() << endl;
|
||||
outStream << "\t" << "switchCornerSize = " << config.switchCornerSize() << endl;
|
||||
|
||||
foreach(const Hotkey& hotkey, config.hotkeys())
|
||||
outStream << hotkey;
|
||||
foreach(const Hotkey& hotkey, config.hotkeys())
|
||||
outStream << hotkey;
|
||||
|
||||
outStream << "end" << endl << endl;
|
||||
outStream << "end" << endl << endl;
|
||||
|
||||
return outStream;
|
||||
return outStream;
|
||||
}
|
||||
|
||||
int ServerConfig::numScreens() const
|
||||
{
|
||||
int rval = 0;
|
||||
int rval = 0;
|
||||
|
||||
foreach(const Screen& s, screens())
|
||||
if (!s.isNull())
|
||||
rval++;
|
||||
foreach(const Screen& s, screens())
|
||||
if (!s.isNull())
|
||||
rval++;
|
||||
|
||||
return rval;
|
||||
return rval;
|
||||
}
|
||||
|
||||
int ServerConfig::autoAddScreen(const QString name)
|
||||
{
|
||||
int serverIndex = -1;
|
||||
int targetIndex = -1;
|
||||
if (!findScreenName(m_ServerName, serverIndex)) {
|
||||
if (!fixNoServer(m_ServerName, serverIndex)) {
|
||||
return kAutoAddScreenManualServer;
|
||||
}
|
||||
}
|
||||
if (findScreenName(name, targetIndex)) {
|
||||
// already exists.
|
||||
return kAutoAddScreenIgnore;
|
||||
}
|
||||
int serverIndex = -1;
|
||||
int targetIndex = -1;
|
||||
if (!findScreenName(m_ServerName, serverIndex)) {
|
||||
if (!fixNoServer(m_ServerName, serverIndex)) {
|
||||
return kAutoAddScreenManualServer;
|
||||
}
|
||||
}
|
||||
if (findScreenName(name, targetIndex)) {
|
||||
// already exists.
|
||||
return kAutoAddScreenIgnore;
|
||||
}
|
||||
|
||||
int result = showAddClientDialog(name);
|
||||
int result = showAddClientDialog(name);
|
||||
|
||||
if (result == kAddClientIgnore) {
|
||||
return kAutoAddScreenIgnore;
|
||||
}
|
||||
if (result == kAddClientIgnore) {
|
||||
return kAutoAddScreenIgnore;
|
||||
}
|
||||
|
||||
if (result == kAddClientOther) {
|
||||
addToFirstEmptyGrid(name);
|
||||
return kAutoAddScreenManualClient;
|
||||
}
|
||||
if (result == kAddClientOther) {
|
||||
addToFirstEmptyGrid(name);
|
||||
return kAutoAddScreenManualClient;
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
int startIndex = serverIndex;
|
||||
int offset = 1;
|
||||
int dirIndex = 0;
|
||||
bool success = false;
|
||||
int startIndex = serverIndex;
|
||||
int offset = 1;
|
||||
int dirIndex = 0;
|
||||
|
||||
if (result == kAddClientLeft) {
|
||||
offset = -1;
|
||||
dirIndex = 1;
|
||||
}
|
||||
else if (result == kAddClientUp) {
|
||||
offset = -5;
|
||||
dirIndex = 2;
|
||||
}
|
||||
else if (result == kAddClientDown) {
|
||||
offset = 5;
|
||||
dirIndex = 3;
|
||||
}
|
||||
if (result == kAddClientLeft) {
|
||||
offset = -1;
|
||||
dirIndex = 1;
|
||||
}
|
||||
else if (result == kAddClientUp) {
|
||||
offset = -5;
|
||||
dirIndex = 2;
|
||||
}
|
||||
else if (result == kAddClientDown) {
|
||||
offset = 5;
|
||||
dirIndex = 3;
|
||||
}
|
||||
|
||||
|
||||
int idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
||||
neighbourDirs[dirIndex].y);
|
||||
while (idx != -1) {
|
||||
if (screens()[idx].isNull()) {
|
||||
m_Screens[idx].setName(name);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
int idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
||||
neighbourDirs[dirIndex].y);
|
||||
while (idx != -1) {
|
||||
if (screens()[idx].isNull()) {
|
||||
m_Screens[idx].setName(name);
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
startIndex += offset;
|
||||
idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
||||
neighbourDirs[dirIndex].y);
|
||||
}
|
||||
startIndex += offset;
|
||||
idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x,
|
||||
neighbourDirs[dirIndex].y);
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
addToFirstEmptyGrid(name);
|
||||
return kAutoAddScreenManualClient;
|
||||
}
|
||||
if (!success) {
|
||||
addToFirstEmptyGrid(name);
|
||||
return kAutoAddScreenManualClient;
|
||||
}
|
||||
|
||||
saveSettings();
|
||||
return kAutoAddScreenOk;
|
||||
saveSettings();
|
||||
return kAutoAddScreenOk;
|
||||
}
|
||||
|
||||
bool ServerConfig::findScreenName(const QString& name, int& index)
|
||||
{
|
||||
bool found = false;
|
||||
for (int i = 0; i < screens().size(); i++) {
|
||||
if (!screens()[i].isNull() &&
|
||||
screens()[i].name().compare(name) == 0) {
|
||||
index = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
bool found = false;
|
||||
for (int i = 0; i < screens().size(); i++) {
|
||||
if (!screens()[i].isNull() &&
|
||||
screens()[i].name().compare(name) == 0) {
|
||||
index = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
bool ServerConfig::fixNoServer(const QString& name, int& index)
|
||||
{
|
||||
bool fixed = false;
|
||||
if (screens()[serverDefaultIndex].isNull()) {
|
||||
m_Screens[serverDefaultIndex].setName(name);
|
||||
index = serverDefaultIndex;
|
||||
fixed = true;
|
||||
}
|
||||
bool fixed = false;
|
||||
if (screens()[serverDefaultIndex].isNull()) {
|
||||
m_Screens[serverDefaultIndex].setName(name);
|
||||
index = serverDefaultIndex;
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
return fixed;
|
||||
return fixed;
|
||||
}
|
||||
|
||||
int ServerConfig::showAddClientDialog(const QString& clientName)
|
||||
{
|
||||
int result = kAddClientIgnore;
|
||||
int result = kAddClientIgnore;
|
||||
|
||||
if (!m_pMainWindow->isActiveWindow()) {
|
||||
m_pMainWindow->showNormal();
|
||||
m_pMainWindow->activateWindow();
|
||||
}
|
||||
if (!m_pMainWindow->isActiveWindow()) {
|
||||
m_pMainWindow->showNormal();
|
||||
m_pMainWindow->activateWindow();
|
||||
}
|
||||
|
||||
AddClientDialog addClientDialog(clientName, m_pMainWindow);
|
||||
addClientDialog.exec();
|
||||
result = addClientDialog.addResult();
|
||||
m_IgnoreAutoConfigClient = addClientDialog.ignoreAutoConfigClient();
|
||||
AddClientDialog addClientDialog(clientName, m_pMainWindow);
|
||||
addClientDialog.exec();
|
||||
result = addClientDialog.addResult();
|
||||
m_IgnoreAutoConfigClient = addClientDialog.ignoreAutoConfigClient();
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void::ServerConfig::addToFirstEmptyGrid(const QString &clientName)
|
||||
{
|
||||
for (int i = 0; i < screens().size(); i++) {
|
||||
if (screens()[i].isNull()) {
|
||||
m_Screens[i].setName(clientName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < screens().size(); i++) {
|
||||
if (screens()[i].isNull()) {
|
||||
m_Screens[i].setName(clientName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,106 +35,106 @@ class MainWindow;
|
|||
|
||||
class ServerConfig : public BaseConfig
|
||||
{
|
||||
friend class ServerConfigDialog;
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config);
|
||||
friend class ServerConfigDialog;
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config);
|
||||
|
||||
public:
|
||||
ServerConfig(QSettings* settings, int numColumns, int numRows,
|
||||
QString serverName, MainWindow* mainWindow);
|
||||
~ServerConfig();
|
||||
public:
|
||||
ServerConfig(QSettings* settings, int numColumns, int numRows,
|
||||
QString serverName, MainWindow* mainWindow);
|
||||
~ServerConfig();
|
||||
|
||||
public:
|
||||
const ScreenList& screens() const { return m_Screens; }
|
||||
int numColumns() const { return m_NumColumns; }
|
||||
int numRows() const { return m_NumRows; }
|
||||
bool hasHeartbeat() const { return m_HasHeartbeat; }
|
||||
int heartbeat() const { return m_Heartbeat; }
|
||||
bool relativeMouseMoves() const { return m_RelativeMouseMoves; }
|
||||
bool screenSaverSync() const { return m_ScreenSaverSync; }
|
||||
bool win32KeepForeground() const { return m_Win32KeepForeground; }
|
||||
bool hasSwitchDelay() const { return m_HasSwitchDelay; }
|
||||
int switchDelay() const { return m_SwitchDelay; }
|
||||
bool hasSwitchDoubleTap() const { return m_HasSwitchDoubleTap; }
|
||||
int switchDoubleTap() const { return m_SwitchDoubleTap; }
|
||||
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
||||
int switchCornerSize() const { return m_SwitchCornerSize; }
|
||||
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
||||
const HotkeyList& hotkeys() const { return m_Hotkeys; }
|
||||
bool ignoreAutoConfigClient() const { return m_IgnoreAutoConfigClient; }
|
||||
bool enableDragAndDrop() const { return m_EnableDragAndDrop; }
|
||||
bool clipboardSharing() const { return m_ClipboardSharing; }
|
||||
public:
|
||||
const ScreenList& screens() const { return m_Screens; }
|
||||
int numColumns() const { return m_NumColumns; }
|
||||
int numRows() const { return m_NumRows; }
|
||||
bool hasHeartbeat() const { return m_HasHeartbeat; }
|
||||
int heartbeat() const { return m_Heartbeat; }
|
||||
bool relativeMouseMoves() const { return m_RelativeMouseMoves; }
|
||||
bool screenSaverSync() const { return m_ScreenSaverSync; }
|
||||
bool win32KeepForeground() const { return m_Win32KeepForeground; }
|
||||
bool hasSwitchDelay() const { return m_HasSwitchDelay; }
|
||||
int switchDelay() const { return m_SwitchDelay; }
|
||||
bool hasSwitchDoubleTap() const { return m_HasSwitchDoubleTap; }
|
||||
int switchDoubleTap() const { return m_SwitchDoubleTap; }
|
||||
bool switchCorner(int c) const { return m_SwitchCorners[c]; }
|
||||
int switchCornerSize() const { return m_SwitchCornerSize; }
|
||||
const QList<bool>& switchCorners() const { return m_SwitchCorners; }
|
||||
const HotkeyList& hotkeys() const { return m_Hotkeys; }
|
||||
bool ignoreAutoConfigClient() const { return m_IgnoreAutoConfigClient; }
|
||||
bool enableDragAndDrop() const { return m_EnableDragAndDrop; }
|
||||
bool clipboardSharing() const { return m_ClipboardSharing; }
|
||||
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
bool save(const QString& fileName) const;
|
||||
void save(QFile& file) const;
|
||||
int numScreens() const;
|
||||
int autoAddScreen(const QString name);
|
||||
void saveSettings();
|
||||
void loadSettings();
|
||||
bool save(const QString& fileName) const;
|
||||
void save(QFile& file) const;
|
||||
int numScreens() const;
|
||||
int autoAddScreen(const QString name);
|
||||
|
||||
protected:
|
||||
QSettings& settings() { return *m_pSettings; }
|
||||
ScreenList& screens() { return m_Screens; }
|
||||
void setScreens(const ScreenList& screens) { m_Screens = screens; }
|
||||
void addScreen(const Screen& screen) { m_Screens.append(screen); }
|
||||
void setNumColumns(int n) { m_NumColumns = n; }
|
||||
void setNumRows(int n) { m_NumRows = n; }
|
||||
void haveHeartbeat(bool on) { m_HasHeartbeat = on; }
|
||||
void setHeartbeat(int val) { m_Heartbeat = val; }
|
||||
void setRelativeMouseMoves(bool on) { m_RelativeMouseMoves = on; }
|
||||
void setScreenSaverSync(bool on) { m_ScreenSaverSync = on; }
|
||||
void setWin32KeepForeground(bool on) { m_Win32KeepForeground = on; }
|
||||
void haveSwitchDelay(bool on) { m_HasSwitchDelay = on; }
|
||||
void setSwitchDelay(int val) { m_SwitchDelay = val; }
|
||||
void haveSwitchDoubleTap(bool on) { m_HasSwitchDoubleTap = on; }
|
||||
void setSwitchDoubleTap(int val) { m_SwitchDoubleTap = val; }
|
||||
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
||||
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
||||
void setIgnoreAutoConfigClient(bool on) { m_IgnoreAutoConfigClient = on; }
|
||||
void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; }
|
||||
void setClipboardSharing(bool on) { m_ClipboardSharing = on; }
|
||||
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
||||
HotkeyList& hotkeys() { return m_Hotkeys; }
|
||||
protected:
|
||||
QSettings& settings() { return *m_pSettings; }
|
||||
ScreenList& screens() { return m_Screens; }
|
||||
void setScreens(const ScreenList& screens) { m_Screens = screens; }
|
||||
void addScreen(const Screen& screen) { m_Screens.append(screen); }
|
||||
void setNumColumns(int n) { m_NumColumns = n; }
|
||||
void setNumRows(int n) { m_NumRows = n; }
|
||||
void haveHeartbeat(bool on) { m_HasHeartbeat = on; }
|
||||
void setHeartbeat(int val) { m_Heartbeat = val; }
|
||||
void setRelativeMouseMoves(bool on) { m_RelativeMouseMoves = on; }
|
||||
void setScreenSaverSync(bool on) { m_ScreenSaverSync = on; }
|
||||
void setWin32KeepForeground(bool on) { m_Win32KeepForeground = on; }
|
||||
void haveSwitchDelay(bool on) { m_HasSwitchDelay = on; }
|
||||
void setSwitchDelay(int val) { m_SwitchDelay = val; }
|
||||
void haveSwitchDoubleTap(bool on) { m_HasSwitchDoubleTap = on; }
|
||||
void setSwitchDoubleTap(int val) { m_SwitchDoubleTap = val; }
|
||||
void setSwitchCorner(int c, bool on) { m_SwitchCorners[c] = on; }
|
||||
void setSwitchCornerSize(int val) { m_SwitchCornerSize = val; }
|
||||
void setIgnoreAutoConfigClient(bool on) { m_IgnoreAutoConfigClient = on; }
|
||||
void setEnableDragAndDrop(bool on) { m_EnableDragAndDrop = on; }
|
||||
void setClipboardSharing(bool on) { m_ClipboardSharing = on; }
|
||||
QList<bool>& switchCorners() { return m_SwitchCorners; }
|
||||
HotkeyList& hotkeys() { return m_Hotkeys; }
|
||||
|
||||
void init();
|
||||
int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
|
||||
void init();
|
||||
int adjacentScreenIndex(int idx, int deltaColumn, int deltaRow) const;
|
||||
|
||||
private:
|
||||
bool findScreenName(const QString& name, int& index);
|
||||
bool fixNoServer(const QString& name, int& index);
|
||||
int showAddClientDialog(const QString& clientName);
|
||||
void addToFirstEmptyGrid(const QString& clientName);
|
||||
private:
|
||||
bool findScreenName(const QString& name, int& index);
|
||||
bool fixNoServer(const QString& name, int& index);
|
||||
int showAddClientDialog(const QString& clientName);
|
||||
void addToFirstEmptyGrid(const QString& clientName);
|
||||
|
||||
private:
|
||||
QSettings* m_pSettings;
|
||||
ScreenList m_Screens;
|
||||
int m_NumColumns;
|
||||
int m_NumRows;
|
||||
bool m_HasHeartbeat;
|
||||
int m_Heartbeat;
|
||||
bool m_RelativeMouseMoves;
|
||||
bool m_ScreenSaverSync;
|
||||
bool m_Win32KeepForeground;
|
||||
bool m_HasSwitchDelay;
|
||||
int m_SwitchDelay;
|
||||
bool m_HasSwitchDoubleTap;
|
||||
int m_SwitchDoubleTap;
|
||||
int m_SwitchCornerSize;
|
||||
QList<bool> m_SwitchCorners;
|
||||
HotkeyList m_Hotkeys;
|
||||
QString m_ServerName;
|
||||
bool m_IgnoreAutoConfigClient;
|
||||
bool m_EnableDragAndDrop;
|
||||
bool m_ClipboardSharing;
|
||||
MainWindow* m_pMainWindow;
|
||||
private:
|
||||
QSettings* m_pSettings;
|
||||
ScreenList m_Screens;
|
||||
int m_NumColumns;
|
||||
int m_NumRows;
|
||||
bool m_HasHeartbeat;
|
||||
int m_Heartbeat;
|
||||
bool m_RelativeMouseMoves;
|
||||
bool m_ScreenSaverSync;
|
||||
bool m_Win32KeepForeground;
|
||||
bool m_HasSwitchDelay;
|
||||
int m_SwitchDelay;
|
||||
bool m_HasSwitchDoubleTap;
|
||||
int m_SwitchDoubleTap;
|
||||
int m_SwitchCornerSize;
|
||||
QList<bool> m_SwitchCorners;
|
||||
HotkeyList m_Hotkeys;
|
||||
QString m_ServerName;
|
||||
bool m_IgnoreAutoConfigClient;
|
||||
bool m_EnableDragAndDrop;
|
||||
bool m_ClipboardSharing;
|
||||
MainWindow* m_pMainWindow;
|
||||
};
|
||||
|
||||
QTextStream& operator<<(QTextStream& outStream, const ServerConfig& config);
|
||||
|
||||
enum {
|
||||
kAutoAddScreenOk,
|
||||
kAutoAddScreenManualServer,
|
||||
kAutoAddScreenManualClient,
|
||||
kAutoAddScreenIgnore
|
||||
kAutoAddScreenOk,
|
||||
kAutoAddScreenManualServer,
|
||||
kAutoAddScreenManualClient,
|
||||
kAutoAddScreenIgnore
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,194 +26,194 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, const QString& defaultScreenName) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ServerConfigDialogBase(),
|
||||
m_OrigServerConfig(config),
|
||||
m_ServerConfig(config),
|
||||
m_ScreenSetupModel(serverConfig().screens(), serverConfig().numColumns(), serverConfig().numRows()),
|
||||
m_Message("")
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::ServerConfigDialogBase(),
|
||||
m_OrigServerConfig(config),
|
||||
m_ServerConfig(config),
|
||||
m_ScreenSetupModel(serverConfig().screens(), serverConfig().numColumns(), serverConfig().numRows()),
|
||||
m_Message("")
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
|
||||
m_pSpinBoxHeartbeat->setValue(serverConfig().heartbeat());
|
||||
m_pCheckBoxHeartbeat->setChecked(serverConfig().hasHeartbeat());
|
||||
m_pSpinBoxHeartbeat->setValue(serverConfig().heartbeat());
|
||||
|
||||
m_pCheckBoxRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
|
||||
m_pCheckBoxScreenSaverSync->setChecked(serverConfig().screenSaverSync());
|
||||
m_pCheckBoxWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
|
||||
m_pCheckBoxRelativeMouseMoves->setChecked(serverConfig().relativeMouseMoves());
|
||||
m_pCheckBoxScreenSaverSync->setChecked(serverConfig().screenSaverSync());
|
||||
m_pCheckBoxWin32KeepForeground->setChecked(serverConfig().win32KeepForeground());
|
||||
|
||||
m_pCheckBoxSwitchDelay->setChecked(serverConfig().hasSwitchDelay());
|
||||
m_pSpinBoxSwitchDelay->setValue(serverConfig().switchDelay());
|
||||
m_pCheckBoxSwitchDelay->setChecked(serverConfig().hasSwitchDelay());
|
||||
m_pSpinBoxSwitchDelay->setValue(serverConfig().switchDelay());
|
||||
|
||||
m_pCheckBoxSwitchDoubleTap->setChecked(serverConfig().hasSwitchDoubleTap());
|
||||
m_pSpinBoxSwitchDoubleTap->setValue(serverConfig().switchDoubleTap());
|
||||
m_pCheckBoxSwitchDoubleTap->setChecked(serverConfig().hasSwitchDoubleTap());
|
||||
m_pSpinBoxSwitchDoubleTap->setValue(serverConfig().switchDoubleTap());
|
||||
|
||||
m_pCheckBoxCornerTopLeft->setChecked(serverConfig().switchCorner(BaseConfig::TopLeft));
|
||||
m_pCheckBoxCornerTopRight->setChecked(serverConfig().switchCorner(BaseConfig::TopRight));
|
||||
m_pCheckBoxCornerBottomLeft->setChecked(serverConfig().switchCorner(BaseConfig::BottomLeft));
|
||||
m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(BaseConfig::BottomRight));
|
||||
m_pSpinBoxSwitchCornerSize->setValue(serverConfig().switchCornerSize());
|
||||
m_pCheckBoxCornerTopLeft->setChecked(serverConfig().switchCorner(BaseConfig::TopLeft));
|
||||
m_pCheckBoxCornerTopRight->setChecked(serverConfig().switchCorner(BaseConfig::TopRight));
|
||||
m_pCheckBoxCornerBottomLeft->setChecked(serverConfig().switchCorner(BaseConfig::BottomLeft));
|
||||
m_pCheckBoxCornerBottomRight->setChecked(serverConfig().switchCorner(BaseConfig::BottomRight));
|
||||
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())
|
||||
m_pListHotkeys->addItem(hotkey.text());
|
||||
foreach(const Hotkey& hotkey, serverConfig().hotkeys())
|
||||
m_pListHotkeys->addItem(hotkey.text());
|
||||
|
||||
m_pScreenSetupView->setModel(&m_ScreenSetupModel);
|
||||
m_pScreenSetupView->setModel(&m_ScreenSetupModel);
|
||||
|
||||
if (serverConfig().numScreens() == 0)
|
||||
model().screen(serverConfig().numColumns() / 2, serverConfig().numRows() / 2) = Screen(defaultScreenName);
|
||||
if (serverConfig().numScreens() == 0)
|
||||
model().screen(serverConfig().numColumns() / 2, serverConfig().numRows() / 2) = Screen(defaultScreenName);
|
||||
}
|
||||
|
||||
void ServerConfigDialog::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::show();
|
||||
QDialog::show();
|
||||
|
||||
if (!m_Message.isEmpty())
|
||||
{
|
||||
// TODO: ideally this massage box should pop up after the dialog is shown
|
||||
QMessageBox::information(this, tr("Configure server"), m_Message);
|
||||
}
|
||||
if (!m_Message.isEmpty())
|
||||
{
|
||||
// TODO: ideally this massage box should pop up after the dialog is shown
|
||||
QMessageBox::information(this, tr("Configure server"), m_Message);
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfigDialog::accept()
|
||||
{
|
||||
serverConfig().haveHeartbeat(m_pCheckBoxHeartbeat->isChecked());
|
||||
serverConfig().setHeartbeat(m_pSpinBoxHeartbeat->value());
|
||||
serverConfig().haveHeartbeat(m_pCheckBoxHeartbeat->isChecked());
|
||||
serverConfig().setHeartbeat(m_pSpinBoxHeartbeat->value());
|
||||
|
||||
serverConfig().setRelativeMouseMoves(m_pCheckBoxRelativeMouseMoves->isChecked());
|
||||
serverConfig().setScreenSaverSync(m_pCheckBoxScreenSaverSync->isChecked());
|
||||
serverConfig().setWin32KeepForeground(m_pCheckBoxWin32KeepForeground->isChecked());
|
||||
serverConfig().setRelativeMouseMoves(m_pCheckBoxRelativeMouseMoves->isChecked());
|
||||
serverConfig().setScreenSaverSync(m_pCheckBoxScreenSaverSync->isChecked());
|
||||
serverConfig().setWin32KeepForeground(m_pCheckBoxWin32KeepForeground->isChecked());
|
||||
|
||||
serverConfig().haveSwitchDelay(m_pCheckBoxSwitchDelay->isChecked());
|
||||
serverConfig().setSwitchDelay(m_pSpinBoxSwitchDelay->value());
|
||||
serverConfig().haveSwitchDelay(m_pCheckBoxSwitchDelay->isChecked());
|
||||
serverConfig().setSwitchDelay(m_pSpinBoxSwitchDelay->value());
|
||||
|
||||
serverConfig().haveSwitchDoubleTap(m_pCheckBoxSwitchDoubleTap->isChecked());
|
||||
serverConfig().setSwitchDoubleTap(m_pSpinBoxSwitchDoubleTap->value());
|
||||
serverConfig().haveSwitchDoubleTap(m_pCheckBoxSwitchDoubleTap->isChecked());
|
||||
serverConfig().setSwitchDoubleTap(m_pSpinBoxSwitchDoubleTap->value());
|
||||
|
||||
serverConfig().setSwitchCorner(BaseConfig::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
||||
serverConfig().setSwitchCorner(BaseConfig::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
||||
serverConfig().setSwitchCorner(BaseConfig::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
||||
serverConfig().setSwitchCorner(BaseConfig::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
||||
serverConfig().setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
||||
serverConfig().setIgnoreAutoConfigClient(m_pCheckBoxIgnoreAutoConfigClient->isChecked());
|
||||
serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked());
|
||||
serverConfig().setClipboardSharing(m_pCheckBoxEnableClipboard->isChecked());
|
||||
serverConfig().setSwitchCorner(BaseConfig::TopLeft, m_pCheckBoxCornerTopLeft->isChecked());
|
||||
serverConfig().setSwitchCorner(BaseConfig::TopRight, m_pCheckBoxCornerTopRight->isChecked());
|
||||
serverConfig().setSwitchCorner(BaseConfig::BottomLeft, m_pCheckBoxCornerBottomLeft->isChecked());
|
||||
serverConfig().setSwitchCorner(BaseConfig::BottomRight, m_pCheckBoxCornerBottomRight->isChecked());
|
||||
serverConfig().setSwitchCornerSize(m_pSpinBoxSwitchCornerSize->value());
|
||||
serverConfig().setIgnoreAutoConfigClient(m_pCheckBoxIgnoreAutoConfigClient->isChecked());
|
||||
serverConfig().setEnableDragAndDrop(m_pCheckBoxEnableDragAndDrop->isChecked());
|
||||
serverConfig().setClipboardSharing(m_pCheckBoxEnableClipboard->isChecked());
|
||||
|
||||
// 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.
|
||||
setOrigServerConfig(serverConfig());
|
||||
// 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.
|
||||
setOrigServerConfig(serverConfig());
|
||||
|
||||
QDialog::accept();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pButtonNewHotkey_clicked()
|
||||
{
|
||||
Hotkey hotkey;
|
||||
HotkeyDialog dlg(this, hotkey);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
serverConfig().hotkeys().append(hotkey);
|
||||
m_pListHotkeys->addItem(hotkey.text());
|
||||
}
|
||||
Hotkey hotkey;
|
||||
HotkeyDialog dlg(this, hotkey);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
serverConfig().hotkeys().append(hotkey);
|
||||
m_pListHotkeys->addItem(hotkey.text());
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pButtonEditHotkey_clicked()
|
||||
{
|
||||
int idx = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||
HotkeyDialog dlg(this, hotkey);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
m_pListHotkeys->currentItem()->setText(hotkey.text());
|
||||
int idx = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||
HotkeyDialog dlg(this, hotkey);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
m_pListHotkeys->currentItem()->setText(hotkey.text());
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pButtonRemoveHotkey_clicked()
|
||||
{
|
||||
int idx = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
serverConfig().hotkeys().removeAt(idx);
|
||||
m_pListActions->clear();
|
||||
delete m_pListHotkeys->item(idx);
|
||||
int idx = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
serverConfig().hotkeys().removeAt(idx);
|
||||
m_pListActions->clear();
|
||||
delete m_pListHotkeys->item(idx);
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pListHotkeys_itemSelectionChanged()
|
||||
{
|
||||
bool itemsSelected = !m_pListHotkeys->selectedItems().isEmpty();
|
||||
m_pButtonEditHotkey->setEnabled(itemsSelected);
|
||||
m_pButtonRemoveHotkey->setEnabled(itemsSelected);
|
||||
m_pButtonNewAction->setEnabled(itemsSelected);
|
||||
bool itemsSelected = !m_pListHotkeys->selectedItems().isEmpty();
|
||||
m_pButtonEditHotkey->setEnabled(itemsSelected);
|
||||
m_pButtonRemoveHotkey->setEnabled(itemsSelected);
|
||||
m_pButtonNewAction->setEnabled(itemsSelected);
|
||||
|
||||
if (itemsSelected && serverConfig().hotkeys().size() > 0)
|
||||
{
|
||||
m_pListActions->clear();
|
||||
if (itemsSelected && serverConfig().hotkeys().size() > 0)
|
||||
{
|
||||
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
|
||||
// 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.
|
||||
// The while() is a generalized workaround for all that and shouldn't be required.
|
||||
while (idx >= 0 && idx >= serverConfig().hotkeys().size())
|
||||
idx--;
|
||||
// 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
|
||||
// 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.
|
||||
while (idx >= 0 && idx >= serverConfig().hotkeys().size())
|
||||
idx--;
|
||||
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
|
||||
const Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||
foreach(const Action& action, hotkey.actions())
|
||||
m_pListActions->addItem(action.text());
|
||||
}
|
||||
const Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||
foreach(const Action& action, hotkey.actions())
|
||||
m_pListActions->addItem(action.text());
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pButtonNewAction_clicked()
|
||||
{
|
||||
int idx = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||
int idx = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idx >= 0 && idx < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idx];
|
||||
|
||||
Action action;
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
hotkey.actions().append(action);
|
||||
m_pListActions->addItem(action.text());
|
||||
}
|
||||
Action action;
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
hotkey.actions().append(action);
|
||||
m_pListActions->addItem(action.text());
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pButtonEditAction_clicked()
|
||||
{
|
||||
int idxHotkey = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
||||
int idxHotkey = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
||||
|
||||
int idxAction = m_pListActions->currentRow();
|
||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||
Action& action = hotkey.actions()[idxAction];
|
||||
int idxAction = m_pListActions->currentRow();
|
||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||
Action& action = hotkey.actions()[idxAction];
|
||||
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
m_pListActions->currentItem()->setText(action.text());
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
m_pListActions->currentItem()->setText(action.text());
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pButtonRemoveAction_clicked()
|
||||
{
|
||||
int idxHotkey = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
||||
int idxHotkey = m_pListHotkeys->currentRow();
|
||||
Q_ASSERT(idxHotkey >= 0 && idxHotkey < serverConfig().hotkeys().size());
|
||||
Hotkey& hotkey = serverConfig().hotkeys()[idxHotkey];
|
||||
|
||||
int idxAction = m_pListActions->currentRow();
|
||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||
int idxAction = m_pListActions->currentRow();
|
||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||
|
||||
hotkey.actions().removeAt(idxAction);
|
||||
delete m_pListActions->currentItem();
|
||||
hotkey.actions().removeAt(idxAction);
|
||||
delete m_pListActions->currentItem();
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pListActions_itemSelectionChanged()
|
||||
{
|
||||
m_pButtonEditAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
||||
m_pButtonRemoveAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
||||
m_pButtonEditAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
||||
m_pButtonRemoveAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
|
||||
}
|
||||
|
|
|
@ -29,37 +29,37 @@
|
|||
|
||||
class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ServerConfigDialog(QWidget* parent, ServerConfig& config, const QString& defaultScreenName);
|
||||
public:
|
||||
ServerConfigDialog(QWidget* parent, ServerConfig& config, const QString& defaultScreenName);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
void showEvent(QShowEvent* event);
|
||||
void message(const QString& message) { m_Message = message; }
|
||||
public slots:
|
||||
void accept();
|
||||
void showEvent(QShowEvent* event);
|
||||
void message(const QString& message) { m_Message = message; }
|
||||
|
||||
protected slots:
|
||||
void on_m_pButtonNewHotkey_clicked();
|
||||
void on_m_pListHotkeys_itemSelectionChanged();
|
||||
void on_m_pButtonEditHotkey_clicked();
|
||||
void on_m_pButtonRemoveHotkey_clicked();
|
||||
protected slots:
|
||||
void on_m_pButtonNewHotkey_clicked();
|
||||
void on_m_pListHotkeys_itemSelectionChanged();
|
||||
void on_m_pButtonEditHotkey_clicked();
|
||||
void on_m_pButtonRemoveHotkey_clicked();
|
||||
|
||||
void on_m_pButtonNewAction_clicked();
|
||||
void on_m_pListActions_itemSelectionChanged();
|
||||
void on_m_pButtonEditAction_clicked();
|
||||
void on_m_pButtonRemoveAction_clicked();
|
||||
void on_m_pButtonNewAction_clicked();
|
||||
void on_m_pListActions_itemSelectionChanged();
|
||||
void on_m_pButtonEditAction_clicked();
|
||||
void on_m_pButtonRemoveAction_clicked();
|
||||
|
||||
protected:
|
||||
ServerConfig& serverConfig() { return m_ServerConfig; }
|
||||
void setOrigServerConfig(const ServerConfig& s) { m_OrigServerConfig = s; }
|
||||
ScreenSetupModel& model() { return m_ScreenSetupModel; }
|
||||
protected:
|
||||
ServerConfig& serverConfig() { return m_ServerConfig; }
|
||||
void setOrigServerConfig(const ServerConfig& s) { m_OrigServerConfig = s; }
|
||||
ScreenSetupModel& model() { return m_ScreenSetupModel; }
|
||||
|
||||
private:
|
||||
ServerConfig& m_OrigServerConfig;
|
||||
ServerConfig m_ServerConfig;
|
||||
ScreenSetupModel m_ScreenSetupModel;
|
||||
QString m_Message;
|
||||
private:
|
||||
ServerConfig& m_OrigServerConfig;
|
||||
ServerConfig m_ServerConfig;
|
||||
ScreenSetupModel m_ScreenSetupModel;
|
||||
QString m_Message;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,120 +36,120 @@
|
|||
static const char networkSecurity[] = "ns";
|
||||
|
||||
SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::SettingsDialogBase(),
|
||||
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
|
||||
Ui::SettingsDialogBase(),
|
||||
m_appConfig(config)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
||||
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
||||
|
||||
m_pLineEditScreenName->setText(appConfig().screenName());
|
||||
m_pSpinBoxPort->setValue(appConfig().port());
|
||||
m_pLineEditInterface->setText(appConfig().networkInterface());
|
||||
m_pComboLogLevel->setCurrentIndex(appConfig().logLevel());
|
||||
m_pCheckBoxLogToFile->setChecked(appConfig().logToFile());
|
||||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
||||
m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide());
|
||||
m_pLineEditScreenName->setText(appConfig().screenName());
|
||||
m_pSpinBoxPort->setValue(appConfig().port());
|
||||
m_pLineEditInterface->setText(appConfig().networkInterface());
|
||||
m_pComboLogLevel->setCurrentIndex(appConfig().logLevel());
|
||||
m_pCheckBoxLogToFile->setChecked(appConfig().logToFile());
|
||||
m_pLineEditLogFilename->setText(appConfig().logFilename());
|
||||
setIndexFromItemData(m_pComboLanguage, appConfig().language());
|
||||
m_pCheckBoxAutoHide->setChecked(appConfig().getAutoHide());
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
m_pComboElevate->setCurrentIndex(static_cast<int>(appConfig().elevateMode()));
|
||||
|
||||
m_pCheckBoxAutoHide->hide();
|
||||
m_pCheckBoxAutoHide->hide();
|
||||
#else
|
||||
// elevate checkbox is only useful on ms windows.
|
||||
m_pLabelElevate->hide();
|
||||
m_pComboElevate->hide();
|
||||
// elevate checkbox is only useful on ms windows.
|
||||
m_pLabelElevate->hide();
|
||||
m_pComboElevate->hide();
|
||||
#endif
|
||||
|
||||
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled());
|
||||
m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.edition() == kPro);
|
||||
m_pCheckBoxEnableCrypto->setChecked(m_appConfig.getCryptoEnabled());
|
||||
m_pCheckBoxEnableCrypto->setEnabled(m_appConfig.edition() == kPro);
|
||||
}
|
||||
|
||||
void SettingsDialog::accept()
|
||||
{
|
||||
appConfig().setScreenName(m_pLineEditScreenName->text());
|
||||
appConfig().setPort(m_pSpinBoxPort->value());
|
||||
appConfig().setNetworkInterface(m_pLineEditInterface->text());
|
||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||
appConfig().setScreenName(m_pLineEditScreenName->text());
|
||||
appConfig().setPort(m_pSpinBoxPort->value());
|
||||
appConfig().setNetworkInterface(m_pLineEditInterface->text());
|
||||
appConfig().setLogLevel(m_pComboLogLevel->currentIndex());
|
||||
appConfig().setLogToFile(m_pCheckBoxLogToFile->isChecked());
|
||||
appConfig().setLogFilename(m_pLineEditLogFilename->text());
|
||||
appConfig().setLanguage(m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString());
|
||||
appConfig().setElevateMode(static_cast<ElevateMode>(m_pComboElevate->currentIndex()));
|
||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||
appConfig().saveSettings();
|
||||
QDialog::accept();
|
||||
appConfig().setAutoHide(m_pCheckBoxAutoHide->isChecked());
|
||||
appConfig().saveSettings();
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SettingsDialog::reject()
|
||||
{
|
||||
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
||||
QSynergyApplication::getInstance()->switchTranslator(appConfig().language());
|
||||
}
|
||||
if (appConfig().language() != m_pComboLanguage->itemData(m_pComboLanguage->currentIndex()).toString()) {
|
||||
QSynergyApplication::getInstance()->switchTranslator(appConfig().language());
|
||||
}
|
||||
|
||||
QDialog::reject();
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void SettingsDialog::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event != 0)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
int logLevelIndex = m_pComboLogLevel->currentIndex();
|
||||
if (event != 0)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
int logLevelIndex = m_pComboLogLevel->currentIndex();
|
||||
|
||||
m_pComboLanguage->blockSignals(true);
|
||||
retranslateUi(this);
|
||||
m_pComboLanguage->blockSignals(false);
|
||||
m_pComboLanguage->blockSignals(true);
|
||||
retranslateUi(this);
|
||||
m_pComboLanguage->blockSignals(false);
|
||||
|
||||
m_pComboLogLevel->setCurrentIndex(logLevelIndex);
|
||||
break;
|
||||
}
|
||||
m_pComboLogLevel->setCurrentIndex(logLevelIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
QDialog::changeEvent(event);
|
||||
}
|
||||
}
|
||||
default:
|
||||
QDialog::changeEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::on_m_pCheckBoxLogToFile_stateChanged(int i)
|
||||
{
|
||||
bool checked = i == 2;
|
||||
bool checked = i == 2;
|
||||
|
||||
m_pLineEditLogFilename->setEnabled(checked);
|
||||
m_pButtonBrowseLog->setEnabled(checked);
|
||||
m_pLineEditLogFilename->setEnabled(checked);
|
||||
m_pButtonBrowseLog->setEnabled(checked);
|
||||
}
|
||||
|
||||
void SettingsDialog::on_m_pButtonBrowseLog_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this, tr("Save log file to..."),
|
||||
m_pLineEditLogFilename->text(),
|
||||
"Logs (*.log *.txt)");
|
||||
QString fileName = QFileDialog::getSaveFileName(
|
||||
this, tr("Save log file to..."),
|
||||
m_pLineEditLogFilename->text(),
|
||||
"Logs (*.log *.txt)");
|
||||
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
m_pLineEditLogFilename->setText(fileName);
|
||||
}
|
||||
if (!fileName.isEmpty())
|
||||
{
|
||||
m_pLineEditLogFilename->setText(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::on_m_pComboLanguage_currentIndexChanged(int index)
|
||||
{
|
||||
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
||||
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
||||
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
||||
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
||||
}
|
||||
|
||||
void SettingsDialog::on_m_pCheckBoxEnableCrypto_toggled(bool checked)
|
||||
{
|
||||
m_appConfig.setCryptoEnabled(checked);
|
||||
m_appConfig.saveSettings();
|
||||
if (checked) {
|
||||
SslCertificate sslCertificate;
|
||||
sslCertificate.generateCertificate();
|
||||
MainWindow& mainWindow = dynamic_cast<MainWindow&> (*this->parent());
|
||||
mainWindow.updateLocalFingerprint();
|
||||
}
|
||||
m_appConfig.setCryptoEnabled(checked);
|
||||
m_appConfig.saveSettings();
|
||||
if (checked) {
|
||||
SslCertificate sslCertificate;
|
||||
sslCertificate.generateCertificate();
|
||||
MainWindow& mainWindow = dynamic_cast<MainWindow&> (*this->parent());
|
||||
mainWindow.updateLocalFingerprint();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,29 +29,29 @@ class AppConfig;
|
|||
|
||||
class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsDialog(QWidget* parent, AppConfig& config);
|
||||
static QString browseForSynergyc(QWidget* parent, const QString& programDir, const QString& synergycName);
|
||||
static QString browseForSynergys(QWidget* parent, const QString& programDir, const QString& synergysName);
|
||||
public:
|
||||
SettingsDialog(QWidget* parent, AppConfig& config);
|
||||
static QString browseForSynergyc(QWidget* parent, const QString& programDir, const QString& synergycName);
|
||||
static QString browseForSynergys(QWidget* parent, const QString& programDir, const QString& synergysName);
|
||||
|
||||
protected:
|
||||
void accept();
|
||||
void reject();
|
||||
void changeEvent(QEvent* event);
|
||||
AppConfig& appConfig() { return m_appConfig; }
|
||||
protected:
|
||||
void accept();
|
||||
void reject();
|
||||
void changeEvent(QEvent* event);
|
||||
AppConfig& appConfig() { return m_appConfig; }
|
||||
|
||||
private:
|
||||
AppConfig& m_appConfig;
|
||||
SynergyLocale m_Locale;
|
||||
CoreInterface m_CoreInterface;
|
||||
private:
|
||||
AppConfig& m_appConfig;
|
||||
SynergyLocale m_Locale;
|
||||
CoreInterface m_CoreInterface;
|
||||
|
||||
private slots:
|
||||
void on_m_pCheckBoxEnableCrypto_toggled(bool checked);
|
||||
void on_m_pComboLanguage_currentIndexChanged(int index);
|
||||
void on_m_pCheckBoxLogToFile_stateChanged(int );
|
||||
void on_m_pButtonBrowseLog_clicked();
|
||||
private slots:
|
||||
void on_m_pCheckBoxEnableCrypto_toggled(bool checked);
|
||||
void on_m_pComboLanguage_currentIndexChanged(int index);
|
||||
void on_m_pCheckBoxLogToFile_stateChanged(int );
|
||||
void on_m_pButtonBrowseLog_clicked();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,34 +27,34 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
SetupWizard::SetupWizard(MainWindow& mainWindow, bool startMain) :
|
||||
m_MainWindow(mainWindow),
|
||||
m_StartMain(startMain)
|
||||
m_MainWindow(mainWindow),
|
||||
m_StartMain(startMain)
|
||||
{
|
||||
setupUi(this);
|
||||
setupUi(this);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
||||
// the mac style needs a little more room because of the
|
||||
// graphic on the left.
|
||||
resize(600, 500);
|
||||
setMinimumSize(size());
|
||||
// the mac style needs a little more room because of the
|
||||
// graphic on the left.
|
||||
resize(600, 500);
|
||||
setMinimumSize(size());
|
||||
|
||||
#elif defined(Q_OS_WIN)
|
||||
|
||||
// when areo is disabled on windows, the next/back buttons
|
||||
// are hidden (must be a qt bug) -- resizing the window
|
||||
// to +1 of the original height seems to fix this.
|
||||
// NOTE: calling setMinimumSize after this will break
|
||||
// it again, so don't do that.
|
||||
resize(size().width(), size().height() + 1);
|
||||
// when areo is disabled on windows, the next/back buttons
|
||||
// are hidden (must be a qt bug) -- resizing the window
|
||||
// to +1 of the original height seems to fix this.
|
||||
// NOTE: calling setMinimumSize after this will break
|
||||
// it again, so don't do that.
|
||||
resize(size().width(), size().height() + 1);
|
||||
|
||||
#endif
|
||||
|
||||
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_pServerRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupServer, SLOT(setChecked(bool)));
|
||||
connect(m_pClientRadioButton, SIGNAL(toggled(bool)), m_MainWindow.m_pGroupClient, SLOT(setChecked(bool)));
|
||||
|
||||
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
||||
setIndexFromItemData(m_pComboLanguage, m_MainWindow.appConfig().language());
|
||||
m_Locale.fillLanguageComboBox(m_pComboLanguage);
|
||||
setIndexFromItemData(m_pComboLanguage, m_MainWindow.appConfig().language());
|
||||
}
|
||||
|
||||
SetupWizard::~SetupWizard()
|
||||
|
@ -62,91 +62,91 @@ SetupWizard::~SetupWizard()
|
|||
}
|
||||
|
||||
bool SetupWizard::validateCurrentPage()
|
||||
{
|
||||
QMessageBox message;
|
||||
message.setWindowTitle(tr("Setup Synergy"));
|
||||
message.setIcon(QMessageBox::Information);
|
||||
{
|
||||
QMessageBox message;
|
||||
message.setWindowTitle(tr("Setup Synergy"));
|
||||
message.setIcon(QMessageBox::Information);
|
||||
|
||||
if (currentPage() == m_pNodePage)
|
||||
{
|
||||
bool result = m_pClientRadioButton->isChecked() ||
|
||||
m_pServerRadioButton->isChecked();
|
||||
if (currentPage() == m_pNodePage)
|
||||
{
|
||||
bool result = m_pClientRadioButton->isChecked() ||
|
||||
m_pServerRadioButton->isChecked();
|
||||
|
||||
if (!result)
|
||||
{
|
||||
message.setText(tr("Please select an option."));
|
||||
message.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!result)
|
||||
{
|
||||
message.setText(tr("Please select an option."));
|
||||
message.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetupWizard::changeEvent(QEvent* event)
|
||||
{
|
||||
if (event != 0)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
m_pComboLanguage->blockSignals(true);
|
||||
retranslateUi(this);
|
||||
m_pComboLanguage->blockSignals(false);
|
||||
break;
|
||||
}
|
||||
if (event != 0)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
{
|
||||
m_pComboLanguage->blockSignals(true);
|
||||
retranslateUi(this);
|
||||
m_pComboLanguage->blockSignals(false);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
QWizard::changeEvent(event);
|
||||
}
|
||||
}
|
||||
default:
|
||||
QWizard::changeEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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.saveSettings();
|
||||
appConfig.setWizardHasRun();
|
||||
appConfig.saveSettings();
|
||||
|
||||
QSettings& settings = m_MainWindow.settings();
|
||||
if (m_pServerRadioButton->isChecked())
|
||||
{
|
||||
settings.setValue("groupServerChecked", true);
|
||||
settings.setValue("groupClientChecked", false);
|
||||
}
|
||||
if (m_pClientRadioButton->isChecked())
|
||||
{
|
||||
settings.setValue("groupClientChecked", true);
|
||||
settings.setValue("groupServerChecked", false);
|
||||
}
|
||||
QSettings& settings = m_MainWindow.settings();
|
||||
if (m_pServerRadioButton->isChecked())
|
||||
{
|
||||
settings.setValue("groupServerChecked", true);
|
||||
settings.setValue("groupClientChecked", false);
|
||||
}
|
||||
if (m_pClientRadioButton->isChecked())
|
||||
{
|
||||
settings.setValue("groupClientChecked", true);
|
||||
settings.setValue("groupServerChecked", false);
|
||||
}
|
||||
|
||||
QWizard::accept();
|
||||
QWizard::accept();
|
||||
|
||||
if (m_StartMain)
|
||||
{
|
||||
m_MainWindow.updateZeroconfService();
|
||||
m_MainWindow.open();
|
||||
}
|
||||
if (m_StartMain)
|
||||
{
|
||||
m_MainWindow.updateZeroconfService();
|
||||
m_MainWindow.open();
|
||||
}
|
||||
}
|
||||
|
||||
void SetupWizard::reject()
|
||||
{
|
||||
QSynergyApplication::getInstance()->switchTranslator(m_MainWindow.appConfig().language());
|
||||
QSynergyApplication::getInstance()->switchTranslator(m_MainWindow.appConfig().language());
|
||||
|
||||
if (m_StartMain)
|
||||
{
|
||||
m_MainWindow.open();
|
||||
}
|
||||
if (m_StartMain)
|
||||
{
|
||||
m_MainWindow.open();
|
||||
}
|
||||
|
||||
QWizard::reject();
|
||||
QWizard::reject();
|
||||
}
|
||||
|
||||
void SetupWizard::on_m_pComboLanguage_currentIndexChanged(int index)
|
||||
{
|
||||
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
||||
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
||||
QString ietfCode = m_pComboLanguage->itemData(index).toString();
|
||||
QSynergyApplication::getInstance()->switchTranslator(ietfCode);
|
||||
}
|
||||
|
|
|
@ -27,27 +27,27 @@ class MainWindow;
|
|||
|
||||
class SetupWizard : public QWizard, public Ui::SetupWizardBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {
|
||||
kMaximiumLoginAttemps = 3
|
||||
};
|
||||
enum {
|
||||
kMaximiumLoginAttemps = 3
|
||||
};
|
||||
|
||||
public:
|
||||
SetupWizard(MainWindow& mainWindow, bool startMain);
|
||||
virtual ~SetupWizard();
|
||||
bool validateCurrentPage();
|
||||
SetupWizard(MainWindow& mainWindow, bool startMain);
|
||||
virtual ~SetupWizard();
|
||||
bool validateCurrentPage();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent* event);
|
||||
void accept();
|
||||
void reject();
|
||||
void changeEvent(QEvent* event);
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
private:
|
||||
MainWindow& m_MainWindow;
|
||||
bool m_StartMain;
|
||||
SynergyLocale m_Locale;
|
||||
MainWindow& m_MainWindow;
|
||||
bool m_StartMain;
|
||||
SynergyLocale m_Locale;
|
||||
|
||||
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
|
||||
|
||||
SslCertificate::SslCertificate(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent)
|
||||
{
|
||||
m_ProfileDir = m_CoreInterface.getProfileDir();
|
||||
if (m_ProfileDir.isEmpty()) {
|
||||
emit error(tr("Failed to get profile directory."));
|
||||
}
|
||||
m_ProfileDir = m_CoreInterface.getProfileDir();
|
||||
if (m_ProfileDir.isEmpty()) {
|
||||
emit error(tr("Failed to get profile directory."));
|
||||
}
|
||||
}
|
||||
|
||||
bool SslCertificate::runTool(const QStringList& args)
|
||||
{
|
||||
QString program;
|
||||
QString program;
|
||||
#if defined(Q_OS_WIN)
|
||||
program = QCoreApplication::applicationDirPath();
|
||||
program.append("\\").append(kWinOpenSslBinary);
|
||||
program = QCoreApplication::applicationDirPath();
|
||||
program.append("\\").append(kWinOpenSslBinary);
|
||||
#else
|
||||
program = kUnixOpenSslCommand;
|
||||
program = kUnixOpenSslCommand;
|
||||
#endif
|
||||
|
||||
|
||||
QStringList environment;
|
||||
QStringList environment;
|
||||
#if defined(Q_OS_WIN)
|
||||
environment << QString("OPENSSL_CONF=%1\\%2")
|
||||
.arg(QCoreApplication::applicationDirPath())
|
||||
.arg(kConfigFile);
|
||||
environment << QString("OPENSSL_CONF=%1\\%2")
|
||||
.arg(QCoreApplication::applicationDirPath())
|
||||
.arg(kConfigFile);
|
||||
#endif
|
||||
|
||||
QProcess process;
|
||||
process.setEnvironment(environment);
|
||||
process.start(program, args);
|
||||
QProcess process;
|
||||
process.setEnvironment(environment);
|
||||
process.start(program, args);
|
||||
|
||||
bool success = process.waitForStarted();
|
||||
bool success = process.waitForStarted();
|
||||
|
||||
QString standardError;
|
||||
if (success && process.waitForFinished())
|
||||
{
|
||||
m_ToolOutput = process.readAllStandardOutput().trimmed();
|
||||
standardError = process.readAllStandardError().trimmed();
|
||||
}
|
||||
QString standardError;
|
||||
if (success && process.waitForFinished())
|
||||
{
|
||||
m_ToolOutput = process.readAllStandardOutput().trimmed();
|
||||
standardError = process.readAllStandardError().trimmed();
|
||||
}
|
||||
|
||||
int code = process.exitCode();
|
||||
if (!success || code != 0)
|
||||
{
|
||||
emit error(
|
||||
QString("SSL tool failed: %1\n\nCode: %2\nError: %3")
|
||||
.arg(program)
|
||||
.arg(process.exitCode())
|
||||
.arg(standardError.isEmpty() ? "Unknown" : standardError));
|
||||
return false;
|
||||
}
|
||||
int code = process.exitCode();
|
||||
if (!success || code != 0)
|
||||
{
|
||||
emit error(
|
||||
QString("SSL tool failed: %1\n\nCode: %2\nError: %3")
|
||||
.arg(program)
|
||||
.arg(process.exitCode())
|
||||
.arg(standardError.isEmpty() ? "Unknown" : standardError));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SslCertificate::generateCertificate()
|
||||
{
|
||||
QString sslDirPath = QString("%1%2%3")
|
||||
.arg(m_ProfileDir)
|
||||
.arg(QDir::separator())
|
||||
.arg(kSslDir);
|
||||
QString sslDirPath = QString("%1%2%3")
|
||||
.arg(m_ProfileDir)
|
||||
.arg(QDir::separator())
|
||||
.arg(kSslDir);
|
||||
|
||||
QString filename = QString("%1%2%3")
|
||||
.arg(sslDirPath)
|
||||
.arg(QDir::separator())
|
||||
.arg(kCertificateFilename);
|
||||
QString filename = QString("%1%2%3")
|
||||
.arg(sslDirPath)
|
||||
.arg(QDir::separator())
|
||||
.arg(kCertificateFilename);
|
||||
|
||||
QFile file(filename);
|
||||
if (!file.exists()) {
|
||||
QStringList arguments;
|
||||
QFile file(filename);
|
||||
if (!file.exists()) {
|
||||
QStringList arguments;
|
||||
|
||||
// self signed certificate
|
||||
arguments.append("req");
|
||||
arguments.append("-x509");
|
||||
arguments.append("-nodes");
|
||||
// self signed certificate
|
||||
arguments.append("req");
|
||||
arguments.append("-x509");
|
||||
arguments.append("-nodes");
|
||||
|
||||
// valide duration
|
||||
arguments.append("-days");
|
||||
arguments.append(kCertificateLifetime);
|
||||
// valide duration
|
||||
arguments.append("-days");
|
||||
arguments.append(kCertificateLifetime);
|
||||
|
||||
// subject information
|
||||
arguments.append("-subj");
|
||||
// subject information
|
||||
arguments.append("-subj");
|
||||
|
||||
QString subInfo(kCertificateSubjectInfo);
|
||||
arguments.append(subInfo);
|
||||
QString subInfo(kCertificateSubjectInfo);
|
||||
arguments.append(subInfo);
|
||||
|
||||
// private key
|
||||
arguments.append("-newkey");
|
||||
arguments.append("rsa:1024");
|
||||
// private key
|
||||
arguments.append("-newkey");
|
||||
arguments.append("rsa:1024");
|
||||
|
||||
QDir sslDir(sslDirPath);
|
||||
if (!sslDir.exists()) {
|
||||
sslDir.mkpath(".");
|
||||
}
|
||||
QDir sslDir(sslDirPath);
|
||||
if (!sslDir.exists()) {
|
||||
sslDir.mkpath(".");
|
||||
}
|
||||
|
||||
// key output filename
|
||||
arguments.append("-keyout");
|
||||
arguments.append(filename);
|
||||
// key output filename
|
||||
arguments.append("-keyout");
|
||||
arguments.append(filename);
|
||||
|
||||
// certificate output filename
|
||||
arguments.append("-out");
|
||||
arguments.append(filename);
|
||||
// certificate output filename
|
||||
arguments.append("-out");
|
||||
arguments.append(filename);
|
||||
|
||||
if (!runTool(arguments)) {
|
||||
return;
|
||||
}
|
||||
if (!runTool(arguments)) {
|
||||
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)
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments.append("x509");
|
||||
arguments.append("-fingerprint");
|
||||
arguments.append("-sha1");
|
||||
arguments.append("-noout");
|
||||
arguments.append("-in");
|
||||
arguments.append(certificateFilename);
|
||||
QStringList arguments;
|
||||
arguments.append("x509");
|
||||
arguments.append("-fingerprint");
|
||||
arguments.append("-sha1");
|
||||
arguments.append("-noout");
|
||||
arguments.append("-in");
|
||||
arguments.append(certificateFilename);
|
||||
|
||||
if (!runTool(arguments)) {
|
||||
return;
|
||||
}
|
||||
if (!runTool(arguments)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// find the fingerprint from the tool output
|
||||
int i = m_ToolOutput.indexOf("=");
|
||||
if (i != -1) {
|
||||
i++;
|
||||
QString fingerprint = m_ToolOutput.mid(
|
||||
i, m_ToolOutput.size() - i);
|
||||
// find the fingerprint from the tool output
|
||||
int i = m_ToolOutput.indexOf("=");
|
||||
if (i != -1) {
|
||||
i++;
|
||||
QString fingerprint = m_ToolOutput.mid(
|
||||
i, m_ToolOutput.size() - i);
|
||||
|
||||
Fingerprint::local().trust(fingerprint, false);
|
||||
emit info(tr("SSL fingerprint generated."));
|
||||
}
|
||||
else {
|
||||
emit error(tr("Failed to find SSL fingerprint."));
|
||||
}
|
||||
Fingerprint::local().trust(fingerprint, false);
|
||||
emit info(tr("SSL fingerprint generated."));
|
||||
}
|
||||
else {
|
||||
emit error(tr("Failed to find SSL fingerprint."));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,22 +26,22 @@ class SslCertificate : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SslCertificate(QObject *parent = 0);
|
||||
explicit SslCertificate(QObject *parent = 0);
|
||||
|
||||
public slots:
|
||||
void generateCertificate();
|
||||
void generateCertificate();
|
||||
|
||||
signals:
|
||||
void error(QString e);
|
||||
void info(QString i);
|
||||
void generateFinished();
|
||||
void error(QString e);
|
||||
void info(QString i);
|
||||
void generateFinished();
|
||||
|
||||
private:
|
||||
bool runTool(const QStringList& args);
|
||||
void generateFingerprint(const QString& certificateFilename);
|
||||
bool runTool(const QStringList& args);
|
||||
void generateFingerprint(const QString& certificateFilename);
|
||||
|
||||
private:
|
||||
QString m_ProfileDir;
|
||||
QString m_ToolOutput;
|
||||
CoreInterface m_CoreInterface;
|
||||
QString m_ProfileDir;
|
||||
QString m_ToolOutput;
|
||||
CoreInterface m_CoreInterface;
|
||||
};
|
||||
|
|
|
@ -23,46 +23,46 @@
|
|||
|
||||
SynergyLocale::SynergyLocale()
|
||||
{
|
||||
loadLanguages();
|
||||
loadLanguages();
|
||||
}
|
||||
|
||||
void SynergyLocale::loadLanguages()
|
||||
{
|
||||
QResource resource(":/res/lang/Languages.xml");
|
||||
QByteArray bytes(reinterpret_cast<const char*>(resource.data()), resource.size());
|
||||
QXmlStreamReader xml(bytes);
|
||||
QResource resource(":/res/lang/Languages.xml");
|
||||
QByteArray bytes(reinterpret_cast<const char*>(resource.data()), resource.size());
|
||||
QXmlStreamReader xml(bytes);
|
||||
|
||||
while (!xml.atEnd())
|
||||
{
|
||||
QXmlStreamReader::TokenType token = xml.readNext();
|
||||
if (xml.hasError())
|
||||
{
|
||||
qCritical() << xml.errorString();
|
||||
throw std::exception();
|
||||
}
|
||||
while (!xml.atEnd())
|
||||
{
|
||||
QXmlStreamReader::TokenType token = xml.readNext();
|
||||
if (xml.hasError())
|
||||
{
|
||||
qCritical() << xml.errorString();
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
if (xml.name() == "language" && token == QXmlStreamReader::StartElement)
|
||||
{
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
addLanguage(
|
||||
attributes.value("ietfCode").toString(),
|
||||
attributes.value("name").toString());
|
||||
}
|
||||
}
|
||||
if (xml.name() == "language" && token == QXmlStreamReader::StartElement)
|
||||
{
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
addLanguage(
|
||||
attributes.value("ietfCode").toString(),
|
||||
attributes.value("name").toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
comboBox->blockSignals(true);
|
||||
QVector<SynergyLocale::Language>::iterator it;
|
||||
for (it = m_Languages.begin(); it != m_Languages.end(); ++it)
|
||||
{
|
||||
comboBox->addItem((*it).m_Name, (*it).m_IetfCode);
|
||||
}
|
||||
comboBox->blockSignals(false);
|
||||
comboBox->blockSignals(true);
|
||||
QVector<SynergyLocale::Language>::iterator it;
|
||||
for (it = m_Languages.begin(); it != m_Languages.end(); ++it)
|
||||
{
|
||||
comboBox->addItem((*it).m_Name, (*it).m_IetfCode);
|
||||
}
|
||||
comboBox->blockSignals(false);
|
||||
}
|
||||
|
|
|
@ -23,26 +23,26 @@
|
|||
|
||||
class SynergyLocale
|
||||
{
|
||||
class Language
|
||||
{
|
||||
public:
|
||||
Language() { }
|
||||
Language(const QString& IetfCode, const QString& name)
|
||||
: m_IetfCode(IetfCode), m_Name(name) { }
|
||||
class Language
|
||||
{
|
||||
public:
|
||||
Language() { }
|
||||
Language(const QString& IetfCode, const QString& name)
|
||||
: m_IetfCode(IetfCode), m_Name(name) { }
|
||||
|
||||
public:
|
||||
QString m_IetfCode;
|
||||
QString m_Name;
|
||||
};
|
||||
public:
|
||||
QString m_IetfCode;
|
||||
QString m_Name;
|
||||
};
|
||||
|
||||
public:
|
||||
SynergyLocale();
|
||||
void fillLanguageComboBox(QComboBox* comboBox);
|
||||
SynergyLocale();
|
||||
void fillLanguageComboBox(QComboBox* comboBox);
|
||||
|
||||
private:
|
||||
void loadLanguages();
|
||||
void addLanguage(const QString& IetfCode, const QString& name);
|
||||
void loadLanguages();
|
||||
void addLanguage(const QString& IetfCode, const QString& name);
|
||||
|
||||
private:
|
||||
QVector<Language> m_Languages;
|
||||
QVector<Language> m_Languages;
|
||||
};
|
||||
|
|
|
@ -24,20 +24,20 @@
|
|||
|
||||
void TrashScreenWidget::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
{
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
event->ignore();
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
{
|
||||
event->setDropAction(Qt::MoveAction);
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
void TrashScreenWidget::dropEvent(QDropEvent* event)
|
||||
{
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
event->acceptProposedAction();
|
||||
else
|
||||
event->ignore();
|
||||
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
|
||||
event->acceptProposedAction();
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,14 @@ class QDropEvent;
|
|||
|
||||
class TrashScreenWidget : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TrashScreenWidget(QWidget* parent) : QLabel(parent) {}
|
||||
public:
|
||||
TrashScreenWidget(QWidget* parent) : QLabel(parent) {}
|
||||
|
||||
public:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
public:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,79 +29,79 @@
|
|||
|
||||
VersionChecker::VersionChecker()
|
||||
{
|
||||
m_manager = new QNetworkAccessManager(this);
|
||||
m_manager = new QNetworkAccessManager(this);
|
||||
|
||||
connect(m_manager, SIGNAL(finished(QNetworkReply*)),
|
||||
this, SLOT(replyFinished(QNetworkReply*)));
|
||||
connect(m_manager, SIGNAL(finished(QNetworkReply*)),
|
||||
this, SLOT(replyFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
VersionChecker::~VersionChecker()
|
||||
{
|
||||
delete m_manager;
|
||||
delete m_manager;
|
||||
}
|
||||
|
||||
void VersionChecker::checkLatest()
|
||||
{
|
||||
m_manager->get(QNetworkRequest(QUrl(VERSION_URL)));
|
||||
m_manager->get(QNetworkRequest(QUrl(VERSION_URL)));
|
||||
}
|
||||
|
||||
void VersionChecker::replyFinished(QNetworkReply* reply)
|
||||
{
|
||||
QString newestVersion = QString(reply->readAll());
|
||||
if (!newestVersion.isEmpty())
|
||||
{
|
||||
QString currentVersion = getVersion();
|
||||
if (currentVersion != "Unknown") {
|
||||
if (compareVersions(currentVersion, newestVersion) > 0)
|
||||
emit updateFound(newestVersion);
|
||||
}
|
||||
}
|
||||
QString newestVersion = QString(reply->readAll());
|
||||
if (!newestVersion.isEmpty())
|
||||
{
|
||||
QString currentVersion = getVersion();
|
||||
if (currentVersion != "Unknown") {
|
||||
if (compareVersions(currentVersion, newestVersion) > 0)
|
||||
emit updateFound(newestVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int VersionChecker::compareVersions(const QString& left, const QString& right)
|
||||
{
|
||||
if (left.compare(right) == 0)
|
||||
return 0; // versions are same.
|
||||
if (left.compare(right) == 0)
|
||||
return 0; // versions are same.
|
||||
|
||||
QStringList leftSplit = left.split(QRegExp("\\."));
|
||||
if (leftSplit.size() != 3)
|
||||
return 1; // assume right wins.
|
||||
QStringList leftSplit = left.split(QRegExp("\\."));
|
||||
if (leftSplit.size() != 3)
|
||||
return 1; // assume right wins.
|
||||
|
||||
QStringList rightSplit = right.split(QRegExp("\\."));
|
||||
if (rightSplit.size() != 3)
|
||||
return -1; // assume left wins.
|
||||
QStringList rightSplit = right.split(QRegExp("\\."));
|
||||
if (rightSplit.size() != 3)
|
||||
return -1; // assume left wins.
|
||||
|
||||
int leftMajor = leftSplit.at(0).toInt();
|
||||
int leftMinor = leftSplit.at(1).toInt();
|
||||
int leftRev = leftSplit.at(2).toInt();
|
||||
int leftMajor = leftSplit.at(0).toInt();
|
||||
int leftMinor = leftSplit.at(1).toInt();
|
||||
int leftRev = leftSplit.at(2).toInt();
|
||||
|
||||
int rightMajor = rightSplit.at(0).toInt();
|
||||
int rightMinor = rightSplit.at(1).toInt();
|
||||
int rightRev = rightSplit.at(2).toInt();
|
||||
int rightMajor = rightSplit.at(0).toInt();
|
||||
int rightMinor = rightSplit.at(1).toInt();
|
||||
int rightRev = rightSplit.at(2).toInt();
|
||||
|
||||
bool rightWins =
|
||||
(rightMajor > leftMajor) ||
|
||||
((rightMajor >= leftMajor) && (rightMinor > leftMinor)) ||
|
||||
((rightMajor >= leftMajor) && (rightMinor >= leftMinor) && (rightRev > leftRev));
|
||||
bool rightWins =
|
||||
(rightMajor > leftMajor) ||
|
||||
((rightMajor >= leftMajor) && (rightMinor > leftMinor)) ||
|
||||
((rightMajor >= leftMajor) && (rightMinor >= leftMinor) && (rightRev > leftRev));
|
||||
|
||||
return rightWins ? 1 : -1;
|
||||
return rightWins ? 1 : -1;
|
||||
}
|
||||
|
||||
QString VersionChecker::getVersion()
|
||||
{
|
||||
QProcess process;
|
||||
process.start(m_app, QStringList() << "--version");
|
||||
QProcess process;
|
||||
process.start(m_app, QStringList() << "--version");
|
||||
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
if (process.waitForStarted() && process.waitForFinished())
|
||||
{
|
||||
QRegExp rx(VERSION_REGEX);
|
||||
QString text = process.readLine();
|
||||
if (rx.indexIn(text) != -1)
|
||||
{
|
||||
return rx.cap(1);
|
||||
}
|
||||
}
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
if (process.waitForStarted() && process.waitForFinished())
|
||||
{
|
||||
QRegExp rx(VERSION_REGEX);
|
||||
QString text = process.readLine();
|
||||
if (rx.indexIn(text) != -1)
|
||||
{
|
||||
return rx.cap(1);
|
||||
}
|
||||
}
|
||||
|
||||
return tr("Unknown");
|
||||
return tr("Unknown");
|
||||
}
|
||||
|
|
|
@ -26,19 +26,19 @@ class QNetworkReply;
|
|||
|
||||
class VersionChecker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
VersionChecker();
|
||||
virtual ~VersionChecker();
|
||||
void checkLatest();
|
||||
QString getVersion();
|
||||
void setApp(const QString& app) { m_app = app; }
|
||||
int compareVersions(const QString& left, const QString& right);
|
||||
VersionChecker();
|
||||
virtual ~VersionChecker();
|
||||
void checkLatest();
|
||||
QString getVersion();
|
||||
void setApp(const QString& app) { m_app = app; }
|
||||
int compareVersions(const QString& left, const QString& right);
|
||||
public slots:
|
||||
void replyFinished(QNetworkReply* reply);
|
||||
void replyFinished(QNetworkReply* reply);
|
||||
signals:
|
||||
void updateFound(const QString& version);
|
||||
void updateFound(const QString& version);
|
||||
private:
|
||||
QNetworkAccessManager* m_manager;
|
||||
QString m_app;
|
||||
QNetworkAccessManager* m_manager;
|
||||
QString m_app;
|
||||
};
|
||||
|
|
|
@ -27,58 +27,58 @@
|
|||
|
||||
bool
|
||||
WebClient::getEdition (int& edition, QString& errorOut) {
|
||||
QString responseJson = request();
|
||||
|
||||
/* TODO: This is horrible and should be ripped out as soon as we move
|
||||
* to Qt 5. See issue #5630
|
||||
*/
|
||||
QString responseJson = request();
|
||||
|
||||
/* TODO: This is horrible and should be ripped out as soon as we move
|
||||
* to Qt 5. See issue #5630
|
||||
*/
|
||||
|
||||
QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
|
||||
if (resultRegex.exactMatch (responseJson)) {
|
||||
QString boolString = resultRegex.cap(1);
|
||||
if (boolString == "true") {
|
||||
QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
|
||||
if (editionRegex.exactMatch(responseJson)) {
|
||||
QString e = editionRegex.cap(1);
|
||||
edition = e.toInt();
|
||||
return true;
|
||||
} else {
|
||||
throw std::runtime_error ("Unrecognised server response.");
|
||||
}
|
||||
} else {
|
||||
errorOut = tr("Login failed. Invalid email address or password.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
|
||||
if (errorRegex.exactMatch (responseJson)) {
|
||||
errorOut = errorRegex.cap(1).replace("\\n", "\n");
|
||||
return false;
|
||||
} else {
|
||||
throw std::runtime_error ("Unrecognised server response.");
|
||||
}
|
||||
}
|
||||
QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
|
||||
if (resultRegex.exactMatch (responseJson)) {
|
||||
QString boolString = resultRegex.cap(1);
|
||||
if (boolString == "true") {
|
||||
QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
|
||||
if (editionRegex.exactMatch(responseJson)) {
|
||||
QString e = editionRegex.cap(1);
|
||||
edition = e.toInt();
|
||||
return true;
|
||||
} else {
|
||||
throw std::runtime_error ("Unrecognised server response.");
|
||||
}
|
||||
} else {
|
||||
errorOut = tr("Login failed. Invalid email address or password.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
|
||||
if (errorRegex.exactMatch (responseJson)) {
|
||||
errorOut = errorRegex.cap(1).replace("\\n", "\n");
|
||||
return false;
|
||||
} else {
|
||||
throw std::runtime_error ("Unrecognised server response.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
WebClient::setEmail (QString email, QString& errorOut) {
|
||||
if (email.isEmpty()) {
|
||||
errorOut = tr("Your email address cannot be left blank.");
|
||||
return false;
|
||||
}
|
||||
m_Email = email;
|
||||
return true;
|
||||
if (email.isEmpty()) {
|
||||
errorOut = tr("Your email address cannot be left blank.");
|
||||
return false;
|
||||
}
|
||||
m_Email = email;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
WebClient::setPassword (QString password, QString&) {
|
||||
m_Password = password;
|
||||
return true;
|
||||
m_Password = password;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString
|
||||
WebClient::request() {
|
||||
QStringList args("--login-auth");
|
||||
QString credentials (m_Email + ":" + hash(m_Password) + "\n");
|
||||
return m_CoreInterface.run (args, credentials);
|
||||
QStringList args("--login-auth");
|
||||
QString credentials (m_Email + ":" + hash(m_Password) + "\n");
|
||||
return m_CoreInterface.run (args, credentials);
|
||||
}
|
||||
|
|
|
@ -29,21 +29,21 @@ class QStringList;
|
|||
|
||||
class WebClient : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
bool getEdition (int& edition, QString& errorOut);
|
||||
bool setEmail (QString email, QString& errorOut);
|
||||
bool setPassword (QString password, QString& errorOut);
|
||||
bool getEdition (int& edition, QString& errorOut);
|
||||
bool setEmail (QString email, QString& errorOut);
|
||||
bool setPassword (QString password, QString& errorOut);
|
||||
signals:
|
||||
void error(QString e);
|
||||
void error(QString e);
|
||||
|
||||
private:
|
||||
QString request();
|
||||
|
||||
QString m_Email;
|
||||
QString m_Password;
|
||||
CoreInterface m_CoreInterface;
|
||||
QString request();
|
||||
|
||||
QString m_Email;
|
||||
QString m_Password;
|
||||
CoreInterface m_CoreInterface;
|
||||
};
|
||||
|
||||
#endif // WEBCLIENT_H
|
||||
|
|
|
@ -20,73 +20,73 @@
|
|||
#include <QtCore/QSocketNotifier>
|
||||
|
||||
ZeroconfBrowser::ZeroconfBrowser(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_DnsServiceRef(0),
|
||||
m_pSocket(0)
|
||||
QObject(parent),
|
||||
m_DnsServiceRef(0),
|
||||
m_pSocket(0)
|
||||
{
|
||||
}
|
||||
|
||||
ZeroconfBrowser::~ZeroconfBrowser()
|
||||
{
|
||||
if (m_pSocket) {
|
||||
delete m_pSocket;
|
||||
}
|
||||
if (m_pSocket) {
|
||||
delete m_pSocket;
|
||||
}
|
||||
|
||||
if (m_DnsServiceRef) {
|
||||
DNSServiceRefDeallocate(m_DnsServiceRef);
|
||||
m_DnsServiceRef = 0;
|
||||
}
|
||||
if (m_DnsServiceRef) {
|
||||
DNSServiceRefDeallocate(m_DnsServiceRef);
|
||||
m_DnsServiceRef = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroconfBrowser::browseForType(const QString& type)
|
||||
{
|
||||
DNSServiceErrorType err = DNSServiceBrowse(&m_DnsServiceRef, 0, 0,
|
||||
type.toUtf8().constData(), 0, browseReply, this);
|
||||
DNSServiceErrorType err = DNSServiceBrowse(&m_DnsServiceRef, 0, 0,
|
||||
type.toUtf8().constData(), 0, browseReply, this);
|
||||
|
||||
if (err != kDNSServiceErr_NoError) {
|
||||
emit error(err);
|
||||
}
|
||||
else {
|
||||
int sockFD = DNSServiceRefSockFD(m_DnsServiceRef);
|
||||
if (sockFD == -1) {
|
||||
emit error(kDNSServiceErr_Invalid);
|
||||
}
|
||||
else {
|
||||
m_pSocket = new QSocketNotifier(sockFD, QSocketNotifier::Read, this);
|
||||
connect(m_pSocket, SIGNAL(activated(int)), this,
|
||||
SLOT(socketReadyRead()));
|
||||
}
|
||||
}
|
||||
if (err != kDNSServiceErr_NoError) {
|
||||
emit error(err);
|
||||
}
|
||||
else {
|
||||
int sockFD = DNSServiceRefSockFD(m_DnsServiceRef);
|
||||
if (sockFD == -1) {
|
||||
emit error(kDNSServiceErr_Invalid);
|
||||
}
|
||||
else {
|
||||
m_pSocket = new QSocketNotifier(sockFD, QSocketNotifier::Read, this);
|
||||
connect(m_pSocket, SIGNAL(activated(int)), this,
|
||||
SLOT(socketReadyRead()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroconfBrowser::socketReadyRead()
|
||||
{
|
||||
DNSServiceErrorType err = DNSServiceProcessResult(m_DnsServiceRef);
|
||||
if (err != kDNSServiceErr_NoError) {
|
||||
emit error(err);
|
||||
}
|
||||
DNSServiceErrorType err = DNSServiceProcessResult(m_DnsServiceRef);
|
||||
if (err != kDNSServiceErr_NoError) {
|
||||
emit error(err);
|
||||
}
|
||||
}
|
||||
|
||||
void ZeroconfBrowser::browseReply(DNSServiceRef, DNSServiceFlags flags,
|
||||
quint32, DNSServiceErrorType errorCode, const char* serviceName,
|
||||
const char* regType, const char* replyDomain, void* context)
|
||||
quint32, DNSServiceErrorType errorCode, const char* serviceName,
|
||||
const char* regType, const char* replyDomain, void* context)
|
||||
{
|
||||
ZeroconfBrowser* browser = static_cast<ZeroconfBrowser*>(context);
|
||||
if (errorCode != kDNSServiceErr_NoError) {
|
||||
emit browser->error(errorCode);
|
||||
}
|
||||
else {
|
||||
ZeroconfRecord record(serviceName, regType, replyDomain);
|
||||
if (flags & kDNSServiceFlagsAdd) {
|
||||
if (!browser->m_Records.contains(record)) {
|
||||
browser->m_Records.append(record);
|
||||
}
|
||||
}
|
||||
else {
|
||||
browser->m_Records.removeAll(record);
|
||||
}
|
||||
if (!(flags & kDNSServiceFlagsMoreComing)) {
|
||||
emit browser->currentRecordsChanged(browser->m_Records);
|
||||
}
|
||||
}
|
||||
ZeroconfBrowser* browser = static_cast<ZeroconfBrowser*>(context);
|
||||
if (errorCode != kDNSServiceErr_NoError) {
|
||||
emit browser->error(errorCode);
|
||||
}
|
||||
else {
|
||||
ZeroconfRecord record(serviceName, regType, replyDomain);
|
||||
if (flags & kDNSServiceFlagsAdd) {
|
||||
if (!browser->m_Records.contains(record)) {
|
||||
browser->m_Records.append(record);
|
||||
}
|
||||
}
|
||||
else {
|
||||
browser->m_Records.removeAll(record);
|
||||
}
|
||||
if (!(flags & kDNSServiceFlagsMoreComing)) {
|
||||
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