summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-11-15 14:42:19 -0600
committerTimothy Pearson <[email protected]>2012-11-15 14:42:19 -0600
commit81e56a909befa0679332c6a22ae84c86e1d057ce (patch)
tree0b0548f32f23170dd3d9346f01b05f8a2f7f161a
parent8fb269b60c0938d1ce8a3912038ad8d7ce8a79e0 (diff)
downloadtdegraphics-81e56a909befa0679332c6a22ae84c86e1d057ce.tar.gz
tdegraphics-81e56a909befa0679332c6a22ae84c86e1d057ce.zip
Fix incorrect kruler orientation on session restore
-rw-r--r--kruler/klineal.cpp65
-rw-r--r--kruler/klineal.h10
-rw-r--r--kruler/main.cpp22
3 files changed, 67 insertions, 30 deletions
diff --git a/kruler/klineal.cpp b/kruler/klineal.cpp
index efa57d07..b5e45250 100644
--- a/kruler/klineal.cpp
+++ b/kruler/klineal.cpp
@@ -241,6 +241,34 @@ void KLineal::setupBackground() {
mLabel->setErasePixmap(bgPixmap);
}
+void KLineal::setupCursor() {
+ switch(mOrientation) {
+ case North:
+ mLabel->move(4, height()-mLabel->height()-4);
+ mColorLabel->move(mLabel->pos() + TQPoint(0, -20));
+ mCurrentCursor = mNorthCursor;
+ break;
+ case South:
+ mLabel->move(4, 4);
+ mColorLabel->move(mLabel->pos() + TQPoint(0, 20));
+ mCurrentCursor = mSouthCursor;
+ break;
+ case East:
+ mLabel->move(4, 4);
+ mColorLabel->move(mLabel->pos() + TQPoint(0, 20));
+ mCurrentCursor = mEastCursor;
+ break;
+ case West:
+ mLabel->move(width()-mLabel->width()-4, 4);
+ mColorLabel->move(mLabel->pos() + TQPoint(-5, 20));
+ mCurrentCursor = mWestCursor;
+ break;
+ }
+ if (mLenMenu)
+ mLenMenu->changeItem(FULLSCREENID, mOrientation % 2 ? i18n("&Full Screen Height") : i18n("&Full Screen Width"));
+ setCursor(mCurrentCursor);
+}
+
void KLineal::setOrientation(int inOrientation) {
TQRect r = frameGeometry();
int nineties = (int)inOrientation - (int)mOrientation;
@@ -267,31 +295,7 @@ void KLineal::setOrientation(int inOrientation) {
setGeometry(r);
mOrientation = (inOrientation + 4) % 4;
- switch(mOrientation) {
- case North:
- mLabel->move(4, height()-mLabel->height()-4);
- mColorLabel->move(mLabel->pos() + TQPoint(0, -20));
- mCurrentCursor = mNorthCursor;
- break;
- case South:
- mLabel->move(4, 4);
- mColorLabel->move(mLabel->pos() + TQPoint(0, 20));
- mCurrentCursor = mSouthCursor;
- break;
- case East:
- mLabel->move(4, 4);
- mColorLabel->move(mLabel->pos() + TQPoint(0, 20));
- mCurrentCursor = mEastCursor;
- break;
- case West:
- mLabel->move(width()-mLabel->width()-4, 4);
- mColorLabel->move(mLabel->pos() + TQPoint(-5, 20));
- mCurrentCursor = mWestCursor;
- break;
- }
- if (mLenMenu)
- mLenMenu->changeItem(FULLSCREENID, mOrientation % 2 ? i18n("&Full Screen Height") : i18n("&Full Screen Width"));
- setCursor(mCurrentCursor);
+ setupCursor();
setupBackground();
repaint();
}
@@ -743,4 +747,15 @@ void KLineal::paintEvent(TQPaintEvent * /*inEvent*/) {
painter.end();
}
+void KLineal::readProperties(KConfig *cfg) {
+ mOrientation = cfg->readNumEntry("Orientation", South);
+ setupCursor();
+ setupBackground();
+ repaint();
+}
+
+void KLineal::saveProperties(KConfig* cfg) {
+ cfg->writeEntry("Orientation", mOrientation);
+}
+
#include "klineal.moc"
diff --git a/kruler/klineal.h b/kruler/klineal.h
index 407472df..31c948ae 100644
--- a/kruler/klineal.h
+++ b/kruler/klineal.h
@@ -44,8 +44,9 @@ public:
TQPoint pos();
int x();
int y();
+
protected:
- void keyPressEvent(TQKeyEvent *e);
+ void keyPressEvent(TQKeyEvent *e);
void mousePressEvent(TQMouseEvent *e);
void mouseReleaseEvent(TQMouseEvent *e);
void mouseMoveEvent(TQMouseEvent *e);
@@ -54,10 +55,14 @@ protected:
void leaveEvent(TQEvent *e);
void setupBackground();
+ // session management
+ virtual void saveProperties( KConfig *config );
+ virtual void readProperties( KConfig *config );
private:
void drawScale(TQPainter &painter);
void reLength(int percentOfScreen);
+ void setupCursor();
bool mDragging;
TQPoint mLastClickPos;
TQPoint mDragOffset;
@@ -79,7 +84,8 @@ private:
TQCursor mDragCursor;
KColorDialog mColorSelector;
TQFont mScaleFont;
- bool _clicked;
+ bool _clicked;
+
public slots:
void setOrientation(int);
void setNorth();
diff --git a/kruler/main.cpp b/kruler/main.cpp
index 764e874c..196909a6 100644
--- a/kruler/main.cpp
+++ b/kruler/main.cpp
@@ -9,6 +9,17 @@
#include "klineal.h"
+#define RESTORE_RULERS(type) { \
+ int n = 1; \
+ while (KMainWindow::canBeRestored(n)) { \
+ type* ruler = new type; \
+ ruler->restore(n); \
+ a.setMainWidget(ruler); \
+ ruler->show(); \
+ n++; \
+ } \
+}
+
static const char homePageURL[] =
"http://www.snafu.de/~till/";
static const char freeFormText[] =
@@ -40,9 +51,14 @@ int main(int argc, char *argv[])
KApplication a;
- KLineal *ruler = new KLineal();
- a.setMainWidget(ruler);
- ruler->show();
+ if (a.isRestored()) {
+ RESTORE_RULERS(KLineal)
+ }
+ else {
+ KLineal *ruler = new KLineal();
+ a.setMainWidget(ruler);
+ ruler->show();
+ }
return a.exec();
}