mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 01:25:33 -07:00
clang-format in src/qt
This commit is contained in:
@@ -1,112 +1,112 @@
|
||||
static std::unordered_map<uint8_t, uint16_t> be_keycodes = {
|
||||
{B_F1_KEY, 0x3b},
|
||||
{B_F2_KEY, 0x3c},
|
||||
{B_F3_KEY, 0x3d},
|
||||
{B_F4_KEY, 0x3e},
|
||||
{B_F5_KEY, 0x3f},
|
||||
{B_F6_KEY, 0x40},
|
||||
{B_F7_KEY, 0x41},
|
||||
{B_F8_KEY, 0x42},
|
||||
{B_F9_KEY, 0x43},
|
||||
{B_F10_KEY, 0x44},
|
||||
{B_F11_KEY, 0x57},
|
||||
{B_F12_KEY, 0x58},
|
||||
{B_PRINT_KEY, 0x137},
|
||||
{B_SCROLL_KEY, 0x46},
|
||||
{B_PAUSE_KEY, 0x145},
|
||||
{B_KATAKANA_HIRAGANA, 0x70},
|
||||
{B_HANKAKU_ZENKAKU, 0x76},
|
||||
{ B_F1_KEY, 0x3b },
|
||||
{ B_F2_KEY, 0x3c },
|
||||
{ B_F3_KEY, 0x3d },
|
||||
{ B_F4_KEY, 0x3e },
|
||||
{ B_F5_KEY, 0x3f },
|
||||
{ B_F6_KEY, 0x40 },
|
||||
{ B_F7_KEY, 0x41 },
|
||||
{ B_F8_KEY, 0x42 },
|
||||
{ B_F9_KEY, 0x43 },
|
||||
{ B_F10_KEY, 0x44 },
|
||||
{ B_F11_KEY, 0x57 },
|
||||
{ B_F12_KEY, 0x58 },
|
||||
{ B_PRINT_KEY, 0x137 },
|
||||
{ B_SCROLL_KEY, 0x46 },
|
||||
{ B_PAUSE_KEY, 0x145 },
|
||||
{ B_KATAKANA_HIRAGANA, 0x70 },
|
||||
{ B_HANKAKU_ZENKAKU, 0x76 },
|
||||
|
||||
{0x01, 0x01}, /* Escape */
|
||||
{0x11, 0x29},
|
||||
{0x12, 0x02},
|
||||
{0x13, 0x03},
|
||||
{0x14, 0x04},
|
||||
{0x15, 0x05},
|
||||
{0x16, 0x06},
|
||||
{0x17, 0x07},
|
||||
{0x18, 0x08},
|
||||
{0x19, 0x09},
|
||||
{0x1a, 0x0a},
|
||||
{0x1b, 0x0b},
|
||||
{0x1c, 0x0c},
|
||||
{0x1d, 0x0d},
|
||||
{0x1e, 0x0e}, /* Backspace */
|
||||
{0x1f, 0x152}, /* Insert */
|
||||
{0x20, 0x147}, /* Home */
|
||||
{0x21, 0x149}, /* Page Up */
|
||||
{0x22, 0x45},
|
||||
{0x23, 0x135},
|
||||
{0x24, 0x37},
|
||||
{0x25, 0x4a},
|
||||
{0x26, 0x0f}, /* Tab */
|
||||
{0x27, 0x10},
|
||||
{0x28, 0x11},
|
||||
{0x29, 0x12},
|
||||
{0x2a, 0x13},
|
||||
{0x2b, 0x14},
|
||||
{0x2c, 0x15},
|
||||
{0x2d, 0x16},
|
||||
{0x2e, 0x17},
|
||||
{0x2f, 0x18},
|
||||
{0x30, 0x19},
|
||||
{0x31, 0x1a},
|
||||
{0x32, 0x1b},
|
||||
{0x33, 0x2b},
|
||||
{0x34, 0x153}, /* Delete */
|
||||
{0x35, 0x14f}, /* End */
|
||||
{0x36, 0x151}, /* Page Down */
|
||||
{0x37, 0x47},
|
||||
{0x38, 0x48},
|
||||
{0x39, 0x49},
|
||||
{0x3a, 0x4e},
|
||||
{0x3b, 0x3a},
|
||||
{0x3c, 0x1e},
|
||||
{0x3d, 0x1f},
|
||||
{0x3e, 0x20},
|
||||
{0x3f, 0x21},
|
||||
{0x40, 0x22},
|
||||
{0x41, 0x23},
|
||||
{0x42, 0x24},
|
||||
{0x43, 0x25},
|
||||
{0x44, 0x26},
|
||||
{0x45, 0x27},
|
||||
{0x46, 0x28},
|
||||
{0x47, 0x1c}, /* Enter */
|
||||
{0x48, 0x4b},
|
||||
{0x49, 0x4c},
|
||||
{0x4a, 0x4d},
|
||||
{0x4b, 0x2a},
|
||||
{0x4c, 0x2c},
|
||||
{0x4d, 0x2d},
|
||||
{0x4e, 0x2e},
|
||||
{0x4f, 0x2f},
|
||||
{0x50, 0x30},
|
||||
{0x51, 0x31},
|
||||
{0x52, 0x32},
|
||||
{0x53, 0x33},
|
||||
{0x54, 0x34},
|
||||
{0x55, 0x35},
|
||||
{0x56, 0x36},
|
||||
{0x57, 0x148}, /* up arrow */
|
||||
{0x58, 0x51},
|
||||
{0x59, 0x50},
|
||||
{0x5a, 0x4f},
|
||||
{0x5b, 0x11c},
|
||||
{0x5c, 0x1d},
|
||||
{0x5d, 0x38},
|
||||
{0x5e, 0x39}, /* space bar */
|
||||
{0x5f, 0x138},
|
||||
{0x60, 0x11d},
|
||||
{0x61, 0x14b}, /* left arrow */
|
||||
{0x62, 0x150}, /* down arrow */
|
||||
{0x63, 0x14d}, /* right arrow */
|
||||
{0x64, 0x52},
|
||||
{0x65, 0x53},
|
||||
{0x66, 0x15b},
|
||||
{0x67, 0x15c},
|
||||
{0x68, 0x15d},
|
||||
{0x69, 0x56},
|
||||
{0x7e, 0x137}, /* System Request */
|
||||
{0x7f, 0x145}, /* Break */
|
||||
{ 0x01, 0x01 }, /* Escape */
|
||||
{ 0x11, 0x29 },
|
||||
{ 0x12, 0x02 },
|
||||
{ 0x13, 0x03 },
|
||||
{ 0x14, 0x04 },
|
||||
{ 0x15, 0x05 },
|
||||
{ 0x16, 0x06 },
|
||||
{ 0x17, 0x07 },
|
||||
{ 0x18, 0x08 },
|
||||
{ 0x19, 0x09 },
|
||||
{ 0x1a, 0x0a },
|
||||
{ 0x1b, 0x0b },
|
||||
{ 0x1c, 0x0c },
|
||||
{ 0x1d, 0x0d },
|
||||
{ 0x1e, 0x0e }, /* Backspace */
|
||||
{ 0x1f, 0x152 }, /* Insert */
|
||||
{ 0x20, 0x147 }, /* Home */
|
||||
{ 0x21, 0x149 }, /* Page Up */
|
||||
{ 0x22, 0x45 },
|
||||
{ 0x23, 0x135 },
|
||||
{ 0x24, 0x37 },
|
||||
{ 0x25, 0x4a },
|
||||
{ 0x26, 0x0f }, /* Tab */
|
||||
{ 0x27, 0x10 },
|
||||
{ 0x28, 0x11 },
|
||||
{ 0x29, 0x12 },
|
||||
{ 0x2a, 0x13 },
|
||||
{ 0x2b, 0x14 },
|
||||
{ 0x2c, 0x15 },
|
||||
{ 0x2d, 0x16 },
|
||||
{ 0x2e, 0x17 },
|
||||
{ 0x2f, 0x18 },
|
||||
{ 0x30, 0x19 },
|
||||
{ 0x31, 0x1a },
|
||||
{ 0x32, 0x1b },
|
||||
{ 0x33, 0x2b },
|
||||
{ 0x34, 0x153 }, /* Delete */
|
||||
{ 0x35, 0x14f }, /* End */
|
||||
{ 0x36, 0x151 }, /* Page Down */
|
||||
{ 0x37, 0x47 },
|
||||
{ 0x38, 0x48 },
|
||||
{ 0x39, 0x49 },
|
||||
{ 0x3a, 0x4e },
|
||||
{ 0x3b, 0x3a },
|
||||
{ 0x3c, 0x1e },
|
||||
{ 0x3d, 0x1f },
|
||||
{ 0x3e, 0x20 },
|
||||
{ 0x3f, 0x21 },
|
||||
{ 0x40, 0x22 },
|
||||
{ 0x41, 0x23 },
|
||||
{ 0x42, 0x24 },
|
||||
{ 0x43, 0x25 },
|
||||
{ 0x44, 0x26 },
|
||||
{ 0x45, 0x27 },
|
||||
{ 0x46, 0x28 },
|
||||
{ 0x47, 0x1c }, /* Enter */
|
||||
{ 0x48, 0x4b },
|
||||
{ 0x49, 0x4c },
|
||||
{ 0x4a, 0x4d },
|
||||
{ 0x4b, 0x2a },
|
||||
{ 0x4c, 0x2c },
|
||||
{ 0x4d, 0x2d },
|
||||
{ 0x4e, 0x2e },
|
||||
{ 0x4f, 0x2f },
|
||||
{ 0x50, 0x30 },
|
||||
{ 0x51, 0x31 },
|
||||
{ 0x52, 0x32 },
|
||||
{ 0x53, 0x33 },
|
||||
{ 0x54, 0x34 },
|
||||
{ 0x55, 0x35 },
|
||||
{ 0x56, 0x36 },
|
||||
{ 0x57, 0x148 }, /* up arrow */
|
||||
{ 0x58, 0x51 },
|
||||
{ 0x59, 0x50 },
|
||||
{ 0x5a, 0x4f },
|
||||
{ 0x5b, 0x11c },
|
||||
{ 0x5c, 0x1d },
|
||||
{ 0x5d, 0x38 },
|
||||
{ 0x5e, 0x39 }, /* space bar */
|
||||
{ 0x5f, 0x138 },
|
||||
{ 0x60, 0x11d },
|
||||
{ 0x61, 0x14b }, /* left arrow */
|
||||
{ 0x62, 0x150 }, /* down arrow */
|
||||
{ 0x63, 0x14d }, /* right arrow */
|
||||
{ 0x64, 0x52 },
|
||||
{ 0x65, 0x53 },
|
||||
{ 0x66, 0x15b },
|
||||
{ 0x67, 0x15c },
|
||||
{ 0x68, 0x15d },
|
||||
{ 0x69, 0x56 },
|
||||
{ 0x7e, 0x137 }, /* System Request */
|
||||
{ 0x7f, 0x145 }, /* Break */
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
static std::array<uint32_t, 127> cocoa_keycodes = { /* key names in parentheses are not declared by Apple headers */
|
||||
static std::array<uint32_t, 127> cocoa_keycodes = {
|
||||
/* key names in parentheses are not declared by Apple headers */
|
||||
0x1e, /* ANSI_A */
|
||||
0x1f, /* ANSI_S */
|
||||
0x20, /* ANSI_D */
|
||||
@@ -66,9 +67,9 @@ static std::array<uint32_t, 127> cocoa_keycodes = { /* key names in parentheses
|
||||
0x5e, /* F17 => F14 */
|
||||
0x53, /* ANSI_KeypadDecimal */
|
||||
0,
|
||||
0x37, /* ANSI_KeypadMultiply */
|
||||
0x37, /* ANSI_KeypadMultiply */
|
||||
0,
|
||||
0x4e, /* ANSI_KeypadPlus */
|
||||
0x4e, /* ANSI_KeypadPlus */
|
||||
0,
|
||||
0x45, /* ANSI_KeypadClear => Num Lock (location equivalent) */
|
||||
0x130, /* VolumeUp */
|
||||
|
||||
@@ -16,132 +16,132 @@
|
||||
#include <QtDebug>
|
||||
|
||||
static std::unordered_map<uint32_t, uint16_t> evdev_keycodes = {
|
||||
{184, 0x46}, /* F14 => Scroll Lock (for Apple keyboards) */
|
||||
{86, 0x56}, /* 102ND */
|
||||
{87, 0x57}, /* F11 */
|
||||
{88, 0x58}, /* F12 */
|
||||
{186, 0x5d}, /* F16 => F13 */
|
||||
{187, 0x5e}, /* F17 => F14 */
|
||||
{188, 0x5f}, /* F18 => F15 */
|
||||
{ 184, 0x46 }, /* F14 => Scroll Lock (for Apple keyboards) */
|
||||
{ 86, 0x56 }, /* 102ND */
|
||||
{ 87, 0x57 }, /* F11 */
|
||||
{ 88, 0x58 }, /* F12 */
|
||||
{ 186, 0x5d }, /* F16 => F13 */
|
||||
{ 187, 0x5e }, /* F17 => F14 */
|
||||
{ 188, 0x5f }, /* F18 => F15 */
|
||||
|
||||
/* Japanese keys. */
|
||||
{95, 0x5c}, /* KPJPCOMMA */
|
||||
{93, 0x70}, /* KATAKANAHIRAGANA */
|
||||
{89, 0x73}, /* RO */
|
||||
{85, 0x76}, /* ZENKAKUHANKAKU */
|
||||
{91, 0x77}, /* HIRAGANA */
|
||||
{90, 0x78}, /* KATAKANA */
|
||||
{92, 0x79}, /* HENKAN */
|
||||
{94, 0x7b}, /* MUHENKAN */
|
||||
{124, 0x7d}, /* YEN */
|
||||
{121, 0x7e}, /* KPCOMMA */
|
||||
{ 95, 0x5c }, /* KPJPCOMMA */
|
||||
{ 93, 0x70 }, /* KATAKANAHIRAGANA */
|
||||
{ 89, 0x73 }, /* RO */
|
||||
{ 85, 0x76 }, /* ZENKAKUHANKAKU */
|
||||
{ 91, 0x77 }, /* HIRAGANA */
|
||||
{ 90, 0x78 }, /* KATAKANA */
|
||||
{ 92, 0x79 }, /* HENKAN */
|
||||
{ 94, 0x7b }, /* MUHENKAN */
|
||||
{ 124, 0x7d }, /* YEN */
|
||||
{ 121, 0x7e }, /* KPCOMMA */
|
||||
|
||||
/* Korean keys. */
|
||||
{123, 0xf1}, /* HANJA */
|
||||
{122, 0xf2}, /* HANGUL */
|
||||
{ 123, 0xf1 }, /* HANJA */
|
||||
{ 122, 0xf2 }, /* HANGUL */
|
||||
|
||||
{96, 0x11c}, /* KPENTER */
|
||||
{97, 0x11d}, /* RIGHTCTRL */
|
||||
{98, 0x135}, /* KPSLASH */
|
||||
{99, 0x137}, /* SYSRQ */
|
||||
{183, 0x137}, /* F13 => SysRq (for Apple keyboards) */
|
||||
{100, 0x138}, /* RIGHTALT */
|
||||
{119, 0x145}, /* PAUSE */
|
||||
{411, 0x145}, /* BREAK */
|
||||
{185, 0x145}, /* F15 => Pause (for Apple keyboards) */
|
||||
{102, 0x147}, /* HOME */
|
||||
{103, 0x148}, /* UP */
|
||||
{104, 0x149}, /* PAGEUP */
|
||||
{105, 0x14b}, /* LEFT */
|
||||
{106, 0x14d}, /* RIGHT */
|
||||
{107, 0x14f}, /* END */
|
||||
{108, 0x150}, /* DOWN */
|
||||
{109, 0x151}, /* PAGEDOWN */
|
||||
{110, 0x152}, /* INSERT */
|
||||
{111, 0x153}, /* DELETE */
|
||||
{ 96, 0x11c }, /* KPENTER */
|
||||
{ 97, 0x11d }, /* RIGHTCTRL */
|
||||
{ 98, 0x135 }, /* KPSLASH */
|
||||
{ 99, 0x137 }, /* SYSRQ */
|
||||
{ 183, 0x137 }, /* F13 => SysRq (for Apple keyboards) */
|
||||
{ 100, 0x138 }, /* RIGHTALT */
|
||||
{ 119, 0x145 }, /* PAUSE */
|
||||
{ 411, 0x145 }, /* BREAK */
|
||||
{ 185, 0x145 }, /* F15 => Pause (for Apple keyboards) */
|
||||
{ 102, 0x147 }, /* HOME */
|
||||
{ 103, 0x148 }, /* UP */
|
||||
{ 104, 0x149 }, /* PAGEUP */
|
||||
{ 105, 0x14b }, /* LEFT */
|
||||
{ 106, 0x14d }, /* RIGHT */
|
||||
{ 107, 0x14f }, /* END */
|
||||
{ 108, 0x150 }, /* DOWN */
|
||||
{ 109, 0x151 }, /* PAGEDOWN */
|
||||
{ 110, 0x152 }, /* INSERT */
|
||||
{ 111, 0x153 }, /* DELETE */
|
||||
|
||||
{125, 0x15b}, /* LEFTMETA */
|
||||
{126, 0x15c}, /* RIGHTMETA */
|
||||
{127, 0x15d}, /* COMPOSE => Menu */
|
||||
{ 125, 0x15b }, /* LEFTMETA */
|
||||
{ 126, 0x15c }, /* RIGHTMETA */
|
||||
{ 127, 0x15d }, /* COMPOSE => Menu */
|
||||
|
||||
/* Multimedia keys. Guideline is to try and follow the Microsoft standard, then
|
||||
fill in remaining scancodes with OEM-specific keys for redundancy sake. Keys
|
||||
marked with # are not translated into evdev codes by the standard atkbd driver. */
|
||||
{634, 0x54}, /* SELECTIVE_SCREENSHOT# => Alt+SysRq */
|
||||
{117, 0x59}, /* KPEQUAL */
|
||||
{418, 0x6a}, /* ZOOMIN# => Logitech */
|
||||
{420, 0x6b}, /* ZOOMRESET# => Logitech */
|
||||
{223, 0x6d}, /* CANCEL# => Logitech */
|
||||
{132, 0x101}, /* # Logitech Task Select */
|
||||
{148, 0x102}, /* PROG1# => Samsung */
|
||||
{149, 0x103}, /* PROG2# => Samsung */
|
||||
{419, 0x104}, /* ZOOMOUT# => Logitech */
|
||||
{144, 0x105}, /* FILE# => Messenger/Files */
|
||||
{216, 0x105}, /* CHAT# => Messenger/Files */
|
||||
{430, 0x105}, /* MESSENGER# */
|
||||
{182, 0x107}, /* REDO# */
|
||||
{131, 0x108}, /* UNDO# */
|
||||
{135, 0x10a}, /* PASTE# */
|
||||
{177, 0x10b}, /* SCROLLUP# => normal speed */
|
||||
{165, 0x110}, /* PREVIOUSSONG */
|
||||
{136, 0x112}, /* FIND# => Logitech */
|
||||
{421, 0x113}, /* WORDPROCESSOR# => Word */
|
||||
{423, 0x114}, /* SPREADSHEET# => Excel */
|
||||
{397, 0x115}, /* CALENDAR# */
|
||||
{433, 0x116}, /* LOGOFF# */
|
||||
{137, 0x117}, /* CUT# */
|
||||
{133, 0x118}, /* COPY# */
|
||||
{163, 0x119}, /* NEXTSONG */
|
||||
{154, 0x11e}, /* CYCLEWINDOWS => Application Right (no left counterpart) */
|
||||
{113, 0x120}, /* MUTE */
|
||||
{140, 0x121}, /* CALC */
|
||||
{164, 0x122}, /* PLAYPAUSE */
|
||||
{432, 0x123}, /* SPELLCHECK# */
|
||||
{166, 0x124}, /* STOPCD */
|
||||
{139, 0x126}, /* MENU# => Shortcut/Menu/Help for a few OEMs */
|
||||
{114, 0x12e}, /* VOL- */
|
||||
{160, 0x12f}, /* CLOSECD# => Logitech Eject */
|
||||
{161, 0x12f}, /* EJECTCD# => Logitech */
|
||||
{162, 0x12f}, /* EJECTCLOSECD# => Logitech */
|
||||
{115, 0x130}, /* VOL+ */
|
||||
{150, 0x132}, /* WWW# */
|
||||
{172, 0x132}, /* HOMEPAGE */
|
||||
{138, 0x13b}, /* HELP# */
|
||||
{213, 0x13c}, /* SOUND# => My Music/Office Home */
|
||||
{360, 0x13c}, /* VENDOR# => My Music/Office Home */
|
||||
{204, 0x13d}, /* DASHBOARD# => Task Pane */
|
||||
{181, 0x13e}, /* NEW# */
|
||||
{134, 0x13f}, /* OPEN# */
|
||||
{206, 0x140}, /* CLOSE# */
|
||||
{232, 0x141}, /* REPLY# */
|
||||
{233, 0x142}, /* FORWARDMAIL# */
|
||||
{231, 0x143}, /* SEND# */
|
||||
{151, 0x144}, /* MSDOS# */
|
||||
{112, 0x14c}, /* MACRO */
|
||||
{179, 0x14c}, /* KPLEFTPAREN# */
|
||||
{118, 0x14e}, /* KPPLUSMINUS */
|
||||
{235, 0x155}, /* DOCUMENTS# => Logitech */
|
||||
{234, 0x157}, /* SAVE# */
|
||||
{210, 0x158}, /* PRINT# */
|
||||
{116, 0x15e}, /* POWER */
|
||||
{142, 0x15f}, /* SLEEP */
|
||||
{143, 0x163}, /* WAKEUP */
|
||||
{180, 0x164}, /* KPRIGHTPAREN# */
|
||||
{212, 0x164}, /* CAMERA# => My Pictures */
|
||||
{217, 0x165}, /* SEARCH */
|
||||
{156, 0x166}, /* BOOKMARKS => Favorites */
|
||||
{364, 0x166}, /* FAVORITES# */
|
||||
{173, 0x167}, /* REFRESH */
|
||||
{128, 0x168}, /* STOP */
|
||||
{159, 0x169}, /* FORWARD */
|
||||
{158, 0x16a}, /* BACK */
|
||||
{157, 0x16b}, /* COMPUTER */
|
||||
{155, 0x16c}, /* MAIL */
|
||||
{215, 0x16c}, /* EMAIL# */
|
||||
{226, 0x16d}, /* MEDIA */
|
||||
{167, 0x178}, /* RECORD# => Logitech */
|
||||
{152, 0x17a}, /* COFFEE/SCREENLOCK# */
|
||||
{178, 0x18b}, /* SCROLLDOWN# => normal speed */
|
||||
{ 634, 0x54 }, /* SELECTIVE_SCREENSHOT# => Alt+SysRq */
|
||||
{ 117, 0x59 }, /* KPEQUAL */
|
||||
{ 418, 0x6a }, /* ZOOMIN# => Logitech */
|
||||
{ 420, 0x6b }, /* ZOOMRESET# => Logitech */
|
||||
{ 223, 0x6d }, /* CANCEL# => Logitech */
|
||||
{ 132, 0x101 }, /* # Logitech Task Select */
|
||||
{ 148, 0x102 }, /* PROG1# => Samsung */
|
||||
{ 149, 0x103 }, /* PROG2# => Samsung */
|
||||
{ 419, 0x104 }, /* ZOOMOUT# => Logitech */
|
||||
{ 144, 0x105 }, /* FILE# => Messenger/Files */
|
||||
{ 216, 0x105 }, /* CHAT# => Messenger/Files */
|
||||
{ 430, 0x105 }, /* MESSENGER# */
|
||||
{ 182, 0x107 }, /* REDO# */
|
||||
{ 131, 0x108 }, /* UNDO# */
|
||||
{ 135, 0x10a }, /* PASTE# */
|
||||
{ 177, 0x10b }, /* SCROLLUP# => normal speed */
|
||||
{ 165, 0x110 }, /* PREVIOUSSONG */
|
||||
{ 136, 0x112 }, /* FIND# => Logitech */
|
||||
{ 421, 0x113 }, /* WORDPROCESSOR# => Word */
|
||||
{ 423, 0x114 }, /* SPREADSHEET# => Excel */
|
||||
{ 397, 0x115 }, /* CALENDAR# */
|
||||
{ 433, 0x116 }, /* LOGOFF# */
|
||||
{ 137, 0x117 }, /* CUT# */
|
||||
{ 133, 0x118 }, /* COPY# */
|
||||
{ 163, 0x119 }, /* NEXTSONG */
|
||||
{ 154, 0x11e }, /* CYCLEWINDOWS => Application Right (no left counterpart) */
|
||||
{ 113, 0x120 }, /* MUTE */
|
||||
{ 140, 0x121 }, /* CALC */
|
||||
{ 164, 0x122 }, /* PLAYPAUSE */
|
||||
{ 432, 0x123 }, /* SPELLCHECK# */
|
||||
{ 166, 0x124 }, /* STOPCD */
|
||||
{ 139, 0x126 }, /* MENU# => Shortcut/Menu/Help for a few OEMs */
|
||||
{ 114, 0x12e }, /* VOL- */
|
||||
{ 160, 0x12f }, /* CLOSECD# => Logitech Eject */
|
||||
{ 161, 0x12f }, /* EJECTCD# => Logitech */
|
||||
{ 162, 0x12f }, /* EJECTCLOSECD# => Logitech */
|
||||
{ 115, 0x130 }, /* VOL+ */
|
||||
{ 150, 0x132 }, /* WWW# */
|
||||
{ 172, 0x132 }, /* HOMEPAGE */
|
||||
{ 138, 0x13b }, /* HELP# */
|
||||
{ 213, 0x13c }, /* SOUND# => My Music/Office Home */
|
||||
{ 360, 0x13c }, /* VENDOR# => My Music/Office Home */
|
||||
{ 204, 0x13d }, /* DASHBOARD# => Task Pane */
|
||||
{ 181, 0x13e }, /* NEW# */
|
||||
{ 134, 0x13f }, /* OPEN# */
|
||||
{ 206, 0x140 }, /* CLOSE# */
|
||||
{ 232, 0x141 }, /* REPLY# */
|
||||
{ 233, 0x142 }, /* FORWARDMAIL# */
|
||||
{ 231, 0x143 }, /* SEND# */
|
||||
{ 151, 0x144 }, /* MSDOS# */
|
||||
{ 112, 0x14c }, /* MACRO */
|
||||
{ 179, 0x14c }, /* KPLEFTPAREN# */
|
||||
{ 118, 0x14e }, /* KPPLUSMINUS */
|
||||
{ 235, 0x155 }, /* DOCUMENTS# => Logitech */
|
||||
{ 234, 0x157 }, /* SAVE# */
|
||||
{ 210, 0x158 }, /* PRINT# */
|
||||
{ 116, 0x15e }, /* POWER */
|
||||
{ 142, 0x15f }, /* SLEEP */
|
||||
{ 143, 0x163 }, /* WAKEUP */
|
||||
{ 180, 0x164 }, /* KPRIGHTPAREN# */
|
||||
{ 212, 0x164 }, /* CAMERA# => My Pictures */
|
||||
{ 217, 0x165 }, /* SEARCH */
|
||||
{ 156, 0x166 }, /* BOOKMARKS => Favorites */
|
||||
{ 364, 0x166 }, /* FAVORITES# */
|
||||
{ 173, 0x167 }, /* REFRESH */
|
||||
{ 128, 0x168 }, /* STOP */
|
||||
{ 159, 0x169 }, /* FORWARD */
|
||||
{ 158, 0x16a }, /* BACK */
|
||||
{ 157, 0x16b }, /* COMPUTER */
|
||||
{ 155, 0x16c }, /* MAIL */
|
||||
{ 215, 0x16c }, /* EMAIL# */
|
||||
{ 226, 0x16d }, /* MEDIA */
|
||||
{ 167, 0x178 }, /* RECORD# => Logitech */
|
||||
{ 152, 0x17a }, /* COFFEE/SCREENLOCK# */
|
||||
{ 178, 0x18b }, /* SCROLLDOWN# => normal speed */
|
||||
};
|
||||
|
||||
uint16_t
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/vid_cga_comp.h>
|
||||
@@ -16,11 +15,11 @@ CGASettingsDialog::CGASettingsDialog(QWidget *parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
cga_hue = vid_cga_comp_hue;
|
||||
cga_hue = vid_cga_comp_hue;
|
||||
cga_saturation = vid_cga_comp_saturation;
|
||||
cga_brightness = vid_cga_comp_brightness;
|
||||
cga_contrast = vid_cga_comp_contrast;
|
||||
cga_sharpness = vid_cga_comp_sharpness;
|
||||
cga_contrast = vid_cga_comp_contrast;
|
||||
cga_sharpness = vid_cga_comp_sharpness;
|
||||
|
||||
ui->horizontalSliderHue->setValue(vid_cga_comp_hue);
|
||||
ui->horizontalSliderSaturation->setValue(vid_cga_comp_saturation);
|
||||
@@ -29,8 +28,7 @@ CGASettingsDialog::CGASettingsDialog(QWidget *parent)
|
||||
ui->horizontalSliderSharpness->setValue(vid_cga_comp_sharpness);
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &CGASettingsDialog::applySettings);
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, [this]
|
||||
{
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, [this] {
|
||||
ui->horizontalSliderHue->setValue(0);
|
||||
ui->horizontalSliderSaturation->setValue(100);
|
||||
ui->horizontalSliderBrightness->setValue(0);
|
||||
@@ -38,11 +36,11 @@ CGASettingsDialog::CGASettingsDialog(QWidget *parent)
|
||||
ui->horizontalSliderSharpness->setValue(0);
|
||||
});
|
||||
|
||||
connect(ui->horizontalSliderHue, &QSlider::valueChanged, this, [this] { updateDisplay(); } );
|
||||
connect(ui->horizontalSliderSaturation, &QSlider::valueChanged, this, [this] { updateDisplay(); } );
|
||||
connect(ui->horizontalSliderBrightness, &QSlider::valueChanged, this, [this] { updateDisplay(); } );
|
||||
connect(ui->horizontalSliderContrast, &QSlider::valueChanged, this, [this] { updateDisplay(); } );
|
||||
connect(ui->horizontalSliderSharpness, &QSlider::valueChanged, this, [this] { updateDisplay(); } );
|
||||
connect(ui->horizontalSliderHue, &QSlider::valueChanged, this, [this] { updateDisplay(); });
|
||||
connect(ui->horizontalSliderSaturation, &QSlider::valueChanged, this, [this] { updateDisplay(); });
|
||||
connect(ui->horizontalSliderBrightness, &QSlider::valueChanged, this, [this] { updateDisplay(); });
|
||||
connect(ui->horizontalSliderContrast, &QSlider::valueChanged, this, [this] { updateDisplay(); });
|
||||
connect(ui->horizontalSliderSharpness, &QSlider::valueChanged, this, [this] { updateDisplay(); });
|
||||
}
|
||||
|
||||
CGASettingsDialog::~CGASettingsDialog()
|
||||
@@ -50,7 +48,8 @@ CGASettingsDialog::~CGASettingsDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CGASettingsDialog::updateDisplay()
|
||||
void
|
||||
CGASettingsDialog::updateDisplay()
|
||||
{
|
||||
auto temp_cga_comp_hue = ui->horizontalSliderHue->value();
|
||||
auto temp_cga_comp_saturation = ui->horizontalSliderSaturation->value();
|
||||
@@ -60,7 +59,8 @@ void CGASettingsDialog::updateDisplay()
|
||||
cga_comp_reload(temp_cga_comp_brightness, temp_cga_comp_saturation, temp_cga_comp_sharpness, temp_cga_comp_hue, temp_cga_comp_contrast);
|
||||
}
|
||||
|
||||
void CGASettingsDialog::applySettings()
|
||||
void
|
||||
CGASettingsDialog::applySettings()
|
||||
{
|
||||
vid_cga_comp_hue = ui->horizontalSliderHue->value();
|
||||
vid_cga_comp_saturation = ui->horizontalSliderSaturation->value();
|
||||
@@ -69,26 +69,27 @@ void CGASettingsDialog::applySettings()
|
||||
vid_cga_comp_sharpness = ui->horizontalSliderSharpness->value();
|
||||
cga_comp_reload(vid_cga_comp_brightness, vid_cga_comp_saturation, vid_cga_comp_sharpness, vid_cga_comp_hue, vid_cga_comp_contrast);
|
||||
|
||||
cga_hue = vid_cga_comp_hue;
|
||||
cga_hue = vid_cga_comp_hue;
|
||||
cga_saturation = vid_cga_comp_saturation;
|
||||
cga_brightness = vid_cga_comp_brightness;
|
||||
cga_contrast = vid_cga_comp_contrast;
|
||||
cga_sharpness = vid_cga_comp_sharpness;
|
||||
cga_contrast = vid_cga_comp_contrast;
|
||||
cga_sharpness = vid_cga_comp_sharpness;
|
||||
}
|
||||
|
||||
void CGASettingsDialog::on_buttonBox_accepted()
|
||||
void
|
||||
CGASettingsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void CGASettingsDialog::on_buttonBox_rejected()
|
||||
void
|
||||
CGASettingsDialog::on_buttonBox_rejected()
|
||||
{
|
||||
vid_cga_comp_hue = cga_hue;
|
||||
vid_cga_comp_hue = cga_hue;
|
||||
vid_cga_comp_saturation = cga_saturation;
|
||||
vid_cga_comp_brightness = cga_brightness;
|
||||
vid_cga_comp_contrast = cga_contrast;
|
||||
vid_cga_comp_sharpness = cga_sharpness;
|
||||
vid_cga_comp_contrast = cga_contrast;
|
||||
vid_cga_comp_sharpness = cga_sharpness;
|
||||
|
||||
cga_comp_reload(vid_cga_comp_brightness, vid_cga_comp_saturation, vid_cga_comp_sharpness, vid_cga_comp_hue, vid_cga_comp_contrast);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
# include <sys/sysmacros.h>
|
||||
#endif
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
DeviceConfig::DeviceConfig(QWidget *parent)
|
||||
@@ -87,15 +87,16 @@ EnumerateSerialDevices()
|
||||
for (int i = 1; i < 256; i++) {
|
||||
devstr[0] = 0;
|
||||
snprintf(devstr.data(), 1024, R"(\\.\COM%d)", i);
|
||||
const auto handle = CreateFileA(devstr.data(),
|
||||
GENERIC_READ | GENERIC_WRITE, 0,
|
||||
nullptr, OPEN_EXISTING,
|
||||
0, nullptr);
|
||||
const auto handle = CreateFileA(devstr.data(),
|
||||
GENERIC_READ | GENERIC_WRITE, 0,
|
||||
nullptr, OPEN_EXISTING,
|
||||
0, nullptr);
|
||||
const auto dwError = GetLastError();
|
||||
if ((handle != INVALID_HANDLE_VALUE) || (dwError == ERROR_ACCESS_DENIED) ||
|
||||
(dwError == ERROR_GEN_FAILURE) || (dwError == ERROR_SHARING_VIOLATION) ||
|
||||
(dwError == ERROR_SEM_TIMEOUT)) {
|
||||
if (handle != INVALID_HANDLE_VALUE) CloseHandle(handle);
|
||||
if (handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle(handle);
|
||||
serialDevices.push_back(QString(devstr));
|
||||
}
|
||||
}
|
||||
@@ -114,8 +115,8 @@ EnumerateSerialDevices()
|
||||
void
|
||||
DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep)
|
||||
{
|
||||
auto * device_context = static_cast<device_context_t *>(dc);
|
||||
const auto * config = static_cast<const _device_config_ *>(c);
|
||||
auto *device_context = static_cast<device_context_t *>(dc);
|
||||
const auto *config = static_cast<const _device_config_ *>(c);
|
||||
const QString blank = "";
|
||||
int p;
|
||||
int q;
|
||||
@@ -136,7 +137,7 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep)
|
||||
|
||||
const int config_major_type = (config_type >> CONFIG_SHIFT) << CONFIG_SHIFT;
|
||||
|
||||
int value = 0;
|
||||
int value = 0;
|
||||
auto selected = blank;
|
||||
|
||||
switch (config_major_type) {
|
||||
@@ -164,210 +165,211 @@ DeviceConfig::ProcessConfig(void *dc, const void *c, const bool is_dep)
|
||||
default:
|
||||
break;
|
||||
case CONFIG_BINARY:
|
||||
{
|
||||
auto *cbox = new QCheckBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setChecked(value > 0);
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
break;
|
||||
}
|
||||
{
|
||||
auto *cbox = new QCheckBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setChecked(value > 0);
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
break;
|
||||
}
|
||||
#ifdef USE_RTMIDI
|
||||
case CONFIG_MIDI_OUT:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < rtmidi_out_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_out_get_dev_name(i, midiName);
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < rtmidi_out_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_out_get_dev_name(i, midiName);
|
||||
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (i == value)
|
||||
currentIndex = i;
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (i == value)
|
||||
currentIndex = i;
|
||||
}
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_MIDI_IN:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < rtmidi_in_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_in_get_dev_name(i, midiName);
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
for (int i = 0; i < rtmidi_in_get_num_devs(); i++) {
|
||||
char midiName[512] = { 0 };
|
||||
rtmidi_in_get_dev_name(i, midiName);
|
||||
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (i == value)
|
||||
currentIndex = i;
|
||||
Models::AddEntry(model, midiName, i);
|
||||
if (i == value)
|
||||
currentIndex = i;
|
||||
}
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case CONFIG_INT:
|
||||
case CONFIG_SELECTION:
|
||||
case CONFIG_HEX16:
|
||||
case CONFIG_HEX20:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
|
||||
for (auto *sel = config->selection; (sel != nullptr) && (sel->description != nullptr) &&
|
||||
(strlen(sel->description) > 0); ++sel) {
|
||||
int row = Models::AddEntry(model, tr(sel->description), sel->value);
|
||||
for (auto *sel = config->selection; (sel != nullptr) && (sel->description != nullptr) &&
|
||||
(strlen(sel->description) > 0); ++sel) {
|
||||
int row = Models::AddEntry(model, tr(sel->description), sel->value);
|
||||
|
||||
if (sel->value == value)
|
||||
currentIndex = row;
|
||||
}
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_BIOS:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
|
||||
q = 0;
|
||||
for (auto *bios = config->bios; (bios != nullptr) &&
|
||||
(bios->name != nullptr) &&
|
||||
(bios->internal_name != nullptr) &&
|
||||
(strlen(bios->name) > 0) &&
|
||||
(strlen(bios->internal_name) > 0) &&
|
||||
(bios->files_no > 0); ++bios) {
|
||||
p = 0;
|
||||
for (int d = 0; d < bios->files_no; d++)
|
||||
p += !!rom_present(const_cast<char *>(bios->files[d]));
|
||||
if (p == bios->files_no) {
|
||||
const int row = Models::AddEntry(model, tr(bios->name), q);
|
||||
if (!strcmp(selected.toUtf8().constData(), bios->internal_name))
|
||||
if (sel->value == value)
|
||||
currentIndex = row;
|
||||
}
|
||||
q++;
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_BIOS:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = -1;
|
||||
|
||||
q = 0;
|
||||
for (auto *bios = config->bios; (bios != nullptr) &&
|
||||
(bios->name != nullptr) &&
|
||||
(bios->internal_name != nullptr) &&
|
||||
(strlen(bios->name) > 0) &&
|
||||
(strlen(bios->internal_name) > 0) &&
|
||||
(bios->files_no > 0); ++bios) {
|
||||
p = 0;
|
||||
for (int d = 0; d < bios->files_no; d++)
|
||||
p += !!rom_present(const_cast<char *>(bios->files[d]));
|
||||
if (p == bios->files_no) {
|
||||
const int row = Models::AddEntry(model, tr(bios->name), q);
|
||||
if (!strcmp(selected.toUtf8().constData(), bios->internal_name))
|
||||
currentIndex = row;
|
||||
}
|
||||
q++;
|
||||
}
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_SPINNER:
|
||||
{
|
||||
auto *spinBox = new QSpinBox();
|
||||
spinBox->setObjectName(config->name);
|
||||
spinBox->setMaximum(config->spinner.max);
|
||||
spinBox->setMinimum(config->spinner.min);
|
||||
if (config->spinner.step > 0)
|
||||
spinBox->setSingleStep(config->spinner.step);
|
||||
spinBox->setValue(value);
|
||||
this->ui->formLayout->addRow(tr(config->description), spinBox);
|
||||
break;
|
||||
}
|
||||
{
|
||||
auto *spinBox = new QSpinBox();
|
||||
spinBox->setObjectName(config->name);
|
||||
spinBox->setMaximum(config->spinner.max);
|
||||
spinBox->setMinimum(config->spinner.min);
|
||||
if (config->spinner.step > 0)
|
||||
spinBox->setSingleStep(config->spinner.step);
|
||||
spinBox->setValue(value);
|
||||
this->ui->formLayout->addRow(tr(config->description), spinBox);
|
||||
break;
|
||||
}
|
||||
case CONFIG_FNAME:
|
||||
{
|
||||
auto *fileField = new FileField(this);
|
||||
fileField->setObjectName(config->name);
|
||||
fileField->setFileName(selected);
|
||||
/* Get the actually used part of the filter */
|
||||
{
|
||||
auto *fileField = new FileField(this);
|
||||
fileField->setObjectName(config->name);
|
||||
fileField->setFileName(selected);
|
||||
/* Get the actually used part of the filter */
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
QString filter = QString(config->file_filter).left(static_cast<int>(strcspn(config->file_filter, "|")));
|
||||
QString filter = QString(config->file_filter).left(static_cast<int>(strcspn(config->file_filter, "|")));
|
||||
#else
|
||||
QString filter = QString(config->file_filter).split("|").at(0);
|
||||
QString filter = QString(config->file_filter).split("|").at(0);
|
||||
#endif
|
||||
/* Extract the description and the extension list */
|
||||
QRegularExpressionMatch match = QRegularExpression("(.+) \\((.+)\\)$").match(filter);
|
||||
QString description = match.captured(1);
|
||||
QString extensions = match.captured(2);
|
||||
/* Split the extension list up and strip the filename globs */
|
||||
QRegularExpression re("\\*\\.(.*)");
|
||||
/* Extract the description and the extension list */
|
||||
QRegularExpressionMatch match = QRegularExpression("(.+) \\((.+)\\)$").match(filter);
|
||||
QString description = match.captured(1);
|
||||
QString extensions = match.captured(2);
|
||||
/* Split the extension list up and strip the filename globs */
|
||||
QRegularExpression re("\\*\\.(.*)");
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList extensionList;
|
||||
int i = 0;
|
||||
while (extensions.section(' ', i, i) != "") {
|
||||
QString extension = re.match(extensions.section(' ', i, i)).captured(1);
|
||||
extensionList.append(extension);
|
||||
i++;
|
||||
QStringList extensionList;
|
||||
int i = 0;
|
||||
while (extensions.section(' ', i, i) != "") {
|
||||
QString extension = re.match(extensions.section(' ', i, i)).captured(1);
|
||||
extensionList.append(extension);
|
||||
i++;
|
||||
}
|
||||
#else
|
||||
QStringList extensionList = extensions.split(" ");
|
||||
for (int i = 0; i < extensionList.count(); i++)
|
||||
extensionList[i] = re.match(extensionList[i]).captured(1);
|
||||
#endif
|
||||
fileField->setFilter(tr(description.toUtf8().constData()) % util::DlgFilter(extensionList) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
this->ui->formLayout->addRow(tr(config->description), fileField);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
QStringList extensionList = extensions.split(" ");
|
||||
for (int i = 0; i < extensionList.count(); i++)
|
||||
extensionList[i] = re.match(extensionList[i]).captured(1);
|
||||
#endif
|
||||
fileField->setFilter(tr(description.toUtf8().constData()) % util::DlgFilter(extensionList) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
this->ui->formLayout->addRow(tr(config->description), fileField);
|
||||
break;
|
||||
}
|
||||
case CONFIG_STRING:
|
||||
{
|
||||
const auto lineEdit = new QLineEdit;
|
||||
lineEdit->setObjectName(config->name);
|
||||
lineEdit->setCursor(Qt::IBeamCursor);
|
||||
lineEdit->setText(selected);
|
||||
this->ui->formLayout->addRow(tr(config->description), lineEdit);
|
||||
break;
|
||||
}
|
||||
{
|
||||
const auto lineEdit = new QLineEdit;
|
||||
lineEdit->setObjectName(config->name);
|
||||
lineEdit->setCursor(Qt::IBeamCursor);
|
||||
lineEdit->setText(selected);
|
||||
this->ui->formLayout->addRow(tr(config->description), lineEdit);
|
||||
break;
|
||||
}
|
||||
case CONFIG_SERPORT:
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = 0;
|
||||
auto serialDevices = EnumerateSerialDevices();
|
||||
{
|
||||
auto *cbox = new QComboBox();
|
||||
cbox->setObjectName(config->name);
|
||||
cbox->setMaxVisibleItems(30);
|
||||
auto *model = cbox->model();
|
||||
int currentIndex = 0;
|
||||
auto serialDevices = EnumerateSerialDevices();
|
||||
|
||||
Models::AddEntry(model, tr("None"), -1);
|
||||
for (int i = 0; i < serialDevices.size(); i++) {
|
||||
const int row = Models::AddEntry(model, serialDevices[i], i);
|
||||
if (selected == serialDevices[i])
|
||||
currentIndex = row;
|
||||
Models::AddEntry(model, tr("None"), -1);
|
||||
for (int i = 0; i < serialDevices.size(); i++) {
|
||||
const int row = Models::AddEntry(model, serialDevices[i], i);
|
||||
if (selected == serialDevices[i])
|
||||
currentIndex = row;
|
||||
}
|
||||
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
this->ui->formLayout->addRow(tr(config->description), cbox);
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_MAC:
|
||||
{
|
||||
// QHBoxLayout for the line edit widget and the generate button
|
||||
const auto hboxLayout = new QHBoxLayout();
|
||||
const auto generateButton = new QPushButton(tr("Generate"));
|
||||
const auto lineEdit = new QLineEdit;
|
||||
// Allow the line edit to expand and fill available space
|
||||
lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred);
|
||||
lineEdit->setInputMask("HH:HH:HH;0");
|
||||
lineEdit->setObjectName(config->name);
|
||||
// Display the current or generated MAC in uppercase
|
||||
// When stored it will be converted to lowercase
|
||||
if (config_get_mac(device_context->name, config->name,
|
||||
config->default_int) & 0xFF000000) {
|
||||
lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(),
|
||||
random_generate(), random_generate()));
|
||||
} else {
|
||||
auto current_mac = QString(config_get_string(device_context->name, config->name,
|
||||
const_cast<char *>(config->default_string)));
|
||||
lineEdit->setText(current_mac.toUpper());
|
||||
{
|
||||
// QHBoxLayout for the line edit widget and the generate button
|
||||
const auto hboxLayout = new QHBoxLayout();
|
||||
const auto generateButton = new QPushButton(tr("Generate"));
|
||||
const auto lineEdit = new QLineEdit;
|
||||
// Allow the line edit to expand and fill available space
|
||||
lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
lineEdit->setInputMask("HH:HH:HH;0");
|
||||
lineEdit->setObjectName(config->name);
|
||||
// Display the current or generated MAC in uppercase
|
||||
// When stored it will be converted to lowercase
|
||||
if (config_get_mac(device_context->name, config->name,
|
||||
config->default_int)
|
||||
& 0xFF000000) {
|
||||
lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(),
|
||||
random_generate(), random_generate()));
|
||||
} else {
|
||||
auto current_mac = QString(config_get_string(device_context->name, config->name,
|
||||
const_cast<char *>(config->default_string)));
|
||||
lineEdit->setText(current_mac.toUpper());
|
||||
}
|
||||
// Action for the generate button
|
||||
connect(generateButton, &QPushButton::clicked, [lineEdit] {
|
||||
lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(),
|
||||
random_generate(), random_generate()));
|
||||
});
|
||||
hboxLayout->addWidget(lineEdit);
|
||||
hboxLayout->addWidget(generateButton);
|
||||
this->ui->formLayout->addRow(tr(config->description), hboxLayout);
|
||||
break;
|
||||
}
|
||||
// Action for the generate button
|
||||
connect(generateButton, &QPushButton::clicked, [lineEdit] {
|
||||
lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(),
|
||||
random_generate(), random_generate()));
|
||||
});
|
||||
hboxLayout->addWidget(lineEdit);
|
||||
hboxLayout->addWidget(generateButton);
|
||||
this->ui->formLayout->addRow(tr(config->description), hboxLayout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
++config;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
private:
|
||||
Ui::DeviceConfig *ui;
|
||||
void ProcessConfig(void *dc, const void *c, bool is_dep);
|
||||
void ProcessConfig(void *dc, const void *c, bool is_dep);
|
||||
};
|
||||
|
||||
#endif // QT_DEVICECONFIG_HPP
|
||||
|
||||
@@ -23,8 +23,7 @@ extern "C" {
|
||||
#include <86box/plat.h>
|
||||
}
|
||||
|
||||
Downloader::
|
||||
Downloader(const DownloadLocation downloadLocation, QObject *parent)
|
||||
Downloader::Downloader(const DownloadLocation downloadLocation, QObject *parent)
|
||||
: QObject(parent)
|
||||
, file(nullptr)
|
||||
, reply(nullptr)
|
||||
@@ -51,7 +50,9 @@ Downloader(const DownloadLocation downloadLocation, QObject *parent)
|
||||
|
||||
Downloader::~Downloader() { delete file; }
|
||||
|
||||
void Downloader::download(const QUrl &url, const QString &filepath, const QVariant &varData) {
|
||||
void
|
||||
Downloader::download(const QUrl &url, const QString &filepath, const QVariant &varData)
|
||||
{
|
||||
|
||||
variantData = varData;
|
||||
// temporary until I get the plat stuff fixed
|
||||
@@ -62,7 +63,7 @@ void Downloader::download(const QUrl &url, const QString &filepath, const QVaria
|
||||
const auto final_path = downloadDirectory.filePath(filepath);
|
||||
|
||||
file = new QFile(final_path);
|
||||
if(!file->open(QIODevice::WriteOnly)) {
|
||||
if (!file->open(QIODevice::WriteOnly)) {
|
||||
qWarning() << "Unable to open file " << final_path;
|
||||
return;
|
||||
}
|
||||
@@ -70,7 +71,7 @@ void Downloader::download(const QUrl &url, const QString &filepath, const QVaria
|
||||
const auto nam = new QNetworkAccessManager(this);
|
||||
// Create the network request and execute
|
||||
const auto request = QNetworkRequest(url);
|
||||
reply = nam->get(request);
|
||||
reply = nam->get(request);
|
||||
// Connect to the finished signal
|
||||
connect(reply, &QNetworkReply::finished, this, &Downloader::onResult);
|
||||
}
|
||||
@@ -93,4 +94,3 @@ Downloader::onResult()
|
||||
qDebug() << Q_FUNC_INFO << "Downloaded complete: file written to " << file->fileName();
|
||||
emit downloadCompleted(file->fileName(), variantData);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
class Downloader final : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -38,17 +37,17 @@ signals:
|
||||
// Signal emitted when the download is successful
|
||||
void downloadCompleted(QString filename, QVariant varData);
|
||||
// Signal emitted when an error occurs
|
||||
void errorOccurred(const QString&);
|
||||
void errorOccurred(const QString &);
|
||||
|
||||
private slots:
|
||||
void onResult();
|
||||
|
||||
private:
|
||||
QFile *file;
|
||||
QFile *file;
|
||||
QNetworkAccessManager nam;
|
||||
QNetworkReply *reply;
|
||||
QVariant variantData;
|
||||
QDir downloadDirectory;
|
||||
QNetworkReply *reply;
|
||||
QVariant variantData;
|
||||
QDir downloadDirectory;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
#include <QWindow>
|
||||
#include <QCoreApplication>
|
||||
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/ini.h>
|
||||
#include <86box/config.h>
|
||||
@@ -19,25 +18,32 @@ extern "C"
|
||||
#include <86box/path.h>
|
||||
#include <86box/plat.h>
|
||||
|
||||
extern void startblit();
|
||||
extern void endblit();
|
||||
extern void startblit();
|
||||
extern void endblit();
|
||||
extern ssize_t local_getline(char **buf, size_t *bufsiz, FILE *fp);
|
||||
extern char* trim(char* str);
|
||||
extern char *trim(char *str);
|
||||
}
|
||||
|
||||
#define safe_strncpy(a, b, n) \
|
||||
do { \
|
||||
strncpy((a), (b), (n)-1); \
|
||||
(a)[(n)-1] = 0; \
|
||||
} while (0)
|
||||
#define safe_strncpy(a, b, n) \
|
||||
do { \
|
||||
strncpy((a), (b), (n) - 1); \
|
||||
(a)[(n) - 1] = 0; \
|
||||
} while (0)
|
||||
|
||||
static inline void *
|
||||
wx_config_load(const char *path)
|
||||
{
|
||||
ini_t ini = ini_read(path);
|
||||
if (ini)
|
||||
ini_strip_quotes(ini);
|
||||
return (void *) ini;
|
||||
}
|
||||
|
||||
|
||||
static inline void *wx_config_load(const char *path) { ini_t ini = ini_read(path); if (ini) ini_strip_quotes(ini); return (void*)ini; }
|
||||
|
||||
static inline int wx_config_get_string(void *config, const char *name, char *dst, int size, const char *defVal) {
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name);
|
||||
char* str = ini_get_string((ini_t)config, "", name, (char*)defVal);
|
||||
static inline int
|
||||
wx_config_get_string(void *config, const char *name, char *dst, int size, const char *defVal)
|
||||
{
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name);
|
||||
char *str = ini_get_string((ini_t) config, "", name, (char *) defVal);
|
||||
if (size == 0)
|
||||
return res;
|
||||
if (str != NULL)
|
||||
@@ -47,40 +53,56 @@ static inline int wx_config_get_string(void *config, const char *name, char *dst
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int wx_config_get_int(void *config, const char *name, int *dst, int defVal) {
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name);
|
||||
*dst = ini_get_int((ini_t)config, "", name, defVal);
|
||||
static inline int
|
||||
wx_config_get_int(void *config, const char *name, int *dst, int defVal)
|
||||
{
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name);
|
||||
*dst = ini_get_int((ini_t) config, "", name, defVal);
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int wx_config_get_float(void *config, const char *name, float *dst, float defVal) {
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name);
|
||||
*dst = (float)ini_get_double((ini_t)config, "", name, defVal);
|
||||
static inline int
|
||||
wx_config_get_float(void *config, const char *name, float *dst, float defVal)
|
||||
{
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name);
|
||||
*dst = (float) ini_get_double((ini_t) config, "", name, defVal);
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int wx_config_get_bool(void *config, const char *name, int *dst, int defVal) {
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name);
|
||||
*dst = !!ini_get_int((ini_t)config, "", name, defVal);
|
||||
static inline int
|
||||
wx_config_get_bool(void *config, const char *name, int *dst, int defVal)
|
||||
{
|
||||
int res = ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name);
|
||||
*dst = !!ini_get_int((ini_t) config, "", name, defVal);
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline int wx_config_has_entry(void *config, const char *name) { return ini_has_entry(ini_find_or_create_section((ini_t)config, ""), name); }
|
||||
static inline void wx_config_free(void *config) { ini_close(config); };
|
||||
static inline int
|
||||
wx_config_has_entry(void *config, const char *name)
|
||||
{
|
||||
return ini_has_entry(ini_find_or_create_section((ini_t) config, ""), name);
|
||||
}
|
||||
static inline void
|
||||
wx_config_free(void *config)
|
||||
{
|
||||
ini_close(config);
|
||||
};
|
||||
|
||||
static int endswith(const char *str, const char *ext) {
|
||||
const char *p;
|
||||
int elen = strlen(ext);
|
||||
int slen = strlen(str);
|
||||
if (slen >= elen) {
|
||||
p = &str[slen - elen];
|
||||
for (int i = 0; i < elen; ++i) {
|
||||
if (tolower(p[i]) != tolower(ext[i]))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
static int
|
||||
endswith(const char *str, const char *ext)
|
||||
{
|
||||
const char *p;
|
||||
int elen = strlen(ext);
|
||||
int slen = strlen(str);
|
||||
if (slen >= elen) {
|
||||
p = &str[slen - elen];
|
||||
for (int i = 0; i < elen; ++i) {
|
||||
if (tolower(p[i]) != tolower(ext[i]))
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -101,326 +123,355 @@ glsl_detect_bom(const char *fn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *load_file(const char *fn) {
|
||||
int bom = glsl_detect_bom(fn);
|
||||
FILE *fp = plat_fopen(fn, "rb");
|
||||
if (!fp)
|
||||
return 0;
|
||||
fseek(fp, 0, SEEK_END);
|
||||
long fsize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
static char *
|
||||
load_file(const char *fn)
|
||||
{
|
||||
int bom = glsl_detect_bom(fn);
|
||||
FILE *fp = plat_fopen(fn, "rb");
|
||||
if (!fp)
|
||||
return 0;
|
||||
fseek(fp, 0, SEEK_END);
|
||||
long fsize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
if (bom) {
|
||||
fsize -= 3;
|
||||
fseek(fp, 3, SEEK_SET);
|
||||
}
|
||||
|
||||
char *data = (char *) malloc(fsize + 1);
|
||||
|
||||
size_t read_bytes = fread(data, fsize, 1, fp);
|
||||
if (read_bytes != 1) {
|
||||
fclose(fp);
|
||||
free(data);
|
||||
return nullptr;
|
||||
} else {
|
||||
fclose(fp);
|
||||
|
||||
data[fsize] = 0;
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
strip_lines(const char *program, const char *starts_with)
|
||||
{
|
||||
/* strip parameters */
|
||||
char *ptr = (char *) strstr(program, starts_with);
|
||||
while (ptr != nullptr) {
|
||||
while (*ptr != '\n' && *ptr != '\0')
|
||||
*ptr++ = ' ';
|
||||
ptr = (char *) strstr(program, starts_with);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
strip_parameters(const char *program)
|
||||
{
|
||||
/* strip parameters */
|
||||
strip_lines(program, "#pragma parameter");
|
||||
}
|
||||
|
||||
static void
|
||||
strip_defines(const char *program)
|
||||
{
|
||||
/* strip texture define */
|
||||
strip_lines(program, "#define texture");
|
||||
}
|
||||
|
||||
static int
|
||||
has_parameter(glslp_t *glsl, char *id)
|
||||
{
|
||||
for (int i = 0; i < glsl->num_parameters; ++i)
|
||||
if (!strcmp(glsl->parameters[i].id, id))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_parameters(glslp_t *glsl)
|
||||
{
|
||||
struct parameter p;
|
||||
for (int i = 0; i < glsl->num_shaders; ++i) {
|
||||
size_t size = 0;
|
||||
char *line = NULL;
|
||||
struct shader *shader = &glsl->shaders[i];
|
||||
int bom = glsl_detect_bom(shader->shader_fn);
|
||||
FILE *f = plat_fopen(shader->shader_fn, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
if (bom) {
|
||||
fsize -= 3;
|
||||
fseek(fp, 3, SEEK_SET);
|
||||
fseek(f, 3, SEEK_SET);
|
||||
}
|
||||
while (local_getline(&line, &size, f) != -1 && glsl->num_parameters < MAX_PARAMETERS) {
|
||||
line[strcspn(line, "\r\n")] = '\0';
|
||||
trim(line);
|
||||
int num = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", p.id, p.description,
|
||||
&p.default_value, &p.min, &p.max, &p.step);
|
||||
if (num < 5)
|
||||
continue;
|
||||
p.id[63] = 0;
|
||||
p.description[63] = 0;
|
||||
|
||||
if (num == 5)
|
||||
p.step = 0.1f * (p.max - p.min);
|
||||
|
||||
p.value = p.default_value;
|
||||
|
||||
if (!has_parameter(glsl, p.id)) {
|
||||
memcpy(&glsl->parameters[glsl->num_parameters++], &p, sizeof(struct parameter));
|
||||
pclog("Read parameter: %s (%s) %f, %f -> %f (%f)\n", p.id, p.description, p.default_value, p.min,
|
||||
p.max, p.step);
|
||||
}
|
||||
}
|
||||
|
||||
char *data = (char*)malloc(fsize + 1);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
size_t read_bytes = fread(data, fsize, 1, fp);
|
||||
if (read_bytes != 1) {
|
||||
fclose(fp);
|
||||
free(data);
|
||||
return nullptr;
|
||||
} else {
|
||||
fclose(fp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
data[fsize] = 0;
|
||||
|
||||
return data;
|
||||
static struct parameter *
|
||||
get_parameter(glslp_t *glslp, const char *id)
|
||||
{
|
||||
for (int i = 0; i < glslp->num_parameters; ++i) {
|
||||
if (!strcmp(glslp->parameters[i].id, id)) {
|
||||
return &glslp->parameters[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void strip_lines(const char *program, const char *starts_with) {
|
||||
/* strip parameters */
|
||||
char *ptr = (char *) strstr(program, starts_with);
|
||||
while (ptr != nullptr) {
|
||||
while (*ptr != '\n' && *ptr != '\0')
|
||||
*ptr++ = ' ';
|
||||
ptr = (char *) strstr(program, starts_with);
|
||||
}
|
||||
}
|
||||
|
||||
static void strip_parameters(const char *program) {
|
||||
/* strip parameters */
|
||||
strip_lines(program, "#pragma parameter");
|
||||
}
|
||||
|
||||
static void strip_defines(const char *program) {
|
||||
/* strip texture define */
|
||||
strip_lines(program, "#define texture");
|
||||
}
|
||||
|
||||
static int has_parameter(glslp_t *glsl, char *id) {
|
||||
for (int i = 0; i < glsl->num_parameters; ++i)
|
||||
if (!strcmp(glsl->parameters[i].id, id))
|
||||
return 1;
|
||||
static glslp_t *
|
||||
glsl_parse(const char *f)
|
||||
{
|
||||
glslp_t *glslp = (glslp_t *) calloc(1, sizeof(glslp_t));
|
||||
glslp->num_shaders = 1;
|
||||
struct shader *shader = &glslp->shaders[0];
|
||||
strcpy(shader->shader_fn, f);
|
||||
shader->shader_program = load_file(f);
|
||||
if (!shader->shader_program) {
|
||||
QMessageBox::critical((QWidget *) qApp->findChild<QWindow *>(), QObject::tr("GLSL error"), QObject::tr("Could not load shader: %1").arg(shader->shader_fn));
|
||||
// wx_simple_messagebox("GLSL error", "Could not load shader %s\n", shader->shader_fn);
|
||||
glslp_free(glslp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_parameters(glslp_t *glsl) {
|
||||
struct parameter p;
|
||||
for (int i = 0; i < glsl->num_shaders; ++i) {
|
||||
size_t size = 0;
|
||||
char* line = NULL;
|
||||
struct shader *shader = &glsl->shaders[i];
|
||||
int bom = glsl_detect_bom(shader->shader_fn);
|
||||
FILE *f = plat_fopen(shader->shader_fn, "rb");
|
||||
if (!f)
|
||||
return 0;
|
||||
if (bom) {
|
||||
fseek(f, 3, SEEK_SET);
|
||||
}
|
||||
while (local_getline(&line, &size, f) != -1 && glsl->num_parameters < MAX_PARAMETERS) {
|
||||
line[strcspn(line, "\r\n")] = '\0';
|
||||
trim(line);
|
||||
int num = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", p.id, p.description,
|
||||
&p.default_value, &p.min, &p.max, &p.step);
|
||||
if (num < 5)
|
||||
continue;
|
||||
p.id[63] = 0;
|
||||
p.description[63] = 0;
|
||||
|
||||
if (num == 5)
|
||||
p.step = 0.1f * (p.max - p.min);
|
||||
|
||||
p.value = p.default_value;
|
||||
|
||||
if (!has_parameter(glsl, p.id)) {
|
||||
memcpy(&glsl->parameters[glsl->num_parameters++], &p, sizeof(struct parameter));
|
||||
pclog("Read parameter: %s (%s) %f, %f -> %f (%f)\n", p.id, p.description, p.default_value, p.min,
|
||||
p.max, p.step);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct parameter *get_parameter(glslp_t *glslp, const char *id) {
|
||||
for (int i = 0; i < glslp->num_parameters; ++i) {
|
||||
if (!strcmp(glslp->parameters[i].id, id)) {
|
||||
return &glslp->parameters[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static glslp_t *glsl_parse(const char *f) {
|
||||
glslp_t *glslp = (glslp_t*) calloc(1, sizeof(glslp_t));
|
||||
glslp->num_shaders = 1;
|
||||
struct shader *shader = &glslp->shaders[0];
|
||||
strcpy(shader->shader_fn, f);
|
||||
shader->shader_program = load_file(f);
|
||||
if (!shader->shader_program) {
|
||||
QMessageBox::critical((QWidget *) qApp->findChild<QWindow *>(), QObject::tr("GLSL error"), QObject::tr("Could not load shader: %1").arg(shader->shader_fn));
|
||||
//wx_simple_messagebox("GLSL error", "Could not load shader %s\n", shader->shader_fn);
|
||||
glslp_free(glslp);
|
||||
return 0;
|
||||
}
|
||||
strip_parameters(shader->shader_program);
|
||||
strip_defines(shader->shader_program);
|
||||
shader->scale_x = shader->scale_y = 1.0f;
|
||||
strcpy(shader->scale_type_x, "source");
|
||||
strcpy(shader->scale_type_y, "source");
|
||||
get_parameters(glslp);
|
||||
return glslp;
|
||||
}
|
||||
strip_parameters(shader->shader_program);
|
||||
strip_defines(shader->shader_program);
|
||||
shader->scale_x = shader->scale_y = 1.0f;
|
||||
strcpy(shader->scale_type_x, "source");
|
||||
strcpy(shader->scale_type_y, "source");
|
||||
get_parameters(glslp);
|
||||
return glslp;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
void get_glslp_name(const char *f, char *s, int size) { safe_strncpy(s, path_get_filename((char *)f), size); }
|
||||
|
||||
glslp_t *glslp_parse(const char *f) {
|
||||
int j;
|
||||
int len;
|
||||
int sublen;
|
||||
char s[2049], t[2049], z[2076];
|
||||
|
||||
memset(s, 0, sizeof(s));
|
||||
if (endswith(f, ".glsl"))
|
||||
return glsl_parse(f);
|
||||
|
||||
void *cfg = wx_config_load(f);
|
||||
|
||||
if (!cfg) {
|
||||
fprintf(stderr, "GLSLP Error: Could not load GLSLP-file %s\n", f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
glslp_t *glslp = (glslp_t*) calloc(1, sizeof(glslp_t));
|
||||
|
||||
get_glslp_name(f, glslp->name, sizeof(glslp->name));
|
||||
|
||||
wx_config_get_int(cfg, "shaders", &glslp->num_shaders, 0);
|
||||
|
||||
wx_config_get_bool(cfg, "filter_linear0", &glslp->input_filter_linear, -1);
|
||||
|
||||
for (int i = 0; i < glslp->num_shaders; ++i) {
|
||||
struct shader *shader = &glslp->shaders[i];
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "shader%d", i);
|
||||
if (!wx_config_get_string(cfg, s, t, sizeof(t), 0)) {
|
||||
/* shader doesn't exist, lets break here */
|
||||
glslp->num_shaders = i;
|
||||
break;
|
||||
}
|
||||
strcpy(s, f);
|
||||
*path_get_filename(s) = 0;
|
||||
|
||||
size_t max_len = sizeof(shader->shader_fn);
|
||||
size_t s_len = strlen(s);
|
||||
|
||||
if (s_len >= max_len) {
|
||||
// s alone fills or overflows the buffer, truncate and null-terminate
|
||||
size_t copy_len = max_len - 1 < s_len ? max_len - 1 : s_len;
|
||||
memcpy(shader->shader_fn, s, copy_len);
|
||||
shader->shader_fn[copy_len] = '\0';
|
||||
} else {
|
||||
// Copy s fully
|
||||
memcpy(shader->shader_fn, s, s_len);
|
||||
// Copy as much of t as fits after s
|
||||
size_t avail = max_len - 1 - s_len; // space left for t + null terminator
|
||||
// Copy as much of t as fits into the remaining space
|
||||
memcpy(shader->shader_fn + s_len, t, avail);
|
||||
// Null-terminate
|
||||
shader->shader_fn[s_len + avail] = '\0';
|
||||
}
|
||||
|
||||
shader->shader_program = load_file(shader->shader_fn);
|
||||
if (!shader->shader_program) {
|
||||
fprintf(stderr, "GLSLP Error: Could not load shader %s\n", shader->shader_fn);
|
||||
glslp_free(glslp);
|
||||
return 0;
|
||||
}
|
||||
strip_parameters(shader->shader_program);
|
||||
strip_defines(shader->shader_program);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "alias%d", i);
|
||||
wx_config_get_string(cfg, s, shader->alias, sizeof(shader->alias), 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "filter_linear%d", i + 1);
|
||||
wx_config_get_bool(cfg, s, &shader->filter_linear, 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "wrap_mode%d", i);
|
||||
wx_config_get_string(cfg, s, shader->wrap_mode, sizeof(shader->wrap_mode), 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "float_framebuffer%d", i);
|
||||
wx_config_get_bool(cfg, s, &shader->float_framebuffer, 0);
|
||||
snprintf(s, sizeof(s) - 1, "srgb_framebuffer%d", i);
|
||||
wx_config_get_bool(cfg, s, &shader->srgb_framebuffer, 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "mipmap_input%d", i);
|
||||
wx_config_get_bool(cfg, s, &shader->mipmap_input, 0);
|
||||
|
||||
strcpy(shader->scale_type_x, "source");
|
||||
snprintf(s, sizeof(s) - 1, "scale_type_x%d", i);
|
||||
wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0);
|
||||
strcpy(shader->scale_type_y, "source");
|
||||
snprintf(s, sizeof(s) - 1, "scale_type_y%d", i);
|
||||
wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0);
|
||||
snprintf(s, sizeof(s) - 1, "scale_type%d", i);
|
||||
if (wx_config_has_entry(cfg, s)) {
|
||||
wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0);
|
||||
wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0);
|
||||
}
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "scale_x%d", i);
|
||||
wx_config_get_float(cfg, s, &shader->scale_x, 1.0f);
|
||||
snprintf(s, sizeof(s) - 1, "scale_y%d", i);
|
||||
wx_config_get_float(cfg, s, &shader->scale_y, 1.0f);
|
||||
snprintf(s, sizeof(s) - 1, "scale%d", i);
|
||||
if (wx_config_has_entry(cfg, s)) {
|
||||
wx_config_get_float(cfg, s, &shader->scale_x, 1.0f);
|
||||
wx_config_get_float(cfg, s, &shader->scale_y, 1.0f);
|
||||
}
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "frame_count_mod%d", i);
|
||||
wx_config_get_int(cfg, s, &shader->frame_count_mod, 0);
|
||||
}
|
||||
|
||||
/* textures */
|
||||
glslp->num_textures = 0;
|
||||
wx_config_get_string(cfg, "textures", t, sizeof(t), 0);
|
||||
|
||||
len = strlen(t);
|
||||
j = 0;
|
||||
sublen = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (t[i] == ';' || i == len - 1) {
|
||||
sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1;
|
||||
safe_strncpy(s, t + j, sublen);
|
||||
s[511 < sublen ? 511 : sublen] = 0;
|
||||
|
||||
if (s[strlen(s) - 1] == ';') s[strlen(s) - 1] = 0;
|
||||
|
||||
struct texture *tex = &glslp->textures[glslp->num_textures++];
|
||||
|
||||
strcpy(tex->name, s);
|
||||
wx_config_get_string(cfg, s, tex->path, sizeof(tex->path), 0);
|
||||
|
||||
snprintf(z, sizeof(z) - 1, "%s_linear", s);
|
||||
wx_config_get_bool(cfg, z, &tex->linear, 0);
|
||||
|
||||
snprintf(z, sizeof(z) - 1, "%s_mipmap", s);
|
||||
wx_config_get_bool(cfg, z, &tex->mipmap, 0);
|
||||
|
||||
snprintf(z, sizeof(z) - 1, "%s_wrap_mode", s);
|
||||
wx_config_get_string(cfg, z, tex->wrap_mode, sizeof(tex->wrap_mode), 0);
|
||||
|
||||
j = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* parameters */
|
||||
get_parameters(glslp);
|
||||
|
||||
wx_config_get_string(cfg, "parameters", t, sizeof(t), 0);
|
||||
|
||||
len = strlen(t);
|
||||
j = 0;
|
||||
sublen = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (t[i] == ';' || i == len - 1) {
|
||||
sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1;
|
||||
safe_strncpy(s, t + j, sublen);
|
||||
s[511 < sublen ? 511 : sublen] = 0;
|
||||
|
||||
struct parameter *p = get_parameter(glslp, s);
|
||||
|
||||
if (p)
|
||||
wx_config_get_float(cfg, s, &p->default_value, 0);
|
||||
|
||||
j = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
wx_config_free(cfg);
|
||||
|
||||
return glslp;
|
||||
void
|
||||
get_glslp_name(const char *f, char *s, int size)
|
||||
{
|
||||
safe_strncpy(s, path_get_filename((char *) f), size);
|
||||
}
|
||||
|
||||
void glslp_free(glslp_t *p) {
|
||||
for (int i = 0; i < p->num_shaders; ++i)
|
||||
if (p->shaders[i].shader_program)
|
||||
free(p->shaders[i].shader_program);
|
||||
free(p);
|
||||
glslp_t *
|
||||
glslp_parse(const char *f)
|
||||
{
|
||||
int j;
|
||||
int len;
|
||||
int sublen;
|
||||
char s[2049], t[2049], z[2076];
|
||||
|
||||
memset(s, 0, sizeof(s));
|
||||
if (endswith(f, ".glsl"))
|
||||
return glsl_parse(f);
|
||||
|
||||
void *cfg = wx_config_load(f);
|
||||
|
||||
if (!cfg) {
|
||||
fprintf(stderr, "GLSLP Error: Could not load GLSLP-file %s\n", f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
glslp_t *glslp = (glslp_t *) calloc(1, sizeof(glslp_t));
|
||||
|
||||
get_glslp_name(f, glslp->name, sizeof(glslp->name));
|
||||
|
||||
wx_config_get_int(cfg, "shaders", &glslp->num_shaders, 0);
|
||||
|
||||
wx_config_get_bool(cfg, "filter_linear0", &glslp->input_filter_linear, -1);
|
||||
|
||||
for (int i = 0; i < glslp->num_shaders; ++i) {
|
||||
struct shader *shader = &glslp->shaders[i];
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "shader%d", i);
|
||||
if (!wx_config_get_string(cfg, s, t, sizeof(t), 0)) {
|
||||
/* shader doesn't exist, lets break here */
|
||||
glslp->num_shaders = i;
|
||||
break;
|
||||
}
|
||||
strcpy(s, f);
|
||||
*path_get_filename(s) = 0;
|
||||
|
||||
size_t max_len = sizeof(shader->shader_fn);
|
||||
size_t s_len = strlen(s);
|
||||
|
||||
if (s_len >= max_len) {
|
||||
// s alone fills or overflows the buffer, truncate and null-terminate
|
||||
size_t copy_len = max_len - 1 < s_len ? max_len - 1 : s_len;
|
||||
memcpy(shader->shader_fn, s, copy_len);
|
||||
shader->shader_fn[copy_len] = '\0';
|
||||
} else {
|
||||
// Copy s fully
|
||||
memcpy(shader->shader_fn, s, s_len);
|
||||
// Copy as much of t as fits after s
|
||||
size_t avail = max_len - 1 - s_len; // space left for t + null terminator
|
||||
// Copy as much of t as fits into the remaining space
|
||||
memcpy(shader->shader_fn + s_len, t, avail);
|
||||
// Null-terminate
|
||||
shader->shader_fn[s_len + avail] = '\0';
|
||||
}
|
||||
|
||||
shader->shader_program = load_file(shader->shader_fn);
|
||||
if (!shader->shader_program) {
|
||||
fprintf(stderr, "GLSLP Error: Could not load shader %s\n", shader->shader_fn);
|
||||
glslp_free(glslp);
|
||||
return 0;
|
||||
}
|
||||
strip_parameters(shader->shader_program);
|
||||
strip_defines(shader->shader_program);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "alias%d", i);
|
||||
wx_config_get_string(cfg, s, shader->alias, sizeof(shader->alias), 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "filter_linear%d", i + 1);
|
||||
wx_config_get_bool(cfg, s, &shader->filter_linear, 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "wrap_mode%d", i);
|
||||
wx_config_get_string(cfg, s, shader->wrap_mode, sizeof(shader->wrap_mode), 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "float_framebuffer%d", i);
|
||||
wx_config_get_bool(cfg, s, &shader->float_framebuffer, 0);
|
||||
snprintf(s, sizeof(s) - 1, "srgb_framebuffer%d", i);
|
||||
wx_config_get_bool(cfg, s, &shader->srgb_framebuffer, 0);
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "mipmap_input%d", i);
|
||||
wx_config_get_bool(cfg, s, &shader->mipmap_input, 0);
|
||||
|
||||
strcpy(shader->scale_type_x, "source");
|
||||
snprintf(s, sizeof(s) - 1, "scale_type_x%d", i);
|
||||
wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0);
|
||||
strcpy(shader->scale_type_y, "source");
|
||||
snprintf(s, sizeof(s) - 1, "scale_type_y%d", i);
|
||||
wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0);
|
||||
snprintf(s, sizeof(s) - 1, "scale_type%d", i);
|
||||
if (wx_config_has_entry(cfg, s)) {
|
||||
wx_config_get_string(cfg, s, shader->scale_type_x, sizeof(shader->scale_type_x), 0);
|
||||
wx_config_get_string(cfg, s, shader->scale_type_y, sizeof(shader->scale_type_y), 0);
|
||||
}
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "scale_x%d", i);
|
||||
wx_config_get_float(cfg, s, &shader->scale_x, 1.0f);
|
||||
snprintf(s, sizeof(s) - 1, "scale_y%d", i);
|
||||
wx_config_get_float(cfg, s, &shader->scale_y, 1.0f);
|
||||
snprintf(s, sizeof(s) - 1, "scale%d", i);
|
||||
if (wx_config_has_entry(cfg, s)) {
|
||||
wx_config_get_float(cfg, s, &shader->scale_x, 1.0f);
|
||||
wx_config_get_float(cfg, s, &shader->scale_y, 1.0f);
|
||||
}
|
||||
|
||||
snprintf(s, sizeof(s) - 1, "frame_count_mod%d", i);
|
||||
wx_config_get_int(cfg, s, &shader->frame_count_mod, 0);
|
||||
}
|
||||
|
||||
/* textures */
|
||||
glslp->num_textures = 0;
|
||||
wx_config_get_string(cfg, "textures", t, sizeof(t), 0);
|
||||
|
||||
len = strlen(t);
|
||||
j = 0;
|
||||
sublen = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (t[i] == ';' || i == len - 1) {
|
||||
sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1;
|
||||
safe_strncpy(s, t + j, sublen);
|
||||
s[511 < sublen ? 511 : sublen] = 0;
|
||||
|
||||
if (s[strlen(s) - 1] == ';')
|
||||
s[strlen(s) - 1] = 0;
|
||||
|
||||
struct texture *tex = &glslp->textures[glslp->num_textures++];
|
||||
|
||||
strcpy(tex->name, s);
|
||||
wx_config_get_string(cfg, s, tex->path, sizeof(tex->path), 0);
|
||||
|
||||
snprintf(z, sizeof(z) - 1, "%s_linear", s);
|
||||
wx_config_get_bool(cfg, z, &tex->linear, 0);
|
||||
|
||||
snprintf(z, sizeof(z) - 1, "%s_mipmap", s);
|
||||
wx_config_get_bool(cfg, z, &tex->mipmap, 0);
|
||||
|
||||
snprintf(z, sizeof(z) - 1, "%s_wrap_mode", s);
|
||||
wx_config_get_string(cfg, z, tex->wrap_mode, sizeof(tex->wrap_mode), 0);
|
||||
|
||||
j = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* parameters */
|
||||
get_parameters(glslp);
|
||||
|
||||
wx_config_get_string(cfg, "parameters", t, sizeof(t), 0);
|
||||
|
||||
len = strlen(t);
|
||||
j = 0;
|
||||
sublen = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (t[i] == ';' || i == len - 1) {
|
||||
sublen = (i - j) + ((i == len - 1) ? 1 : 0) + 1;
|
||||
safe_strncpy(s, t + j, sublen);
|
||||
s[511 < sublen ? 511 : sublen] = 0;
|
||||
|
||||
struct parameter *p = get_parameter(glslp, s);
|
||||
|
||||
if (p)
|
||||
wx_config_get_float(cfg, s, &p->default_value, 0);
|
||||
|
||||
j = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
wx_config_free(cfg);
|
||||
|
||||
return glslp;
|
||||
}
|
||||
|
||||
void glslp_read_shader_config(glslp_t *shader) {
|
||||
char s[512];
|
||||
void
|
||||
glslp_free(glslp_t *p)
|
||||
{
|
||||
for (int i = 0; i < p->num_shaders; ++i)
|
||||
if (p->shaders[i].shader_program)
|
||||
free(p->shaders[i].shader_program);
|
||||
free(p);
|
||||
}
|
||||
|
||||
void
|
||||
glslp_read_shader_config(glslp_t *shader)
|
||||
{
|
||||
char s[512];
|
||||
char *name = shader->name;
|
||||
snprintf(s, sizeof(s) -1, "GL3 Shaders - %s", name);
|
||||
snprintf(s, sizeof(s) - 1, "GL3 Shaders - %s", name);
|
||||
for (int i = 0; i < shader->num_parameters; ++i) {
|
||||
struct parameter *param = &shader->parameters[i];
|
||||
param->value = config_get_double(s, param->id, param->default_value);
|
||||
param->value = config_get_double(s, param->id, param->default_value);
|
||||
}
|
||||
}
|
||||
|
||||
void glslp_write_shader_config(glslp_t *shader) {
|
||||
char s[512];
|
||||
void
|
||||
glslp_write_shader_config(glslp_t *shader)
|
||||
{
|
||||
char s[512];
|
||||
char *name = shader->name;
|
||||
|
||||
startblit();
|
||||
@@ -431,5 +482,4 @@ void glslp_write_shader_config(glslp_t *shader) {
|
||||
}
|
||||
endblit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
extern "C" {
|
||||
#ifdef __unix__
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <86box/86box.h>
|
||||
#include <86box/hdd.h>
|
||||
@@ -75,7 +75,7 @@ HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent)
|
||||
for (int i = 0; i < 127; i++) {
|
||||
uint64_t size = ((uint64_t) hdd_table[i][0]) * hdd_table[i][1] * hdd_table[i][2];
|
||||
uint32_t size_mb = size >> 11LL;
|
||||
QString text = tr("%1 MB (CHS: %2, %3, %4)").arg(size_mb).arg(hdd_table[i][0]).arg(hdd_table[i][1]).arg(hdd_table[i][2]);
|
||||
QString text = tr("%1 MB (CHS: %2, %3, %4)").arg(size_mb).arg(hdd_table[i][0]).arg(hdd_table[i][1]).arg(hdd_table[i][2]);
|
||||
Models::AddEntry(model, text, i);
|
||||
}
|
||||
Models::AddEntry(model, tr("Custom..."), 127);
|
||||
@@ -85,11 +85,11 @@ HarddiskDialog::HarddiskDialog(bool existing, QWidget *parent)
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
filters = QStringList({ tr("Raw image") % util::DlgFilter({ "img" }, true),
|
||||
tr("HDI image") % util::DlgFilter({ "hdi" }, true),
|
||||
tr("HDX image") % util::DlgFilter({ "hdx" }, true),
|
||||
tr("Fixed-size VHD") % util::DlgFilter({ "vhd" }, true),
|
||||
tr("Dynamic-size VHD") % util::DlgFilter({ "vhd" }, true),
|
||||
tr("Differencing VHD") % util::DlgFilter({ "vhd" }, true) });
|
||||
tr("HDI image") % util::DlgFilter({ "hdi" }, true),
|
||||
tr("HDX image") % util::DlgFilter({ "hdx" }, true),
|
||||
tr("Fixed-size VHD") % util::DlgFilter({ "vhd" }, true),
|
||||
tr("Dynamic-size VHD") % util::DlgFilter({ "vhd" }, true),
|
||||
tr("Differencing VHD") % util::DlgFilter({ "vhd" }, true) });
|
||||
|
||||
if (existing) {
|
||||
ui->fileField->setFilter(tr("Hard disk images") % util::DlgFilter({ "hd?", "im?", "vhd" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
@@ -317,7 +317,6 @@ create_drive_vhd_diff(const QString &fileName, const QString &parentFileName, in
|
||||
_86box_geometry.spt = vhd_geometry.spt;
|
||||
}
|
||||
|
||||
|
||||
mvhd_close(vhd);
|
||||
}
|
||||
|
||||
@@ -414,7 +413,7 @@ HarddiskDialog::onCreateNewFile()
|
||||
file.close();
|
||||
|
||||
_86BoxGeom _86box_geometry {};
|
||||
int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL;
|
||||
int block_size = ui->comboBoxBlockSize->currentIndex() == 0 ? MVHD_BLOCK_LARGE : MVHD_BLOCK_SMALL;
|
||||
switch (img_format) {
|
||||
case IMG_FMT_VHD_FIXED:
|
||||
{
|
||||
@@ -568,7 +567,7 @@ HarddiskDialog::onExistingFileSelected(const QString &fileName, bool precheck)
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
// No message box during precheck (performed when the file input loses focus and this function is called)
|
||||
// If precheck is false, the file has been chosen from a file dialog and the alert should display.
|
||||
if(!precheck) {
|
||||
if (!precheck) {
|
||||
QMessageBox::critical(this, tr("Unable to read file"), tr("Make sure the file exists and is readable."));
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -123,10 +123,10 @@ Harddrives::populateBusChannels(QAbstractItemModel *model, int bus, SettingsBusT
|
||||
{
|
||||
model->removeRows(0, model->rowCount());
|
||||
|
||||
int busRows = 0;
|
||||
int shifter = 1;
|
||||
int orer = 1;
|
||||
int subChannelWidth = 1;
|
||||
int busRows = 0;
|
||||
int shifter = 1;
|
||||
int orer = 1;
|
||||
int subChannelWidth = 1;
|
||||
QList<int> busesToCheck;
|
||||
QList<int> channelsInUse;
|
||||
switch (bus) {
|
||||
@@ -160,15 +160,15 @@ Harddrives::populateBusChannels(QAbstractItemModel *model, int bus, SettingsBusT
|
||||
busesToCheck.append(HDD_BUS_SCSI);
|
||||
break;
|
||||
case CDROM_BUS_MKE:
|
||||
shifter = 2;
|
||||
orer = 3;
|
||||
busRows = 4;
|
||||
shifter = 2;
|
||||
orer = 3;
|
||||
busRows = 4;
|
||||
busesToCheck.append(CDROM_BUS_MKE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(sbt != nullptr && !busesToCheck.empty()) {
|
||||
if (sbt != nullptr && !busesToCheck.empty()) {
|
||||
for (auto const &checkBus : busesToCheck) {
|
||||
channelsInUse.append(sbt->busChannelsInUse(checkBus));
|
||||
}
|
||||
@@ -179,9 +179,9 @@ Harddrives::populateBusChannels(QAbstractItemModel *model, int bus, SettingsBusT
|
||||
auto idx = model->index(i, 0);
|
||||
model->setData(idx, QString("%1:%2").arg(i >> shifter).arg(i & orer, subChannelWidth, 10, QChar('0')));
|
||||
model->setData(idx, ((i >> shifter) << shifter) | (i & orer), Qt::UserRole);
|
||||
const auto *channelModel = qobject_cast<QStandardItemModel*>(model);
|
||||
auto *channelItem = channelModel->item(i);
|
||||
if(channelItem) {
|
||||
const auto *channelModel = qobject_cast<QStandardItemModel *>(model);
|
||||
auto *channelItem = channelModel->item(i);
|
||||
if (channelItem) {
|
||||
channelItem->setEnabled(!channelsInUse.contains(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ getIconWithIndicator(const QIcon &icon, const QSize &size, QIcon::Mode iconMode,
|
||||
if (indicator == None)
|
||||
return iconPixmap;
|
||||
|
||||
auto painter = QPainter(&iconPixmap);
|
||||
auto painter = QPainter(&iconPixmap);
|
||||
auto indicatorPixmap = getIndicatorIcon((indicator == ReadWriteActive || indicator == WriteProtectedActive) ? Active : indicator).pixmap(size);
|
||||
|
||||
if (indicator == WriteProtectedBrowse)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef QT_ICONINDICATORS_HPP
|
||||
# define QT_ICONINDICATORS_HPP
|
||||
#define QT_ICONINDICATORS_HPP
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QIcon>
|
||||
|
||||
@@ -52,7 +52,7 @@ extern "C" {
|
||||
# include <sys/sysmacros.h>
|
||||
#endif
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
KeyBinder::KeyBinder(QWidget *parent)
|
||||
@@ -60,10 +60,10 @@ KeyBinder::KeyBinder(QWidget *parent)
|
||||
, ui(new Ui::KeyBinder)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
singleKeySequenceEdit *seq = new singleKeySequenceEdit();
|
||||
ui->formLayout->addRow(seq);
|
||||
seq->setObjectName("keySequence");
|
||||
this->setTabOrder(seq, ui->buttonBox);
|
||||
singleKeySequenceEdit *seq = new singleKeySequenceEdit();
|
||||
ui->formLayout->addRow(seq);
|
||||
seq->setObjectName("keySequence");
|
||||
this->setTabOrder(seq, ui->buttonBox);
|
||||
}
|
||||
|
||||
KeyBinder::~KeyBinder()
|
||||
@@ -72,29 +72,31 @@ KeyBinder::~KeyBinder()
|
||||
}
|
||||
|
||||
void
|
||||
KeyBinder::showEvent( QShowEvent* event ) {
|
||||
QWidget::showEvent( event );
|
||||
this->findChild<QKeySequenceEdit*>()->setFocus();
|
||||
}
|
||||
|
||||
bool KeyBinder::eventFilter(QObject *obj, QEvent *event)
|
||||
KeyBinder::showEvent(QShowEvent *event)
|
||||
{
|
||||
return QObject::eventFilter(obj, event);
|
||||
QWidget::showEvent(event);
|
||||
this->findChild<QKeySequenceEdit *>()->setFocus();
|
||||
}
|
||||
|
||||
bool
|
||||
KeyBinder::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
QKeySequence
|
||||
KeyBinder::BindKey(QWidget* widget, QString CurValue)
|
||||
KeyBinder::BindKey(QWidget *widget, QString CurValue)
|
||||
{
|
||||
KeyBinder kb(widget);
|
||||
kb.setWindowTitle(tr("Bind Key"));
|
||||
KeyBinder kb(widget);
|
||||
kb.setWindowTitle(tr("Bind Key"));
|
||||
kb.setFixedSize(kb.minimumSizeHint());
|
||||
kb.findChild<QKeySequenceEdit*>()->setKeySequence(QKeySequence::fromString(CurValue, QKeySequence::NativeText));
|
||||
kb.setEnabled(true);
|
||||
|
||||
kb.findChild<QKeySequenceEdit *>()->setKeySequence(QKeySequence::fromString(CurValue, QKeySequence::NativeText));
|
||||
kb.setEnabled(true);
|
||||
|
||||
if (kb.exec() == QDialog::Accepted) {
|
||||
QKeySequenceEdit *seq = kb.findChild<QKeySequenceEdit*>();
|
||||
return (seq->keySequence());
|
||||
QKeySequenceEdit *seq = kb.findChild<QKeySequenceEdit *>();
|
||||
return (seq->keySequence());
|
||||
} else {
|
||||
return (false);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,12 @@ public:
|
||||
explicit KeyBinder(QWidget *parent = nullptr);
|
||||
~KeyBinder() override;
|
||||
|
||||
static QKeySequence BindKey(QWidget* widget, QString CurValue);
|
||||
static QKeySequence BindKey(QWidget *widget, QString CurValue);
|
||||
|
||||
private:
|
||||
Ui::KeyBinder *ui;
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void showEvent( QShowEvent* event ) override;
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
};
|
||||
|
||||
#endif // QT_KeyBinder_HPP
|
||||
|
||||
@@ -109,9 +109,9 @@ struct Pixmaps {
|
||||
|
||||
struct StateActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetActive *pixmaps = nullptr;
|
||||
bool active = false;
|
||||
bool write_active = false;
|
||||
PixmapSetActive *pixmaps = nullptr;
|
||||
bool active = false;
|
||||
bool write_active = false;
|
||||
|
||||
void setActive(bool b)
|
||||
{
|
||||
@@ -164,11 +164,11 @@ struct StateEmpty {
|
||||
};
|
||||
struct StateEmptyActive {
|
||||
std::unique_ptr<QLabel> label;
|
||||
PixmapSetEmptyActive *pixmaps = nullptr;
|
||||
bool empty = false;
|
||||
bool active = false;
|
||||
bool write_active = false;
|
||||
bool wp = false;
|
||||
PixmapSetEmptyActive *pixmaps = nullptr;
|
||||
bool empty = false;
|
||||
bool active = false;
|
||||
bool write_active = false;
|
||||
bool wp = false;
|
||||
|
||||
void setActive(bool b)
|
||||
{
|
||||
@@ -222,7 +222,7 @@ struct StateEmptyActive {
|
||||
}
|
||||
};
|
||||
|
||||
static QSize pixmap_size(16, 16);
|
||||
static QSize pixmap_size(16, 16);
|
||||
|
||||
void
|
||||
PixmapSetEmpty::load(const QIcon &icon)
|
||||
@@ -236,8 +236,8 @@ PixmapSetActive::load(const QIcon &icon)
|
||||
{
|
||||
normal = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, None);
|
||||
active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, Active);
|
||||
|
||||
write_active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, WriteActive);
|
||||
|
||||
write_active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, WriteActive);
|
||||
read_write_active = getIconWithIndicator(icon, pixmap_size, QIcon::Normal, ReadWriteActive);
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ MachineStatus::MachineStatus(QObject *parent)
|
||||
: QObject(parent)
|
||||
, refreshTimer(new QTimer(this))
|
||||
{
|
||||
d = std::make_unique<MachineStatus::States>(this);
|
||||
d = std::make_unique<MachineStatus::States>(this);
|
||||
soundMenu = nullptr;
|
||||
connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons);
|
||||
refreshTimer->start(75);
|
||||
@@ -335,7 +335,7 @@ MachineStatus::MachineStatus(QObject *parent)
|
||||
MachineStatus::~MachineStatus() = default;
|
||||
|
||||
void
|
||||
MachineStatus::setSoundMenu(QMenu* menu)
|
||||
MachineStatus::setSoundMenu(QMenu *menu)
|
||||
{
|
||||
soundMenu = menu;
|
||||
}
|
||||
@@ -768,7 +768,7 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
tooltip.append("\n");
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus_type == HDD_BUS_MFM && hdd[i].fn[0] != 0) {
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
}
|
||||
}
|
||||
d->hdds[HDD_BUS_MFM].label->setToolTip(tooltip);
|
||||
@@ -784,7 +784,7 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
tooltip.append("\n");
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus_type == HDD_BUS_ESDI && hdd[i].fn[0] != 0) {
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
}
|
||||
}
|
||||
d->hdds[HDD_BUS_ESDI].label->setToolTip(tooltip);
|
||||
@@ -800,7 +800,7 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
tooltip.append("\n");
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus_type == HDD_BUS_XTA && hdd[i].fn[0] != 0) {
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
}
|
||||
}
|
||||
d->hdds[HDD_BUS_XTA].label->setToolTip(tooltip);
|
||||
@@ -819,7 +819,7 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
tooltip.append("\n");
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus_type == HDD_BUS_IDE && hdd[i].fn[0] != 0) {
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
}
|
||||
}
|
||||
d->hdds[HDD_BUS_IDE].label->setToolTip(tooltip);
|
||||
@@ -835,7 +835,7 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
tooltip.append("\n");
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus_type == HDD_BUS_ATAPI && hdd[i].fn[0] != 0) {
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 1), QString::number(hdd[i].channel & 1), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
}
|
||||
}
|
||||
d->hdds[HDD_BUS_ATAPI].label->setToolTip(tooltip);
|
||||
@@ -855,7 +855,7 @@ MachineStatus::refresh(QStatusBar *sbar)
|
||||
tooltip.append("\n");
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
if (hdd[i].bus_type == HDD_BUS_SCSI && hdd[i].fn[0] != 0) {
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 4), QString::asprintf("%02d", hdd[i].channel & 15), QString::number((((qulonglong)hdd[i].hpc * (qulonglong)hdd[i].spt * (qulonglong)hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
tooltip.append(QString("\n%5:%6: %1 (C:H:S = %2:%3:%4, %7 %8)").arg(QString::fromUtf8(hdd[i].fn), QString::number(hdd[i].tracks), QString::number(hdd[i].hpc), QString::number(hdd[i].spt), QString::number(hdd[i].channel >> 4), QString::asprintf("%02d", hdd[i].channel & 15), QString::number((((qulonglong) hdd[i].hpc * (qulonglong) hdd[i].spt * (qulonglong) hdd[i].tracks) * 512ull) / 1048576ull), tr("MB")));
|
||||
}
|
||||
}
|
||||
d->hdds[HDD_BUS_SCSI].label->setToolTip(tooltip);
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
QString getMessage();
|
||||
void clearActivity();
|
||||
void setSoundMenu(QMenu* menu);
|
||||
void setSoundMenu(QMenu *menu);
|
||||
public slots:
|
||||
void refresh(QStatusBar *sbar);
|
||||
void message(const QString &msg);
|
||||
|
||||
@@ -50,14 +50,14 @@ extern "C" {
|
||||
#include <86box/ui.h>
|
||||
#include <86box/video.h>
|
||||
#ifdef DISCORD
|
||||
# include <86box/discord.h>
|
||||
# include <86box/discord.h>
|
||||
#endif
|
||||
#include <86box/gdbstub.h>
|
||||
#include <86box/version.h>
|
||||
#include <86box/renderdefs.h>
|
||||
#ifdef Q_OS_LINUX
|
||||
#define GAMEMODE_AUTO
|
||||
#include "../unix/gamemode/gamemode_client.h"
|
||||
# define GAMEMODE_AUTO
|
||||
# include "../unix/gamemode/gamemode_client.h"
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ extern "C" {
|
||||
#include "cpu.h"
|
||||
#include <86box/timer.h>
|
||||
#include <86box/nvr.h>
|
||||
extern int qt_nvr_save(void);
|
||||
extern int qt_nvr_save(void);
|
||||
extern void exit_pause(void);
|
||||
|
||||
bool cpu_thread_running = false;
|
||||
@@ -210,19 +210,19 @@ win_keyboard_handle(uint32_t scancode, int up, int e0, int e1)
|
||||
static LRESULT CALLBACK
|
||||
emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LPKBDLLHOOKSTRUCT lpKdhs = (LPKBDLLHOOKSTRUCT) lParam;
|
||||
LPKBDLLHOOKSTRUCT lpKdhs = (LPKBDLLHOOKSTRUCT) lParam;
|
||||
/* Checks if CTRL was pressed. */
|
||||
BOOL bCtrlDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
|
||||
BOOL is_over_window = (GetForegroundWindow() == ((HWND) main_window->winId()));
|
||||
BOOL ret = TRUE;
|
||||
BOOL bCtrlDown = GetAsyncKeyState(VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
|
||||
BOOL is_over_window = (GetForegroundWindow() == ((HWND) main_window->winId()));
|
||||
BOOL ret = TRUE;
|
||||
|
||||
static int last = 0;
|
||||
static int last = 0;
|
||||
|
||||
if (show_second_monitors) for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) {
|
||||
const auto &secondaryRenderer = main_window->renderers[monitor_index];
|
||||
is_over_window = is_over_window || ((secondaryRenderer != nullptr) &&
|
||||
(GetForegroundWindow() == ((HWND) secondaryRenderer->winId())));
|
||||
}
|
||||
if (show_second_monitors)
|
||||
for (int monitor_index = 1; monitor_index < MONITORS_NUM; monitor_index++) {
|
||||
const auto &secondaryRenderer = main_window->renderers[monitor_index];
|
||||
is_over_window = is_over_window || ((secondaryRenderer != nullptr) && (GetForegroundWindow() == ((HWND) secondaryRenderer->winId())));
|
||||
}
|
||||
|
||||
bool skip = ((nCode < 0) || (nCode != HC_ACTION) || !is_over_window || (kbd_req_capture && !mouse_capture));
|
||||
|
||||
@@ -235,179 +235,173 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
Only a handful of keys can be handled via Virtual Key
|
||||
detection; rest can't be reliably detected. */
|
||||
DWORD vkCode = lpKdhs->vkCode;
|
||||
bool up = !!(lpKdhs->flags & LLKHF_UP);
|
||||
bool up = !!(lpKdhs->flags & LLKHF_UP);
|
||||
|
||||
if (inhibit_multimedia_keys
|
||||
&& (lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE
|
||||
|| lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK
|
||||
|| lpKdhs->vkCode == VK_MEDIA_PREV_TRACK
|
||||
|| lpKdhs->vkCode == VK_VOLUME_DOWN
|
||||
|| lpKdhs->vkCode == VK_VOLUME_UP
|
||||
|| lpKdhs->vkCode == VK_VOLUME_MUTE
|
||||
|| lpKdhs->vkCode == VK_MEDIA_STOP
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_MAIL
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_APP1
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_APP2
|
||||
|| lpKdhs->vkCode == VK_HELP
|
||||
|| lpKdhs->vkCode == VK_BROWSER_BACK
|
||||
|| lpKdhs->vkCode == VK_BROWSER_FORWARD
|
||||
|| lpKdhs->vkCode == VK_BROWSER_FAVORITES
|
||||
|| lpKdhs->vkCode == VK_BROWSER_HOME
|
||||
|| lpKdhs->vkCode == VK_BROWSER_REFRESH
|
||||
|| lpKdhs->vkCode == VK_BROWSER_SEARCH
|
||||
|| lpKdhs->vkCode == VK_BROWSER_STOP))
|
||||
if (inhibit_multimedia_keys &&
|
||||
(lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE ||
|
||||
lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK ||
|
||||
lpKdhs->vkCode == VK_MEDIA_PREV_TRACK ||
|
||||
lpKdhs->vkCode == VK_VOLUME_DOWN ||
|
||||
lpKdhs->vkCode == VK_VOLUME_UP ||
|
||||
lpKdhs->vkCode == VK_VOLUME_MUTE ||
|
||||
lpKdhs->vkCode == VK_MEDIA_STOP ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_MAIL ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_APP1 ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_APP2 ||
|
||||
lpKdhs->vkCode == VK_HELP ||
|
||||
lpKdhs->vkCode == VK_BROWSER_BACK ||
|
||||
lpKdhs->vkCode == VK_BROWSER_FORWARD ||
|
||||
lpKdhs->vkCode == VK_BROWSER_FAVORITES ||
|
||||
lpKdhs->vkCode == VK_BROWSER_HOME ||
|
||||
lpKdhs->vkCode == VK_BROWSER_REFRESH ||
|
||||
lpKdhs->vkCode == VK_BROWSER_SEARCH ||
|
||||
lpKdhs->vkCode == VK_BROWSER_STOP))
|
||||
ret = TRUE;
|
||||
else
|
||||
ret = CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
|
||||
switch (vkCode)
|
||||
{
|
||||
switch (vkCode) {
|
||||
case VK_MEDIA_PLAY_PAUSE:
|
||||
{
|
||||
win_keyboard_handle(0x22, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x22, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_MEDIA_STOP:
|
||||
{
|
||||
win_keyboard_handle(0x24, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x24, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_VOLUME_UP:
|
||||
{
|
||||
win_keyboard_handle(0x30, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x30, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_VOLUME_DOWN:
|
||||
{
|
||||
win_keyboard_handle(0x2E, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x2E, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_VOLUME_MUTE:
|
||||
{
|
||||
win_keyboard_handle(0x20, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x20, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_MEDIA_NEXT_TRACK:
|
||||
{
|
||||
win_keyboard_handle(0x19, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x19, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_MEDIA_PREV_TRACK:
|
||||
{
|
||||
win_keyboard_handle(0x10, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x10, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_LAUNCH_MEDIA_SELECT:
|
||||
{
|
||||
win_keyboard_handle(0x6D, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x6D, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_LAUNCH_MAIL:
|
||||
{
|
||||
win_keyboard_handle(0x6C, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x6C, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_LAUNCH_APP1:
|
||||
{
|
||||
win_keyboard_handle(0x6B, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x6B, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_LAUNCH_APP2:
|
||||
{
|
||||
win_keyboard_handle(0x21, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x21, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_BROWSER_BACK:
|
||||
{
|
||||
win_keyboard_handle(0x6A, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x6A, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_BROWSER_FORWARD:
|
||||
{
|
||||
win_keyboard_handle(0x69, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x69, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_BROWSER_STOP:
|
||||
{
|
||||
win_keyboard_handle(0x68, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x68, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_BROWSER_HOME:
|
||||
{
|
||||
win_keyboard_handle(0x32, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x32, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_BROWSER_SEARCH:
|
||||
{
|
||||
win_keyboard_handle(0x65, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x65, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_BROWSER_REFRESH:
|
||||
{
|
||||
win_keyboard_handle(0x67, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x67, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_BROWSER_FAVORITES:
|
||||
{
|
||||
win_keyboard_handle(0x66, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x66, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
case VK_HELP:
|
||||
{
|
||||
win_keyboard_handle(0x3b, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
{
|
||||
win_keyboard_handle(0x3b, up, 1, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
else if ((lpKdhs->scanCode == 0x01) && (lpKdhs->flags & LLKHF_ALTDOWN) &&
|
||||
!(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
} else if ((lpKdhs->scanCode == 0x01) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
ret = TRUE;
|
||||
else if ((lpKdhs->scanCode == 0x01) && bCtrlDown && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
ret = TRUE;
|
||||
else if ((lpKdhs->scanCode == 0x0f) && (lpKdhs->flags & LLKHF_ALTDOWN) &&
|
||||
!(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
else if ((lpKdhs->scanCode == 0x0f) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
ret = TRUE;
|
||||
else if ((lpKdhs->scanCode == 0x0f) && bCtrlDown && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
ret = TRUE;
|
||||
else if ((lpKdhs->scanCode == 0x39) && (lpKdhs->flags & LLKHF_ALTDOWN) &&
|
||||
!(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
else if ((lpKdhs->scanCode == 0x39) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
ret = TRUE;
|
||||
else if ((lpKdhs->scanCode == 0x3e) && (lpKdhs->flags & LLKHF_ALTDOWN) &&
|
||||
!(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
else if ((lpKdhs->scanCode == 0x3e) && (lpKdhs->flags & LLKHF_ALTDOWN) && !(lpKdhs->flags & (LLKHF_UP | LLKHF_EXTENDED)))
|
||||
ret = TRUE;
|
||||
else if ((lpKdhs->scanCode >= 0x5b) && (lpKdhs->scanCode <= 0x5d) && (lpKdhs->flags & LLKHF_EXTENDED))
|
||||
ret = TRUE;
|
||||
else if (inhibit_multimedia_keys
|
||||
&& (lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE
|
||||
|| lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK
|
||||
|| lpKdhs->vkCode == VK_MEDIA_PREV_TRACK
|
||||
|| lpKdhs->vkCode == VK_VOLUME_DOWN
|
||||
|| lpKdhs->vkCode == VK_VOLUME_UP
|
||||
|| lpKdhs->vkCode == VK_VOLUME_MUTE
|
||||
|| lpKdhs->vkCode == VK_MEDIA_STOP
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_MAIL
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_APP1
|
||||
|| lpKdhs->vkCode == VK_LAUNCH_APP2
|
||||
|| lpKdhs->vkCode == VK_HELP
|
||||
|| lpKdhs->vkCode == VK_BROWSER_BACK
|
||||
|| lpKdhs->vkCode == VK_BROWSER_FORWARD
|
||||
|| lpKdhs->vkCode == VK_BROWSER_FAVORITES
|
||||
|| lpKdhs->vkCode == VK_BROWSER_HOME
|
||||
|| lpKdhs->vkCode == VK_BROWSER_REFRESH
|
||||
|| lpKdhs->vkCode == VK_BROWSER_SEARCH
|
||||
|| lpKdhs->vkCode == VK_BROWSER_STOP))
|
||||
else if (inhibit_multimedia_keys &&
|
||||
(lpKdhs->vkCode == VK_MEDIA_PLAY_PAUSE ||
|
||||
lpKdhs->vkCode == VK_MEDIA_NEXT_TRACK ||
|
||||
lpKdhs->vkCode == VK_MEDIA_PREV_TRACK ||
|
||||
lpKdhs->vkCode == VK_VOLUME_DOWN ||
|
||||
lpKdhs->vkCode == VK_VOLUME_UP ||
|
||||
lpKdhs->vkCode == VK_VOLUME_MUTE ||
|
||||
lpKdhs->vkCode == VK_MEDIA_STOP ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_MEDIA_SELECT ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_MAIL ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_APP1 ||
|
||||
lpKdhs->vkCode == VK_LAUNCH_APP2 ||
|
||||
lpKdhs->vkCode == VK_HELP ||
|
||||
lpKdhs->vkCode == VK_BROWSER_BACK ||
|
||||
lpKdhs->vkCode == VK_BROWSER_FORWARD ||
|
||||
lpKdhs->vkCode == VK_BROWSER_FAVORITES ||
|
||||
lpKdhs->vkCode == VK_BROWSER_HOME ||
|
||||
lpKdhs->vkCode == VK_BROWSER_REFRESH ||
|
||||
lpKdhs->vkCode == VK_BROWSER_SEARCH ||
|
||||
lpKdhs->vkCode == VK_BROWSER_STOP))
|
||||
ret = TRUE;
|
||||
else
|
||||
ret = CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
|
||||
if (lpKdhs->scanCode == 0x00000045) {
|
||||
if ((lpKdhs->flags & LLKHF_EXTENDED) && (lpKdhs->vkCode == 0x00000090)) {
|
||||
/* NumLock. */
|
||||
lpKdhs->flags &= ~LLKHF_EXTENDED;
|
||||
/* NumLock. */
|
||||
lpKdhs->flags &= ~LLKHF_EXTENDED;
|
||||
} else if (!(lpKdhs->flags & LLKHF_EXTENDED) && (lpKdhs->vkCode == 0x00000013)) {
|
||||
/* Pause - send E1 1D. */
|
||||
win_keyboard_handle(0xe1, 0, 0, 0);
|
||||
@@ -433,21 +427,21 @@ emu_LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
static HHOOK llhook = NULL;
|
||||
static HHOOK llhook = NULL;
|
||||
#endif
|
||||
|
||||
void
|
||||
main_thread_fn()
|
||||
{
|
||||
int frames;
|
||||
int frames;
|
||||
|
||||
QThread::currentThread()->setPriority(QThread::HighestPriority);
|
||||
plat_set_thread_name(nullptr, "main_thread");
|
||||
framecountx = 0;
|
||||
// title_update = 1;
|
||||
uint64_t old_time = elapsed_timer.elapsed();
|
||||
int drawits = frames = 0;
|
||||
is_cpu_thread = 1;
|
||||
int drawits = frames = 0;
|
||||
is_cpu_thread = 1;
|
||||
while (!is_quit && cpu_thread_run) {
|
||||
/* See if it is time to run a frame of code. */
|
||||
const uint64_t new_time = elapsed_timer.elapsed();
|
||||
@@ -505,8 +499,8 @@ main_thread_fn()
|
||||
}
|
||||
|
||||
cpu_thread_running = false;
|
||||
is_quit = 1;
|
||||
for (uint8_t i = 1; i < GFXCARD_MAX; i ++) {
|
||||
is_quit = 1;
|
||||
for (uint8_t i = 1; i < GFXCARD_MAX; i++) {
|
||||
if (gfxcard[i]) {
|
||||
ui_deinit_monitor(i);
|
||||
plat_delay_ms(500);
|
||||
@@ -520,7 +514,7 @@ static std::thread *main_thread;
|
||||
QTimer discordupdate;
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
WindowsDarkModeFilter* vmm_dark_mode_filter = nullptr;
|
||||
WindowsDarkModeFilter *vmm_dark_mode_filter = nullptr;
|
||||
#endif
|
||||
|
||||
int
|
||||
@@ -530,9 +524,9 @@ main(int argc, char *argv[])
|
||||
bool wasDarkTheme = false;
|
||||
/* Check if Windows supports UTF-8 */
|
||||
if (GetACP() == CP_UTF8)
|
||||
acp_utf8 = 1;
|
||||
acp_utf8 = 1;
|
||||
else
|
||||
acp_utf8 = 0;
|
||||
acp_utf8 = 0;
|
||||
#endif
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false);
|
||||
@@ -568,9 +562,9 @@ main(int argc, char *argv[])
|
||||
if (!util::isWindowsLightTheme()) {
|
||||
QFile f(":qdarkstyle/dark/darkstyle.qss");
|
||||
|
||||
if (!f.exists()) {
|
||||
if (!f.exists()) {
|
||||
printf("Unable to set stylesheet, file not found\n");
|
||||
} else {
|
||||
} else {
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream ts(&f);
|
||||
qApp->setStyleSheet(ts.readAll());
|
||||
@@ -685,7 +679,7 @@ main(int argc, char *argv[])
|
||||
pc_init_modules();
|
||||
|
||||
// UUID / copy / move detection
|
||||
if(!util::compareUuid()) {
|
||||
if (!util::compareUuid()) {
|
||||
QMessageBox movewarnbox;
|
||||
movewarnbox.setIcon(QMessageBox::Icon::Warning);
|
||||
movewarnbox.setText(QObject::tr("This machine might have been moved or copied."));
|
||||
@@ -721,7 +715,7 @@ main(int argc, char *argv[])
|
||||
warningbox.addButton(QObject::tr("Exit"), QMessageBox::RejectRole);
|
||||
warningbox.exec();
|
||||
if (warningbox.result() == QDialog::Accepted)
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -748,7 +742,7 @@ main(int argc, char *argv[])
|
||||
warningbox.addButton(QObject::tr("Exit"), QMessageBox::RejectRole);
|
||||
warningbox.exec();
|
||||
if (warningbox.result() == QDialog::Accepted)
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DISCORD
|
||||
@@ -760,7 +754,7 @@ main(int argc, char *argv[])
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timebeginperiod
|
||||
exit_pause();
|
||||
timeBeginPeriod(1);
|
||||
atexit([] () -> void { timeEndPeriod(1); });
|
||||
atexit([]() -> void { timeEndPeriod(1); });
|
||||
#endif
|
||||
|
||||
main_window = new MainWindow();
|
||||
@@ -772,13 +766,12 @@ main(int argc, char *argv[])
|
||||
#ifdef WAYLAND
|
||||
if (QApplication::platformName().contains("wayland")) {
|
||||
/* Force a sync. */
|
||||
(void)main_window->winId();
|
||||
(void) main_window->winId();
|
||||
QApplication::sync();
|
||||
extern void wl_keyboard_grab(QWindow *window);
|
||||
extern void wl_keyboard_grab(QWindow * window);
|
||||
wl_keyboard_grab(main_window->windowHandle());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
app.installEventFilter(main_window);
|
||||
|
||||
@@ -826,7 +819,7 @@ main(int argc, char *argv[])
|
||||
if (hook_enabled) {
|
||||
/* Yes, low-level hooks *DO* work with raw input, at least global ones. */
|
||||
llhook = SetWindowsHookEx(WH_KEYBOARD_LL, emu_LowLevelKeyboardProc, NULL, 0);
|
||||
atexit([] () -> void {
|
||||
atexit([]() -> void {
|
||||
if (llhook)
|
||||
UnhookWindowsHookEx(llhook);
|
||||
});
|
||||
@@ -920,10 +913,10 @@ main(int argc, char *argv[])
|
||||
plat_pause(0);
|
||||
|
||||
cpu_thread_running = true;
|
||||
main_thread = new std::thread(main_thread_fn);
|
||||
main_thread = new std::thread(main_thread_fn);
|
||||
});
|
||||
|
||||
const auto ret = app.exec();
|
||||
const auto ret = app.exec();
|
||||
cpu_thread_run = 0;
|
||||
main_thread->join();
|
||||
pc_close(nullptr);
|
||||
|
||||
@@ -40,7 +40,7 @@ extern "C" {
|
||||
#include <86box/plat.h>
|
||||
#include <86box/ui.h>
|
||||
#ifdef DISCORD
|
||||
# include <86box/discord.h>
|
||||
# include <86box/discord.h>
|
||||
#endif
|
||||
#include <86box/device.h>
|
||||
#include <86box/video.h>
|
||||
@@ -124,8 +124,8 @@ void qt_set_sequence_auto_mnemonic(bool b);
|
||||
#endif
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_HAIKU && !defined Q_OS_MACOS
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include "x11_util.h"
|
||||
# include <qpa/qplatformwindow.h>
|
||||
# include "x11_util.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
@@ -143,7 +143,7 @@ namespace IOKit {
|
||||
# include "be_keyboard.hpp"
|
||||
|
||||
extern MainWindow *main_window;
|
||||
QShortcut *windowedShortcut;
|
||||
QShortcut *windowedShortcut;
|
||||
|
||||
filter_result
|
||||
keyb_filter(BMessage *message, BHandler **target, BMessageFilter *filter)
|
||||
@@ -191,8 +191,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ui->stackedWidget->setMouseTracking(true);
|
||||
statusBar()->setVisible(!hide_status_bar);
|
||||
|
||||
auto hertz_label = new QLabel;
|
||||
QTimer* frameRateTimer = new QTimer(this);
|
||||
auto hertz_label = new QLabel;
|
||||
QTimer *frameRateTimer = new QTimer(this);
|
||||
frameRateTimer->setInterval(1000);
|
||||
frameRateTimer->setSingleShot(false);
|
||||
connect(frameRateTimer, &QTimer::timeout, [hertz_label] {
|
||||
@@ -205,14 +205,14 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
statusBar()->addPermanentWidget(hertz_label);
|
||||
frameRateTimer->start(1000);
|
||||
|
||||
num_icon = QIcon(":/settings/qt/icons/num_lock_on.ico");
|
||||
num_icon_off = QIcon(":/settings/qt/icons/num_lock_off.ico");
|
||||
scroll_icon = QIcon(":/settings/qt/icons/scroll_lock_on.ico");
|
||||
num_icon = QIcon(":/settings/qt/icons/num_lock_on.ico");
|
||||
num_icon_off = QIcon(":/settings/qt/icons/num_lock_off.ico");
|
||||
scroll_icon = QIcon(":/settings/qt/icons/scroll_lock_on.ico");
|
||||
scroll_icon_off = QIcon(":/settings/qt/icons/scroll_lock_off.ico");
|
||||
caps_icon = QIcon(":/settings/qt/icons/caps_lock_on.ico");
|
||||
caps_icon_off = QIcon(":/settings/qt/icons/caps_lock_off.ico");
|
||||
kana_icon = QIcon(":/settings/qt/icons/kana_lock_on.ico");
|
||||
kana_icon_off = QIcon(":/settings/qt/icons/kana_lock_off.ico");
|
||||
caps_icon = QIcon(":/settings/qt/icons/caps_lock_on.ico");
|
||||
caps_icon_off = QIcon(":/settings/qt/icons/caps_lock_off.ico");
|
||||
kana_icon = QIcon(":/settings/qt/icons/kana_lock_on.ico");
|
||||
kana_icon_off = QIcon(":/settings/qt/icons/kana_lock_off.ico");
|
||||
|
||||
num_label = new QLabel;
|
||||
num_label->setPixmap(num_icon_off.pixmap(QSize(16, 16)));
|
||||
@@ -234,10 +234,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
kana_label->setToolTip(QShortcut::tr("Kana Lock"));
|
||||
statusBar()->addPermanentWidget(kana_label);
|
||||
|
||||
QTimer* ledKeyboardTimer = new QTimer(this);
|
||||
QTimer *ledKeyboardTimer = new QTimer(this);
|
||||
ledKeyboardTimer->setTimerType(Qt::CoarseTimer);
|
||||
ledKeyboardTimer->setInterval(1);
|
||||
connect(ledKeyboardTimer, &QTimer::timeout, this, [this] () {
|
||||
connect(ledKeyboardTimer, &QTimer::timeout, this, [this]() {
|
||||
uint8_t caps, num, scroll, kana;
|
||||
keyboard_get_states(&caps, &num, &scroll, &kana);
|
||||
|
||||
@@ -246,12 +246,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
if (caps_label->isVisible())
|
||||
caps_label->setPixmap(caps ? this->caps_icon.pixmap(QSize(16, 16)) : this->caps_icon_off.pixmap(QSize(16, 16)));
|
||||
if (scroll_label->isVisible())
|
||||
scroll_label->setPixmap(scroll ? this->scroll_icon.pixmap(QSize(16, 16)) :
|
||||
this->scroll_icon_off.pixmap(QSize(16, 16)));
|
||||
scroll_label->setPixmap(scroll ? this->scroll_icon.pixmap(QSize(16, 16)) : this->scroll_icon_off.pixmap(QSize(16, 16)));
|
||||
|
||||
if (kana_label->isVisible())
|
||||
kana_label->setPixmap(kana ? this->kana_icon.pixmap(QSize(16, 16)) :
|
||||
this->kana_icon_off.pixmap(QSize(16, 16)));
|
||||
kana_label->setPixmap(kana ? this->kana_icon.pixmap(QSize(16, 16)) : this->kana_icon_off.pixmap(QSize(16, 16)));
|
||||
});
|
||||
ledKeyboardTimer->start();
|
||||
|
||||
@@ -285,10 +283,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
num_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
|
||||
scroll_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
|
||||
caps_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
|
||||
int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) &&
|
||||
(keyboard_type == KEYBOARD_TYPE_AX);
|
||||
int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) &&
|
||||
!machine_has_bus(machine, MACHINE_BUS_PS2_PORTS);
|
||||
int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && (keyboard_type == KEYBOARD_TYPE_AX);
|
||||
int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) && !machine_has_bus(machine, MACHINE_BUS_PS2_PORTS);
|
||||
kana_label->setVisible(ext_ax_kbd || int_ax_kbd);
|
||||
while (QApplication::overrideCursor())
|
||||
QApplication::restoreOverrideCursor();
|
||||
@@ -300,7 +296,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
bool enable_comp_option = false;
|
||||
for (int i = 0; i < MONITORS_NUM; i++) {
|
||||
if (monitors[i].mon_composite) { enable_comp_option = true; break; }
|
||||
if (monitors[i].mon_composite) {
|
||||
enable_comp_option = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ui->actionCGA_composite_settings->setEnabled(enable_comp_option);
|
||||
@@ -398,8 +397,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) {
|
||||
w = static_cast<int>(w / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.));
|
||||
|
||||
const int modifiedHeight =
|
||||
static_cast<int>(h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.))
|
||||
const int modifiedHeight = static_cast<int>(h / (!dpi_scale ? util::screenOfWidget(this)->devicePixelRatio() : 1.))
|
||||
+ menuBar()->height()
|
||||
+ (statusBar()->height() * !hide_status_bar)
|
||||
+ (ui->toolBar->height() * !hide_tool_bar);
|
||||
@@ -576,17 +574,27 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
actGroup->addAction(ui->action_6x_2);
|
||||
actGroup->addAction(ui->action_7x_2);
|
||||
actGroup->addAction(ui->action_8x_2);
|
||||
connect(actGroup, &QActionGroup::triggered, this, [this](QAction* action) {
|
||||
if (action == ui->action_0_5x_2) video_gl_input_scale = 0.5;
|
||||
if (action == ui->action_1x_2) video_gl_input_scale = 1;
|
||||
if (action == ui->action1_5x_2) video_gl_input_scale = 1.5;
|
||||
if (action == ui->action_2x_2) video_gl_input_scale = 2;
|
||||
if (action == ui->action_3x_2) video_gl_input_scale = 3;
|
||||
if (action == ui->action_4x_2) video_gl_input_scale = 4;
|
||||
if (action == ui->action_5x_2) video_gl_input_scale = 5;
|
||||
if (action == ui->action_6x_2) video_gl_input_scale = 6;
|
||||
if (action == ui->action_7x_2) video_gl_input_scale = 7;
|
||||
if (action == ui->action_8x_2) video_gl_input_scale = 8;
|
||||
connect(actGroup, &QActionGroup::triggered, this, [this](QAction *action) {
|
||||
if (action == ui->action_0_5x_2)
|
||||
video_gl_input_scale = 0.5;
|
||||
if (action == ui->action_1x_2)
|
||||
video_gl_input_scale = 1;
|
||||
if (action == ui->action1_5x_2)
|
||||
video_gl_input_scale = 1.5;
|
||||
if (action == ui->action_2x_2)
|
||||
video_gl_input_scale = 2;
|
||||
if (action == ui->action_3x_2)
|
||||
video_gl_input_scale = 3;
|
||||
if (action == ui->action_4x_2)
|
||||
video_gl_input_scale = 4;
|
||||
if (action == ui->action_5x_2)
|
||||
video_gl_input_scale = 5;
|
||||
if (action == ui->action_6x_2)
|
||||
video_gl_input_scale = 6;
|
||||
if (action == ui->action_7x_2)
|
||||
video_gl_input_scale = 7;
|
||||
if (action == ui->action_8x_2)
|
||||
video_gl_input_scale = 8;
|
||||
});
|
||||
|
||||
switch (scale) {
|
||||
@@ -697,12 +705,17 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
actGroup->addAction(ui->action_Square_pixels_keep_ratio_gl);
|
||||
actGroup->addAction(ui->action_Integer_scale_gl);
|
||||
actGroup->addAction(ui->action4_3_Integer_scale_gl);
|
||||
connect(actGroup, &QActionGroup::triggered, this, [this](QAction* action) {
|
||||
if (action == ui->action_Full_screen_stretch_gl) video_gl_input_scale_mode = FULLSCR_SCALE_FULL;
|
||||
if (action == ui->action_4_3_gl) video_gl_input_scale_mode = FULLSCR_SCALE_43;
|
||||
if (action == ui->action_Square_pixels_keep_ratio_gl) video_gl_input_scale_mode = FULLSCR_SCALE_KEEPRATIO;
|
||||
if (action == ui->action_Integer_scale_gl) video_gl_input_scale_mode = FULLSCR_SCALE_INT;
|
||||
if (action == ui->action4_3_Integer_scale_gl) video_gl_input_scale_mode = FULLSCR_SCALE_INT43;
|
||||
connect(actGroup, &QActionGroup::triggered, this, [this](QAction *action) {
|
||||
if (action == ui->action_Full_screen_stretch_gl)
|
||||
video_gl_input_scale_mode = FULLSCR_SCALE_FULL;
|
||||
if (action == ui->action_4_3_gl)
|
||||
video_gl_input_scale_mode = FULLSCR_SCALE_43;
|
||||
if (action == ui->action_Square_pixels_keep_ratio_gl)
|
||||
video_gl_input_scale_mode = FULLSCR_SCALE_KEEPRATIO;
|
||||
if (action == ui->action_Integer_scale_gl)
|
||||
video_gl_input_scale_mode = FULLSCR_SCALE_INT;
|
||||
if (action == ui->action4_3_Integer_scale_gl)
|
||||
video_gl_input_scale_mode = FULLSCR_SCALE_INT43;
|
||||
});
|
||||
switch (video_grayscale) {
|
||||
default:
|
||||
@@ -770,7 +783,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
video_setblit(qt_blit);
|
||||
|
||||
if (start_in_fullscreen) {
|
||||
connect(ui->stackedWidget, &RendererStack::blitToRenderer, this, [this] () {
|
||||
connect(ui->stackedWidget, &RendererStack::blitToRenderer, this, [this]() {
|
||||
if (start_in_fullscreen) {
|
||||
QTimer::singleShot(100, ui->actionFullscreen, &QAction::trigger);
|
||||
start_in_fullscreen = 0;
|
||||
@@ -820,9 +833,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
/* Remove default Shift+F10 handler, which unfocuses keyboard input even with no context menu. */
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
connect(new QShortcut(QKeySequence(Qt::SHIFT | Qt::Key_F10), this), &QShortcut::activated, this, [](){});
|
||||
connect(new QShortcut(QKeySequence(Qt::SHIFT | Qt::Key_F10), this), &QShortcut::activated, this, []() {});
|
||||
#else
|
||||
connect(new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F10), this), &QShortcut::activated, this, [](){});
|
||||
connect(new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F10), this), &QShortcut::activated, this, []() {});
|
||||
#endif
|
||||
|
||||
connect(this, &MainWindow::initRendererMonitor, this, &MainWindow::initRendererMonitorSlot);
|
||||
@@ -880,18 +893,19 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
else
|
||||
# endif
|
||||
# ifdef WAYLAND
|
||||
if (QApplication::platformName().contains("wayland"))
|
||||
if (QApplication::platformName().contains("wayland"))
|
||||
xkbcommon_wl_init();
|
||||
else
|
||||
# endif
|
||||
{}
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined Q_OS_UNIX && !defined Q_OS_MACOS && !defined Q_OS_HAIKU
|
||||
if (QApplication::platformName().contains("xcb")) {
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
auto whandle = windowHandle();
|
||||
if (! whandle) {
|
||||
if (!whandle) {
|
||||
qWarning() << "No window handle";
|
||||
} else {
|
||||
QPlatformWindow *window = whandle->handle();
|
||||
@@ -901,7 +915,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
}
|
||||
#endif
|
||||
|
||||
updateShortcuts();
|
||||
updateShortcuts();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -914,7 +928,7 @@ MainWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
if (confirm_exit && confirm_exit_cmdl && cpu_thread_run) {
|
||||
QMessageBox questionbox(QMessageBox::Icon::Question, "86Box", tr("Are you sure you want to exit 86Box?"), QMessageBox::Yes | QMessageBox::No, this);
|
||||
auto chkbox = new QCheckBox(tr("Don't show this message again"));
|
||||
auto chkbox = new QCheckBox(tr("Don't show this message again"));
|
||||
questionbox.setCheckBox(chkbox);
|
||||
chkbox->setChecked(!confirm_exit);
|
||||
|
||||
@@ -967,57 +981,57 @@ MainWindow::closeEvent(QCloseEvent *event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateShortcuts()
|
||||
void
|
||||
MainWindow::updateShortcuts()
|
||||
{
|
||||
/*
|
||||
Update menu shortcuts from accelerator table
|
||||
|
||||
Note that these only work in windowed mode. If you add any new shortcuts,
|
||||
you have to go duplicate them in MainWindow::eventFilter()
|
||||
*/
|
||||
|
||||
// First we need to wipe all existing accelerators, otherwise Qt will
|
||||
// run into conflicts with old ones.
|
||||
ui->actionTake_screenshot->setShortcut(QKeySequence());
|
||||
ui->actionCtrl_Alt_Del->setShortcut(QKeySequence());
|
||||
ui->actionCtrl_Alt_Esc->setShortcut(QKeySequence());
|
||||
ui->actionHard_Reset->setShortcut(QKeySequence());
|
||||
ui->actionPause->setShortcut(QKeySequence());
|
||||
ui->actionMute_Unmute->setShortcut(QKeySequence());
|
||||
|
||||
int accID;
|
||||
QKeySequence seq;
|
||||
|
||||
accID = FindAccelerator("screenshot");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionTake_screenshot->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("send_ctrl_alt_del");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionCtrl_Alt_Del->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("send_ctrl_alt_esc");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionCtrl_Alt_Esc->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("hard_reset");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionHard_Reset->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("fullscreen");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionFullscreen->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("pause");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionPause->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("mute");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionMute_Unmute->setShortcut(seq);
|
||||
/*
|
||||
Update menu shortcuts from accelerator table
|
||||
|
||||
Note that these only work in windowed mode. If you add any new shortcuts,
|
||||
you have to go duplicate them in MainWindow::eventFilter()
|
||||
*/
|
||||
|
||||
// First we need to wipe all existing accelerators, otherwise Qt will
|
||||
// run into conflicts with old ones.
|
||||
ui->actionTake_screenshot->setShortcut(QKeySequence());
|
||||
ui->actionCtrl_Alt_Del->setShortcut(QKeySequence());
|
||||
ui->actionCtrl_Alt_Esc->setShortcut(QKeySequence());
|
||||
ui->actionHard_Reset->setShortcut(QKeySequence());
|
||||
ui->actionPause->setShortcut(QKeySequence());
|
||||
ui->actionMute_Unmute->setShortcut(QKeySequence());
|
||||
|
||||
int accID;
|
||||
QKeySequence seq;
|
||||
|
||||
accID = FindAccelerator("screenshot");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionTake_screenshot->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("send_ctrl_alt_del");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionCtrl_Alt_Del->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("send_ctrl_alt_esc");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionCtrl_Alt_Esc->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("hard_reset");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionHard_Reset->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("fullscreen");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionFullscreen->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("pause");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionPause->setShortcut(seq);
|
||||
|
||||
accID = FindAccelerator("mute");
|
||||
seq = QKeySequence::fromString(acc_keys[accID].seq);
|
||||
ui->actionMute_Unmute->setShortcut(seq);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
@@ -1031,24 +1045,26 @@ MainWindow::resizeEvent(QResizeEvent *event)
|
||||
int newY = pos().y();
|
||||
|
||||
if (((frameGeometry().x() + event->size().width() + 1) > util::screenOfWidget(this)->availableGeometry().right())) {
|
||||
//move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y());
|
||||
// move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y());
|
||||
newX = util::screenOfWidget(this)->availableGeometry().right() - frameGeometry().width() - 1;
|
||||
if (newX < 1) newX = 1;
|
||||
if (newX < 1)
|
||||
newX = 1;
|
||||
}
|
||||
|
||||
if (((frameGeometry().y() + event->size().height() + 1) > util::screenOfWidget(this)->availableGeometry().bottom())) {
|
||||
newY = util::screenOfWidget(this)->availableGeometry().bottom() - frameGeometry().height() - 1;
|
||||
if (newY < 1) newY = 1;
|
||||
if (newY < 1)
|
||||
newY = 1;
|
||||
}
|
||||
move(newX, newY);
|
||||
#endif
|
||||
#endif /*MOVE_WINDOW*/
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::initRendererMonitorSlot(int monitor_index)
|
||||
{
|
||||
auto &secondaryRenderer = this->renderers[monitor_index];
|
||||
secondaryRenderer = std::make_unique<RendererStack>(nullptr, monitor_index);
|
||||
secondaryRenderer = std::make_unique<RendererStack>(nullptr, monitor_index);
|
||||
if (secondaryRenderer) {
|
||||
connect(secondaryRenderer.get(), &RendererStack::rendererChanged, this, [this, monitor_index] {
|
||||
this->renderers[monitor_index]->show();
|
||||
@@ -1083,7 +1099,7 @@ MainWindow::initRendererMonitorSlot(int monitor_index)
|
||||
if (monitor_settings[monitor_index].mon_window_maximized) {
|
||||
if (renderers[monitor_index])
|
||||
renderers[monitor_index]->onResize(renderers[monitor_index]->width(),
|
||||
renderers[monitor_index]->height());
|
||||
renderers[monitor_index]->height());
|
||||
|
||||
device_force_redraw();
|
||||
}
|
||||
@@ -1258,7 +1274,7 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode)
|
||||
# ifdef EVDEV_KEYBOARD_HPP
|
||||
keycode = evdev_translate(keycode - 8);
|
||||
# else
|
||||
keycode = 0;
|
||||
keycode = 0;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -1277,8 +1293,8 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode)
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x80 ... 0xff: /* regular break codes */
|
||||
case 0x10b: /* Microsoft scroll up normal */
|
||||
case 0x80 ... 0xff: /* regular break codes */
|
||||
case 0x10b: /* Microsoft scroll up normal */
|
||||
case 0x180 ... 0x1ff: /* E0 break codes (including Microsoft scroll down normal) */
|
||||
/* This key uses a break code as make. Send it manually, only on press. */
|
||||
if (down && (mouse_capture || !kbd_req_capture || video_fullscreen)) {
|
||||
@@ -1293,7 +1309,7 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode)
|
||||
keycode = 0x38; /* map to Left Alt */
|
||||
break;
|
||||
|
||||
case 0x137: /* Print Screen */
|
||||
case 0x137: /* Print Screen */
|
||||
if (keyboard_recv_ui(0x38) || keyboard_recv_ui(0x138)) { /* Alt+ */
|
||||
keycode = 0x54;
|
||||
} else if (down) {
|
||||
@@ -1304,7 +1320,7 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode)
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x145: /* Pause */
|
||||
case 0x145: /* Pause */
|
||||
if (keyboard_recv_ui(0x1d) || keyboard_recv_ui(0x11d)) { /* Ctrl+ */
|
||||
keycode = 0x146;
|
||||
} else {
|
||||
@@ -1322,15 +1338,15 @@ MainWindow::processKeyboardInput(bool down, uint32_t keycode)
|
||||
// that's followed up with "(really?)". It's the only way to distinguish
|
||||
// left and right modifiers with Qt 6 on macOS, so let's just roll with it.
|
||||
static std::unordered_map<uint32_t, uint16_t> mac_modifiers_to_xt = {
|
||||
{NX_DEVICELCTLKEYMASK, 0x1D },
|
||||
{ NX_DEVICELSHIFTKEYMASK, 0x2A },
|
||||
{ NX_DEVICERSHIFTKEYMASK, 0x36 },
|
||||
{ NX_DEVICELCMDKEYMASK, 0x15B},
|
||||
{ NX_DEVICERCMDKEYMASK, 0x15C},
|
||||
{ NX_DEVICELALTKEYMASK, 0x38 },
|
||||
{ NX_DEVICERALTKEYMASK, 0x138},
|
||||
{ NX_DEVICE_ALPHASHIFT_STATELESS_MASK, 0x3A },
|
||||
{ NX_DEVICERCTLKEYMASK, 0x11D},
|
||||
{ NX_DEVICELCTLKEYMASK, 0x1D },
|
||||
{ NX_DEVICELSHIFTKEYMASK, 0x2A },
|
||||
{ NX_DEVICERSHIFTKEYMASK, 0x36 },
|
||||
{ NX_DEVICELCMDKEYMASK, 0x15B },
|
||||
{ NX_DEVICERCMDKEYMASK, 0x15C },
|
||||
{ NX_DEVICELALTKEYMASK, 0x38 },
|
||||
{ NX_DEVICERALTKEYMASK, 0x138 },
|
||||
{ NX_DEVICE_ALPHASHIFT_STATELESS_MASK, 0x3A },
|
||||
{ NX_DEVICERCTLKEYMASK, 0x11D },
|
||||
};
|
||||
static bool mac_iso_swap = false;
|
||||
|
||||
@@ -1391,45 +1407,44 @@ MainWindow::processMacKeyboardInput(bool down, const QKeyEvent *event)
|
||||
- Romanian third level ANSI_Grave is unknown
|
||||
- Russian clusters <>, plusminus and paragraph into a four-level ANSI_Grave, with the aforementioned `~ on ISO_Section */
|
||||
auto key = event->key();
|
||||
if ((nvk == 0x32) && ( /* system reports ANSI_Grave for ISO_Section keys: */
|
||||
(key == Qt::Key_Less) || (key == Qt::Key_Greater) || /* Croatian, French, German, Icelandic, Italian, Norwegian, Portuguese, Spanish, Spanish Latin America, Turkish Q */
|
||||
(key == Qt::Key_Ugrave) || /* French Canadian */
|
||||
(key == Qt::Key_Icircumflex) || /* Romanian */
|
||||
(key == Qt::Key_Iacute) || /* Hungarian */
|
||||
(key == Qt::Key_BracketLeft) || (key == Qt::Key_BracketRight) || /* Russian upper two levels */
|
||||
(key == Qt::Key_W) /* Turkish F */
|
||||
))
|
||||
if ((nvk == 0x32) && ( /* system reports ANSI_Grave for ISO_Section keys: */
|
||||
(key == Qt::Key_Less) || (key == Qt::Key_Greater) || /* Croatian, French, German, Icelandic, Italian, Norwegian, Portuguese, Spanish, Spanish Latin America, Turkish Q */
|
||||
(key == Qt::Key_Ugrave) || /* French Canadian */
|
||||
(key == Qt::Key_Icircumflex) || /* Romanian */
|
||||
(key == Qt::Key_Iacute) || /* Hungarian */
|
||||
(key == Qt::Key_BracketLeft) || (key == Qt::Key_BracketRight) || /* Russian upper two levels */
|
||||
(key == Qt::Key_W) /* Turkish F */
|
||||
))
|
||||
mac_iso_swap = true;
|
||||
else if ((nvk == 0x0a) && ( /* system reports ISO_Section for ANSI_Grave keys: */
|
||||
(key == Qt::Key_paragraph) || (key == Qt::Key_plusminus) || /* Arabic, British, Bulgarian, Danish shifted, Dutch, Greek, Hebrew, Hungarian shifted, International English, Norwegian shifted, Portuguese, Russian lower two levels, Swiss unshifted, Swedish unshifted, Turkish F */
|
||||
(key == Qt::Key_At) || (key == Qt::Key_NumberSign) || /* Belgian, French */
|
||||
(key == Qt::Key_Apostrophe) || /* Brazilian unshifted */
|
||||
(key == Qt::Key_QuoteDbl) || /* Brazilian shifted, Turkish Q unshifted */
|
||||
(key == Qt::Key_QuoteLeft) || /* Croatian (right quote unknown) */
|
||||
(key == Qt::Key_Dollar) || /* Danish unshifted */
|
||||
(key == Qt::Key_AsciiCircum) || (key == 0x1ffffff) || /* German unshifted (0x1ffffff according to one tester), Polish unshifted */
|
||||
(key == Qt::Key_degree) || /* German shifted, Icelandic unshifted, Spanish Latin America shifted, Swiss shifted, Swedish shifted */
|
||||
(key == Qt::Key_0) || /* Hungarian unshifted */
|
||||
(key == Qt::Key_diaeresis) || /* Icelandic shifted */
|
||||
(key == Qt::Key_acute) || /* Norwegian unshifted */
|
||||
(key == Qt::Key_Asterisk) || /* Polish shifted */
|
||||
(key == Qt::Key_masculine) || (key == Qt::Key_ordfeminine) || /* Spanish (masculine unconfirmed) */
|
||||
(key == Qt::Key_Eacute) || /* Turkish Q shifted */
|
||||
(key == Qt::Key_Slash) /* French Canadian unshifted, Ukrainian shifted */
|
||||
))
|
||||
else if ((nvk == 0x0a) && ( /* system reports ISO_Section for ANSI_Grave keys: */
|
||||
(key == Qt::Key_paragraph) || (key == Qt::Key_plusminus) || /* Arabic, British, Bulgarian, Danish shifted, Dutch, Greek, Hebrew, Hungarian shifted, International English, Norwegian shifted, Portuguese, Russian lower two levels, Swiss unshifted, Swedish unshifted, Turkish F */
|
||||
(key == Qt::Key_At) || (key == Qt::Key_NumberSign) || /* Belgian, French */
|
||||
(key == Qt::Key_Apostrophe) || /* Brazilian unshifted */
|
||||
(key == Qt::Key_QuoteDbl) || /* Brazilian shifted, Turkish Q unshifted */
|
||||
(key == Qt::Key_QuoteLeft) || /* Croatian (right quote unknown) */
|
||||
(key == Qt::Key_Dollar) || /* Danish unshifted */
|
||||
(key == Qt::Key_AsciiCircum) || (key == 0x1ffffff) || /* German unshifted (0x1ffffff according to one tester), Polish unshifted */
|
||||
(key == Qt::Key_degree) || /* German shifted, Icelandic unshifted, Spanish Latin America shifted, Swiss shifted, Swedish shifted */
|
||||
(key == Qt::Key_0) || /* Hungarian unshifted */
|
||||
(key == Qt::Key_diaeresis) || /* Icelandic shifted */
|
||||
(key == Qt::Key_acute) || /* Norwegian unshifted */
|
||||
(key == Qt::Key_Asterisk) || /* Polish shifted */
|
||||
(key == Qt::Key_masculine) || (key == Qt::Key_ordfeminine) || /* Spanish (masculine unconfirmed) */
|
||||
(key == Qt::Key_Eacute) || /* Turkish Q shifted */
|
||||
(key == Qt::Key_Slash) /* French Canadian unshifted, Ukrainian shifted */
|
||||
))
|
||||
mac_iso_swap = true;
|
||||
#if 0
|
||||
# if 0
|
||||
if (down) {
|
||||
QMessageBox questionbox(QMessageBox::Icon::Information, QString("Mac key swap test"), QString("nativeVirtualKey 0x%1\nnativeScanCode 0x%2\nkey 0x%3\nmac_iso_swap %4").arg(nvk, 0, 16).arg(event->nativeScanCode(), 0, 16).arg(key, 0, 16).arg(mac_iso_swap ? "yes" : "no"), QMessageBox::Ok, this);
|
||||
questionbox.exec();
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
if (mac_iso_swap)
|
||||
nvk = (nvk == 0x0a) ? 0x32 : 0x0a;
|
||||
}
|
||||
// Special case for command + forward delete to send insert.
|
||||
if ((event->nativeModifiers() & NSEventModifierFlagCommand) &&
|
||||
((event->nativeVirtualKey() == nvk_Delete) || event->key() == Qt::Key_Delete)) {
|
||||
if ((event->nativeModifiers() & NSEventModifierFlagCommand) && ((event->nativeVirtualKey() == nvk_Delete) || event->key() == Qt::Key_Delete)) {
|
||||
nvk = nvk_Insert; // Qt::Key_Help according to event->key()
|
||||
}
|
||||
|
||||
@@ -1461,7 +1476,7 @@ MainWindow::on_actionFullscreen_triggered()
|
||||
ui->stackedWidget->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
showFullScreen();
|
||||
}
|
||||
fs_on_signal = false;
|
||||
fs_on_signal = false;
|
||||
fs_off_signal = false;
|
||||
ui->stackedWidget->onResize(width(), height());
|
||||
}
|
||||
@@ -1482,85 +1497,71 @@ MainWindow::getTitle(wchar_t *title)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Helper to find an accelerator key and return it's sequence
|
||||
// TODO: Is there a more central place to put this?
|
||||
QKeySequence
|
||||
MainWindow::FindAcceleratorSeq(const char *name)
|
||||
{
|
||||
int accID = FindAccelerator(name);
|
||||
if(accID == -1)
|
||||
return false;
|
||||
|
||||
return(QKeySequence::fromString(acc_keys[accID].seq));
|
||||
int accID = FindAccelerator(name);
|
||||
if (accID == -1)
|
||||
return false;
|
||||
|
||||
return (QKeySequence::fromString(acc_keys[accID].seq));
|
||||
}
|
||||
|
||||
bool
|
||||
MainWindow::eventFilter(QObject *receiver, QEvent *event)
|
||||
{
|
||||
// Detect shortcuts when menubar is hidden
|
||||
// TODO: Could this be simplified by proxying the event and manually
|
||||
// shoving it into the menubar?
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
this->keyPressEvent((QKeyEvent *) event);
|
||||
// Detect shortcuts when menubar is hidden
|
||||
// TODO: Could this be simplified by proxying the event and manually
|
||||
// shoving it into the menubar?
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
this->keyPressEvent((QKeyEvent *) event);
|
||||
|
||||
// We check for mouse release even if we aren't fullscreen,
|
||||
// because it's not a menu accelerator.
|
||||
if (event->type() == QEvent::KeyPress)
|
||||
{
|
||||
QKeyEvent *ke = (QKeyEvent *) event;
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("release_mouse") ||
|
||||
(QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("release_mouse"))
|
||||
{
|
||||
plat_mouse_capture(0);
|
||||
}
|
||||
}
|
||||
// We check for mouse release even if we aren't fullscreen,
|
||||
// because it's not a menu accelerator.
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *ke = (QKeyEvent *) event;
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("release_mouse") || (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("release_mouse")) {
|
||||
plat_mouse_capture(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::KeyPress && video_fullscreen != 0)
|
||||
{
|
||||
QKeyEvent *ke = (QKeyEvent *) event;
|
||||
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("screenshot")
|
||||
|| (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("screenshot"))
|
||||
{
|
||||
ui->actionTake_screenshot->trigger();
|
||||
}
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("fullscreen")
|
||||
|| (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("fullscreen"))
|
||||
{
|
||||
ui->actionFullscreen->trigger();
|
||||
}
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("hard_reset")
|
||||
|| (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("hard_reset"))
|
||||
{
|
||||
ui->actionHard_Reset->trigger();
|
||||
}
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_del")
|
||||
|| (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_del"))
|
||||
{
|
||||
ui->actionCtrl_Alt_Del->trigger();
|
||||
}
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_esc")
|
||||
|| (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_esc"))
|
||||
{
|
||||
ui->actionCtrl_Alt_Esc->trigger();
|
||||
}
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("pause")
|
||||
|| (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("pause"))
|
||||
{
|
||||
ui->actionPause->trigger();
|
||||
}
|
||||
if ((QKeySequence)(ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("mute")
|
||||
|| (QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("mute"))
|
||||
{
|
||||
ui->actionMute_Unmute->trigger();
|
||||
}
|
||||
if (event->type() == QEvent::KeyPress && video_fullscreen != 0) {
|
||||
QKeyEvent *ke = (QKeyEvent *) event;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("screenshot")
|
||||
|| (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("screenshot")) {
|
||||
ui->actionTake_screenshot->trigger();
|
||||
}
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("fullscreen")
|
||||
|| (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("fullscreen")) {
|
||||
ui->actionFullscreen->trigger();
|
||||
}
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("hard_reset")
|
||||
|| (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("hard_reset")) {
|
||||
ui->actionHard_Reset->trigger();
|
||||
}
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_del")
|
||||
|| (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_del")) {
|
||||
ui->actionCtrl_Alt_Del->trigger();
|
||||
}
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("send_ctrl_alt_esc")
|
||||
|| (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_esc")) {
|
||||
ui->actionCtrl_Alt_Esc->trigger();
|
||||
}
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("pause")
|
||||
|| (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("pause")) {
|
||||
ui->actionPause->trigger();
|
||||
}
|
||||
if ((QKeySequence) (ke->key() | (ke->modifiers() & ~Qt::KeypadModifier)) == FindAcceleratorSeq("mute")
|
||||
|| (QKeySequence) (ke->key() | ke->modifiers()) == FindAcceleratorSeq("mute")) {
|
||||
ui->actionMute_Unmute->trigger();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dopause && (!kbd_req_capture || mouse_capture)) {
|
||||
if (event->type() == QEvent::Shortcut) {
|
||||
@@ -1571,8 +1572,8 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
|
||||
}
|
||||
}
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
event->accept();
|
||||
|
||||
event->accept();
|
||||
|
||||
return true;
|
||||
}
|
||||
if (event->type() == QEvent::KeyRelease) {
|
||||
@@ -1586,7 +1587,7 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
|
||||
static auto curdopause = dopause;
|
||||
if (event->type() == QEvent::WindowBlocked) {
|
||||
window_blocked = true;
|
||||
curdopause = dopause;
|
||||
curdopause = dopause;
|
||||
plat_pause(isNonPause ? dopause : (isShowMessage ? 2 : 1));
|
||||
emit setMouseCapture(false);
|
||||
releaseKeyboard();
|
||||
@@ -1595,7 +1596,7 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
|
||||
plat_pause(curdopause);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return QMainWindow::eventFilter(receiver, event);
|
||||
}
|
||||
|
||||
@@ -1615,15 +1616,16 @@ MainWindow::refreshMediaMenu()
|
||||
caps_label->setToolTip(QShortcut::tr("Caps Lock"));
|
||||
caps_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD));
|
||||
kana_label->setToolTip(QShortcut::tr("Kana Lock"));
|
||||
int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) &&
|
||||
(keyboard_type == KEYBOARD_TYPE_AX);
|
||||
int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) &&
|
||||
!machine_has_bus(machine, MACHINE_BUS_PS2_PORTS);
|
||||
int ext_ax_kbd = machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && (keyboard_type == KEYBOARD_TYPE_AX);
|
||||
int int_ax_kbd = machine_has_flags(machine, MACHINE_KEYBOARD_JIS) && !machine_has_bus(machine, MACHINE_BUS_PS2_PORTS);
|
||||
kana_label->setVisible(ext_ax_kbd || int_ax_kbd);
|
||||
|
||||
bool enable_comp_option = false;
|
||||
for (int i = 0; i < MONITORS_NUM; i++) {
|
||||
if (monitors[i].mon_composite) { enable_comp_option = true; break; }
|
||||
if (monitors[i].mon_composite) {
|
||||
enable_comp_option = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ui->actionCGA_composite_settings->setEnabled(enable_comp_option);
|
||||
@@ -1635,12 +1637,11 @@ MainWindow::showMessage(int flags, const QString &header, const QString &message
|
||||
if (QThread::currentThread() == this->thread()) {
|
||||
if (!cpu_thread_running) {
|
||||
showMessageForNonQtThread(flags, header, message, richText, nullptr);
|
||||
}
|
||||
else
|
||||
} else
|
||||
showMessage_(flags, header, message, richText);
|
||||
} else {
|
||||
std::atomic_bool done = false;
|
||||
emit showMessageForNonQtThread(flags, header, message, richText, &done);
|
||||
emit showMessageForNonQtThread(flags, header, message, richText, &done);
|
||||
while (!done) {
|
||||
QThread::msleep(1);
|
||||
}
|
||||
@@ -1681,7 +1682,7 @@ MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
processKeyboardInput(true, event->nativeScanCode());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -1724,13 +1725,13 @@ MainWindow::getRenderWidgetSize()
|
||||
void
|
||||
MainWindow::focusInEvent(QFocusEvent *event)
|
||||
{
|
||||
//this->grabKeyboard();
|
||||
// this->grabKeyboard();
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::focusOutEvent(QFocusEvent *event)
|
||||
{
|
||||
//this->releaseKeyboard();
|
||||
// this->releaseKeyboard();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2209,7 +2210,7 @@ void
|
||||
MainWindow::on_actionTake_screenshot_triggered()
|
||||
{
|
||||
startblit();
|
||||
for (auto & monitor : monitors)
|
||||
for (auto &monitor : monitors)
|
||||
++monitor.mon_screenshots;
|
||||
endblit();
|
||||
device_force_redraw();
|
||||
@@ -2240,16 +2241,13 @@ MainWindow::setSendKeyboardInput(bool enabled)
|
||||
void
|
||||
MainWindow::updateUiPauseState()
|
||||
{
|
||||
const auto pause_icon = dopause ? QIcon(":/menuicons/qt/icons/run.ico") :
|
||||
QIcon(":/menuicons/qt/icons/pause.ico");
|
||||
const auto tooltip_text = dopause ? QString(tr("Resume execution")) :
|
||||
QString(tr("Pause execution"));
|
||||
const auto menu_text = dopause ? QString(tr("Re&sume")) :
|
||||
QString(tr("&Pause"));
|
||||
const auto pause_icon = dopause ? QIcon(":/menuicons/qt/icons/run.ico") : QIcon(":/menuicons/qt/icons/pause.ico");
|
||||
const auto tooltip_text = dopause ? QString(tr("Resume execution")) : QString(tr("Pause execution"));
|
||||
const auto menu_text = dopause ? QString(tr("Re&sume")) : QString(tr("&Pause"));
|
||||
ui->actionPause->setIcon(pause_icon);
|
||||
ui->actionPause->setToolTip(tooltip_text);
|
||||
ui->actionPause->setText(menu_text);
|
||||
emit vmmRunningStateChanged(static_cast<VMManagerProtocol::RunningState>(window_blocked ? (dopause ? VMManagerProtocol::RunningState::PausedWaiting : VMManagerProtocol::RunningState::RunningWaiting) : (VMManagerProtocol::RunningState)dopause));
|
||||
emit vmmRunningStateChanged(static_cast<VMManagerProtocol::RunningState>(window_blocked ? (dopause ? VMManagerProtocol::RunningState::PausedWaiting : VMManagerProtocol::RunningState::RunningWaiting) : (VMManagerProtocol::RunningState) dopause));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2345,10 +2343,11 @@ MainWindow::on_actionRenderer_options_triggered()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else for (int i = 1; i < MONITORS_NUM; i++) {
|
||||
if (renderers[i] && renderers[i]->hasOptions())
|
||||
renderers[i]->reloadOptions();
|
||||
}
|
||||
} else
|
||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||
if (renderers[i] && renderers[i]->hasOptions())
|
||||
renderers[i]->reloadOptions();
|
||||
}
|
||||
} else if (reload_renderers && ui->stackedWidget->reloadRendererOption()) {
|
||||
reload_renderers = false;
|
||||
ui->stackedWidget->switchRenderer(static_cast<RendererStack::Renderer>(vid_api));
|
||||
@@ -2437,24 +2436,28 @@ MainWindow::on_actionApply_fullscreen_stretch_mode_when_maximized_triggered(bool
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCursor_Puck_triggered()
|
||||
void
|
||||
MainWindow::on_actionCursor_Puck_triggered()
|
||||
{
|
||||
tablet_tool_type = 0;
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionPen_triggered()
|
||||
void
|
||||
MainWindow::on_actionPen_triggered()
|
||||
{
|
||||
tablet_tool_type = 1;
|
||||
config_save();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionACPI_Shutdown_triggered()
|
||||
void
|
||||
MainWindow::on_actionACPI_Shutdown_triggered()
|
||||
{
|
||||
acpi_pwrbut_pressed = 1;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCGA_composite_settings_triggered()
|
||||
void
|
||||
MainWindow::on_actionCGA_composite_settings_triggered()
|
||||
{
|
||||
isNonPause = true;
|
||||
CGASettingsDialog dialog;
|
||||
@@ -2463,4 +2466,3 @@ void MainWindow::on_actionCGA_composite_settings_triggered()
|
||||
isNonPause = false;
|
||||
config_save();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,16 +33,15 @@ public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
void showMessage(int flags, const QString &header, const QString &message, bool richText);
|
||||
void getTitle(wchar_t *title);
|
||||
void blitToWidget(int x, int y, int w, int h, int monitor_index);
|
||||
QSize getRenderWidgetSize();
|
||||
void setSendKeyboardInput(bool enabled);
|
||||
void reloadAllRenderers();
|
||||
QShortcut *windowedShortcut;
|
||||
QKeySequence FindAcceleratorSeq(const char *name);
|
||||
|
||||
|
||||
void showMessage(int flags, const QString &header, const QString &message, bool richText);
|
||||
void getTitle(wchar_t *title);
|
||||
void blitToWidget(int x, int y, int w, int h, int monitor_index);
|
||||
QSize getRenderWidgetSize();
|
||||
void setSendKeyboardInput(bool enabled);
|
||||
void reloadAllRenderers();
|
||||
QShortcut *windowedShortcut;
|
||||
QKeySequence FindAcceleratorSeq(const char *name);
|
||||
|
||||
std::array<std::unique_ptr<RendererStack>, 8> renderers;
|
||||
signals:
|
||||
void paint(const QImage &image);
|
||||
@@ -65,7 +64,7 @@ signals:
|
||||
void setFullscreen(bool state);
|
||||
void setMouseCapture(bool state);
|
||||
|
||||
void showMessageForNonQtThread(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done);
|
||||
void showMessageForNonQtThread(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool *done);
|
||||
void getTitleForNonQtThread(wchar_t *title);
|
||||
|
||||
void vmmRunningStateChanged(VMManagerProtocol::RunningState state);
|
||||
@@ -138,7 +137,7 @@ private slots:
|
||||
void on_actionRenderer_options_triggered();
|
||||
|
||||
void refreshMediaMenu();
|
||||
void showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done = nullptr);
|
||||
void showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool *done = nullptr);
|
||||
void getTitle_(wchar_t *title);
|
||||
|
||||
void on_actionMCA_devices_triggered();
|
||||
@@ -178,8 +177,8 @@ private:
|
||||
std::unique_ptr<MachineStatus> status;
|
||||
std::shared_ptr<MediaMenu> mm;
|
||||
|
||||
void updateShortcuts();
|
||||
void processKeyboardInput(bool down, uint32_t keycode);
|
||||
void updateShortcuts();
|
||||
void processKeyboardInput(bool down, uint32_t keycode);
|
||||
#ifdef Q_OS_MACOS
|
||||
uint32_t last_modifiers = 0;
|
||||
void processMacKeyboardInput(bool down, const QKeyEvent *event);
|
||||
@@ -192,24 +191,24 @@ private:
|
||||
bool vnc_enabled = false;
|
||||
|
||||
/* Full screen ON and OFF signals */
|
||||
bool fs_on_signal = false;
|
||||
bool fs_off_signal = false;
|
||||
bool fs_on_signal = false;
|
||||
bool fs_off_signal = false;
|
||||
|
||||
/* Reload the renderers after closing renderer options dialog. */
|
||||
bool reload_renderers = false;
|
||||
bool reload_renderers = false;
|
||||
|
||||
friend class SpecifyDimensions;
|
||||
friend class ProgSettings;
|
||||
friend class RendererCommon;
|
||||
friend class RendererStack; // For UI variable access by non-primary renderer windows.
|
||||
friend class RendererStack; // For UI variable access by non-primary renderer windows.
|
||||
friend class WindowsRawInputFilter; // Needed to reload renderers on style sheet changes.
|
||||
|
||||
QLabel *caps_label, *scroll_label, *num_label, *kana_label;
|
||||
QIcon caps_icon, scroll_icon, num_icon, kana_icon;
|
||||
QIcon caps_icon_off, scroll_icon_off, num_icon_off, kana_icon_off;
|
||||
QIcon caps_icon, scroll_icon, num_icon, kana_icon;
|
||||
QIcon caps_icon_off, scroll_icon_off, num_icon_off, kana_icon_off;
|
||||
|
||||
bool isShowMessage = false;
|
||||
bool isNonPause = false;
|
||||
bool isShowMessage = false;
|
||||
bool isNonPause = false;
|
||||
bool window_blocked = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <utility>
|
||||
#include "qt_mediahistorymanager.hpp"
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include <windows.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
@@ -371,7 +371,7 @@ MediaHistoryManager::removeMissingImages(device_index_list_t &device_history)
|
||||
path_normalize(temp);
|
||||
}
|
||||
|
||||
QString qstr = QString::fromUtf8(temp);
|
||||
QString qstr = QString::fromUtf8(temp);
|
||||
QFileInfo new_fi(qstr);
|
||||
|
||||
bool file_exists = new_fi.exists();
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
|
||||
extern "C" {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#define BITMAP WINDOWS_BITMAP
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#undef BITMAP
|
||||
# define BITMAP WINDOWS_BITMAP
|
||||
# include <windows.h>
|
||||
# include <windowsx.h>
|
||||
# undef BITMAP
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
@@ -70,7 +70,7 @@ extern "C" {
|
||||
|
||||
std::shared_ptr<MediaMenu> MediaMenu::ptr;
|
||||
|
||||
static QSize pixmap_size(16, 16);
|
||||
static QSize pixmap_size(16, 16);
|
||||
|
||||
MediaMenu::MediaMenu(QWidget *parent)
|
||||
: QObject(parent)
|
||||
@@ -85,7 +85,7 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
parentMenu->clear();
|
||||
|
||||
if (MachineStatus::hasCassette()) {
|
||||
cassetteMenu = parentMenu->addMenu("");
|
||||
cassetteMenu = parentMenu->addMenu("");
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/cassette_image.ico");
|
||||
cassetteMenu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this]() { cassetteNewImage(); });
|
||||
cassetteMenu->addSeparator();
|
||||
@@ -114,7 +114,7 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
cartridgeMenus.clear();
|
||||
if (machine_has_cartridge(machine)) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/cartridge_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Image..."), [this, i]() { cartridgeSelectImage(i); });
|
||||
menu->addSeparator();
|
||||
@@ -132,9 +132,8 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
|
||||
floppyMenus.clear();
|
||||
MachineStatus::iterateFDD([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
QIcon img_icon = fdd_is_525(i) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") :
|
||||
QIcon(":/settings/qt/icons/floppy_35_image.ico");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
QIcon img_icon = fdd_is_525(i) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") : QIcon(":/settings/qt/icons/floppy_35_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { floppyNewImage(i); });
|
||||
menu->addSeparator();
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, Browse), tr("&Existing image..."), [this, i]() { floppySelectImage(i, false); });
|
||||
@@ -186,7 +185,7 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
|
||||
rdiskMenus.clear();
|
||||
MachineStatus::iterateRDisk([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/rdisk_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { rdiskNewImage(i); });
|
||||
menu->addSeparator();
|
||||
@@ -206,7 +205,7 @@ MediaMenu::refresh(QMenu *parentMenu)
|
||||
|
||||
moMenus.clear();
|
||||
MachineStatus::iterateMO([this, parentMenu](int i) {
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
auto *menu = parentMenu->addMenu("");
|
||||
QIcon img_icon = QIcon(":/settings/qt/icons/mo_image.ico");
|
||||
menu->addAction(getIconWithIndicator(img_icon, pixmap_size, QIcon::Normal, New), tr("&New image..."), [this, i]() { moNewImage(i); });
|
||||
menu->addSeparator();
|
||||
@@ -316,15 +315,15 @@ MediaMenu::cassetteEject()
|
||||
void
|
||||
MediaMenu::cassetteUpdateMenu()
|
||||
{
|
||||
QString name = cassette_fname;
|
||||
QFileInfo fi(cassette_fname);
|
||||
const QString mode = cassette_mode;
|
||||
auto childs = cassetteMenu->children();
|
||||
auto *recordMenu = dynamic_cast<QAction *>(childs[cassetteRecordPos]);
|
||||
auto *playMenu = dynamic_cast<QAction *>(childs[cassettePlayPos]);
|
||||
auto *rewindMenu = dynamic_cast<QAction *>(childs[cassetteRewindPos]);
|
||||
auto *fastFwdMenu = dynamic_cast<QAction *>(childs[cassetteFastFwdPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[cassetteEjectPos]);
|
||||
QString name = cassette_fname;
|
||||
QFileInfo fi(cassette_fname);
|
||||
const QString mode = cassette_mode;
|
||||
auto childs = cassetteMenu->children();
|
||||
auto *recordMenu = dynamic_cast<QAction *>(childs[cassetteRecordPos]);
|
||||
auto *playMenu = dynamic_cast<QAction *>(childs[cassettePlayPos]);
|
||||
auto *rewindMenu = dynamic_cast<QAction *>(childs[cassetteRewindPos]);
|
||||
auto *fastFwdMenu = dynamic_cast<QAction *>(childs[cassetteFastFwdPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[cassetteEjectPos]);
|
||||
|
||||
recordMenu->setEnabled(!name.isEmpty());
|
||||
playMenu->setEnabled(!name.isEmpty());
|
||||
@@ -400,9 +399,9 @@ MediaMenu::cartridgeUpdateMenu(int i)
|
||||
{
|
||||
const QString name = cart_fns[i];
|
||||
QFileInfo fi(cart_fns[i]);
|
||||
auto *menu = cartridgeMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[cartridgeEjectPos]);
|
||||
auto *menu = cartridgeMenus[i];
|
||||
auto childs = menu->children();
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[cartridgeEjectPos]);
|
||||
ejectMenu->setEnabled(!name.isEmpty());
|
||||
ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(fi.fileName()));
|
||||
menu->setTitle(tr("Car&tridge %1: %2").arg(QString::number(i + 1), name.isEmpty() ? tr("(empty)") : name));
|
||||
@@ -447,7 +446,8 @@ MediaMenu::floppySelectImage(int i, bool wp)
|
||||
tr("All files") %
|
||||
util::DlgFilter({ "*" }, true));
|
||||
|
||||
if (!filename.isEmpty()) floppyMount(i, filename, wp);
|
||||
if (!filename.isEmpty())
|
||||
floppyMount(i, filename, wp);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -525,7 +525,6 @@ MediaMenu::floppyUpdateMenu(int i)
|
||||
int type = fdd_get_type(i);
|
||||
floppyMenus[i]->setTitle(tr("&Floppy %1 (%2): %3").arg(QString::number(i + 1), fdd_getname(type), name.isEmpty() ? tr("(empty)") : name));
|
||||
floppyMenus[i]->setToolTip(tr("Floppy %1 (%2): %3").arg(QString::number(i + 1), fdd_getname(type), name.isEmpty() ? tr("(empty)") : name));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -597,7 +596,7 @@ MediaMenu::cdromMount(int i, int dir, const QString &arg)
|
||||
else {
|
||||
filename = QFileDialog::getOpenFileName(parentWidget, QString(),
|
||||
QString(),
|
||||
tr("CD-ROM images") % util::DlgFilter({ "iso", "cue", "mds" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
tr("CD-ROM images") % util::DlgFilter({ "iso", "cue", "mds" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
}
|
||||
|
||||
if (filename.isEmpty())
|
||||
@@ -649,7 +648,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
QObjectList children;
|
||||
QFileInfo fi;
|
||||
QIcon menu_icon;
|
||||
const auto fn = mhm.getImageForSlot(index, slot, type);
|
||||
const auto fn = mhm.getImageForSlot(index, slot, type);
|
||||
|
||||
QString menu_item_name;
|
||||
|
||||
@@ -691,8 +690,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
menu = floppyMenus[index];
|
||||
children = menu->children();
|
||||
imageHistoryUpdatePos = dynamic_cast<QAction *>(children[floppyImageHistoryPos[slot]]);
|
||||
menu_icon = fdd_is_525(index) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") :
|
||||
QIcon(":/settings/qt/icons/floppy_35_image.ico");
|
||||
menu_icon = fdd_is_525(index) ? QIcon(":/settings/qt/icons/floppy_525_image.ico") : QIcon(":/settings/qt/icons/floppy_35_image.ico");
|
||||
if (fn.left(5) == "wp://")
|
||||
fi.setFile(fn.right(fn.length() - 5));
|
||||
else
|
||||
@@ -720,7 +718,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
#endif
|
||||
} else {
|
||||
fi.setFile(fn);
|
||||
menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico");
|
||||
menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico");
|
||||
menu_item_name = fn.isEmpty() ? tr("Reload previous image") : fn;
|
||||
}
|
||||
imageHistoryUpdatePos->setIcon(menu_icon);
|
||||
@@ -770,7 +768,7 @@ MediaMenu::updateImageHistory(int index, int slot, ui::MediaType type)
|
||||
imageHistoryUpdatePos->setText(menu_item_name.prepend("&%1 ").arg((slot == 9) ? 0 : (slot + 1)));
|
||||
else
|
||||
#endif
|
||||
imageHistoryUpdatePos->setText(menu_item_name);
|
||||
imageHistoryUpdatePos->setText(menu_item_name);
|
||||
|
||||
if (fn.left(8) == "ioctl://")
|
||||
imageHistoryUpdatePos->setVisible(true);
|
||||
@@ -788,9 +786,9 @@ MediaMenu::clearImageHistory()
|
||||
void
|
||||
MediaMenu::cdromUpdateMenu(int i)
|
||||
{
|
||||
QString name = cdrom[i].image_path;
|
||||
QString name2;
|
||||
QIcon menu_icon;
|
||||
QString name = cdrom[i].image_path;
|
||||
QString name2;
|
||||
QIcon menu_icon;
|
||||
|
||||
if (!cdromMenus.contains(i))
|
||||
return;
|
||||
@@ -810,17 +808,17 @@ MediaMenu::cdromUpdateMenu(int i)
|
||||
#else
|
||||
menu_item_name = tr("Host CD/DVD Drive (%1)").arg(name.right(name.length() - 8));
|
||||
#endif
|
||||
name2 = menu_item_name;
|
||||
menu_icon = QIcon(":/settings/qt/icons/cdrom_host.ico");
|
||||
name2 = menu_item_name;
|
||||
menu_icon = QIcon(":/settings/qt/icons/cdrom_host.ico");
|
||||
} else {
|
||||
QFileInfo fi(cdrom[i].image_path);
|
||||
|
||||
menu_item_name = name.isEmpty() ? QString() : fi.fileName();
|
||||
name2 = name;
|
||||
if (name.isEmpty())
|
||||
menu_icon = QIcon(":/settings/qt/icons/cdrom.ico");
|
||||
menu_icon = QIcon(":/settings/qt/icons/cdrom.ico");
|
||||
else
|
||||
menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico");
|
||||
menu_icon = fi.isDir() ? QIcon(":/settings/qt/icons/cdrom_folder.ico") : QIcon(":/settings/qt/icons/cdrom_image.ico");
|
||||
}
|
||||
ejectMenu->setIcon(getIconWithIndicator(menu_icon, pixmap_size, QIcon::Normal, Eject));
|
||||
ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(menu_item_name));
|
||||
@@ -846,8 +844,8 @@ MediaMenu::cdromUpdateMenu(int i)
|
||||
break;
|
||||
}
|
||||
|
||||
menu->setTitle(tr("&CD-ROM %1 (%2): %3").arg(QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name2));
|
||||
menu->setToolTip(tr("CD-ROM %1 (%2): %3").arg(QString::number(i+1), busName, name.isEmpty() ? tr("(empty)") : name2));
|
||||
menu->setTitle(tr("&CD-ROM %1 (%2): %3").arg(QString::number(i + 1), busName, name.isEmpty() ? tr("(empty)") : name2));
|
||||
menu->setToolTip(tr("CD-ROM %1 (%2): %3").arg(QString::number(i + 1), busName, name.isEmpty() ? tr("(empty)") : name2));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -970,7 +968,7 @@ MediaMenu::moUpdateMenu(int i)
|
||||
auto *menu = moMenus[i];
|
||||
auto childs = menu->children();
|
||||
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[moEjectPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[moEjectPos]);
|
||||
ejectMenu->setEnabled(!name.isEmpty());
|
||||
ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(fi.fileName()));
|
||||
|
||||
@@ -1004,7 +1002,7 @@ MediaMenu::rdiskUpdateMenu(int i)
|
||||
auto *menu = rdiskMenus[i];
|
||||
auto childs = menu->children();
|
||||
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[rdiskEjectPos]);
|
||||
auto *ejectMenu = dynamic_cast<QAction *>(childs[rdiskEjectPos]);
|
||||
ejectMenu->setEnabled(!name.isEmpty());
|
||||
ejectMenu->setText(name.isEmpty() ? tr("E&ject") : tr("E&ject %1").arg(fi.fileName()));
|
||||
|
||||
|
||||
@@ -69,5 +69,4 @@ plat_midi_in_get_dev_name(int num, char *s)
|
||||
s[0] = ' ';
|
||||
s[1] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
class QString;
|
||||
class QAbstractItemModel;
|
||||
namespace Models {
|
||||
int AddEntry(QAbstractItemModel *model, const QString &displayRole, int userRole);
|
||||
int AddEntry(QAbstractItemModel *model, const QString &displayRole, int userRole);
|
||||
};
|
||||
|
||||
@@ -83,7 +83,7 @@ static const disk_size_t disk_sizes[14] = {
|
||||
{ 0, 8, 0, 0, 0, 963, 32, 2, 0, 0, 0, 0, 0 }, /* LS-120 */
|
||||
{ 0, 32, 0, 0, 0, 262, 56, 2, 0, 0, 0, 0, 0 } /* LS-240 */
|
||||
#endif
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const QStringList rpmModes = {
|
||||
@@ -198,7 +198,7 @@ NewFloppyDialog::onCreate()
|
||||
QFileInfo fi(filename);
|
||||
filename = (fi.isRelative() && !fi.filePath().isEmpty()) ? (usr_path + fi.filePath()) : fi.filePath();
|
||||
ui->fileField->setFileName(filename);
|
||||
FileType fileType;
|
||||
FileType fileType;
|
||||
|
||||
QProgressDialog progress("Creating floppy image", QString(), 0, 100, this);
|
||||
connect(this, &NewFloppyDialog::fileProgress, &progress, &QProgressDialog::setValue);
|
||||
@@ -646,8 +646,8 @@ NewFloppyDialog::createRDiskSectorImage(const QString &filename, const disk_size
|
||||
bool
|
||||
NewFloppyDialog::createMoSectorImage(const QString &filename, int8_t disk_size, FileType type, QProgressDialog &pbar)
|
||||
{
|
||||
const mo_type_t *dp = &mo_types[disk_size];
|
||||
uint64_t total_size = 0;
|
||||
const mo_type_t *dp = &mo_types[disk_size];
|
||||
uint64_t total_size = 0;
|
||||
uint64_t total_size2;
|
||||
uint32_t total_sectors = 0;
|
||||
uint32_t sector_bytes = 0;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "qt_renderercommon.hpp"
|
||||
#include "qt_mainwindow.hpp"
|
||||
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QMessageBox>
|
||||
@@ -58,7 +58,7 @@ extern "C" {
|
||||
#include <86box/config.h>
|
||||
#include <86box/qt-glslp-parser.h>
|
||||
|
||||
char gl3_shader_file[MAX_USER_SHADERS][512];
|
||||
char gl3_shader_file[MAX_USER_SHADERS][512];
|
||||
extern bool cpu_thread_running;
|
||||
}
|
||||
|
||||
@@ -73,76 +73,76 @@ extern int video_vsync;
|
||||
extern int video_focus_dim;
|
||||
extern int video_refresh_rate;
|
||||
|
||||
const char* vertex_shader_default_tex_src =
|
||||
const char *vertex_shader_default_tex_src =
|
||||
#ifdef __APPLE__
|
||||
"#version 150\n"
|
||||
"#version 150\n"
|
||||
#else
|
||||
"#version 130\n"
|
||||
"#version 130\n"
|
||||
#endif
|
||||
"\n"
|
||||
"in vec4 VertexCoord;\n"
|
||||
"in vec2 TexCoord;\n"
|
||||
"\n"
|
||||
"out vec2 texCoord;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = VertexCoord;\n"
|
||||
" texCoord = TexCoord;\n"
|
||||
"}\n";
|
||||
"\n"
|
||||
"in vec4 VertexCoord;\n"
|
||||
"in vec2 TexCoord;\n"
|
||||
"\n"
|
||||
"out vec2 texCoord;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = VertexCoord;\n"
|
||||
" texCoord = TexCoord;\n"
|
||||
"}\n";
|
||||
|
||||
const char* fragment_shader_default_tex_src =
|
||||
const char *fragment_shader_default_tex_src =
|
||||
#ifdef __APPLE__
|
||||
"#version 150\n"
|
||||
"#version 150\n"
|
||||
#else
|
||||
"#version 130\n"
|
||||
"#version 130\n"
|
||||
#endif
|
||||
"\n"
|
||||
"in vec2 texCoord;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"\n"
|
||||
"out vec4 color;"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" color = texture(Texture, texCoord);\n"
|
||||
" color.a = 1.0;\n"
|
||||
"}\n";
|
||||
"\n"
|
||||
"in vec2 texCoord;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"\n"
|
||||
"out vec4 color;"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" color = texture(Texture, texCoord);\n"
|
||||
" color.a = 1.0;\n"
|
||||
"}\n";
|
||||
|
||||
const char* vertex_shader_default_color_src =
|
||||
const char *vertex_shader_default_color_src =
|
||||
#ifdef __APPLE__
|
||||
"#version 150\n"
|
||||
"#version 150\n"
|
||||
#else
|
||||
"#version 130\n"
|
||||
"#version 130\n"
|
||||
#endif
|
||||
"\n"
|
||||
"in vec4 VertexCoord;\n"
|
||||
"in vec4 Color;\n"
|
||||
"\n"
|
||||
"out vec4 color;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = VertexCoord;\n"
|
||||
" color = Color;\n"
|
||||
"}\n";
|
||||
"\n"
|
||||
"in vec4 VertexCoord;\n"
|
||||
"in vec4 Color;\n"
|
||||
"\n"
|
||||
"out vec4 color;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = VertexCoord;\n"
|
||||
" color = Color;\n"
|
||||
"}\n";
|
||||
|
||||
const char* fragment_shader_default_color_src =
|
||||
const char *fragment_shader_default_color_src =
|
||||
#ifdef __APPLE__
|
||||
"#version 150\n"
|
||||
"#version 150\n"
|
||||
#else
|
||||
"#version 130\n"
|
||||
"#version 130\n"
|
||||
#endif
|
||||
"\n"
|
||||
"in vec4 color;\n"
|
||||
"\n"
|
||||
"out vec4 outColor;"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" outColor = color;\n"
|
||||
" outColor.a = 1.0;\n"
|
||||
"}\n";
|
||||
"\n"
|
||||
"in vec4 color;\n"
|
||||
"\n"
|
||||
"out vec4 outColor;"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" outColor = color;\n"
|
||||
" outColor.a = 1.0;\n"
|
||||
"}\n";
|
||||
|
||||
#ifdef ENABLE_OGL3_LOG
|
||||
int ogl3_do_log = ENABLE_OGL3_LOG;
|
||||
@@ -212,11 +212,11 @@ int
|
||||
OpenGLRenderer::compile_shader(GLenum shader_type, const char *prepend, const char *program, int *dst)
|
||||
{
|
||||
QRegularExpression versionRegex("^\\s*(#version\\s+\\w+)", QRegularExpression::MultilineOption);
|
||||
QString progSource = QString(program);
|
||||
QByteArray finalSource = nullptr;
|
||||
const char *source[5];
|
||||
char version[50];
|
||||
char *version_loc = (char *) strstr(program, "#version");
|
||||
QString progSource = QString(program);
|
||||
QByteArray finalSource = nullptr;
|
||||
const char *source[5];
|
||||
char version[50];
|
||||
char *version_loc = (char *) strstr(program, "#version");
|
||||
if (version_loc) {
|
||||
snprintf(version, 49, "%s\n", versionRegex.match(progSource).captured(1).toLatin1().data());
|
||||
progSource.remove(versionRegex);
|
||||
@@ -230,7 +230,7 @@ OpenGLRenderer::compile_shader(GLenum shader_type, const char *prepend, const ch
|
||||
ver = 150;
|
||||
snprintf(version, 49, "#version %d\n", ver);
|
||||
}
|
||||
|
||||
|
||||
/* Remove parameter lines. */
|
||||
progSource.remove(QRegularExpression("^\\s*#pragma parameter.*?\\n", QRegularExpression::MultilineOption));
|
||||
|
||||
@@ -309,27 +309,27 @@ OpenGLRenderer::find_uniforms(struct glsl_shader *glsl, int num_pass)
|
||||
u->orig.texture_size = get_uniform(p, "OrigTextureSize");
|
||||
|
||||
for (i = 0; i < glsl->num_passes; ++i) {
|
||||
snprintf(s, sizeof(s) -1, "Pass%dTexture", (i + 1));
|
||||
snprintf(s, sizeof(s) - 1, "Pass%dTexture", (i + 1));
|
||||
u->pass[i].texture = get_uniform(p, s);
|
||||
snprintf(s, sizeof(s) -1, "Pass%dInputSize", (i + 1));
|
||||
snprintf(s, sizeof(s) - 1, "Pass%dInputSize", (i + 1));
|
||||
u->pass[i].input_size = get_uniform(p, s);
|
||||
snprintf(s, sizeof(s) -1, "Pass%dTextureSize", (i + 1));
|
||||
snprintf(s, sizeof(s) - 1, "Pass%dTextureSize", (i + 1));
|
||||
u->pass[i].texture_size = get_uniform(p, s);
|
||||
|
||||
snprintf(s, sizeof(s) -1, "PassPrev%dTexture", num_pass - i);
|
||||
snprintf(s, sizeof(s) - 1, "PassPrev%dTexture", num_pass - i);
|
||||
u->prev_pass[i].texture = get_uniform(p, s);
|
||||
snprintf(s, sizeof(s) -1, "PassPrev%dInputSize", num_pass - i);
|
||||
snprintf(s, sizeof(s) - 1, "PassPrev%dInputSize", num_pass - i);
|
||||
u->prev_pass[i].input_size = get_uniform(p, s);
|
||||
snprintf(s, sizeof(s) -1, "PassPrev%dTextureSize", num_pass - i);
|
||||
snprintf(s, sizeof(s) - 1, "PassPrev%dTextureSize", num_pass - i);
|
||||
u->prev_pass[i].texture_size = get_uniform(p, s);
|
||||
}
|
||||
|
||||
u->prev[0].texture = get_uniform(p, "PrevTexture");
|
||||
u->prev[0].tex_coord = get_attrib(p, "PrevTexCoord");
|
||||
for (i = 1; i < MAX_PREV; ++i) {
|
||||
snprintf(s, sizeof(s) -1, "Prev%dTexture", i);
|
||||
snprintf(s, sizeof(s) - 1, "Prev%dTexture", i);
|
||||
u->prev[i].texture = get_uniform(p, s);
|
||||
snprintf(s, sizeof(s) -1, "Prev%dTexCoord", i);
|
||||
snprintf(s, sizeof(s) - 1, "Prev%dTexCoord", i);
|
||||
u->prev[i].tex_coord = get_attrib(p, s);
|
||||
}
|
||||
for (i = 0; i < MAX_PREV; ++i)
|
||||
@@ -653,7 +653,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f)
|
||||
ogl3_log("Load texture %s...\n", file);
|
||||
|
||||
if (!load_texture(file, &tex->texture)) {
|
||||
//QMessageBox::critical(main_window, tr("GLSL Error"), tr("Could not load texture: %s").arg(file));
|
||||
// QMessageBox::critical(main_window, tr("GLSL Error"), tr("Could not load texture: %s").arg(file));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load texture: %1").arg(file), false);
|
||||
ogl3_log("Could not load texture %s!\n", file);
|
||||
failed = 1;
|
||||
@@ -805,7 +805,7 @@ OpenGLRenderer::read_shader_config()
|
||||
for (int i = 0; i < active_shader->num_shaders; ++i) {
|
||||
struct glsl_shader *shader = &active_shader->shaders[i];
|
||||
char *name = shader->name;
|
||||
snprintf(s, sizeof(s) -1, "GL3 Shaders - %s", name);
|
||||
snprintf(s, sizeof(s) - 1, "GL3 Shaders - %s", name);
|
||||
// shader->shader_refresh_rate = config_get_float(CFG_MACHINE, s, "shader_refresh_rate", -1);
|
||||
for (int j = 0; j < shader->num_parameters; ++j) {
|
||||
struct shader_parameter *param = &shader->parameters[j];
|
||||
@@ -818,7 +818,7 @@ OpenGLRenderer::OpenGLRenderer(QWidget *parent)
|
||||
: QWindow((QWindow*)nullptr)
|
||||
, renderTimer(new QTimer(this))
|
||||
{
|
||||
connect(renderTimer, &QTimer::timeout, this, [this]() { this->render(); } );
|
||||
connect(renderTimer, &QTimer::timeout, this, [this]() { this->render(); });
|
||||
imagebufs[0] = std::unique_ptr<uint8_t>(new uint8_t[2048 * 2048 * 4]);
|
||||
imagebufs[1] = std::unique_ptr<uint8_t>(new uint8_t[2048 * 2048 * 4]);
|
||||
|
||||
@@ -846,8 +846,8 @@ OpenGLRenderer::OpenGLRenderer(QWidget *parent)
|
||||
|
||||
source.setRect(0, 0, 100, 100);
|
||||
isInitialized = false;
|
||||
isFinalized = false;
|
||||
context = nullptr;
|
||||
isFinalized = false;
|
||||
context = nullptr;
|
||||
}
|
||||
|
||||
OpenGLRenderer::~OpenGLRenderer() { finalize(); }
|
||||
@@ -897,9 +897,9 @@ OpenGLRenderer::initialize()
|
||||
|
||||
glw.glEnable(GL_TEXTURE_2D);
|
||||
|
||||
//renderTimer->start(75);
|
||||
// renderTimer->start(75);
|
||||
if (video_framerate != -1) {
|
||||
renderTimer->start(ceilf(1000.f / (float)video_framerate));
|
||||
renderTimer->start(ceilf(1000.f / (float) video_framerate));
|
||||
}
|
||||
|
||||
scene_texture.data = NULL;
|
||||
@@ -1105,7 +1105,7 @@ OpenGLRenderer::initialize()
|
||||
emit initialized();
|
||||
|
||||
glw.glClearColor(0, 0, 0, 1);
|
||||
|
||||
|
||||
glw.glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
context->swapBuffers(this);
|
||||
@@ -1227,7 +1227,7 @@ OpenGLRenderer::resizeEvent(QResizeEvent *event)
|
||||
destination.y(),
|
||||
destination.width(),
|
||||
destination.height());
|
||||
|
||||
|
||||
if (video_framerate == -1)
|
||||
render();
|
||||
}
|
||||
@@ -1387,7 +1387,7 @@ OpenGLRenderer::event(QEvent *event)
|
||||
return res;
|
||||
}
|
||||
|
||||
QDialog*
|
||||
QDialog *
|
||||
OpenGLRenderer::getOptions(QWidget *parent)
|
||||
{
|
||||
return new OpenGLShaderManagerDialog(parent);
|
||||
@@ -1426,7 +1426,7 @@ OpenGLRenderer::render()
|
||||
glw.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, video_filter_method ? GL_LINEAR : GL_NEAREST);
|
||||
glw.glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
GLfloat orig_output_size[] = { (GLfloat)window_rect.w, (GLfloat)window_rect.h };
|
||||
GLfloat orig_output_size[] = { (GLfloat) window_rect.w, (GLfloat) window_rect.h };
|
||||
|
||||
if (active_shader->srgb)
|
||||
glw.glEnable(GL_FRAMEBUFFER_SRGB);
|
||||
@@ -1507,8 +1507,8 @@ OpenGLRenderer::render()
|
||||
|
||||
/* loop through each pass */
|
||||
for (int i = 0; i < shader->num_passes; ++i) {
|
||||
bool resetFiltering = false;
|
||||
struct shader_pass *pass = &shader->passes[i];
|
||||
bool resetFiltering = false;
|
||||
struct shader_pass *pass = &shader->passes[i];
|
||||
|
||||
memcpy(pass->state.input_size, input->state.output_size, 2 * sizeof(GLfloat));
|
||||
memcpy(pass->state.input_texture_size, input->state.output_texture_size, 2 * sizeof(GLfloat));
|
||||
@@ -1696,27 +1696,27 @@ OpenGLRenderer::render()
|
||||
}
|
||||
|
||||
if (monitors[r_monitor_index].mon_screenshots) {
|
||||
int width = destination.width(), height = destination.height();
|
||||
int width = destination.width(), height = destination.height();
|
||||
char path[1024];
|
||||
char fn[256];
|
||||
|
||||
|
||||
memset(fn, 0, sizeof(fn));
|
||||
memset(path, 0, sizeof(path));
|
||||
|
||||
|
||||
path_append_filename(path, usr_path, SCREENSHOT_PATH);
|
||||
|
||||
|
||||
if (!plat_dir_check(path))
|
||||
plat_dir_create(path);
|
||||
|
||||
|
||||
path_slash(path);
|
||||
strcat(path, "Monitor_");
|
||||
snprintf(&path[strlen(path)], 42, "%d_", r_monitor_index + 1);
|
||||
|
||||
plat_tempfile(fn, NULL, (char*)".png");
|
||||
|
||||
plat_tempfile(fn, NULL, (char *) ".png");
|
||||
strcat(path, fn);
|
||||
|
||||
unsigned char *rgb = (unsigned char *) calloc(1, (size_t) width * height * 4);
|
||||
|
||||
|
||||
glw.glFinish();
|
||||
glw.glReadPixels(window_rect.x, window_rect.y, width, height, GL_RGB, GL_UNSIGNED_BYTE, rgb);
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@
|
||||
|
||||
#include "qt_renderercommon.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/qt-glslp-parser.h>
|
||||
}
|
||||
|
||||
@@ -83,10 +82,9 @@ protected:
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
private:
|
||||
|
||||
std::array<std::unique_ptr<uint8_t>, 2> imagebufs;
|
||||
|
||||
QTimer *renderTimer;
|
||||
QTimer *renderTimer;
|
||||
|
||||
QString glslVersion = "";
|
||||
|
||||
@@ -98,7 +96,7 @@ private:
|
||||
|
||||
QOpenGLExtraFunctions glw;
|
||||
struct shader_texture scene_texture;
|
||||
glsl_t *active_shader;
|
||||
glsl_t *active_shader;
|
||||
|
||||
void *unpackBuffer = nullptr;
|
||||
|
||||
@@ -108,20 +106,20 @@ private:
|
||||
void initializeExtensions();
|
||||
void initializeBuffers();
|
||||
void applyOptions();
|
||||
|
||||
|
||||
void create_scene_shader();
|
||||
void create_texture(struct shader_texture *tex);
|
||||
void create_fbo(struct shader_fbo *fbo);
|
||||
void recreate_fbo(struct shader_fbo *fbo, int width, int height);
|
||||
void setup_fbo(struct shader *shader, struct shader_fbo *fbo);
|
||||
|
||||
bool notReady() const { return !isInitialized || isFinalized; }
|
||||
glsl_t* load_glslp(glsl_t *glsl, int num_shader, const char *f);
|
||||
glsl_t* load_shaders(int num, char shaders[MAX_USER_SHADERS][512]);
|
||||
int compile_shader(GLenum shader_type, const char *prepend, const char *program, int *dst);
|
||||
int create_default_shader_tex(struct shader_pass *pass);
|
||||
int create_default_shader_color(struct shader_pass *pass);
|
||||
int create_program(struct shader_program *program);
|
||||
bool notReady() const { return !isInitialized || isFinalized; }
|
||||
glsl_t *load_glslp(glsl_t *glsl, int num_shader, const char *f);
|
||||
glsl_t *load_shaders(int num, char shaders[MAX_USER_SHADERS][512]);
|
||||
int compile_shader(GLenum shader_type, const char *prepend, const char *program, int *dst);
|
||||
int create_default_shader_tex(struct shader_pass *pass);
|
||||
int create_default_shader_color(struct shader_pass *pass);
|
||||
int create_program(struct shader_program *program);
|
||||
|
||||
GLuint get_uniform(GLuint program, const char *name);
|
||||
GLuint get_attrib(GLuint program, const char *name);
|
||||
|
||||
@@ -3,16 +3,15 @@
|
||||
|
||||
#include "qt_mainwindow.hpp"
|
||||
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/config.h>
|
||||
}
|
||||
|
||||
OpenGLShaderConfig::OpenGLShaderConfig(QWidget *parent, glslp_t* shader)
|
||||
OpenGLShaderConfig::OpenGLShaderConfig(QWidget *parent, glslp_t *shader)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::OpenGLShaderConfig)
|
||||
{
|
||||
@@ -32,7 +31,7 @@ OpenGLShaderConfig::OpenGLShaderConfig(QWidget *parent, glslp_t* shader)
|
||||
spinBox->setRange(currentShader->parameters[i].min, currentShader->parameters[i].max);
|
||||
spinBox->setValue(currentShader->parameters[i].value);
|
||||
spinBox->setSingleStep(currentShader->parameters[i].step);
|
||||
QFormLayout* layout = (QFormLayout*)ui->scrollAreaWidgetContents->layout();
|
||||
QFormLayout *layout = (QFormLayout *) ui->scrollAreaWidgetContents->layout();
|
||||
layout->addRow(currentShader->parameters[i].description, spinBox);
|
||||
}
|
||||
}
|
||||
@@ -42,11 +41,12 @@ OpenGLShaderConfig::~OpenGLShaderConfig()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button)
|
||||
void
|
||||
OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::ResetRole) {
|
||||
for (int i = 0; i < currentShader->num_parameters; i++) {
|
||||
QDoubleSpinBox* box = this->findChild<QDoubleSpinBox*>(QString(currentShader->parameters[i].id));
|
||||
QDoubleSpinBox *box = this->findChild<QDoubleSpinBox *>(QString(currentShader->parameters[i].id));
|
||||
if (box) {
|
||||
box->setValue(currentShader->parameters[i].default_value);
|
||||
}
|
||||
@@ -54,9 +54,9 @@ void OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button)
|
||||
} else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole) {
|
||||
startblit();
|
||||
for (int i = 0; i < currentShader->num_parameters; i++) {
|
||||
QDoubleSpinBox* box = this->findChild<QDoubleSpinBox*>(QString(currentShader->parameters[i].id));
|
||||
QDoubleSpinBox *box = this->findChild<QDoubleSpinBox *>(QString(currentShader->parameters[i].id));
|
||||
if (box) {
|
||||
float val = (float)box->value();
|
||||
float val = (float) box->value();
|
||||
currentShader->parameters[i].value = val;
|
||||
}
|
||||
}
|
||||
@@ -67,14 +67,14 @@ void OpenGLShaderConfig::on_buttonBox_clicked(QAbstractButton *button)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderConfig::on_OpenGLShaderConfig_accepted()
|
||||
void
|
||||
OpenGLShaderConfig::on_OpenGLShaderConfig_accepted()
|
||||
{
|
||||
startblit();
|
||||
for (int i = 0; i < currentShader->num_parameters; i++) {
|
||||
QDoubleSpinBox* box = (QDoubleSpinBox*)this->findChild<QDoubleSpinBox*>(QString(currentShader->parameters[i].id));
|
||||
QDoubleSpinBox *box = (QDoubleSpinBox *) this->findChild<QDoubleSpinBox *>(QString(currentShader->parameters[i].id));
|
||||
if (box) {
|
||||
float val = (float)box->value();
|
||||
float val = (float) box->value();
|
||||
currentShader->parameters[i].value = val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#include <86box/qt-glslp-parser.h>
|
||||
}
|
||||
|
||||
@@ -22,7 +21,7 @@ class OpenGLShaderConfig : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenGLShaderConfig(QWidget *parent = nullptr, glslp_t* shader = nullptr);
|
||||
explicit OpenGLShaderConfig(QWidget *parent = nullptr, glslp_t *shader = nullptr);
|
||||
~OpenGLShaderConfig();
|
||||
|
||||
private slots:
|
||||
@@ -32,7 +31,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::OpenGLShaderConfig *ui;
|
||||
glslp_t* currentShader;
|
||||
glslp_t *currentShader;
|
||||
|
||||
std::map<std::string, double> defaultValues;
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "qt_mainwindow.hpp"
|
||||
#include "qt_util.hpp"
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
#include "qt_openglshaderconfig.hpp"
|
||||
|
||||
@@ -41,14 +41,14 @@ OpenGLShaderManagerDialog::OpenGLShaderManagerDialog(QWidget *parent)
|
||||
|
||||
for (int i = 0; i < MAX_USER_SHADERS; i++) {
|
||||
if (gl3_shader_file[i][0] != 0) {
|
||||
char* filename = path_get_filename(gl3_shader_file[i]);
|
||||
char *filename = path_get_filename(gl3_shader_file[i]);
|
||||
if (filename[0] != 0) {
|
||||
glslp_t* shaderfile = glslp_parse(gl3_shader_file[i]);
|
||||
glslp_t *shaderfile = glslp_parse(gl3_shader_file[i]);
|
||||
if (shaderfile) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->shaderListWidget);
|
||||
QListWidgetItem *item = new QListWidgetItem(ui->shaderListWidget);
|
||||
item->setText(filename);
|
||||
item->setData(Qt::UserRole + 1, QString(gl3_shader_file[i]));
|
||||
item->setData(Qt::UserRole + 2, (qulonglong)(uintptr_t)shaderfile);
|
||||
item->setData(Qt::UserRole + 2, (qulonglong) (uintptr_t) shaderfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ OpenGLShaderManagerDialog::OpenGLShaderManagerDialog(QWidget *parent)
|
||||
ui->shaderListWidget->setCurrentRow(ui->shaderListWidget->count() - 1);
|
||||
auto current = ui->shaderListWidget->currentItem();
|
||||
if (current) {
|
||||
glslp_t* shader = (glslp_t*)current->data(Qt::UserRole + 2).toULongLong();
|
||||
glslp_t *shader = (glslp_t *) current->data(Qt::UserRole + 2).toULongLong();
|
||||
if (shader->num_parameters > 0)
|
||||
ui->buttonConfigure->setEnabled(true);
|
||||
else
|
||||
@@ -78,13 +78,14 @@ OpenGLShaderManagerDialog::~OpenGLShaderManagerDialog()
|
||||
{
|
||||
for (int i = 0; i < ui->shaderListWidget->count(); i++) {
|
||||
if (ui->shaderListWidget->item(i) && ui->shaderListWidget->item(i)->data(Qt::UserRole + 2).toULongLong()) {
|
||||
glslp_free((glslp_t*)ui->shaderListWidget->item(i)->data(Qt::UserRole + 2).toULongLong());
|
||||
glslp_free((glslp_t *) ui->shaderListWidget->item(i)->data(Qt::UserRole + 2).toULongLong());
|
||||
}
|
||||
}
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
|
||||
accept();
|
||||
@@ -96,20 +97,20 @@ void OpenGLShaderManagerDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_buttonMoveUp_clicked()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_buttonMoveUp_clicked()
|
||||
{
|
||||
if (ui->shaderListWidget->currentRow() == 0)
|
||||
return;
|
||||
|
||||
int row = ui->shaderListWidget->currentRow();
|
||||
int row = ui->shaderListWidget->currentRow();
|
||||
auto item = ui->shaderListWidget->takeItem(row);
|
||||
ui->shaderListWidget->insertItem(row - 1, item);
|
||||
ui->shaderListWidget->setCurrentItem(item);
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
{
|
||||
if (current == nullptr) {
|
||||
ui->buttonRemove->setDisabled(true);
|
||||
@@ -121,7 +122,7 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidg
|
||||
ui->buttonRemove->setDisabled(false);
|
||||
ui->buttonConfigure->setDisabled(true);
|
||||
if (current) {
|
||||
glslp_t* shader = (glslp_t*)current->data(Qt::UserRole + 2).toULongLong();
|
||||
glslp_t *shader = (glslp_t *) current->data(Qt::UserRole + 2).toULongLong();
|
||||
if (shader->num_parameters > 0)
|
||||
ui->buttonConfigure->setEnabled(true);
|
||||
}
|
||||
@@ -130,8 +131,8 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentItemChanged(QListWidg
|
||||
ui->buttonMoveDown->setDisabled(ui->shaderListWidget->currentRow() == (ui->shaderListWidget->count() - 1));
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int currentRow)
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int currentRow)
|
||||
{
|
||||
auto current = ui->shaderListWidget->currentItem();
|
||||
if (current == nullptr) {
|
||||
@@ -144,7 +145,7 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int curren
|
||||
ui->buttonRemove->setDisabled(false);
|
||||
ui->buttonConfigure->setDisabled(true);
|
||||
if (current) {
|
||||
glslp_t* shader = (glslp_t*)current->data(Qt::UserRole + 2).toULongLong();
|
||||
glslp_t *shader = (glslp_t *) current->data(Qt::UserRole + 2).toULongLong();
|
||||
if (shader->num_parameters > 0)
|
||||
ui->buttonConfigure->setEnabled(true);
|
||||
}
|
||||
@@ -153,32 +154,32 @@ void OpenGLShaderManagerDialog::on_shaderListWidget_currentRowChanged(int curren
|
||||
ui->buttonMoveDown->setDisabled(ui->shaderListWidget->currentRow() == (ui->shaderListWidget->count() - 1));
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_buttonMoveDown_clicked()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_buttonMoveDown_clicked()
|
||||
{
|
||||
if (ui->shaderListWidget->currentRow() == (ui->shaderListWidget->count() - 1))
|
||||
return;
|
||||
|
||||
int row = ui->shaderListWidget->currentRow();
|
||||
int row = ui->shaderListWidget->currentRow();
|
||||
auto item = ui->shaderListWidget->takeItem(row);
|
||||
ui->shaderListWidget->insertItem(row + 1, item);
|
||||
ui->shaderListWidget->setCurrentItem(item);
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_buttonAdd_clicked()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_buttonAdd_clicked()
|
||||
{
|
||||
auto res = QFileDialog::getOpenFileName(this, QString(), QString(),
|
||||
tr("GLSL shaders") % util::DlgFilter({ "glslp", "glsl" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
if (!res.isEmpty()) {
|
||||
auto glslp_file = res.toUtf8();
|
||||
glslp_t* shaderfile = glslp_parse(glslp_file.data());
|
||||
auto glslp_file = res.toUtf8();
|
||||
glslp_t *shaderfile = glslp_parse(glslp_file.data());
|
||||
if (shaderfile) {
|
||||
auto filename = path_get_filename(glslp_file.data());
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->shaderListWidget);
|
||||
auto filename = path_get_filename(glslp_file.data());
|
||||
QListWidgetItem *item = new QListWidgetItem(ui->shaderListWidget);
|
||||
item->setText(filename);
|
||||
item->setData(Qt::UserRole + 1, res);
|
||||
item->setData(Qt::UserRole + 2, (qulonglong)(uintptr_t)shaderfile);
|
||||
item->setData(Qt::UserRole + 2, (qulonglong) (uintptr_t) shaderfile);
|
||||
if (ui->shaderListWidget->count()) {
|
||||
ui->shaderListWidget->setCurrentRow(ui->shaderListWidget->count() - 1);
|
||||
ui->buttonAdd->setDisabled(ui->shaderListWidget->count() >= MAX_USER_SHADERS);
|
||||
@@ -189,14 +190,14 @@ void OpenGLShaderManagerDialog::on_buttonAdd_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_buttonRemove_clicked()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_buttonRemove_clicked()
|
||||
{
|
||||
if (ui->shaderListWidget->currentItem()) {
|
||||
auto item = ui->shaderListWidget->takeItem(ui->shaderListWidget->currentRow());
|
||||
|
||||
if (item->data(Qt::UserRole + 2).toULongLong()) {
|
||||
glslp_free((glslp_t*)item->data(Qt::UserRole + 2).toULongLong());
|
||||
glslp_free((glslp_t *) item->data(Qt::UserRole + 2).toULongLong());
|
||||
}
|
||||
delete item;
|
||||
|
||||
@@ -205,7 +206,8 @@ void OpenGLShaderManagerDialog::on_buttonRemove_clicked()
|
||||
ui->buttonAdd->setDisabled(ui->shaderListWidget->count() >= MAX_USER_SHADERS);
|
||||
}
|
||||
|
||||
void OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted()
|
||||
{
|
||||
memset(gl3_shader_file, 0, sizeof(gl3_shader_file));
|
||||
for (int i = 0; i < ui->shaderListWidget->count(); i++) {
|
||||
@@ -222,43 +224,43 @@ void OpenGLShaderManagerDialog::on_OpenGLShaderManagerDialog_accepted()
|
||||
endblit();
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_buttonConfigure_clicked()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_buttonConfigure_clicked()
|
||||
{
|
||||
auto item = ui->shaderListWidget->currentItem();
|
||||
if (item) {
|
||||
glslp_t* shader = (glslp_t*)item->data(Qt::UserRole + 2).toULongLong();
|
||||
glslp_t *shader = (glslp_t *) item->data(Qt::UserRole + 2).toULongLong();
|
||||
|
||||
auto configDialog = new OpenGLShaderConfig(this, shader);
|
||||
configDialog->exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_radioButtonVideoSync_clicked()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_radioButtonVideoSync_clicked()
|
||||
{
|
||||
ui->targetFrameRate->setDisabled(true);
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_radioButtonTargetFramerate_clicked()
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_radioButtonTargetFramerate_clicked()
|
||||
{
|
||||
ui->targetFrameRate->setDisabled(false);
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_horizontalSliderFramerate_sliderMoved(int position)
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_horizontalSliderFramerate_sliderMoved(int position)
|
||||
{
|
||||
(void)position;
|
||||
(void) position;
|
||||
|
||||
if (ui->horizontalSliderFramerate->value() != ui->targetFrameRate->value())
|
||||
ui->targetFrameRate->setValue(ui->horizontalSliderFramerate->value());
|
||||
}
|
||||
|
||||
|
||||
void OpenGLShaderManagerDialog::on_targetFrameRate_valueChanged(int arg1)
|
||||
void
|
||||
OpenGLShaderManagerDialog::on_targetFrameRate_valueChanged(int arg1)
|
||||
{
|
||||
(void)arg1;
|
||||
(void) arg1;
|
||||
|
||||
if (ui->horizontalSliderFramerate->value() != ui->targetFrameRate->value())
|
||||
ui->horizontalSliderFramerate->setValue(ui->targetFrameRate->value());
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* Copyright 2021-2022 Teemu Korhonen
|
||||
*/
|
||||
#ifdef __HAIKU__
|
||||
#include <OS.h>
|
||||
# include <OS.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
@@ -125,7 +125,7 @@ extern "C" {
|
||||
#include <86box/config.h>
|
||||
#include <86box/ui.h>
|
||||
#ifdef DISCORD
|
||||
# include <86box/discord.h>
|
||||
# include <86box/discord.h>
|
||||
#endif
|
||||
|
||||
#include "../cpu/cpu.h"
|
||||
@@ -186,9 +186,9 @@ plat_get_exe_name(char *s, int size)
|
||||
if (acp_utf8)
|
||||
GetModuleFileNameA(NULL, s, size);
|
||||
else {
|
||||
temp = (wchar_t*)calloc(size, sizeof(wchar_t));
|
||||
temp = (wchar_t *) calloc(size, sizeof(wchar_t));
|
||||
GetModuleFileNameW(NULL, temp, size);
|
||||
c16stombs(s, (uint16_t*)temp, size);
|
||||
c16stombs(s, (uint16_t *) temp, size);
|
||||
free(temp);
|
||||
}
|
||||
#else
|
||||
@@ -254,7 +254,7 @@ plat_file_check(const char *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
auto data = QString::fromUtf8(path).toStdWString();
|
||||
auto res = GetFileAttributesW(data.c_str());
|
||||
auto res = GetFileAttributesW(data.c_str());
|
||||
return (res != INVALID_FILE_ATTRIBUTES) && !(res & FILE_ATTRIBUTE_DIRECTORY);
|
||||
#else
|
||||
struct stat stats;
|
||||
@@ -269,12 +269,12 @@ plat_getcwd(char *bufp, int max)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
/* Working directory for .app bundles is undefined. */
|
||||
#ifdef USE_EXE_PATH
|
||||
# ifdef USE_EXE_PATH
|
||||
strncpy(bufp, exe_path, max);
|
||||
#else
|
||||
# else
|
||||
CharPointer(bufp, max) = QDir::homePath().toUtf8();
|
||||
path_append_filename(bufp, bufp, "Library/86Box");
|
||||
#endif
|
||||
# endif
|
||||
#else
|
||||
CharPointer(bufp, max) = QDir::currentPath().toUtf8();
|
||||
#endif
|
||||
@@ -320,7 +320,7 @@ path_get_filename(char *s)
|
||||
|
||||
return s;
|
||||
#else
|
||||
auto idx = QByteArray::fromRawData(s, strlen(s)).lastIndexOf(QDir::separator().toLatin1());
|
||||
auto idx = QByteArray::fromRawData(s, strlen(s)).lastIndexOf(QDir::separator().toLatin1());
|
||||
if (idx >= 0) {
|
||||
return s + idx + 1;
|
||||
}
|
||||
@@ -390,7 +390,7 @@ path_append_filename(char *dest, const char *s1, const char *s2)
|
||||
if (len > 0 && dest[len - 1] != '/' && dest[len - 1] != '\\') {
|
||||
if (len + 1 < dest_size) {
|
||||
dest[len++] = '/';
|
||||
dest[len] = '\0';
|
||||
dest[len] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,58 +453,58 @@ extern bool cpu_thread_running;
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
/* SetThreadDescription was added in 14393 and SetProcessInformation in 8. Revisit if we ever start requiring 10. */
|
||||
static void *kernel32_handle = NULL;
|
||||
static HRESULT(WINAPI *pSetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription) = NULL;
|
||||
static void *kernel32_handle = NULL;
|
||||
static HRESULT(WINAPI *pSetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription) = NULL;
|
||||
static HRESULT(WINAPI *pSetProcessInformation)(HANDLE hProcess, PROCESS_INFORMATION_CLASS ProcessInformationClass, LPVOID ProcessInformation, DWORD ProcessInformationSize) = NULL;
|
||||
static dllimp_t kernel32_imports[] = {
|
||||
// clang-format off
|
||||
static dllimp_t kernel32_imports[] = {
|
||||
// clang-format off
|
||||
{ "SetThreadDescription", &pSetThreadDescription },
|
||||
{ "SetProcessInformation", &pSetProcessInformation },
|
||||
{ NULL, NULL }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static void
|
||||
enter_pause(void)
|
||||
{
|
||||
PROCESS_POWER_THROTTLING_STATE state{};
|
||||
state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
|
||||
PROCESS_POWER_THROTTLING_STATE state {};
|
||||
state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
|
||||
state.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
|
||||
state.StateMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
|
||||
state.StateMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
|
||||
|
||||
if (!kernel32_handle) {
|
||||
kernel32_handle = dynld_module("kernel32.dll", kernel32_imports);
|
||||
if (!kernel32_handle) {
|
||||
kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */
|
||||
pSetThreadDescription = NULL;
|
||||
kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */
|
||||
pSetThreadDescription = NULL;
|
||||
pSetProcessInformation = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (pSetProcessInformation) {
|
||||
pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID)&state, sizeof(state));
|
||||
pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID) &state, sizeof(state));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
exit_pause(void)
|
||||
{
|
||||
PROCESS_POWER_THROTTLING_STATE state{};
|
||||
state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
|
||||
PROCESS_POWER_THROTTLING_STATE state {};
|
||||
state.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;
|
||||
state.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
|
||||
state.StateMask = 0;
|
||||
state.StateMask = 0;
|
||||
|
||||
if (!kernel32_handle) {
|
||||
kernel32_handle = dynld_module("kernel32.dll", kernel32_imports);
|
||||
if (!kernel32_handle) {
|
||||
kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */
|
||||
pSetThreadDescription = NULL;
|
||||
kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */
|
||||
pSetThreadDescription = NULL;
|
||||
pSetProcessInformation = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (pSetProcessInformation) {
|
||||
pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID)&state, sizeof(state));
|
||||
pSetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, (LPVOID) &state, sizeof(state));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -695,13 +695,13 @@ c16stombs(char dst[], const uint16_t src[], int len)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define LIB_NAME_GS "gsdll64.dll"
|
||||
# define LIB_NAME_GPCL "gpcl6dll64.dll"
|
||||
# define LIB_NAME_PCAP "Npcap"
|
||||
# define LIB_NAME_GS "gsdll64.dll"
|
||||
# define LIB_NAME_GPCL "gpcl6dll64.dll"
|
||||
# define LIB_NAME_PCAP "Npcap"
|
||||
#else
|
||||
# define LIB_NAME_GS "libgs"
|
||||
# define LIB_NAME_GPCL "libgpcl6"
|
||||
# define LIB_NAME_PCAP "libpcap"
|
||||
# define LIB_NAME_GS "libgs"
|
||||
# define LIB_NAME_GPCL "libgpcl6"
|
||||
# define LIB_NAME_PCAP "libpcap"
|
||||
#endif
|
||||
|
||||
QMap<int, std::wstring> ProgSettings::translatedstrings;
|
||||
@@ -837,15 +837,16 @@ plat_init_rom_paths(void)
|
||||
}
|
||||
|
||||
void
|
||||
plat_get_cpu_string(char *outbuf, uint8_t len) {
|
||||
plat_get_cpu_string(char *outbuf, uint8_t len)
|
||||
{
|
||||
auto cpu_string = QString("Unknown");
|
||||
/* Write the default string now in case we have to exit early from an error */
|
||||
qstrncpy(outbuf, cpu_string.toUtf8().constData(), len);
|
||||
|
||||
#if defined(Q_OS_MACOS)
|
||||
auto *process = new QProcess(nullptr);
|
||||
auto *process = new QProcess(nullptr);
|
||||
QStringList arguments;
|
||||
QString program = "/usr/sbin/sysctl";
|
||||
QString program = "/usr/sbin/sysctl";
|
||||
arguments << "machdep.cpu.brand_string";
|
||||
process->start(program, arguments);
|
||||
if (!process->waitForStarted()) {
|
||||
@@ -854,9 +855,9 @@ plat_get_cpu_string(char *outbuf, uint8_t len) {
|
||||
if (!process->waitForFinished()) {
|
||||
return;
|
||||
}
|
||||
QByteArray result = process->readAll();
|
||||
auto command_result = QString(result).split(": ").last().trimmed();
|
||||
if(!command_result.isEmpty()) {
|
||||
QByteArray result = process->readAll();
|
||||
auto command_result = QString(result).split(": ").last().trimmed();
|
||||
if (!command_result.isEmpty()) {
|
||||
cpu_string = command_result;
|
||||
}
|
||||
#elif defined(Q_OS_WINDOWS)
|
||||
@@ -868,38 +869,36 @@ plat_get_cpu_string(char *outbuf, uint8_t len) {
|
||||
bufSize = 32768;
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName, 0, 1, &hKey) == ERROR_SUCCESS) {
|
||||
if (RegQueryValueExA(hKey, valueName, NULL, NULL, buf, &bufSize) == ERROR_SUCCESS) {
|
||||
cpu_string = reinterpret_cast<const char*>(buf);
|
||||
cpu_string = reinterpret_cast<const char *>(buf);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
auto cpuinfo = QString("/proc/cpuinfo");
|
||||
auto cpuinfo = QString("/proc/cpuinfo");
|
||||
auto cpuinfo_fi = QFileInfo(cpuinfo);
|
||||
if(!cpuinfo_fi.isReadable()) {
|
||||
if (!cpuinfo_fi.isReadable()) {
|
||||
return;
|
||||
}
|
||||
QFile file(cpuinfo);
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream textStream(&file);
|
||||
while(true) {
|
||||
while (true) {
|
||||
QString line = textStream.readLine();
|
||||
if (line.isNull()) {
|
||||
break;
|
||||
}
|
||||
if(QRegularExpression("model name.*:").match(line).hasMatch()) {
|
||||
if (QRegularExpression("model name.*:").match(line).hasMatch()) {
|
||||
auto list = line.split(": ");
|
||||
if(!list.last().isEmpty()) {
|
||||
if (!list.last().isEmpty()) {
|
||||
cpu_string = list.last();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
qstrncpy(outbuf, cpu_string.toUtf8().constData(), len);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -909,14 +908,14 @@ plat_set_thread_name(void *thread, const char *name)
|
||||
if (!kernel32_handle) {
|
||||
kernel32_handle = dynld_module("kernel32.dll", kernel32_imports);
|
||||
if (!kernel32_handle) {
|
||||
kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */
|
||||
pSetThreadDescription = NULL;
|
||||
kernel32_handle = kernel32_imports; /* store dummy pointer to avoid trying again */
|
||||
pSetThreadDescription = NULL;
|
||||
pSetProcessInformation = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (pSetThreadDescription) {
|
||||
size_t len = strlen(name) + 1;
|
||||
size_t len = strlen(name) + 1;
|
||||
wchar_t wname[2048];
|
||||
mbstowcs(wname, name, (len >= 1024) ? 1024 : len);
|
||||
pSetThreadDescription(thread ? (HANDLE) thread : GetCurrentThread(), wname);
|
||||
@@ -935,7 +934,7 @@ plat_set_thread_name(void *thread, const char *name)
|
||||
# if defined(Q_OS_DARWIN)
|
||||
pthread_setname_np(truncated);
|
||||
# elif defined(Q_OS_NETBSD)
|
||||
pthread_setname_np(thread ? *((pthread_t *) thread) : pthread_self(), truncated, (void*)"%s");
|
||||
pthread_setname_np(thread ? *((pthread_t *) thread) : pthread_self(), truncated, (void *) "%s");
|
||||
# elif defined(__HAIKU__)
|
||||
rename_thread(find_thread(NULL), truncated);
|
||||
# elif defined(Q_OS_OPENBSD)
|
||||
|
||||
@@ -40,7 +40,7 @@ extern "C" {
|
||||
#include <86box/video.h>
|
||||
}
|
||||
|
||||
extern MainWindow *main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
ProgSettings::CustomTranslator *ProgSettings::translator = nullptr;
|
||||
QTranslator *ProgSettings::qtTranslator = nullptr;
|
||||
|
||||
@@ -17,10 +17,10 @@ public:
|
||||
#ifdef Q_OS_WINDOWS
|
||||
static QString getFontName(int langId);
|
||||
#endif
|
||||
static int languageCodeToId(QString langCode);
|
||||
static QString languageIdToCode(int id);
|
||||
static void loadTranslators(QObject *parent = nullptr);
|
||||
static void reloadStrings();
|
||||
static int languageCodeToId(QString langCode);
|
||||
static QString languageIdToCode(int id);
|
||||
static void loadTranslators(QObject *parent = nullptr);
|
||||
static void reloadStrings();
|
||||
class CustomTranslator : public QTranslator {
|
||||
public:
|
||||
CustomTranslator(QObject *parent = nullptr)
|
||||
@@ -33,10 +33,10 @@ public:
|
||||
return QTranslator::translate("", sourceText, disambiguation, n);
|
||||
}
|
||||
};
|
||||
static CustomTranslator *translator;
|
||||
static QTranslator *qtTranslator;
|
||||
static QVector<QPair<QString, QString>> languages;
|
||||
static QMap<int, std::wstring> translatedstrings;
|
||||
static CustomTranslator *translator;
|
||||
static QTranslator *qtTranslator;
|
||||
static QVector<QPair<QString, QString>> languages;
|
||||
static QMap<int, std::wstring> translatedstrings;
|
||||
|
||||
protected slots:
|
||||
void accept() override;
|
||||
@@ -49,7 +49,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::ProgSettings *ui;
|
||||
static bool loadQtTranslations(const QString name);
|
||||
static bool loadQtTranslations(const QString name);
|
||||
|
||||
friend class MainWindow;
|
||||
double mouseSensitivity;
|
||||
|
||||
@@ -117,13 +117,13 @@ void
|
||||
RendererCommon::onResize(int width, int height)
|
||||
{
|
||||
/* This is needed so that the if below does not take like, 5 lines. */
|
||||
bool is_fs = (video_fullscreen == 0);
|
||||
bool parent_max = (parentWidget->isMaximized() == false);
|
||||
bool is_fs = (video_fullscreen == 0);
|
||||
bool parent_max = (parentWidget->isMaximized() == false);
|
||||
bool main_is_ancestor = main_window->isAncestorOf(parentWidget);
|
||||
bool main_max = main_window->isMaximized();
|
||||
bool main_is_max = (main_is_ancestor && main_max == false);
|
||||
bool main_max = main_window->isMaximized();
|
||||
bool main_is_max = (main_is_ancestor && main_max == false);
|
||||
|
||||
width = round(pixelRatio * width);
|
||||
width = round(pixelRatio * width);
|
||||
height = round(pixelRatio * height);
|
||||
|
||||
if (is_fs && (video_fullscreen_scale_maximized ? (parent_max && main_is_max) : 1) && !(force_43 && vid_resize))
|
||||
@@ -142,7 +142,7 @@ RendererCommon::onResize(int width, int height)
|
||||
double gh = source.height();
|
||||
double hsr = hw / hh;
|
||||
double r43 = 4.0 / 3.0;
|
||||
|
||||
|
||||
if (force_43 && is_fs && vid_resize) {
|
||||
if (!video_fullscreen_scale_maximized || (video_fullscreen_scale_maximized && parent_max && main_is_max))
|
||||
temp_fullscreen_scale = FULLSCR_SCALE_43;
|
||||
@@ -155,7 +155,7 @@ RendererCommon::onResize(int width, int height)
|
||||
|
||||
if (temp_fullscreen_scale == FULLSCR_SCALE_INT43) {
|
||||
gh = gw / r43;
|
||||
// gw = gw;
|
||||
// gw = gw;
|
||||
|
||||
gsr = r43;
|
||||
}
|
||||
@@ -203,8 +203,8 @@ RendererCommon::onResize(int width, int height)
|
||||
monitors[r_monitor_index].mon_res_x = (double) destination.width();
|
||||
monitors[r_monitor_index].mon_res_y = (double) destination.height();
|
||||
|
||||
destinationF.setRect((double)destination.x() / (double)width, (double)destination.y() / (double)height,
|
||||
(double)destination.width() / (double)width, (double)destination.height() / (double)height);
|
||||
destinationF.setRect((double) destination.x() / (double) width, (double) destination.y() / (double) height,
|
||||
(double) destination.width() / (double) width, (double) destination.height() / (double) height);
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -40,12 +40,12 @@ public:
|
||||
/* Should the renderer take screenshots itself? */
|
||||
virtual bool rendererTakeScreenshot() { return false; }
|
||||
|
||||
int r_monitor_index = 0;
|
||||
QRectF destinationF = QRectF(0, 0, 1, 1); /* normalized to 0.0-1.0 range. */
|
||||
int r_monitor_index = 0;
|
||||
QRectF destinationF = QRectF(0, 0, 1, 1); /* normalized to 0.0-1.0 range. */
|
||||
|
||||
protected:
|
||||
bool eventDelegate(QEvent *event, bool &result);
|
||||
void drawStatusBarIcons(QPainter* painter);
|
||||
bool eventDelegate(QEvent *event, bool &result);
|
||||
void drawStatusBarIcons(QPainter *painter);
|
||||
|
||||
QRect source { 0, 0, 0, 0 };
|
||||
QRect destination;
|
||||
|
||||
@@ -77,14 +77,14 @@ extern "C" {
|
||||
struct mouseinputdata {
|
||||
atomic_bool mouse_tablet_in_proximity;
|
||||
|
||||
char *mouse_type;
|
||||
char *mouse_type;
|
||||
};
|
||||
static mouseinputdata mousedata;
|
||||
|
||||
extern MainWindow *main_window;
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
HWND rw_hwnd;
|
||||
HWND rw_hwnd;
|
||||
#endif
|
||||
|
||||
RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
@@ -98,7 +98,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
#endif
|
||||
#ifdef Q_OS_WINDOWS
|
||||
setAttribute(Qt::WA_NativeWindow, true);
|
||||
(void)winId();
|
||||
(void) winId();
|
||||
#endif
|
||||
rendererTakesScreenshots = false;
|
||||
#ifdef Q_OS_WINDOWS
|
||||
@@ -111,9 +111,8 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
|
||||
m_monitor_index = monitor_index;
|
||||
|
||||
|
||||
if (monitor_index >= 1) {
|
||||
QTimer* frameRateTimer = new QTimer(this);
|
||||
QTimer *frameRateTimer = new QTimer(this);
|
||||
frameRateTimer->setSingleShot(false);
|
||||
frameRateTimer->setInterval(1000);
|
||||
connect(frameRateTimer, &QTimer::timeout, [this] {
|
||||
@@ -122,7 +121,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
frameRateTimer->start(1000);
|
||||
}
|
||||
#if defined __unix__ && !defined __HAIKU__
|
||||
memset(auto_mouse_type, 0, sizeof (auto_mouse_type));
|
||||
memset(auto_mouse_type, 0, sizeof(auto_mouse_type));
|
||||
mousedata.mouse_type = getenv("EMU86BOX_MOUSE");
|
||||
if (!mousedata.mouse_type || (mousedata.mouse_type[0] == '\0') || !stricmp(mousedata.mouse_type, "auto")) {
|
||||
if (QApplication::platformName().contains("wayland"))
|
||||
@@ -163,7 +162,7 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
|
||||
RendererStack::~RendererStack()
|
||||
{
|
||||
while (QApplication::overrideCursor())
|
||||
while (QApplication::overrideCursor())
|
||||
QApplication::restoreOverrideCursor();
|
||||
delete ui;
|
||||
}
|
||||
@@ -173,7 +172,8 @@ qt_mouse_capture(int on)
|
||||
{
|
||||
if (!on) {
|
||||
mouse_capture = 0;
|
||||
while (QApplication::overrideCursor()) QApplication::restoreOverrideCursor();
|
||||
while (QApplication::overrideCursor())
|
||||
QApplication::restoreOverrideCursor();
|
||||
#ifdef __APPLE__
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
#endif
|
||||
@@ -192,7 +192,7 @@ void
|
||||
RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
rw_hwnd = (HWND) this->winId();
|
||||
rw_hwnd = (HWND) this->winId();
|
||||
#endif
|
||||
|
||||
event->accept();
|
||||
@@ -201,9 +201,7 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
||||
#else
|
||||
if (!dopause && this->geometry().contains(m_monitor_index >= 1 ? event->globalPos() : event->pos()) &&
|
||||
#endif
|
||||
(event->button() == Qt::LeftButton) && !mouse_capture &&
|
||||
(isMouseDown & 1) && (kbd_req_capture || (mouse_get_buttons() != 0)) &&
|
||||
(mouse_input_mode == 0)) {
|
||||
(event->button() == Qt::LeftButton) && !mouse_capture && (isMouseDown & 1) && (kbd_req_capture || (mouse_get_buttons() != 0)) && (mouse_input_mode == 0)) {
|
||||
plat_mouse_capture(1);
|
||||
this->setCursor(Qt::BlankCursor);
|
||||
if (!ignoreNextMouseEvent)
|
||||
@@ -219,15 +217,13 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
||||
}
|
||||
if (mouse_capture || (mouse_input_mode >= 1)) {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) ||
|
||||
((m_monitor_index < 1) && (mouse_input_mode >= 1)))
|
||||
#else
|
||||
#ifndef __APPLE__
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) ||
|
||||
(m_monitor_index < 1))
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || ((m_monitor_index < 1) && (mouse_input_mode >= 1)))
|
||||
#else
|
||||
# ifndef __APPLE__
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || (m_monitor_index < 1))
|
||||
# else
|
||||
if ((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity)
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~event->button());
|
||||
}
|
||||
@@ -240,15 +236,13 @@ RendererStack::mousePressEvent(QMouseEvent *event)
|
||||
isMouseDown |= 1;
|
||||
if (mouse_capture || (mouse_input_mode >= 1)) {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) ||
|
||||
((m_monitor_index < 1) && (mouse_input_mode >= 1)))
|
||||
#else
|
||||
#ifndef __APPLE__
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) ||
|
||||
(m_monitor_index < 1))
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || ((m_monitor_index < 1) && (mouse_input_mode >= 1)))
|
||||
#else
|
||||
# ifndef __APPLE__
|
||||
if (((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity) || (m_monitor_index < 1))
|
||||
# else
|
||||
if ((m_monitor_index >= 1) && (mouse_input_mode >= 1) && mousedata.mouse_tablet_in_proximity)
|
||||
#endif
|
||||
# endif
|
||||
#endif
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | event->button());
|
||||
}
|
||||
@@ -264,7 +258,7 @@ RendererStack::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
|
||||
#if !defined(Q_OS_WINDOWS) && !defined(__APPLE__)
|
||||
double numSteps = (double) event->angleDelta().y() / 120.0;
|
||||
double numSteps = (double) event->angleDelta().y() / 120.0;
|
||||
double numStepsW = (double) event->angleDelta().x() / 120.0;
|
||||
|
||||
mouse_set_z((int) numSteps);
|
||||
@@ -296,18 +290,18 @@ RendererStack::mouseMoveEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined __unix__ && !defined __HAIKU__
|
||||
# if defined __unix__ && !defined __HAIKU__
|
||||
if (!stricmp(mousedata.mouse_type, "wayland"))
|
||||
mouse_scale(event->pos().x() - oldPos.x(), event->pos().y() - oldPos.y());
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (QApplication::platformName() == "eglfs") {
|
||||
leaveEvent((QEvent *) event);
|
||||
ignoreNextMouseEvent--;
|
||||
}
|
||||
#if !defined _WIN32
|
||||
# if !defined _WIN32
|
||||
QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
|
||||
#endif
|
||||
# endif
|
||||
ignoreNextMouseEvent = 2;
|
||||
oldPos = event->pos();
|
||||
#endif
|
||||
@@ -351,7 +345,7 @@ RendererStack::leaveEvent(QEvent *event)
|
||||
void
|
||||
RendererStack::switchRenderer(Renderer renderer)
|
||||
{
|
||||
//startblit();
|
||||
// startblit();
|
||||
switchInProgress = true;
|
||||
if (current) {
|
||||
rendererWindow->finalize();
|
||||
@@ -389,12 +383,12 @@ RendererStack::createRenderer(Renderer renderer)
|
||||
{
|
||||
this->createWinId();
|
||||
this->rendererTakesScreenshots = true;
|
||||
auto hw = new OpenGLRenderer(this);
|
||||
rendererWindow = hw;
|
||||
auto hw = new OpenGLRenderer(this);
|
||||
rendererWindow = hw;
|
||||
connect(this, &RendererStack::blitToRenderer, hw, &OpenGLRenderer::onBlit, Qt::QueuedConnection);
|
||||
connect(hw, &OpenGLRenderer::initialized, [=]() {
|
||||
/* Buffers are available only after initialization. */
|
||||
imagebufs = rendererWindow->getBuffers();
|
||||
imagebufs = rendererWindow->getBuffers();
|
||||
switchInProgress = false;
|
||||
emit rendererChanged();
|
||||
});
|
||||
@@ -426,7 +420,7 @@ RendererStack::createRenderer(Renderer renderer)
|
||||
connect(this, &RendererStack::blitToRenderer, hw, &VulkanWindowRenderer::onBlit, Qt::QueuedConnection);
|
||||
connect(hw, &VulkanWindowRenderer::rendererInitialized, [=]() {
|
||||
/* Buffers are available only after initialization. */
|
||||
imagebufs = rendererWindow->getBuffers();
|
||||
imagebufs = rendererWindow->getBuffers();
|
||||
switchInProgress = false;
|
||||
emit rendererChanged();
|
||||
});
|
||||
@@ -460,7 +454,7 @@ RendererStack::createRenderer(Renderer renderer)
|
||||
currentBuf = 0;
|
||||
|
||||
if (renderer != Renderer::OpenGL3 && renderer != Renderer::Vulkan) {
|
||||
imagebufs = rendererWindow->getBuffers();
|
||||
imagebufs = rendererWindow->getBuffers();
|
||||
switchInProgress = false;
|
||||
emit rendererChanged();
|
||||
}
|
||||
@@ -470,10 +464,7 @@ RendererStack::createRenderer(Renderer renderer)
|
||||
void
|
||||
RendererStack::blit(int x, int y, int w, int h)
|
||||
{
|
||||
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) ||
|
||||
(w > 2048) || (h > 2048) || (switchInProgress) ||
|
||||
(monitors[m_monitor_index].target_buffer == NULL) || imagebufs.empty() ||
|
||||
std::get<std::atomic_flag *>(imagebufs[currentBuf])->test_and_set()) {
|
||||
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (switchInProgress) || (monitors[m_monitor_index].target_buffer == NULL) || imagebufs.empty() || std::get<std::atomic_flag *>(imagebufs[currentBuf])->test_and_set()) {
|
||||
video_blit_complete_monitor(m_monitor_index);
|
||||
return;
|
||||
}
|
||||
@@ -517,20 +508,20 @@ RendererStack::changeEvent(QEvent *event)
|
||||
}
|
||||
|
||||
bool
|
||||
RendererStack::event(QEvent* event)
|
||||
RendererStack::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::MouseMove) {
|
||||
QMouseEvent* mouse_event = (QMouseEvent*)event;
|
||||
QMouseEvent *mouse_event = (QMouseEvent *) event;
|
||||
|
||||
if (m_monitor_index >= 1) {
|
||||
if (mouse_input_mode >= 1) {
|
||||
#ifdef TOUCH_PR
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
mouse_x_abs = (mouse_event->position().x()) / (double)width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (double)height();
|
||||
mouse_x_abs = (mouse_event->position().x()) / (double) width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (double) height();
|
||||
#else
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (double)width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (double)height();
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (double) width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (double) height();
|
||||
#endif
|
||||
#else
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
@@ -546,14 +537,18 @@ RendererStack::event(QEvent* event)
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
if (mouse_x_abs < 0)
|
||||
mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0)
|
||||
mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
|
||||
if (mouse_x_abs > 1) mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1) mouse_y_abs = 1;
|
||||
if (mouse_x_abs > 1)
|
||||
mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1)
|
||||
mouse_y_abs = 1;
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
@@ -561,47 +556,51 @@ RendererStack::event(QEvent* event)
|
||||
#ifdef TOUCH_PR
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (mouse_input_mode == 0) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
mouse_x_abs = (mouse_event->position().x()) / (double)width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (double)height();
|
||||
#else
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (double)width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (double)height();
|
||||
#endif
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
mouse_x_abs = (mouse_event->position().x()) / (double) width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (double) height();
|
||||
# else
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (double) width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (double) height();
|
||||
# endif
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
if (mouse_x_abs < 0)
|
||||
mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0)
|
||||
mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
|
||||
if (mouse_x_abs > 1) mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1) mouse_y_abs = 1;
|
||||
if (mouse_x_abs > 1)
|
||||
mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1)
|
||||
mouse_y_abs = 1;
|
||||
return QWidget::event(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
mouse_x_abs = (mouse_event->position().x()) / (double)width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (double)height();
|
||||
mouse_x_abs = (mouse_event->position().x()) / (double) width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (double) height();
|
||||
#else
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (double)width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (double)height();
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (double) width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (double) height();
|
||||
#endif
|
||||
#else
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (mouse_input_mode == 0) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
mouse_x_abs = (mouse_event->position().x()) / (long double)width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (long double)height();
|
||||
mouse_x_abs = (mouse_event->position().x()) / (long double)width();
|
||||
mouse_y_abs = (mouse_event->position().y()) / (long double)height();
|
||||
#else
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (long double)width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (long double)height();
|
||||
mouse_x_abs = (mouse_event->localPos().x()) / (long double)width();
|
||||
mouse_y_abs = (mouse_event->localPos().y()) / (long double)height();
|
||||
#endif
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
@@ -626,117 +625,142 @@ RendererStack::event(QEvent* event)
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
if (mouse_x_abs < 0)
|
||||
mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0)
|
||||
mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
|
||||
if (mouse_x_abs > 1) mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1) mouse_y_abs = 1;
|
||||
if (mouse_x_abs > 1)
|
||||
mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1)
|
||||
mouse_y_abs = 1;
|
||||
mouse_tablet_in_proximity = mousedata.mouse_tablet_in_proximity;
|
||||
#ifdef TOUCH_PR
|
||||
} else switch (event->type()) {
|
||||
case QEvent::TouchBegin:
|
||||
case QEvent::TouchUpdate:
|
||||
{
|
||||
} else
|
||||
switch (event->type()) {
|
||||
case QEvent::TouchBegin:
|
||||
case QEvent::TouchUpdate:
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QTouchEvent* touchevent = (QTouchEvent*)event;
|
||||
if (mouse_input_mode == 0) break;
|
||||
if (touchevent->touchPoints().count()) {
|
||||
mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double)width();
|
||||
mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double)height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
QTouchEvent *touchevent = (QTouchEvent *) event;
|
||||
if (mouse_input_mode == 0)
|
||||
break;
|
||||
if (touchevent->touchPoints().count()) {
|
||||
mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double) width();
|
||||
mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double) height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs > 1) mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1) mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | 1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
if (mouse_x_abs < 0)
|
||||
mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0)
|
||||
mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
|
||||
if (mouse_x_abs > 1)
|
||||
mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1)
|
||||
mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | 1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
#else
|
||||
QTouchEvent* touchevent = (QTouchEvent*)event;
|
||||
if (mouse_input_mode == 0) break;
|
||||
if (touchevent->pointCount()) {
|
||||
mouse_x_abs = (touchevent->point(0).position().x()) / (double)width();
|
||||
mouse_y_abs = (touchevent->point(0).position().y()) / (double)height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
QTouchEvent *touchevent = (QTouchEvent *) event;
|
||||
if (mouse_input_mode == 0)
|
||||
break;
|
||||
if (touchevent->pointCount()) {
|
||||
mouse_x_abs = (touchevent->point(0).position().x()) / (double) width();
|
||||
mouse_y_abs = (touchevent->point(0).position().y()) / (double) height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs > 1) mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1) mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | 1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
if (mouse_x_abs < 0)
|
||||
mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0)
|
||||
mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
|
||||
if (mouse_x_abs > 1)
|
||||
mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1)
|
||||
mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | 1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
case QEvent::TouchEnd:
|
||||
case QEvent::TouchCancel:
|
||||
{
|
||||
}
|
||||
case QEvent::TouchEnd:
|
||||
case QEvent::TouchCancel:
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QTouchEvent* touchevent = (QTouchEvent*)event;
|
||||
if (mouse_input_mode == 0) break;
|
||||
if (touchevent->touchPoints().count()) {
|
||||
mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double)width();
|
||||
mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double)height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
QTouchEvent *touchevent = (QTouchEvent *) event;
|
||||
if (mouse_input_mode == 0)
|
||||
break;
|
||||
if (touchevent->touchPoints().count()) {
|
||||
mouse_x_abs = (touchevent->touchPoints()[0].pos().x()) / (double) width();
|
||||
mouse_y_abs = (touchevent->touchPoints()[0].pos().y()) / (double) height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs > 1) mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1) mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
if (mouse_x_abs < 0)
|
||||
mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0)
|
||||
mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
|
||||
if (mouse_x_abs > 1)
|
||||
mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1)
|
||||
mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
#else
|
||||
QTouchEvent* touchevent = (QTouchEvent*)event;
|
||||
if (mouse_input_mode == 0) break;
|
||||
if (touchevent->pointCount()) {
|
||||
mouse_x_abs = (touchevent->point(0).position().x()) / (double)width();
|
||||
mouse_y_abs = (touchevent->point(0).position().y()) / (double)height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs < 0) mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0) mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
QTouchEvent *touchevent = (QTouchEvent *) event;
|
||||
if (mouse_input_mode == 0)
|
||||
break;
|
||||
if (touchevent->pointCount()) {
|
||||
mouse_x_abs = (touchevent->point(0).position().x()) / (double) width();
|
||||
mouse_y_abs = (touchevent->point(0).position().y()) / (double) height();
|
||||
mouse_x_abs -= rendererWindow->destinationF.left();
|
||||
mouse_y_abs -= rendererWindow->destinationF.top();
|
||||
|
||||
if (mouse_x_abs > 1) mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1) mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
if (mouse_x_abs < 0)
|
||||
mouse_x_abs = 0;
|
||||
if (mouse_y_abs < 0)
|
||||
mouse_y_abs = 0;
|
||||
|
||||
mouse_x_abs /= rendererWindow->destinationF.width();
|
||||
mouse_y_abs /= rendererWindow->destinationF.height();
|
||||
|
||||
if (mouse_x_abs > 1)
|
||||
mouse_x_abs = 1;
|
||||
if (mouse_y_abs > 1)
|
||||
mouse_y_abs = 1;
|
||||
}
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~1);
|
||||
touchevent->accept();
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
default:
|
||||
return QWidget::event(event);
|
||||
#endif /*TOUCH_PR*/
|
||||
}
|
||||
|
||||
default:
|
||||
return QWidget::event(event);
|
||||
#endif
|
||||
}
|
||||
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
@@ -753,7 +777,7 @@ RendererStack::onResize(int width, int height)
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (mouse_capture) {
|
||||
RECT rect;
|
||||
if (GetWindowRect((HWND)this->winId(), &rect)) {
|
||||
if (GetWindowRect((HWND) this->winId(), &rect)) {
|
||||
ClipCursor(&rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,8 @@ namespace Ui {
|
||||
class RendererStack;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern int vid_resize;
|
||||
extern "C" {
|
||||
extern int vid_resize;
|
||||
}
|
||||
|
||||
class RendererCommon;
|
||||
@@ -54,16 +53,18 @@ public:
|
||||
if (this->m_monitor_index != 0 && vid_resize != 1) {
|
||||
int newX = pos().x();
|
||||
int newY = pos().y();
|
||||
|
||||
|
||||
if (((frameGeometry().x() + event->size().width() + 1) > util::screenOfWidget(this)->availableGeometry().right())) {
|
||||
//move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y());
|
||||
// move(util::screenOfWidget(this)->availableGeometry().right() - size().width() - 1, pos().y());
|
||||
newX = util::screenOfWidget(this)->availableGeometry().right() - frameGeometry().width() - 1;
|
||||
if (newX < 1) newX = 1;
|
||||
if (newX < 1)
|
||||
newX = 1;
|
||||
}
|
||||
|
||||
|
||||
if (((frameGeometry().y() + event->size().height() + 1) > util::screenOfWidget(this)->availableGeometry().bottom())) {
|
||||
newY = util::screenOfWidget(this)->availableGeometry().bottom() - frameGeometry().height() - 1;
|
||||
if (newY < 1) newY = 1;
|
||||
if (newY < 1)
|
||||
newY = 1;
|
||||
}
|
||||
move(newX, newY);
|
||||
}
|
||||
@@ -77,7 +78,7 @@ public:
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
bool event(QEvent* event) override;
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
enum class Renderer {
|
||||
Software,
|
||||
@@ -99,12 +100,12 @@ public:
|
||||
void setFocusRenderer();
|
||||
void onResize(int width, int height);
|
||||
|
||||
QWidget* currentWidget() { return current.get(); }
|
||||
QWidget *currentWidget() { return current.get(); }
|
||||
|
||||
void (*mouse_capture_func)(QWindow *window) = nullptr;
|
||||
void (*mouse_uncapture_func)() = nullptr;
|
||||
|
||||
void (*mouse_exit_func)() = nullptr;
|
||||
void (*mouse_exit_func)() = nullptr;
|
||||
|
||||
signals:
|
||||
void blitToRenderer(int buf_idx, int x, int y, int w, int h);
|
||||
@@ -116,7 +117,7 @@ public slots:
|
||||
private:
|
||||
void createRenderer(Renderer renderer);
|
||||
|
||||
QBoxLayout* boxLayout = nullptr;
|
||||
QBoxLayout *boxLayout = nullptr;
|
||||
|
||||
Ui::RendererStack *ui;
|
||||
|
||||
@@ -139,7 +140,7 @@ private:
|
||||
std::unique_ptr<QWidget> current;
|
||||
|
||||
std::atomic_bool rendererTakesScreenshots;
|
||||
std::atomic_bool switchInProgress{false};
|
||||
std::atomic_bool switchInProgress { false };
|
||||
|
||||
char auto_mouse_type[16];
|
||||
};
|
||||
|
||||
@@ -187,8 +187,7 @@ Settings::Settings(QWidget *parent)
|
||||
&SettingsOtherRemovable::reloadBusChannels_MO);
|
||||
|
||||
connect(ui->listView->selectionModel(), &QItemSelectionModel::currentChanged, this,
|
||||
[this](const QModelIndex ¤t, const QModelIndex &previous) {
|
||||
ui->stackedWidget->setCurrentIndex(current.row()); });
|
||||
[this](const QModelIndex ¤t, const QModelIndex &previous) { ui->stackedWidget->setCurrentIndex(current.row()); });
|
||||
|
||||
ui->listView->setCurrentIndex(model->index(0, 0));
|
||||
|
||||
@@ -224,14 +223,12 @@ Settings::accept()
|
||||
{
|
||||
if (confirm_save && !settings_only) {
|
||||
QMessageBox questionbox(QMessageBox::Icon::Question, "86Box",
|
||||
QStringLiteral("%1\n\n%2").arg(tr("Do you want to save the settings?"),
|
||||
tr("This will hard reset the emulated machine.")),
|
||||
QStringLiteral("%1\n\n%2").arg(tr("Do you want to save the settings?"), tr("This will hard reset the emulated machine.")),
|
||||
QMessageBox::Save | QMessageBox::Cancel, this);
|
||||
QCheckBox *chkbox = new QCheckBox(tr("Don't show this message again"));
|
||||
questionbox.setCheckBox(chkbox);
|
||||
chkbox->setChecked(!confirm_save);
|
||||
QObject::connect(chkbox, &QCheckBox::stateChanged, [](int state) {
|
||||
confirm_save = (state == Qt::CheckState::Unchecked); });
|
||||
QObject::connect(chkbox, &QCheckBox::stateChanged, [](int state) { confirm_save = (state == Qt::CheckState::Unchecked); });
|
||||
questionbox.exec();
|
||||
if (questionbox.result() == QMessageBox::Cancel) {
|
||||
confirm_save = true;
|
||||
|
||||
@@ -47,7 +47,7 @@ SettingsBusTracking::next_free_mke_channel()
|
||||
uint8_t ret = CHANNEL_NONE;
|
||||
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
|
||||
if (!(mke_tracking & mask)) {
|
||||
ret = (uint8_t) i;
|
||||
@@ -65,7 +65,7 @@ SettingsBusTracking::next_free_mfm_channel()
|
||||
uint8_t ret = CHANNEL_NONE;
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
|
||||
if (!(mfm_tracking & mask)) {
|
||||
ret = (uint8_t) i;
|
||||
@@ -83,7 +83,7 @@ SettingsBusTracking::next_free_esdi_channel()
|
||||
uint8_t ret = CHANNEL_NONE;
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
|
||||
if (!(esdi_tracking & mask)) {
|
||||
ret = (uint8_t) i;
|
||||
@@ -101,7 +101,7 @@ SettingsBusTracking::next_free_xta_channel()
|
||||
uint8_t ret = CHANNEL_NONE;
|
||||
|
||||
for (uint8_t i = 0; i < 2; i++) {
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
mask = 0xffULL << ((uint64_t) ((i << 3) & 0x3f));
|
||||
|
||||
if (!(xta_tracking & mask)) {
|
||||
ret = (uint8_t) i;
|
||||
@@ -236,7 +236,9 @@ SettingsBusTracking::scsi_bus_full()
|
||||
return (count == 64);
|
||||
}
|
||||
|
||||
QList<int> SettingsBusTracking::busChannelsInUse(const int bus) {
|
||||
QList<int>
|
||||
SettingsBusTracking::busChannelsInUse(const int bus)
|
||||
{
|
||||
|
||||
QList<int> channelsInUse;
|
||||
int element;
|
||||
@@ -277,7 +279,7 @@ QList<int> SettingsBusTracking::busChannelsInUse(const int bus) {
|
||||
case HDD_BUS_IDE:
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
element = ((i << 3) >> 6);
|
||||
mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f));
|
||||
mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f));
|
||||
if (ide_tracking[element] & mask)
|
||||
channelsInUse.append(i);
|
||||
}
|
||||
@@ -285,7 +287,7 @@ QList<int> SettingsBusTracking::busChannelsInUse(const int bus) {
|
||||
case HDD_BUS_ATAPI:
|
||||
for (uint8_t i = 0; i < 32; i++) {
|
||||
element = ((i << 3) >> 6);
|
||||
mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f));
|
||||
mask = ((uint64_t) 0xffULL) << ((uint64_t) ((i << 3) & 0x3f));
|
||||
if (ide_tracking[element] & mask)
|
||||
channelsInUse.append(i);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ SettingsDisplay::SettingsDisplay(QWidget *parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
for (uint8_t i = 0; i < GFXCARD_MAX; i ++)
|
||||
for (uint8_t i = 0; i < GFXCARD_MAX; i++)
|
||||
videoCard[i] = gfxcard[i];
|
||||
|
||||
ui->lineEditCustomEDID->setFilter(tr("EDID") % util::DlgFilter({ "bin", "dat", "edid", "txt" }) % tr("All files") % util::DlgFilter({ "*" }, true));
|
||||
@@ -67,7 +67,7 @@ SettingsDisplay::save()
|
||||
}
|
||||
#else
|
||||
gfxcard[0] = ui->comboBoxVideo->currentData().toInt();
|
||||
for (uint8_t i = 1; i < GFXCARD_MAX; i ++)
|
||||
for (uint8_t i = 1; i < GFXCARD_MAX; i++)
|
||||
gfxcard[i] = ui->comboBoxVideoSecondary->currentData().toInt();
|
||||
#endif
|
||||
|
||||
@@ -129,7 +129,7 @@ SettingsDisplay::onCurrentMachineChanged(int machineId)
|
||||
}
|
||||
ui->comboBoxVideo->setCurrentIndex(selectedRow);
|
||||
// TODO
|
||||
for (uint8_t i = 1; i < GFXCARD_MAX; i ++)
|
||||
for (uint8_t i = 1; i < GFXCARD_MAX; i++)
|
||||
if (gfxcard[i] == 0)
|
||||
ui->pushButtonConfigureVideoSecondary->setEnabled(false);
|
||||
|
||||
@@ -142,8 +142,8 @@ SettingsDisplay::onCurrentMachineChanged(int machineId)
|
||||
void
|
||||
SettingsDisplay::on_pushButtonConfigureVideo_clicked()
|
||||
{
|
||||
int videoCard = ui->comboBoxVideo->currentData().toInt();
|
||||
auto *device = video_card_getdevice(videoCard);
|
||||
int videoCard = ui->comboBoxVideo->currentData().toInt();
|
||||
auto *device = video_card_getdevice(videoCard);
|
||||
if (videoCard == VID_INTERNAL)
|
||||
device = machine_get_vid_device(machineId);
|
||||
DeviceConfig::ConfigureDevice(device);
|
||||
@@ -185,11 +185,10 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index)
|
||||
return;
|
||||
|
||||
static QRegularExpression voodooRegex("3dfx|voodoo|banshee|raven", QRegularExpression::CaseInsensitiveOption);
|
||||
auto curVideoCard_2 = videoCard[1];
|
||||
videoCard[0] = ui->comboBoxVideo->currentData().toInt();
|
||||
auto curVideoCard_2 = videoCard[1];
|
||||
videoCard[0] = ui->comboBoxVideo->currentData().toInt();
|
||||
if (videoCard[0] == VID_INTERNAL)
|
||||
ui->pushButtonConfigureVideo->setEnabled(machine_has_flags(machineId, MACHINE_VIDEO) &&
|
||||
device_has_config(machine_get_vid_device(machineId)));
|
||||
ui->pushButtonConfigureVideo->setEnabled(machine_has_flags(machineId, MACHINE_VIDEO) && device_has_config(machine_get_vid_device(machineId)));
|
||||
else
|
||||
ui->pushButtonConfigureVideo->setEnabled(video_card_has_config(videoCard[0]) > 0);
|
||||
bool machineHasPci = machine_has_bus(machineId, MACHINE_BUS_PCI) > 0;
|
||||
@@ -203,7 +202,7 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index)
|
||||
|
||||
bool machineSupports8514 = ((machineHasIsa16 || machineHasMca) && !videoCardHas8514);
|
||||
bool machineSupportsXga = ((machineHasMca && device_available(&xga_device)) && !videoCardHasXga);
|
||||
bool machineSupportsDa2 = machineHasMca && device_available(&ps55da2_device);
|
||||
bool machineSupportsDa2 = machineHasMca && device_available(&ps55da2_device);
|
||||
|
||||
ui->checkBox8514->setEnabled(machineSupports8514);
|
||||
ui->checkBox8514->setChecked(ibm8514_standalone_enabled && machineSupports8514);
|
||||
@@ -322,30 +321,32 @@ SettingsDisplay::on_pushButtonConfigureVideoSecondary_clicked()
|
||||
DeviceConfig::ConfigureDevice(device);
|
||||
}
|
||||
|
||||
void SettingsDisplay::on_radioButtonDefault_clicked()
|
||||
void
|
||||
SettingsDisplay::on_radioButtonDefault_clicked()
|
||||
{
|
||||
ui->radioButtonDefault->setChecked(true);
|
||||
ui->radioButtonCustom->setChecked(false);
|
||||
ui->lineEditCustomEDID->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
void SettingsDisplay::on_radioButtonCustom_clicked()
|
||||
void
|
||||
SettingsDisplay::on_radioButtonCustom_clicked()
|
||||
{
|
||||
ui->radioButtonDefault->setChecked(false);
|
||||
ui->radioButtonCustom->setChecked(true);
|
||||
ui->lineEditCustomEDID->setEnabled(true);
|
||||
}
|
||||
|
||||
void SettingsDisplay::on_pushButtonExportDefault_clicked()
|
||||
void
|
||||
SettingsDisplay::on_pushButtonExportDefault_clicked()
|
||||
{
|
||||
auto str = QFileDialog::getSaveFileName(this, tr("Export EDID"));
|
||||
if (!str.isEmpty()) {
|
||||
QFile file(str);
|
||||
if (file.open(QFile::WriteOnly)) {
|
||||
uint8_t *bytes = nullptr;
|
||||
auto size = ddc_create_default_edid(&bytes);
|
||||
file.write((char*)bytes, size);
|
||||
auto size = ddc_create_default_edid(&bytes);
|
||||
file.write((char *) bytes, size);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::SettingsDisplay *ui;
|
||||
int machineId = 0;
|
||||
int machineId = 0;
|
||||
int videoCard[VIDEOCARD_MAX] = { 0, 0 };
|
||||
};
|
||||
|
||||
|
||||
@@ -114,8 +114,8 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent)
|
||||
ui->setupUi(this);
|
||||
|
||||
floppy_disabled_icon = QIcon(":/settings/qt/icons/floppy_disabled.ico");
|
||||
floppy_525_icon = QIcon(":/settings/qt/icons/floppy_525.ico");
|
||||
floppy_35_icon = QIcon(":/settings/qt/icons/floppy_35.ico");
|
||||
floppy_525_icon = QIcon(":/settings/qt/icons/floppy_525.ico");
|
||||
floppy_35_icon = QIcon(":/settings/qt/icons/floppy_35.ico");
|
||||
|
||||
auto *model = ui->comboBoxFloppyType->model();
|
||||
int i = 0;
|
||||
@@ -135,7 +135,7 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent)
|
||||
model->setHeaderData(2, Qt::Horizontal, tr("Check BPB"));
|
||||
model->setHeaderData(3, Qt::Horizontal, tr("Audio"));
|
||||
|
||||
model->insertRows(0, FDD_NUM);
|
||||
model->insertRows(0, FDD_NUM);
|
||||
/* Floppy drives category */
|
||||
for (int i = 0; i < FDD_NUM; i++) {
|
||||
auto idx = model->index(i, 0);
|
||||
@@ -169,7 +169,7 @@ model->insertRows(0, FDD_NUM);
|
||||
|
||||
connect(ui->tableViewFloppy->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
this, &SettingsFloppyCDROM::onFloppyRowChanged);
|
||||
|
||||
|
||||
#ifndef DISABLE_FDD_AUDIO
|
||||
ui->comboBoxFloppyAudio->setVisible(true);
|
||||
int profile_count = fdd_audio_get_profile_count();
|
||||
@@ -190,7 +190,7 @@ model->insertRows(0, FDD_NUM);
|
||||
onFloppyRowChanged(model->index(0, 0));
|
||||
|
||||
cdrom_disabled_icon = QIcon(":/settings/qt/icons/cdrom_disabled.ico");
|
||||
cdrom_icon = QIcon(":/settings/qt/icons/cdrom.ico");
|
||||
cdrom_icon = QIcon(":/settings/qt/icons/cdrom.ico");
|
||||
|
||||
Harddrives::populateCDROMBuses(ui->comboBoxBus->model());
|
||||
model = ui->comboBoxSpeed->model();
|
||||
@@ -204,8 +204,8 @@ model->insertRows(0, FDD_NUM);
|
||||
model->setHeaderData(2, Qt::Horizontal, tr("Type"));
|
||||
model->insertRows(0, CDROM_NUM);
|
||||
for (int i = 0; i < CDROM_NUM; i++) {
|
||||
auto idx = model->index(i, 0);
|
||||
int type = cdrom_get_type(i);
|
||||
auto idx = model->index(i, 0);
|
||||
int type = cdrom_get_type(i);
|
||||
setCDROMBus(model, idx, cdrom[i].bus_type, cdrom[i].res);
|
||||
setCDROMType(model, idx.siblingAtColumn(2), type);
|
||||
int speed = cdrom_get_speed(type);
|
||||
@@ -230,19 +230,16 @@ model->insertRows(0, FDD_NUM);
|
||||
ui->tableViewCDROM->setCurrentIndex(model->index(0, 0));
|
||||
|
||||
uint8_t bus_type = ui->comboBoxBus->currentData().toUInt();
|
||||
int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt();
|
||||
int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt();
|
||||
|
||||
auto *modelType = ui->comboBoxCDROMType->model();
|
||||
int removeRows = modelType->rowCount();
|
||||
|
||||
uint32_t j = 0;
|
||||
int selectedTypeRow = 0;
|
||||
int eligibleRows = 0;
|
||||
int selectedTypeRow = 0;
|
||||
int eligibleRows = 0;
|
||||
while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) {
|
||||
if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) ||
|
||||
(bus_type == CDROM_BUS_SCSI)) &&
|
||||
((cdrom_drive_types[j].bus_type == bus_type) ||
|
||||
((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) {
|
||||
if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) || (bus_type == CDROM_BUS_SCSI)) && ((cdrom_drive_types[j].bus_type == bus_type) || ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) {
|
||||
QString name = CDROMName(j);
|
||||
Models::AddEntry(modelType, name, j);
|
||||
if (cdrom[cdromIdx].type == j)
|
||||
@@ -278,16 +275,16 @@ SettingsFloppyCDROM::save()
|
||||
/* Removable devices category */
|
||||
model = ui->tableViewCDROM->model();
|
||||
for (int i = 0; i < CDROM_NUM; i++) {
|
||||
cdrom[i].priv = NULL;
|
||||
cdrom[i].ops = NULL;
|
||||
cdrom[i].local = NULL;
|
||||
cdrom[i].insert = NULL;
|
||||
cdrom[i].close = NULL;
|
||||
cdrom[i].get_volume = NULL;
|
||||
cdrom[i].priv = NULL;
|
||||
cdrom[i].ops = NULL;
|
||||
cdrom[i].local = NULL;
|
||||
cdrom[i].insert = NULL;
|
||||
cdrom[i].close = NULL;
|
||||
cdrom[i].get_volume = NULL;
|
||||
cdrom[i].get_channel = NULL;
|
||||
cdrom[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt();
|
||||
cdrom[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt();
|
||||
cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt();
|
||||
cdrom[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt();
|
||||
cdrom[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt();
|
||||
cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt();
|
||||
cdrom_set_type(i, model->index(i, 2).data(Qt::UserRole).toInt());
|
||||
}
|
||||
|
||||
@@ -306,7 +303,7 @@ SettingsFloppyCDROM::onFloppyRowChanged(const QModelIndex ¤t)
|
||||
ui->checkBoxTurboTimings->setChecked(current.siblingAtColumn(1).data() == tr("On"));
|
||||
ui->checkBoxCheckBPB->setChecked(current.siblingAtColumn(2).data() == tr("On"));
|
||||
|
||||
int prof = current.siblingAtColumn(3).data(Qt::UserRole).toInt();
|
||||
int prof = current.siblingAtColumn(3).data(Qt::UserRole).toInt();
|
||||
int comboIndex = ui->comboBoxFloppyAudio->findData(prof);
|
||||
ui->comboBoxFloppyAudio->setCurrentIndex(comboIndex);
|
||||
}
|
||||
@@ -319,9 +316,9 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t)
|
||||
uint32_t type = current.siblingAtColumn(2).data(Qt::UserRole).toUInt();
|
||||
|
||||
ui->comboBoxBus->setCurrentIndex(-1);
|
||||
auto* model = ui->comboBoxBus->model();
|
||||
auto match = model->match(model->index(0, 0), Qt::UserRole, bus);
|
||||
if (! match.isEmpty())
|
||||
auto *model = ui->comboBoxBus->model();
|
||||
auto match = model->match(model->index(0, 0), Qt::UserRole, bus);
|
||||
if (!match.isEmpty())
|
||||
ui->comboBoxBus->setCurrentIndex(match.first().row());
|
||||
|
||||
model = ui->comboBoxChannel->model();
|
||||
@@ -329,9 +326,9 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t)
|
||||
if (!match.isEmpty())
|
||||
ui->comboBoxChannel->setCurrentIndex(match.first().row());
|
||||
|
||||
int speed = cdrom_get_speed(type);
|
||||
int speed = cdrom_get_speed(type);
|
||||
if (speed == -1) {
|
||||
speed = current.siblingAtColumn(1).data(Qt::UserRole).toUInt();
|
||||
speed = current.siblingAtColumn(1).data(Qt::UserRole).toUInt();
|
||||
ui->comboBoxSpeed->setEnabled((bus == CDROM_BUS_DISABLED) ? false : true);
|
||||
} else
|
||||
ui->comboBoxSpeed->setEnabled(false);
|
||||
@@ -341,13 +338,10 @@ SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t)
|
||||
int removeRows = modelType->rowCount();
|
||||
|
||||
uint32_t j = 0;
|
||||
int selectedTypeRow = 0;
|
||||
int eligibleRows = 0;
|
||||
int selectedTypeRow = 0;
|
||||
int eligibleRows = 0;
|
||||
while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) {
|
||||
if (((bus == CDROM_BUS_MKE) || (bus == CDROM_BUS_ATAPI) ||
|
||||
(bus == CDROM_BUS_SCSI)) &&
|
||||
((cdrom_drive_types[j].bus_type == bus) ||
|
||||
((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus != BUS_TYPE_MKE)))) {
|
||||
if (((bus == CDROM_BUS_MKE) || (bus == CDROM_BUS_ATAPI) || (bus == CDROM_BUS_SCSI)) && ((cdrom_drive_types[j].bus_type == bus) || ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus != BUS_TYPE_MKE)))) {
|
||||
QString name = CDROMName(j);
|
||||
Models::AddEntry(modelType, name, j);
|
||||
if (type == j)
|
||||
@@ -368,19 +362,16 @@ void
|
||||
SettingsFloppyCDROM::on_checkBoxTurboTimings_stateChanged(int arg1)
|
||||
{
|
||||
auto idx = ui->tableViewFloppy->selectionModel()->currentIndex();
|
||||
ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(1), arg1 == Qt::Checked ?
|
||||
tr("On") : tr("Off"));
|
||||
ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(1), arg1 == Qt::Checked ? tr("On") : tr("Off"));
|
||||
}
|
||||
|
||||
void
|
||||
SettingsFloppyCDROM::on_checkBoxCheckBPB_stateChanged(int arg1)
|
||||
{
|
||||
auto idx = ui->tableViewFloppy->selectionModel()->currentIndex();
|
||||
ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(2), arg1 == Qt::Checked ?
|
||||
tr("On") : tr("Off"));
|
||||
ui->tableViewFloppy->model()->setData(idx.siblingAtColumn(2), arg1 == Qt::Checked ? tr("On") : tr("Off"));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsFloppyCDROM::on_comboBoxFloppyType_activated(int index)
|
||||
{
|
||||
@@ -412,7 +403,9 @@ SettingsFloppyCDROM::on_comboBoxFloppyAudio_activated(int)
|
||||
ui->tableViewFloppy->model()->setData(audioIdx, prof, Qt::UserRole);
|
||||
}
|
||||
|
||||
void SettingsFloppyCDROM::reloadBusChannels() {
|
||||
void
|
||||
SettingsFloppyCDROM::reloadBusChannels()
|
||||
{
|
||||
auto selected = ui->comboBoxChannel->currentIndex();
|
||||
Harddrives::populateBusChannels(ui->comboBoxChannel->model(), ui->comboBoxBus->currentData().toInt(), Harddrives::busTrackClass);
|
||||
ui->comboBoxChannel->setCurrentIndex(selected);
|
||||
@@ -447,9 +440,7 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int)
|
||||
uint8_t bus_type = ui->comboBoxBus->currentData().toUInt();
|
||||
int cdromIdx = ui->tableViewCDROM->selectionModel()->currentIndex().data().toInt();
|
||||
|
||||
Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
if (bus_type == CDROM_BUS_MKE)
|
||||
ui->comboBoxChannel->setCurrentIndex(Harddrives::busTrackClass->next_free_mke_channel());
|
||||
else if (bus_type == CDROM_BUS_ATAPI)
|
||||
@@ -463,21 +454,16 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int)
|
||||
ui->tableViewCDROM->selectionModel()->currentIndex(),
|
||||
bus_type,
|
||||
ui->comboBoxChannel->currentData().toUInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
|
||||
auto *modelType = ui->comboBoxCDROMType->model();
|
||||
int removeRows = modelType->rowCount();
|
||||
|
||||
uint32_t j = 0;
|
||||
int selectedTypeRow = 0;
|
||||
int eligibleRows = 0;
|
||||
uint32_t j = 0;
|
||||
int selectedTypeRow = 0;
|
||||
int eligibleRows = 0;
|
||||
while (cdrom_drive_types[j].bus_type != BUS_TYPE_NONE) {
|
||||
if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) ||
|
||||
(bus_type == CDROM_BUS_SCSI)) &&
|
||||
((cdrom_drive_types[j].bus_type == bus_type) ||
|
||||
((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) {
|
||||
if (((bus_type == CDROM_BUS_MKE) || (bus_type == CDROM_BUS_ATAPI) || (bus_type == CDROM_BUS_SCSI)) && ((cdrom_drive_types[j].bus_type == bus_type) || ((cdrom_drive_types[j].bus_type == BUS_TYPE_BOTH) && (bus_type != BUS_TYPE_MKE)))) {
|
||||
QString name = CDROMName(j);
|
||||
Models::AddEntry(modelType, name, j);
|
||||
if (cdrom[cdromIdx].type == j)
|
||||
@@ -502,7 +488,7 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int)
|
||||
} else {
|
||||
ui->comboBoxSpeed->setEnabled(false);
|
||||
if (bus_type == CDROM_BUS_MITSUMI) // temp hack
|
||||
speed = 0;
|
||||
speed = 0;
|
||||
}
|
||||
ui->comboBoxSpeed->setCurrentIndex(speed == 0 ? 7 : speed - 1);
|
||||
setCDROMSpeed(ui->tableViewCDROM->model(),
|
||||
@@ -514,10 +500,10 @@ SettingsFloppyCDROM::on_comboBoxBus_activated(int)
|
||||
void
|
||||
SettingsFloppyCDROM::enableCurrentlySelectedChannel()
|
||||
{
|
||||
const auto *item_model = qobject_cast<QStandardItemModel*>(ui->comboBoxChannel->model());
|
||||
const auto *item_model = qobject_cast<QStandardItemModel *>(ui->comboBoxChannel->model());
|
||||
const auto index = ui->comboBoxChannel->currentIndex();
|
||||
auto *item = item_model->item(index);
|
||||
if(item)
|
||||
if (item)
|
||||
item->setEnabled(true);
|
||||
}
|
||||
|
||||
@@ -525,16 +511,12 @@ void
|
||||
SettingsFloppyCDROM::on_comboBoxChannel_activated(int)
|
||||
{
|
||||
auto i = ui->tableViewCDROM->selectionModel()->currentIndex().siblingAtColumn(0);
|
||||
Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(0, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
setCDROMBus(ui->tableViewCDROM->model(),
|
||||
ui->tableViewCDROM->selectionModel()->currentIndex(),
|
||||
ui->comboBoxBus->currentData().toUInt(),
|
||||
ui->comboBoxChannel->currentData().toUInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
emit cdromChannelChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,11 @@ private slots:
|
||||
void on_comboBoxSpeed_activated(int index);
|
||||
void on_comboBoxCDROMType_activated(int index);
|
||||
|
||||
|
||||
private:
|
||||
Ui::SettingsFloppyCDROM *ui;
|
||||
void setFloppyType(QAbstractItemModel *model, const QModelIndex &idx, int type);
|
||||
void setCDROMBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel);
|
||||
void enableCurrentlySelectedChannel();
|
||||
void setFloppyType(QAbstractItemModel *model, const QModelIndex &idx, int type);
|
||||
void setCDROMBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel);
|
||||
void enableCurrentlySelectedChannel();
|
||||
|
||||
QIcon floppy_disabled_icon;
|
||||
QIcon floppy_525_icon;
|
||||
|
||||
@@ -74,12 +74,12 @@ static void
|
||||
addRow(QAbstractItemModel *model, hard_disk_t *hd)
|
||||
{
|
||||
const QString userPath = usr_path;
|
||||
int row = model->rowCount();
|
||||
int row = model->rowCount();
|
||||
|
||||
model->insertRow(row);
|
||||
|
||||
auto busIndex = model->index(row, ColumnBus);
|
||||
QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel);
|
||||
auto busIndex = model->index(row, ColumnBus);
|
||||
QString busName = Harddrives::BusChannelName(hd->bus_type, hd->channel);
|
||||
model->setData(busIndex, busName);
|
||||
model->setData(busIndex, hard_disk_icon, Qt::DecorationRole);
|
||||
model->setData(busIndex, hd->bus_type, DataBus);
|
||||
@@ -87,8 +87,8 @@ addRow(QAbstractItemModel *model, hard_disk_t *hd)
|
||||
model->setData(busIndex, hd->channel, DataBusChannel);
|
||||
model->setData(busIndex, hd->channel, DataBusChannelPrevious);
|
||||
Harddrives::busTrackClass->device_track(1, DEV_HDD, hd->bus_type, hd->channel);
|
||||
auto filenameIndex = model->index(row, ColumnFilename);
|
||||
QString fileName = hd->fn;
|
||||
auto filenameIndex = model->index(row, ColumnFilename);
|
||||
QString fileName = hd->fn;
|
||||
if (fileName.startsWith(userPath, Qt::CaseInsensitive))
|
||||
model->setData(filenameIndex, fileName.mid(userPath.size()));
|
||||
else
|
||||
@@ -169,7 +169,9 @@ SettingsHarddisks::save()
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsHarddisks::reloadBusChannels() {
|
||||
void
|
||||
SettingsHarddisks::reloadBusChannels()
|
||||
{
|
||||
const auto selected = ui->comboBoxChannel->currentIndex();
|
||||
Harddrives::populateBusChannels(ui->comboBoxChannel->model(), ui->comboBoxBus->currentData().toInt(), Harddrives::busTrackClass);
|
||||
ui->comboBoxChannel->setCurrentIndex(selected);
|
||||
@@ -248,10 +250,10 @@ SettingsHarddisks::on_comboBoxChannel_currentIndexChanged(int index)
|
||||
void
|
||||
SettingsHarddisks::enableCurrentlySelectedChannel()
|
||||
{
|
||||
const auto *item_model = qobject_cast<QStandardItemModel*>(ui->comboBoxChannel->model());
|
||||
const auto index = ui->comboBoxChannel->currentIndex();
|
||||
auto *item = item_model->item(index);
|
||||
if(item)
|
||||
const auto *item_model = qobject_cast<QStandardItemModel *>(ui->comboBoxChannel->model());
|
||||
const auto index = ui->comboBoxChannel->currentIndex();
|
||||
auto *item = item_model->item(index);
|
||||
if (item)
|
||||
item->setEnabled(true);
|
||||
}
|
||||
|
||||
@@ -359,8 +361,8 @@ SettingsHarddisks::on_pushButtonRemove_clicked()
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
auto *model = ui->tableView->model();
|
||||
const auto col = idx.siblingAtColumn(ColumnBus);
|
||||
auto *model = ui->tableView->model();
|
||||
const auto col = idx.siblingAtColumn(ColumnBus);
|
||||
Harddrives::busTrackClass->device_track(0, DEV_HDD, model->data(col, DataBus).toInt(), model->data(col, DataBusChannel).toInt());
|
||||
model->removeRow(idx.row());
|
||||
ui->pushButtonNew->setEnabled(true);
|
||||
|
||||
@@ -61,7 +61,7 @@ SettingsInput::SettingsInput(QWidget *parent)
|
||||
keyTable->setColumnWidth(0, 200);
|
||||
keyTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
QStringList headers;
|
||||
//headers << "Action" << "Bound key";
|
||||
// headers << "Action" << "Bound key";
|
||||
keyTable->setHorizontalHeaderLabels(horizontalHeader);
|
||||
keyTable->verticalHeader()->setVisible(false);
|
||||
keyTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
@@ -71,7 +71,7 @@ SettingsInput::SettingsInput(QWidget *parent)
|
||||
|
||||
// Make a working copy of acc_keys so we can check for dupes later without getting
|
||||
// confused
|
||||
for(int x = 0; x < NUM_ACCELS; x++) {
|
||||
for (int x = 0; x < NUM_ACCELS; x++) {
|
||||
strcpy(acc_keys_t[x].name, acc_keys[x].name);
|
||||
strcpy(acc_keys_t[x].desc, acc_keys[x].desc);
|
||||
strcpy(acc_keys_t[x].seq, acc_keys[x].seq);
|
||||
@@ -96,7 +96,7 @@ SettingsInput::save()
|
||||
joystick_type[0] = ui->comboBoxJoystick0->currentData().toInt();
|
||||
|
||||
// Copy accelerators from working set to global set
|
||||
for(int x = 0; x < NUM_ACCELS; x++) {
|
||||
for (int x = 0; x < NUM_ACCELS; x++) {
|
||||
strcpy(acc_keys[x].name, acc_keys_t[x].name);
|
||||
strcpy(acc_keys[x].desc, acc_keys_t[x].desc);
|
||||
strcpy(acc_keys[x].seq, acc_keys_t[x].seq);
|
||||
@@ -111,7 +111,7 @@ SettingsInput::onCurrentMachineChanged(int machineId)
|
||||
this->machineId = machineId;
|
||||
|
||||
auto *keyboardModel = ui->comboBoxKeyboard->model();
|
||||
auto removeRows = keyboardModel->rowCount();
|
||||
auto removeRows = keyboardModel->rowCount();
|
||||
|
||||
int selectedRow = 0;
|
||||
|
||||
@@ -119,11 +119,10 @@ SettingsInput::onCurrentMachineChanged(int machineId)
|
||||
int has_int_kbd = !!machine_has_flags(machineId, MACHINE_KEYBOARD);
|
||||
|
||||
for (int i = 0; i < keyboard_get_ndev(); ++i) {
|
||||
const auto *dev = keyboard_get_device(i);
|
||||
int ikbd = (i == KEYBOARD_TYPE_INTERNAL);
|
||||
const auto *dev = keyboard_get_device(i);
|
||||
int ikbd = (i == KEYBOARD_TYPE_INTERNAL);
|
||||
|
||||
int pc5086_filter = (strstr(keyboard_get_internal_name(i), "ps") &&
|
||||
machines[machineId].init == machine_xt_pc5086_init);
|
||||
int pc5086_filter = (strstr(keyboard_get_internal_name(i), "ps") && machines[machineId].init == machine_xt_pc5086_init);
|
||||
|
||||
if ((ikbd != has_int_kbd) || !device_is_valid(dev, machineId) || pc5086_filter)
|
||||
continue;
|
||||
@@ -209,7 +208,7 @@ void
|
||||
SettingsInput::on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
|
||||
{
|
||||
// Enable/disable bind/clear buttons if user clicked valid row
|
||||
QTableWidgetItem *cell = ui->tableKeys->item(currentRow,1);
|
||||
QTableWidgetItem *cell = ui->tableKeys->item(currentRow, 1);
|
||||
if (!cell) {
|
||||
ui->pushButtonBind->setEnabled(false);
|
||||
ui->pushButtonClearBind->setEnabled(false);
|
||||
@@ -223,7 +222,7 @@ void
|
||||
SettingsInput::on_tableKeys_cellDoubleClicked(int row, int col)
|
||||
{
|
||||
// Edit bind
|
||||
QTableWidgetItem *cell = ui->tableKeys->item(row,1);
|
||||
QTableWidgetItem *cell = ui->tableKeys->item(row, 1);
|
||||
if (!cell)
|
||||
return;
|
||||
|
||||
@@ -236,8 +235,8 @@ SettingsInput::on_tableKeys_cellDoubleClicked(int row, int col)
|
||||
// Otherwise, check for conflicts.
|
||||
// Check against the *working* copy - NOT the one in use by the app,
|
||||
// so we don't test against shortcuts the user already changed.
|
||||
for(int x = 0; x < NUM_ACCELS; x++) {
|
||||
if(QString::fromStdString(acc_keys_t[x].seq) == keyseq.toString(QKeySequence::PortableText)) {
|
||||
for (int x = 0; x < NUM_ACCELS; x++) {
|
||||
if (QString::fromStdString(acc_keys_t[x].seq) == keyseq.toString(QKeySequence::PortableText)) {
|
||||
// That key is already in use
|
||||
QMessageBox::warning(this, tr("Bind conflict"), tr("This key combo is already in use."), QMessageBox::StandardButton::Ok);
|
||||
return;
|
||||
@@ -247,7 +246,7 @@ SettingsInput::on_tableKeys_cellDoubleClicked(int row, int col)
|
||||
// Go ahead and apply the bind.
|
||||
|
||||
// Find the correct accelerator key entry
|
||||
int accKeyID = FindAccelerator(ui->tableKeys->item(row,2)->text().toUtf8().constData());
|
||||
int accKeyID = FindAccelerator(ui->tableKeys->item(row, 2)->text().toUtf8().constData());
|
||||
if (accKeyID < 0)
|
||||
return; // this should never happen
|
||||
|
||||
@@ -280,7 +279,7 @@ SettingsInput::on_pushButtonClearBind_clicked()
|
||||
|
||||
cell->setText("");
|
||||
// Find the correct accelerator key entry
|
||||
int accKeyID = FindAccelerator(ui->tableKeys->item(cell->row(),2)->text().toUtf8().constData());
|
||||
int accKeyID = FindAccelerator(ui->tableKeys->item(cell->row(), 2)->text().toUtf8().constData());
|
||||
if (accKeyID < 0)
|
||||
return; // this should never happen
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ private slots:
|
||||
private:
|
||||
Ui::SettingsInput *ui;
|
||||
int machineId = 0;
|
||||
void refreshInputList();
|
||||
void refreshInputList();
|
||||
};
|
||||
|
||||
#endif // QT_SETTINGSINPUT_HPP
|
||||
|
||||
@@ -60,10 +60,10 @@ SettingsMachine::SettingsMachine(QWidget *parent)
|
||||
}
|
||||
|
||||
auto machineListCompleter = new QCompleter(ui->lineEditSearch);
|
||||
auto machineListModel = new QStandardItemModel(machineListCompleter);
|
||||
auto machineListModel = new QStandardItemModel(machineListCompleter);
|
||||
machineListCompleter->setModel(machineListModel);
|
||||
ui->lineEditSearch->setCompleter(machineListCompleter);
|
||||
connect(ui->lineEditSearch, &QLineEdit::editingFinished, this, [this] () { ui->lineEditSearch->setText("");} );
|
||||
connect(ui->lineEditSearch, &QLineEdit::editingFinished, this, [this]() { ui->lineEditSearch->setText(""); });
|
||||
machineListCompleter->setCompletionMode(QCompleter::PopupCompletion);
|
||||
machineListCompleter->setFilterMode(Qt::MatchContains);
|
||||
machineListCompleter->setCompletionRole(Qt::DisplayRole);
|
||||
@@ -101,7 +101,7 @@ SettingsMachine::SettingsMachine(QWidget *parent)
|
||||
ui->comboBoxPitMode->setCurrentIndex(pit_mode + 1);
|
||||
|
||||
int selectedMachineType = 0;
|
||||
auto * machineTypesModel = ui->comboBoxMachineType->model();
|
||||
auto *machineTypesModel = ui->comboBoxMachineType->model();
|
||||
int i = -1;
|
||||
int j = 0;
|
||||
int cur_j = 0;
|
||||
@@ -116,12 +116,12 @@ SettingsMachine::SettingsMachine(QWidget *parent)
|
||||
selectedMachineType = row;
|
||||
}
|
||||
|
||||
i = machine_get_type(j);
|
||||
i = machine_get_type(j);
|
||||
cur_j = 0;
|
||||
}
|
||||
|
||||
if (machine_available(j)) {
|
||||
QStandardItem* item = new QStandardItem(machines[j].name);
|
||||
QStandardItem *item = new QStandardItem(machines[j].name);
|
||||
item->setData(machine_types[machine_get_type(j)].id);
|
||||
machineListModel->appendRow(item);
|
||||
|
||||
@@ -137,10 +137,10 @@ SettingsMachine::SettingsMachine(QWidget *parent)
|
||||
ui->radioButtonLargerFrames->setChecked(force_10ms);
|
||||
ui->radioButtonSmallerFrames->setChecked(!force_10ms);
|
||||
|
||||
connect(machineListCompleter, QOverload<const QModelIndex &>::of(&QCompleter::activated), this, [this] (const QModelIndex& idx) {
|
||||
connect(machineListCompleter, QOverload<const QModelIndex &>::of(&QCompleter::activated), this, [this](const QModelIndex &idx) {
|
||||
ui->lineEditSearch->setText("");
|
||||
int machineIdType = idx.model()->data(idx, Qt::UserRole + 1).toInt();
|
||||
auto name = idx.model()->data(idx, Qt::DisplayRole).toString();
|
||||
int machineIdType = idx.model()->data(idx, Qt::UserRole + 1).toInt();
|
||||
auto name = idx.model()->data(idx, Qt::DisplayRole).toString();
|
||||
for (int i = 0; i < ui->comboBoxMachineType->model()->rowCount(); i++) {
|
||||
if (ui->comboBoxMachineType->model()->data(ui->comboBoxMachineType->model()->index(i, 0), Qt::UserRole).toInt() == machineIdType) {
|
||||
ui->comboBoxMachineType->setCurrentIndex(i);
|
||||
@@ -215,8 +215,7 @@ SettingsMachine::on_comboBoxMachineType_currentIndexChanged(int index)
|
||||
|
||||
int selectedMachineRow = 0;
|
||||
for (int i = 0; i < machine_count(); ++i) {
|
||||
if ((machine_get_type(i) == ui->comboBoxMachineType->currentData().toInt()) &&
|
||||
machine_available(i)) {
|
||||
if ((machine_get_type(i) == ui->comboBoxMachineType->currentData().toInt()) && machine_available(i)) {
|
||||
int row = Models::AddEntry(model, machines[i].name, i);
|
||||
if (i == machine)
|
||||
selectedMachineRow = row - removeRows;
|
||||
@@ -246,8 +245,7 @@ SettingsMachine::on_comboBoxMachine_currentIndexChanged(int index)
|
||||
int selectedCpuFamilyRow = 0;
|
||||
while (cpu_families[i].package != 0) {
|
||||
if (cpu_family_is_eligible(&cpu_families[i], machineId)) {
|
||||
Models::AddEntry(modelCpu, QString("%1 %2").arg(cpu_families[i].manufacturer,
|
||||
cpu_families[i].name), i);
|
||||
Models::AddEntry(modelCpu, QString("%1 %2").arg(cpu_families[i].manufacturer, cpu_families[i].name), i);
|
||||
if (&cpu_families[i] == cpu_f)
|
||||
selectedCpuFamilyRow = eligibleRows;
|
||||
++eligibleRows;
|
||||
@@ -346,7 +344,7 @@ SettingsMachine::on_comboBoxSpeed_currentIndexChanged(int index)
|
||||
|
||||
int i = 0;
|
||||
int selectedFpuRow = 0;
|
||||
for (const char *fpuName = fpu_get_name_from_index(cpuFamily, cpuId, i);
|
||||
for (const char *fpuName = fpu_get_name_from_index(cpuFamily, cpuId, i);
|
||||
fpuName != nullptr; fpuName = fpu_get_name_from_index(cpuFamily, cpuId, ++i)) {
|
||||
auto fpuType = fpu_get_type_from_index(cpuFamily, cpuId, i);
|
||||
Models::AddEntry(modelFpu, tr(QString("%1").arg(fpuName).toUtf8().data()), fpuType);
|
||||
@@ -374,10 +372,8 @@ SettingsMachine::on_comboBoxFPU_currentIndexChanged(int index)
|
||||
ui->checkBoxFPUSoftfloat->setChecked(false);
|
||||
ui->checkBoxFPUSoftfloat->setEnabled(false);
|
||||
} else {
|
||||
ui->checkBoxFPUSoftfloat->setChecked(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ?
|
||||
true : fpu_softfloat);
|
||||
ui->checkBoxFPUSoftfloat->setEnabled(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ?
|
||||
false : true);
|
||||
ui->checkBoxFPUSoftfloat->setChecked(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ? true : fpu_softfloat);
|
||||
ui->checkBoxFPUSoftfloat->setEnabled(machine_has_flags(machineId, MACHINE_SOFTFLOAT_ONLY) ? false : true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,8 +387,10 @@ SettingsMachine::on_pushButtonConfigure_clicked()
|
||||
DeviceConfig::ConfigureDevice(device);
|
||||
}
|
||||
|
||||
void SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state) {
|
||||
if(state == Qt::Checked) {
|
||||
void
|
||||
SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state)
|
||||
{
|
||||
if (state == Qt::Checked) {
|
||||
ui->softFloatWarningIcon->setVisible(true);
|
||||
ui->softFloatWarningText->setVisible(true);
|
||||
} else {
|
||||
@@ -401,13 +399,14 @@ void SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state) {
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsMachine::on_radioButtonSmallerFrames_clicked()
|
||||
void
|
||||
SettingsMachine::on_radioButtonSmallerFrames_clicked()
|
||||
{
|
||||
ui->radioButtonLargerFrames->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
void SettingsMachine::on_radioButtonLargerFrames_clicked()
|
||||
void
|
||||
SettingsMachine::on_radioButtonLargerFrames_clicked()
|
||||
{
|
||||
ui->radioButtonSmallerFrames->setChecked(false);
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
auto *intf_label = findChild<QLabel *>(QString("labelIntf%1").arg(i + 1));
|
||||
auto *intf_cbox = findChild<QComboBox *>(QString("comboBoxIntf%1").arg(i + 1));
|
||||
|
||||
auto *conf_btn = findChild<QPushButton *>(QString("pushButtonConf%1").arg(i + 1));
|
||||
// auto *net_type_conf_btn = findChild<QPushButton *>(QString("pushButtonNetTypeConf%1").arg(i + 1));
|
||||
auto *conf_btn = findChild<QPushButton *>(QString("pushButtonConf%1").arg(i + 1));
|
||||
// auto *net_type_conf_btn = findChild<QPushButton *>(QString("pushButtonNetTypeConf%1").arg(i + 1));
|
||||
|
||||
auto *vde_socket_label = findChild<QLabel *>(QString("labelSocketVDENIC%1").arg(i + 1));
|
||||
auto *socket_line = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i + 1));
|
||||
@@ -51,14 +51,14 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
|
||||
// Switch group
|
||||
auto *switch_group_label = findChild<QLabel *>(QString("labelSwitch%1").arg(i + 1));
|
||||
// auto *switch_group_hlayout = findChild<QHBoxLayout *>(QString("HLayoutSwitch%1").arg(i + 1));
|
||||
// auto *switch_group_hspacer = findChild<QWidget *>(QString("horizontalSpacerSwitch%1").arg(i + 1));
|
||||
// auto *switch_group_hlayout = findChild<QHBoxLayout *>(QString("HLayoutSwitch%1").arg(i + 1));
|
||||
// auto *switch_group_hspacer = findChild<QWidget *>(QString("horizontalSpacerSwitch%1").arg(i + 1));
|
||||
auto *switch_group_value = findChild<QSpinBox *>(QString("spinnerSwitch%1").arg(i + 1));
|
||||
switch_group_value->setMinimum(1);
|
||||
switch_group_value->setMaximum(10);
|
||||
|
||||
// Promiscuous option
|
||||
auto *promisc_label = findChild<QLabel *>(QString("labelPromisc%1").arg(i + 1));
|
||||
auto *promisc_label = findChild<QLabel *>(QString("labelPromisc%1").arg(i + 1));
|
||||
auto *promisc_value = findChild<QCheckBox *>(QString("boxPromisc%1").arg(i + 1));
|
||||
|
||||
// Remote switch hostname
|
||||
@@ -68,7 +68,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
bridge_line->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_TAP);
|
||||
intf_cbox->setEnabled(net_type_cbox->currentData().toInt() == NET_TYPE_PCAP);
|
||||
conf_btn->setEnabled(network_card_has_config(nic_cbox->currentData().toInt()));
|
||||
// net_type_conf_btn->setEnabled(network_type_has_config(netType));
|
||||
// net_type_conf_btn->setEnabled(network_type_has_config(netType));
|
||||
|
||||
// NEW STUFF
|
||||
// Make all options invisible by default
|
||||
@@ -76,7 +76,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
// Switch group
|
||||
switch_group_label->setVisible(false);
|
||||
switch_group_value->setVisible(false);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
|
||||
// Promiscuous options
|
||||
promisc_label->setVisible(false);
|
||||
@@ -103,7 +103,7 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
intf_label->setVisible(false);
|
||||
|
||||
// Don't enable anything unless there's a nic selected
|
||||
if(nic_cbox->currentData().toInt() != 0) {
|
||||
if (nic_cbox->currentData().toInt() != 0) {
|
||||
// Then only enable as needed based on network type
|
||||
switch (net_type_cbox->currentData().toInt()) {
|
||||
#ifdef HAS_VDE
|
||||
@@ -138,15 +138,15 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETSWITCH
|
||||
case NET_TYPE_NMSWITCH:
|
||||
// option_list_label->setText("Local Switch Options");
|
||||
case NET_TYPE_NMSWITCH:
|
||||
// option_list_label->setText("Local Switch Options");
|
||||
option_list_label->setVisible(true);
|
||||
option_list_line->setVisible(true);
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(true);
|
||||
switch_group_value->setVisible(true);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
|
||||
// Promiscuous options
|
||||
promisc_label->setVisible(true);
|
||||
@@ -154,14 +154,14 @@ SettingsNetwork::enableElements(Ui::SettingsNetwork *ui)
|
||||
break;
|
||||
|
||||
case NET_TYPE_NRSWITCH:
|
||||
// option_list_label->setText("Remote Switch Options");
|
||||
// option_list_label->setText("Remote Switch Options");
|
||||
option_list_label->setVisible(true);
|
||||
option_list_line->setVisible(true);
|
||||
|
||||
// Switch group
|
||||
switch_group_label->setVisible(true);
|
||||
switch_group_value->setVisible(true);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
// switch_group_hspacer->setVisible(false);
|
||||
|
||||
// Hostname
|
||||
hostname_label->setVisible(true);
|
||||
@@ -204,12 +204,12 @@ void
|
||||
SettingsNetwork::save()
|
||||
{
|
||||
for (int i = 0; i < NET_CARD_MAX; ++i) {
|
||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxNIC%1").arg(i + 1));
|
||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxNIC%1").arg(i + 1));
|
||||
#ifdef HAS_VDE
|
||||
auto *socket_line = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i + 1));
|
||||
auto *socket_line = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i + 1));
|
||||
#endif
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
auto *bridge_line = findChild<QLineEdit *>(QString("bridgeTAPNIC%1").arg(i + 1));
|
||||
auto *bridge_line = findChild<QLineEdit *>(QString("bridgeTAPNIC%1").arg(i + 1));
|
||||
#endif
|
||||
net_cards_conf[i].device_num = cbox->currentData().toInt();
|
||||
cbox = findChild<QComboBox *>(QString("comboBoxNet%1").arg(i + 1));
|
||||
@@ -249,15 +249,15 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
{
|
||||
this->machineId = machineId;
|
||||
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
|
||||
// Network Card
|
||||
QComboBox *cbox_[NET_CARD_MAX] = { 0 };
|
||||
QAbstractItemModel *models[NET_CARD_MAX] = { 0 };
|
||||
int removeRows_[NET_CARD_MAX] = { 0 };
|
||||
int selectedRows[NET_CARD_MAX] = { 0 };
|
||||
int m_has_net = machine_has_flags(machineId, MACHINE_NIC);
|
||||
QComboBox *cbox_[NET_CARD_MAX] = { 0 };
|
||||
QAbstractItemModel *models[NET_CARD_MAX] = { 0 };
|
||||
int removeRows_[NET_CARD_MAX] = { 0 };
|
||||
int selectedRows[NET_CARD_MAX] = { 0 };
|
||||
int m_has_net = machine_has_flags(machineId, MACHINE_NIC);
|
||||
|
||||
for (uint8_t i = 0; i < NET_CARD_MAX; ++i) {
|
||||
cbox_[i] = findChild<QComboBox *>(QString("comboBoxNIC%1").arg(i + 1));
|
||||
@@ -286,7 +286,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
}
|
||||
}
|
||||
|
||||
c++;
|
||||
c++;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < NET_CARD_MAX; ++i) {
|
||||
@@ -308,17 +308,17 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
if (network_devmap.has_vde)
|
||||
Models::AddEntry(model, "VDE", NET_TYPE_VDE);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
Models::AddEntry(model, "TAP", NET_TYPE_TAP);
|
||||
#endif
|
||||
|
||||
#ifdef USE_NETSWITCH
|
||||
Models::AddEntry(model, "Local Switch", NET_TYPE_NMSWITCH);
|
||||
#ifdef ENABLE_NET_NRSWITCH
|
||||
# ifdef ENABLE_NET_NRSWITCH
|
||||
Models::AddEntry(model, "Remote Switch", NET_TYPE_NRSWITCH);
|
||||
#endif /* ENABLE_NET_NRSWITCH */
|
||||
#endif /* USE_NETSWITCH */
|
||||
# endif /* ENABLE_NET_NRSWITCH */
|
||||
#endif /* USE_NETSWITCH */
|
||||
|
||||
model->removeRows(0, removeRows);
|
||||
cbox->setCurrentIndex(cbox->findData(net_cards_conf[i].net_type));
|
||||
@@ -343,7 +343,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
if (net_cards_conf[i].net_type == NET_TYPE_VDE) {
|
||||
#ifdef HAS_VDE
|
||||
QString currentVdeSocket = net_cards_conf[i].host_dev_name;
|
||||
auto editline = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i+1));
|
||||
auto editline = findChild<QLineEdit *>(QString("socketVDENIC%1").arg(i + 1));
|
||||
editline->setText(currentVdeSocket);
|
||||
#else
|
||||
;
|
||||
@@ -351,7 +351,7 @@ SettingsNetwork::onCurrentMachineChanged(int machineId)
|
||||
#if defined(__unix__) || defined(__APPLE__)
|
||||
} else if (net_cards_conf[i].net_type == NET_TYPE_TAP) {
|
||||
QString currentTapDevice = net_cards_conf[i].host_dev_name;
|
||||
auto editline = findChild<QLineEdit *>(QString("bridgeTAPNIC%1").arg(i+1));
|
||||
auto editline = findChild<QLineEdit *>(QString("bridgeTAPNIC%1").arg(i + 1));
|
||||
editline->setText(currentTapDevice);
|
||||
#endif
|
||||
#ifdef USE_NETSWITCH
|
||||
|
||||
@@ -68,8 +68,8 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId)
|
||||
if (auto *cb = findChild<QComboBox *>(QString("comboBoxIsaRomCard%1").arg(i + 1)))
|
||||
cb->clear();
|
||||
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
|
||||
// ISA RTC Cards
|
||||
auto *model = ui->comboBoxRTC->model();
|
||||
@@ -127,8 +127,7 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId)
|
||||
isamem_cbox[i]->setEnabled(isamem_models[i]->rowCount() > 1);
|
||||
isamem_cbox[i]->setCurrentIndex(-1);
|
||||
isamem_cbox[i]->setCurrentIndex(isamem_selectedRows[i]);
|
||||
findChild<QPushButton *>(QString("pushButtonConfigureIsaMemCard%1").arg(i + 1))->setEnabled((isamem_type[i] != 0) &&
|
||||
isamem_has_config(isamem_type[i]) && machineHasIsa);
|
||||
findChild<QPushButton *>(QString("pushButtonConfigureIsaMemCard%1").arg(i + 1))->setEnabled((isamem_type[i] != 0) && isamem_has_config(isamem_type[i]) && machineHasIsa);
|
||||
}
|
||||
|
||||
// ISA ROM Expansion Cards
|
||||
@@ -168,8 +167,7 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId)
|
||||
isarom_cbox[i]->setEnabled(isarom_models[i]->rowCount() > 1);
|
||||
isarom_cbox[i]->setCurrentIndex(-1);
|
||||
isarom_cbox[i]->setCurrentIndex(isarom_selectedRows[i]);
|
||||
findChild<QPushButton *>(QString("pushButtonConfigureIsaRomCard%1").arg(i + 1))->setEnabled((isarom_type[i] != 0) &&
|
||||
isarom_has_config(isarom_type[i]) && machineHasIsa);
|
||||
findChild<QPushButton *>(QString("pushButtonConfigureIsaRomCard%1").arg(i + 1))->setEnabled((isarom_type[i] != 0) && isarom_has_config(isarom_type[i]) && machineHasIsa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,12 +346,14 @@ SettingsOtherPeripherals::on_pushButtonConfigureUT_clicked()
|
||||
DeviceConfig::ConfigureDevice(&unittester_device);
|
||||
}
|
||||
|
||||
void SettingsOtherPeripherals::on_checkBoxKeyCard_stateChanged(int arg1)
|
||||
void
|
||||
SettingsOtherPeripherals::on_checkBoxKeyCard_stateChanged(int arg1)
|
||||
{
|
||||
ui->pushButtonConfigureKeyCard->setEnabled(arg1 != 0);
|
||||
}
|
||||
|
||||
void SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked()
|
||||
void
|
||||
SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked()
|
||||
{
|
||||
DeviceConfig::ConfigureDevice(&novell_keycard_device);
|
||||
}
|
||||
|
||||
@@ -32,15 +32,13 @@ extern "C" {
|
||||
static QString
|
||||
moDriveTypeName(int i)
|
||||
{
|
||||
return QString("%1 %2 %3").arg(mo_drive_types[i].vendor, mo_drive_types[i].model,
|
||||
mo_drive_types[i].revision);
|
||||
return QString("%1 %2 %3").arg(mo_drive_types[i].vendor, mo_drive_types[i].model, mo_drive_types[i].revision);
|
||||
}
|
||||
|
||||
static QString
|
||||
rdiskDriveTypeName(int i)
|
||||
{
|
||||
return QString("%1 %2 %3").arg(rdisk_drive_types[i].vendor, rdisk_drive_types[i].model,
|
||||
rdisk_drive_types[i].revision);
|
||||
return QString("%1 %2 %3").arg(rdisk_drive_types[i].vendor, rdisk_drive_types[i].model, rdisk_drive_types[i].revision);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -120,7 +118,7 @@ SettingsOtherRemovable::SettingsOtherRemovable(QWidget *parent)
|
||||
ui->setupUi(this);
|
||||
|
||||
mo_disabled_icon = QIcon(":/settings/qt/icons/mo_disabled.ico");
|
||||
mo_icon = QIcon(":/settings/qt/icons/mo.ico");
|
||||
mo_icon = QIcon(":/settings/qt/icons/mo.ico");
|
||||
|
||||
Harddrives::populateRemovableBuses(ui->comboBoxMOBus->model());
|
||||
ui->comboBoxMOBus->model()->removeRows(3, ui->comboBoxMOBus->model()->rowCount() - 3);
|
||||
@@ -147,11 +145,11 @@ SettingsOtherRemovable::SettingsOtherRemovable(QWidget *parent)
|
||||
ui->tableViewMO->setCurrentIndex(model->index(0, 0));
|
||||
|
||||
rdisk_disabled_icon = QIcon(":/settings/qt/icons/rdisk_disabled.ico");
|
||||
rdisk_icon = QIcon(":/settings/qt/icons/rdisk.ico");
|
||||
rdisk_icon = QIcon(":/settings/qt/icons/rdisk.ico");
|
||||
|
||||
Harddrives::populateRemovableBuses(ui->comboBoxRDiskBus->model());
|
||||
if ((ui->comboBoxRDiskBus->model()->rowCount() - 3) > 0)
|
||||
ui->comboBoxRDiskBus->model()->removeRows(3, ui->comboBoxRDiskBus->model()->rowCount() - 3);
|
||||
ui->comboBoxRDiskBus->model()->removeRows(3, ui->comboBoxRDiskBus->model()->rowCount() - 3);
|
||||
model = ui->comboBoxRDiskType->model();
|
||||
for (uint32_t i = 0; i < KNOWN_RDISK_DRIVE_TYPES; i++) {
|
||||
Models::AddEntry(model, rdiskDriveTypeName(i), i);
|
||||
@@ -245,7 +243,8 @@ SettingsOtherRemovable::onRDiskRowChanged(const QModelIndex ¤t)
|
||||
}
|
||||
|
||||
void
|
||||
SettingsOtherRemovable::reloadBusChannels_MO() {
|
||||
SettingsOtherRemovable::reloadBusChannels_MO()
|
||||
{
|
||||
auto selected = ui->comboBoxMOChannel->currentIndex();
|
||||
Harddrives::populateBusChannels(ui->comboBoxMOChannel->model(),
|
||||
ui->comboBoxMOBus->currentData().toInt(), Harddrives::busTrackClass);
|
||||
@@ -254,7 +253,8 @@ SettingsOtherRemovable::reloadBusChannels_MO() {
|
||||
}
|
||||
|
||||
void
|
||||
SettingsOtherRemovable::reloadBusChannels_RDisk() {
|
||||
SettingsOtherRemovable::reloadBusChannels_RDisk()
|
||||
{
|
||||
auto selected = ui->comboBoxRDiskChannel->currentIndex();
|
||||
Harddrives::populateBusChannels(ui->comboBoxRDiskChannel->model(),
|
||||
ui->comboBoxRDiskBus->currentData().toInt(), Harddrives::busTrackClass);
|
||||
@@ -290,12 +290,8 @@ void
|
||||
SettingsOtherRemovable::on_comboBoxMOBus_activated(int)
|
||||
{
|
||||
auto i = ui->tableViewMO->selectionModel()->currentIndex().siblingAtColumn(0);
|
||||
Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
ui->comboBoxMOChannel->setCurrentIndex(ui->comboBoxMOBus->currentData().toUInt() == MO_BUS_ATAPI ?
|
||||
Harddrives::busTrackClass->next_free_ide_channel() :
|
||||
Harddrives::busTrackClass->next_free_scsi_id());
|
||||
Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
ui->comboBoxMOChannel->setCurrentIndex(ui->comboBoxMOBus->currentData().toUInt() == MO_BUS_ATAPI ? Harddrives::busTrackClass->next_free_ide_channel() : Harddrives::busTrackClass->next_free_scsi_id());
|
||||
ui->tableViewMO->model()->data(i, Qt::UserRole + 1);
|
||||
setMOBus(ui->tableViewMO->model(),
|
||||
ui->tableViewMO->selectionModel()->currentIndex(),
|
||||
@@ -306,9 +302,7 @@ SettingsOtherRemovable::on_comboBoxMOBus_activated(int)
|
||||
ui->comboBoxMOType->currentData().toUInt());
|
||||
ui->tableViewMO->resizeColumnsToContents();
|
||||
ui->tableViewMO->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
emit moChannelChanged();
|
||||
}
|
||||
|
||||
@@ -316,12 +310,8 @@ void
|
||||
SettingsOtherRemovable::on_comboBoxRDiskBus_activated(int)
|
||||
{
|
||||
auto i = ui->tableViewRDisk->selectionModel()->currentIndex().siblingAtColumn(0);
|
||||
Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
ui->comboBoxRDiskChannel->setCurrentIndex(ui->comboBoxRDiskBus->currentData().toUInt() == RDISK_BUS_ATAPI ?
|
||||
Harddrives::busTrackClass->next_free_ide_channel() :
|
||||
Harddrives::busTrackClass->next_free_scsi_id());
|
||||
Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
ui->comboBoxRDiskChannel->setCurrentIndex(ui->comboBoxRDiskBus->currentData().toUInt() == RDISK_BUS_ATAPI ? Harddrives::busTrackClass->next_free_ide_channel() : Harddrives::busTrackClass->next_free_scsi_id());
|
||||
ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1);
|
||||
setRDiskBus(ui->tableViewRDisk->model(),
|
||||
ui->tableViewRDisk->selectionModel()->currentIndex(),
|
||||
@@ -332,18 +322,16 @@ SettingsOtherRemovable::on_comboBoxRDiskBus_activated(int)
|
||||
ui->comboBoxRDiskType->currentData().toUInt());
|
||||
ui->tableViewRDisk->resizeColumnsToContents();
|
||||
ui->tableViewRDisk->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
emit rdiskChannelChanged();
|
||||
}
|
||||
|
||||
void
|
||||
SettingsOtherRemovable::enableCurrentlySelectedChannel_MO()
|
||||
{
|
||||
const auto *item_model = qobject_cast<QStandardItemModel*>(ui->comboBoxMOChannel->model());
|
||||
const auto index = ui->comboBoxMOChannel->currentIndex();
|
||||
auto *item = item_model->item(index);
|
||||
const auto *item_model = qobject_cast<QStandardItemModel *>(ui->comboBoxMOChannel->model());
|
||||
const auto index = ui->comboBoxMOChannel->currentIndex();
|
||||
auto *item = item_model->item(index);
|
||||
if (item)
|
||||
item->setEnabled(true);
|
||||
}
|
||||
@@ -351,9 +339,9 @@ SettingsOtherRemovable::enableCurrentlySelectedChannel_MO()
|
||||
void
|
||||
SettingsOtherRemovable::enableCurrentlySelectedChannel_RDisk()
|
||||
{
|
||||
const auto *item_model = qobject_cast<QStandardItemModel*>(ui->comboBoxRDiskChannel->model());
|
||||
const auto index = ui->comboBoxRDiskChannel->currentIndex();
|
||||
auto *item = item_model->item(index);
|
||||
const auto *item_model = qobject_cast<QStandardItemModel *>(ui->comboBoxRDiskChannel->model());
|
||||
const auto index = ui->comboBoxRDiskChannel->currentIndex();
|
||||
auto *item = item_model->item(index);
|
||||
if (item)
|
||||
item->setEnabled(true);
|
||||
}
|
||||
@@ -361,16 +349,12 @@ void
|
||||
SettingsOtherRemovable::on_comboBoxMOChannel_activated(int)
|
||||
{
|
||||
auto i = ui->tableViewMO->selectionModel()->currentIndex().siblingAtColumn(0);
|
||||
Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(0, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
setMOBus(ui->tableViewMO->model(),
|
||||
ui->tableViewMO->selectionModel()->currentIndex(),
|
||||
ui->comboBoxMOBus->currentData().toUInt(),
|
||||
ui->comboBoxMOChannel->currentData().toUInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_MO, ui->tableViewMO->model()->data(i, Qt::UserRole).toInt(), ui->tableViewMO->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
emit moChannelChanged();
|
||||
}
|
||||
|
||||
@@ -378,15 +362,12 @@ void
|
||||
SettingsOtherRemovable::on_comboBoxRDiskChannel_activated(int)
|
||||
{
|
||||
auto i = ui->tableViewRDisk->selectionModel()->currentIndex().siblingAtColumn(0);
|
||||
Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i,
|
||||
Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i,
|
||||
Qt::UserRole + 1).toInt());
|
||||
Harddrives::busTrackClass->device_track(0, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(), ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
setRDiskBus(ui->tableViewRDisk->model(),
|
||||
ui->tableViewRDisk->selectionModel()->currentIndex(),
|
||||
ui->comboBoxRDiskBus->currentData().toUInt(),
|
||||
ui->comboBoxRDiskChannel->currentData().toUInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i,
|
||||
Qt::UserRole).toInt(),
|
||||
ui->tableViewRDisk->selectionModel()->currentIndex(),
|
||||
ui->comboBoxRDiskBus->currentData().toUInt(),
|
||||
ui->comboBoxRDiskChannel->currentData().toUInt());
|
||||
Harddrives::busTrackClass->device_track(1, DEV_RDISK, ui->tableViewRDisk->model()->data(i, Qt::UserRole).toInt(),
|
||||
ui->tableViewRDisk->model()->data(i, Qt::UserRole + 1).toInt());
|
||||
emit rdiskChannelChanged();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::SettingsOtherRemovable *ui;
|
||||
|
||||
void setMOBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel);
|
||||
void setRDiskBus(QAbstractItemModel *model, const QModelIndex &idx, uint8_t bus, uint8_t channel);
|
||||
void enableCurrentlySelectedChannel_MO();
|
||||
|
||||
@@ -53,7 +53,7 @@ SettingsPorts::save()
|
||||
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
|
||||
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
|
||||
if (cbox != NULL)
|
||||
lpt_ports[i].device = cbox->currentData().toInt();
|
||||
lpt_ports[i].device = cbox->currentData().toInt();
|
||||
if (checkBox != NULL)
|
||||
lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
|
||||
}
|
||||
@@ -73,21 +73,20 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
|
||||
{
|
||||
this->machineId = machineId;
|
||||
|
||||
int c = 0;
|
||||
int c = 0;
|
||||
|
||||
auto *lptEcpDmaModel = ui->comboBoxLptECPDMA->model();
|
||||
auto removeRowsEcpDma = lptEcpDmaModel->rowCount();
|
||||
|
||||
int has_jumpers = !!machine_has_jumpered_ecp_dma(machineId, DMA_ANY);
|
||||
int has_jumpers = !!machine_has_jumpered_ecp_dma(machineId, DMA_ANY);
|
||||
|
||||
int selectedRow = -2;
|
||||
int first = -2;
|
||||
int selectedRow = -2;
|
||||
int first = -2;
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
int j = machine_map_jumpered_ecp_dma(i);
|
||||
int j = machine_map_jumpered_ecp_dma(i);
|
||||
|
||||
if ((has_jumpers && ((j == DMA_NONE) || !machine_has_jumpered_ecp_dma(machineId, j))) ||
|
||||
(!has_jumpers && (j != DMA_NONE)))
|
||||
if ((has_jumpers && ((j == DMA_NONE) || !machine_has_jumpered_ecp_dma(machineId, j))) || (!has_jumpers && (j != DMA_NONE)))
|
||||
continue;
|
||||
|
||||
if (first == -2)
|
||||
@@ -122,7 +121,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
|
||||
c = 0;
|
||||
|
||||
// LPT Device
|
||||
QComboBox * cbox[PARALLEL_MAX] = { 0 };
|
||||
QComboBox *cbox[PARALLEL_MAX] = { 0 };
|
||||
QAbstractItemModel *models[PARALLEL_MAX] = { 0 };
|
||||
int removeRows_[PARALLEL_MAX] = { 0 };
|
||||
int selectedRows[PARALLEL_MAX] = { 0 };
|
||||
@@ -134,12 +133,12 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
|
||||
}
|
||||
|
||||
while (true) {
|
||||
const char *lptName = lpt_device_get_name(c);
|
||||
const char *lptName = lpt_device_get_name(c);
|
||||
|
||||
if (lptName == nullptr)
|
||||
break;
|
||||
|
||||
const QString name = tr(lptName);
|
||||
const QString name = tr(lptName);
|
||||
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
||||
int row = Models::AddEntry(models[i], name, c);
|
||||
@@ -148,7 +147,7 @@ SettingsPorts::onCurrentMachineChanged(int machineId)
|
||||
selectedRows[i] = row - removeRows_[i];
|
||||
}
|
||||
|
||||
c++;
|
||||
c++;
|
||||
}
|
||||
|
||||
for (uint8_t i = 0; i < PARALLEL_MAX; ++i) {
|
||||
|
||||
@@ -71,8 +71,8 @@ SettingsSound::onCurrentMachineChanged(const int machineId)
|
||||
{
|
||||
this->machineId = machineId;
|
||||
|
||||
int c;
|
||||
int selectedRow;
|
||||
int c;
|
||||
int selectedRow;
|
||||
|
||||
// Sound Cards
|
||||
QComboBox *cbox[SOUND_CARD_MAX] = { 0 };
|
||||
@@ -119,10 +119,10 @@ SettingsSound::onCurrentMachineChanged(const int machineId)
|
||||
}
|
||||
|
||||
// Midi Out
|
||||
c = 0;
|
||||
auto *model = ui->comboBoxMidiOut->model();
|
||||
auto removeRows = model->rowCount();
|
||||
selectedRow = 0;
|
||||
c = 0;
|
||||
auto *model = ui->comboBoxMidiOut->model();
|
||||
auto removeRows = model->rowCount();
|
||||
selectedRow = 0;
|
||||
|
||||
while (true) {
|
||||
const QString name = DeviceConfig::DeviceName(midi_out_device_getdevice(c), midi_out_device_get_internal_name(c), 0);
|
||||
@@ -210,8 +210,7 @@ SettingsSound::on_comboBoxSoundCard1_currentIndexChanged(int index)
|
||||
int sndCard = ui->comboBoxSoundCard1->currentData().toInt();
|
||||
|
||||
if (sndCard == SOUND_INTERNAL)
|
||||
ui->pushButtonConfigureSoundCard1->setEnabled(machine_has_flags(machineId, MACHINE_SOUND) &&
|
||||
device_has_config(machine_get_snd_device(machineId)));
|
||||
ui->pushButtonConfigureSoundCard1->setEnabled(machine_has_flags(machineId, MACHINE_SOUND) && device_has_config(machine_get_snd_device(machineId)));
|
||||
else
|
||||
ui->pushButtonConfigureSoundCard1->setEnabled(sound_card_has_config(sndCard));
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ SettingsStorageControllers::save()
|
||||
{
|
||||
/* Storage devices category */
|
||||
for (uint8_t i = 0; i < HDC_MAX; ++i) {
|
||||
QComboBox *cbox = findChild<QComboBox *>(QString("comboBoxHD%1").arg(i + 1));
|
||||
hdc_current[i] = cbox->currentData().toInt();
|
||||
QComboBox *cbox = findChild<QComboBox *>(QString("comboBoxHD%1").arg(i + 1));
|
||||
hdc_current[i] = cbox->currentData().toInt();
|
||||
}
|
||||
for (uint8_t i = 0; i < SCSI_CARD_MAX; ++i) {
|
||||
QComboBox *cbox = findChild<QComboBox *>(QString("comboBoxSCSI%1").arg(i + 1));
|
||||
@@ -140,10 +140,10 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId)
|
||||
ui->comboBoxCDInterface->setCurrentIndex(selectedRow);
|
||||
|
||||
// HD Controller
|
||||
QComboBox * hd_cbox[HDC_MAX] = { 0 };
|
||||
QAbstractItemModel *hd_models[HDC_MAX] = { 0 };
|
||||
int hd_removeRows_[HDC_MAX] = { 0 };
|
||||
int hd_selectedRows[HDC_MAX] = { 0 };
|
||||
QComboBox *hd_cbox[HDC_MAX] = { 0 };
|
||||
QAbstractItemModel *hd_models[HDC_MAX] = { 0 };
|
||||
int hd_removeRows_[HDC_MAX] = { 0 };
|
||||
int hd_selectedRows[HDC_MAX] = { 0 };
|
||||
|
||||
for (uint8_t i = 0; i < HDC_MAX; ++i) {
|
||||
hd_cbox[i] = findChild<QComboBox *>(QString("comboBoxHD%1").arg(i + 1));
|
||||
@@ -185,7 +185,7 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId)
|
||||
}
|
||||
|
||||
// SCSI Card
|
||||
QComboBox * cbox[SCSI_CARD_MAX] = { 0 };
|
||||
QComboBox *cbox[SCSI_CARD_MAX] = { 0 };
|
||||
QAbstractItemModel *models[SCSI_CARD_MAX] = { 0 };
|
||||
int removeRows_[SCSI_CARD_MAX] = { 0 };
|
||||
int selectedRows[SCSI_CARD_MAX] = { 0 };
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
#include "qt_singlekeyseqedit.hpp"
|
||||
|
||||
/*
|
||||
This subclass of QKeySequenceEdit restricts the input to only a single
|
||||
shortcut instead of an unlimited number with a fixed timeout.
|
||||
This subclass of QKeySequenceEdit restricts the input to only a single
|
||||
shortcut instead of an unlimited number with a fixed timeout.
|
||||
*/
|
||||
|
||||
singleKeySequenceEdit::singleKeySequenceEdit(QWidget *parent) : QKeySequenceEdit(parent) {}
|
||||
singleKeySequenceEdit::singleKeySequenceEdit(QWidget *parent)
|
||||
: QKeySequenceEdit(parent)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void singleKeySequenceEdit::keyPressEvent(QKeyEvent *event)
|
||||
void
|
||||
singleKeySequenceEdit::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QKeySequenceEdit::keyPressEvent(event);
|
||||
if (this->keySequence().count() > 0) {
|
||||
QKeySequenceEdit::setKeySequence(this->keySequence());
|
||||
|
||||
// This could have unintended consequences since it will happen
|
||||
// every single time the user presses a key.
|
||||
|
||||
// This could have unintended consequences since it will happen
|
||||
// every single time the user presses a key.
|
||||
emit editingFinished();
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,7 @@
|
||||
#include <QKeySequenceEdit>
|
||||
#include <QWidget>
|
||||
|
||||
class singleKeySequenceEdit : public QKeySequenceEdit
|
||||
{
|
||||
class singleKeySequenceEdit : public QKeySequenceEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
singleKeySequenceEdit(QWidget *parent = nullptr);
|
||||
|
||||
@@ -30,7 +30,8 @@ SoftwareRenderer::SoftwareRenderer(QWidget *parent)
|
||||
#ifdef __HAIKU__
|
||||
: QWidget(parent)
|
||||
#else
|
||||
: QWindow(parent->windowHandle()), m_backingStore(new QBackingStore(this))
|
||||
: QWindow(parent->windowHandle())
|
||||
, m_backingStore(new QBackingStore(this))
|
||||
#endif
|
||||
{
|
||||
RendererCommon::parentWidget = parent;
|
||||
@@ -72,7 +73,7 @@ SoftwareRenderer::render()
|
||||
}
|
||||
|
||||
void
|
||||
SoftwareRenderer::exposeEvent(QExposeEvent* event)
|
||||
SoftwareRenderer::exposeEvent(QExposeEvent *event)
|
||||
{
|
||||
render();
|
||||
}
|
||||
@@ -81,7 +82,7 @@ void
|
||||
SoftwareRenderer::onBlit(int buf_idx, int x, int y, int w, int h)
|
||||
{
|
||||
/* TODO: should look into deleteLater() */
|
||||
auto tval = this;
|
||||
auto tval = this;
|
||||
if ((void *) tval == nullptr)
|
||||
return;
|
||||
auto origSource = source;
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
#endif
|
||||
|
||||
void exposeEvent(QExposeEvent* event) override;
|
||||
void exposeEvent(QExposeEvent *event) override;
|
||||
|
||||
std::vector<std::tuple<uint8_t *, std::atomic_flag *>> getBuffers() override;
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ extern "C" {
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include <dwmapi.h>
|
||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||
#endif
|
||||
# include <dwmapi.h>
|
||||
# ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||
# define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int
|
||||
@@ -72,7 +72,7 @@ StyleOverride::polish(QWidget *widget)
|
||||
widget->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||
#ifdef Q_OS_WINDOWS
|
||||
BOOL DarkMode = !util::isWindowsLightTheme();
|
||||
DwmSetWindowAttribute((HWND)widget->winId(), DWMWA_USE_IMMERSIVE_DARK_MODE, (LPCVOID)&DarkMode, sizeof(DarkMode));
|
||||
DwmSetWindowAttribute((HWND) widget->winId(), DWMWA_USE_IMMERSIVE_DARK_MODE, (LPCVOID) &DarkMode, sizeof(DarkMode));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -111,7 +111,6 @@ StyleOverride::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
||||
color.setBlueF(avg);
|
||||
|
||||
image.setPixelColor(x, y, color);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
const QWidget *widget = nullptr,
|
||||
QStyleHintReturn *returnData = nullptr) const override;
|
||||
|
||||
void polish(QWidget *widget) override;
|
||||
void polish(QWidget *widget) override;
|
||||
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -153,10 +153,8 @@ plat_mouse_capture(int on)
|
||||
int
|
||||
ui_msgbox_header(int flags, void *header, void *message)
|
||||
{
|
||||
const auto hdr = (flags & MBX_ANSI) ? QString(static_cast<char *>(header)) :
|
||||
QString::fromWCharArray(static_cast<const wchar_t *>(header));
|
||||
const auto msg = (flags & MBX_ANSI) ? QString(static_cast<char *>(message)) :
|
||||
QString::fromWCharArray(static_cast<const wchar_t *>(message));
|
||||
const auto hdr = (flags & MBX_ANSI) ? QString(static_cast<char *>(header)) : QString::fromWCharArray(static_cast<const wchar_t *>(header));
|
||||
const auto msg = (flags & MBX_ANSI) ? QString(static_cast<char *>(message)) : QString::fromWCharArray(static_cast<const wchar_t *>(message));
|
||||
|
||||
// any error in early init
|
||||
if (main_window == nullptr) {
|
||||
@@ -259,9 +257,9 @@ ui_sb_set_ready(int ready)
|
||||
void
|
||||
ui_sb_update_icon_wp(int tag, int state)
|
||||
{
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
|
||||
switch (category) {
|
||||
default:
|
||||
@@ -287,9 +285,9 @@ ui_sb_update_icon_wp(int tag, int state)
|
||||
void
|
||||
ui_sb_update_icon_state(int tag, int state)
|
||||
{
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
|
||||
switch (category) {
|
||||
default:
|
||||
@@ -329,9 +327,9 @@ ui_sb_update_icon_state(int tag, int state)
|
||||
void
|
||||
ui_sb_update_icon(int tag, int active)
|
||||
{
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
|
||||
switch (category) {
|
||||
default:
|
||||
@@ -365,9 +363,9 @@ ui_sb_update_icon(int tag, int active)
|
||||
void
|
||||
ui_sb_update_icon_write(int tag, int write)
|
||||
{
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
const auto temp = static_cast<unsigned int>(tag);
|
||||
const int category = static_cast<int>(temp & 0xfffffff0);
|
||||
const int item = tag & 0xf;
|
||||
|
||||
switch (category) {
|
||||
default:
|
||||
@@ -397,5 +395,4 @@ ui_sb_update_icon_write(int tag, int write)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ extern "C" {
|
||||
}
|
||||
|
||||
UpdateCheck::
|
||||
UpdateCheck(const UpdateChannel channel, QObject *parent) : QObject(parent)
|
||||
UpdateCheck(const UpdateChannel channel, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
updateChannel = channel;
|
||||
updateChannel = channel;
|
||||
currentVersion = getCurrentVersion(channel);
|
||||
}
|
||||
|
||||
UpdateCheck::~
|
||||
UpdateCheck()
|
||||
UpdateCheck::~UpdateCheck()
|
||||
= default;
|
||||
|
||||
void
|
||||
@@ -56,35 +56,35 @@ UpdateCheck::checkForUpdates()
|
||||
void
|
||||
UpdateCheck::jenkinsDownloadComplete(const QString &filename, const QVariant &varData)
|
||||
{
|
||||
auto generalError = tr("Unable to determine release information");
|
||||
auto generalError = tr("Unable to determine release information");
|
||||
auto jenkinsReleaseListResult = parseJenkinsJson(filename);
|
||||
auto latestVersion = 0; // NOLINT (Default value as a fallback)
|
||||
auto latestVersion = 0; // NOLINT (Default value as a fallback)
|
||||
|
||||
if(!jenkinsReleaseListResult.has_value() || jenkinsReleaseListResult.value().isEmpty()) {
|
||||
if (!jenkinsReleaseListResult.has_value() || jenkinsReleaseListResult.value().isEmpty()) {
|
||||
generalDownloadError(generalError);
|
||||
return;
|
||||
}
|
||||
const auto jenkinsReleaseList = jenkinsReleaseListResult.value();
|
||||
latestVersion = jenkinsReleaseListResult->first().buildNumber;
|
||||
latestVersion = jenkinsReleaseListResult->first().buildNumber;
|
||||
|
||||
// If we can't determine the local build (blank current version), always show an update as available.
|
||||
// Callers can adjust accordingly.
|
||||
// Otherwise, do a comparison with EMU_BUILD_NUM
|
||||
bool updateAvailable = false;
|
||||
bool upToDate = true;
|
||||
if(currentVersion.isEmpty() || EMU_BUILD_NUM < latestVersion) {
|
||||
bool upToDate = true;
|
||||
if (currentVersion.isEmpty() || EMU_BUILD_NUM < latestVersion) {
|
||||
updateAvailable = true;
|
||||
upToDate = false;
|
||||
upToDate = false;
|
||||
}
|
||||
|
||||
const auto updateResult = UpdateResult {
|
||||
.channel = updateChannel,
|
||||
.channel = updateChannel,
|
||||
.updateAvailable = updateAvailable,
|
||||
.upToDate = upToDate,
|
||||
.currentVersion = currentVersion,
|
||||
.latestVersion = QString::number(latestVersion),
|
||||
.githubInfo = {},
|
||||
.jenkinsInfo = jenkinsReleaseList,
|
||||
.upToDate = upToDate,
|
||||
.currentVersion = currentVersion,
|
||||
.latestVersion = QString::number(latestVersion),
|
||||
.githubInfo = {},
|
||||
.jenkinsInfo = jenkinsReleaseList,
|
||||
};
|
||||
|
||||
emit updateCheckComplete(updateResult);
|
||||
@@ -101,8 +101,8 @@ UpdateCheck::githubDownloadComplete(const QString &filename, const QVariant &var
|
||||
{
|
||||
const auto generalError = tr("Unable to determine release information");
|
||||
const auto githubReleaseListResult = parseGithubJson(filename);
|
||||
QString latestVersion = "0.0";
|
||||
if(!githubReleaseListResult.has_value() || githubReleaseListResult.value().isEmpty()) {
|
||||
QString latestVersion = "0.0";
|
||||
if (!githubReleaseListResult.has_value() || githubReleaseListResult.value().isEmpty()) {
|
||||
generalDownloadError(generalError);
|
||||
}
|
||||
auto githubReleaseList = githubReleaseListResult.value();
|
||||
@@ -111,30 +111,29 @@ UpdateCheck::githubDownloadComplete(const QString &filename, const QVariant &var
|
||||
// Another option would be parsing the name field which is generally "86Box <number>" but
|
||||
// either option requires a consistent naming scheme.
|
||||
latestVersion = githubReleaseList.first().tag_name.replace("v", "");
|
||||
for (const auto &release: githubReleaseList) {
|
||||
for (const auto &release : githubReleaseList) {
|
||||
qDebug().noquote().nospace() << release.name << ": " << release.html_url << " (" << release.created_at << ")";
|
||||
}
|
||||
|
||||
// const auto updateDetails = new UpdateDetails(githubReleaseList, currentVersion);
|
||||
bool updateAvailable = false;
|
||||
bool upToDate = true;
|
||||
if(currentVersion.isEmpty() || (versionCompare(currentVersion, latestVersion) < 0)) {
|
||||
bool upToDate = true;
|
||||
if (currentVersion.isEmpty() || (versionCompare(currentVersion, latestVersion) < 0)) {
|
||||
updateAvailable = true;
|
||||
upToDate = false;
|
||||
upToDate = false;
|
||||
}
|
||||
|
||||
const auto updateResult = UpdateResult {
|
||||
.channel = updateChannel,
|
||||
.channel = updateChannel,
|
||||
.updateAvailable = updateAvailable,
|
||||
.upToDate = upToDate,
|
||||
.currentVersion = currentVersion,
|
||||
.latestVersion = latestVersion,
|
||||
.githubInfo = githubReleaseList,
|
||||
.jenkinsInfo = {},
|
||||
.upToDate = upToDate,
|
||||
.currentVersion = currentVersion,
|
||||
.latestVersion = latestVersion,
|
||||
.githubInfo = githubReleaseList,
|
||||
.jenkinsInfo = {},
|
||||
};
|
||||
|
||||
emit updateCheckComplete(updateResult);
|
||||
|
||||
}
|
||||
|
||||
QUrl
|
||||
@@ -148,7 +147,7 @@ QString
|
||||
UpdateCheck::getCurrentVersion(const UpdateChannel &updateChannel)
|
||||
{
|
||||
if (updateChannel == UpdateChannel::Stable) {
|
||||
return {EMU_VERSION};
|
||||
return { EMU_VERSION };
|
||||
}
|
||||
// If EMU_BUILD_NUM is anything other than the default of zero it was set by the build process
|
||||
if constexpr (EMU_BUILD_NUM != 0) {
|
||||
@@ -162,7 +161,7 @@ std::optional<QList<UpdateCheck::JenkinsReleaseInfo>>
|
||||
UpdateCheck::parseJenkinsJson(const QString &filename)
|
||||
{
|
||||
QList<JenkinsReleaseInfo> releaseInfoList;
|
||||
QFile json_file(filename);
|
||||
QFile json_file(filename);
|
||||
if (!json_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qWarning() << "Couldn't open the json file: error" << json_file.error();
|
||||
return std::nullopt;
|
||||
@@ -186,15 +185,15 @@ UpdateCheck::parseJenkinsJson(const QString &filename)
|
||||
auto json_object = json_doc.object();
|
||||
|
||||
// The json contains multiple release
|
||||
if(json_object.contains("builds") && json_object["builds"].isArray()) {
|
||||
if (json_object.contains("builds") && json_object["builds"].isArray()) {
|
||||
|
||||
QJsonArray builds = json_object["builds"].toArray();
|
||||
for (const auto &each_build: builds) {
|
||||
for (const auto &each_build : builds) {
|
||||
if (auto build = parseJenkinsRelease(each_build.toObject()); build.has_value() && build.value().result == "SUCCESS") {
|
||||
releaseInfoList.append(build.value());
|
||||
}
|
||||
}
|
||||
} else if(json_object.contains("changeSets") && json_object["changeSets"].isArray()) {
|
||||
} else if (json_object.contains("changeSets") && json_object["changeSets"].isArray()) {
|
||||
// The json contains only one release, as obtained by the lastSuccessfulBuild api
|
||||
if (const auto build = parseJenkinsRelease(json_object); build.has_value()) {
|
||||
releaseInfoList.append(build.value());
|
||||
@@ -268,7 +267,7 @@ std::optional<QList<UpdateCheck::GithubReleaseInfo>>
|
||||
UpdateCheck::parseGithubJson(const QString &filename)
|
||||
{
|
||||
QList<GithubReleaseInfo> releaseInfoList;
|
||||
QFile json_file(filename);
|
||||
QFile json_file(filename);
|
||||
if (!json_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qWarning("Couldn't open the json file: error %d", json_file.error());
|
||||
return std::nullopt;
|
||||
@@ -291,7 +290,7 @@ UpdateCheck::parseGithubJson(const QString &filename)
|
||||
|
||||
auto release_array = json_doc.array();
|
||||
|
||||
for (const auto &each_release: release_array) {
|
||||
for (const auto &each_release : release_array) {
|
||||
if (auto release = parseGithubRelease(each_release.toObject()); release.has_value()) {
|
||||
releaseInfoList.append(release.value());
|
||||
}
|
||||
|
||||
@@ -31,16 +31,16 @@ public:
|
||||
};
|
||||
|
||||
struct JenkinsChangeSetItem {
|
||||
QString buildId; // sha hash
|
||||
QString author; // github username
|
||||
QString message; // commit message
|
||||
QString buildId; // sha hash
|
||||
QString author; // github username
|
||||
QString message; // commit message
|
||||
QStringList affectedPaths; // list of files in the change
|
||||
};
|
||||
|
||||
struct JenkinsReleaseInfo {
|
||||
int buildNumber = 0;
|
||||
QString result;
|
||||
qint64 timestamp = 0;
|
||||
int buildNumber = 0;
|
||||
QString result;
|
||||
qint64 timestamp = 0;
|
||||
QList<JenkinsChangeSetItem> changeSetItems;
|
||||
};
|
||||
|
||||
@@ -55,19 +55,19 @@ public:
|
||||
};
|
||||
|
||||
struct UpdateResult {
|
||||
UpdateChannel channel;
|
||||
bool updateAvailable = false;
|
||||
bool upToDate = false;
|
||||
QString currentVersion;
|
||||
QString latestVersion;
|
||||
QList<GithubReleaseInfo> githubInfo;
|
||||
UpdateChannel channel;
|
||||
bool updateAvailable = false;
|
||||
bool upToDate = false;
|
||||
QString currentVersion;
|
||||
QString latestVersion;
|
||||
QList<GithubReleaseInfo> githubInfo;
|
||||
QList<JenkinsReleaseInfo> jenkinsInfo;
|
||||
};
|
||||
|
||||
explicit UpdateCheck(UpdateChannel channel, QObject *parent = nullptr);
|
||||
~UpdateCheck() override;
|
||||
void checkForUpdates();
|
||||
static int versionCompare(const QString &version1, const QString &version2);
|
||||
void checkForUpdates();
|
||||
static int versionCompare(const QString &version1, const QString &version2);
|
||||
[[nodiscard]] static QString getCurrentVersion(const UpdateChannel &updateChannel = UpdateChannel::Stable);
|
||||
|
||||
signals:
|
||||
@@ -86,15 +86,14 @@ private:
|
||||
static QUrl jenkinsLatestNReleasesUrl(const int &count);
|
||||
|
||||
static std::optional<QList<JenkinsReleaseInfo>> parseJenkinsJson(const QString &filename);
|
||||
static std::optional<JenkinsReleaseInfo> parseJenkinsRelease(const QJsonObject &json);
|
||||
static std::optional<JenkinsReleaseInfo> parseJenkinsRelease(const QJsonObject &json);
|
||||
|
||||
static std::optional<QList<GithubReleaseInfo>> parseGithubJson(const QString &filename);
|
||||
static std::optional<GithubReleaseInfo> parseGithubRelease(const QJsonObject &json);
|
||||
|
||||
static std::optional<GithubReleaseInfo> parseGithubRelease(const QJsonObject &json);
|
||||
|
||||
private slots:
|
||||
void jenkinsDownloadComplete(const QString &filename, const QVariant& varData);
|
||||
void githubDownloadComplete(const QString &filename, const QVariant& varData);
|
||||
void jenkinsDownloadComplete(const QString &filename, const QVariant &varData);
|
||||
void githubDownloadComplete(const QString &filename, const QVariant &varData);
|
||||
void generalDownloadError(const QString &error);
|
||||
};
|
||||
|
||||
|
||||
@@ -24,11 +24,14 @@ extern "C" {
|
||||
}
|
||||
|
||||
UpdateCheckDialog::
|
||||
UpdateCheckDialog(const UpdateCheck::UpdateChannel channel, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateCheckDialog), updateCheck(new UpdateCheck(channel))
|
||||
UpdateCheckDialog(const UpdateCheck::UpdateChannel channel, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::UpdateCheckDialog)
|
||||
, updateCheck(new UpdateCheck(channel))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->statusLabel->setHidden(true);
|
||||
updateChannel = channel;
|
||||
updateChannel = channel;
|
||||
currentVersion = UpdateCheck::getCurrentVersion(updateChannel);
|
||||
connect(updateCheck, &UpdateCheck::updateCheckError, [=](const QString &errorMsg) {
|
||||
generalDownloadError(errorMsg);
|
||||
@@ -40,8 +43,7 @@ UpdateCheckDialog(const UpdateCheck::UpdateChannel channel, QWidget *parent) : Q
|
||||
});
|
||||
}
|
||||
|
||||
UpdateCheckDialog::~
|
||||
UpdateCheckDialog()
|
||||
UpdateCheckDialog::~UpdateCheckDialog()
|
||||
= default;
|
||||
|
||||
void
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
UpdateDetails::
|
||||
UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) : QDialog(parent), ui(new Ui::UpdateDetails)
|
||||
UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::UpdateDetails)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->updateTitle->setText(tr("<b>An update to 86Box is available!</b>"));
|
||||
@@ -39,7 +40,7 @@ UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) :
|
||||
const auto updateDetailsText = QString("%1 %2%3").arg(latestVersionText, currentVersionText.append(' '), tr("Would you like to visit the download page?"));
|
||||
ui->updateDetails->setText(updateDetailsText);
|
||||
|
||||
if(updateResult.channel == UpdateCheck::UpdateChannel::Stable) {
|
||||
if (updateResult.channel == UpdateCheck::UpdateChannel::Stable) {
|
||||
ui->updateText->setMarkdown(githubUpdateToMarkdown(updateResult.githubInfo));
|
||||
} else {
|
||||
ui->updateText->setMarkdown(jenkinsUpdateToMarkdown(updateResult.jenkinsInfo));
|
||||
@@ -56,8 +57,7 @@ UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent) :
|
||||
ui->icon->setPixmap(logo);
|
||||
}
|
||||
|
||||
UpdateDetails::~
|
||||
UpdateDetails()
|
||||
UpdateDetails::~UpdateDetails()
|
||||
= default;
|
||||
|
||||
QString
|
||||
@@ -109,25 +109,25 @@ UpdateDetails::visitDownloadPage(const UpdateCheck::UpdateChannel &channel)
|
||||
case UpdateCheck::UpdateChannel::CI:
|
||||
QDesktopServices::openUrl(QUrl("https://86box.net/builds#"
|
||||
#ifdef Q_OS_WINDOWS
|
||||
"win"
|
||||
"win"
|
||||
#elif defined(Q_OS_MACOS)
|
||||
"mac"
|
||||
"mac"
|
||||
#elif defined(Q_OS_LINUX)
|
||||
"lin"
|
||||
"lin"
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
"arm64"
|
||||
"arm64"
|
||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
||||
"64"
|
||||
"64"
|
||||
#endif
|
||||
|
||||
#ifdef USE_NEW_DYNAREC
|
||||
"ndr"
|
||||
"ndr"
|
||||
#else
|
||||
"odr"
|
||||
"odr"
|
||||
#endif
|
||||
));
|
||||
));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ class UpdateDetails final : public QDialog {
|
||||
public:
|
||||
explicit UpdateDetails(const UpdateCheck::UpdateResult &updateResult, QWidget *parent = nullptr);
|
||||
~UpdateDetails() override;
|
||||
|
||||
private:
|
||||
Ui::UpdateDetails *ui;
|
||||
static QString jenkinsUpdateToMarkdown(const QList<UpdateCheck::JenkinsReleaseInfo> &releaseInfoList);
|
||||
static QString githubUpdateToMarkdown(const QList<UpdateCheck::GithubReleaseInfo> &releaseInfoList);
|
||||
static QString jenkinsUpdateToMarkdown(const QList<UpdateCheck::JenkinsReleaseInfo> &releaseInfoList);
|
||||
static QString githubUpdateToMarkdown(const QList<UpdateCheck::GithubReleaseInfo> &releaseInfoList);
|
||||
private slots:
|
||||
static void visitDownloadPage(const UpdateCheck::UpdateChannel &channel);
|
||||
};
|
||||
|
||||
|
||||
#endif // QT_UPDATEDETAILS_HPP
|
||||
|
||||
@@ -63,7 +63,8 @@ screenOfWidget(QWidget *widget)
|
||||
#ifdef Q_OS_WINDOWS
|
||||
|
||||
bool
|
||||
isWindowsLightTheme(void) {
|
||||
isWindowsLightTheme(void)
|
||||
{
|
||||
if (color_scheme != 0) {
|
||||
return (color_scheme == 1);
|
||||
}
|
||||
@@ -73,7 +74,7 @@ isWindowsLightTheme(void) {
|
||||
// The value is expected to be a REG_DWORD, which is a signed 32-bit little-endian
|
||||
auto buffer = std::vector<char>(4);
|
||||
auto cbData = static_cast<DWORD>(buffer.size() * sizeof(char));
|
||||
auto res = RegGetValueW(
|
||||
auto res = RegGetValueW(
|
||||
HKEY_CURRENT_USER,
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
|
||||
L"AppsUseLightTheme",
|
||||
@@ -87,10 +88,7 @@ isWindowsLightTheme(void) {
|
||||
}
|
||||
|
||||
// convert bytes written to our buffer to an int, assuming little-endian
|
||||
auto i = int(buffer[3] << 24 |
|
||||
buffer[2] << 16 |
|
||||
buffer[1] << 8 |
|
||||
buffer[0]);
|
||||
auto i = int(buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]);
|
||||
|
||||
return i == 1;
|
||||
}
|
||||
@@ -147,22 +145,24 @@ DlgFilter(QStringList extensions, bool last)
|
||||
return " (" % temp.join(' ') % ")" % (!last ? ";;" : "");
|
||||
}
|
||||
|
||||
|
||||
QString currentUuid()
|
||||
QString
|
||||
currentUuid()
|
||||
{
|
||||
return generateUuid(QString(cfg_path));
|
||||
}
|
||||
|
||||
QString generateUuid(const QString &path)
|
||||
QString
|
||||
generateUuid(const QString &path)
|
||||
{
|
||||
auto dirPath = QFileInfo(path).dir().canonicalPath();
|
||||
if(!dirPath.endsWith("/")) {
|
||||
if (!dirPath.endsWith("/")) {
|
||||
dirPath.append("/");
|
||||
}
|
||||
return QUuid::createUuidV5(QUuid{}, dirPath).toString(QUuid::WithoutBraces);
|
||||
return QUuid::createUuidV5(QUuid {}, dirPath).toString(QUuid::WithoutBraces);
|
||||
}
|
||||
|
||||
bool compareUuid()
|
||||
bool
|
||||
compareUuid()
|
||||
{
|
||||
// A uuid not set in the config file will have a zero length.
|
||||
// Any uuid that is lower than the minimum length will be considered invalid
|
||||
@@ -172,7 +172,7 @@ bool compareUuid()
|
||||
return true;
|
||||
}
|
||||
// Do not prompt on mismatch if the system does not have any configured NICs. Just update the uuid
|
||||
if(!hasConfiguredNICs() && uuid != currentUuid()) {
|
||||
if (!hasConfiguredNICs() && uuid != currentUuid()) {
|
||||
storeCurrentUuid();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,10 +20,10 @@ void setWin11RoundedCorners(WId hwnd, bool enable);
|
||||
#endif
|
||||
QString currentUuid();
|
||||
QString generateUuid(const QString &path);
|
||||
void storeCurrentUuid();
|
||||
bool compareUuid();
|
||||
void generateNewMacAdresses();
|
||||
bool hasConfiguredNICs();
|
||||
void storeCurrentUuid();
|
||||
bool compareUuid();
|
||||
void generateNewMacAdresses();
|
||||
bool hasConfiguredNICs();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,8 @@ extern "C" {
|
||||
// One for the main Wizard class and one for each page of the wizard
|
||||
|
||||
VMManagerAddMachine::
|
||||
VMManagerAddMachine(QWidget *parent) : QWizard(parent)
|
||||
VMManagerAddMachine(QWidget *parent)
|
||||
: QWizard(parent)
|
||||
{
|
||||
setPage(Page_Intro, new IntroPage);
|
||||
setPage(Page_WithExistingConfig, new WithExistingConfigPage);
|
||||
@@ -64,7 +65,7 @@ VMManagerAddMachine(QWidget *parent) : QWizard(parent)
|
||||
}
|
||||
|
||||
IntroPage::
|
||||
IntroPage(QWidget *parent)
|
||||
IntroPage(QWidget *parent)
|
||||
{
|
||||
setTitle(tr("Introduction"));
|
||||
|
||||
@@ -74,7 +75,7 @@ IntroPage(QWidget *parent)
|
||||
// topLabel = new QLabel(tr("This will help you add a new system to 86Box.\n\n Choose \"New configuration\" if you'd like to create a new machine.\n\nChoose \"Use existing configuration\" if you'd like to paste in an existing configuration from elsewhere."));
|
||||
topLabel->setWordWrap(true);
|
||||
|
||||
newConfigRadioButton = new QRadioButton(tr("New configuration"));
|
||||
newConfigRadioButton = new QRadioButton(tr("New configuration"));
|
||||
// auto newDescription = new QLabel(tr("Choose this option to start with a fresh configuration."));
|
||||
existingConfigRadioButton = new QRadioButton(tr("Use existing configuration"));
|
||||
// auto existingDescription = new QLabel(tr("Use this option if you'd like to paste in the configuration file from an existing system."));
|
||||
@@ -101,12 +102,12 @@ IntroPage::nextId() const
|
||||
}
|
||||
|
||||
WithExistingConfigPage::
|
||||
WithExistingConfigPage(QWidget *parent)
|
||||
WithExistingConfigPage(QWidget *parent)
|
||||
{
|
||||
setTitle(tr("Use existing configuration"));
|
||||
setSubTitle(tr("Paste the contents of the existing configuration file into the box below."));
|
||||
|
||||
existingConfiguration = new QPlainTextEdit();
|
||||
existingConfiguration = new QPlainTextEdit();
|
||||
const auto monospaceFont = new QFont();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
monospaceFont->setFamily("Consolas");
|
||||
@@ -124,8 +125,8 @@ WithExistingConfigPage(QWidget *parent)
|
||||
const auto layout = new QVBoxLayout();
|
||||
layout->addWidget(existingConfiguration);
|
||||
const auto loadFileButton = new QPushButton();
|
||||
const auto loadFileLabel = new QLabel(tr("Load configuration from file"));
|
||||
const auto hLayout = new QHBoxLayout();
|
||||
const auto loadFileLabel = new QLabel(tr("Load configuration from file"));
|
||||
const auto hLayout = new QHBoxLayout();
|
||||
loadFileButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_FileIcon));
|
||||
loadFileButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
connect(loadFileButton, &QPushButton::clicked, this, &WithExistingConfigPage::chooseExistingConfigFile);
|
||||
@@ -138,10 +139,10 @@ WithExistingConfigPage(QWidget *parent)
|
||||
void
|
||||
WithExistingConfigPage::chooseExistingConfigFile()
|
||||
{
|
||||
const auto startDirectory = QString(vmm_path);
|
||||
const auto startDirectory = QString(vmm_path);
|
||||
const auto selectedConfigFile = QFileDialog::getOpenFileName(this, tr("Choose configuration file"),
|
||||
startDirectory,
|
||||
tr("86Box configuration files (86box.cfg)"));
|
||||
startDirectory,
|
||||
tr("86Box configuration files (86box.cfg)"));
|
||||
// Empty value means the dialog was canceled
|
||||
if (!selectedConfigFile.isEmpty()) {
|
||||
QFile configFile(selectedConfigFile);
|
||||
@@ -183,18 +184,18 @@ WithExistingConfigPage::isComplete() const
|
||||
}
|
||||
|
||||
NameAndLocationPage::
|
||||
NameAndLocationPage(QWidget *parent)
|
||||
NameAndLocationPage(QWidget *parent)
|
||||
{
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
setTitle(tr("System name and location"));
|
||||
|
||||
#if defined(_WIN32)
|
||||
# if defined(_WIN32)
|
||||
dirValidate = QRegularExpression(R"(^[^\\/:*?"<>|]+$)");
|
||||
#elif defined(__APPLE__)
|
||||
# elif defined(__APPLE__)
|
||||
dirValidate = QRegularExpression(R"(^[^/:]+$)");
|
||||
#else
|
||||
# else
|
||||
dirValidate = QRegularExpression(R"(^[^/]+$)");
|
||||
#endif
|
||||
# endif
|
||||
|
||||
setSubTitle(tr("Enter the name of the system and choose the location"));
|
||||
#else
|
||||
@@ -206,7 +207,7 @@ NameAndLocationPage(QWidget *parent)
|
||||
chooseDirectoryButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
|
||||
|
||||
const auto systemNameLabel = new QLabel(tr("System name:"));
|
||||
systemName = new QLineEdit();
|
||||
systemName = new QLineEdit();
|
||||
// Special event filter to override enter key
|
||||
systemName->installEventFilter(this);
|
||||
registerField("systemName*", systemName);
|
||||
@@ -214,7 +215,7 @@ NameAndLocationPage(QWidget *parent)
|
||||
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
const auto systemLocationLabel = new QLabel(tr("System location:"));
|
||||
systemLocation = new QLineEdit();
|
||||
systemLocation = new QLineEdit();
|
||||
systemLocation->setText(QDir::toNativeSeparators(vmm_path));
|
||||
registerField("systemLocation*", systemLocation);
|
||||
systemLocationValidation = new QLabel();
|
||||
@@ -222,7 +223,7 @@ NameAndLocationPage(QWidget *parent)
|
||||
#endif
|
||||
|
||||
const auto displayNameLabel = new QLabel(tr("Display name (optional):"));
|
||||
displayName = new QLineEdit();
|
||||
displayName = new QLineEdit();
|
||||
// Special event filter to override enter key
|
||||
displayName->installEventFilter(this);
|
||||
registerField("displayName*", displayName);
|
||||
@@ -278,7 +279,7 @@ NameAndLocationPage::chooseDirectoryLocation()
|
||||
bool
|
||||
NameAndLocationPage::isComplete() const
|
||||
{
|
||||
bool nameValid = false;
|
||||
bool nameValid = false;
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
bool locationValid = false;
|
||||
#endif
|
||||
@@ -319,10 +320,10 @@ NameAndLocationPage::eventFilter(QObject *watched, QEvent *event)
|
||||
// Override the enter key to hit the next wizard button
|
||||
// if the validator (isComplete) is satisfied
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
const auto keyEvent = dynamic_cast<QKeyEvent*>(event);
|
||||
const auto keyEvent = dynamic_cast<QKeyEvent *>(event);
|
||||
if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) {
|
||||
// Only advance if the validator is satisfied (isComplete)
|
||||
if(const auto wizard = qobject_cast<QWizard*>(this->wizard())) {
|
||||
if (const auto wizard = qobject_cast<QWizard *>(this->wizard())) {
|
||||
if (wizard->currentPage()->isComplete()) {
|
||||
wizard->next();
|
||||
}
|
||||
@@ -335,7 +336,7 @@ NameAndLocationPage::eventFilter(QObject *watched, QEvent *event)
|
||||
}
|
||||
|
||||
ConclusionPage::
|
||||
ConclusionPage(QWidget *parent)
|
||||
ConclusionPage(QWidget *parent)
|
||||
{
|
||||
setTitle(tr("Complete"));
|
||||
|
||||
@@ -344,20 +345,20 @@ ConclusionPage(QWidget *parent)
|
||||
topLabel = new QLabel(tr("The wizard will now launch the configuration for the new system."));
|
||||
topLabel->setWordWrap(true);
|
||||
|
||||
const auto systemNameLabel = new QLabel(tr("System name:"));
|
||||
const auto systemNameLabel = new QLabel(tr("System name:"));
|
||||
systemNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
systemName = new QLabel();
|
||||
systemName = new QLabel();
|
||||
systemName->setWordWrap(true);
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
const auto systemLocationLabel = new QLabel(tr("System location:"));
|
||||
systemLocationLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
systemLocation = new QLabel();
|
||||
systemLocation = new QLabel();
|
||||
systemLocation->setWordWrap(true);
|
||||
#endif
|
||||
|
||||
displayNameLabel = new QLabel(tr("Display name:"));
|
||||
displayNameLabel = new QLabel(tr("Display name:"));
|
||||
displayNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||
displayName = new QLabel();
|
||||
displayName = new QLabel();
|
||||
displayName->setWordWrap(true);
|
||||
|
||||
const auto layout = new QGridLayout();
|
||||
@@ -380,10 +381,10 @@ void
|
||||
ConclusionPage::initializePage()
|
||||
{
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
const auto finalPath = QDir::cleanPath(field("systemLocation").toString() + "/" + field("systemName").toString());
|
||||
const auto finalPath = QDir::cleanPath(field("systemLocation").toString() + "/" + field("systemName").toString());
|
||||
const auto nativePath = QDir::toNativeSeparators(finalPath);
|
||||
#endif
|
||||
const auto systemNameDisplay = field("systemName").toString();
|
||||
const auto systemNameDisplay = field("systemName").toString();
|
||||
const auto displayNameDisplay = field("displayName").toString();
|
||||
|
||||
systemName->setText(systemNameDisplay);
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
[[nodiscard]] int nextId() const override;
|
||||
|
||||
private:
|
||||
QLabel *topLabel;
|
||||
QLabel *topLabel;
|
||||
QRadioButton *newConfigRadioButton;
|
||||
QRadioButton *existingConfigRadioButton;
|
||||
};
|
||||
@@ -61,17 +61,18 @@ public:
|
||||
explicit WithExistingConfigPage(QWidget *parent = nullptr);
|
||||
// These extra functions are required to register QPlainTextEdit fields
|
||||
[[nodiscard]] QString configuration() const;
|
||||
void setConfiguration(const QString &configuration);
|
||||
void setConfiguration(const QString &configuration);
|
||||
signals:
|
||||
void configurationChanged(const QString &configuration);
|
||||
|
||||
private:
|
||||
QPlainTextEdit *existingConfiguration;
|
||||
private slots:
|
||||
void chooseExistingConfigFile();
|
||||
protected:
|
||||
[[nodiscard]] int nextId() const override;
|
||||
[[nodiscard]] bool isComplete() const override;
|
||||
void chooseExistingConfigFile();
|
||||
|
||||
protected:
|
||||
[[nodiscard]] int nextId() const override;
|
||||
[[nodiscard]] bool isComplete() const override;
|
||||
};
|
||||
|
||||
class NameAndLocationPage final : public QWizardPage {
|
||||
@@ -80,6 +81,7 @@ class NameAndLocationPage final : public QWizardPage {
|
||||
public:
|
||||
explicit NameAndLocationPage(QWidget *parent = nullptr);
|
||||
[[nodiscard]] int nextId() const override;
|
||||
|
||||
private:
|
||||
QLineEdit *systemName;
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
@@ -88,21 +90,21 @@ private:
|
||||
QLineEdit *displayName;
|
||||
QLabel *systemNameValidation;
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
QLabel *systemLocationValidation;
|
||||
QLabel *systemLocationValidation;
|
||||
QRegularExpression dirValidate;
|
||||
private slots:
|
||||
void chooseDirectoryLocation();
|
||||
#endif
|
||||
protected:
|
||||
[[nodiscard]] bool isComplete() const override;
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
};
|
||||
|
||||
class ConclusionPage final : public QWizardPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConclusionPage(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
QLabel *topLabel;
|
||||
QLabel *systemName;
|
||||
@@ -111,6 +113,7 @@ private:
|
||||
#endif
|
||||
QLabel *displayNameLabel;
|
||||
QLabel *displayName;
|
||||
|
||||
protected:
|
||||
void initializePage() override;
|
||||
};
|
||||
|
||||
@@ -23,10 +23,10 @@ extern "C" {
|
||||
#include "86box/config.h"
|
||||
}
|
||||
|
||||
VMManagerClientSocket::VMManagerClientSocket(QObject* obj) : server_connected(false)
|
||||
VMManagerClientSocket::VMManagerClientSocket(QObject *obj)
|
||||
: server_connected(false)
|
||||
{
|
||||
socket = new QLocalSocket;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -44,7 +44,7 @@ VMManagerClientSocket::dataReady()
|
||||
if (stream.commitTransaction()) {
|
||||
// first try to successfully read some data
|
||||
// need to also make sure it's valid json
|
||||
QJsonParseError parse_error{};
|
||||
QJsonParseError parse_error {};
|
||||
// try to create a document with the data received
|
||||
const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &parse_error);
|
||||
if (parse_error.error == QJsonParseError::NoError) {
|
||||
@@ -63,7 +63,6 @@ VMManagerClientSocket::dataReady()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -77,7 +76,7 @@ VMManagerClientSocket::IPCConnect(const QString &server)
|
||||
|
||||
socket->connectToServer(server_name);
|
||||
|
||||
if(!socket->isValid()) {
|
||||
if (!socket->isValid()) {
|
||||
qInfo("Could not connect to server: %s", qPrintable(socket->errorString()));
|
||||
return false;
|
||||
}
|
||||
@@ -123,13 +122,13 @@ VMManagerClientSocket::sendMessageFull(const VMManagerProtocol::ClientMessage pr
|
||||
{
|
||||
QDataStream clientStream(socket);
|
||||
clientStream.setVersion(QDataStream::Qt_5_7);
|
||||
auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Client);
|
||||
auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Client);
|
||||
auto jsonMessage = packet->protocolClientMessage(protocol_message);
|
||||
if (!list.isEmpty()) {
|
||||
jsonMessage["list"] = QJsonArray::fromStringList(list);
|
||||
}
|
||||
// TODO: Add the logic for including objects
|
||||
if(!json.isEmpty()) {
|
||||
if (!json.isEmpty()) {
|
||||
jsonMessage["params"] = json;
|
||||
}
|
||||
clientStream << QJsonDocument(jsonMessage).toJson(QJsonDocument::Compact);
|
||||
@@ -228,7 +227,7 @@ VMManagerClientSocket::eventFilter(QObject *obj, QEvent *event)
|
||||
window_blocked = true;
|
||||
} else if (event->type() == QEvent::WindowUnblocked) {
|
||||
window_blocked = false;
|
||||
running_state = dopause ? VMManagerProtocol::RunningState::Paused : VMManagerProtocol::RunningState::Running;
|
||||
running_state = dopause ? VMManagerProtocol::RunningState::Paused : VMManagerProtocol::RunningState::Running;
|
||||
clientRunningStateChanged(running_state);
|
||||
}
|
||||
}
|
||||
@@ -248,7 +247,8 @@ VMManagerClientSocket::clientRunningStateChanged(VMManagerProtocol::RunningState
|
||||
{
|
||||
QJsonObject extra_object;
|
||||
if ((state == VMManagerProtocol::RunningState::Paused
|
||||
|| state == VMManagerProtocol::RunningState::Running) && window_blocked) {
|
||||
|| state == VMManagerProtocol::RunningState::Running)
|
||||
&& window_blocked) {
|
||||
state = (state == VMManagerProtocol::RunningState::Paused) ? VMManagerProtocol::RunningState::PausedWaiting : VMManagerProtocol::RunningState::RunningWaiting;
|
||||
}
|
||||
extra_object["status"] = static_cast<int>(state);
|
||||
|
||||
@@ -25,7 +25,7 @@ class VMManagerClientSocket final : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VMManagerClientSocket(QObject* object = nullptr);
|
||||
explicit VMManagerClientSocket(QObject *object = nullptr);
|
||||
bool IPCConnect(const QString &server);
|
||||
|
||||
void sendWinIdMessage(WId id);
|
||||
@@ -45,13 +45,13 @@ public slots:
|
||||
void globalConfigurationChanged() const;
|
||||
|
||||
private:
|
||||
QString server_name;
|
||||
QString server_name;
|
||||
QLocalSocket *socket;
|
||||
bool server_connected;
|
||||
bool window_blocked = false;
|
||||
void connected() const;
|
||||
void disconnected() const;
|
||||
static void connectionError(QLocalSocket::LocalSocketError socketError);
|
||||
bool server_connected;
|
||||
bool window_blocked = false;
|
||||
void connected() const;
|
||||
void disconnected() const;
|
||||
static void connectionError(QLocalSocket::LocalSocketError socketError);
|
||||
|
||||
// Main convenience send function
|
||||
void sendMessage(VMManagerProtocol::ClientMessage protocol_message) const;
|
||||
@@ -67,7 +67,6 @@ private:
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // QT_VMMANAGER_CLIENTSOCKET_HPP
|
||||
|
||||
@@ -20,11 +20,11 @@ extern "C" {
|
||||
#include <86box/plat.h>
|
||||
}
|
||||
|
||||
VMManagerConfig::VMManagerConfig(const ConfigType type, const QString& section)
|
||||
VMManagerConfig::VMManagerConfig(const ConfigType type, const QString §ion)
|
||||
{
|
||||
char BUF[256];
|
||||
plat_get_global_config_dir(BUF, 255);
|
||||
const auto configDir = QString(BUF);
|
||||
const auto configDir = QString(BUF);
|
||||
const auto configFile = QDir::cleanPath(configDir + "/" + "vmm.ini");
|
||||
|
||||
config_type = type;
|
||||
@@ -34,17 +34,18 @@ VMManagerConfig::VMManagerConfig(const ConfigType type, const QString& section)
|
||||
settings->setIniCodec("UTF-8");
|
||||
#endif
|
||||
settings->setFallbacksEnabled(false);
|
||||
if(type == ConfigType::System && !section.isEmpty()) {
|
||||
if (type == ConfigType::System && !section.isEmpty()) {
|
||||
settings->beginGroup(section);
|
||||
}
|
||||
}
|
||||
|
||||
VMManagerConfig::~VMManagerConfig() {
|
||||
VMManagerConfig::~VMManagerConfig()
|
||||
{
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
QString
|
||||
VMManagerConfig::getStringValue(const QString& key) const
|
||||
VMManagerConfig::getStringValue(const QString &key) const
|
||||
{
|
||||
const auto value = settings->value(key);
|
||||
// An invalid QVariant with toString will give a default QString value which is blank.
|
||||
@@ -73,4 +74,3 @@ VMManagerConfig::sync() const
|
||||
{
|
||||
settings->sync();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,17 @@ public:
|
||||
};
|
||||
Q_ENUM(ConfigType);
|
||||
|
||||
explicit VMManagerConfig(ConfigType type, const QString& section = {});
|
||||
explicit VMManagerConfig(ConfigType type, const QString §ion = {});
|
||||
~VMManagerConfig() override;
|
||||
[[nodiscard]] QString getStringValue(const QString& key) const;
|
||||
void setStringValue(const QString& key, const QString& value) const;
|
||||
void remove(const QString &key) const;
|
||||
[[nodiscard]] QString getStringValue(const QString &key) const;
|
||||
void setStringValue(const QString &key, const QString &value) const;
|
||||
void remove(const QString &key) const;
|
||||
|
||||
void sync() const;
|
||||
|
||||
QSettings *settings;
|
||||
ConfigType config_type;
|
||||
QString system_name;
|
||||
QString system_name;
|
||||
};
|
||||
|
||||
#endif // QT_VMMANAGER_CONFIG_H
|
||||
@@ -22,21 +22,23 @@
|
||||
|
||||
#define TOOLBUTTON_STYLESHEET_LIGHT "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(midlight)} QToolButton:pressed {background: palette(mid)}"
|
||||
#ifdef Q_OS_WINDOWS
|
||||
# define TOOLBUTTON_STYLESHEET_DARK "QToolButton {padding: 5px}"
|
||||
# define TOOLBUTTON_STYLESHEET_DARK "QToolButton {padding: 5px}"
|
||||
# define SCREENSHOTBORDER_STYLESHEET_DARK "QLabel { border: 1px solid gray }"
|
||||
#else
|
||||
# define TOOLBUTTON_STYLESHEET_DARK "QToolButton {background: transparent; border: none; padding: 5px} QToolButton:hover {background: palette(dark)} QToolButton:pressed {background: palette(mid)}"
|
||||
#endif
|
||||
#define SCROLLAREA_STYLESHEET_LIGHT "QWidget {background-color: palette(light)} QScrollBar{ background-color: none }"
|
||||
#define SCROLLAREA_STYLESHEET_LIGHT "QWidget {background-color: palette(light)} QScrollBar{ background-color: none }"
|
||||
#define SYSTEMLABEL_STYLESHEET_LIGHT "background-color: palette(midlight);"
|
||||
|
||||
using namespace VMManager;
|
||||
|
||||
VMManagerDetails::VMManagerDetails(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::VMManagerDetails) {
|
||||
VMManagerDetails::VMManagerDetails(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::VMManagerDetails)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
const auto leftColumnLayout = qobject_cast<QVBoxLayout*>(ui->leftColumn->layout());
|
||||
const auto leftColumnLayout = qobject_cast<QVBoxLayout *>(ui->leftColumn->layout());
|
||||
|
||||
// Each section here gets its own VMManagerDetailSection, named in the constructor.
|
||||
// When a system is selected in the list view it is updated through this object
|
||||
@@ -116,7 +118,7 @@ VMManagerDetails::VMManagerDetails(QWidget *parent) :
|
||||
ui->ssNavTBHolder->setStyleSheet(toolButtonStyleSheet);
|
||||
|
||||
pauseIcon = QIcon(":/menuicons/qt/icons/pause.ico");
|
||||
runIcon = QIcon(":/menuicons/qt/icons/run.ico");
|
||||
runIcon = QIcon(":/menuicons/qt/icons/run.ico");
|
||||
|
||||
// Experimenting
|
||||
startPauseButton = new QToolButton();
|
||||
@@ -164,12 +166,14 @@ VMManagerDetails::VMManagerDetails(QWidget *parent) :
|
||||
sysconfig = new VMManagerSystem();
|
||||
}
|
||||
|
||||
VMManagerDetails::~VMManagerDetails() {
|
||||
VMManagerDetails::~VMManagerDetails()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) {
|
||||
VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig)
|
||||
{
|
||||
|
||||
// Set the scrollarea background but also set the scroll bar to none. Otherwise it will also
|
||||
// set the scrollbar background to the same.
|
||||
@@ -202,9 +206,8 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) {
|
||||
connect(cadButton, &QToolButton::clicked, sysconfig, &VMManagerSystem::cadButtonPressed);
|
||||
cadButton->setEnabled(true);
|
||||
|
||||
bool running = sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running ||
|
||||
sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::RunningWaiting;
|
||||
if(running) {
|
||||
bool running = sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running || sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::RunningWaiting;
|
||||
if (running) {
|
||||
startPauseButton->setIcon(pauseIcon);
|
||||
connect(startPauseButton, &QToolButton::clicked, sysconfig, &VMManagerSystem::pauseButtonPressed);
|
||||
} else {
|
||||
@@ -218,9 +221,7 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) {
|
||||
updateScreenshots(passed_sysconfig);
|
||||
|
||||
ui->systemLabel->setText(passed_sysconfig->displayName);
|
||||
ui->statusLabel->setText(sysconfig->process->processId() == 0 ?
|
||||
tr("Not running") :
|
||||
QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())));
|
||||
ui->statusLabel->setText(sysconfig->process->processId() == 0 ? tr("Not running") : QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())));
|
||||
ui->notesTextEdit->setPlainText(passed_sysconfig->notes);
|
||||
ui->notesTextEdit->setEnabled(true);
|
||||
|
||||
@@ -237,7 +238,8 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) {
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) {
|
||||
VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig)
|
||||
{
|
||||
// Each detail section here has its own VMManagerDetailSection.
|
||||
// When a system is selected in the list view it is updated here, through this object:
|
||||
// * First you clear it with VMManagerDetailSection::clear()
|
||||
@@ -252,7 +254,7 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) {
|
||||
// Video
|
||||
videoSection->clear();
|
||||
videoSection->addSection("Video", passed_sysconfig->getDisplayValue(VMManager::Display::Name::Video));
|
||||
if(!passed_sysconfig->getDisplayValue(VMManager::Display::Name::Voodoo).isEmpty()) {
|
||||
if (!passed_sysconfig->getDisplayValue(VMManager::Display::Name::Voodoo).isEmpty()) {
|
||||
videoSection->addSection("Voodoo", passed_sysconfig->getDisplayValue(VMManager::Display::Name::Voodoo));
|
||||
}
|
||||
|
||||
@@ -303,7 +305,8 @@ VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) {
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) {
|
||||
VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig)
|
||||
{
|
||||
// Disable screenshot navigation buttons by default
|
||||
ui->screenshotNext->setEnabled(false);
|
||||
ui->screenshotPrevious->setEnabled(false);
|
||||
@@ -315,7 +318,7 @@ VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) {
|
||||
if (!screenshots.empty()) {
|
||||
ui->screenshot->setFrameStyle(QFrame::NoFrame);
|
||||
ui->screenshot->setEnabled(true);
|
||||
if(screenshots.size() > 1) {
|
||||
if (screenshots.size() > 1) {
|
||||
ui->screenshotNext->setEnabled(true);
|
||||
ui->screenshotPrevious->setEnabled(true);
|
||||
ui->screenshotNextTB->setEnabled(true);
|
||||
@@ -324,7 +327,7 @@ VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
ui->screenshot->setStyleSheet("");
|
||||
#endif
|
||||
if(QFileInfo::exists(screenshots.last().filePath())) {
|
||||
if (QFileInfo::exists(screenshots.last().filePath())) {
|
||||
screenshotIndex = screenshots.size() - 1;
|
||||
const QPixmap pic(screenshots.at(screenshotIndex).filePath());
|
||||
ui->screenshot->setPixmap(pic.scaled(240, 160, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
@@ -351,18 +354,17 @@ VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) {
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetails::updateProcessStatus() {
|
||||
const bool running = sysconfig->process->state() == QProcess::ProcessState::Running;
|
||||
QString status_text = running ?
|
||||
QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())) :
|
||||
tr("Not running");
|
||||
VMManagerDetails::updateProcessStatus()
|
||||
{
|
||||
const bool running = sysconfig->process->state() == QProcess::ProcessState::Running;
|
||||
QString status_text = running ? QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())) : tr("Not running");
|
||||
status_text.append(sysconfig->window_obscured ? QString(" (%1)").arg(tr("Waiting")) : "");
|
||||
ui->statusLabel->setText(status_text);
|
||||
resetButton->setEnabled(running);
|
||||
stopButton->setEnabled(running);
|
||||
cadButton->setEnabled(running);
|
||||
if(running) {
|
||||
if(sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running) {
|
||||
if (running) {
|
||||
if (sysconfig->getProcessStatus() == VMManagerSystem::ProcessStatus::Running) {
|
||||
startPauseButton->setIcon(pauseIcon);
|
||||
startPauseButton->setToolTip(tr("Pause"));
|
||||
} else {
|
||||
@@ -404,7 +406,7 @@ VMManagerDetails::updateWindowStatus()
|
||||
void
|
||||
VMManagerDetails::updateStyle()
|
||||
{
|
||||
QString toolButtonStyleSheet;
|
||||
QString toolButtonStyleSheet;
|
||||
const bool lightMode = util::isWindowsLightTheme();
|
||||
if (lightMode) {
|
||||
toolButtonStyleSheet = TOOLBUTTON_STYLESHEET_LIGHT;
|
||||
@@ -472,10 +474,9 @@ VMManagerDetails::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched->isWidgetType() && event->type() == QEvent::FocusOut) {
|
||||
// Make sure it's the textedit
|
||||
if (const auto *textEdit = qobject_cast<QPlainTextEdit*>(watched); textEdit) {
|
||||
if (const auto *textEdit = qobject_cast<QPlainTextEdit *>(watched); textEdit) {
|
||||
saveNotes();
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
// #include "qt_vmmanager_details_section.hpp"
|
||||
#include "qt_vmmanager_detailsection.hpp"
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
//namespace Ui { class VMManagerDetails; class CollapseButton;}
|
||||
namespace Ui { class VMManagerDetails;}
|
||||
// namespace Ui { class VMManagerDetails; class CollapseButton;}
|
||||
namespace Ui {
|
||||
class VMManagerDetails;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class VMManagerDetails : public QWidget {
|
||||
@@ -44,7 +45,7 @@ public:
|
||||
void updateStyle();
|
||||
#endif
|
||||
|
||||
// CollapseButton *systemCollapseButton;
|
||||
// CollapseButton *systemCollapseButton;
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
signals:
|
||||
@@ -53,7 +54,7 @@ signals:
|
||||
|
||||
private:
|
||||
Ui::VMManagerDetails *ui;
|
||||
VMManagerSystem *sysconfig;
|
||||
VMManagerSystem *sysconfig;
|
||||
|
||||
VMManagerDetailSection *systemSection;
|
||||
VMManagerDetailSection *videoSection;
|
||||
@@ -78,9 +79,9 @@ private:
|
||||
QIcon pauseIcon;
|
||||
QIcon runIcon;
|
||||
|
||||
void updateConfig(VMManagerSystem *passed_sysconfig);
|
||||
void updateScreenshots(VMManagerSystem *passed_sysconfig);
|
||||
static QWidget* createHorizontalLine(int leftSpacing = 25, int rightSpacing = 25);
|
||||
void updateConfig(VMManagerSystem *passed_sysconfig);
|
||||
void updateScreenshots(VMManagerSystem *passed_sysconfig);
|
||||
static QWidget *createHorizontalLine(int leftSpacing = 25, int rightSpacing = 25);
|
||||
// QVBoxLayout *detailsLayout;
|
||||
private slots:
|
||||
void saveNotes() const;
|
||||
@@ -90,12 +91,14 @@ private slots:
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
// CollapseButton *systemCollapseButton;
|
||||
// QFrame *systemFrame;
|
||||
// CollapseButton *displayCollapseButton;
|
||||
// QFrame *displayFrame;
|
||||
// CollapseButton *storageCollapseButton;
|
||||
// QFrame *storageFrame;
|
||||
#if 0
|
||||
CollapseButton *systemCollapseButton;
|
||||
QFrame *systemFrame;
|
||||
CollapseButton *displayCollapseButton;
|
||||
QFrame *displayFrame;
|
||||
CollapseButton *storageCollapseButton;
|
||||
QFrame *storageFrame;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif //QT_VMMANAGER_DETAILS_H
|
||||
#endif // QT_VMMANAGER_DETAILS_H
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#define HEADER_STYLESHEET_LIGHT "background-color: palette(midlight);"
|
||||
#ifdef Q_OS_WINDOWS
|
||||
# define HEADER_STYLESHEET_DARK "background-color: #616161;"
|
||||
# define HEADER_STYLESHEET_DARK "background-color: #616161;"
|
||||
# define BACKGROUND_STYLESHEET_DARK "background-color: #272727;"
|
||||
#else
|
||||
# define HEADER_STYLESHEET_DARK "background-color: palette(mid);"
|
||||
@@ -30,7 +30,7 @@ const QString VMManagerDetailSection::sectionSeparator = ";";
|
||||
using namespace VMManager;
|
||||
|
||||
VMManagerDetailSection::
|
||||
VMManagerDetailSection(const QString §ionName)
|
||||
VMManagerDetailSection(const QString §ionName)
|
||||
: mainLayout(new QVBoxLayout())
|
||||
, buttonLayout(new QHBoxLayout())
|
||||
, frame(new QFrame())
|
||||
@@ -80,7 +80,8 @@ VMManagerDetailSection(const QString §ionName)
|
||||
}
|
||||
|
||||
VMManagerDetailSection::
|
||||
VMManagerDetailSection(const QVariant &varSectionName) : ui(new Ui::DetailSection)
|
||||
VMManagerDetailSection(const QVariant &varSectionName)
|
||||
: ui(new Ui::DetailSection)
|
||||
{
|
||||
const auto sectionName = varSectionName.toString();
|
||||
|
||||
@@ -100,7 +101,7 @@ VMManagerDetailSection(const QVariant &varSectionName) : ui(new Ui::DetailSectio
|
||||
|
||||
const auto buttonWidget = new QWidget(this);
|
||||
|
||||
mainLayout = new QVBoxLayout();
|
||||
mainLayout = new QVBoxLayout();
|
||||
buttonLayout = new QHBoxLayout();
|
||||
buttonWidget->setLayout(buttonLayout);
|
||||
|
||||
@@ -130,7 +131,7 @@ VMManagerDetailSection(const QVariant &varSectionName) : ui(new Ui::DetailSectio
|
||||
}
|
||||
|
||||
VMManagerDetailSection::~VMManagerDetailSection()
|
||||
= default;
|
||||
= default;
|
||||
|
||||
void
|
||||
VMManagerDetailSection::setSectionName(const QString &name)
|
||||
@@ -144,7 +145,7 @@ VMManagerDetailSection::setSectionName(const QString &name)
|
||||
void
|
||||
VMManagerDetailSection::addSection(const QString &name, const QString &value, VMManager::Display::Name displayField)
|
||||
{
|
||||
const auto new_section = DetailSection { name, value};
|
||||
const auto new_section = DetailSection { name, value };
|
||||
sections.push_back(new_section);
|
||||
}
|
||||
|
||||
@@ -158,14 +159,14 @@ VMManagerDetailSection::setupMainLayout()
|
||||
void
|
||||
VMManagerDetailSection::setSections()
|
||||
{
|
||||
int row = 0;
|
||||
int row = 0;
|
||||
bool empty = true;
|
||||
|
||||
for (const auto& section : sections) {
|
||||
for (const auto §ion : sections) {
|
||||
QStringList sectionsToAdd = section.value.split(sectionSeparator);
|
||||
QLabel *labelKey = nullptr;
|
||||
QLabel *labelKey = nullptr;
|
||||
|
||||
for (const auto& line : sectionsToAdd) {
|
||||
for (const auto &line : sectionsToAdd) {
|
||||
if (line.isEmpty()) {
|
||||
// Don't bother adding entries if the values are blank
|
||||
continue;
|
||||
@@ -203,10 +204,10 @@ VMManagerDetailSection::clear()
|
||||
setVisible(false);
|
||||
|
||||
// Clear everything out
|
||||
if(frameGridLayout) {
|
||||
while(frameGridLayout->count()) {
|
||||
QLayoutItem * cur_item = frameGridLayout->takeAt(0);
|
||||
if(cur_item->widget())
|
||||
if (frameGridLayout) {
|
||||
while (frameGridLayout->count()) {
|
||||
QLayoutItem *cur_item = frameGridLayout->takeAt(0);
|
||||
if (cur_item->widget())
|
||||
delete cur_item->widget();
|
||||
delete cur_item;
|
||||
}
|
||||
@@ -242,15 +243,15 @@ VMManagerDetailSection::getMargins(const MarginSection section)
|
||||
switch (section) {
|
||||
case MarginSection::ToolButton:
|
||||
#if defined(Q_OS_WINDOWS) or defined(Q_OS_LINUX)
|
||||
return {10, 0, 5, 0};
|
||||
return { 10, 0, 5, 0 };
|
||||
#else
|
||||
return {0, 0, 5, 0};
|
||||
return { 0, 0, 5, 0 };
|
||||
#endif
|
||||
case MarginSection::DisplayGrid:
|
||||
#if defined(Q_OS_WINDOWS) or defined(Q_OS_LINUX)
|
||||
return {10, 0, 0, 10};
|
||||
return { 10, 0, 0, 10 };
|
||||
#else
|
||||
return {0, 0, 0, 10};
|
||||
return { 0, 0, 0, 10 };
|
||||
#endif
|
||||
default:
|
||||
return {};
|
||||
@@ -259,7 +260,10 @@ VMManagerDetailSection::getMargins(const MarginSection section)
|
||||
|
||||
// CollapseButton Class
|
||||
|
||||
CollapseButton::CollapseButton(QWidget *parent) : QToolButton(parent), content_(nullptr) {
|
||||
CollapseButton::CollapseButton(QWidget *parent)
|
||||
: QToolButton(parent)
|
||||
, content_(nullptr)
|
||||
{
|
||||
setCheckable(true);
|
||||
setStyleSheet("background:none; border:none;");
|
||||
setIconSize(QSize(8, 8));
|
||||
@@ -267,16 +271,20 @@ CollapseButton::CollapseButton(QWidget *parent) : QToolButton(parent), content_(
|
||||
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
connect(this, &QToolButton::toggled, [=](const bool checked) {
|
||||
setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow);
|
||||
content_ != nullptr && checked ? showContent() : hideContent();
|
||||
content_ != nullptr &&checked ? showContent() : hideContent();
|
||||
});
|
||||
setChecked(true);
|
||||
}
|
||||
|
||||
void CollapseButton::setButtonText(const QString &text) {
|
||||
void
|
||||
CollapseButton::setButtonText(const QString &text)
|
||||
{
|
||||
setText(" " + text);
|
||||
}
|
||||
|
||||
void CollapseButton::setContent(QWidget *content) {
|
||||
void
|
||||
CollapseButton::setContent(QWidget *content)
|
||||
{
|
||||
assert(content != nullptr);
|
||||
content_ = content;
|
||||
const auto animation_ = new QPropertyAnimation(content_, "maximumHeight"); // QObject with auto delete
|
||||
@@ -292,12 +300,16 @@ void CollapseButton::setContent(QWidget *content) {
|
||||
}
|
||||
}
|
||||
|
||||
void CollapseButton::hideContent() {
|
||||
void
|
||||
CollapseButton::hideContent()
|
||||
{
|
||||
animator_.setDirection(QAbstractAnimation::Backward);
|
||||
animator_.start();
|
||||
}
|
||||
|
||||
void CollapseButton::showContent() {
|
||||
void
|
||||
CollapseButton::showContent()
|
||||
{
|
||||
animator_.setDirection(QAbstractAnimation::Forward);
|
||||
animator_.start();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@
|
||||
#include "qt_vmmanager_system.hpp"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class DetailSection; }
|
||||
namespace Ui {
|
||||
class DetailSection;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class CollapseButton final : public QToolButton {
|
||||
@@ -42,8 +44,8 @@ public:
|
||||
void showContent();
|
||||
|
||||
private:
|
||||
QWidget *content_;
|
||||
QString text_;
|
||||
QWidget *content_;
|
||||
QString text_;
|
||||
QParallelAnimationGroup animator_;
|
||||
};
|
||||
|
||||
@@ -61,13 +63,13 @@ public:
|
||||
void setSections();
|
||||
void clear();
|
||||
|
||||
QLabel *tableLabel;
|
||||
QLabel *tableLabel;
|
||||
CollapseButton *collapseButton;
|
||||
// QGridLayout *buttonGridLayout;
|
||||
// QGridLayout *buttonGridLayout;
|
||||
QGridLayout *frameGridLayout;
|
||||
QVBoxLayout *mainLayout;
|
||||
QHBoxLayout *buttonLayout;
|
||||
QFrame *frame;
|
||||
QFrame *frame;
|
||||
|
||||
static const QString sectionSeparator;
|
||||
|
||||
@@ -96,8 +98,7 @@ private:
|
||||
};
|
||||
|
||||
QVector<DetailSection> sections;
|
||||
Ui::DetailSection *ui;
|
||||
|
||||
Ui::DetailSection *ui;
|
||||
};
|
||||
|
||||
#endif // QT_VMMANAGER_DETAILSECTION_H
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* 86Box VM manager list view delegate module
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2024 cold-brewed
|
||||
*/
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* 86Box VM manager list view delegate module
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2024 cold-brewed
|
||||
*/
|
||||
#include <QApplication>
|
||||
|
||||
#include "qt_util.hpp"
|
||||
@@ -22,25 +22,27 @@
|
||||
// from https://stackoverflow.com/questions/53105343/is-it-possible-to-add-a-custom-widget-into-a-qlistview
|
||||
|
||||
VMManagerListViewDelegate::VMManagerListViewDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent),
|
||||
m_ptr(new VMManagerListViewDelegateStyle)
|
||||
: QStyledItemDelegate(parent)
|
||||
, m_ptr(new VMManagerListViewDelegateStyle)
|
||||
{
|
||||
default_icon = QIcon(":/settings/qt/icons/86Box-gray.ico");
|
||||
stop_icon = QApplication::style()->standardIcon(QStyle::SP_MediaStop);
|
||||
stop_icon = QApplication::style()->standardIcon(QStyle::SP_MediaStop);
|
||||
running_icon = QIcon(":/menuicons/qt/icons/run.ico");
|
||||
stopped_icon = QIcon(":/menuicons/qt/icons/acpi_shutdown.ico");
|
||||
paused_icon = QIcon(":/menuicons/qt/icons/pause.ico");
|
||||
paused_icon = QIcon(":/menuicons/qt/icons/pause.ico");
|
||||
unknown_icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
|
||||
|
||||
highlight_color = QColor("#616161");
|
||||
bg_color = QColor("#272727");
|
||||
bg_color = QColor("#272727");
|
||||
}
|
||||
|
||||
VMManagerListViewDelegate::~VMManagerListViewDelegate()
|
||||
= default;
|
||||
= default;
|
||||
|
||||
void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const {
|
||||
void
|
||||
VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
bool windows_light_mode = true;
|
||||
#ifdef Q_OS_WINDOWS
|
||||
windows_light_mode = util::isWindowsLightTheme();
|
||||
@@ -51,16 +53,16 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI
|
||||
// opt.rect = opt.rect.adjusted(0, 0, 0, 20);
|
||||
const QRect &rect(opt.rect);
|
||||
const QRect &contentRect(rect.adjusted(m_ptr->margins.left(),
|
||||
m_ptr->margins.top(),
|
||||
-m_ptr->margins.right(),
|
||||
-m_ptr->margins.bottom()));
|
||||
m_ptr->margins.top(),
|
||||
-m_ptr->margins.right(),
|
||||
-m_ptr->margins.bottom()));
|
||||
|
||||
// The status icon represents the current state of the vm. Initially set to a default state.
|
||||
auto process_variant = index.data(VMManagerModel::Roles::ProcessStatus);
|
||||
auto process_status = process_variant.value<VMManagerSystem::ProcessStatus>();
|
||||
auto process_status = process_variant.value<VMManagerSystem::ProcessStatus>();
|
||||
// The main icon, configurable. Falls back to default if it cannot be loaded.
|
||||
auto customIcon = index.data(VMManagerModel::Roles::Icon).toString();
|
||||
opt.icon = default_icon;
|
||||
opt.icon = default_icon;
|
||||
if (!customIcon.isEmpty()) {
|
||||
const auto customPixmap = QPixmap(customIcon);
|
||||
if (!customPixmap.isNull())
|
||||
@@ -69,7 +71,7 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI
|
||||
|
||||
// Set the status icon based on the process status
|
||||
QIcon status_icon;
|
||||
switch(process_status) {
|
||||
switch (process_status) {
|
||||
case VMManagerSystem::ProcessStatus::Running:
|
||||
status_icon = running_icon;
|
||||
break;
|
||||
@@ -85,12 +87,11 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI
|
||||
status_icon = unknown_icon;
|
||||
}
|
||||
|
||||
|
||||
// Used to determine if the horizontal separator should be drawn
|
||||
const bool lastIndex = (index.model()->rowCount() - 1) == index.row();
|
||||
const bool hasIcon = !opt.icon.isNull();
|
||||
const int bottomEdge = rect.bottom();
|
||||
QFont f(opt.font);
|
||||
const bool lastIndex = (index.model()->rowCount() - 1) == index.row();
|
||||
const bool hasIcon = !opt.icon.isNull();
|
||||
const int bottomEdge = rect.bottom();
|
||||
QFont f(opt.font);
|
||||
|
||||
f.setPointSizeF(m_ptr->statusFontPointSize(opt.font));
|
||||
|
||||
@@ -102,11 +103,11 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI
|
||||
// Draw the background
|
||||
if (opt.state & QStyle::State_Selected) {
|
||||
// When selected, only draw the highlighted part until the horizontal separator
|
||||
int offset = 2;
|
||||
int offset = 2;
|
||||
auto highlightRect = rect.adjusted(0, 0, 0, -offset);
|
||||
painter->fillRect(highlightRect, windows_light_mode ? palette.highlight().color() : highlight_color);
|
||||
// Then fill the remainder with the normal color
|
||||
auto regularRect = rect.adjusted(0, rect.height()-offset, 0, 0);
|
||||
auto regularRect = rect.adjusted(0, rect.height() - offset, 0, 0);
|
||||
painter->fillRect(regularRect, windows_light_mode ? palette.light().color() : bg_color);
|
||||
} else {
|
||||
// Otherwise just draw the background color as usual
|
||||
@@ -129,16 +130,16 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI
|
||||
QRect systemNameRect(m_ptr->systemNameBox(opt, index));
|
||||
|
||||
systemNameRect.moveTo(m_ptr->margins.left() + m_ptr->iconSize.width()
|
||||
+ m_ptr->spacingHorizontal, contentRect.top());
|
||||
+ m_ptr->spacingHorizontal,
|
||||
contentRect.top());
|
||||
// If desired, font can be changed here
|
||||
// painter->setFont(f);
|
||||
// painter->setFont(f);
|
||||
painter->setFont(opt.font);
|
||||
painter->setPen(palette.text().color());
|
||||
painter->drawText(systemNameRect, Qt::TextSingleLine, opt.text);
|
||||
|
||||
// Draw status icon
|
||||
painter->drawPixmap(systemNameRect.left(), systemNameRect.bottom()
|
||||
+ m_ptr->spacingVertical,
|
||||
painter->drawPixmap(systemNameRect.left(), systemNameRect.bottom() + m_ptr->spacingVertical,
|
||||
status_icon.pixmap(m_ptr->smallIconSize));
|
||||
|
||||
// This rectangle is around the status icon
|
||||
@@ -150,53 +151,58 @@ void VMManagerListViewDelegate::paint(QPainter *painter, const QStyleOptionViewI
|
||||
|
||||
// Draw status text
|
||||
QRect statusRect(m_ptr->statusBox(opt, index));
|
||||
int extraaa = 2;
|
||||
int extraaa = 2;
|
||||
statusRect.moveTo(systemNameRect.left() + m_ptr->margins.left() + m_ptr->smallIconSize.width(),
|
||||
systemNameRect.bottom() + m_ptr->spacingVertical + extraaa + (m_ptr->smallIconSize.height() - systemNameRect.height() ));
|
||||
systemNameRect.bottom() + m_ptr->spacingVertical + extraaa + (m_ptr->smallIconSize.height() - systemNameRect.height()));
|
||||
|
||||
// painter->setFont(opt.font);
|
||||
// painter->setFont(opt.font);
|
||||
painter->setFont(f);
|
||||
painter->setPen(palette.windowText().color());
|
||||
painter->drawText(statusRect, Qt::TextSingleLine,
|
||||
index.data(VMManagerModel::Roles::ProcessStatusString).toString());
|
||||
|
||||
painter->restore();
|
||||
|
||||
}
|
||||
|
||||
QMargins VMManagerListViewDelegate::contentsMargins() const
|
||||
QMargins
|
||||
VMManagerListViewDelegate::contentsMargins() const
|
||||
{
|
||||
return m_ptr->margins;
|
||||
}
|
||||
|
||||
void VMManagerListViewDelegate::setContentsMargins(const int left, const int top, const int right, const int bottom) const
|
||||
void
|
||||
VMManagerListViewDelegate::setContentsMargins(const int left, const int top, const int right, const int bottom) const
|
||||
{
|
||||
m_ptr->margins = QMargins(left, top, right, bottom);
|
||||
}
|
||||
|
||||
int VMManagerListViewDelegate::horizontalSpacing() const
|
||||
int
|
||||
VMManagerListViewDelegate::horizontalSpacing() const
|
||||
{
|
||||
return m_ptr->spacingHorizontal;
|
||||
}
|
||||
|
||||
void VMManagerListViewDelegate::setHorizontalSpacing(const int spacing) const
|
||||
void
|
||||
VMManagerListViewDelegate::setHorizontalSpacing(const int spacing) const
|
||||
{
|
||||
m_ptr->spacingHorizontal = spacing;
|
||||
}
|
||||
|
||||
int VMManagerListViewDelegate::verticalSpacing() const
|
||||
int
|
||||
VMManagerListViewDelegate::verticalSpacing() const
|
||||
{
|
||||
return m_ptr->spacingVertical;
|
||||
}
|
||||
|
||||
void VMManagerListViewDelegate::setVerticalSpacing(const int spacing) const
|
||||
void
|
||||
VMManagerListViewDelegate::setVerticalSpacing(const int spacing) const
|
||||
{
|
||||
m_ptr->spacingVertical = spacing;
|
||||
}
|
||||
|
||||
|
||||
QSize VMManagerListViewDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
QSize
|
||||
VMManagerListViewDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QStyleOptionViewItem opt(option);
|
||||
initStyleOption(&opt, index);
|
||||
@@ -204,45 +210,48 @@ QSize VMManagerListViewDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
const int textHeight = m_ptr->systemNameBox(opt, index).height()
|
||||
+ m_ptr->spacingVertical + m_ptr->statusBox(opt, index).height();
|
||||
const int iconHeight = m_ptr->iconSize.height();
|
||||
const int h = textHeight > iconHeight ? textHeight : iconHeight;
|
||||
const int h = textHeight > iconHeight ? textHeight : iconHeight;
|
||||
|
||||
// return the same width
|
||||
// for height, add margins on top and bottom *plus* either the text or icon height, whichever is greater
|
||||
// Note: text height is the combined value of the system name and the status just below the name
|
||||
return {opt.rect.width(), m_ptr->margins.top() + h
|
||||
+ m_ptr->margins.bottom()};
|
||||
return { opt.rect.width(), m_ptr->margins.top() + h + m_ptr->margins.bottom() };
|
||||
}
|
||||
|
||||
VMManagerListViewDelegateStyle::VMManagerListViewDelegateStyle() :
|
||||
iconSize(32, 32),
|
||||
smallIconSize(16, 16),
|
||||
VMManagerListViewDelegateStyle::VMManagerListViewDelegateStyle()
|
||||
: iconSize(32, 32)
|
||||
, smallIconSize(16, 16)
|
||||
,
|
||||
// bottom gets a little more than the top because of the custom separator
|
||||
margins(4, 10, 8, 12),
|
||||
margins(4, 10, 8, 12)
|
||||
,
|
||||
// Spacing between icon and text
|
||||
spacingHorizontal(8),
|
||||
spacingVertical(4)
|
||||
spacingHorizontal(8)
|
||||
, spacingVertical(4)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
QRect VMManagerListViewDelegateStyle::statusBox(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
QRect
|
||||
VMManagerListViewDelegateStyle::statusBox(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QFont f(option.font);
|
||||
|
||||
f.setPointSizeF(statusFontPointSize(option.font));
|
||||
|
||||
return QFontMetrics(f).boundingRect(index.data(VMManagerModel::Roles::ProcessStatusString).toString())
|
||||
.adjusted(0, 0, 1, 1);
|
||||
return QFontMetrics(f).boundingRect(index.data(VMManagerModel::Roles::ProcessStatusString).toString()).adjusted(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
qreal VMManagerListViewDelegateStyle::statusFontPointSize(const QFont &f) const
|
||||
qreal
|
||||
VMManagerListViewDelegateStyle::statusFontPointSize(const QFont &f) const
|
||||
{
|
||||
return 0.75*f.pointSize();
|
||||
// return 1*f.pointSize();
|
||||
return 0.75 * f.pointSize();
|
||||
// return 1*f.pointSize();
|
||||
}
|
||||
|
||||
QRect VMManagerListViewDelegateStyle::systemNameBox(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
QRect
|
||||
VMManagerListViewDelegateStyle::systemNameBox(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
return option.fontMetrics.boundingRect(option.text).adjusted(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
@@ -19,20 +19,19 @@
|
||||
#include <QStyledItemDelegate>
|
||||
#include "qt_vmmanager_system.hpp"
|
||||
|
||||
class VMManagerListViewDelegateStyle
|
||||
{
|
||||
class VMManagerListViewDelegateStyle {
|
||||
VMManagerListViewDelegateStyle();
|
||||
|
||||
[[nodiscard]] inline QRect systemNameBox(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
const QModelIndex &index) const;
|
||||
[[nodiscard]] inline qreal statusFontPointSize(const QFont &f) const;
|
||||
[[nodiscard]] inline QRect statusBox(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
QSize iconSize;
|
||||
QSize smallIconSize;
|
||||
QSize iconSize;
|
||||
QSize smallIconSize;
|
||||
QMargins margins;
|
||||
int spacingHorizontal;
|
||||
int spacingVertical;
|
||||
int spacingHorizontal;
|
||||
int spacingVertical;
|
||||
|
||||
friend class VMManagerListViewDelegate;
|
||||
};
|
||||
@@ -46,18 +45,19 @@ public:
|
||||
using QStyledItemDelegate::QStyledItemDelegate;
|
||||
|
||||
[[nodiscard]] QMargins contentsMargins() const;
|
||||
void setContentsMargins(int left, int top, int right, int bottom) const;
|
||||
void setContentsMargins(int left, int top, int right, int bottom) const;
|
||||
|
||||
[[nodiscard]] int horizontalSpacing() const;
|
||||
void setHorizontalSpacing(int spacing) const;
|
||||
void setHorizontalSpacing(int spacing) const;
|
||||
|
||||
[[nodiscard]] int verticalSpacing() const;
|
||||
void setVerticalSpacing(int spacing) const;
|
||||
void setVerticalSpacing(int spacing) const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
[[nodiscard]] QSize sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
VMManagerListViewDelegateStyle *m_ptr;
|
||||
|
||||
|
||||
@@ -33,41 +33,33 @@
|
||||
#include "qt_vmmanager_model.hpp"
|
||||
#include "qt_vmmanager_addmachine.hpp"
|
||||
|
||||
extern VMManagerMainWindow* vmm_main_window;
|
||||
extern VMManagerMainWindow *vmm_main_window;
|
||||
|
||||
// https://stackoverflow.com/a/36460740
|
||||
bool copyPath(QString sourceDir, QString destinationDir, bool overWriteDirectory)
|
||||
bool
|
||||
copyPath(QString sourceDir, QString destinationDir, bool overWriteDirectory)
|
||||
{
|
||||
QDir originDirectory(sourceDir);
|
||||
|
||||
if (! originDirectory.exists())
|
||||
{
|
||||
if (!originDirectory.exists())
|
||||
return false;
|
||||
}
|
||||
|
||||
QDir destinationDirectory(destinationDir);
|
||||
|
||||
if(destinationDirectory.exists() && !overWriteDirectory)
|
||||
{
|
||||
if (destinationDirectory.exists() && !overWriteDirectory)
|
||||
return false;
|
||||
}
|
||||
else if(destinationDirectory.exists() && overWriteDirectory)
|
||||
{
|
||||
else if (destinationDirectory.exists() && overWriteDirectory)
|
||||
destinationDirectory.removeRecursively();
|
||||
}
|
||||
|
||||
originDirectory.mkpath(destinationDir);
|
||||
|
||||
foreach (QString directoryName, originDirectory.entryList(QDir::Dirs | \
|
||||
QDir::NoDotAndDotDot))
|
||||
{
|
||||
foreach (QString directoryName, originDirectory.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||
QString destinationPath = destinationDir + "/" + directoryName;
|
||||
originDirectory.mkpath(destinationPath);
|
||||
copyPath(sourceDir + "/" + directoryName, destinationPath, overWriteDirectory);
|
||||
}
|
||||
|
||||
foreach (QString fileName, originDirectory.entryList(QDir::Files))
|
||||
{
|
||||
foreach (QString fileName, originDirectory.entryList(QDir::Files)) {
|
||||
QFile::copy(sourceDir + "/" + fileName, destinationDir + "/" + fileName);
|
||||
}
|
||||
|
||||
@@ -75,21 +67,22 @@ bool copyPath(QString sourceDir, QString destinationDir, bool overWriteDirectory
|
||||
QDir finalDestination(destinationDir);
|
||||
finalDestination.refresh();
|
||||
|
||||
if(finalDestination.exists())
|
||||
{
|
||||
if (finalDestination.exists())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
VMManagerMain::VMManagerMain(QWidget *parent) :
|
||||
QWidget(parent), ui(new Ui::VMManagerMain), selected_sysconfig(new VMManagerSystem) {
|
||||
VMManagerMain::VMManagerMain(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::VMManagerMain)
|
||||
, selected_sysconfig(new VMManagerSystem)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Set up the main listView
|
||||
ui->listView->setItemDelegate(new VMManagerListViewDelegate);
|
||||
vm_model = new VMManagerModel;
|
||||
vm_model = new VMManagerModel;
|
||||
proxy_model = new StringListProxyModel(this);
|
||||
proxy_model->setSourceModel(vm_model);
|
||||
ui->listView->setModel(proxy_model);
|
||||
@@ -157,16 +150,15 @@ VMManagerMain::VMManagerMain(QWidget *parent) :
|
||||
contextMenu.addAction(&nameChangeAction);
|
||||
// Use a lambda to call a function so indexAt can be passed
|
||||
connect(&nameChangeAction, &QAction::triggered, ui->listView, [this, indexAt] {
|
||||
updateDisplayName(indexAt);
|
||||
updateDisplayName(indexAt);
|
||||
});
|
||||
nameChangeAction.setEnabled(!selected_sysconfig->window_obscured);
|
||||
|
||||
|
||||
QAction setSystemIcon(tr("Set &icon..."));
|
||||
contextMenu.addAction(&setSystemIcon);
|
||||
connect(&setSystemIcon, &QAction::triggered, [this] {
|
||||
IconSelectionDialog dialog(":/systemicons/");
|
||||
if(dialog.exec() == QDialog::Accepted) {
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
const QString iconName = dialog.getSelectedIconName();
|
||||
// A Blank iconName will cause setIcon to reset to the default
|
||||
selected_sysconfig->setIcon(iconName);
|
||||
@@ -180,28 +172,28 @@ VMManagerMain::VMManagerMain(QWidget *parent) :
|
||||
contextMenu.addAction(&cloneMachine);
|
||||
connect(&cloneMachine, &QAction::triggered, [this] {
|
||||
QDialog dialog = QDialog(this);
|
||||
auto layout = new QVBoxLayout(&dialog);
|
||||
auto layout = new QVBoxLayout(&dialog);
|
||||
layout->setSizeConstraint(QLayout::SetFixedSize);
|
||||
layout->addWidget(new QLabel(tr("Virtual machine \"%1\" (%2) will be cloned into:").arg(selected_sysconfig->displayName, selected_sysconfig->config_dir)));
|
||||
QLineEdit* edit = new QLineEdit(&dialog);
|
||||
QLineEdit *edit = new QLineEdit(&dialog);
|
||||
layout->addWidget(edit);
|
||||
QLabel* errLabel = new QLabel(&dialog);
|
||||
QLabel *errLabel = new QLabel(&dialog);
|
||||
layout->addWidget(errLabel);
|
||||
errLabel->setVisible(false);
|
||||
QDialogButtonBox* buttonBox = new QDialogButtonBox(&dialog);
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(&dialog);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||
layout->addWidget(buttonBox);
|
||||
connect(edit, &QLineEdit::textChanged, this, [errLabel, buttonBox] (const QString& text) {
|
||||
connect(edit, &QLineEdit::textChanged, this, [errLabel, buttonBox](const QString &text) {
|
||||
bool isSpaceOnly = true;
|
||||
#ifdef Q_OS_WINDOWS
|
||||
const char illegalChars[] = "<>:\"|?*\\/";
|
||||
#else
|
||||
const char illegalChars[] = "\\/";
|
||||
#endif
|
||||
for (const auto& curChar : text) {
|
||||
for (const auto &curChar : text) {
|
||||
for (size_t i = 0; i < sizeof(illegalChars) - 1; i++) {
|
||||
if (illegalChars[i] == curChar) {
|
||||
goto illegal_chars;
|
||||
@@ -236,9 +228,9 @@ illegal_chars:
|
||||
});
|
||||
|
||||
if (dialog.exec() > 0) {
|
||||
std::atomic_bool finished{false};
|
||||
std::atomic_bool finished { false };
|
||||
std::atomic_bool errCode;
|
||||
auto vmDir = QDir(vmm_path).canonicalPath();
|
||||
auto vmDir = QDir(vmm_path).canonicalPath();
|
||||
vmDir.append("/");
|
||||
vmDir.append(edit->text());
|
||||
vmDir.append("/");
|
||||
@@ -248,7 +240,7 @@ illegal_chars:
|
||||
return;
|
||||
}
|
||||
|
||||
QProgressDialog* progDialog = new QProgressDialog(this);
|
||||
QProgressDialog *progDialog = new QProgressDialog(this);
|
||||
progDialog->setMaximum(0);
|
||||
progDialog->setMinimum(0);
|
||||
progDialog->setWindowFlags(progDialog->windowFlags() & ~Qt::WindowCloseButtonHint);
|
||||
@@ -266,7 +258,7 @@ illegal_chars:
|
||||
QString dstPath = vmDir;
|
||||
|
||||
std::thread copyThread([&finished, srcPath, dstPath, &errCode] {
|
||||
errCode = copyPath(srcPath, dstPath, true);
|
||||
errCode = copyPath(srcPath, dstPath, true);
|
||||
finished = true;
|
||||
});
|
||||
while (!finished) {
|
||||
@@ -346,7 +338,7 @@ illegal_chars:
|
||||
QDir dir(configDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
@@ -358,7 +350,7 @@ illegal_chars:
|
||||
QDir dir(printerDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
@@ -370,7 +362,7 @@ illegal_chars:
|
||||
QDir dir(screenshotsDir);
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QString("file:///") + dir.canonicalPath()));
|
||||
}
|
||||
});
|
||||
@@ -395,7 +387,7 @@ illegal_chars:
|
||||
}
|
||||
});
|
||||
|
||||
connect(vm_model, &VMManagerModel::globalConfigurationChanged, this, [] () {
|
||||
connect(vm_model, &VMManagerModel::globalConfigurationChanged, this, []() {
|
||||
vmm_main_window->updateSettings();
|
||||
});
|
||||
|
||||
@@ -416,7 +408,7 @@ illegal_chars:
|
||||
|
||||
// Load and apply settings
|
||||
loadSettings();
|
||||
ui->splitter->setSizes({ui->detailsArea->width(), (ui->listView->minimumWidth() * 2)});
|
||||
ui->splitter->setSizes({ ui->detailsArea->width(), (ui->listView->minimumWidth() * 2) });
|
||||
|
||||
// Set up search bar
|
||||
connect(ui->searchBar, &QLineEdit::textChanged, this, &VMManagerMain::searchSystems);
|
||||
@@ -439,14 +431,14 @@ illegal_chars:
|
||||
#if EMU_BUILD_NUM != 0
|
||||
// Start update check after a slight delay
|
||||
QTimer::singleShot(1000, this, [this] {
|
||||
if(updateCheck) {
|
||||
backgroundUpdateCheckStart();
|
||||
}
|
||||
if (updateCheck)
|
||||
backgroundUpdateCheckStart();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
VMManagerMain::~VMManagerMain() {
|
||||
VMManagerMain::~VMManagerMain()
|
||||
{
|
||||
delete ui;
|
||||
delete vm_model;
|
||||
}
|
||||
@@ -459,11 +451,10 @@ VMManagerMain::updateGlobalSettings()
|
||||
|
||||
void
|
||||
VMManagerMain::currentSelectionChanged(const QModelIndex ¤t,
|
||||
const QModelIndex &previous)
|
||||
const QModelIndex &previous)
|
||||
{
|
||||
if(!current.isValid()) {
|
||||
if (!current.isValid())
|
||||
return;
|
||||
}
|
||||
|
||||
/* hack to prevent strange segfaults when adding a machine after
|
||||
removing all machines previously */
|
||||
@@ -472,7 +463,7 @@ VMManagerMain::currentSelectionChanged(const QModelIndex ¤t,
|
||||
selected_sysconfig->config_signal_connected = false;
|
||||
}
|
||||
const auto mapped_index = proxy_model->mapToSource(current);
|
||||
selected_sysconfig = vm_model->getConfigObjectForIndex(mapped_index);
|
||||
selected_sysconfig = vm_model->getConfigObjectForIndex(mapped_index);
|
||||
vm_details->updateData(selected_sysconfig);
|
||||
if (selected_sysconfig->config_signal_connected == false) {
|
||||
connect(selected_sysconfig, &VMManagerSystem::configurationChanged, this, &VMManagerMain::onConfigUpdated);
|
||||
@@ -481,60 +472,59 @@ VMManagerMain::currentSelectionChanged(const QModelIndex ¤t,
|
||||
|
||||
// Emit that the selection changed, include with the process state
|
||||
emit selectionChanged(current, selected_sysconfig->process->state());
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::settingsButtonPressed() {
|
||||
if(!currentSelectionIsValid()) {
|
||||
VMManagerMain::settingsButtonPressed()
|
||||
{
|
||||
if (!currentSelectionIsValid())
|
||||
return;
|
||||
}
|
||||
|
||||
selected_sysconfig->launchSettings();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::startButtonPressed() const
|
||||
{
|
||||
if(!currentSelectionIsValid()) {
|
||||
if (!currentSelectionIsValid())
|
||||
return;
|
||||
}
|
||||
|
||||
selected_sysconfig->startButtonPressed();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::restartButtonPressed() const
|
||||
{
|
||||
if(!currentSelectionIsValid()) {
|
||||
if (!currentSelectionIsValid())
|
||||
return;
|
||||
}
|
||||
selected_sysconfig->restartButtonPressed();
|
||||
|
||||
selected_sysconfig->restartButtonPressed();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::pauseButtonPressed() const
|
||||
{
|
||||
if(!currentSelectionIsValid()) {
|
||||
if (!currentSelectionIsValid())
|
||||
return;
|
||||
}
|
||||
|
||||
selected_sysconfig->pauseButtonPressed();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::shutdownRequestButtonPressed() const
|
||||
{
|
||||
if (!currentSelectionIsValid()) {
|
||||
if (!currentSelectionIsValid())
|
||||
return;
|
||||
}
|
||||
|
||||
selected_sysconfig->shutdownRequestButtonPressed();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::shutdownForceButtonPressed() const
|
||||
{
|
||||
if (!currentSelectionIsValid()) {
|
||||
if (!currentSelectionIsValid())
|
||||
return;
|
||||
}
|
||||
|
||||
selected_sysconfig->shutdownForceButtonPressed();
|
||||
}
|
||||
|
||||
@@ -543,10 +533,10 @@ void
|
||||
VMManagerMain::refresh()
|
||||
{
|
||||
const auto current_index = ui->listView->currentIndex();
|
||||
emit selectionChanged(current_index, selected_sysconfig->process->state());
|
||||
emit selectionChanged(current_index, selected_sysconfig->process->state());
|
||||
|
||||
// if(!selected_sysconfig->config_file.path().isEmpty()) {
|
||||
if(!selected_sysconfig->isValid()) {
|
||||
if (!selected_sysconfig->isValid()) {
|
||||
// what was happening here?
|
||||
}
|
||||
}
|
||||
@@ -621,7 +611,7 @@ VMManagerMain::searchSystems(const QString &text) const
|
||||
{
|
||||
// Escape the search text string unless regular expression searching is enabled.
|
||||
// When escaped, the search string functions as a plain text match.
|
||||
const auto searchText = regexSearch ? text : QRegularExpression::escape(text);
|
||||
const auto searchText = regexSearch ? text : QRegularExpression::escape(text);
|
||||
const QRegularExpression regex(searchText, QRegularExpression::CaseInsensitiveOption);
|
||||
if (!regex.isValid()) {
|
||||
qDebug() << "Skipping, invalid regex";
|
||||
@@ -640,11 +630,11 @@ VMManagerMain::newMachineWizard()
|
||||
{
|
||||
const auto wizard = new VMManagerAddMachine(this);
|
||||
if (wizard->exec() == QDialog::Accepted) {
|
||||
const auto newName = wizard->field("systemName").toString();
|
||||
const auto newName = wizard->field("systemName").toString();
|
||||
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||
const auto systemDir = wizard->field("systemLocation").toString();
|
||||
const auto systemDir = wizard->field("systemLocation").toString();
|
||||
#else
|
||||
const auto systemDir = QDir(vmm_path).path();
|
||||
const auto systemDir = QDir(vmm_path).path();
|
||||
#endif
|
||||
const auto existingConfiguration = wizard->field("existingConfiguration").toString();
|
||||
const auto displayName = wizard->field("displayName").toString();
|
||||
@@ -693,8 +683,7 @@ VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QStri
|
||||
if (exitCode != 0 || exitStatus != QProcess::NormalExit) {
|
||||
qInfo().nospace().noquote() << "Abnormal program termination while creating new system: exit code " << exitCode << ", exit status " << exitStatus;
|
||||
qInfo() << "Not adding system due to errors";
|
||||
QString errMsg = tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg(
|
||||
(!displayName.isEmpty() ? displayName : name), QString::number(exitCode));
|
||||
QString errMsg = tr("The virtual machine \"%1\"'s process has unexpectedly terminated with exit code %2.").arg((!displayName.isEmpty() ? displayName : name), QString::number(exitCode));
|
||||
QMessageBox::critical(this, tr("Error adding system"),
|
||||
QString("%1\n\n%2").arg(errMsg, tr("The system will not be added.")));
|
||||
fail = true;
|
||||
@@ -731,7 +720,6 @@ VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QStri
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
VMManagerMain::deleteSystem(VMManagerSystem *sysconfig)
|
||||
{
|
||||
@@ -804,8 +792,8 @@ VMManagerMain::modelDataChange()
|
||||
auto modelStats = vm_model->getProcessStats();
|
||||
QStringList stats;
|
||||
for (auto it = modelStats.constBegin(); it != modelStats.constEnd(); ++it) {
|
||||
const auto &key = it.key();
|
||||
QString text = "";
|
||||
const auto &key = it.key();
|
||||
QString text = "";
|
||||
switch (key) {
|
||||
case VMManagerSystem::ProcessStatus::Running:
|
||||
text = tr("%n running", "", modelStats[key]);
|
||||
@@ -820,7 +808,7 @@ VMManagerMain::modelDataChange()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!text.isEmpty())
|
||||
if (!text.isEmpty())
|
||||
stats.append(text);
|
||||
}
|
||||
auto states = stats.join(", ");
|
||||
@@ -831,16 +819,14 @@ void
|
||||
VMManagerMain::onPreferencesUpdated()
|
||||
{
|
||||
// Only reload values that we care about
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
const auto oldRegexSearch = regexSearch;
|
||||
regexSearch = config->getStringValue("regex_search").toInt();
|
||||
if (oldRegexSearch != regexSearch) {
|
||||
regexSearch = config->getStringValue("regex_search").toInt();
|
||||
if (oldRegexSearch != regexSearch)
|
||||
ui->searchBar->clear();
|
||||
}
|
||||
|
||||
if (vm_model) {
|
||||
if (vm_model)
|
||||
vm_model->sendGlobalConfigurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -877,9 +863,9 @@ void
|
||||
VMManagerMain::backgroundUpdateCheckStart() const
|
||||
{
|
||||
auto updateChannel = UpdateCheck::UpdateChannel::CI;
|
||||
#ifdef RELEASE_BUILD
|
||||
# ifdef RELEASE_BUILD
|
||||
updateChannel = UpdateCheck::UpdateChannel::Stable;
|
||||
#endif
|
||||
# endif
|
||||
const auto updateCheck = new UpdateCheck(updateChannel);
|
||||
connect(updateCheck, &UpdateCheck::updateCheckComplete, this, &VMManagerMain::backgroundUpdateCheckComplete);
|
||||
connect(updateCheck, &UpdateCheck::updateCheckError, this, &VMManagerMain::backgroundUpdateCheckError);
|
||||
@@ -891,9 +877,9 @@ VMManagerMain::backgroundUpdateCheckComplete(const UpdateCheck::UpdateResult &re
|
||||
{
|
||||
qDebug() << "Check complete: update available?" << result.updateAvailable;
|
||||
if (result.updateAvailable) {
|
||||
auto type = result.channel == UpdateCheck::UpdateChannel::CI ? tr("build") : tr("version");
|
||||
auto type = result.channel == UpdateCheck::UpdateChannel::CI ? tr("build") : tr("version");
|
||||
const auto updateMessage = tr("An update to 86Box is available: %1 %2").arg(type, result.latestVersion);
|
||||
emit updateStatusLeft(updateMessage);
|
||||
emit updateStatusLeft(updateMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -910,7 +896,7 @@ VMManagerMain::showTextFileContents(const QString &title, const QString &path)
|
||||
{
|
||||
// Make sure we can open the file
|
||||
const auto fi = QFileInfo(path);
|
||||
if(!fi.exists()) {
|
||||
if (!fi.exists()) {
|
||||
qWarning("Requested file does not exist: %s", path.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
@@ -927,7 +913,7 @@ VMManagerMain::showTextFileContents(const QString &title, const QString &path)
|
||||
textDisplayDialog->setMinimumSize(QSize(540, 360));
|
||||
textDisplayDialog->setWindowTitle(QString("%1 - %2").arg(title, fi.fileName()));
|
||||
|
||||
const auto textEdit = new QPlainTextEdit();
|
||||
const auto textEdit = new QPlainTextEdit();
|
||||
const auto monospaceFont = new QFont();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
monospaceFont->setFamily("Consolas");
|
||||
|
||||
@@ -32,7 +32,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class VMManagerMain; }
|
||||
namespace Ui {
|
||||
class VMManagerMain;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class VMManagerMain final : public QWidget {
|
||||
@@ -90,24 +92,24 @@ public slots:
|
||||
private:
|
||||
Ui::VMManagerMain *ui;
|
||||
|
||||
VMManagerModel *vm_model;
|
||||
VMManagerDetails *vm_details;
|
||||
VMManagerSystem *selected_sysconfig;
|
||||
VMManagerModel *vm_model;
|
||||
VMManagerDetails *vm_details;
|
||||
VMManagerSystem *selected_sysconfig;
|
||||
// VMManagerConfig *config;
|
||||
QSortFilterProxyModel *proxy_model;
|
||||
#if EMU_BUILD_NUM != 0
|
||||
bool updateCheck = false;
|
||||
bool updateCheck = false;
|
||||
#endif
|
||||
bool regexSearch = false;
|
||||
bool regexSearch = false;
|
||||
|
||||
// void updateSelection(const QItemSelection &selected,
|
||||
// const QItemSelection &deselected);
|
||||
void currentSelectionChanged(const QModelIndex ¤t,
|
||||
const QModelIndex &previous);
|
||||
void refresh();
|
||||
void updateDisplayName(const QModelIndex &index);
|
||||
void loadSettings();
|
||||
[[nodiscard]] bool currentSelectionIsValid() const;
|
||||
void currentSelectionChanged(const QModelIndex ¤t,
|
||||
const QModelIndex &previous);
|
||||
void refresh();
|
||||
void updateDisplayName(const QModelIndex &index);
|
||||
void loadSettings();
|
||||
[[nodiscard]] bool currentSelectionIsValid() const;
|
||||
[[nodiscard]] QString machineCountString(QString states = "") const;
|
||||
#if EMU_BUILD_NUM != 0
|
||||
void backgroundUpdateCheckStart() const;
|
||||
@@ -129,7 +131,10 @@ class IconSelectionDialog final : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IconSelectionDialog(QString assetPath, QWidget *parent = nullptr) : QDialog(parent), listWidget(new QListWidget) {
|
||||
explicit IconSelectionDialog(QString assetPath, QWidget *parent = nullptr)
|
||||
: QDialog(parent)
|
||||
, listWidget(new QListWidget)
|
||||
{
|
||||
// Set the list widget to icon mode
|
||||
listWidget->setViewMode(QListWidget::IconMode);
|
||||
setFixedSize(QSize(540, 360));
|
||||
@@ -143,7 +148,7 @@ public:
|
||||
setWindowTitle(tr("Select an icon"));
|
||||
|
||||
// Loop on all files and add them as items (icons) in QListWidget
|
||||
for(const QString& iconName : iconsDir.entryList()) {
|
||||
for (const QString &iconName : iconsDir.entryList()) {
|
||||
const auto item = new QListWidgetItem(QIcon(assetPath + iconName), iconName);
|
||||
// Set the UserRole to the resource bundle path
|
||||
item->setData(Qt::UserRole, assetPath + iconName);
|
||||
@@ -153,7 +158,7 @@ public:
|
||||
// Dialog buttons
|
||||
const auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Reset);
|
||||
// Use the reset button for resetting the icon to the default
|
||||
const QPushButton* resetButton = buttonBox->button(QDialogButtonBox::Reset);
|
||||
const QPushButton *resetButton = buttonBox->button(QDialogButtonBox::Reset);
|
||||
|
||||
// Connect the buttons signals
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
@@ -171,8 +176,9 @@ public:
|
||||
layout->addWidget(buttonBox);
|
||||
}
|
||||
|
||||
public slots:
|
||||
[[nodiscard]] QString getSelectedIconName() const {
|
||||
public slots:
|
||||
[[nodiscard]] QString getSelectedIconName() const
|
||||
{
|
||||
if (listWidget->currentIndex().isValid()) {
|
||||
return listWidget->currentItem()->data(Qt::UserRole).toString();
|
||||
}
|
||||
@@ -181,7 +187,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
QListWidget* listWidget;
|
||||
QListWidget *listWidget;
|
||||
};
|
||||
|
||||
#endif //QT_VMMANAGER_MAIN_H
|
||||
#endif // QT_VMMANAGER_MAIN_H
|
||||
|
||||
@@ -30,17 +30,16 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QDesktopServices>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
extern void config_load_global();
|
||||
extern void config_save_global();
|
||||
}
|
||||
|
||||
VMManagerMainWindow* vmm_main_window = nullptr;
|
||||
extern WindowsDarkModeFilter* vmm_dark_mode_filter;
|
||||
VMManagerMainWindow *vmm_main_window = nullptr;
|
||||
extern WindowsDarkModeFilter *vmm_dark_mode_filter;
|
||||
|
||||
VMManagerMainWindow::
|
||||
VMManagerMainWindow(QWidget *parent)
|
||||
VMManagerMainWindow(QWidget *parent)
|
||||
: ui(new Ui::VMManagerMainWindow)
|
||||
, vmm(new VMManagerMain(this))
|
||||
, statusLeft(new QLabel)
|
||||
@@ -63,14 +62,14 @@ VMManagerMainWindow(QWidget *parent)
|
||||
connect(ui->actionHard_Reset, &QAction::triggered, vmm, &VMManagerMain::restartButtonPressed);
|
||||
connect(ui->actionForce_Shutdown, &QAction::triggered, vmm, &VMManagerMain::shutdownForceButtonPressed);
|
||||
|
||||
// Set up menu actions
|
||||
// (Disable this if the EMU_BUILD_NUM == 0)
|
||||
#if EMU_BUILD_NUM == 0
|
||||
ui->actionCheck_for_updates->setVisible(false);
|
||||
#else
|
||||
connect(ui->actionCheck_for_updates, &QAction::triggered, this, &VMManagerMainWindow::checkForUpdatesTriggered);
|
||||
#endif
|
||||
|
||||
// Set up menu actions
|
||||
// (Disable this if the EMU_BUILD_NUM == 0)
|
||||
#if EMU_BUILD_NUM == 0
|
||||
ui->actionCheck_for_updates->setVisible(false);
|
||||
#else
|
||||
connect(ui->actionCheck_for_updates, &QAction::triggered, this, &VMManagerMainWindow::checkForUpdatesTriggered);
|
||||
#endif
|
||||
|
||||
// TODO: Remove all of this (all the way to END REMOVE) once certain the search will no longer be in the toolbar.
|
||||
// BEGIN REMOVE
|
||||
// Everything is still setup here for it but it is all hidden. None of it will be
|
||||
@@ -90,7 +89,7 @@ VMManagerMainWindow(QWidget *parent)
|
||||
searchBar->setClearButtonEnabled(true);
|
||||
// Spacer to make the search go all the way to the right
|
||||
const auto spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
ui->toolBar->addWidget(spacer);
|
||||
ui->toolBar->addWidget(searchBar);
|
||||
// Connect signal for search
|
||||
@@ -127,7 +126,7 @@ VMManagerMainWindow(QWidget *parent)
|
||||
connect(this, &VMManagerMainWindow::languageUpdated, vmm, &VMManagerMain::onLanguageUpdated);
|
||||
#ifdef Q_OS_WINDOWS
|
||||
connect(this, &VMManagerMainWindow::darkModeUpdated, vmm, &VMManagerMain::onDarkModeUpdated);
|
||||
connect(this, &VMManagerMainWindow::preferencesUpdated, [] () { vmm_dark_mode_filter->reselectDarkMode(); });
|
||||
connect(this, &VMManagerMainWindow::preferencesUpdated, []() { vmm_dark_mode_filter->reselectDarkMode(); });
|
||||
#endif
|
||||
|
||||
{
|
||||
@@ -136,7 +135,7 @@ VMManagerMainWindow(QWidget *parent)
|
||||
QString coords = config->getStringValue("window_coordinates");
|
||||
if (!coords.isEmpty()) {
|
||||
QStringList list = coords.split(',');
|
||||
for (auto& cur : list) {
|
||||
for (auto &cur : list) {
|
||||
cur = cur.trimmed();
|
||||
}
|
||||
QRect geom;
|
||||
@@ -155,7 +154,7 @@ VMManagerMainWindow(QWidget *parent)
|
||||
QString splitter = config->getStringValue("window_splitter");
|
||||
if (!splitter.isEmpty()) {
|
||||
QStringList list = splitter.split(',');
|
||||
for (auto& cur : list) {
|
||||
for (auto &cur : list) {
|
||||
cur = cur.trimmed();
|
||||
}
|
||||
QList<int> paneSizes;
|
||||
@@ -173,8 +172,7 @@ VMManagerMainWindow(QWidget *parent)
|
||||
}
|
||||
}
|
||||
|
||||
VMManagerMainWindow::~
|
||||
VMManagerMainWindow()
|
||||
VMManagerMainWindow::~VMManagerMainWindow()
|
||||
= default;
|
||||
|
||||
void
|
||||
@@ -224,7 +222,7 @@ void
|
||||
VMManagerMainWindow::saveSettings() const
|
||||
{
|
||||
const auto currentSelection = vmm->getCurrentSelection();
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
config->setStringValue("last_selection", currentSelection);
|
||||
if (!!config->getStringValue("window_remember").toInt()) {
|
||||
config->setStringValue("window_coordinates", QString::asprintf("%i, %i, %i, %i", this->geometry().x(), this->geometry().y(), this->geometry().width(), this->geometry().height()));
|
||||
@@ -249,7 +247,6 @@ VMManagerMainWindow::updateLanguage()
|
||||
emit languageUpdated();
|
||||
}
|
||||
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
void
|
||||
VMManagerMainWindow::updateDarkMode()
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace Ui {
|
||||
class VMManagerMainWindow;
|
||||
}
|
||||
|
||||
class VMManagerMainWindow final : public QMainWindow
|
||||
{
|
||||
class VMManagerMainWindow final : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VMManagerMainWindow(QWidget *parent = nullptr);
|
||||
@@ -41,10 +40,12 @@ signals:
|
||||
|
||||
private:
|
||||
Ui::VMManagerMainWindow *ui;
|
||||
|
||||
VMManagerMain *vmm;
|
||||
void saveSettings() const;
|
||||
QLabel *statusLeft;
|
||||
QLabel *statusRight;
|
||||
void saveSettings() const;
|
||||
QLabel *statusLeft;
|
||||
QLabel *statusRight;
|
||||
|
||||
public slots:
|
||||
void setStatusLeft(const QString &text) const;
|
||||
void setStatusRight(const QString &text) const;
|
||||
|
||||
@@ -15,28 +15,32 @@
|
||||
#include <QDebug>
|
||||
#include "qt_vmmanager_model.hpp"
|
||||
|
||||
VMManagerModel::VMManagerModel() {
|
||||
VMManagerModel::VMManagerModel()
|
||||
{
|
||||
auto machines_vec = VMManagerSystem::scanForConfigs();
|
||||
for ( const auto& each_config : machines_vec) {
|
||||
for (const auto &each_config : machines_vec) {
|
||||
machines.append(each_config);
|
||||
connect(each_config, &VMManagerSystem::itemDataChanged, this, &VMManagerModel::modelDataChanged);
|
||||
connect(each_config, &VMManagerSystem::globalConfigurationChanged, this, &VMManagerModel::globalConfigurationChanged);
|
||||
}
|
||||
}
|
||||
|
||||
VMManagerModel::~VMManagerModel() {
|
||||
for ( auto machine : machines) {
|
||||
VMManagerModel::~VMManagerModel()
|
||||
{
|
||||
for (auto machine : machines) {
|
||||
delete machine;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
VMManagerModel::rowCount(const QModelIndex &parent) const {
|
||||
VMManagerModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return machines.size();
|
||||
}
|
||||
|
||||
QVariant
|
||||
VMManagerModel::data(const QModelIndex &index, int role) const {
|
||||
VMManagerModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return {};
|
||||
|
||||
@@ -76,7 +80,8 @@ VMManagerModel::data(const QModelIndex &index, int role) const {
|
||||
}
|
||||
|
||||
QVariant
|
||||
VMManagerModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
VMManagerModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return {};
|
||||
@@ -93,7 +98,7 @@ VMManagerModel::getConfigObjectForIndex(const QModelIndex &index) const
|
||||
return machines.at(index.row());
|
||||
}
|
||||
void
|
||||
VMManagerModel::reload(QWidget* parent)
|
||||
VMManagerModel::reload(QWidget *parent)
|
||||
{
|
||||
// Scan for configs
|
||||
auto machines_vec = VMManagerSystem::scanForConfigs(parent);
|
||||
@@ -112,16 +117,17 @@ VMManagerModel::reload(QWidget* parent)
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerModel::refreshConfigs() {
|
||||
for ( const auto& each_config : machines)
|
||||
VMManagerModel::refreshConfigs()
|
||||
{
|
||||
for (const auto &each_config : machines)
|
||||
each_config->reloadConfig();
|
||||
}
|
||||
|
||||
QModelIndex
|
||||
VMManagerModel::getIndexForConfigFile(const QFileInfo& config_file)
|
||||
VMManagerModel::getIndexForConfigFile(const QFileInfo &config_file)
|
||||
{
|
||||
int object_index = 0;
|
||||
for (const auto& config_object: machines) {
|
||||
for (const auto &config_object : machines) {
|
||||
if (config_object->config_file == config_file) {
|
||||
return this->index(object_index);
|
||||
}
|
||||
@@ -155,7 +161,7 @@ void
|
||||
VMManagerModel::modelDataChanged()
|
||||
{
|
||||
// Inform the model
|
||||
emit dataChanged(this->index(0), this->index(machines.size()-1));
|
||||
emit dataChanged(this->index(0), this->index(machines.size() - 1));
|
||||
// Inform any interested observers
|
||||
emit systemDataChanged();
|
||||
}
|
||||
@@ -170,7 +176,7 @@ QMap<VMManagerSystem::ProcessStatus, int>
|
||||
VMManagerModel::getProcessStats()
|
||||
{
|
||||
QMap<VMManagerSystem::ProcessStatus, int> stats;
|
||||
for (const auto& system: machines) {
|
||||
for (const auto &system : machines) {
|
||||
stats[system->getProcessStatus()] += 1;
|
||||
}
|
||||
return stats;
|
||||
@@ -179,7 +185,7 @@ VMManagerModel::getProcessStats()
|
||||
void
|
||||
VMManagerModel::sendGlobalConfigurationChanged()
|
||||
{
|
||||
for (auto& system: machines) {
|
||||
for (auto &system : machines) {
|
||||
if (system->getProcessStatus() != VMManagerSystem::ProcessStatus::Stopped) {
|
||||
system->sendGlobalConfigurationChanged();
|
||||
}
|
||||
@@ -190,7 +196,7 @@ int
|
||||
VMManagerModel::getActiveMachineCount()
|
||||
{
|
||||
int running = 0;
|
||||
for (const auto& system: machines) {
|
||||
for (const auto &system : machines) {
|
||||
if (system->getProcessStatus() != VMManagerSystem::ProcessStatus::Stopped)
|
||||
running++;
|
||||
}
|
||||
|
||||
@@ -42,29 +42,29 @@ public:
|
||||
Icon
|
||||
};
|
||||
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||
[[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role) const override;
|
||||
void addConfigToModel(VMManagerSystem *system_config);
|
||||
void removeConfigFromModel(VMManagerSystem *system_config);
|
||||
int role) const override;
|
||||
void addConfigToModel(VMManagerSystem *system_config);
|
||||
void removeConfigFromModel(VMManagerSystem *system_config);
|
||||
|
||||
[[nodiscard]] VMManagerSystem * getConfigObjectForIndex(const QModelIndex &index) const;
|
||||
QModelIndex getIndexForConfigFile(const QFileInfo& config_file);
|
||||
void reload(QWidget* parent = nullptr);
|
||||
void updateDisplayName(const QModelIndex &index, const QString &newDisplayName);
|
||||
[[nodiscard]] VMManagerSystem *getConfigObjectForIndex(const QModelIndex &index) const;
|
||||
QModelIndex getIndexForConfigFile(const QFileInfo &config_file);
|
||||
void reload(QWidget *parent = nullptr);
|
||||
void updateDisplayName(const QModelIndex &index, const QString &newDisplayName);
|
||||
QMap<VMManagerSystem::ProcessStatus, int> getProcessStats();
|
||||
int getActiveMachineCount();
|
||||
void refreshConfigs();
|
||||
void sendGlobalConfigurationChanged();
|
||||
int getActiveMachineCount();
|
||||
void refreshConfigs();
|
||||
void sendGlobalConfigurationChanged();
|
||||
|
||||
signals:
|
||||
void systemDataChanged();
|
||||
void globalConfigurationChanged();
|
||||
|
||||
private:
|
||||
QVector<VMManagerSystem *> machines;
|
||||
void modelDataChanged();
|
||||
|
||||
void modelDataChanged();
|
||||
};
|
||||
|
||||
// Note: Custom QSortFilterProxyModel is included here instead of its own file as
|
||||
@@ -72,10 +72,14 @@ private:
|
||||
|
||||
class StringListProxyModel final : public QSortFilterProxyModel {
|
||||
public:
|
||||
explicit StringListProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) {}
|
||||
explicit StringListProxyModel(QObject *parent = nullptr)
|
||||
: QSortFilterProxyModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
[[nodiscard]] bool filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const override {
|
||||
[[nodiscard]] bool filterAcceptsRow(const int sourceRow, const QModelIndex &sourceParent) const override
|
||||
{
|
||||
const QModelIndex index = sourceModel()->index(sourceRow, filterKeyColumn(), sourceParent);
|
||||
|
||||
QStringList stringList = sourceModel()->data(index, VMManagerModel::Roles::SearchList).toStringList();
|
||||
@@ -89,4 +93,4 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
#endif //QT_VMMANAGER_MODEL_H
|
||||
#endif // QT_VMMANAGER_MODEL_H
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include "ui_qt_vmmanager_preferences.h"
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include "qt_vmmanager_windarkmodefilter.hpp"
|
||||
extern WindowsDarkModeFilter* vmm_dark_mode_filter;
|
||||
# include "qt_vmmanager_windarkmodefilter.hpp"
|
||||
extern WindowsDarkModeFilter *vmm_dark_mode_filter;
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
@@ -33,18 +33,19 @@ extern "C" {
|
||||
}
|
||||
|
||||
VMManagerPreferences::
|
||||
VMManagerPreferences(QWidget *parent) : ui(new Ui::VMManagerPreferences)
|
||||
VMManagerPreferences(QWidget *parent)
|
||||
: ui(new Ui::VMManagerPreferences)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->dirSelectButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirIcon));
|
||||
connect(ui->dirSelectButton, &QPushButton::clicked, this, &VMManagerPreferences::chooseDirectoryLocation);
|
||||
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
const auto configSystemDir = QString(vmm_path_cfg);
|
||||
if(!configSystemDir.isEmpty()) {
|
||||
if (!configSystemDir.isEmpty()) {
|
||||
// Prefer this one
|
||||
ui->systemDirectory->setText(QDir::toNativeSeparators(configSystemDir));
|
||||
} else if(!QString(vmm_path).isEmpty()) {
|
||||
} else if (!QString(vmm_path).isEmpty()) {
|
||||
// If specified on command line
|
||||
ui->systemDirectory->setText(QDir::toNativeSeparators(QDir(vmm_path).path()));
|
||||
}
|
||||
@@ -79,8 +80,7 @@ VMManagerPreferences(QWidget *parent) : ui(new Ui::VMManagerPreferences)
|
||||
#endif
|
||||
}
|
||||
|
||||
VMManagerPreferences::~
|
||||
VMManagerPreferences()
|
||||
VMManagerPreferences::~VMManagerPreferences()
|
||||
= default;
|
||||
|
||||
// Bad copy pasta from machine add
|
||||
@@ -104,7 +104,7 @@ VMManagerPreferences::accept()
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
|
||||
strncpy(vmm_path_cfg, QDir::cleanPath(ui->systemDirectory->text()).toUtf8().constData(), sizeof(vmm_path_cfg) - 1);
|
||||
lang_id = ui->comboBoxLanguage->currentData().toInt();
|
||||
lang_id = ui->comboBoxLanguage->currentData().toInt();
|
||||
color_scheme = (ui->radioButtonSystem->isChecked()) ? 0 : (ui->radioButtonLight->isChecked() ? 1 : 2);
|
||||
config_save_global();
|
||||
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Header for 86Box VM manager preferences module
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2024 cold-brewed
|
||||
*/
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Header for 86Box VM manager preferences module
|
||||
*
|
||||
* Authors: cold-brewed
|
||||
*
|
||||
* Copyright 2024 cold-brewed
|
||||
*/
|
||||
#ifndef VMMANAGER_PREFERENCES_H
|
||||
#define VMMANAGER_PREFERENCES_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class VMManagerPreferences; }
|
||||
namespace Ui {
|
||||
class VMManagerPreferences;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
class VMManagerPreferences final : public QDialog
|
||||
{
|
||||
class VMManagerPreferences final : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VMManagerPreferences(QWidget *parent = nullptr);
|
||||
@@ -31,14 +31,14 @@ public:
|
||||
|
||||
private:
|
||||
Ui::VMManagerPreferences *ui;
|
||||
QString settingsFile;
|
||||
QString settingsFile;
|
||||
private slots:
|
||||
void chooseDirectoryLocation();
|
||||
void on_pushButtonLanguage_released();
|
||||
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
|
||||
};
|
||||
|
||||
#endif // VMMANAGER_PREFERENCES_H
|
||||
|
||||
@@ -22,12 +22,12 @@ VMManagerProtocol::VMManagerProtocol(VMManagerProtocol::Sender sender)
|
||||
}
|
||||
|
||||
VMManagerProtocol::~VMManagerProtocol()
|
||||
= default;
|
||||
= default;
|
||||
|
||||
QJsonObject
|
||||
VMManagerProtocol::protocolManagerMessage(VMManagerProtocol::ManagerMessage message_type)
|
||||
{
|
||||
auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Manager);
|
||||
auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Manager);
|
||||
json_message["message"] = managerMessageTypeToString(message_type);
|
||||
return json_message;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ VMManagerProtocol::protocolManagerMessage(VMManagerProtocol::ManagerMessage mess
|
||||
QJsonObject
|
||||
VMManagerProtocol::protocolClientMessage(VMManagerProtocol::ClientMessage message_type)
|
||||
{
|
||||
auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Client);
|
||||
auto json_message = constructDefaultObject(VMManagerProtocol::Sender::Client);
|
||||
json_message["message"] = clientMessageTypeToString(message_type);
|
||||
return json_message;
|
||||
}
|
||||
@@ -58,16 +58,16 @@ QJsonObject
|
||||
VMManagerProtocol::constructDefaultObject(VMManagerProtocol::Sender type)
|
||||
{
|
||||
QJsonObject json_message;
|
||||
QString sender_type = ( type == VMManagerProtocol::Sender::Client ) ? "Client" : "VMManager";
|
||||
json_message["type"] = QString(sender_type);
|
||||
QString sender_type = (type == VMManagerProtocol::Sender::Client) ? "Client" : "VMManager";
|
||||
json_message["type"] = QString(sender_type);
|
||||
json_message["version"] = QStringLiteral(EMU_VERSION);
|
||||
return json_message;
|
||||
}
|
||||
|
||||
bool
|
||||
VMManagerProtocol::hasRequiredFields(const QJsonObject& json_document)
|
||||
VMManagerProtocol::hasRequiredFields(const QJsonObject &json_document)
|
||||
{
|
||||
for (const auto& field : ProtocolRequiredFields) {
|
||||
for (const auto &field : ProtocolRequiredFields) {
|
||||
if (!json_document.contains(field)) {
|
||||
qDebug("Received json missing field \"%s\"", qPrintable(field));
|
||||
return false;
|
||||
@@ -83,21 +83,21 @@ VMManagerProtocol::getClientMessageType(const QJsonObject &json_document)
|
||||
// required values.
|
||||
QString message_type = json_document.value("message").toString();
|
||||
// Can't use switch with strings, manual compare
|
||||
if (message_type == "Status") {
|
||||
if (message_type == "Status")
|
||||
return VMManagerProtocol::ClientMessage::Status;
|
||||
} else if (message_type == "WindowBlocked") {
|
||||
else if (message_type == "WindowBlocked")
|
||||
return VMManagerProtocol::ClientMessage::WindowBlocked;
|
||||
} else if (message_type == "WindowUnblocked") {
|
||||
else if (message_type == "WindowUnblocked")
|
||||
return VMManagerProtocol::ClientMessage::WindowUnblocked;
|
||||
} else if (message_type == "RunningStateChanged") {
|
||||
else if (message_type == "RunningStateChanged")
|
||||
return VMManagerProtocol::ClientMessage::RunningStateChanged;
|
||||
} else if (message_type == "ConfigurationChanged") {
|
||||
else if (message_type == "ConfigurationChanged")
|
||||
return VMManagerProtocol::ClientMessage::ConfigurationChanged;
|
||||
} else if (message_type == "WinIdMessage") {
|
||||
else if (message_type == "WinIdMessage")
|
||||
return VMManagerProtocol::ClientMessage::WinIdMessage;
|
||||
} else if (message_type == "GlobalConfigurationChanged") {
|
||||
else if (message_type == "GlobalConfigurationChanged")
|
||||
return VMManagerProtocol::ClientMessage::GlobalConfigurationChanged;
|
||||
}
|
||||
|
||||
return VMManagerProtocol::ClientMessage::UnknownMessage;
|
||||
}
|
||||
|
||||
@@ -108,23 +108,29 @@ VMManagerProtocol::getManagerMessageType(const QJsonObject &json_document)
|
||||
// required values.
|
||||
QString message_type = json_document.value("message").toString();
|
||||
// Can't use switch with strings, manual compare
|
||||
if (message_type == "RequestStatus") {
|
||||
if (message_type == "RequestStatus")
|
||||
return VMManagerProtocol::ManagerMessage::RequestStatus;
|
||||
} else if (message_type == "Pause") {
|
||||
else if (message_type == "Pause")
|
||||
return VMManagerProtocol::ManagerMessage::Pause;
|
||||
} if (message_type == "CtrlAltDel") {
|
||||
|
||||
if (message_type == "CtrlAltDel")
|
||||
return VMManagerProtocol::ManagerMessage::CtrlAltDel;
|
||||
} if (message_type == "ShowSettings") {
|
||||
|
||||
if (message_type == "ShowSettings")
|
||||
return VMManagerProtocol::ManagerMessage::ShowSettings;
|
||||
} if (message_type == "ResetVM") {
|
||||
|
||||
if (message_type == "ResetVM")
|
||||
return VMManagerProtocol::ManagerMessage::ResetVM;
|
||||
} if (message_type == "RequestShutdown") {
|
||||
|
||||
if (message_type == "RequestShutdown")
|
||||
return VMManagerProtocol::ManagerMessage::RequestShutdown;
|
||||
} if (message_type == "ForceShutdown") {
|
||||
|
||||
if (message_type == "ForceShutdown")
|
||||
return VMManagerProtocol::ManagerMessage::ForceShutdown;
|
||||
} if (message_type == "GlobalConfigurationChanged") {
|
||||
|
||||
if (message_type == "GlobalConfigurationChanged")
|
||||
return VMManagerProtocol::ManagerMessage::GlobalConfigurationChanged;
|
||||
}
|
||||
|
||||
return VMManagerProtocol::ManagerMessage::UnknownMessage;
|
||||
}
|
||||
|
||||
@@ -134,8 +140,8 @@ VMManagerProtocol::getParams(const QJsonObject &json_document)
|
||||
// FIXME: This key ("params") is hardcoded here. Make a hash which maps these
|
||||
// required values.
|
||||
auto params_object = json_document.value("params");
|
||||
if (params_object.type() != QJsonValue::Object) {
|
||||
if (params_object.type() != QJsonValue::Object)
|
||||
return {};
|
||||
}
|
||||
|
||||
return params_object.toObject();
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
|
||||
VMManagerServerSocket::VMManagerServerSocket(const QFileInfo &config_path, const ServerType type)
|
||||
{
|
||||
server_type = type;
|
||||
config_file = config_path;
|
||||
server_type = type;
|
||||
config_file = config_path;
|
||||
serverIsRunning = false;
|
||||
socket = nullptr;
|
||||
server = new QLocalServer;
|
||||
socket = nullptr;
|
||||
server = new QLocalServer;
|
||||
setupVars();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ VMManagerServerSocket::~VMManagerServerSocket()
|
||||
}
|
||||
|
||||
bool
|
||||
VMManagerServerSocket::startServer() {
|
||||
VMManagerServerSocket::startServer()
|
||||
{
|
||||
|
||||
// Remove socket file (if it exists) in order to start a new one
|
||||
qInfo("Socket path is %s", qPrintable(socket_path.filePath()));
|
||||
@@ -60,10 +61,11 @@ VMManagerServerSocket::startServer() {
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerServerSocket::serverConnectionReceived() {
|
||||
VMManagerServerSocket::serverConnectionReceived()
|
||||
{
|
||||
qDebug("Connection received on %s", qPrintable(socket_path.fileName()));
|
||||
socket = server->nextPendingConnection();
|
||||
if(!socket) {
|
||||
if (!socket) {
|
||||
qInfo("Invalid socket when trying to receive the connection");
|
||||
return;
|
||||
}
|
||||
@@ -72,14 +74,15 @@ VMManagerServerSocket::serverConnectionReceived() {
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerServerSocket::serverReceivedMessage() {
|
||||
VMManagerServerSocket::serverReceivedMessage()
|
||||
{
|
||||
|
||||
// Handle legacy socket connections first. These connections only receive
|
||||
// information on window status
|
||||
if(server_type == VMManagerServerSocket::ServerType::Legacy) {
|
||||
QByteArray tempString = socket->read(1);
|
||||
int window_obscured = tempString.toInt();
|
||||
emit windowStatusChanged(window_obscured);
|
||||
if (server_type == VMManagerServerSocket::ServerType::Legacy) {
|
||||
QByteArray tempString = socket->read(1);
|
||||
int window_obscured = tempString.toInt();
|
||||
emit windowStatusChanged(window_obscured);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,7 +96,7 @@ VMManagerServerSocket::serverReceivedMessage() {
|
||||
// Try to read the data
|
||||
stream >> jsonData;
|
||||
if (stream.commitTransaction()) {
|
||||
QJsonParseError parse_error{};
|
||||
QJsonParseError parse_error {};
|
||||
// Validate the received data to make sure it's valid json
|
||||
const QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData, &parse_error);
|
||||
if (parse_error.error == QJsonParseError::NoError) {
|
||||
@@ -115,8 +118,9 @@ VMManagerServerSocket::serverReceivedMessage() {
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerServerSocket::serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList& arguments) const {
|
||||
if(!socket) {
|
||||
VMManagerServerSocket::serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList &arguments) const
|
||||
{
|
||||
if (!socket) {
|
||||
qInfo("Cannot send message: Invalid socket");
|
||||
return;
|
||||
}
|
||||
@@ -124,7 +128,7 @@ VMManagerServerSocket::serverSendMessage(VMManagerProtocol::ManagerMessage proto
|
||||
// Regular connection
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_5_7);
|
||||
auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Manager);
|
||||
auto packet = new VMManagerProtocol(VMManagerProtocol::Sender::Manager);
|
||||
auto jsonMessage = packet->protocolManagerMessage(protocol_message);
|
||||
stream << QJsonDocument(jsonMessage).toJson(QJsonDocument::Compact);
|
||||
}
|
||||
@@ -145,7 +149,7 @@ VMManagerServerSocket::jsonReceived(const QJsonObject &json)
|
||||
qDebug() << json;
|
||||
return;
|
||||
}
|
||||
// qDebug().noquote() << Q_FUNC_INFO << json;
|
||||
// qDebug().noquote() << Q_FUNC_INFO << json;
|
||||
QJsonObject params_object;
|
||||
|
||||
auto message_type = VMManagerProtocol::getClientMessageType(json);
|
||||
@@ -155,7 +159,7 @@ VMManagerServerSocket::jsonReceived(const QJsonObject &json)
|
||||
params_object = VMManagerProtocol::getParams(json);
|
||||
if (!params_object.isEmpty()) {
|
||||
// valid object
|
||||
if(params_object.value("params").type() == QJsonValue::Double) {
|
||||
if (params_object.value("params").type() == QJsonValue::Double) {
|
||||
emit winIdReceived(params_object.value("params").toVariant().toULongLong());
|
||||
}
|
||||
}
|
||||
@@ -176,7 +180,7 @@ VMManagerServerSocket::jsonReceived(const QJsonObject &json)
|
||||
params_object = VMManagerProtocol::getParams(json);
|
||||
if (!params_object.isEmpty()) {
|
||||
// valid object
|
||||
if(params_object.value("status").type() == QJsonValue::Double) {
|
||||
if (params_object.value("status").type() == QJsonValue::Double) {
|
||||
// has status key, value is an int (qt assigns it as Double)
|
||||
emit runningStatusChanged(static_cast<VMManagerProtocol::RunningState>(params_object.value("status").toInt()));
|
||||
}
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
|
||||
// This macro helps give us the required `qHash()` function in order to use the
|
||||
// enum as a hash key
|
||||
#define QHASH_FOR_CLASS_ENUM(T) \
|
||||
inline uint qHash(const T &t, uint seed) { \
|
||||
return ::qHash(static_cast<typename std::underlying_type<T>::type>(t), seed); \
|
||||
}
|
||||
#define QHASH_FOR_CLASS_ENUM(T) \
|
||||
inline uint qHash(const T &t, uint seed) \
|
||||
{ \
|
||||
return ::qHash(static_cast<typename std::underlying_type<T>::type>(t), seed); \
|
||||
}
|
||||
|
||||
class VMManagerServerSocket : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum class ServerType {
|
||||
Standard,
|
||||
Legacy,
|
||||
@@ -53,16 +53,16 @@ public:
|
||||
QLocalServer *server;
|
||||
QLocalSocket *socket;
|
||||
ServerType server_type;
|
||||
bool serverIsRunning;
|
||||
bool serverIsRunning;
|
||||
|
||||
// Server functions
|
||||
bool startServer();
|
||||
void serverConnectionReceived();
|
||||
void serverReceivedMessage();
|
||||
void serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList& arguments = QStringList()) const;
|
||||
bool startServer();
|
||||
void serverConnectionReceived();
|
||||
void serverReceivedMessage();
|
||||
void serverSendMessage(VMManagerProtocol::ManagerMessage protocol_message, const QStringList &arguments = QStringList()) const;
|
||||
static void serverDisconnected();
|
||||
void jsonReceived(const QJsonObject &json);
|
||||
QString getSocketPath() const;
|
||||
void jsonReceived(const QJsonObject &json);
|
||||
QString getSocketPath() const;
|
||||
|
||||
static QString serverTypeToString(ServerType server_type_lookup);
|
||||
|
||||
@@ -75,8 +75,6 @@ signals:
|
||||
void configurationChanged();
|
||||
void globalConfigurationChanged();
|
||||
void winIdReceived(WId id);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // QT_VMMANAGER_SERVERSOCKET_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,43 +26,44 @@
|
||||
|
||||
// This macro helps give us the required `qHash()` function in order to use the
|
||||
// enum as a hash key
|
||||
#define QHASH_FOR_CLASS_ENUM(T) \
|
||||
inline uint qHash(const T &t, uint seed) { \
|
||||
return ::qHash(static_cast<typename std::underlying_type<T>::type>(t), seed); \
|
||||
}
|
||||
#define QHASH_FOR_CLASS_ENUM(T) \
|
||||
inline uint qHash(const T &t, uint seed) \
|
||||
{ \
|
||||
return ::qHash(static_cast<typename std::underlying_type<T>::type>(t), seed); \
|
||||
}
|
||||
|
||||
namespace VMManager {
|
||||
Q_NAMESPACE
|
||||
namespace Display {
|
||||
Q_NAMESPACE
|
||||
enum class Name {
|
||||
Machine,
|
||||
CPU,
|
||||
Memory,
|
||||
Video,
|
||||
Disks,
|
||||
Floppy,
|
||||
CD,
|
||||
RDisk,
|
||||
MO,
|
||||
SCSIController,
|
||||
StorageController,
|
||||
MidiOut,
|
||||
Joystick,
|
||||
Serial,
|
||||
Parallel,
|
||||
Audio,
|
||||
Voodoo,
|
||||
NIC,
|
||||
Keyboard,
|
||||
Mouse,
|
||||
IsaRtc,
|
||||
IsaMem,
|
||||
IsaRom,
|
||||
Unknown
|
||||
};
|
||||
Q_ENUM_NS(Name)
|
||||
QHASH_FOR_CLASS_ENUM(Name)
|
||||
Q_NAMESPACE
|
||||
enum class Name {
|
||||
Machine,
|
||||
CPU,
|
||||
Memory,
|
||||
Video,
|
||||
Disks,
|
||||
Floppy,
|
||||
CD,
|
||||
RDisk,
|
||||
MO,
|
||||
SCSIController,
|
||||
StorageController,
|
||||
MidiOut,
|
||||
Joystick,
|
||||
Serial,
|
||||
Parallel,
|
||||
Audio,
|
||||
Voodoo,
|
||||
NIC,
|
||||
Keyboard,
|
||||
Mouse,
|
||||
IsaRtc,
|
||||
IsaMem,
|
||||
IsaRom,
|
||||
Unknown
|
||||
};
|
||||
Q_ENUM_NS(Name)
|
||||
QHASH_FOR_CLASS_ENUM(Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +71,9 @@ class VMManagerSystem : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
typedef QHash<VMManager::Display::Name, QString> display_table_t;
|
||||
typedef QHash <QString, QHash <QString, QString>> config_hash_t;
|
||||
typedef QHash<QString, QHash<QString, QString>> config_hash_t;
|
||||
|
||||
public:
|
||||
|
||||
enum class ProcessStatus {
|
||||
Stopped,
|
||||
Running,
|
||||
@@ -87,12 +87,15 @@ public:
|
||||
explicit VMManagerSystem(const QString &sysconfig_file);
|
||||
// Default constructor will generate a temporary filename as the config file
|
||||
// but it will not be valid (isValid() will return false)
|
||||
VMManagerSystem() : VMManagerSystem(generateTemporaryFilename()) {}
|
||||
VMManagerSystem()
|
||||
: VMManagerSystem(generateTemporaryFilename())
|
||||
{
|
||||
}
|
||||
|
||||
~VMManagerSystem() override;
|
||||
|
||||
static QVector<VMManagerSystem *> scanForConfigs(QWidget* parent = nullptr, const QString &searchPath = {});
|
||||
static QString generateTemporaryFilename();
|
||||
static QVector<VMManagerSystem *> scanForConfigs(QWidget *parent = nullptr, const QString &searchPath = {});
|
||||
static QString generateTemporaryFilename();
|
||||
|
||||
QFileInfo config_file;
|
||||
QString config_name;
|
||||
@@ -106,15 +109,15 @@ public:
|
||||
|
||||
config_hash_t config_hash;
|
||||
|
||||
[[nodiscard]] QString getAll(const QString& category) const;
|
||||
[[nodiscard]] QHash <QString, QString> getCategory(const QString& category) const;
|
||||
[[nodiscard]] QHash <QString, QHash <QString, QString>> getConfigHash() const;
|
||||
[[nodiscard]] QString getAll(const QString &category) const;
|
||||
[[nodiscard]] QHash<QString, QString> getCategory(const QString &category) const;
|
||||
[[nodiscard]] QHash<QString, QHash<QString, QString>> getConfigHash() const;
|
||||
|
||||
void setDisplayName(const QString& newDisplayName);
|
||||
void setNotes(const QString& newNotes);
|
||||
void setDisplayName(const QString &newDisplayName);
|
||||
void setNotes(const QString &newNotes);
|
||||
|
||||
[[nodiscard]] bool isValid() const;
|
||||
[[nodiscard]] bool isProcessRunning() const;
|
||||
[[nodiscard]] bool isValid() const;
|
||||
[[nodiscard]] bool isProcessRunning() const;
|
||||
[[nodiscard]] qint64 processId() const;
|
||||
public slots:
|
||||
void launchMainProcess();
|
||||
@@ -127,16 +130,17 @@ public slots:
|
||||
void cadButtonPressed();
|
||||
void reloadConfig();
|
||||
void sendGlobalConfigurationChanged();
|
||||
|
||||
public:
|
||||
QDateTime timestamp();
|
||||
void setIcon(const QString &newIcon);
|
||||
void setIcon(const QString &newIcon);
|
||||
|
||||
QProcess *process = new QProcess();
|
||||
|
||||
bool window_obscured;
|
||||
bool config_signal_connected = false;
|
||||
|
||||
QString getDisplayValue(VMManager::Display::Name key);
|
||||
QString getDisplayValue(VMManager::Display::Name key);
|
||||
QFileInfoList getScreenshots();
|
||||
|
||||
inline bool operator==(const VMManagerSystem &rhs) const
|
||||
@@ -145,9 +149,9 @@ public:
|
||||
}
|
||||
|
||||
static QString
|
||||
processStatusToString(VMManagerSystem::ProcessStatus status) ;
|
||||
ProcessStatus process_status;
|
||||
[[nodiscard]] QString getProcessStatusString() const;
|
||||
processStatusToString(VMManagerSystem::ProcessStatus status);
|
||||
ProcessStatus process_status;
|
||||
[[nodiscard]] QString getProcessStatusString() const;
|
||||
[[nodiscard]] ProcessStatus getProcessStatus() const;
|
||||
|
||||
signals:
|
||||
@@ -166,15 +170,15 @@ private:
|
||||
display_table_t display_table;
|
||||
|
||||
QFileInfo main_binary;
|
||||
QString platform;
|
||||
QString platform;
|
||||
|
||||
// QDir application_temp_directory;
|
||||
// QDir standard_temp_directory;
|
||||
// QDir app_data_directory;
|
||||
QDir screenshot_directory;
|
||||
|
||||
QString unique_name;
|
||||
QDateTime lastUsedTimestamp;
|
||||
QString unique_name;
|
||||
QDateTime lastUsedTimestamp;
|
||||
|
||||
VMManagerServerSocket *socket_server;
|
||||
VMManagerServerSocket::ServerType socket_server_type;
|
||||
@@ -201,4 +205,4 @@ private:
|
||||
void statusRefresh();
|
||||
};
|
||||
|
||||
#endif //QT_VMMANAGER_SYSTEM_H
|
||||
#endif // QT_VMMANAGER_SYSTEM_H
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <windows.h>
|
||||
#include <dwmapi.h>
|
||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||
# define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||
#endif
|
||||
|
||||
#include <86box/86box.h>
|
||||
@@ -68,7 +68,8 @@ WindowsDarkModeFilter::reselectDarkMode()
|
||||
}
|
||||
window->updateDarkMode();
|
||||
|
||||
if (NewDarkMode != OldDarkMode) QTimer::singleShot(1000, [this] () {
|
||||
if (NewDarkMode != OldDarkMode)
|
||||
QTimer::singleShot(1000, [this]() {
|
||||
BOOL DarkMode = NewDarkMode;
|
||||
DwmSetWindowAttribute((HWND) window->winId(),
|
||||
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||
@@ -90,11 +91,8 @@ WindowsDarkModeFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
MSG *msg = static_cast<MSG *>(message);
|
||||
|
||||
if ((msg != nullptr) && (msg->message == WM_SETTINGCHANGE)) {
|
||||
if ((((void *) msg->lParam) != nullptr) &&
|
||||
(wcscmp(L"ImmersiveColorSet", (wchar_t*)msg->lParam) == 0) &&
|
||||
color_scheme == 0) {
|
||||
if ((((void *) msg->lParam) != nullptr) && (wcscmp(L"ImmersiveColorSet", (wchar_t *) msg->lParam) == 0) && color_scheme == 0)
|
||||
reselectDarkMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -502,16 +502,16 @@ VulkanRenderer2::initResources()
|
||||
VK_VERTEX_INPUT_RATE_VERTEX
|
||||
};
|
||||
VkVertexInputAttributeDescription vertexAttrDesc[] = {
|
||||
{// position
|
||||
{ // position
|
||||
0, // location
|
||||
0, // binding
|
||||
VK_FORMAT_R32G32B32_SFLOAT,
|
||||
0 },
|
||||
0 },
|
||||
{ // texcoord
|
||||
1,
|
||||
0,
|
||||
VK_FORMAT_R32G32_SFLOAT,
|
||||
3 * sizeof(float)}
|
||||
3 * sizeof(float) }
|
||||
};
|
||||
|
||||
VkPipelineVertexInputStateCreateInfo vertexInputInfo;
|
||||
@@ -556,8 +556,8 @@ VulkanRenderer2::initResources()
|
||||
|
||||
// Set up descriptor set and its layout.
|
||||
VkDescriptorPoolSize descPoolSizes[2] = {
|
||||
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, uint32_t(concurrentFrameCount)},
|
||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, uint32_t(concurrentFrameCount)}
|
||||
{ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, uint32_t(concurrentFrameCount) },
|
||||
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, uint32_t(concurrentFrameCount) }
|
||||
};
|
||||
VkDescriptorPoolCreateInfo descPoolInfo;
|
||||
memset(&descPoolInfo, 0, sizeof(descPoolInfo));
|
||||
@@ -572,16 +572,16 @@ VulkanRenderer2::initResources()
|
||||
}
|
||||
|
||||
VkDescriptorSetLayoutBinding layoutBinding[2] = {
|
||||
{0, // binding
|
||||
{ 0, // binding
|
||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
1, // descriptorCount
|
||||
VK_SHADER_STAGE_VERTEX_BIT,
|
||||
nullptr},
|
||||
nullptr },
|
||||
{ 1, // binding
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
1, // descriptorCount
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
nullptr}
|
||||
nullptr }
|
||||
};
|
||||
VkDescriptorSetLayoutCreateInfo descLayoutInfo = {
|
||||
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
@@ -658,8 +658,8 @@ VulkanRenderer2::initResources()
|
||||
}
|
||||
|
||||
// Shaders
|
||||
#if 0
|
||||
#version 440
|
||||
# if 0
|
||||
# version 440
|
||||
|
||||
layout(location = 0) in vec4 position;
|
||||
layout(location = 1) in vec2 texcoord;
|
||||
@@ -677,10 +677,10 @@ VulkanRenderer2::initResources()
|
||||
v_texcoord = texcoord;
|
||||
gl_Position = ubuf.mvp * position;
|
||||
}
|
||||
#endif /* 0 */
|
||||
# endif /* 0 */
|
||||
VkShaderModule vertShaderModule = createShader(QStringLiteral(":/texture_vert.spv"));
|
||||
#if 0
|
||||
#version 440
|
||||
# if 0
|
||||
# version 440
|
||||
|
||||
layout(location = 0) in vec2 v_texcoord;
|
||||
|
||||
@@ -692,7 +692,7 @@ VulkanRenderer2::initResources()
|
||||
{
|
||||
fragColor = texture(tex, v_texcoord);
|
||||
}
|
||||
#endif /* 0 */
|
||||
# endif /* 0 */
|
||||
VkShaderModule fragShaderModule = createShader(QStringLiteral(":/texture_frag.spv"));
|
||||
|
||||
// Graphics pipeline
|
||||
@@ -913,7 +913,7 @@ VulkanRenderer2::startNextFrame()
|
||||
ensureTexture();
|
||||
|
||||
VkClearColorValue clearColor = {
|
||||
{0, 0, 0, 1}
|
||||
{ 0, 0, 0, 1 }
|
||||
};
|
||||
VkClearDepthStencilValue clearDS = { 1, 0 };
|
||||
VkClearValue clearValues[2];
|
||||
@@ -970,11 +970,11 @@ VulkanRenderer2::startNextFrame()
|
||||
m_devFuncs->vkCmdBindVertexBuffers(cb, 0, 1, &m_buf, &vbOffset);
|
||||
|
||||
VkViewport viewport;
|
||||
viewport.x = destination.x();
|
||||
viewport.y = destination.y();
|
||||
viewport.width = destination.width();
|
||||
viewport.height = destination.height();
|
||||
|
||||
viewport.x = destination.x();
|
||||
viewport.y = destination.y();
|
||||
viewport.width = destination.width();
|
||||
viewport.height = destination.height();
|
||||
|
||||
viewport.minDepth = 0;
|
||||
viewport.maxDepth = 1;
|
||||
m_devFuncs->vkCmdSetViewport(cb, 0, 1, &viewport);
|
||||
|
||||
@@ -32,13 +32,13 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef VULKANRENDERER_HPP
|
||||
#define VULKANRENDERER_HPP
|
||||
# define VULKANRENDERER_HPP
|
||||
|
||||
#include <QVulkanWindow>
|
||||
#include <QImage>
|
||||
# include <QVulkanWindow>
|
||||
# include <QImage>
|
||||
|
||||
#if QT_CONFIG(vulkan)
|
||||
# include "qt_vulkanwindowrenderer.hpp"
|
||||
# if QT_CONFIG(vulkan)
|
||||
# include "qt_vulkanwindowrenderer.hpp"
|
||||
|
||||
class VulkanRenderer2 : public QVulkanWindowRenderer {
|
||||
public:
|
||||
@@ -92,6 +92,6 @@ private:
|
||||
|
||||
QMatrix4x4 m_proj;
|
||||
};
|
||||
#endif // QT_CONFIG(vulkan)
|
||||
# endif // QT_CONFIG(vulkan)
|
||||
|
||||
#endif // VULKANRENDERER_HPP
|
||||
|
||||
@@ -820,7 +820,7 @@ public:
|
||||
m_devFuncs->vkDeviceWaitIdle(m_window->device());
|
||||
}
|
||||
};
|
||||
# endif /* 0*/
|
||||
# endif /* 0*/
|
||||
|
||||
VulkanWindowRenderer::VulkanWindowRenderer(QWidget *parent)
|
||||
: QVulkanWindow(NULL)
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include <windows.h>
|
||||
#include <dwmapi.h>
|
||||
#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||
#define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||
# define DWMWA_USE_IMMERSIVE_DARK_MODE 20
|
||||
#endif
|
||||
|
||||
#include <86box/keyboard.h>
|
||||
@@ -63,7 +63,7 @@
|
||||
#include <dbt.h>
|
||||
#include <strsafe.h>
|
||||
|
||||
extern void win_keyboard_handle(uint32_t scancode, int up, int e0, int e1);
|
||||
extern void win_keyboard_handle(uint32_t scancode, int up, int e0, int e1);
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
@@ -74,15 +74,15 @@ extern void win_keyboard_handle(uint32_t scancode, int up, int e0, int e1);
|
||||
|
||||
bool NewDarkMode = FALSE;
|
||||
|
||||
extern MainWindow* main_window;
|
||||
extern MainWindow *main_window;
|
||||
|
||||
struct
|
||||
{
|
||||
HANDLE done_event = 0, ready_event = 0;
|
||||
std::atomic_bool done{false};
|
||||
HANDLE done_event = 0, ready_event = 0;
|
||||
std::atomic_bool done { false };
|
||||
|
||||
size_t rawinput_offset = 0, rawinput_size = 0;
|
||||
uint8_t* rawinput = nullptr;
|
||||
size_t rawinput_offset = 0, rawinput_size = 0;
|
||||
uint8_t *rawinput = nullptr;
|
||||
|
||||
HANDLE thread = 0;
|
||||
} win_rawinput_data;
|
||||
@@ -91,11 +91,11 @@ static void
|
||||
win_poll_mouse(void)
|
||||
{
|
||||
// Yes, this is a thing in C++.
|
||||
auto* data = &win_rawinput_data;
|
||||
uint32_t size, i, count, total = 0;
|
||||
auto *data = &win_rawinput_data;
|
||||
uint32_t size, i, count, total = 0;
|
||||
RAWINPUT *input;
|
||||
//static int64_t ms_time = plat_get_ticks();
|
||||
|
||||
// static int64_t ms_time = plat_get_ticks();
|
||||
|
||||
if (data->rawinput_offset == 0) {
|
||||
BOOL isWow64;
|
||||
|
||||
@@ -106,18 +106,18 @@ win_poll_mouse(void)
|
||||
}
|
||||
}
|
||||
|
||||
input = (RAWINPUT *)data->rawinput;
|
||||
input = (RAWINPUT *) data->rawinput;
|
||||
for (;;) {
|
||||
size = data->rawinput_size - (UINT)((BYTE *)input - data->rawinput);
|
||||
size = data->rawinput_size - (UINT) ((BYTE *) input - data->rawinput);
|
||||
count = GetRawInputBuffer(input, &size, sizeof(RAWINPUTHEADER));
|
||||
if (count == 0 || count == (UINT)-1) {
|
||||
if (!data->rawinput || (count == (UINT)-1 && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
||||
const UINT RAWINPUT_BUFFER_SIZE_INCREMENT = 96; // 2 64-bit raw mouse packets
|
||||
BYTE *rawinput = (BYTE *)realloc(data->rawinput, data->rawinput_size + RAWINPUT_BUFFER_SIZE_INCREMENT);
|
||||
if (count == 0 || count == (UINT) -1) {
|
||||
if (!data->rawinput || (count == (UINT) -1 && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
|
||||
const UINT RAWINPUT_BUFFER_SIZE_INCREMENT = 96; // 2 64-bit raw mouse packets
|
||||
BYTE *rawinput = (BYTE *) realloc(data->rawinput, data->rawinput_size + RAWINPUT_BUFFER_SIZE_INCREMENT);
|
||||
if (!rawinput) {
|
||||
break;
|
||||
}
|
||||
input = (RAWINPUT *)(rawinput + ((BYTE *)input - data->rawinput));
|
||||
input = (RAWINPUT *) (rawinput + ((BYTE *) input - data->rawinput));
|
||||
data->rawinput = rawinput;
|
||||
data->rawinput_size += RAWINPUT_BUFFER_SIZE_INCREMENT;
|
||||
} else {
|
||||
@@ -134,21 +134,21 @@ win_poll_mouse(void)
|
||||
}
|
||||
|
||||
if (total > 0) {
|
||||
for (i = 0, input = (RAWINPUT *)data->rawinput; i < total; ++i, input = NEXTRAWINPUTBLOCK(input)) {
|
||||
for (i = 0, input = (RAWINPUT *) data->rawinput; i < total; ++i, input = NEXTRAWINPUTBLOCK(input)) {
|
||||
if (input->header.dwType == RIM_TYPEMOUSE) {
|
||||
RAWMOUSE *rawmouse = (RAWMOUSE *)((BYTE *)input + data->rawinput_offset);
|
||||
RAWMOUSE *rawmouse = (RAWMOUSE *) ((BYTE *) input + data->rawinput_offset);
|
||||
if (mouse_capture)
|
||||
WindowsRawInputFilter::mouse_handle(rawmouse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//qDebug() << "Mouse delay: " << (plat_get_ticks() - ms_time);
|
||||
//ms_time = plat_get_ticks();
|
||||
// qDebug() << "Mouse delay: " << (plat_get_ticks() - ms_time);
|
||||
// ms_time = plat_get_ticks();
|
||||
}
|
||||
|
||||
static DWORD
|
||||
win_rawinput_thread(void* param)
|
||||
win_rawinput_thread(void *param)
|
||||
{
|
||||
RAWINPUTDEVICE rid = {
|
||||
.usUsagePage = 0x01,
|
||||
@@ -179,14 +179,14 @@ win_rawinput_thread(void* param)
|
||||
}
|
||||
|
||||
// Clear the queue status so MsgWaitForMultipleObjects() will wait again
|
||||
(void)GetQueueStatus(QS_RAWINPUT);
|
||||
(void) GetQueueStatus(QS_RAWINPUT);
|
||||
|
||||
win_poll_mouse();
|
||||
}
|
||||
|
||||
rid.dwFlags |= RIDEV_REMOVE;
|
||||
rid.hwndTarget = NULL;
|
||||
|
||||
|
||||
RegisterRawInputDevices(&rid, 1, sizeof(rid));
|
||||
DestroyWindow(window);
|
||||
return 0;
|
||||
@@ -197,19 +197,17 @@ std::unique_ptr<WindowsRawInputFilter>
|
||||
WindowsRawInputFilter::Register(MainWindow *window)
|
||||
{
|
||||
RAWINPUTDEVICE rid[1] = {
|
||||
{
|
||||
.usUsagePage = 0x01,
|
||||
.usUsage = 0x06,
|
||||
.dwFlags = RIDEV_NOHOTKEYS,
|
||||
.hwndTarget = nullptr
|
||||
}
|
||||
{ .usUsagePage = 0x01,
|
||||
.usUsage = 0x06,
|
||||
.dwFlags = RIDEV_NOHOTKEYS,
|
||||
.hwndTarget = nullptr }
|
||||
};
|
||||
|
||||
if (!hook_enabled) {
|
||||
RegisterRawInputDevices(rid, 1, sizeof(rid[0]));
|
||||
}
|
||||
|
||||
win_rawinput_data.done_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
win_rawinput_data.done_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
win_rawinput_data.ready_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
||||
if (!win_rawinput_data.done_event || !win_rawinput_data.ready_event) {
|
||||
@@ -250,13 +248,12 @@ WindowsRawInputFilter::~WindowsRawInputFilter()
|
||||
SetEvent(win_rawinput_data.done_event);
|
||||
if (win_rawinput_data.thread)
|
||||
WaitForSingleObject(win_rawinput_data.thread, INFINITE);
|
||||
RAWINPUTDEVICE rid =
|
||||
{
|
||||
.usUsagePage = 0x01,
|
||||
.usUsage = 0x06,
|
||||
.dwFlags = RIDEV_REMOVE,
|
||||
.hwndTarget = NULL
|
||||
};
|
||||
RAWINPUTDEVICE rid = {
|
||||
.usUsagePage = 0x01,
|
||||
.usUsage = 0x06,
|
||||
.dwFlags = RIDEV_REMOVE,
|
||||
.hwndTarget = NULL
|
||||
};
|
||||
|
||||
if (!hook_enabled)
|
||||
RegisterRawInputDevices(&rid, 1, sizeof(rid));
|
||||
@@ -267,25 +264,25 @@ WindowsRawInputFilter::~WindowsRawInputFilter()
|
||||
static void
|
||||
notify_drives(ULONG unitmask, int empty)
|
||||
{
|
||||
if (unitmask & cdrom_assigned_letters) for (int i = 0; i < CDROM_NUM; i++) {
|
||||
cdrom_t *dev = &(cdrom[i]);
|
||||
if (unitmask & cdrom_assigned_letters)
|
||||
for (int i = 0; i < CDROM_NUM; i++) {
|
||||
cdrom_t *dev = &(cdrom[i]);
|
||||
|
||||
if ((dev->host_letter != 0xff) &&
|
||||
(unitmask & (1 << dev->host_letter))) {
|
||||
if (empty)
|
||||
cdrom_set_empty(dev);
|
||||
else
|
||||
cdrom_update_status(dev);
|
||||
if ((dev->host_letter != 0xff) && (unitmask & (1 << dev->host_letter))) {
|
||||
if (empty)
|
||||
cdrom_set_empty(dev);
|
||||
else
|
||||
cdrom_update_status(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
device_change(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR) lParam;
|
||||
PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR) lParam;
|
||||
|
||||
switch(wParam) {
|
||||
switch (wParam) {
|
||||
case DBT_DEVICEARRIVAL:
|
||||
case DBT_DEVICEREMOVECOMPLETE:
|
||||
/* Check whether a CD or DVD was inserted into a drive. */
|
||||
@@ -300,9 +297,9 @@ device_change(WPARAM wParam, LPARAM lParam)
|
||||
|
||||
default:
|
||||
/*
|
||||
Process other WM_DEVICECHANGE notifications for other
|
||||
Process other WM_DEVICECHANGE notifications for other
|
||||
devices or reasons.
|
||||
*/
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -363,25 +360,24 @@ WindowsRawInputFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
if (eventType == "windows_generic_MSG") {
|
||||
MSG *msg = static_cast<MSG *>(message);
|
||||
|
||||
if (msg != nullptr) switch(msg->message) {
|
||||
case WM_INPUT:
|
||||
if (window->isActiveWindow() && (menus_open == 0))
|
||||
handle_input((HRAWINPUT) msg->lParam);
|
||||
else {
|
||||
for (auto &w : window->renderers) {
|
||||
if (w && w->isActiveWindow()) {
|
||||
handle_input((HRAWINPUT) msg->lParam);
|
||||
break;
|
||||
if (msg != nullptr)
|
||||
switch (msg->message) {
|
||||
case WM_INPUT:
|
||||
if (window->isActiveWindow() && (menus_open == 0))
|
||||
handle_input((HRAWINPUT) msg->lParam);
|
||||
else {
|
||||
for (auto &w : window->renderers) {
|
||||
if (w && w->isActiveWindow()) {
|
||||
handle_input((HRAWINPUT) msg->lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case WM_SETTINGCHANGE:
|
||||
if ((((void *) msg->lParam) != nullptr) &&
|
||||
(wcscmp(L"ImmersiveColorSet", (wchar_t*)msg->lParam) == 0) &&
|
||||
color_scheme == 0) {
|
||||
return true;
|
||||
case WM_SETTINGCHANGE:
|
||||
if ((((void *) msg->lParam) != nullptr) && (wcscmp(L"ImmersiveColorSet", (wchar_t *) msg->lParam) == 0) && color_scheme == 0) {
|
||||
|
||||
bool OldDarkMode = NewDarkMode;
|
||||
bool OldDarkMode = NewDarkMode;
|
||||
#if 0
|
||||
if (do_auto_pause && !dopause) {
|
||||
auto_paused = 1;
|
||||
@@ -389,48 +385,48 @@ WindowsRawInputFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!util::isWindowsLightTheme()) {
|
||||
QFile f(":qdarkstyle/dark/darkstyle.qss");
|
||||
if (!util::isWindowsLightTheme()) {
|
||||
QFile f(":qdarkstyle/dark/darkstyle.qss");
|
||||
|
||||
if (!f.exists())
|
||||
printf("Unable to set stylesheet, file not found\n");
|
||||
else {
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream ts(&f);
|
||||
qApp->setStyleSheet(ts.readAll());
|
||||
if (!f.exists())
|
||||
printf("Unable to set stylesheet, file not found\n");
|
||||
else {
|
||||
f.open(QFile::ReadOnly | QFile::Text);
|
||||
QTextStream ts(&f);
|
||||
qApp->setStyleSheet(ts.readAll());
|
||||
}
|
||||
QPalette palette(qApp->palette());
|
||||
palette.setColor(QPalette::Link, Qt::white);
|
||||
palette.setColor(QPalette::LinkVisited, Qt::lightGray);
|
||||
qApp->setPalette(palette);
|
||||
NewDarkMode = TRUE;
|
||||
} else {
|
||||
qApp->setStyleSheet("");
|
||||
QPalette palette(qApp->palette());
|
||||
palette.setColor(QPalette::Link, Qt::blue);
|
||||
palette.setColor(QPalette::LinkVisited, Qt::magenta);
|
||||
qApp->setPalette(palette);
|
||||
NewDarkMode = FALSE;
|
||||
}
|
||||
QPalette palette(qApp->palette());
|
||||
palette.setColor(QPalette::Link, Qt::white);
|
||||
palette.setColor(QPalette::LinkVisited, Qt::lightGray);
|
||||
qApp->setPalette(palette);
|
||||
NewDarkMode = TRUE;
|
||||
} else {
|
||||
qApp->setStyleSheet("");
|
||||
QPalette palette(qApp->palette());
|
||||
palette.setColor(QPalette::Link, Qt::blue);
|
||||
palette.setColor(QPalette::LinkVisited, Qt::magenta);
|
||||
qApp->setPalette(palette);
|
||||
NewDarkMode = FALSE;
|
||||
}
|
||||
|
||||
if (NewDarkMode != OldDarkMode) QTimer::singleShot(1000, [this] () {
|
||||
BOOL DarkMode = NewDarkMode;
|
||||
DwmSetWindowAttribute((HWND) window->winId(),
|
||||
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||
(LPCVOID) &DarkMode,
|
||||
sizeof(DarkMode));
|
||||
if (NewDarkMode != OldDarkMode)
|
||||
QTimer::singleShot(1000, [this]() {
|
||||
BOOL DarkMode = NewDarkMode;
|
||||
DwmSetWindowAttribute((HWND) window->winId(),
|
||||
DWMWA_USE_IMMERSIVE_DARK_MODE,
|
||||
(LPCVOID) &DarkMode,
|
||||
sizeof(DarkMode));
|
||||
|
||||
window->resizeContents(monitors[0].mon_scrnsz_x,
|
||||
monitors[0].mon_scrnsz_y);
|
||||
window->resizeContents(monitors[0].mon_scrnsz_x,
|
||||
monitors[0].mon_scrnsz_y);
|
||||
|
||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||
auto mon = &(monitors[i]);
|
||||
for (int i = 1; i < MONITORS_NUM; i++) {
|
||||
auto mon = &(monitors[i]);
|
||||
|
||||
if ((window->renderers[i] != nullptr) &&
|
||||
!window->renderers[i]->isHidden())
|
||||
window->resizeContentsMonitor(mon->mon_scrnsz_x,
|
||||
mon->mon_scrnsz_y, i);
|
||||
}
|
||||
if ((window->renderers[i] != nullptr) && !window->renderers[i]->isHidden())
|
||||
window->resizeContentsMonitor(mon->mon_scrnsz_x,
|
||||
mon->mon_scrnsz_y, i);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (auto_paused) {
|
||||
@@ -438,19 +434,19 @@ WindowsRawInputFilter::nativeEventFilter(const QByteArray &eventType, void *mess
|
||||
auto_paused = 0;
|
||||
}
|
||||
#endif
|
||||
});
|
||||
}
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
/* Stop processing of Alt-F4 */
|
||||
if (msg->wParam == 0x73)
|
||||
return true;
|
||||
break;
|
||||
case WM_DEVICECHANGE:
|
||||
if (msg->hwnd == (HWND) window->winId())
|
||||
device_change(msg->wParam, msg->lParam);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
/* Stop processing of Alt-F4 */
|
||||
if (msg->wParam == 0x73)
|
||||
return true;
|
||||
break;
|
||||
case WM_DEVICECHANGE:
|
||||
if (msg->hwnd == (HWND) window->winId())
|
||||
device_change(msg->wParam, msg->lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -491,7 +487,7 @@ WindowsRawInputFilter::keyboard_handle(PRAWINPUT raw)
|
||||
}
|
||||
|
||||
void
|
||||
WindowsRawInputFilter::mouse_handle(RAWMOUSE* raw)
|
||||
WindowsRawInputFilter::mouse_handle(RAWMOUSE *raw)
|
||||
{
|
||||
RAWMOUSE state = *raw;
|
||||
static int x, delta_x;
|
||||
@@ -548,8 +544,8 @@ WindowsRawInputFilter::mouse_handle(RAWMOUSE* raw)
|
||||
*/
|
||||
delta_x = (state.lLastX - x) / 25;
|
||||
delta_y = (state.lLastY - y) / 25;
|
||||
x = state.lLastX;
|
||||
y = state.lLastY;
|
||||
x = state.lLastX;
|
||||
y = state.lLastY;
|
||||
} else {
|
||||
/* relative mouse, i.e. regular mouse */
|
||||
delta_x = state.lLastX;
|
||||
|
||||
@@ -57,20 +57,20 @@ public:
|
||||
|
||||
~WindowsRawInputFilter();
|
||||
|
||||
static void mouse_handle(RAWMOUSE* raw);
|
||||
static void mouse_handle(RAWMOUSE *raw);
|
||||
|
||||
private:
|
||||
MainWindow *window;
|
||||
int buttons = 0;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
int dwheel = 0;
|
||||
int menus_open = 0;
|
||||
int buttons = 0;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
int dwheel = 0;
|
||||
int menus_open = 0;
|
||||
|
||||
WindowsRawInputFilter(MainWindow *window);
|
||||
|
||||
void handle_input(HRAWINPUT input);
|
||||
void keyboard_handle(PRAWINPUT raw);
|
||||
void handle_input(HRAWINPUT input);
|
||||
void keyboard_handle(PRAWINPUT raw);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -44,7 +44,7 @@ extern "C" {
|
||||
static Display *disp = nullptr;
|
||||
static QThread *procThread = nullptr;
|
||||
static XIEventMask ximask;
|
||||
static std::atomic<bool> exitfromthread = false;
|
||||
static std::atomic<bool> exitfromthread = false;
|
||||
static std::atomic<double> xi2_mouse_abs_x = 0, xi2_mouse_abs_y = 0;
|
||||
static int xi2opcode = 0;
|
||||
static double prev_coords[2] = { 0.0 };
|
||||
@@ -56,8 +56,8 @@ parse_valuators(const double *input_values,
|
||||
const unsigned char *mask, int mask_len,
|
||||
double *output_values, int output_values_len)
|
||||
{
|
||||
int i = 0;
|
||||
int z = 0;
|
||||
int i = 0;
|
||||
int z = 0;
|
||||
int top = mask_len * 8;
|
||||
if (top > 16)
|
||||
top = 16;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user