Commit 89a3b11416b07bf66ce417102d4937ba54f864c8
- Diff rendering mode:
- inline
- side by side
src/main.cpp
(22 / 23)
|   | |||
| 5 | 5 | // Description: main application | |
| 6 | 6 | // | |
| 7 | 7 | // | |
| 8 | // Author: <claudiuc@kde.org>, (C) 2001, 2002, 2003 | ||
| 8 | // Authors: <claudiuc@kde.org>, (C) 2001, 2002, 2003 | ||
| 9 | // <enrico.ros@gmail.com>, (C) 2009 | ||
| 9 | 10 | // | |
| 10 | 11 | // Copyright: See COPYING file that comes with this distribution | |
| 11 | 12 | // | |
| 12 | 13 | // | |
| 13 | 14 | ||
| 14 | #include <qtextcodec.h> | ||
| 15 | #include <qtranslator.h> | ||
| 16 | #include <qapplication.h> | ||
| 15 | #include <QApplication> | ||
| 16 | #include <QLocale> | ||
| 17 | #include <QTranslator> | ||
| 17 | 18 | ||
| 18 | 19 | #include "quax.h" | |
| 19 | 20 | ||
| 21 | int main(int argc, char ** argv) | ||
| 22 | { | ||
| 23 | QApplication app(argc, argv); | ||
| 24 | app.setApplicationName("Quax"); | ||
| 25 | app.setApplicationVersion("1.2"); | ||
| 20 | 26 | ||
| 21 | int main(int argc, char ** argv) { | ||
| 27 | // install translators (qt + this application) | ||
| 28 | QString locale = QLocale::system().name(); | ||
| 29 | QTranslator qTranslator; | ||
| 30 | qTranslator.load(QString("qt_") + locale, "."); | ||
| 31 | app.installTranslator(&qTranslator); | ||
| 32 | QTranslator appTranslator; | ||
| 33 | appTranslator.load(QString("quax_") + locale, "."); | ||
| 34 | app.installTranslator(&appTranslator); | ||
| 22 | 35 | ||
| 23 | QApplication a(argc,argv); | ||
| 24 | |||
| 25 | // translation file for Qt | ||
| 26 | QTranslator qt(0); | ||
| 27 | qt.load(QString("qt_")+QTextCodec::locale(),"."); | ||
| 28 | a.installTranslator(&qt); | ||
| 29 | |||
| 30 | // translation file for my application | ||
| 31 | QTranslator myapp(0); | ||
| 32 | qt.load(QString("quax_")+QTextCodec::locale(),"."); | ||
| 33 | a.installTranslator(&myapp); | ||
| 34 | |||
| 35 | Quax * quax = new Quax(); | ||
| 36 | |||
| 37 | a.setMainWidget(quax); | ||
| 38 | quax->setCaption("Quax"); | ||
| 39 | quax->show(); | ||
| 40 | return a.exec(); | ||
| 36 | Quax quax; | ||
| 37 | quax.setWindowTitle(app.applicationName()); | ||
| 38 | quax.show(); | ||
| 39 | return app.exec(); | ||
| 41 | 40 | } |
src/quax.cpp
(159 / 159)
|   | |||
| 46 | 46 | #include <QLabel> | |
| 47 | 47 | #include <QPixmap> | |
| 48 | 48 | #include <Q3Frame> | |
| 49 | #include <Q3PopupMenu> | ||
| 49 | #include <QMenu> | ||
| 50 | 50 | #include <QMouseEvent> | |
| 51 | 51 | #include <QEvent> | |
| 52 | 52 | #include <QPaintEvent> | |
| … | … | ||
| 64 | 64 | #else | |
| 65 | 65 | // "borrowed" from kcursor.cpp from kdelibs | |
| 66 | 66 | static const unsigned char HAND_BITS[] = { | |
| 67 | 0x80, 0x01, 0x00, 0x40, 0x02, 0x00, 0x40, 0x02, 0x00, 0x40, 0x02, | ||
| 68 | 0x00, 0x40, 0x02, 0x00, 0x40, 0x02, 0x00, 0x40, 0x1e, 0x00, 0x40, | ||
| 69 | 0xf2, 0x00, 0x40, 0x92, 0x01, 0x70, 0x92, 0x02, 0x50, 0x92, 0x04, | ||
| 70 | 0x48, 0x80, 0x04, 0x48, 0x00, 0x04, 0x48, 0x00, 0x04, 0x08, 0x00, | ||
| 71 | 0x04, 0x08, 0x00, 0x04, 0x10, 0x00, 0x04, 0x10, 0x00, 0x04, 0x20, | ||
| 72 | 0x00, 0x02, 0x40, 0x00, 0x02, 0x40, 0x00, 0x01, 0xc0, 0xff, 0x01 | ||
| 73 | }; | ||
| 67 | 0x80, 0x01, 0x00, 0x40, 0x02, 0x00, 0x40, 0x02, 0x00, 0x40, 0x02, | ||
| 68 | 0x00, 0x40, 0x02, 0x00, 0x40, 0x02, 0x00, 0x40, 0x1e, 0x00, 0x40, | ||
| 69 | 0xf2, 0x00, 0x40, 0x92, 0x01, 0x70, 0x92, 0x02, 0x50, 0x92, 0x04, | ||
| 70 | 0x48, 0x80, 0x04, 0x48, 0x00, 0x04, 0x48, 0x00, 0x04, 0x08, 0x00, | ||
| 71 | 0x04, 0x08, 0x00, 0x04, 0x10, 0x00, 0x04, 0x10, 0x00, 0x04, 0x20, | ||
| 72 | 0x00, 0x02, 0x40, 0x00, 0x02, 0x40, 0x00, 0x01, 0xc0, 0xff, 0x01 | ||
| 73 | }; | ||
| 74 | 74 | static const unsigned char HAND_MASK_BITS[] = { | |
| 75 | 0x80, 0x01, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, | ||
| 76 | 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x1f, 0x00, 0xc0, | ||
| 77 | 0xff, 0x00, 0xc0, 0xff, 0x01, 0xf0, 0xff, 0x03, 0xf0, 0xff, 0x07, | ||
| 78 | 0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff, | ||
| 79 | 0x07, 0xf8, 0xff, 0x07, 0xf0, 0xff, 0x07, 0xf0, 0xff, 0x07, 0xe0, | ||
| 80 | 0xff, 0x03, 0xc0, 0xff, 0x03, 0xc0, 0xff, 0x01, 0xc0, 0xff, 0x01 | ||
| 81 | }; | ||
| 82 | QBitmap hand_bitmap(22, 22, HAND_BITS, true); | ||
| 75 | 0x80, 0x01, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, | ||
| 76 | 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xc0, 0x1f, 0x00, 0xc0, | ||
| 77 | 0xff, 0x00, 0xc0, 0xff, 0x01, 0xf0, 0xff, 0x03, 0xf0, 0xff, 0x07, | ||
| 78 | 0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff, | ||
| 79 | 0x07, 0xf8, 0xff, 0x07, 0xf0, 0xff, 0x07, 0xf0, 0xff, 0x07, 0xe0, | ||
| 80 | 0xff, 0x03, 0xc0, 0xff, 0x03, 0xc0, 0xff, 0x01, 0xc0, 0xff, 0x01 | ||
| 81 | }; | ||
| 82 | QBitmap hand_bitmap(22, 22, HAND_BITS, true); | ||
| 83 | 83 | QBitmap hand_mask(22, 22, HAND_MASK_BITS, true); | |
| 84 | 84 | hand_cursor = QCursor(hand_bitmap, hand_mask, 7, 0); | |
| 85 | 85 | #endif | |
| … | … | ||
| 127 | 127 | ||
| 128 | 128 | ||
| 129 | 129 | // build RMB popup menu | |
| 130 | menu = new Q3PopupMenu(this); | ||
| 130 | menu = new QMenu(this); | ||
| 131 | 131 | ||
| 132 | menuzoom = new Q3PopupMenu(this); | ||
| 132 | menuzoom = new QMenu(this); | ||
| 133 | 133 | menuzoom->setCheckable(true); | |
| 134 | 134 | for (int i=ZOOM_SCALE_MIN; i<=ZOOM_SCALE_MAX; i++) { | |
| 135 | 135 | zoomid[i]=menuzoom->insertItem(QObject::tr("1:%1").arg(i),this,SLOT(zoomTo(int))); | |
| … | … | ||
| 143 | 143 | menuzoom->insertItem(QPixmap(viewmagout_xpm),QObject::tr("Zoom Out"),this,SLOT(zoomOut()),Q3Accel::stringToKey(QObject::tr("-","Zoom Out"))); | |
| 144 | 144 | #endif | |
| 145 | 145 | ||
| 146 | menulook = new Q3PopupMenu(this); | ||
| 146 | menulook = new QMenu(this); | ||
| 147 | 147 | menulook->setCheckable(true); | |
| 148 | 148 | #if QT_VERSION >= 300 | |
| 149 | 149 | lookid[1]=menulook->insertItem(QObject::tr("North-West"),this,SLOT(rotateNorthWest()),QKeySequence(QObject::tr("U","North-West"))); | |
| … | … | ||
| 164 | 164 | menulook->insertItem(QPixmap(left_xpm),QObject::tr("Rotate Left"),this,SLOT(rotateLeft()),Q3Accel::stringToKey(QObject::tr("l","Rotate Left"))); | |
| 165 | 165 | menulook->insertItem(QPixmap(right_xpm),QObject::tr("Rotate Right"),this,SLOT(rotateRight()),Q3Accel::stringToKey(QObject::tr("r","Rotate Right"))); | |
| 166 | 166 | #endif | |
| 167 | |||
| 168 | menucolor = new Q3PopupMenu(this); | ||
| 167 | |||
| 168 | menucolor = new QMenu(this); | ||
| 169 | 169 | colorid[1]=menucolor->insertItem(colorStringDecimal,this,SLOT(copyColor(int))); | |
| 170 | 170 | #if QT_VERSION >= 300 | |
| 171 | 171 | colorid[2]=menucolor->insertItem(colorStringHexaLower,this,SLOT(copyColor(int)),QKeySequence(QObject::tr("Ctrl+C","Copy Color"))); | |
| … | … | ||
| 219 | 219 | ||
| 220 | 220 | ||
| 221 | 221 | Quax::~Quax() { | |
| 222 | delete colorTip; | ||
| 222 | delete colorTip; | ||
| 223 | 223 | } | |
| 224 | 224 | ||
| 225 | 225 | ||
| 226 | 226 | void Quax::enterEvent(QEvent *e) { | |
| 227 | e=e; | ||
| 227 | e=e; | ||
| 228 | 228 | ||
| 229 | cursorOverQuax=true; | ||
| 230 | if (colorTipShowed && colorTip->isHidden()) { | ||
| 231 | displayColorTip(); | ||
| 232 | } | ||
| 229 | cursorOverQuax=true; | ||
| 230 | if (colorTipShowed && colorTip->isHidden()) { | ||
| 231 | displayColorTip(); | ||
| 232 | } | ||
| 233 | 233 | } | |
| 234 | 234 | ||
| 235 | 235 | ||
| 236 | 236 | void Quax::leaveEvent(QEvent *e) { | |
| 237 | e=e; | ||
| 237 | e=e; | ||
| 238 | 238 | ||
| 239 | cursorOverQuax=false; | ||
| 240 | if (colorTipShowed) { | ||
| 241 | colorTip->hide(); | ||
| 242 | } | ||
| 239 | cursorOverQuax=false; | ||
| 240 | if (colorTipShowed) { | ||
| 241 | colorTip->hide(); | ||
| 242 | } | ||
| 243 | 243 | } | |
| 244 | 244 | ||
| 245 | 245 | ||
| … | … | ||
| 277 | 277 | } | |
| 278 | 278 | ||
| 279 | 279 | void Quax::wheelEvent(QWheelEvent *e) { | |
| 280 | if (ctrlKeyOn) { | ||
| 281 | if (e->delta()>0) { | ||
| 282 | rotateLeft(); | ||
| 280 | if (ctrlKeyOn) { | ||
| 281 | if (e->delta()>0) { | ||
| 282 | rotateLeft(); | ||
| 283 | } else { | ||
| 284 | rotateRight(); | ||
| 285 | } | ||
| 283 | 286 | } else { | |
| 284 | rotateRight(); | ||
| 287 | if (e->delta()>0) { | ||
| 288 | zoomIn(); | ||
| 289 | } else { | ||
| 290 | zoomOut(); | ||
| 291 | } | ||
| 285 | 292 | } | |
| 286 | } else { | ||
| 287 | if (e->delta()>0) { | ||
| 288 | zoomIn(); | ||
| 289 | } else { | ||
| 290 | zoomOut(); | ||
| 293 | e->accept(); | ||
| 294 | if (colorTipShowed && ! colorTip->isHidden()) { | ||
| 295 | displayColorTip(); | ||
| 291 | 296 | } | |
| 292 | } | ||
| 293 | e->accept(); | ||
| 294 | if (colorTipShowed && ! colorTip->isHidden()) { | ||
| 295 | displayColorTip(); | ||
| 296 | } | ||
| 297 | 297 | } | |
| 298 | 298 | ||
| 299 | 299 | void Quax::grab() { | |
| … | … | ||
| 371 | 371 | } | |
| 372 | 372 | ||
| 373 | 373 | void Quax::grabForPixel() { | |
| 374 | // get the color under cursor | ||
| 375 | QPixmap pix_grab = QPixmap::grabWindow(QApplication::desktop()->winId(),QCursor::pos().x()-1,QCursor::pos().y()-1,1,1); | ||
| 376 | QImage img_grab = pix_grab.convertToImage(); | ||
| 377 | QRgb rgb_color = img_grab.pixel(0,0); | ||
| 378 | colorStringDecimal = QString::number(qRed(rgb_color)) + ", " + | ||
| 379 | QString::number(qGreen(rgb_color)) + ", " + | ||
| 380 | QString::number(qBlue(rgb_color)); | ||
| 381 | colorStringHexaLower.sprintf("#%02x%02x%02x",qRed(rgb_color),qGreen(rgb_color),qBlue(rgb_color)); | ||
| 382 | colorStringHexaUpper = colorStringHexaLower.upper(); | ||
| 374 | // get the color under cursor | ||
| 375 | QPixmap pix_grab = QPixmap::grabWindow(QApplication::desktop()->winId(),QCursor::pos().x()-1,QCursor::pos().y()-1,1,1); | ||
| 376 | QImage img_grab = pix_grab.convertToImage(); | ||
| 377 | QRgb rgb_color = img_grab.pixel(0,0); | ||
| 378 | colorStringDecimal = QString::number(qRed(rgb_color)) + ", " + | ||
| 379 | QString::number(qGreen(rgb_color)) + ", " + | ||
| 380 | QString::number(qBlue(rgb_color)); | ||
| 381 | colorStringHexaLower.sprintf("#%02x%02x%02x",qRed(rgb_color),qGreen(rgb_color),qBlue(rgb_color)); | ||
| 382 | colorStringHexaUpper = colorStringHexaLower.upper(); | ||
| 383 | 383 | ||
| 384 | // make a little pixmap with grabbed color | ||
| 385 | QMatrix m; | ||
| 386 | m.scale((double)14,(double)14); | ||
| 387 | pix_cursor=pix_grab.xForm(m); | ||
| 384 | // make a little pixmap with grabbed color | ||
| 385 | QMatrix m; | ||
| 386 | m.scale((double)14,(double)14); | ||
| 387 | pix_cursor=pix_grab.xForm(m); | ||
| 388 | 388 | } | |
| 389 | 389 | ||
| 390 | 390 | void Quax::displayColorTip() { | |
| 391 | return; | ||
| 392 | /* | ||
| 391 | return; | ||
| 392 | /* | ||
| 393 | 393 | grabForPixel(); | |
| 394 | 394 | Q3MimeSourceFactory::defaultFactory()->setPixmap("pixel",pix_cursor); | |
| 395 | 395 | colorTip->setText("<qml> <img height=\"14\" width=\"14\" src=\"pixel\"> <tt>" + colorStringHexaUpper + "</tt></qml>"); | |
| … | … | ||
| 420 | 420 | switch (e->button()) { | |
| 421 | 421 | case Qt::LeftButton: | |
| 422 | 422 | if (colorTipShowed) { | |
| 423 | copyColor(0); | ||
| 424 | setCursor(copy_cursor); | ||
| 423 | copyColor(0); | ||
| 424 | setCursor(copy_cursor); | ||
| 425 | 425 | } else { | |
| 426 | grabMouse(hand_cursor); | ||
| 427 | inDrag=true; | ||
| 428 | dragOffset = QCursor::pos() - QPoint(geometry().left(),geometry().top()); | ||
| 426 | grabMouse(hand_cursor); | ||
| 427 | inDrag=true; | ||
| 428 | dragOffset = QCursor::pos() - QPoint(geometry().left(),geometry().top()); | ||
| 429 | 429 | } | |
| 430 | 430 | break; | |
| 431 | 431 | case Qt::RightButton: | |
| … | … | ||
| 440 | 440 | switch (e->button()) { | |
| 441 | 441 | case Qt::LeftButton: | |
| 442 | 442 | if (colorTipShowed) { | |
| 443 | setCursor(cross_cursor); | ||
| 443 | setCursor(cross_cursor); | ||
| 444 | 444 | } else { | |
| 445 | releaseMouse(); | ||
| 446 | inDrag=false; | ||
| 445 | releaseMouse(); | ||
| 446 | inDrag=false; | ||
| 447 | 447 | } | |
| 448 | 448 | break; | |
| 449 | 449 | default: | |
| … | … | ||
| 455 | 455 | e=e; | |
| 456 | 456 | ||
| 457 | 457 | if (colorTipShowed && cursorOverQuax) { | |
| 458 | displayColorTip(); | ||
| 458 | displayColorTip(); | ||
| 459 | 459 | } | |
| 460 | 460 | if (!inDrag || this != mouseGrabber()) return; | |
| 461 | 461 | move(QCursor::pos()-dragOffset); | |
| … | … | ||
| 464 | 464 | ||
| 465 | 465 | void Quax::keyReleaseEvent(QKeyEvent *e) { | |
| 466 | 466 | if (ctrlKeyOn) { | |
| 467 | if (!(e->state() & Qt::ShiftButton) && (e->key() == Qt::Key_Control)) { | ||
| 468 | ctrlKeyOn=false; | ||
| 469 | } | ||
| 467 | if (!(e->state() & Qt::ShiftButton) && (e->key() == Qt::Key_Control)) { | ||
| 468 | ctrlKeyOn=false; | ||
| 469 | } | ||
| 470 | 470 | } | |
| 471 | 471 | ||
| 472 | 472 | if (colorTipShowed) { | |
| 473 | if (e->key() == Qt::Key_Control ||e->key() == Qt::Key_Shift) { | ||
| 474 | colorTipShowed=false; | ||
| 475 | setCursor(hand_cursor); | ||
| 476 | colorTip->hide(); | ||
| 477 | } | ||
| 473 | if (e->key() == Qt::Key_Control ||e->key() == Qt::Key_Shift) { | ||
| 474 | colorTipShowed=false; | ||
| 475 | setCursor(hand_cursor); | ||
| 476 | colorTip->hide(); | ||
| 477 | } | ||
| 478 | 478 | } | |
| 479 | 479 | } | |
| 480 | 480 | ||
| … | … | ||
| 482 | 482 | QPoint dist(0,0); | |
| 483 | 483 | ||
| 484 | 484 | if (!(e->state() & Qt::ShiftButton) && (e->key() == Qt::Key_Control)) { | |
| 485 | ctrlKeyOn=true; | ||
| 486 | e->ignore(); | ||
| 487 | return; | ||
| 485 | ctrlKeyOn=true; | ||
| 486 | e->ignore(); | ||
| 487 | return; | ||
| 488 | 488 | } | |
| 489 | 489 | ||
| 490 | 490 | if (!colorTipShowed) { | |
| 491 | if ((e->state() & Qt::ShiftButton) && (e->key() == Qt::Key_Control) || | ||
| 492 | (e->state() & Qt::ControlButton) && (e->key() == Qt::Key_Shift)) { | ||
| 493 | colorTipShowed=true; | ||
| 494 | ctrlKeyOn=false; | ||
| 495 | setCursor(cross_cursor); | ||
| 496 | displayColorTip(); | ||
| 497 | e->ignore(); | ||
| 498 | return; | ||
| 499 | } | ||
| 491 | if (((e->state() & Qt::ShiftButton) && (e->key() == Qt::Key_Control)) || | ||
| 492 | ((e->state() & Qt::ControlButton) && (e->key() == Qt::Key_Shift))) { | ||
| 493 | colorTipShowed=true; | ||
| 494 | ctrlKeyOn=false; | ||
| 495 | setCursor(cross_cursor); | ||
| 496 | displayColorTip(); | ||
| 497 | e->ignore(); | ||
| 498 | return; | ||
| 499 | } | ||
| 500 | 500 | } | |
| 501 | 501 | ||
| 502 | 502 | ||
| 503 | 503 | ||
| 504 | 504 | switch (e->key()) { | |
| 505 | case Qt::Key_Left: | ||
| 505 | case Qt::Key_Left: | ||
| 506 | 506 | dist.setX(-1); | |
| 507 | break; | ||
| 508 | case Qt::Key_Right: | ||
| 507 | break; | ||
| 508 | case Qt::Key_Right: | ||
| 509 | 509 | dist.setX(1); | |
| 510 | break; | ||
| 511 | case Qt::Key_Up: | ||
| 510 | break; | ||
| 511 | case Qt::Key_Up: | ||
| 512 | 512 | dist.setY(-1); | |
| 513 | break; | ||
| 514 | case Qt::Key_Down: | ||
| 513 | break; | ||
| 514 | case Qt::Key_Down: | ||
| 515 | 515 | dist.setY(1); | |
| 516 | break; | ||
| 517 | case Qt::Key_Equal: | ||
| 518 | zoomIn(); | ||
| 519 | break; | ||
| 520 | case Qt::Key_Underscore: | ||
| 521 | zoomOut(); | ||
| 522 | break; | ||
| 523 | default: | ||
| 516 | break; | ||
| 517 | case Qt::Key_Equal: | ||
| 518 | zoomIn(); | ||
| 519 | break; | ||
| 520 | case Qt::Key_Underscore: | ||
| 521 | zoomOut(); | ||
| 522 | break; | ||
| 523 | default: | ||
| 524 | 524 | e->ignore(); | |
| 525 | 525 | return; | |
| 526 | 526 | } | |
| … | … | ||
| 534 | 534 | #if QT_VERSION >= 300 | |
| 535 | 535 | #ifdef _OS_WIN32_ | |
| 536 | 536 | #else | |
| 537 | QString helpApp = "kfmclient"; | ||
| 537 | QString helpApp = "kfmclient"; | ||
| 538 | 538 | ||
| 539 | Q3Process *proc = new Q3Process(this); | ||
| 540 | proc->addArgument(helpApp); | ||
| 541 | proc->addArgument("openURL"); | ||
| 542 | proc->addArgument("help:quax"); | ||
| 543 | proc->closeStdin(); | ||
| 544 | if (!proc->start()) { | ||
| 545 | QMessageBox::critical(this,QObject::tr("Help Error"), | ||
| 546 | QObject::tr("<qml>There was an error executing <b>%1</b> application. " | ||
| 547 | "Please check your KDE installation. You may try to open an <b>xterm</b> " | ||
| 548 | "window and run <tt>man quax</tt> from there.</qml>").arg(helpApp), | ||
| 549 | QMessageBox::Ok, Qt::NoButton, Qt::NoButton); | ||
| 550 | } | ||
| 539 | Q3Process *proc = new Q3Process(this); | ||
| 540 | proc->addArgument(helpApp); | ||
| 541 | proc->addArgument("openURL"); | ||
| 542 | proc->addArgument("help:quax"); | ||
| 543 | proc->closeStdin(); | ||
| 544 | if (!proc->start()) { | ||
| 545 | QMessageBox::critical(this,QObject::tr("Help Error"), | ||
| 546 | QObject::tr("<qml>There was an error executing <b>%1</b> application. " | ||
| 547 | "Please check your KDE installation. You may try to open an <b>xterm</b> " | ||
| 548 | "window and run <tt>man quax</tt> from there.</qml>").arg(helpApp), | ||
| 549 | QMessageBox::Ok, Qt::NoButton, Qt::NoButton); | ||
| 550 | } | ||
| 551 | 551 | #endif | |
| 552 | 552 | #endif | |
| 553 | 553 | } | |
| 554 | 554 | ||
| 555 | 555 | void Quax::about() { | |
| 556 | QMessageBox::about(this,QObject::tr("About Quax %1").arg(VERSION "-" RELEASE),QObject::tr( | ||
| 557 | "<p><b>Quax</b> is a little magnifing tool for X. Quax homepage is " | ||
| 558 | "at <tt><http://www.ro.kde.org/quax/></tt>." | ||
| 559 | "</p><p>This is Quax version %1." | ||
| 560 | "</p><p>This program is released under GNU General Public License." | ||
| 561 | "<dl>" | ||
| 562 | "<dt><nobr>Claudiu Costin <tt><claudiuc@kde.org></tt></nobr></dt>" | ||
| 563 | "<dd>coding, documentation, packaging</dd>" | ||
| 564 | "<dt><nobr>Vlad Oancea <tt><xtrim@fx.ro></tt></nobr></dt>" | ||
| 565 | "<dd>Quax skin design</dd>" | ||
| 566 | "</dl></p>").arg(VERSION "-" RELEASE)); | ||
| 556 | QMessageBox::about(this,QObject::tr("About Quax %1").arg(QUAX_VERSION "-" QUAX_RELEASE),QObject::tr( | ||
| 557 | "<p><b>Quax</b> is a little magnifing tool for X. Quax homepage is " | ||
| 558 | "at <tt><http://www.ro.kde.org/quax/></tt>." | ||
| 559 | "</p><p>This is Quax version %1." | ||
| 560 | "</p><p>This program is released under GNU General Public License." | ||
| 561 | "<dl>" | ||
| 562 | "<dt><nobr>Claudiu Costin <tt><claudiuc@kde.org></tt></nobr></dt>" | ||
| 563 | "<dd>coding, documentation, packaging</dd>" | ||
| 564 | "<dt><nobr>Vlad Oancea <tt><xtrim@fx.ro></tt></nobr></dt>" | ||
| 565 | "<dd>Quax skin design</dd>" | ||
| 566 | "</dl></p>").arg(QUAX_VERSION "-" QUAX_RELEASE)); | ||
| 567 | 567 | } | |
| 568 | 568 | ||
| 569 | 569 | void Quax::aboutQt() { | |
| … | … | ||
| 589 | 589 | void Quax::zoomTo(int pos) { | |
| 590 | 590 | for (int i=ZOOM_SCALE_MIN;i<=ZOOM_SCALE_MAX;i++) | |
| 591 | 591 | if (zoomid[i]==pos) { | |
| 592 | menuzoom->setItemChecked(zoomid[i],true); | ||
| 593 | zoom=i; | ||
| 594 | } else { | ||
| 595 | menuzoom->setItemChecked(zoomid[i],false); | ||
| 596 | } | ||
| 592 | menuzoom->setItemChecked(zoomid[i],true); | ||
| 593 | zoom=i; | ||
| 594 | } else { | ||
| 595 | menuzoom->setItemChecked(zoomid[i],false); | ||
| 596 | } | ||
| 597 | 597 | } | |
| 598 | 598 | ||
| 599 | 599 | void Quax::rotateNorthWest() { | |
| … | … | ||
| 655 | 655 | ||
| 656 | 656 | ||
| 657 | 657 | void Quax::copyColor(int id) { | |
| 658 | |||
| 659 | if (id == colorid[1] ) { | ||
| 660 | qApp->clipboard()->setText(colorStringDecimal); | ||
| 661 | } else if (id == colorid[2]) { | ||
| 662 | // this get called when user press Ctrl+C | ||
| 663 | // | ||
| 664 | // I must call grabForPixel because it's posible that | ||
| 665 | // this slot get executed even user doesn't right click | ||
| 666 | // on Quax, so updateMenuColor is not yet called and | ||
| 667 | // variables may contain old or invalid color | ||
| 668 | grabForPixel(); | ||
| 669 | qApp->clipboard()->setText(colorStringHexaLower); | ||
| 670 | } else if (id == colorid[3] || id == 0) { | ||
| 671 | // id=0 if user click when color tip is displayed | ||
| 672 | qApp->clipboard()->setText(colorStringHexaUpper); | ||
| 673 | } else { | ||
| 674 | qWarning("id=%d: This must not happen",id); | ||
| 675 | } | ||
| 658 | |||
| 659 | if (id == colorid[1] ) { | ||
| 660 | qApp->clipboard()->setText(colorStringDecimal); | ||
| 661 | } else if (id == colorid[2]) { | ||
| 662 | // this get called when user press Ctrl+C | ||
| 663 | // | ||
| 664 | // I must call grabForPixel because it's posible that | ||
| 665 | // this slot get executed even user doesn't right click | ||
| 666 | // on Quax, so updateMenuColor is not yet called and | ||
| 667 | // variables may contain old or invalid color | ||
| 668 | grabForPixel(); | ||
| 669 | qApp->clipboard()->setText(colorStringHexaLower); | ||
| 670 | } else if (id == colorid[3] || id == 0) { | ||
| 671 | // id=0 if user click when color tip is displayed | ||
| 672 | qApp->clipboard()->setText(colorStringHexaUpper); | ||
| 673 | } else { | ||
| 674 | qWarning("id=%d: This must not happen",id); | ||
| 675 | } | ||
| 676 | 676 | } | |
| 677 | 677 | ||
| 678 | 678 | void Quax::updateMenuColor() { | |
| 679 | grabForPixel(); | ||
| 679 | grabForPixel(); | ||
| 680 | 680 | #if QT_VERSION > 300 | |
| 681 | ///pixelColorIcon->clearGenerated(); | ||
| 681 | ///pixelColorIcon->clearGenerated(); | ||
| 682 | 682 | #endif | |
| 683 | pixelColorIcon->reset(pix_cursor,QIcon::Small); | ||
| 683 | pixelColorIcon->reset(pix_cursor,QIcon::Small); | ||
| 684 | 684 | ||
| 685 | menu->changeItem(colorid[0],QIcon(pix_cursor),QObject::tr("Copy Color")); | ||
| 686 | menucolor->changeItem(colorid[1],colorStringDecimal); | ||
| 687 | menucolor->changeItem(colorid[2],colorStringHexaLower); | ||
| 688 | menucolor->changeItem(colorid[3],colorStringHexaUpper); | ||
| 685 | menu->changeItem(colorid[0],QIcon(pix_cursor),QObject::tr("Copy Color")); | ||
| 686 | menucolor->changeItem(colorid[1],colorStringDecimal); | ||
| 687 | menucolor->changeItem(colorid[2],colorStringHexaLower); | ||
| 688 | menucolor->changeItem(colorid[3],colorStringHexaUpper); | ||
| 689 | 689 | } |
src/quax.h
(183 / 184)
|   | |||
| 5 | 5 | // Description: Quax declarations | |
| 6 | 6 | // | |
| 7 | 7 | // | |
| 8 | // Author: <claudiuc@kde.org>, (C) 2001, 2002, 2003 | ||
| 8 | // Authors: <claudiuc@kde.org>, (C) 2001, 2002, 2003 | ||
| 9 | // <enrico.ros@gmail.com>, (C) 2009 | ||
| 9 | 10 | // | |
| 10 | 11 | // Copyright: See COPYING file that comes with this distribution | |
| 11 | 12 | // | |
| 12 | 13 | // | |
| 13 | 14 | ||
| 14 | #ifndef QUAX_H | ||
| 15 | #define QUAX_H | ||
| 15 | #ifndef __quax_h__ | ||
| 16 | #define __quax_h__ | ||
| 16 | 17 | ||
| 17 | #include "../config.h" | ||
| 18 | |||
| 19 | 18 | #include <qglobal.h> | |
| 20 | 19 | ||
| 21 | 20 | #include <qcursor.h> | |
| … | … | ||
| 30 | 30 | #include <qmessagebox.h> | |
| 31 | 31 | #include <qapplication.h> | |
| 32 | 32 | #include <qmatrix.h> | |
| 33 | #include <q3popupmenu.h> | ||
| 34 | 33 | #include <qapplication.h> | |
| 35 | 34 | //Added by qt3to4: | |
| 35 | #include <QMenu> | ||
| 36 | 36 | #include <QWheelEvent> | |
| 37 | 37 | #include <QEvent> | |
| 38 | 38 | #include <QMouseEvent> | |
| … | … | ||
| 40 | 40 | #include <QKeyEvent> | |
| 41 | 41 | #include <QPaintEvent> | |
| 42 | 42 | ||
| 43 | #define QUAX_VERSION "1.0" | ||
| 44 | #define QUAX_RELEASE "1" | ||
| 45 | |||
| 43 | 46 | #define PIX_CURSOR_SCALE 10 | |
| 44 | 47 | #define ZOOM_SCALE_MIN 2 | |
| 45 | 48 | #define ZOOM_SCALE_MAX 5 | |
| … | … | ||
| 56 | 56 | ||
| 57 | 57 | #define UPDATE 40 | |
| 58 | 58 | ||
| 59 | |||
| 60 | 59 | /** | |
| 61 | 60 | * Magnifing widget for desktop | |
| 62 | 61 | * | |
| … | … | ||
| 65 | 65 | */ | |
| 66 | 66 | class Quax : public QWidget | |
| 67 | 67 | { | |
| 68 | Q_OBJECT | ||
| 68 | Q_OBJECT | ||
| 69 | public: | ||
| 70 | /** | ||
| 71 | * Contruct Quax GUI and initialize variables to sane values. | ||
| 72 | * It build popup menu, set the Quax widget pixmap mask, build custom | ||
| 73 | * cursors and start grab timer. | ||
| 74 | */ | ||
| 75 | Quax(); | ||
| 76 | /** | ||
| 77 | * Destroy Quax instance | ||
| 78 | */ | ||
| 79 | ~Quax(); | ||
| 80 | |||
| 81 | protected: | ||
| 82 | /** | ||
| 83 | * Show color tooltip when mouse enter Quax area, and set | ||
| 84 | * the @p cursorOverQuax flag. | ||
| 85 | */ | ||
| 86 | void enterEvent(QEvent *e); | ||
| 87 | /** | ||
| 88 | * Hide color tooltip if shown, and set the @p cursorOverQuax flag. | ||
| 89 | */ | ||
| 90 | void leaveEvent(QEvent *e); | ||
| 91 | /** | ||
| 92 | * If right button was pressed, show popup menu. If color tooltip is already | ||
| 93 | * showed then "take a shot" of current pixel under cursor. | ||
| 94 | */ | ||
| 95 | void mousePressEvent(QMouseEvent *e); | ||
| 96 | /** | ||
| 97 | * Executed when user release one mouse button. | ||
| 98 | */ | ||
| 99 | void mouseReleaseEvent(QMouseEvent *e); | ||
| 100 | /** | ||
| 101 | * Executed when user release move the mouse. If the color tip is enabled, | ||
| 102 | * then displayed color is updated as well the tooltip position. | ||
| 103 | * If is @p inDrag is true, then Quax position is updated (dragged) | ||
| 104 | * to that of mouse position. | ||
| 105 | */ | ||
| 106 | void mouseMoveEvent(QMouseEvent *e); | ||
| 107 | /** | ||
| 108 | * Get the modifier keys status and display color tooltip if Shift and Ctrl | ||
| 109 | * are both pressed down. If cursor keys are pressed, then adjust Quax | ||
| 110 | * position by one pixel or by ten pixels if Shift is down. | ||
| 111 | */ | ||
| 112 | void keyPressEvent(QKeyEvent *e); | ||
| 113 | /** | ||
| 114 | * Hide color tooltip if one of Shift and Ctrl key modifiers is released. | ||
| 115 | */ | ||
| 116 | void keyReleaseEvent(QKeyEvent *e); | ||
| 117 | /** | ||
| 118 | * Take the grabbed @p pix_zoom pixmap and scale it. Then it's painted | ||
| 119 | * on Quax following an circle region for clipping. | ||
| 120 | */ | ||
| 121 | void paintEvent(QPaintEvent *e); | ||
| 122 | /** | ||
| 123 | * Grab a screen region at every 40 miliseconds executing @ref grab(). | ||
| 124 | */ | ||
| 125 | void timerEvent(QTimerEvent *e); | ||
| 126 | /** | ||
| 127 | * If mouse wheel is dragged, then zoom scale in or out. When Ctrl key | ||
| 128 | * modifier is pressed, Quax is rotated left or right | ||
| 129 | */ | ||
| 130 | void wheelEvent(QWheelEvent *e); | ||
| 69 | 131 | ||
| 70 | public: | ||
| 71 | /** | ||
| 72 | * Contruct Quax GUI and initialize variables to sane values. | ||
| 73 | * It build popup menu, set the Quax widget pixmap mask, build custom | ||
| 74 | * cursors and start grab timer. | ||
| 75 | */ | ||
| 76 | Quax(); | ||
| 77 | /** | ||
| 78 | * Destroy Quax instance | ||
| 79 | */ | ||
| 80 | ~Quax(); | ||
| 132 | private: | ||
| 133 | QString colorStringDecimal, ///< the current color under mouse as decimals comma seperated | ||
| 134 | colorStringHexaLower, ///< the current color under mouse as web RGB with lower hexadecimals | ||
| 135 | colorStringHexaUpper; ///< the current color under mouse as web RGB with upper hexadecimals | ||
| 136 | QIcon *pixelColorIcon; ///< The icon set which is used in QML content from @ref colorTip | ||
| 137 | QLabel *colorTip; ///< The tool tip for displaying current color under mouse | ||
| 138 | QMenu *menu, ///< The main menu of Quax | ||
| 139 | *menuzoom, ///< Menu for zoom levels and zoom in and zoom out items | ||
| 140 | *menulook, ///< The "Look at" menu | ||
| 141 | *menucolor; ///< Menu for coying textual representation into clipboard | ||
| 142 | QPixmap pix, ///< Quax skin image | ||
| 143 | pix_alpha, ///< Quax alpha mask for skin image | ||
| 144 | pix_zoom, ///< The grabbed image zoomend and clipped | ||
| 145 | pix_cursor; ///< The icon used in color menu item and color tooltip | ||
| 146 | QCursor hand_cursor, ///< normal mouse cursor when mouse pointer is over Quax | ||
| 147 | cross_cursor, ///< cursor when color tooltip is displayed (cross) | ||
| 148 | copy_cursor; ///< cursor when user "take a shot" of current color | ||
| 149 | bool inDrag, ///< if true, the user is dragging the Quax | ||
| 150 | colorTipShowed, ///< if true, the color tooltip is displayed | ||
| 151 | cursorOverQuax, ///< if true, mouse cursor is over Quax surface | ||
| 152 | ctrlKeyOn; ///< if true, the Ctrl key is pressed down | ||
| 153 | QPoint dragOffset; ///< the offset between Quax position and new mouse position | ||
| 154 | QMap<int,int> zoomid, ///< mapping between zoom level and @ref menuzoom menu item ids | ||
| 155 | lookid, ///< mapping between look direction and @ref menulook menu item ids | ||
| 156 | colorid; ///< mapping between text color type and @ref menucolor menu item ids | ||
| 157 | int zoom, ///< current zoom level | ||
| 158 | look; ///< current quadrant direction where Quax "look at" | ||
| 81 | 159 | ||
| 82 | protected: | ||
| 83 | /** | ||
| 84 | * Show color tooltip when mouse enter Quax area, and set | ||
| 85 | * the @p cursorOverQuax flag. | ||
| 86 | */ | ||
| 87 | void enterEvent(QEvent *e); | ||
| 88 | /** | ||
| 89 | * Hide color tooltip if shown, and set the @p cursorOverQuax flag. | ||
| 90 | */ | ||
| 91 | void leaveEvent(QEvent *e); | ||
| 92 | /** | ||
| 93 | * If right button was pressed, show popup menu. If color tooltip is already | ||
| 94 | * showed then "take a shot" of current pixel under cursor. | ||
| 95 | */ | ||
| 96 | void mousePressEvent(QMouseEvent *e); | ||
| 97 | /** | ||
| 98 | * Executed when user release one mouse button. | ||
| 99 | */ | ||
| 100 | void mouseReleaseEvent(QMouseEvent *e); | ||
| 101 | /** | ||
| 102 | * Executed when user release move the mouse. If the color tip is enabled, | ||
| 103 | * then displayed color is updated as well the tooltip position. | ||
| 104 | * If is @p inDrag is true, then Quax position is updated (dragged) | ||
| 105 | * to that of mouse position. | ||
| 106 | */ | ||
| 107 | void mouseMoveEvent(QMouseEvent *e); | ||
| 108 | /** | ||
| 109 | * Get the modifier keys status and display color tooltip if Shift and Ctrl | ||
| 110 | * are both pressed down. If cursor keys are pressed, then adjust Quax | ||
| 111 | * position by one pixel or by ten pixels if Shift is down. | ||
| 112 | */ | ||
| 113 | void keyPressEvent(QKeyEvent *e); | ||
| 114 | /** | ||
| 115 | * Hide color tooltip if one of Shift and Ctrl key modifiers is released. | ||
| 116 | */ | ||
| 117 | void keyReleaseEvent(QKeyEvent *e); | ||
| 118 | /** | ||
| 119 | * Take the grabbed @p pix_zoom pixmap and scale it. Then it's painted | ||
| 120 | * on Quax following an circle region for clipping. | ||
| 121 | */ | ||
| 122 | void paintEvent(QPaintEvent *e); | ||
| 123 | /** | ||
| 124 | * Grab a screen region at every 40 miliseconds executing @ref grab(). | ||
| 125 | */ | ||
| 126 | void timerEvent(QTimerEvent *e); | ||
| 127 | /** | ||
| 128 | * If mouse wheel is dragged, then zoom scale in or out. When Ctrl key | ||
| 129 | * modifier is pressed, Quax is rotated left or right | ||
| 130 | */ | ||
| 131 | void wheelEvent(QWheelEvent *e); | ||
| 132 | |||
| 133 | private: | ||
| 134 | QString colorStringDecimal, ///< the current color under mouse as decimals comma seperated | ||
| 135 | colorStringHexaLower, ///< the current color under mouse as web RGB with lower hexadecimals | ||
| 136 | colorStringHexaUpper; ///< the current color under mouse as web RGB with upper hexadecimals | ||
| 137 | QIcon *pixelColorIcon; ///< The icon set which is used in QML content from @ref colorTip | ||
| 138 | QLabel *colorTip; ///< The tool tip for displaying current color under mouse | ||
| 139 | Q3PopupMenu *menu, ///< The main menu of Quax | ||
| 140 | *menuzoom, ///< Menu for zoom levels and zoom in and zoom out items | ||
| 141 | *menulook, ///< The "Look at" menu | ||
| 142 | *menucolor; ///< Menu for coying textual representation into clipboard | ||
| 143 | QPixmap pix, ///< Quax skin image | ||
| 144 | pix_alpha, ///< Quax alpha mask for skin image | ||
| 145 | pix_zoom, ///< The grabbed image zoomend and clipped | ||
| 146 | pix_cursor; ///< The icon used in color menu item and color tooltip | ||
| 147 | QCursor hand_cursor, ///< normal mouse cursor when mouse pointer is over Quax | ||
| 148 | cross_cursor, ///< cursor when color tooltip is displayed (cross) | ||
| 149 | copy_cursor; ///< cursor when user "take a shot" of current color | ||
| 150 | bool inDrag, ///< if true, the user is dragging the Quax | ||
| 151 | colorTipShowed, ///< if true, the color tooltip is displayed | ||
| 152 | cursorOverQuax, ///< if true, mouse cursor is over Quax surface | ||
| 153 | ctrlKeyOn; ///< if true, the Ctrl key is pressed down | ||
| 154 | QPoint dragOffset; ///< the offset between Quax position and new mouse position | ||
| 155 | QMap<int,int> zoomid, ///< mapping between zoom level and @ref menuzoom menu item ids | ||
| 156 | lookid, ///< mapping between look direction and @ref menulook menu item ids | ||
| 157 | colorid; ///< mapping between text color type and @ref menucolor menu item ids | ||
| 158 | int zoom, ///< current zoom level | ||
| 159 | look; ///< current quadrant direction where Quax "look at" | ||
| 160 | /** | ||
| 161 | * It grab desktop area, scale it, clip it with circle region, | ||
| 162 | * and then paint on Quax area. | ||
| 163 | */ | ||
| 164 | void grab(); | ||
| 165 | /** | ||
| 166 | * Show color tooltip and move the QLabel when mouse position change. Color | ||
| 167 | * is updated runnning @ref grabForPixel(). If tooltip will be displayed | ||
| 168 | * clipped by screen margins, then it will be repositioned before moving. | ||
| 169 | */ | ||
| 170 | void displayColorTip(); | ||
| 171 | /** | ||
| 172 | * Grab exactly one pixel under mouse cursor to show it in color tooltip. | ||
| 173 | */ | ||
| 174 | void grabForPixel(); | ||
| 160 | 175 | ||
| 161 | /** | ||
| 162 | * It grab desktop area, scale it, clip it with circle region, | ||
| 163 | * and then paint on Quax area. | ||
| 164 | */ | ||
| 165 | void grab(); | ||
| 166 | /** | ||
| 167 | * Show color tooltip and move the QLabel when mouse position change. Color | ||
| 168 | * is updated runnning @ref grabForPixel(). If tooltip will be displayed | ||
| 169 | * clipped by screen margins, then it will be repositioned before moving. | ||
| 170 | */ | ||
| 171 | void displayColorTip(); | ||
| 172 | /** | ||
| 173 | * Grab exactly one pixel under mouse cursor to show it in color tooltip. | ||
| 174 | */ | ||
| 175 | void grabForPixel(); | ||
| 176 | |||
| 177 | protected slots: | ||
| 178 | /** | ||
| 179 | * Display manual page or open help center according with underling desktop environment. | ||
| 180 | */ | ||
| 181 | void help(); | ||
| 182 | /** | ||
| 183 | * Open Quax "about" messagebox with author list and some other | ||
| 184 | * usefull information (copyright, version). | ||
| 185 | */ | ||
| 186 | void about(); | ||
| 187 | /** | ||
| 188 | * Open Trolltech standard "about" messagebox. | ||
| 189 | */ | ||
| 190 | void aboutQt(); | ||
| 191 | /** | ||
| 192 | * Scale up grabed desktop area if not at maximum zoom value. | ||
| 193 | */ | ||
| 194 | void zoomIn(); | ||
| 195 | /** | ||
| 196 | * Scale down grabed desktop area if not at minimum zoom value. | ||
| 197 | */ | ||
| 198 | void zoomOut(); | ||
| 199 | /** | ||
| 200 | * Zoom grabed desktop area to the @p pos level. | ||
| 201 | * @param pos represent position into zoom menu, as well the zoom level | ||
| 202 | */ | ||
| 203 | void zoomTo(int pos); | ||
| 204 | /** | ||
| 205 | * Move the Quax point of desktop area grab to the North-West direction. | ||
| 206 | * It make use of @ref Quax::rotate | ||
| 207 | */ | ||
| 208 | void rotateNorthWest(); | ||
| 209 | /** | ||
| 210 | * Move the Quax point of desktop area grab to the South-West direction. | ||
| 211 | */ | ||
| 212 | void rotateSouthWest(); | ||
| 213 | /** | ||
| 214 | * Move the Quax point of desktop area grab to the North-East direction. | ||
| 215 | */ | ||
| 216 | void rotateNorthEast(); | ||
| 217 | /** | ||
| 218 | * Move the Quax point of desktop area grab to the South-East direction. | ||
| 219 | */ | ||
| 220 | void rotateSouthEast(); | ||
| 221 | /** | ||
| 222 | * Rotate Quax point of desktop area grab to the left (counter-clockwise). | ||
| 223 | */ | ||
| 224 | void rotateLeft(); | ||
| 225 | /** | ||
| 226 | * Rotate Quax point of desktop area grab to the right (clockwise). | ||
| 227 | */ | ||
| 228 | void rotateRight(); | ||
| 229 | /** | ||
| 230 | * Rotate Quax point of desktop area to the @p pos quadrant. | ||
| 231 | * @param pos quadrant number (0..3) | ||
| 232 | */ | ||
| 233 | void rotate(int pos); | ||
| 234 | /** | ||
| 235 | * Copy the last color under mouse which was saved on @p colorStringDecimal, | ||
| 236 | * @p colorStringHexaLower and @p colorStringHexaUpper into system | ||
| 237 | * clipboard. For the menu item which handle "Ctrl+C" accelerator, it call | ||
| 238 | * @ref grabForPixel() prior to cliboard operation. | ||
| 239 | * @param id the menu identificator to get what color menu item was selected | ||
| 240 | */ | ||
| 241 | void copyColor(int id); | ||
| 242 | /** | ||
| 243 | * Build the menu left pixmap from the grabed color under mouse. This is slot is | ||
| 244 | * called from QPopupMenu::aboutToShow signal. | ||
| 245 | */ | ||
| 246 | void updateMenuColor(); | ||
| 176 | protected Q_SLOTS: | ||
| 177 | /** | ||
| 178 | * Display manual page or open help center according with underling desktop environment. | ||
| 179 | */ | ||
| 180 | void help(); | ||
| 181 | /** | ||
| 182 | * Open Quax "about" messagebox with author list and some other | ||
| 183 | * usefull information (copyright, version). | ||
| 184 | */ | ||
| 185 | void about(); | ||
| 186 | /** | ||
| 187 | * Open Trolltech standard "about" messagebox. | ||
| 188 | */ | ||
| 189 | void aboutQt(); | ||
| 190 | /** | ||
| 191 | * Scale up grabed desktop area if not at maximum zoom value. | ||
| 192 | */ | ||
| 193 | void zoomIn(); | ||
| 194 | /** | ||
| 195 | * Scale down grabed desktop area if not at minimum zoom value. | ||
| 196 | */ | ||
| 197 | void zoomOut(); | ||
| 198 | /** | ||
| 199 | * Zoom grabed desktop area to the @p pos level. | ||
| 200 | * @param pos represent position into zoom menu, as well the zoom level | ||
| 201 | */ | ||
| 202 | void zoomTo(int pos); | ||
| 203 | /** | ||
| 204 | * Move the Quax point of desktop area grab to the North-West direction. | ||
| 205 | * It make use of @ref Quax::rotate | ||
| 206 | */ | ||
| 207 | void rotateNorthWest(); | ||
| 208 | /** | ||
| 209 | * Move the Quax point of desktop area grab to the South-West direction. | ||
| 210 | */ | ||
| 211 | void rotateSouthWest(); | ||
| 212 | /** | ||
| 213 | * Move the Quax point of desktop area grab to the North-East direction. | ||
| 214 | */ | ||
| 215 | void rotateNorthEast(); | ||
| 216 | /** | ||
| 217 | * Move the Quax point of desktop area grab to the South-East direction. | ||
| 218 | */ | ||
| 219 | void rotateSouthEast(); | ||
| 220 | /** | ||
| 221 | * Rotate Quax point of desktop area grab to the left (counter-clockwise). | ||
| 222 | */ | ||
| 223 | void rotateLeft(); | ||
| 224 | /** | ||
| 225 | * Rotate Quax point of desktop area grab to the right (clockwise). | ||
| 226 | */ | ||
| 227 | void rotateRight(); | ||
| 228 | /** | ||
| 229 | * Rotate Quax point of desktop area to the @p pos quadrant. | ||
| 230 | * @param pos quadrant number (0..3) | ||
| 231 | */ | ||
| 232 | void rotate(int pos); | ||
| 233 | /** | ||
| 234 | * Copy the last color under mouse which was saved on @p colorStringDecimal, | ||
| 235 | * @p colorStringHexaLower and @p colorStringHexaUpper into system | ||
| 236 | * clipboard. For the menu item which handle "Ctrl+C" accelerator, it call | ||
| 237 | * @ref grabForPixel() prior to cliboard operation. | ||
| 238 | * @param id the menu identificator to get what color menu item was selected | ||
| 239 | */ | ||
| 240 | void copyColor(int id); | ||
| 241 | /** | ||
| 242 | * Build the menu left pixmap from the grabed color under mouse. This is slot is | ||
| 243 | * called from QPopupMenu::aboutToShow signal. | ||
| 244 | */ | ||
| 245 | void updateMenuColor(); | ||
| 247 | 246 | }; | |
| 248 | |||
| 249 | 247 | ||
| 250 | 248 | #endif |
src/quax.pro
(1 / 1)
|   | |||
| 23 | 23 | help.xpm | |
| 24 | 24 | SOURCES += main.cpp quax.cpp | |
| 25 | 25 | #The following line was inserted by qt3to4 | |
| 26 | QT += qt3support | ||
| 26 | QT += qt3support |
Comments
Add a new comment:
Login or create an account to post a comment
Add your comment
Please log in to comment

