### macOS Accessibility Permissions Setup Source: https://context7.com/vasylbaran/commandshift/llms.txt Guides users on setting up macOS Accessibility permissions for CommandShift. Explains the initial prompt, manual steps via System Preferences, troubleshooting common permission loss, and adding the app to Login Items for automatic startup. ```bash # The app will show notification on first launch: # Title: "One more thing..." # Message: "Please add CommandShift to Security & Privacy -> Privacy -> Accessibility" # Manual steps to grant permissions: # 1. Open System Preferences/Settings # 2. Navigate to Security & Privacy -> Privacy -> Accessibility # 3. Click the lock icon to make changes # 4. Add CommandShift to the list and enable it # If shortcuts stop working, the app lost permissions and will notify: # Title: "CommandShift will no longer work... =(" # Message: "CommandShift has been removed from Accessibility list" # Troubleshooting: Reset default keyboard shortcuts # If CommandShift doesn't work, ensure Keyboard -> Shortcuts -> Input Sources # are set to defaults by clicking "Restore Defaults" button # Add to Login Items for automatic startup: # System Settings -> General -> Login Items -> [+] -> select CommandShift.app ``` -------------------------------- ### Build CommandShift from Source Source: https://context7.com/vasylbaran/commandshift/llms.txt Builds the CommandShift application from source using qmake and make. Requires macOS with Qt framework installed. Generates universal binaries for Intel and Apple Silicon. ```bash # Prerequisites: Qt 5.x or Qt 6.x installed via Homebrew or Qt installer # Clone the repository git clone https://github.com/VasylBaran/CommandShift.git cd CommandShift/src # Generate Makefile using qmake qmake CommandShift.pro # Build the application make # The resulting CommandShift.app will be created in the build directory # Move to Applications folder cp -r CommandShift.app /Applications/ # If you get "app is damaged" error, remove quarantine attribute xattr -cr /Applications/CommandShift.app ``` -------------------------------- ### Initialize and Configure KeyPressCatcher Source: https://context7.com/vasylbaran/commandshift/llms.txt Demonstrates initializing the `KeyPressCatcher` with a notification callback, setting a custom shortcut key (Option + Shift), and configuring language changes to occur on key release. Requires `KeyPressCatcher` and `QSystemTrayIcon`. ```cpp #include "keypresscatcher.h" #include // Create a callback for displaying system notifications auto showMessageCallback = [systemTrayIcon](const QString& title, const QString& message) { systemTrayIcon->showMessage(title, message, QIcon(), 30000); }; // Initialize the key press catcher with notification callback KeyPressCatcher catcher(showMessageCallback); // Configure the shortcut combination (Shift + Option/Alt) catcher.setSecondShortcutKey(CS::SecondShortcutKeyEnum::Option); // Get current shortcut configuration CS::SecondShortcutKeyEnum currentKey = catcher.getSecondShortcutKey(); // Returns: CS::SecondShortcutKeyEnum::Option // Enable language change on key release instead of key press catcher.setChangeLanguageOnRelease(true); // Check if change-on-release mode is enabled bool onRelease = catcher.changeLanguageOnRelease(); // Returns: true ``` -------------------------------- ### Configure SecondShortcutKeyEnum Options Source: https://context7.com/vasylbaran/commandshift/llms.txt Illustrates how to configure different keyboard shortcut combinations using the `CS::SecondShortcutKeyEnum` enumeration. This allows users to select preferred modifier keys to pair with Shift for input source switching. Requires `constants.h`. ```cpp #include "constants.h" // Available shortcut options in CS namespace: // CS::SecondShortcutKeyEnum::GlobalFN - Shift + FN key // CS::SecondShortcutKeyEnum::Control - Shift + Control key // CS::SecondShortcutKeyEnum::Option - Shift + Option/Alt key (Windows-style) // CS::SecondShortcutKeyEnum::Command - Shift + Command key (default) // CS::SecondShortcutKeyEnum::Nothing - Shift key only // Example: Configure different shortcuts KeyPressCatcher catcher(callback); // Windows-style Alt+Shift catcher.setSecondShortcutKey(CS::SecondShortcutKeyEnum::Option); // Use just Shift key alone catcher.setSecondShortcutKey(CS::SecondShortcutKeyEnum::Nothing); // Use Command+Shift (default macOS style) catcher.setSecondShortcutKey(CS::SecondShortcutKeyEnum::Command); ``` -------------------------------- ### System Tray Integration with Qt Source: https://context7.com/vasylbaran/commandshift/llms.txt Integrates CommandShift with the macOS system tray using Qt. Loads user settings, creates a tray icon, and sets up context menu actions for shortcut selection and behavior toggling. Requires Qt framework. ```cpp #include #include #include #include #include QApplication app(argc, argv); QMenu menu; // Load user settings from config file auto homePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); auto settingsPath = std::filesystem::path(homePath.toStdString()) / ".config" / "commandShift.ini"; auto settings = new QSettings(QString::fromStdString(settingsPath.string()), QSettings::Format::IniFormat); // Create system tray icon with optional white icon preference bool preferWhiteIcon = settings->value("tray_icon/white_tray_icon", false).toBool(); auto systemTrayIcon = new QSystemTrayIcon( preferWhiteIcon ? QIcon(":/icons/trayicon_white.png") : QIcon(":/icons/trayicon.png"), &menu ); systemTrayIcon->setContextMenu(&menu); systemTrayIcon->setToolTip("CommandShift (1.0) - developed by Vasyl Baran"); systemTrayIcon->show(); // Create mutually exclusive shortcut selection group auto shortcutGroup = new QActionGroup(&menu); shortcutGroup->setExclusive(true); auto optionAction = new QAction("Shift + Option", shortcutGroup); optionAction->setCheckable(true); QObject::connect(optionAction, &QAction::triggered, [&catcher](bool checked) { if (checked) catcher.setSecondShortcutKey(CS::Option); }); // Add dropdown menu for shortcut selection auto shortcutMenu = menu.addMenu("Change language with..."); shortcutMenu->addAction(optionAction); // Add toggle for change-on-release behavior auto releaseAction = menu.addAction("Change language after Shift release"); releaseAction->setCheckable(true); QObject::connect(releaseAction, &QAction::triggered, [&catcher, settings]() { catcher.setChangeLanguageOnRelease(!catcher.changeLanguageOnRelease()); settings->setValue("language/trigger_on_key_release", catcher.changeLanguageOnRelease()); }); app.exec(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.