Commit c09650d2c9dc33def0662daa1ee6dab373f5ac73

More cleanup. Approaching the end.
src/quax.cpp
(22 / 22)
  
102102 connect(menu,SIGNAL(aboutToShow()), this, SLOT(updatemenuColor()));
103103
104104 // 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);
108107 m_colorTip->setAlignment(Qt::AlignLeft | Qt::AlignTop);
109108 m_colorTip->setFrameStyle(QFrame::Plain | QFrame::Box);
110109 m_colorTip->setTextFormat(Qt::RichText);
110 m_colorTip->resize(120, 28);
111111
112112 setMouseTracking(true);
113113 startTimer(UPDATE);
259259 // make a little pixmap with grabbed color
260260 m_colorPixmap = grabPix.scaled(14, 14);
261261}
262#include <Q3MimeSourceFactory>
263#include <QResource>
262
264263void Quax::genColorTip()
265264{
266265 grabForPixel();
267 Q3MimeSourceFactory::defaultFactory()->setPixmap("pixel",m_colorPixmap);
268 m_colorTip->setText("<qml>&nbsp;<img height=\"14\" width=\"14\" src=\"pixel\">&nbsp;<tt>" + m_colorStringHexaUpper + "</tt></qml>");
266 m_colorTip->document()->addResource(QTextDocument::ImageResource, QUrl("qrc:/pixel"), m_colorPixmap);
267 m_colorTip->document()->setHtml("<html>&nbsp;<img height=\"14\" width=\"14\" src=\"qrc:/pixel\">&nbsp;<tt>" + m_colorStringHexaUpper + "</tt></html>");
269268
270269 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;
273272 //check if tooltip get outside screen area
274273 QRect r = m_colorTip->rect();
275274 QPoint c = QCursor::pos();
276275 if (c.x()+r.width()+x_ofs+x_margin > qApp->desktop()->width())
277276 x_pos = c.x()-r.width()-x_ofs;
278277 else
279 x_pos=c.x()+x_ofs;
278 x_pos = c.x()+x_ofs;
280279 if (c.y()-r.height()-y_ofs-y_margin < 0)
281 y_pos=c.y()+y_ofs;
280 y_pos = c.y()+y_ofs;
282281 else
283 y_pos=c.y()-r.height()-y_ofs;
282 y_pos = c.y()-r.height()-y_ofs;
284283 m_colorTip->move(x_pos,y_pos);
285284 m_colorTip->show();
286285}
329329 }
330330}
331331
332void 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}
342332void Quax::keyPressEvent(QKeyEvent *e)
343333{
344334 if (!m_colorTipEnabled && e->modifiers() & Qt::ShiftModifier && e->modifiers() & Qt::ControlModifier) {
368368 if (e->modifiers() & Qt::ShiftModifier)
369369 dist *= 10;
370370 move(pos() + dist);
371}
372
373void 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 }
371382}
372383
373384void Quax::help()
src/quax.h
(2 / 1)
  
3838#include <QTimerEvent>
3939#include <QKeyEvent>
4040#include <QPaintEvent>
41#include <QTextBrowser>
4142
4243#define QUAX_VERSION "1.0"
4344#define QUAX_RELEASE "1"
132132 QString m_colorStringDecimal, ///< the current color under mouse as decimals comma seperated
133133 m_colorStringHexaLower, ///< the current color under mouse as web RGB with lower hexadecimals
134134 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
136135 QMenu *menu, ///< The main menu of Quax
137136 *menuZoom, ///< Menu for zoom levels and zoom in and zoom out items
138137 *menuLook, ///< The "Look at" menu
139138 *menuColor; ///< Menu for coying textual representation into clipboard
139 QTextBrowser *m_colorTip; ///< The tool tip for displaying current color under mouse
140140 QPixmap m_zoomPixmap, ///< The grabbed image zoomend and clipped
141141 m_colorPixmap; ///< The icon used in color menu item and color tooltip
142142 bool m_inDrag, ///< if true, the user is dragging the Quax
src/quax.pro
(5 / 15)
  
77DEPENDPATH += .
88INCLUDEPATH += .
99
10# Input
11HEADERS += 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
24SOURCES += main.cpp quax.cpp
2510#The following line was inserted by qt3to4
2611QT += qt3support
12
13# Input
14HEADERS += quax.h
15SOURCES += main.cpp \
16 quax.cpp