From ebd5a36abecab400a8f18efa59f52970a3189c96 Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Fri, 3 Aug 2018 08:42:38 +0200 Subject: [PATCH 1/4] mac: Update dependencies Switch to Qt 5.11.1 and postgres 10.4. This makes all patching unnecessary since it's all been fixed upstream. Incidentally remove the need to specify SRC_DIR when building outside the source. --- extra/mac/Makefile.dependencies | 27 ++++++++++++--------- extra/mac/README.dependencies | 2 +- extra/mac/qt-5.0.1-popen-feof.patch | 11 --------- extra/mac/qt-5.4.1-right-mouse-button.patch | 11 --------- extra/mac/qt-5.5.1-tbd-libs.patch | 20 --------------- extra/mac/sctime-mac-dist | 2 +- 6 files changed, 17 insertions(+), 56 deletions(-) delete mode 100644 extra/mac/qt-5.0.1-popen-feof.patch delete mode 100644 extra/mac/qt-5.4.1-right-mouse-button.patch delete mode 100644 extra/mac/qt-5.5.1-tbd-libs.patch diff --git a/extra/mac/Makefile.dependencies b/extra/mac/Makefile.dependencies index 745ce3e..6b8b415 100644 --- a/extra/mac/Makefile.dependencies +++ b/extra/mac/Makefile.dependencies @@ -1,5 +1,5 @@ BUILD_DIR=$(shell pwd) -SRC_DIR=$(BUILD_DIR) +SRC_DIR=$(dir $(abspath $(MAKEFILE_LIST))) PATCH_DIR=$(SRC_DIR) CURL=curl @@ -8,27 +8,27 @@ CURL_OPTS=-L PREFIX=$(BUILD_DIR)/deps -SDK=macosx10.11 +SDK=macosx10.13 SDK_PATH=$(shell xcrun --sdk $(SDK) --show-sdk-path) -QT_MINOR=5.5 +QT_MINOR=5.11 QT_VER=$(QT_MINOR).1 -QT_BN=qt-everywhere-opensource-src-$(QT_VER) -QT_SOURCE_FILE=$(QT_BN).tar.gz -QT_URL=http://download.qt-project.org/official_releases/qt/$(QT_MINOR)/$(QT_VER)/single/$(QT_SOURCE_FILE) +QT_BN=qt-everywhere-src-$(QT_VER) +QT_SOURCE_FILE=$(QT_BN).tar.xz +QT_URL=http://download.qt.io/official_releases/qt/$(QT_MINOR)/$(QT_VER)/single/$(QT_SOURCE_FILE) QT_DIR=$(BUILD_DIR)/qt QT_SOURCE=$(QT_DIR)/$(QT_SOURCE_FILE) QT_SOURCE_DIR=$(QT_DIR)/$(QT_BN) -PGSQL_VER=9.5.1 +PGSQL_VER=10.4 PGSQL_BN=postgresql-$(PGSQL_VER) PGSQL_SOURCE_FILE=$(PGSQL_BN).tar.bz2 PGSQL_URL=http://ftp.postgresql.org/pub/source/v$(PGSQL_VER)/$(PGSQL_SOURCE_FILE) PGSQL_DIR=$(BUILD_DIR)/postgres PGSQL_SOURCE=$(PGSQL_DIR)/$(PGSQL_SOURCE_FILE) PGSQL_SOURCE_DIR=$(PGSQL_DIR)/$(PGSQL_BN) -PGSQL_COMMON_CFLAGS=-isysroot $(SDK_PATH) -mmacosx-version-min=10.11 -PGSQL_COMMON_LDFLAGS=-Wl,-syslibroot,$(SDK_PATH) -mmacosx-version-min=10.11 +PGSQL_COMMON_CFLAGS=-isysroot $(SDK_PATH) -mmacosx-version-min=10.13 +PGSQL_COMMON_LDFLAGS=-Wl,-syslibroot,$(SDK_PATH) -mmacosx-version-min=10.13 PGSQL_CONFIGURE_FLAGS=--without-openssl --without-perl --without-python --without-tcl --without-bonjour --without-pam --with-gssapi --without-libxml .PHONY: all clean mrproper clean.destdir \ @@ -62,10 +62,13 @@ $(QT_DIR)/configured: $(QT_DIR)/patched $(PGSQL_DIR)/installed ./configure -release \ -opensource -confirm-license \ -sdk "$(SDK)" \ - -qt-sql-psql \ + -sql-psql \ -prefix "$(PREFIX)" \ -verbose \ - -skip qtwebkit \ + -skip qtwebengine \ + -skip qt3d \ + -skip qtlocation \ + -skip qtvirtualkeyboard \ -nomake examples \ -nomake tests \ -I"$(PREFIX)"/include \ @@ -75,7 +78,7 @@ $(QT_DIR)/configured: $(QT_DIR)/patched $(PGSQL_DIR)/installed $(QT_DIR)/patched: $(QT_DIR)/unpacked cd "$(QT_SOURCE_DIR)" && \ for i in "$(PATCH_DIR)"/qt-*.patch ; do \ - [ "$$i" != "$(PATCH_DIR)"/qt-"*".patch ] && \ + [ "$$i" = "$(PATCH_DIR)"/qt-"*".patch ] || \ patch -p0 < "$$i" ; \ done && \ touch "$@" diff --git a/extra/mac/README.dependencies b/extra/mac/README.dependencies index 31284df..18e4b9b 100644 --- a/extra/mac/README.dependencies +++ b/extra/mac/README.dependencies @@ -13,7 +13,7 @@ Content: Create a build directory for the dependencies, go there and run: -make -f /extra/mac/Makefile.dependencies SRC_DIR=/extra/mac/ +make -f /extra/mac/Makefile.dependencies You can also build directly inside the sctime source tree by changing into extra/mac and running: diff --git a/extra/mac/qt-5.0.1-popen-feof.patch b/extra/mac/qt-5.0.1-popen-feof.patch deleted file mode 100644 index fcb906e..0000000 --- a/extra/mac/qt-5.0.1-popen-feof.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ./qtbase/src/corelib/io/qfsfileengine_unix.cpp.feof 2013-01-29 20:03:02.000000000 +0100 -+++ ./qtbase/src/corelib/io/qfsfileengine_unix.cpp 2013-03-06 15:31:09.000000000 +0100 -@@ -292,7 +292,7 @@ - int readByte = 0; - do { - readByte = fgetc(fh); -- } while (readByte == -1 && errno == EINTR); -+ } while (readByte == EOF && !feof(fh) && errno == EINTR); - if (readByte != -1) { - *data = uchar(readByte); - readBytes += 1; diff --git a/extra/mac/qt-5.4.1-right-mouse-button.patch b/extra/mac/qt-5.4.1-right-mouse-button.patch deleted file mode 100644 index 0c58b7f..0000000 --- a/extra/mac/qt-5.4.1-right-mouse-button.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ./qtbase/src/gui/kernel/qguiapplication.cpp.orig 2015-05-26 14:11:49.000000000 +0200 -+++ ./qtbase/src/gui/kernel/qguiapplication.cpp 2015-05-26 16:34:34.000000000 +0200 -@@ -1679,7 +1679,7 @@ - { - QEvent::Type type; - Qt::MouseButtons stateChange = e->buttons ^ buttons; -- if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) { -+ if (0 && e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) { - // A mouse event should not change both position and buttons at the same time. Instead we - // should first send a move event followed by a button changed event. Since this is not the case - // with the current event, we fake a move-only event that we recurse and process first. This diff --git a/extra/mac/qt-5.5.1-tbd-libs.patch b/extra/mac/qt-5.5.1-tbd-libs.patch deleted file mode 100644 index d3ba4ee..0000000 --- a/extra/mac/qt-5.5.1-tbd-libs.patch +++ /dev/null @@ -1,20 +0,0 @@ -https://trac.macports.org/attachment/ticket/49074/patch-chromium_tbd_libraries.diff - ---- qtwebengine/src/3rdparty/chromium/tools/gyp/pylib/gyp/xcode_emulation.py.orig 2015-10-18 21:54:12.000000000 +0200 -+++ qtwebengine/src/3rdparty/chromium/tools/gyp/pylib/gyp/xcode_emulation.py 2015-10-18 21:55:54.000000000 +0200 -@@ -984,7 +984,14 @@ - sdk_root = self._SdkPath(config_name) - if not sdk_root: - sdk_root = '' -- return l.replace('$(SDKROOT)', sdk_root) -+ library = l.replace('$(SDKROOT)', sdk_root) -+ if l.startswith('$(SDKROOT)'): -+ basename, ext = os.path.splitext(library) -+ if ext == '.dylib' and not os.path.exists(library): -+ tbd_library = basename + '.tbd' -+ if os.path.exists(tbd_library): -+ library = tbd_library -+ return library - - def AdjustLibraries(self, libraries, config_name=None): - """Transforms entries like 'Cocoa.framework' in libraries into entries like diff --git a/extra/mac/sctime-mac-dist b/extra/mac/sctime-mac-dist index 71ad06a..1da7664 100755 --- a/extra/mac/sctime-mac-dist +++ b/extra/mac/sctime-mac-dist @@ -13,7 +13,7 @@ patchqtdir="Resources/Qt" echo "Copying qt plugins into application bundle..." rm -rf "$appqtdir"/plugins && \ mkdir -p "$appqtdir"/plugins && \ - cp -R "$qtdir"/plugins/platforms "$appqtdir"/plugins && \ + cp -R "$qtdir"/plugins/{platforms,sqldrivers,styles} "$appqtdir"/plugins && \ rm -f "$appqtdir"/plugins/*/*_debug.dylib || \ exit 1 From 0d365f909de48765f9d685f268d7ac192843423e Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Fri, 3 Aug 2018 12:00:27 +0200 Subject: [PATCH 2/4] mac: Drop settings menu visibility workaround With current Qt it does not seem to be necessary any more to hide menus and menu items which have been merged into the system menu. Indeed it's even harmful in that it disables the merged menu item in question so it can't be used. --- src/timemainwindow.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/timemainwindow.cpp b/src/timemainwindow.cpp index 020fe66..f4594ef 100644 --- a/src/timemainwindow.cpp +++ b/src/timemainwindow.cpp @@ -213,11 +213,6 @@ TimeMainWindow::TimeMainWindow():QMainWindow(), startTime(QDateTime::currentDate QAction* preferenceAction = new QAction(tr("&Settings..."),this); preferenceAction->setMenuRole(QAction::PreferencesRole); connect(preferenceAction, SIGNAL(triggered()), this, SLOT(callPreferenceDialog())); -#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000 - /* ugly workaround: Qt 5.0 does not automatically hide the menu emptied by - * merging the actions into the system menu */ - settingsmenu->menuAction()->setVisible(false); -#endif QAction* helpAction = new QAction(tr("&Manual..."), this); helpAction->setShortcut(Qt::Key_F1); From c7004961fec1e6b6d5d14c3d9b86838e95d5f45d Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Fri, 3 Aug 2018 14:54:39 +0200 Subject: [PATCH 3/4] mac: Fix Qt 5.11.1 native QFontDialog --- extra/mac/qt-5.11.1-fontmanager.patch | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 extra/mac/qt-5.11.1-fontmanager.patch diff --git a/extra/mac/qt-5.11.1-fontmanager.patch b/extra/mac/qt-5.11.1-fontmanager.patch new file mode 100644 index 0000000..e0220aa --- /dev/null +++ b/extra/mac/qt-5.11.1-fontmanager.patch @@ -0,0 +1,35 @@ +Revert +https://github.com/qt/qtbase/commit/c7eb2c173e79f2936985cd7589347e59b6005c7c +because it breaks the dialog: The font never updates and always returns the +initial font. + +--- qtbase/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm.orig 2018-06-15 09:29:31.000000000 +0200 ++++ qtbase/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm 2018-08-03 14:49:38.000000000 +0200 +@@ -73,6 +74,8 @@ + return newFont; + } + ++@class QT_MANGLE_NAMESPACE(QNSFontPanelDelegate); ++ + @interface QT_MANGLE_NAMESPACE(QNSFontPanelDelegate) : NSObject + { + @public +@@ -109,8 +112,8 @@ + [mFontPanel setRestorable:NO]; + [mFontPanel setDelegate:self]; + +- [NSFontManager sharedFontManager].target = self; // Action is changeFont: ++ [[NSFontManager sharedFontManager] setDelegate:self]; + + [mFontPanel retain]; + return self; + } +@@ -119,7 +123,7 @@ + { + [mStolenContentView release]; + [mFontPanel setDelegate:nil]; +- [NSFontManager sharedFontManager].target = nil; ++ [[NSFontManager sharedFontManager] setDelegate:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [super dealloc]; From dd1e384d955d37da81bb902304d784e312e1532b Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Fri, 3 Aug 2018 18:55:25 +0200 Subject: [PATCH 4/4] mac: Fix right mouse button for good (hopefully) The mac port exposed early on that using the context menu logic to intercept right button presses is horribly broken. We used to patch Qt to work around this but that never fully solved the problem. Additional debugging now shows that signal customContextMenuRequested() fires on the mouse button press already and does not wait for the release. This causes the event handling and mouse button state tracking inside Qt to become corrupted. This in turn causes "ghost" button presses to happen once the account dialog is closed again and actual button presses to be ignored. It is unclear why this only happens on the Mac. From looking at the Qt code this should also affect other OSes. This change switches to actual tracking of right mouse button presses and matching releases and emitting a custom itemRightClicked() signal. Looking at the Qt code also assures us that itemClicked() only fires on left button clicks and makes sure that the item delivered to the slot is valid. This allows us to get rid of some other cruft such as getCurrentButton(). --- src/kontotreeview.cpp | 35 ++++++++++++++++++++++------------- src/kontotreeview.h | 9 ++++++--- src/timemainwindow.cpp | 30 ++++++++---------------------- src/timemainwindow.h | 2 -- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/kontotreeview.cpp b/src/kontotreeview.cpp index a302f07..1cbfbaf 100644 --- a/src/kontotreeview.cpp +++ b/src/kontotreeview.cpp @@ -68,8 +68,9 @@ KontoTreeView::KontoTreeView(QWidget *parent, AbteilungsListe* abtlist, const st setDropIndicatorShown( true ); setSortingEnabled( true ); sortItems(0,Qt::AscendingOrder); - setContextMenuPolicy(Qt::CustomContextMenu); + // make sure we see all right mouse button events + setContextMenuPolicy(Qt::PreventContextMenu); #ifndef Q_OS_MAC setSelectionMode(QTreeWidget::NoSelection); @@ -101,19 +102,32 @@ void KontoTreeView::keyPressEvent(QKeyEvent *event) void KontoTreeView::mousePressEvent(QMouseEvent * event) { - //Only to detect in timemainwindow.cpp which mousebutton was clicked. - currentButton = event->button(); + QPoint pos = event->pos(); - //Do only Drag n Drop if a time column is selected - if( currentButton == Qt::LeftButton )//&& currentColumn() == 3 || currentColumn() == 4) - { - dragStartPosition = event->pos(); - } + if (event->button() == Qt::LeftButton) + dragStartPosition = pos; + + // signal itemClicked() of QTreeWidget only fires on left button clicks + // (based on QAbstractItemView's clicked() signal). Track right clicks as + // well to implement our own itemRightClicked() signal + if (event->button() == Qt::RightButton) + rightPressedIndex = indexAt(pos); //Put event to the parentwidget QTreeWidget::mousePressEvent(event); } +void KontoTreeView::mouseReleaseEvent(QMouseEvent *event) { + QTreeWidget::mouseReleaseEvent(event); + + // emit itemRightClicked if we saw a right button press matching this release + QModelIndex index = indexAt(event->pos()); + if (event->button() == Qt::RightButton && + index == rightPressedIndex && + index.isValid()) + emit itemRightClicked(itemFromIndex(index)); +} + void KontoTreeView::mouseMoveEvent(QMouseEvent * event ) { if (!(event->buttons() & Qt::LeftButton)) @@ -1041,8 +1055,3 @@ void KontoTreeView::refreshAllItemsInDepartment(const QString& department) refreshAllItemsInKonto(department, subAccountPos->first); } } - -Qt::MouseButton KontoTreeView::getCurrentButton() -{ - return currentButton; -} diff --git a/src/kontotreeview.h b/src/kontotreeview.h index a5efbc4..27948ee 100644 --- a/src/kontotreeview.h +++ b/src/kontotreeview.h @@ -81,19 +81,22 @@ class KontoTreeView: public QTreeWidget int getItemDepth( QTreeWidgetItem* ); - Qt::MouseButton getCurrentButton(); - void updateColumnWidth(); + public slots: virtual void refreshItem(const QString& abt, const QString& ko,const QString& uko, int idx); void refreshAllItemsInUnterkonto(const QString& abt, const QString& ko,const QString& uko); void refreshAllItemsInKonto(const QString& abt, const QString& ko); void refreshAllItemsInDepartment(const QString&); + signals: + void itemRightClicked(QTreeWidgetItem *item); + protected: virtual bool eventFilter ( QObject* obj, QEvent * e ); virtual void mouseMoveEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dropEvent(QDropEvent *event); virtual void dragMoveEvent(QDragMoveEvent *event); @@ -106,8 +109,8 @@ class KontoTreeView: public QTreeWidget bool m_showPersoenlicheKontenSummenzeit; AbteilungsListe* abtList; QPoint dragStartPosition; - Qt::MouseButton currentButton; Qt::KeyboardModifiers keyboardModifier; + QPersistentModelIndex rightPressedIndex; }; #endif diff --git a/src/timemainwindow.cpp b/src/timemainwindow.cpp index f4594ef..df1b0fc 100644 --- a/src/timemainwindow.cpp +++ b/src/timemainwindow.cpp @@ -304,7 +304,6 @@ TimeMainWindow::TimeMainWindow():QMainWindow(), startTime(QDateTime::currentDate connect(this,SIGNAL(unterkontoSelected(bool)), bereitschaftsAction, SLOT(setEnabled(bool))); connect(this,SIGNAL(aktivierbarerEintragSelected(bool)), eintragActivateAction, SLOT(setEnabled(bool))); - connect(kontoTree,SIGNAL(customContextMenuRequested(const QPoint & )), this, SLOT(showContextMenu( const QPoint & ))); toolBar->addAction(editUnterKontoAction); toolBar->addAction(saveAction); @@ -432,20 +431,23 @@ void TimeMainWindow::showAdditionalButtons(bool show) void TimeMainWindow::configClickMode(bool singleClickActivation) { - disconnect(kontoTree, SIGNAL(itemClicked ( QTreeWidgetItem * , int )), - this, SLOT(mouseButtonInKontoTreeClicked(QTreeWidgetItem * , int ))); disconnect(kontoTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int )), this, SLOT(callUnterKontoDialog(QTreeWidgetItem *)) ); + disconnect(kontoTree, SIGNAL(itemRightClicked(QTreeWidgetItem *)), + this, SLOT(callUnterKontoDialog(QTreeWidgetItem *))); + disconnect(kontoTree, SIGNAL(itemClicked(QTreeWidgetItem *, int )), + this, SLOT(setAktivesProjekt(QTreeWidgetItem *))); disconnect(kontoTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int )), this, SLOT(setAktivesProjekt(QTreeWidgetItem *))); if (!singleClickActivation) { connect(kontoTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int )), this, SLOT(setAktivesProjekt(QTreeWidgetItem *))); - } - else { + connect(kontoTree, SIGNAL(itemRightClicked(QTreeWidgetItem *)), + this, SLOT(callUnterKontoDialog(QTreeWidgetItem *)) ); + } else { connect(kontoTree, SIGNAL(itemClicked ( QTreeWidgetItem * , int )), - this, SLOT(mouseButtonInKontoTreeClicked(QTreeWidgetItem * , int ))); + this, SLOT(setAktivesProjekt(QTreeWidgetItem *))); connect(kontoTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int )), this, SLOT(callUnterKontoDialog(QTreeWidgetItem *)) ); } @@ -499,14 +501,6 @@ void TimeMainWindow::copyNameToClipboard() cb->setText( kontoTree->currentItem()->text(KontoTreeItem::COL_ACCOUNTS), QClipboard::Clipboard ); } -void TimeMainWindow::mouseButtonInKontoTreeClicked(QTreeWidgetItem * item, int) -{ - if ( (kontoTree->getCurrentButton() == Qt::LeftButton) &&(item)) { - - setAktivesProjekt(item); - } -} - void TimeMainWindow::driftKorrektur() { int drift = startTime.secsTo(lastMinuteTick) - sekunden; if (abs(drift) < 60) return; @@ -1118,14 +1112,6 @@ void TimeMainWindow::flagsChanged(const QString& abt, const QString& ko, const Q updateCaption(); } -void TimeMainWindow::showContextMenu(const QPoint& pos) -{ - if (!settings->singleClickActivation()) - { - callUnterKontoDialog(kontoTree->itemAt(pos)); - } -} - void TimeMainWindow::resizeToIfSensible(QDialog* dialog, const QPoint& pos, const QSize& size) { if (size.isNull()) diff --git a/src/timemainwindow.h b/src/timemainwindow.h index 9584362..f87a1fa 100644 --- a/src/timemainwindow.h +++ b/src/timemainwindow.h @@ -100,10 +100,8 @@ class TimeMainWindow: public QMainWindow void refreshKontoListe(); void configClickMode(bool singleClickActivation); - void mouseButtonInKontoTreeClicked(QTreeWidgetItem * item, int column ); void copyNameToClipboard(); void copyEntryAsText(); - void showContextMenu(const QPoint& pos); void showArbeitszeitwarning(); void checkComment(const QString& abt, const QString& ko , const QString& uko,int idx); void commitKontenliste(DSResult data);