Commit c09650d2c9dc33def0662daa1ee6dab373f5ac73
- Diff rendering mode:
- inline
- side by side
src/quax.cpp
(22 / 22)
|   | |||
| 102 | 102 | connect(menu,SIGNAL(aboutToShow()), this, SLOT(updatemenuColor())); | |
| 103 | 103 | ||
| 104 | 104 | // set the color tooltip | |
| 105 | m_colorTip = new QLabel(0, Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::Tool | Qt::X11BypassWindowManagerHint); | ||
| 106 | m_colorTip->setMargin(1); | ||
| 107 | m_colorTip->setIndent(0); | ||
| 105 | m_colorTip = new QTextBrowser; | ||
| 106 | m_colorTip->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::Tool | Qt::X11BypassWindowManagerHint); | ||
| 108 | 107 | m_colorTip->setAlignment(Qt::AlignLeft | Qt::AlignTop); | |
| 109 | 108 | m_colorTip->setFrameStyle(QFrame::Plain | QFrame::Box); | |
| 110 | 109 | m_colorTip->setTextFormat(Qt::RichText); | |
| 110 | m_colorTip->resize(120, 28); | ||
| 111 | 111 | ||
| 112 | 112 | setMouseTracking(true); | |
| 113 | 113 | startTimer(UPDATE); | |
| … | … | ||
| 259 | 259 | // make a little pixmap with grabbed color | |
| 260 | 260 | m_colorPixmap = grabPix.scaled(14, 14); | |
| 261 | 261 | } | |
| 262 | #include <Q3MimeSourceFactory> | ||
| 263 | #include <QResource> | ||
| 262 | |||
| 264 | 263 | void Quax::genColorTip() | |
| 265 | 264 | { | |
| 266 | 265 | grabForPixel(); | |
| 267 | Q3MimeSourceFactory::defaultFactory()->setPixmap("pixel",m_colorPixmap); | ||
| 268 | m_colorTip->setText("<qml> <img height=\"14\" width=\"14\" src=\"pixel\"> <tt>" + m_colorStringHexaUpper + "</tt></qml>"); | ||
| 266 | m_colorTip->document()->addResource(QTextDocument::ImageResource, QUrl("qrc:/pixel"), m_colorPixmap); | ||
| 267 | m_colorTip->document()->setHtml("<html> <img height=\"14\" width=\"14\" src=\"qrc:/pixel\"> <tt>" + m_colorStringHexaUpper + "</tt></html>"); | ||
| 269 | 268 | ||
| 270 | 269 | int x_pos, y_pos; | |
| 271 | int x_ofs=7, y_ofs=5; | ||
| 272 | int x_margin=2, y_margin=2; | ||
| 270 | int x_ofs = 7, y_ofs = 5; | ||
| 271 | int x_margin = 2, y_margin = 2; | ||
| 273 | 272 | //check if tooltip get outside screen area | |
| 274 | 273 | QRect r = m_colorTip->rect(); | |
| 275 | 274 | QPoint c = QCursor::pos(); | |
| 276 | 275 | if (c.x()+r.width()+x_ofs+x_margin > qApp->desktop()->width()) | |
| 277 | 276 | x_pos = c.x()-r.width()-x_ofs; | |
| 278 | 277 | else | |
| 279 | x_pos=c.x()+x_ofs; | ||
| 278 | x_pos = c.x()+x_ofs; | ||
| 280 | 279 | if (c.y()-r.height()-y_ofs-y_margin < 0) | |
| 281 | y_pos=c.y()+y_ofs; | ||
| 280 | y_pos = c.y()+y_ofs; | ||
| 282 | 281 | else | |
| 283 | y_pos=c.y()-r.height()-y_ofs; | ||
| 282 | y_pos = c.y()-r.height()-y_ofs; | ||
| 284 | 283 | m_colorTip->move(x_pos,y_pos); | |
| 285 | 284 | m_colorTip->show(); | |
| 286 | 285 | } | |
| … | … | ||
| 329 | 329 | } | |
| 330 | 330 | } | |
| 331 | 331 | ||
| 332 | void Quax::keyReleaseEvent(QKeyEvent *e) | ||
| 333 | { | ||
| 334 | if (m_colorTipEnabled) { | ||
| 335 | if (e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift) { | ||
| 336 | m_colorTipEnabled = false; | ||
| 337 | m_colorTip->hide(); | ||
| 338 | setCursor(Qt::PointingHandCursor); | ||
| 339 | } | ||
| 340 | } | ||
| 341 | } | ||
| 342 | 332 | void Quax::keyPressEvent(QKeyEvent *e) | |
| 343 | 333 | { | |
| 344 | 334 | if (!m_colorTipEnabled && e->modifiers() & Qt::ShiftModifier && e->modifiers() & Qt::ControlModifier) { | |
| … | … | ||
| 368 | 368 | if (e->modifiers() & Qt::ShiftModifier) | |
| 369 | 369 | dist *= 10; | |
| 370 | 370 | move(pos() + dist); | |
| 371 | } | ||
| 372 | |||
| 373 | void Quax::keyReleaseEvent(QKeyEvent *e) | ||
| 374 | { | ||
| 375 | if (m_colorTipEnabled) { | ||
| 376 | if (e->key() == Qt::Key_Control || e->key() == Qt::Key_Shift) { | ||
| 377 | m_colorTipEnabled = false; | ||
| 378 | m_colorTip->hide(); | ||
| 379 | setCursor(Qt::PointingHandCursor); | ||
| 380 | } | ||
| 381 | } | ||
| 371 | 382 | } | |
| 372 | 383 | ||
| 373 | 384 | void Quax::help() |
src/quax.h
(2 / 1)
|   | |||
| 38 | 38 | #include <QTimerEvent> | |
| 39 | 39 | #include <QKeyEvent> | |
| 40 | 40 | #include <QPaintEvent> | |
| 41 | #include <QTextBrowser> | ||
| 41 | 42 | ||
| 42 | 43 | #define QUAX_VERSION "1.0" | |
| 43 | 44 | #define QUAX_RELEASE "1" | |
| … | … | ||
| 132 | 132 | QString m_colorStringDecimal, ///< the current color under mouse as decimals comma seperated | |
| 133 | 133 | m_colorStringHexaLower, ///< the current color under mouse as web RGB with lower hexadecimals | |
| 134 | 134 | m_colorStringHexaUpper; ///< the current color under mouse as web RGB with upper hexadecimals | |
| 135 | QLabel *m_colorTip; ///< The tool tip for displaying current color under mouse | ||
| 136 | 135 | QMenu *menu, ///< The main menu of Quax | |
| 137 | 136 | *menuZoom, ///< Menu for zoom levels and zoom in and zoom out items | |
| 138 | 137 | *menuLook, ///< The "Look at" menu | |
| 139 | 138 | *menuColor; ///< Menu for coying textual representation into clipboard | |
| 139 | QTextBrowser *m_colorTip; ///< The tool tip for displaying current color under mouse | ||
| 140 | 140 | QPixmap m_zoomPixmap, ///< The grabbed image zoomend and clipped | |
| 141 | 141 | m_colorPixmap; ///< The icon used in color menu item and color tooltip | |
| 142 | 142 | bool m_inDrag, ///< if true, the user is dragging the Quax |
src/quax.pro
(5 / 15)
|   | |||
| 7 | 7 | DEPENDPATH += . | |
| 8 | 8 | INCLUDEPATH += . | |
| 9 | 9 | ||
| 10 | # Input | ||
| 11 | HEADERS += quax.h \ | ||
| 12 | ../config.h \ | ||
| 13 | mag.xpm \ | ||
| 14 | mag-alpha.xpm \ | ||
| 15 | exit.xpm \ | ||
| 16 | viewmag.xpm \ | ||
| 17 | viewmagin.xpm \ | ||
| 18 | viewmagout.xpm \ | ||
| 19 | look.xpm \ | ||
| 20 | left.xpm \ | ||
| 21 | right.xpm \ | ||
| 22 | icon.xpm \ | ||
| 23 | help.xpm | ||
| 24 | SOURCES += main.cpp quax.cpp | ||
| 25 | 10 | #The following line was inserted by qt3to4 | |
| 26 | 11 | QT += qt3support | |
| 12 | |||
| 13 | # Input | ||
| 14 | HEADERS += quax.h | ||
| 15 | SOURCES += main.cpp \ | ||
| 16 | quax.cpp |

