Changeset 52002 in vbox
- Timestamp:
- Jul 12, 2014 7:18:36 AM (10 years ago)
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 2 edited
-
VBoxDbgConsole.cpp (modified) (4 diffs)
-
VBoxDbgConsole.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/VBoxDbgConsole.cpp
r49276 r52002 30 30 #include <QAction> 31 31 #include <QContextMenuEvent> 32 #include <QMenu> 32 33 33 34 #include <VBox/dbg.h> … … 68 69 setAcceptRichText(false); 69 70 71 /* 72 * Font. 73 * Create actions for font menu items. 74 */ 75 m_pCourierFontAction = new QAction(tr("Courier"), this); 76 m_pCourierFontAction->setCheckable(true); 77 m_pCourierFontAction->setShortcut(Qt::ControlModifier + Qt::Key_D); 78 connect(m_pCourierFontAction, SIGNAL(triggered()), this, SLOT(setFontCourier())); 79 80 m_pMonospaceFontAction = new QAction(tr("Monospace"), this); 81 m_pMonospaceFontAction->setCheckable(true); 82 m_pMonospaceFontAction->setShortcut(Qt::ControlModifier + Qt::Key_M); 83 connect(m_pMonospaceFontAction, SIGNAL(triggered()), this, SLOT(setFontMonospace())); 84 85 /* Create action group for grouping of exclusive font menu items. */ 86 QActionGroup *pActionFontGroup = new QActionGroup(this); 87 pActionFontGroup->addAction(m_pCourierFontAction); 88 pActionFontGroup->addAction(m_pMonospaceFontAction); 89 pActionFontGroup->setExclusive(true); 90 91 /* 92 * Color scheme. 93 * Create actions for color-scheme menu items. 94 */ 95 m_pGreenOnBlackAction = new QAction(tr("Green On Black"), this); 96 m_pGreenOnBlackAction->setCheckable(true); 97 m_pGreenOnBlackAction->setShortcut(Qt::ControlModifier + Qt::Key_1); 98 connect(m_pGreenOnBlackAction, SIGNAL(triggered()), this, SLOT(setColorGreenOnBlack())); 99 100 m_pBlackOnWhiteAction = new QAction(tr("Black On White"), this); 101 m_pBlackOnWhiteAction->setCheckable(true); 102 m_pBlackOnWhiteAction->setShortcut(Qt::ControlModifier + Qt::Key_2); 103 connect(m_pBlackOnWhiteAction, SIGNAL(triggered()), this, SLOT(setColorBlackOnWhite())); 104 105 /* Create action group for grouping of exclusive color-scheme menu items. */ 106 QActionGroup *pActionColorGroup = new QActionGroup(this); 107 pActionColorGroup->addAction(m_pGreenOnBlackAction); 108 pActionColorGroup->addAction(m_pBlackOnWhiteAction); 109 pActionColorGroup->setExclusive(true); 110 111 /* 112 * Set the defaults (which syncs with the menu item checked state). 113 */ 114 setFontCourier(); 115 setColorGreenOnBlack(); 116 117 NOREF(pszName); 118 } 119 120 121 VBoxDbgConsoleOutput::~VBoxDbgConsoleOutput() 122 { 123 Assert(m_hGUIThread == RTThreadNativeSelf()); 124 } 125 126 127 void 128 VBoxDbgConsoleOutput::contextMenuEvent(QContextMenuEvent *pEvent) 129 { 130 /* 131 * Create the context menu and add the menu items. 132 */ 133 QMenu *pMenu = createStandardContextMenu(); 134 QMenu *pColorMenu = pMenu->addMenu(tr("Co&lor Scheme")); 135 pColorMenu->addAction(m_pGreenOnBlackAction); 136 pColorMenu->addAction(m_pBlackOnWhiteAction); 137 138 QMenu *pFontMenu = pMenu->addMenu(tr("&Font Family")); 139 pFontMenu->addAction(m_pCourierFontAction); 140 pFontMenu->addAction(m_pMonospaceFontAction); 141 142 pMenu->exec(pEvent->globalPos()); 143 delete pMenu; 144 } 145 146 147 void 148 VBoxDbgConsoleOutput::setColorGreenOnBlack() 149 { 150 setStyleSheet("QTextEdit { background-color: black; color: rgb(0, 224, 0) }"); 151 m_enmColorScheme = kGreenOnBlack; 152 153 /* This is used both as a trigger as well as called independently from code. 154 When used as a trigger, the checked is done automatically by Qt. */ 155 if (!m_pGreenOnBlackAction->isChecked()) 156 m_pGreenOnBlackAction->setChecked(true); 157 } 158 159 160 void 161 VBoxDbgConsoleOutput::setColorBlackOnWhite() 162 { 163 setStyleSheet("QTextEdit { background-color: white; color: black }"); 164 m_enmColorScheme = kBlackOnWhite; 165 166 if (!m_pBlackOnWhiteAction->isChecked()) 167 m_pBlackOnWhiteAction->setChecked(true); 168 } 169 170 171 void 172 VBoxDbgConsoleOutput::setFontCourier() 173 { 70 174 #ifdef Q_WS_MAC 71 175 QFont Font("Monaco", 10, QFont::Normal, FALSE); … … 78 182 setFont(Font); 79 183 80 /* green on black */ 81 QPalette Pal(palette()); 82 Pal.setColor(QPalette::All, QPalette::Base, QColor(Qt::black)); 83 setPalette(Pal); 84 setTextColor(QColor(qRgb(0, 0xe0, 0))); 85 86 #ifdef DEBUG_ramshankar 87 /* Solaris host (esp. S10) has illegible Courier font (bad aliasing). */ 184 if (!m_pCourierFontAction->isChecked()) 185 m_pCourierFontAction->setChecked(true); 186 } 187 188 189 void 190 VBoxDbgConsoleOutput::setFontMonospace() 191 { 192 QFont Font = font(); 193 Font.setStyleHint(QFont::TypeWriter); 194 Font.setStyleStrategy(QFont::PreferAntialias); 88 195 Font.setFamily("Monospace [Monotype]"); 89 196 setFont(Font); 90 197 91 /* White on black while I'm at it. */ 92 Pal.setColor(QPalette::All, QPalette::Base, QColor(Qt::white)); 93 setPalette(Pal); 94 setTextColor(QColor(qRgb(0, 0, 0))); 95 #endif 96 97 NOREF(pszName); 98 } 99 100 101 VBoxDbgConsoleOutput::~VBoxDbgConsoleOutput() 102 { 103 Assert(m_hGUIThread == RTThreadNativeSelf()); 198 if (!m_pMonospaceFontAction->isChecked()) 199 m_pMonospaceFontAction->setChecked(true); 104 200 } 105 201 … … 366 462 addAction(m_pFocusToOutput); 367 463 connect(m_pFocusToOutput, SIGNAL(triggered(bool)), this, SLOT(actFocusToOutput())); 464 465 addAction(m_pOutput->m_pBlackOnWhiteAction); 466 addAction(m_pOutput->m_pGreenOnBlackAction); 467 addAction(m_pOutput->m_pCourierFontAction); 468 addAction(m_pOutput->m_pMonospaceFontAction); 368 469 } 369 470 -
trunk/src/VBox/Debugger/VBoxDbgConsole.h
r49276 r52002 61 61 virtual void appendText(const QString &rStr, bool fClearSelection); 62 62 63 protected: 63 /** The action to switch to black-on-white color scheme. */ 64 QAction *m_pBlackOnWhiteAction; 65 /** The action to switch to green-on-black color scheme. */ 66 QAction *m_pGreenOnBlackAction; 67 68 /** The action to switch to Courier font. */ 69 QAction *m_pCourierFontAction; 70 /** The action to switch to Monospace font. */ 71 QAction *m_pMonospaceFontAction; 72 73 protected: 74 typedef enum { kGreenOnBlack, kBlackOnWhite } VBoxDbgConsoleColor; 75 76 /** 77 * Context menu event. 78 * This adds custom menu items for the output view. 79 * 80 * @param pEvent Pointer to the event. 81 */ 82 virtual void contextMenuEvent(QContextMenuEvent *pEvent); 83 64 84 /** The current line (paragraph) number. */ 65 85 unsigned m_uCurLine; … … 68 88 /** The handle to the GUI thread. */ 69 89 RTNATIVETHREAD m_hGUIThread; 90 /** The current color scheme (foreground on background). */ 91 VBoxDbgConsoleColor m_enmColorScheme; 92 93 private slots: 94 /** 95 * The green-on-black color scheme context-menu item was triggered. 96 */ 97 void setColorGreenOnBlack(); 98 99 /** 100 * The black-on-white color scheme context-menu item was triggered. 101 */ 102 void setColorBlackOnWhite(); 103 104 /** 105 * The courier font family context-menu item was triggered. 106 */ 107 void setFontCourier(); 108 109 /** 110 * The monospace font family context-menu item was triggered. 111 */ 112 void setFontMonospace(); 70 113 }; 71 114
Note:
See TracChangeset
for help on using the changeset viewer.

