Commit b5f12a39 authored by Urs Wolfer's avatar Urs Wolfer

* deprecated--

* cleanup (code and cmake files)
* add missing copyright notice in main.cpp to the original author

svn path=/trunk/KDE/kdegraphics/kruler/; revision=567041
parent 639eca38
project(kruler)
add_subdirectory( pics )
add_subdirectory( pics )
########### next target ###############
set(kruler_SRCS klineal.cpp main.cpp )
set(kruler_SRCS klineal.cpp main.cpp)
kde4_automoc(${kruler_SRCS})
kde4_add_executable(kruler ${kruler_SRCS})
target_link_libraries(kruler ${KDE4_KDEUI_LIBS} )
target_link_libraries(kruler ${KDE4_KDEUI_LIBS})
install(TARGETS kruler DESTINATION ${BIN_INSTALL_DIR} )
install(TARGETS kruler DESTINATION ${BIN_INSTALL_DIR})
########### install files ###############
......@@ -23,39 +20,3 @@ install(TARGETS kruler DESTINATION ${BIN_INSTALL_DIR} )
install( FILES kruler.desktop DESTINATION ${XDG_APPS_DIR} )
install( FILES eventsrc DESTINATION ${DATA_INSTALL_DIR}/kruler )
install( FILES move.wav DESTINATION ${DATA_INSTALL_DIR}/kruler/sounds )
#install-data-local: uninstall.desktop
# $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Graphics
# $(INSTALL_DATA) $(srcdir)/uninstall.desktop $(DESTDIR)$(kde_appsdir)/Graphics/kruler.desktop
#
#original Makefile.am contents follow:
#SUBDIRS = pics
#
#INCLUDES= $(all_includes)
#
#bin_PROGRAMS = kruler
#kruler_METASOURCES = AUTO
#kruler_LDFLAGS = $(all_libraries) $(KDE_RPATH)
#kruler_LDADD = $(LIB_KDEUI)
#kruler_SOURCES = klineal.cpp main.cpp
#
#xdg_apps_DATA = kruler.desktop
#
#install-data-local: uninstall.desktop
# $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Graphics
# $(INSTALL_DATA) $(srcdir)/uninstall.desktop $(DESTDIR)$(kde_appsdir)/Graphics/kruler.desktop
#
#appdir = $(kde_datadir)/kruler
#app_DATA = eventsrc
#
#sounddir = $(kde_datadir)/kruler/sounds
#sound_DATA = move.wav
#
#messages:
# $(XGETTEXT) $(kruler_SOURCES) -o $(podir)/kruler.pot
#
......@@ -15,39 +15,25 @@
* *
***************************************************************************/
#include <iostream>
#include <QBitmap>
#include <QPainter>
#include <QMouseEvent>
#include <QLabel>
#include <kconfig.h>
#include <kcursor.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <kiconloader.h>
#include <khelpmenu.h>
#include <kimageeffect.h>
#include <klocale.h>
#include <kmainwindow.h>
#include <knotification.h>
#include <kmenu.h>
#include <kstandarddirs.h>
#include <kwin.h>
#include <kstdguiitem.h>
#include <qbitmap.h>
#include <qcursor.h>
#include <qdialog.h>
#include <qicon.h>
#include <qimage.h>
#include <qpainter.h>
#include <qpixmap.h>
//Added by qt3to4:
#include <QPaintEvent>
#include <QKeyEvent>
#include <QEvent>
#include <QLabel>
#include <QMouseEvent>
#include <ktoolinvocation.h>
#include <kfontdialog.h>
#include <kmenu.h>
#include <kapplication.h>
#include "klineal.h"
......@@ -57,6 +43,7 @@
#define CFG_GROUP_SETTINGS "StoredSettings"
#define DEFAULT_RULER_COLOR QColor(255, 200, 80)
#define FULLSCREENID 23
/**
* this is our cursor bitmap:
* a line 48 pixels long with an arrow pointing down
......@@ -78,12 +65,10 @@ static const uchar cursorBits[] = {
KLineal::KLineal(QWidget*parent):QWidget(parent){
mLenMenu=0;
KWin::setType(winId(), NET::Override); // or NET::Normal
KWin::setState(winId(), NET::StaysOnTop);
KWin::setState(winId(), NET::KeepAbove);
this->setWhatsThis(
i18n(
"This is a tool to measure pixel distances and colors on the screen. "
"It is useful for working on layouts of dialogs, web pages etc."
));
i18n("This is a tool to measure pixel distances and colors on the screen. "
"It is useful for working on layouts of dialogs, web pages etc."));
QBitmap bim = QBitmap::fromData(QSize(8, 48), cursorBits, QImage::Format_Mono);
QMatrix m;
m.rotate(90.0);
......@@ -108,7 +93,7 @@ KLineal::KLineal(QWidget*parent):QWidget(parent){
mScaleFont = cfg->readEntry(CFG_KEY_SCALE_FONT, defaultFont);
mLongEdgeLen = cfg->readEntry(CFG_KEY_LENGTH, 600);
} else {
mColor = defaultColor;
mColor = defaultColor;
mScaleFont = defaultFont;
mLongEdgeLen = 400;
}
......@@ -120,11 +105,8 @@ KLineal::KLineal(QWidget*parent):QWidget(parent){
QFont labelFont(KGlobalSettings::generalFont().family(), 10);
labelFont.setPixelSize(10);
mLabel->setFont(labelFont);
mLabel->setWhatsThis(
i18n(
"This is the current distance measured in pixels."
));
mColorLabel = new QLabel(this);
mLabel->setWhatsThis(i18n("This is the current distance measured in pixels."));
mColorLabel = new QLabel(this);
mColorLabel->setAutoFillBackground(true);
mColorLabel->resize(45,12);
mColorLabel->hide();
......@@ -132,12 +114,10 @@ KLineal::KLineal(QWidget*parent):QWidget(parent){
colorFont.setPixelSize(10);
mColorLabel->setFont(colorFont);
mColorLabel->move(mLabel->pos() + QPoint(0, 20));
mColorLabel->setWhatsThis(
i18n(
"This is the current color in hexadecimal rgb representation as you may use it in HTML or as a QColor name. "
"The rectangles background shows the color of the pixel inside the "
"little square at the end of the line cursor."
));
mColorLabel->setWhatsThis(i18n(
"This is the current color in hexadecimal rgb representation as you may use it in HTML or as a QColor name. "
"The rectangles background shows the color of the pixel inside the "
"little square at the end of the line cursor."));
resize(QSize(mLongEdgeLen, mShortEdgeLen));
setMouseTracking(TRUE);
......@@ -167,8 +147,7 @@ KLineal::KLineal(QWidget*parent):QWidget(parent){
mMenu->addAction(SmallIcon("colorscm"), i18n("&Choose Color..."), this, SLOT(choseColor()), Qt::CTRL+Qt::Key_C);
mMenu->addAction(SmallIcon("font"), i18n("Choose &Font..."), this, SLOT(choseFont()), Qt::Key_F);
mMenu->addSeparator();
mMenu->addMenu((new KHelpMenu(this, KGlobal::instance()->aboutData(),
true))->menu());
mMenu->addMenu((new KHelpMenu(this, KGlobal::instance()->aboutData(), true))->menu());
mMenu->addSeparator();
mMenu->addAction(SmallIcon( "exit" ), KStdGuiItem::quit().text(), kapp, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
mLastClickPos = geometry().topLeft()+QPoint(width()/2, height()/2);
......@@ -208,11 +187,10 @@ static void rotateRect(QRect &r, QPoint center, int nineties) {
r.translate(-center.x(), -center.y());
r.getCoords(&x1, &y1, &x2, &y2);
r.setCoords(
x1 * costab[i] + y1 * sintab[i],
-x1 * sintab[i] + y1 * costab[i],
x2 * costab[i] + y2 * sintab[i],
-x2 * sintab[i] + y2 * costab[i]
);
x1 * costab[i] + y1 * sintab[i],
-x1 * sintab[i] + y1 * costab[i],
x2 * costab[i] + y2 * sintab[i],
-x2 * sintab[i] + y2 * costab[i]);
r = r.normalized();
r.translate(center.x(), center.y());
}
......@@ -259,7 +237,7 @@ void KLineal::setOrientation(int inOrientation) {
} else {
center = r.topLeft()+QPoint(width()/2, height()/2);
}
rotateRect(r, center, nineties);
QRect desktop = KGlobalSettings::desktopGeometry(this);
......@@ -429,9 +407,9 @@ void KLineal::saveSettings() {
if (cfg) {
QColor color = mColor;
cfg->setGroup(CFG_GROUP_SETTINGS);
cfg->writeEntry(QString(CFG_KEY_BGCOLOR), color);
cfg->writeEntry(QString(CFG_KEY_SCALE_FONT), mScaleFont);
cfg->writeEntry(QString(CFG_KEY_LENGTH), mLongEdgeLen);
cfg->writeEntry(QString(CFG_KEY_BGCOLOR), color);
cfg->writeEntry(QString(CFG_KEY_SCALE_FONT), mScaleFont);
cfg->writeEntry(QString(CFG_KEY_LENGTH), mLongEdgeLen);
cfg->sync();
}
}
......@@ -446,8 +424,8 @@ void KLineal::restoreColor() {
* lets the context menu appear at current cursor position
*/
void KLineal::showMenu() {
QPoint pos = QCursor::pos();
mMenu->popup(pos);
QPoint pos = QCursor::pos();
mMenu->popup(pos);
}
/**
......@@ -502,29 +480,29 @@ void KLineal::adjustLabel() {
mLabel->setText(s);
}
void KLineal::keyPressEvent(QKeyEvent *e) {
QPoint dist(0,0);
switch (e->key()) {
case Qt::Key_F1:
KToolInvocation::invokeHelp();
break;
case Qt::Key_Left:
dist.setX(-1);
break;
case Qt::Key_Right:
dist.setX(1);
break;
case Qt::Key_Up:
dist.setY(-1);
break;
case Qt::Key_Down:
dist.setY(1);
break;
default:
QWidget::keyPressEvent(e);
return;
}
if (e->modifiers() & Qt::ShiftModifier) {
dist *= 10;
QPoint dist(0,0);
switch (e->key()) {
case Qt::Key_F1:
KToolInvocation::invokeHelp();
break;
case Qt::Key_Left:
dist.setX(-1);
break;
case Qt::Key_Right:
dist.setX(1);
break;
case Qt::Key_Up:
dist.setY(-1);
break;
case Qt::Key_Down:
dist.setY(1);
break;
default:
QWidget::keyPressEvent(e);
return;
}
if (e->modifiers() & Qt::ShiftModifier) {
dist *= 10;
}
move(pos()+dist);
KNotification::event(0, "cursormove", QString());
......@@ -537,20 +515,20 @@ void KLineal::mouseMoveEvent(QMouseEvent * /*inEvent*/) {
if (mDragging && this == mouseGrabber()) {
move(QCursor::pos() - mDragOffset);
} else {
QPoint p = QCursor::pos();
switch (mOrientation) {
QPoint p = QCursor::pos();
switch (mOrientation) {
case North:
p.setY(p.y()-46);
break;
p.setY(p.y()-46);
break;
case East:
p.setX(p.x()+46);
break;
p.setX(p.x()+46);
break;
case West:
p.setX(p.x()-46);
break;
p.setX(p.x()-46);
break;
case South:
p.setY(p.y()+46);
break;
p.setY(p.y()+46);
break;
}
// cerr << p.x()-x() << "," << p.y()-y() << ": " << KColorDialog::grabColor(p).name() << endl;
QColor color = KColorDialog::grabColor(p);
......@@ -559,11 +537,11 @@ void KLineal::mouseMoveEvent(QMouseEvent * /*inEvent*/) {
mColorLabel->setText(color.name().toUpper());
QPalette palette = mColorLabel->palette();
palette.setColor(mColorLabel->backgroundRole(), color);
if (v < 255/2) {
v = 255;
} else {
v = 0;
}
if (v < 255/2) {
v = 255;
} else {
v = 0;
}
color.setHsv(h, s, v);
palette.setColor(mColorLabel->foregroundRole(), color);
mColorLabel->setPalette(palette);
......@@ -586,7 +564,7 @@ void KLineal::mousePressEvent(QMouseEvent *inEvent) {
mDragging = TRUE;
}
} else if (inEvent->button() == Qt::MidButton) {
_clicked = true;
_clicked = true;
turnLeft();
} else if (inEvent->button() == Qt::RightButton) {
showMenu();
......@@ -665,55 +643,55 @@ void KLineal::drawScale(QPainter &painter) {
painter.setFont(font);
len = 18;
} else {
len = 15;
len = 15;
}
QString units;
QString units;
int digits;
if (hundred == 100 || mOrientation == West || mOrientation == East) {
digits = longCoo;
} else {
digits = longCoo % 100;
}
units.sprintf("%d", digits);
QSize textSize = metrics.size(Qt::TextSingleLine, units);
units.sprintf("%d", digits);
QSize textSize = metrics.size(Qt::TextSingleLine, units);
int tw = textSize.width();
int th = textSize.height();
switch (mOrientation) {
case North:
switch (mOrientation) {
case North:
if (digits < 1000 || fourty == 40 || hundred == 100) {
if (longCoo != 0) {
painter.drawText(longCoo - tw/2, shortStart + len + th, units);
painter.drawText(longCoo - tw/2, shortStart + len + th, units);
} else {
painter.drawText(1, shortStart + len + th, units);
painter.drawText(1, shortStart + len + th, units);
}
}
break;
case South:
break;
case South:
if (digits < 1000 || fourty == 40 || hundred == 100) {
if (longCoo != 0) {
painter.drawText(longCoo - tw/2, shortStart - len - 2, units);
painter.drawText(longCoo - tw/2, shortStart - len - 2, units);
} else {
painter.drawText(1, shortStart - len - 2, units);
painter.drawText(1, shortStart - len - 2, units);
}
}
break;
case East:
break;
case East:
if (longCoo != 0) {
painter.drawText(shortStart - len - tw - 2, longCoo + th/2 - 2, units);
painter.drawText(shortStart - len - tw - 2, longCoo + th/2 - 2, units);
} else {
painter.drawText(shortStart - len - tw - 2, th-2, units);
painter.drawText(shortStart - len - tw - 2, th-2, units);
}
break;
case West:
break;
case West:
if (longCoo != 0) {
painter.drawText(shortStart + len + 2, longCoo + th/2 - 2, units);
painter.drawText(shortStart + len + 2, longCoo + th/2 - 2, units);
} else {
painter.drawText(shortStart + len + 2, th-2, units);
painter.drawText(shortStart + len + 2, th-2, units);
}
break;
}
break;
}
} else {
len = 10;
len = 10;
}
}
switch(mOrientation) {
......
......@@ -18,22 +18,12 @@
#ifndef KLINEAL_H
#define KLINEAL_H
#include <kapplication.h>
#include <kmenu.h>
#include <kmainwindow.h>
#include <QWidget>
#include <kcolordialog.h>
#include <kfontdialog.h>
#include <qlabel.h>
#include <qpainter.h>
#include <qwidget.h>
#include <qcursor.h>
//Added by qt3to4:
#include <QMouseEvent>
#include <QKeyEvent>
#include <QEvent>
#include <QPaintEvent>
class QLabel;
class KMenu;
class KLineal : public QWidget {
Q_OBJECT
......@@ -49,7 +39,7 @@ public:
int x();
int y();
protected:
void keyPressEvent(QKeyEvent *e);
void keyPressEvent(QKeyEvent *e);
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
......@@ -83,7 +73,7 @@ private:
QCursor mDragCursor;
KColorDialog mColorSelector;
QFont mScaleFont;
bool _clicked;
bool _clicked;
public slots:
void setOrientation(int);
void setNorth();
......
/***************************************************************************
main.cpp - description
-------------------
copyright : (C) 2000 by Till Krech
email : till@snafu.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include "klineal.h"
static const char homePageURL[] =
"http://www.snafu.de/~till/";
static const char freeFormText[] =
"\"May the source be with you.\"";
static const char homePageURL[] = "http://www.snafu.de/~till/";
static const char freeFormText[] = "\"May the source be with you.\"";
static KCmdLineOptions options[] =
{
......@@ -24,21 +36,19 @@ static KCmdLineOptions options[] =
int main(int argc, char *argv[])
{
KAboutData aboutData( "kruler", I18N_NOOP("KDE Screen Ruler"),
VERSION,
I18N_NOOP("A screen ruler for the K Desktop Environment"),
KAboutData::License_GPL,
I18N_NOOP("A screen ruler for the K Desktop Environment"),
KAboutData::License_GPL,
"(c) 2000, Till Krech",
freeFormText,
homePageURL);
freeFormText,
homePageURL);
aboutData.addAuthor("Till Krech",I18N_NOOP("Programming"), "till@snafu.de");
aboutData.addCredit("Gunnstein Lye",I18N_NOOP("Initial port to KDE 2"), "gl@ez.no");
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
KApplication a;
KApplication a;
KLineal *ruler = new KLineal();
ruler->show();
......
########### install files ###############
install( FILES kruler-east.png kruler-north.png kruler-south.png kruler-west.png DESTINATION ${DATA_INSTALL_DIR}/kruler/pics )
kde4_install_icons( ${ICON_INSTALL_DIR} hicolor )
#original Makefile.am contents follow:
install( FILES kruler-east.png kruler-north.png kruler-south.png kruler-west.png DESTINATION ${DATA_INSTALL_DIR}/kruler/pics )
#
#pixdir = $(kde_datadir)/kruler/pics
#pix_DATA = kruler-east.png kruler-north.png kruler-south.png kruler-west.png
#
#KDE_ICON = kruler
kde4_install_icons( ${ICON_INSTALL_DIR} hicolor )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment