//---------------------------------------------------------------------------------- // UpdateIcon: Load the icon from the resource files, and attach it to the windows. //---------------------------------------------------------------------------------- void UpdateIcon(void) { DisplayContext *aContext = g_pWindow->GetDisplayContext(); std::string anIconFile; if(!(GetCustomInfo()->GetResourceDirectory().empty())) { anIconFile = GetCustomInfo()->GetResourceDirectory(); char anEndChar = anIconFile[anIconFile.size()-1]; if(anEndChar != '/' && anEndChar != '\\') anIconFile += '/'; } anIconFile += ("SierraUp.ico"); HICON anHIcon = (HICON)LoadImage(NULL,anIconFile.c_str(),IMAGE_ICON,0,0,LR_LOADFROMFILE); if(anHIcon==NULL) anHIcon = LoadIcon(g_pWindowMgr->GetHinstance(),MAKEINTRESOURCE(IDI_SIERRAUP)); if(anHIcon!=NULL) { MSNativeIconPtr anIcon = new MSNativeIcon(aContext, anHIcon); g_pWindow->SetIcon(anIcon); g_pWindowMgr->SetDefaultWindowIcon(anIcon); } }
bool ScriptableProxyHelper::copyFromCurrentWindow() { INVOKE(copyFromCurrentWindow()); PlatformWindowPtr window = createPlatformNativeInterface()->getCurrentWindow(); if (!window) return false; window->copy(); return true; }
bool ScriptableProxyHelper::pasteToCurrentWindow() { INVOKE(pasteToCurrentWindow()); PlatformWindowPtr window = createPlatformNativeInterface()->getCurrentWindow(); if (!window) return false; window->pasteClipboard(); return true; }
//---------------------------------------------------------------------------------- // DoDialog: Display this dialog as a modal dialog. //---------------------------------------------------------------------------------- int AboutDlg::DoDialog(Window *pParent) { PlatformWindowPtr pWindow = new PlatformWindow; pWindow->SetParent(pParent); pWindow->SetTitle(GetCustomInfo()->GetResourceManager()->GetString(IDS_ABOUT_DLG_TITLE)); pWindow->SetCreateFlags(CreateWindow_SizeSpecClientArea | CreateWindow_NotSizeable); WONRectangle aRect; if (pParent != NULL) pParent->GetScreenPos(aRect); else pWindow->GetWindowManager()->GetScreenRect(aRect); // Center it on top of its parent (or the desktop). pWindow->Create(WONRectangle(aRect.Left() + (aRect.Width() - Width()) / 2, aRect.Top() + (aRect.Height() - Height()) / 2, Width(), Height())); pWindow->AddComponent(this); m_pCloseButton->RequestFocus(); int nResult = pWindow->DoDialog(this); pWindow->Close(); return nResult; }
//---------------------------------------------------------------------------------- // DoDialog: Display this dialog as a modal dialog. //---------------------------------------------------------------------------------- int LoginCtrl::DoDialog(const GUIString& theTitle, const GUIString& theText, Window *pParent) { PlatformWindowPtr pWindow = new PlatformWindow; pWindow->SetParent(pParent); pWindow->SetTitle(theTitle); m_pText->SetText(theText); m_pText->SetDesiredSize(); pWindow->SetCreateFlags(CreateWindow_SizeSpecClientArea | CreateWindow_NotSizeable); RecalcLayout(); WONRectangle aRect; if (pParent != NULL) pParent->GetScreenPos(aRect); else pWindow->GetWindowManager()->GetScreenRect(aRect); // Center it on top of its parent (or the desktop). pWindow->Create(WONRectangle(aRect.Left() + (aRect.Width() - Width()) / 2, aRect.Top() + (aRect.Height() - Height()) / 2, Width(), Height())); pWindow->AddComponent(this); m_pLoginNameInputBox->RequestFocus(); int nResult = pWindow->DoDialog(this); pWindow->Close(); return nResult; }
virtual void ThreadFunc(void) { while (true) { if (g_pCore->WaitTillNeedPump(20)) { g_pWindow->PostEvent(new UserEvent(PumpAPI)); g_pWindow->PostEvent(new UserEvent(SignalAPI)); mSignalEvent.WaitFor(INFINITE); } if (mStopped) return; } }
//---------------------------------------------------------------------------------- // ShowScreen: Display the provided screen. //---------------------------------------------------------------------------------- void ShowScreen(Container* pScreen) { g_pWindow->EndPopup(); g_pWindow->GetRoot()->RemoveAllChildren(); pScreen->SetPosSize(0, 0, g_pWindow->GetRoot()->Width(), g_pWindow->GetRoot()->Height()); g_pWindow->AddComponent(pScreen); g_pWindow->GetRoot()->AddChildLayout(pScreen, CLI_SameSize, g_pWindow->GetRoot()); }
//---------------------------------------------------------------------------------- // CreateMainScreen: Create the main screen. //---------------------------------------------------------------------------------- void CreateMainScreen(void) { int nWidth = g_pWindow->GetRoot()->Width(); int nHeight = g_pWindow->GetRoot()->Height(); g_pMainScreen = new Container; g_pMainScreen->SetSize(nWidth, nHeight); WONUpdateCtrlPtr pCtrl = new WONUpdateCtrl(); ResourceConfigTablePtr aTable = pCtrl->InitScreens(); g_pMainScreen->AddChildLayout(pCtrl, CLI_SameSize, g_pMainScreen); pCtrl->SetFinishedCallback(Finished); pCtrl->SetTitleChangedCallback(TitleChanged); g_pAboutDlg = pCtrl->GetAboutCtrl(); CustomInfo* pCI = GetCustomInfo(); g_pAboutDlg->SetVersion(pCI->GetSierraUpVersion()); g_pMainScreen->AddChild(pCtrl); }
//---------------------------------------------------------------------------------- // Finished: The core claims that we are finished, so shut down. //---------------------------------------------------------------------------------- void Finished(int nReturnCode) { if (GetMainControl()->GetReturnResult() == SUR_PATCHING_SELF) { if (ExtractRestarter()) LaunchRestarter(GetCustomInfo()->GetPatchFile()); } g_pWindow->Close(); }
//---------------------------------------------------------------------------------- // UpdateSystemMenu: Add the 'About' menu item to the system menu. //---------------------------------------------------------------------------------- void UpdateSystemMenu(void) { assert((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); assert(IDM_ABOUTBOX < 0xF000); // Add 'About...' menu item to system menu. HWND hWnd = g_pWindow->GetHWND(); HMENU hMenu = GetSystemMenu(hWnd, FALSE); AppendMenu(hMenu, MF_SEPARATOR, 0, 0L); AppendMenu(hMenu, MF_STRING, IDM_ABOUTBOX, "About"); }
//---------------------------------------------------------------------------------- // TitleChanged: Time to upadte the title. //---------------------------------------------------------------------------------- void TitleChanged(const GUIString& sTitle) { g_pWindow->SetTitle(sTitle); }
void ClipboardMonitor::checkClipboard(QClipboard::Mode mode) { #ifdef COPYQ_WS_X11 m_x11->cancelSynchronization(); #endif // Check clipboard after interval because someone is updating it very quickly. bool needToWait = m_updateTimer->isActive(); if (mode == QClipboard::Clipboard) m_needCheckClipboard = needToWait; #ifdef COPYQ_WS_X11 else if (mode == QClipboard::Selection) m_needCheckSelection = needToWait; #endif else return; m_updateTimer->start(); if (needToWait) return; #ifdef COPYQ_WS_X11 if ( mode == QClipboard::Selection && m_x11->isSelectionIncomplete() ) return; if ( m_x11->maybeResetClipboard(mode) ) return; #endif COPYQ_LOG( QString("Checking for new %1 content.") .arg(mode == QClipboard::Clipboard ? "clipboard" : "selection") ); // get clipboard data const QMimeData *data = clipboardData(mode); // data retrieved? if (!data) { log( tr("Cannot access clipboard data!"), LogError ); return; } // clone only mime types defined by user #if defined(Q_OS_MAC) // On OS X, when you copy files in Finder, etc. you get: // - The file name(s) (not paths) as plain text // - The file URI(s) // - The icon (not thumbnail) for the type of item you have in various image formants // We really only want the URI list, so throw the rest away QStringList formats = m_formats; if (data->formats().contains(mimeUriList) && formats.contains(mimeUriList)) { formats = QStringList() << mimeUriList; } QVariantMap data2( cloneData(*data, formats) ); #else QVariantMap data2( cloneData(*data, m_formats) ); #endif // add window title of clipboard owner if ( !data2.contains(mimeOwner) && !data2.contains(mimeWindowTitle) ) { PlatformPtr platform = createPlatformNativeInterface(); PlatformWindowPtr currentWindow = platform->getCurrentWindow(); if (currentWindow) data2.insert( mimeWindowTitle, currentWindow->getTitle().toUtf8() ); } #ifdef COPYQ_WS_X11 m_x11->setData(mode, data2); if (mode == QClipboard::Clipboard) { if ( !ownsClipboardData(data2) && m_x11->synchronize(QClipboard::Selection) ) m_needCheckSelection = false; clipboardChanged(data2); } else { data2.insert(mimeClipboardMode, "selection"); if ( !ownsClipboardData(data2) && m_x11->synchronize(QClipboard::Clipboard) ) m_needCheckClipboard = false; if ( m_x11->hasCheckSelection() ) clipboardChanged(data2); } #else /* !COPYQ_WS_X11 */ clipboardChanged(data2); #endif }
void ClipboardMonitor::onClipboardChanged(ClipboardMode mode) { QVariantMap data = m_clipboard->data(mode, m_formats); auto clipboardData = mode == ClipboardMode::Clipboard ? &m_clipboardData : &m_selectionData; if ( hasSameData(data, *clipboardData) ) { COPYQ_LOG( QString("Ignoring unchanged %1") .arg(mode == ClipboardMode::Clipboard ? "clipboard" : "selection") ); return; } *clipboardData = data; COPYQ_LOG( QString("%1 changed, owner is \"%2\"") .arg(mode == ClipboardMode::Clipboard ? "Clipboard" : "Selection", getTextData(data, mimeOwner)) ); if (mode != ClipboardMode::Clipboard) { const QString modeName = mode == ClipboardMode::Selection ? "selection" : "find buffer"; data.insert(mimeClipboardMode, modeName); } // add window title of clipboard owner if ( !data.contains(mimeOwner) && !data.contains(mimeWindowTitle) ) { PlatformPtr platform = createPlatformNativeInterface(); PlatformWindowPtr currentWindow = platform->getCurrentWindow(); if (currentWindow) data.insert( mimeWindowTitle, currentWindow->getTitle().toUtf8() ); } #ifdef HAS_MOUSE_SELECTIONS if ( (mode == ClipboardMode::Clipboard ? m_clipboardToSelection : m_selectionToClipboard) && !data.contains(mimeOwner) ) { const auto text = getTextData(data); if ( !text.isEmpty() ) { const auto targetData = mode == ClipboardMode::Clipboard ? &m_selectionData : &m_clipboardData; const auto targetText = getTextData(*targetData); emit synchronizeSelection(mode, text, qHash(targetText)); } } #endif // run automatic commands if ( anySessionOwnsClipboardData(data) ) { emit clipboardChanged(data, ClipboardOwnership::Own); } else if ( isClipboardDataHidden(data) ) { emit clipboardChanged(data, ClipboardOwnership::Hidden); } else { const auto defaultTab = m_clipboardTab.isEmpty() ? defaultClipboardTabName() : m_clipboardTab; setTextData(&data, defaultTab, mimeCurrentTab); #ifdef HAS_MOUSE_SELECTIONS if (mode == ClipboardMode::Clipboard ? m_storeClipboard : m_storeSelection) { #else if (m_storeClipboard) { #endif setTextData(&data, m_clipboardTab, mimeOutputTab); } emit clipboardChanged(data, ClipboardOwnership::Foreign); } }