Skip to content

Commit

Permalink
PsiWindowHeader now supports Mac. Some code optimizations in PsiWindo…
Browse files Browse the repository at this point in the history
…wHeader
  • Loading branch information
Vitozz committed Apr 6, 2012
1 parent b256b18 commit 6a3402b
Showing 1 changed file with 39 additions and 41 deletions.
80 changes: 39 additions & 41 deletions patches/dev/psiplus-decorate-windows_fixed.diff
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@
#endif
--- git.orig/src/widgets/psiwindowheader.cpp
+++ git/src/widgets/psiwindowheader.cpp
@@ -0,0 +1,228 @@
@@ -0,0 +1,226 @@
+/*
+ * psiwindowheader.cpp
+ * Copyright (C) 2010 Khryukin Evgeny, Vitaly Tonkacheyev
Expand Down Expand Up @@ -711,6 +711,11 @@
+{
+ parent_ = p->window();
+ ui_.setupUi(this);
+#ifdef Q_WS_MAC
+ ui_.horiz->insertWidget(0, ui_.closeButton);
+ ui_.horiz->insertWidget(1, ui_.hideButton);
+ ui_.horiz->insertWidget(2, ui_.maximizeButton);
+#endif
+ ui_.hideButton->setIcon(qApp->style()->standardIcon(QStyle::SP_TitleBarMinButton));
+ ui_.maximizeButton->setIcon(qApp->style()->standardIcon(QStyle::SP_TitleBarMaxButton));
+ ui_.closeButton->setIcon(qApp->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
Expand Down Expand Up @@ -738,17 +743,35 @@
+
+void PsiWindowHeader::maximizePressed()
+{
+ const QRect desktop = qApp->desktop()->availableGeometry(-1);
+ if (!maximized) {
+ if (parent_->window()->width() != qApp->desktop()->width()
+ && parent_->window()->height() != qApp->desktop()->height()) {
+ oldSize = parent_->window()->geometry();
+ parent_->window()->setGeometry(qApp->desktop()->availableGeometry(-1));
+ parent_->window()->setGeometry(desktop);
+ maximized = true;
+ } else {
+ }
+ else if (!oldSize.isNull() && !oldSize.isEmpty()) {
+ parent_->window()->setGeometry(oldSize);
+ maximized = false;
+ }
+ else {
+ parent_->window()->resize(defaultSize);
+ maximized = false;
+ }
+ } else {
+ if (oldSize.top() < desktop.top()) {
+ oldSize.setTop(desktop.top());
+ }
+ if (oldSize.left() < desktop.left() ) {
+ oldSize.setLeft(desktop.left());
+ }
+ if (oldSize.right() > desktop.right()) {
+ oldSize.setRight(desktop.right());
+ }
+ if (oldSize.bottom() > desktop.bottom()) {
+ oldSize.setBottom(desktop.bottom());
+ }
+ parent_->window()->setGeometry(oldSize);
+ maximized = false;
+ }
Expand Down Expand Up @@ -784,72 +807,47 @@
+ const QPoint pg = e->globalPos();
+ int ypath = 0;
+ int xpath = 0;
+ if (isLeftButton && inLDRect && isResize) {
+ if (isLeftButton && inLDRect && isResize && !maximized) {
+ setCursor(QCursor(Qt::SizeFDiagCursor));
+ if (pg.y() < parent_->window()->y()) {
+ ypath = parent_->window()->y() - pg.y();
+ }
+ else {
+ ypath = -(pg.y() - parent_->window()->y());
+ }
+ if (pg.x() < parent_->window()->x()) {
+ xpath = parent_->window()->x() - pg.x();
+ }
+ else {
+ xpath = -(pg.x() - parent_->window()->x());
+ }
+ ypath = parent_->window()->y() - pg.y() ;
+ xpath = parent_->window()->x() - pg.x();
+ if ((parent_->window()->width() + xpath) < parent_->window()->minimumWidth()) {
+ xpath = -(parent_->window()->width() - parent_->window()->minimumWidth());
+ xpath = parent_->window()->minimumWidth() - parent_->window()->width();
+ }
+ if ((parent_->window()->height() + ypath) < parent_->window()->minimumHeight()) {
+ ypath = -(parent_->window()->height() - parent_->window()->minimumHeight());
+ ypath = parent_->window()->minimumHeight() - parent_->window()->height();
+ }
+ parent_->window()->setGeometry(parent_->window()->x() - xpath,
+ parent_->window()->y() - ypath,
+ parent_->window()->width() + xpath,
+ parent_->window()->height() + ypath);
+
+ }
+ else if (isLeftButton && inVRect && isResize) {
+ else if (isLeftButton && inVRect && isResize && !maximized) {
+ setCursor(QCursor(Qt::SizeVerCursor));
+ if (pg.y() < parent_->window()->y()) {
+ ypath = parent_->window()->y() - pg.y();
+ }
+ else {
+ ypath = -(pg.y() - parent_->window()->y());
+ }
+ ypath = parent_->window()->y() - pg.y();
+ if ((parent_->window()->height() + ypath) < parent_->window()->minimumHeight()) {
+ ypath = -(parent_->window()->height() - parent_->window()->minimumHeight());
+ ypath = parent_->window()->minimumHeight() - parent_->window()->height();
+ }
+ parent_->window()->setGeometry(parent_->window()->x(),
+ parent_->window()->y() - ypath,
+ parent_->window()->width(),
+ parent_->window()->height() + ypath);
+ }
+ else if (isLeftButton && inRDRect && isResize) {
+ else if (isLeftButton && inRDRect && isResize && !maximized) {
+ setCursor(QCursor(Qt::SizeBDiagCursor));
+ if (pg.y() < parent_->window()->y()) {
+ ypath = parent_->window()->y() - pg.y();
+ }
+ else {
+ ypath = -(pg.y() - parent_->window()->y());
+ }
+ if (pg.x() < parent_->window()->geometry().right()) {
+ xpath = -(parent_->window()->geometry().right() - pg.x());
+ }
+ else {
+ xpath = pg.x() - parent_->window()->geometry().right();
+ }
+ ypath = parent_->window()->y() - pg.y();
+ xpath = pg.x() - parent_->window()->geometry().right();
+ if ((parent_->window()->height() + ypath) < parent_->window()->minimumHeight()) {
+ ypath = -(parent_->window()->height() - parent_->window()->minimumHeight());
+ ypath = parent_->window()->minimumHeight() - parent_->window()->height();
+ }
+ parent_->window()->setGeometry(parent_->window()->x(),
+ parent_->window()->y() - ypath,
+ parent_->window()->width() + xpath,
+ parent_->window()->height() + ypath);
+
+ }
+ else if(isLeftButton && isDrag &&!isResize) {
+ else if(isLeftButton && isDrag &&!isResize && !maximized) {
+ setCursor(QCursor(Qt::ArrowCursor));
+ parent_->window()->move( e->globalPos() - movepath );
+ }
Expand Down

0 comments on commit 6a3402b

Please sign in to comment.