From e4aaacf0d4215d319ac8b3de72f3c77ab0d76c49 Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Thu, 22 Dec 2016 00:36:10 +0100 Subject: [PATCH] Cherry-picking upstream version 0.7.1 * Bumped minimum version libqtermwidget5-0-dev (>= 0.7.1) * Removed build dependencies: - cmake - liblxqt0-dev - libqt5xdg-dev - qttools5-dev - qttools5-dev-tools * Added build dependency lxqt-build-tools --- CHANGELOG | 20 ++- CMakeLists.txt | 17 +- debian/changelog | 14 ++ debian/control | 10 +- qterminal.pro | 2 +- src/config.h | 8 +- src/forms/propertiesdialog.ui | 134 +++++++++++++-- src/forms/qterminal.ui | 6 - src/mainwindow.cpp | 312 ++++++++++++++-------------------- src/mainwindow.h | 10 +- src/properties.cpp | 8 +- src/properties.h | 1 + src/propertiesdialog.cpp | 29 +++- src/propertiesdialog.h | 1 + src/tabwidget.cpp | 31 ++-- src/termwidget.cpp | 39 +++-- src/termwidget.h | 2 +- 17 files changed, 373 insertions(+), 271 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c25a6aa..6298968 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,25 @@ -qterminal-0.7.0 / 2016-09-24 +qterminal-0.7.1 / 2016-12-21 ============================ + * Bump patch version (#294) + * Add common shortcuts for switching tabs (#275) + * Fix tabstop order in properties dialog & add buddy relations for labels. (#290) + * Add preferences for background images (#273) + * Disable menu actions that are not applicable currently (#244) + * DEFINES += STR_VERSION=\\\"0.7.0\\\" + * Add context menu actions for URLs and E-Mail addresses (#276) + * Removed minimum size (#265) + * Set maxval of dropdown spinboxen to 100, instead of 99 + * Use the new lxqt-build-tools package + * Fix context menu actions being applied to the window opened last (#235) + * Show exit confirmation dialog when closing the last window tab (#242) + * remove "building with cpack" from CMakeLists.txt - not used anymore Added very basic .gitattributes + +0.7.0 / 2016-09-24 +================== + + * Release 0.7.0: Add changelog * Bump version to 0.7.0 (#262) * Update README.md * Collapse splitter hierarchies containing a single terminal (#254) diff --git a/CMakeLists.txt b/CMakeLists.txt index eed8190..496fc7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,8 @@ project(qterminal) include(GNUInstallDirs) -set(STR_VERSION "0.7.0") +set(STR_VERSION "0.7.1") +set(LXQTBT_MINIMUM_VERSION "0.3.0") # additional cmake files @@ -35,8 +36,7 @@ elseif(UNIX) find_package(Qt5X11Extras REQUIRED) endif() find_package(QTermWidget5 REQUIRED) -#Note: no run-time dependency on liblxqt, just a build dependency for lxqt_translate_ts/desktop -find_package(lxqt REQUIRED) +find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) include(LXQtTranslateTs) message(STATUS "Qt version: ${Qt5Core_VERSION_STRING}") @@ -235,14 +235,3 @@ add_custom_target(lupdate COMMAND ${QT_LUPDATE_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/qterminal.pro" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) - -# make dist custom target -set(CPACK_PACKAGE_NAME "qterminal") -set(CPACK_PACKAGE_VERSION ${STR_VERSION}) -set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2") -set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") -set(CPACK_IGNORE_FILES "/CVS/;/\\\\.svn/;/\\\\.git/;\\\\.swp$;\\\\.#;/#;\\\\.tar.gz$;/CMakeFiles/;CMakeCache.txt;\\\\.qm$;/build/;\\\\.diff$;.DS_Store'") -set(CPACK_SOURCE_IGNORE_FILES ${CPACK_IGNORE_FILES}) -include(CPack) -# simulate autotools' "make dist" -add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) diff --git a/debian/changelog b/debian/changelog index 15a3477..d69b3f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,17 @@ +qterminal (0.7.1-1) unstable; urgency=medium + + * Cherry-picking upstream version 0.7.1 + * Bumped minimum version libqtermwidget5-0-dev (>= 0.7.1) + * Removed build dependencies: + - cmake + - liblxqt0-dev + - libqt5xdg-dev + - qttools5-dev + - qttools5-dev-tools + * Added build dependency lxqt-build-tools + + -- Alf Gaida Thu, 22 Dec 2016 00:35:57 +0100 + qterminal (0.7.0-2) unstable; urgency=medium * Cherry-picking upstream release 0.7.0 diff --git a/debian/control b/debian/control index 0022c8e..5165f2b 100644 --- a/debian/control +++ b/debian/control @@ -6,17 +6,13 @@ Uploaders: Alf Gaida , Section: x11 Priority: optional Build-Depends: debhelper (>= 10), - cmake (>= 3.0.2), libkf5windowsystem-dev, - liblxqt0-dev (>= 0.11.0), - libqtermwidget5-0-dev (>= 0.7.0), + libqtermwidget5-0-dev (>= 0.7.1), libqt5svg5-dev, libqt5x11extras5-dev, - libqt5xdg-dev (>= 2.0.0), libx11-dev, - qtbase5-private-dev, - qttools5-dev, - qttools5-dev-tools + lxqt-build-tools, + qtbase5-private-dev Standards-Version: 3.9.8 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-lxqt/qterminal.git/?h=debian/sid Vcs-Git: https://anonscm.debian.org/git/pkg-lxqt/qterminal.git -b debian/sid diff --git a/qterminal.pro b/qterminal.pro index 66b120a..29cfc0d 100644 --- a/qterminal.pro +++ b/qterminal.pro @@ -8,7 +8,7 @@ CONFIG += link_pkgconfig \ PKGCONFIG += qtermwidget5 -DEFINES += STR_VERSION=\\\"0.6.0\\\" +DEFINES += STR_VERSION=\\\"0.7.0\\\" SOURCES += $$files(src/*.cpp) HEADERS += $$files(src/*.h) diff --git a/src/config.h b/src/config.h index 5f613a3..4219d3b 100644 --- a/src/config.h +++ b/src/config.h @@ -69,8 +69,8 @@ // ACTIONS #define CLEAR_TERMINAL_SHORTCUT "Ctrl+Shift+X" -#define TAB_PREV_SHORTCUT "Shift+Left" -#define TAB_NEXT_SHORTCUT "Shift+Right" +#define TAB_PREV_SHORTCUT "Shift+Left|Ctrl+PgUp|Ctrl+Shift+Tab" +#define TAB_NEXT_SHORTCUT "Shift+Right|Ctrl+PgDown|Ctrl+Tab" #define SUB_PREV_SHORTCUT "Shift+Down" #define SUB_NEXT_SHORTCUT "Shift+Up" @@ -100,8 +100,8 @@ #define ZOOM_OUT_SHORTCUT "Ctrl+-" #define ZOOM_RESET_SHORTCUT "Ctrl+0" -#define MOVE_LEFT_SHORTCUT "Shift+Alt+Left" -#define MOVE_RIGHT_SHORTCUT "Shift+Alt+Right" +#define MOVE_LEFT_SHORTCUT "Shift+Alt+Left|Ctrl+Shift+PgUp" +#define MOVE_RIGHT_SHORTCUT "Shift+Alt+Right|Ctrl+Shift+PgDown" #define RENAME_SESSION_SHORTCUT "Shift+Alt+S" diff --git a/src/forms/propertiesdialog.ui b/src/forms/propertiesdialog.ui index 9056354..ff26b76 100644 --- a/src/forms/propertiesdialog.ui +++ b/src/forms/propertiesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 715 - 495 + 746 + 634 @@ -82,7 +82,7 @@ 0 - + @@ -99,6 +99,9 @@ Color scheme + + colorSchemaCombo + @@ -106,15 +109,24 @@ Scrollbar position + + scrollBarPos_comboBox + - + Start with preset: + + terminalPresetComboBox + + + + @@ -125,14 +137,14 @@ - - - Terminal transparency + + termTransparencyBox + @@ -145,7 +157,7 @@ - + @@ -205,6 +217,9 @@ Font + + changeFontButton + @@ -243,15 +258,21 @@ + + + Tabs position + + tabsPos_comboBox + - - + + @@ -269,17 +290,17 @@ - - - Widget style + + styleComboBox + - + Qt::Vertical @@ -304,6 +325,9 @@ Keyboard cursor shape + + keybCursorShape_comboBox + @@ -320,9 +344,30 @@ + + + + Background image: + + + + + + + + + + + + Select + + + + + - + @@ -373,6 +418,9 @@ Action after paste + + motionAfterPasting_comboBox + @@ -470,6 +518,9 @@ 105 + + true + false @@ -487,7 +538,7 @@ - + @@ -512,6 +563,9 @@ Height + + dropHeightSpinBox + @@ -526,6 +580,9 @@ Width + + dropWidthSpinBox + @@ -547,6 +604,9 @@ Shortcut: + + dropShortCutEdit + @@ -569,7 +629,7 @@ - + @@ -607,6 +667,9 @@ Bookmark file + + bookmarksLineEdit + @@ -637,6 +700,43 @@ + + listWidget + changeFontButton + colorSchemaCombo + styleComboBox + scrollBarPos_comboBox + tabsPos_comboBox + keybCursorShape_comboBox + showMenuCheckBox + hideTabBarCheckBox + highlightCurrentCheckBox + changeWindowTitleCheckBox + changeWindowIconCheckBox + appTransparencyBox + termTransparencyBox + backgroundImageLineEdit + chooseBackgroundImageButton + terminalPresetComboBox + historyLimited + historyLimitedTo + historyUnlimited + motionAfterPasting_comboBox + askOnExitCheckBox + savePosOnExitCheckBox + saveSizeOnExitCheckBox + useCwdCheckBox + emulationComboBox + shortcutsWidget + dropShowOnStartCheckBox + dropHeightSpinBox + dropWidthSpinBox + dropShortCutEdit + useBookmarksCheckBox + bookmarksLineEdit + bookmarksButton + bookmarkPlainEdit + diff --git a/src/forms/qterminal.ui b/src/forms/qterminal.ui index 55761fe..c921f50 100644 --- a/src/forms/qterminal.ui +++ b/src/forms/qterminal.ui @@ -32,12 +32,6 @@ - - - 320 - 200 - - QTabWidget::South diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5326cef..c6a6617 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "mainwindow.h" #include "tabwidget.h" @@ -30,6 +31,9 @@ #include "bookmarkswidget.h" +typedef std::function checkfn; +Q_DECLARE_METATYPE(checkfn) + // TODO/FXIME: probably remove. QSS makes it unusable on mac... #define QSS_DROP "MainWindow {border: 1px solid rgba(0, 0, 0, 50%);}\n" @@ -94,6 +98,8 @@ MainWindow::MainWindow(const QString& work_dir, setupCustomDirs(); connect(consoleTabulator, &TabWidget::currentTitleChanged, this, &MainWindow::onCurrentTitleChanged); + connect(menu_Actions, SIGNAL(aboutToShow()), this, SLOT(aboutToShowActionsMenu())); + /* The tab should be added after all changes are made to the main window; otherwise, the initial prompt might get jumbled because of changes in internal geometry. */ @@ -131,140 +137,102 @@ void MainWindow::setDropShortcut(QKeySequence dropShortCut) } } -void MainWindow::setup_ActionsMenu_Actions() +void MainWindow::setup_Action(const char *name, QAction *action, const char *defaultShortcut, const QObject *receiver, + const char *slot, QMenu *menu, const QVariant &data) { QSettings settings; settings.beginGroup("Shortcuts"); - QKeySequence seq; + QList shortcuts; - Properties::Instance()->actions[CLEAR_TERMINAL] = new QAction(QIcon::fromTheme("edit-clear"), tr("&Clear Current Tab"), this); - seq = QKeySequence::fromString(settings.value(CLEAR_TERMINAL, CLEAR_TERMINAL_SHORTCUT).toString()); - Properties::Instance()->actions[CLEAR_TERMINAL]->setShortcut(seq); - connect(Properties::Instance()->actions[CLEAR_TERMINAL], SIGNAL(triggered()), consoleTabulator, SLOT(clearActiveTerminal())); - menu_Actions->addAction(Properties::Instance()->actions[CLEAR_TERMINAL]); - addAction(Properties::Instance()->actions[CLEAR_TERMINAL]); + Properties::Instance()->actions[name] = action; + foreach (const QString &sequenceString, settings.value(name, defaultShortcut).toString().split('|')) + shortcuts.append(QKeySequence::fromString(sequenceString)); + Properties::Instance()->actions[name]->setShortcuts(shortcuts); + + if (receiver) + { + connect(Properties::Instance()->actions[name], SIGNAL(triggered(bool)), receiver, slot); + addAction(Properties::Instance()->actions[name]); + } + + if (menu) + menu->addAction(Properties::Instance()->actions[name]); + + if (!data.isNull()) + Properties::Instance()->actions[name]->setData(data); +} + +void MainWindow::setup_ActionsMenu_Actions() +{ + QVariant data; + + const checkfn checkTabs = &MainWindow::hasMultipleTabs; + const checkfn checkSubterminals = &MainWindow::hasMultipleSubterminals; + + setup_Action(CLEAR_TERMINAL, new QAction(QIcon::fromTheme("edit-clear"), tr("&Clear Current Tab"), this), + CLEAR_TERMINAL_SHORTCUT, consoleTabulator, SLOT(clearActiveTerminal()), menu_Actions); menu_Actions->addSeparator(); - Properties::Instance()->actions[TAB_NEXT] = new QAction(QIcon::fromTheme("go-next"), tr("&Next Tab"), this); - seq = QKeySequence::fromString( settings.value(TAB_NEXT, TAB_NEXT_SHORTCUT).toString() ); - Properties::Instance()->actions[TAB_NEXT]->setShortcut(seq); - connect(Properties::Instance()->actions[TAB_NEXT], SIGNAL(triggered()), consoleTabulator, SLOT(switchToRight())); - menu_Actions->addAction(Properties::Instance()->actions[TAB_NEXT]); - addAction(Properties::Instance()->actions[TAB_NEXT]); + data.setValue(checkTabs); - Properties::Instance()->actions[TAB_PREV] = new QAction(QIcon::fromTheme("go-previous"), tr("&Previous Tab"), this); - seq = QKeySequence::fromString( settings.value(TAB_PREV, TAB_PREV_SHORTCUT).toString() ); - Properties::Instance()->actions[TAB_PREV]->setShortcut(seq); - connect(Properties::Instance()->actions[TAB_PREV], SIGNAL(triggered()), consoleTabulator, SLOT(switchToLeft())); - menu_Actions->addAction(Properties::Instance()->actions[TAB_PREV]); - addAction(Properties::Instance()->actions[TAB_PREV]); + setup_Action(TAB_NEXT, new QAction(QIcon::fromTheme("go-next"), tr("&Next Tab"), this), + TAB_NEXT_SHORTCUT, consoleTabulator, SLOT(switchToRight()), menu_Actions, data); - Properties::Instance()->actions[MOVE_LEFT] = new QAction(tr("Move Tab &Left"), this); - seq = QKeySequence::fromString( settings.value(MOVE_LEFT, MOVE_LEFT_SHORTCUT).toString() ); - Properties::Instance()->actions[MOVE_LEFT]->setShortcut(seq); - connect(Properties::Instance()->actions[MOVE_LEFT], SIGNAL(triggered()), consoleTabulator, SLOT(moveLeft())); - menu_Actions->addAction(Properties::Instance()->actions[MOVE_LEFT]); - addAction(Properties::Instance()->actions[MOVE_LEFT]); + setup_Action(TAB_PREV, new QAction(QIcon::fromTheme("go-previous"), tr("&Previous Tab"), this), + TAB_PREV_SHORTCUT, consoleTabulator, SLOT(switchToLeft()), menu_Actions, data); - Properties::Instance()->actions[MOVE_RIGHT] = new QAction(tr("Move Tab &Right"), this); - seq = QKeySequence::fromString( settings.value(MOVE_RIGHT, MOVE_RIGHT_SHORTCUT).toString() ); - Properties::Instance()->actions[MOVE_RIGHT]->setShortcut(seq); - connect(Properties::Instance()->actions[MOVE_RIGHT], SIGNAL(triggered()), consoleTabulator, SLOT(moveRight())); - menu_Actions->addAction(Properties::Instance()->actions[MOVE_RIGHT]); - addAction(Properties::Instance()->actions[MOVE_RIGHT]); + setup_Action(MOVE_LEFT, new QAction(tr("Move Tab &Left"), this), + MOVE_LEFT_SHORTCUT, consoleTabulator, SLOT(moveLeft()), menu_Actions, data); + + setup_Action(MOVE_RIGHT, new QAction(tr("Move Tab &Right"), this), + MOVE_RIGHT_SHORTCUT, consoleTabulator, SLOT(moveRight()), menu_Actions, data); menu_Actions->addSeparator(); - Properties::Instance()->actions[SPLIT_HORIZONTAL] = new QAction(tr("Split Terminal &Horizontally"), this); - seq = QKeySequence::fromString( settings.value(SPLIT_HORIZONTAL).toString() ); - Properties::Instance()->actions[SPLIT_HORIZONTAL]->setShortcut(seq); - connect(Properties::Instance()->actions[SPLIT_HORIZONTAL], SIGNAL(triggered()), consoleTabulator, SLOT(splitHorizontally())); - menu_Actions->addAction(Properties::Instance()->actions[SPLIT_HORIZONTAL]); - addAction(Properties::Instance()->actions[SPLIT_HORIZONTAL]); + setup_Action(SPLIT_HORIZONTAL, new QAction(tr("Split Terminal &Horizontally"), this), + NULL, consoleTabulator, SLOT(splitHorizontally()), menu_Actions); - Properties::Instance()->actions[SPLIT_VERTICAL] = new QAction(tr("Split Terminal &Vertically"), this); - seq = QKeySequence::fromString( settings.value(SPLIT_VERTICAL).toString() ); - Properties::Instance()->actions[SPLIT_VERTICAL]->setShortcut(seq); - connect(Properties::Instance()->actions[SPLIT_VERTICAL], SIGNAL(triggered()), consoleTabulator, SLOT(splitVertically())); - menu_Actions->addAction(Properties::Instance()->actions[SPLIT_VERTICAL]); - addAction(Properties::Instance()->actions[SPLIT_VERTICAL]); + setup_Action(SPLIT_VERTICAL, new QAction(tr("Split Terminal &Vertically"), this), + NULL, consoleTabulator, SLOT(splitVertically()), menu_Actions); - Properties::Instance()->actions[SUB_COLLAPSE] = new QAction(tr("&Collapse Subterminal"), this); - seq = QKeySequence::fromString( settings.value(SUB_COLLAPSE).toString() ); - Properties::Instance()->actions[SUB_COLLAPSE]->setShortcut(seq); - connect(Properties::Instance()->actions[SUB_COLLAPSE], SIGNAL(triggered()), consoleTabulator, SLOT(splitCollapse())); - menu_Actions->addAction(Properties::Instance()->actions[SUB_COLLAPSE]); - addAction(Properties::Instance()->actions[SUB_COLLAPSE]); + data.setValue(checkSubterminals); - Properties::Instance()->actions[SUB_NEXT] = new QAction(QIcon::fromTheme("go-up"), tr("N&ext Subterminal"), this); - seq = QKeySequence::fromString( settings.value(SUB_NEXT, SUB_NEXT_SHORTCUT).toString() ); - Properties::Instance()->actions[SUB_NEXT]->setShortcut(seq); - connect(Properties::Instance()->actions[SUB_NEXT], SIGNAL(triggered()), consoleTabulator, SLOT(switchNextSubterminal())); - menu_Actions->addAction(Properties::Instance()->actions[SUB_NEXT]); - addAction(Properties::Instance()->actions[SUB_NEXT]); + setup_Action(SUB_COLLAPSE, new QAction(tr("&Collapse Subterminal"), this), + NULL, consoleTabulator, SLOT(splitCollapse()), menu_Actions, data); - Properties::Instance()->actions[SUB_PREV] = new QAction(QIcon::fromTheme("go-down"), tr("P&revious Subterminal"), this); - seq = QKeySequence::fromString( settings.value(SUB_PREV, SUB_PREV_SHORTCUT).toString() ); - Properties::Instance()->actions[SUB_PREV]->setShortcut(seq); - connect(Properties::Instance()->actions[SUB_PREV], SIGNAL(triggered()), consoleTabulator, SLOT(switchPrevSubterminal())); - menu_Actions->addAction(Properties::Instance()->actions[SUB_PREV]); - addAction(Properties::Instance()->actions[SUB_PREV]); + setup_Action(SUB_NEXT, new QAction(QIcon::fromTheme("go-up"), tr("N&ext Subterminal"), this), + SUB_NEXT_SHORTCUT, consoleTabulator, SLOT(switchNextSubterminal()), menu_Actions, data); + + setup_Action(SUB_PREV, new QAction(QIcon::fromTheme("go-down"), tr("P&revious Subterminal"), this), + SUB_PREV_SHORTCUT, consoleTabulator, SLOT(switchPrevSubterminal()), menu_Actions, data); menu_Actions->addSeparator(); // Copy and Paste are only added to the table for the sake of bindings at the moment; there is no Edit menu, only a context menu. - Properties::Instance()->actions[COPY_SELECTION] = new QAction(QIcon::fromTheme("edit-copy"), tr("Copy &Selection"), this); - seq = QKeySequence::fromString( settings.value(COPY_SELECTION, COPY_SELECTION_SHORTCUT).toString() ); - Properties::Instance()->actions[COPY_SELECTION]->setShortcut(seq); - connect(Properties::Instance()->actions[COPY_SELECTION], SIGNAL(triggered()), consoleTabulator, SLOT(copySelection())); - menu_Edit->addAction(Properties::Instance()->actions[COPY_SELECTION]); - addAction(Properties::Instance()->actions[COPY_SELECTION]); + setup_Action(COPY_SELECTION, new QAction(QIcon::fromTheme("edit-copy"), tr("Copy &Selection"), this), + COPY_SELECTION_SHORTCUT, consoleTabulator, SLOT(copySelection()), menu_Edit); - Properties::Instance()->actions[PASTE_CLIPBOARD] = new QAction(QIcon::fromTheme("edit-paste"), tr("Paste Clip&board"), this); - seq = QKeySequence::fromString( settings.value(PASTE_CLIPBOARD, PASTE_CLIPBOARD_SHORTCUT).toString() ); - Properties::Instance()->actions[PASTE_CLIPBOARD]->setShortcut(seq); - connect(Properties::Instance()->actions[PASTE_CLIPBOARD], SIGNAL(triggered()), consoleTabulator, SLOT(pasteClipboard())); - menu_Edit->addAction(Properties::Instance()->actions[PASTE_CLIPBOARD]); - addAction(Properties::Instance()->actions[PASTE_CLIPBOARD]); + setup_Action(PASTE_CLIPBOARD, new QAction(QIcon::fromTheme("edit-paste"), tr("Paste Clip&board"), this), + PASTE_CLIPBOARD_SHORTCUT, consoleTabulator, SLOT(pasteClipboard()), menu_Edit); - Properties::Instance()->actions[PASTE_SELECTION] = new QAction(QIcon::fromTheme("edit-paste"), tr("Paste S&election"), this); - seq = QKeySequence::fromString( settings.value(PASTE_SELECTION, PASTE_SELECTION_SHORTCUT).toString() ); - Properties::Instance()->actions[PASTE_SELECTION]->setShortcut(seq); - connect(Properties::Instance()->actions[PASTE_SELECTION], SIGNAL(triggered()), consoleTabulator, SLOT(pasteSelection())); - menu_Edit->addAction(Properties::Instance()->actions[PASTE_SELECTION]); - addAction(Properties::Instance()->actions[PASTE_SELECTION]); + setup_Action(PASTE_SELECTION, new QAction(QIcon::fromTheme("edit-paste"), tr("Paste S&election"), this), + PASTE_SELECTION_SHORTCUT, consoleTabulator, SLOT(pasteSelection()), menu_Edit); - Properties::Instance()->actions[ZOOM_IN] = new QAction(QIcon::fromTheme("zoom-in"), tr("Zoom &in"), this); - seq = QKeySequence::fromString( settings.value(ZOOM_IN, ZOOM_IN_SHORTCUT).toString() ); - Properties::Instance()->actions[ZOOM_IN]->setShortcut(seq); - connect(Properties::Instance()->actions[ZOOM_IN], SIGNAL(triggered()), consoleTabulator, SLOT(zoomIn())); - menu_Edit->addAction(Properties::Instance()->actions[ZOOM_IN]); - addAction(Properties::Instance()->actions[ZOOM_IN]); + setup_Action(ZOOM_IN, new QAction(QIcon::fromTheme("zoom-in"), tr("Zoom &in"), this), + ZOOM_IN_SHORTCUT, consoleTabulator, SLOT(zoomIn()), menu_Edit); - Properties::Instance()->actions[ZOOM_OUT] = new QAction(QIcon::fromTheme("zoom-out"), tr("Zoom &out"), this); - seq = QKeySequence::fromString( settings.value(ZOOM_OUT, ZOOM_OUT_SHORTCUT).toString() ); - Properties::Instance()->actions[ZOOM_OUT]->setShortcut(seq); - connect(Properties::Instance()->actions[ZOOM_OUT], SIGNAL(triggered()), consoleTabulator, SLOT(zoomOut())); - menu_Edit->addAction(Properties::Instance()->actions[ZOOM_OUT]); - addAction(Properties::Instance()->actions[ZOOM_OUT]); + setup_Action(ZOOM_OUT, new QAction(QIcon::fromTheme("zoom-out"), tr("Zoom &out"), this), + ZOOM_OUT_SHORTCUT, consoleTabulator, SLOT(zoomOut()), menu_Edit); - Properties::Instance()->actions[ZOOM_RESET] = new QAction(QIcon::fromTheme("zoom-original"), tr("Zoom rese&t"), this); - seq = QKeySequence::fromString( settings.value(ZOOM_RESET, ZOOM_RESET_SHORTCUT).toString() ); - Properties::Instance()->actions[ZOOM_RESET]->setShortcut(seq); - connect(Properties::Instance()->actions[ZOOM_RESET], SIGNAL(triggered()), consoleTabulator, SLOT(zoomReset())); - menu_Edit->addAction(Properties::Instance()->actions[ZOOM_RESET]); - addAction(Properties::Instance()->actions[ZOOM_RESET]); + setup_Action(ZOOM_RESET, new QAction(QIcon::fromTheme("zoom-original"), tr("Zoom rese&t"), this), + ZOOM_RESET_SHORTCUT, consoleTabulator, SLOT(zoomReset()), menu_Edit); menu_Actions->addSeparator(); - Properties::Instance()->actions[FIND] = new QAction(QIcon::fromTheme("edit-find"), tr("&Find..."), this); - seq = QKeySequence::fromString( settings.value(FIND, FIND_SHORTCUT).toString() ); - Properties::Instance()->actions[FIND]->setShortcut(seq); - connect(Properties::Instance()->actions[FIND], SIGNAL(triggered()), this, SLOT(find())); - menu_Actions->addAction(Properties::Instance()->actions[FIND]); - addAction(Properties::Instance()->actions[FIND]); + setup_Action(FIND, new QAction(QIcon::fromTheme("edit-find"), tr("&Find..."), this), + FIND_SHORTCUT, this, SLOT(find()), menu_Actions); #if 0 act = new QAction(this); @@ -284,39 +252,22 @@ void MainWindow::setup_ActionsMenu_Actions() connect(act, SIGNAL(triggered()), consoleTabulator, SLOT(loadSession())); #endif - Properties::Instance()->actions[TOGGLE_MENU] = new QAction(tr("&Toggle Menu"), this); - seq = QKeySequence::fromString( settings.value(TOGGLE_MENU, TOGGLE_MENU_SHORTCUT).toString() ); - Properties::Instance()->actions[TOGGLE_MENU]->setShortcut(seq); - connect(Properties::Instance()->actions[TOGGLE_MENU], SIGNAL(triggered()), this, SLOT(toggleMenu())); - addAction(Properties::Instance()->actions[TOGGLE_MENU]); + setup_Action(TOGGLE_MENU, new QAction(tr("&Toggle Menu"), this), + TOGGLE_MENU_SHORTCUT, this, SLOT(find())); // this is correct - add action to main window - not to menu to keep toggle working // Add global rename current session shortcut - Properties::Instance()->actions[RENAME_SESSION] = new QAction(tr("Rename session"), this); - seq = QKeySequence::fromString(settings.value(RENAME_SESSION, RENAME_SESSION_SHORTCUT).toString()); - Properties::Instance()->actions[RENAME_SESSION]->setShortcut(seq); - connect(Properties::Instance()->actions[RENAME_SESSION], SIGNAL(triggered()), consoleTabulator, SLOT(renameCurrentSession())); - addAction(Properties::Instance()->actions[RENAME_SESSION]); + setup_Action(RENAME_SESSION, new QAction(tr("Rename session"), this), + RENAME_SESSION_SHORTCUT, consoleTabulator, SLOT(renameCurrentSession())); // this is correct - add action to main window - not to menu - settings.endGroup(); - // apply props propertiesChanged(); } void MainWindow::setup_FileMenu_Actions() { - QSettings settings; - settings.beginGroup("Shortcuts"); - - QKeySequence seq; - - Properties::Instance()->actions[ADD_TAB] = new QAction(QIcon::fromTheme("list-add"), tr("&New Tab"), this); - seq = QKeySequence::fromString( settings.value(ADD_TAB, ADD_TAB_SHORTCUT).toString() ); - Properties::Instance()->actions[ADD_TAB]->setShortcut(seq); - connect(Properties::Instance()->actions[ADD_TAB], SIGNAL(triggered()), this, SLOT(addNewTab())); - menu_File->addAction(Properties::Instance()->actions[ADD_TAB]); - addAction(Properties::Instance()->actions[ADD_TAB]); + setup_Action(ADD_TAB, new QAction(QIcon::fromTheme("list-add"), tr("&New Tab"), this), + ADD_TAB_SHORTCUT, this, SLOT(addNewTab()), menu_File); QMenu *presetsMenu = new QMenu(tr("New Tab From &Preset"), this); presetsMenu->addAction(QIcon(), tr("1 &Terminal"), @@ -329,56 +280,28 @@ void MainWindow::setup_FileMenu_Actions() consoleTabulator, SLOT(preset4Terminals())); menu_File->addMenu(presetsMenu); - Properties::Instance()->actions[CLOSE_TAB] = new QAction(QIcon::fromTheme("list-remove"), tr("&Close Tab"), this); - seq = QKeySequence::fromString( settings.value(CLOSE_TAB, CLOSE_TAB_SHORTCUT).toString() ); - Properties::Instance()->actions[CLOSE_TAB]->setShortcut(seq); - connect(Properties::Instance()->actions[CLOSE_TAB], SIGNAL(triggered()), consoleTabulator, SLOT(removeCurrentTab())); - menu_File->addAction(Properties::Instance()->actions[CLOSE_TAB]); - addAction(Properties::Instance()->actions[CLOSE_TAB]); + setup_Action(CLOSE_TAB, new QAction(QIcon::fromTheme("list-remove"), tr("&Close Tab"), this), + CLOSE_TAB_SHORTCUT, consoleTabulator, SLOT(removeCurrentTab()), menu_File); - Properties::Instance()->actions[NEW_WINDOW] = new QAction(QIcon::fromTheme("window-new"), tr("&New Window"), this); - seq = QKeySequence::fromString( settings.value(NEW_WINDOW, NEW_WINDOW_SHORTCUT).toString() ); - Properties::Instance()->actions[NEW_WINDOW]->setShortcut(seq); - connect(Properties::Instance()->actions[NEW_WINDOW], SIGNAL(triggered()), this, SLOT(newTerminalWindow())); - menu_File->addAction(Properties::Instance()->actions[NEW_WINDOW]); - addAction(Properties::Instance()->actions[NEW_WINDOW]); + setup_Action(NEW_WINDOW, new QAction(QIcon::fromTheme("window-new"), tr("&New Window"), this), + NEW_WINDOW_SHORTCUT, this, SLOT(newTerminalWindow()), menu_File); menu_File->addSeparator(); - Properties::Instance()->actions[PREFERENCES] = actProperties; - seq = QKeySequence::fromString( settings.value(PREFERENCES).toString() ); - Properties::Instance()->actions[PREFERENCES]->setShortcut(seq); - connect(actProperties, SIGNAL(triggered()), SLOT(actProperties_triggered())); - menu_File->addAction(Properties::Instance()->actions[PREFERENCES]); - addAction(Properties::Instance()->actions[PREFERENCES]); + setup_Action(PREFERENCES, actProperties, "", this, SLOT(actProperties_triggered()), menu_File); menu_File->addSeparator(); - Properties::Instance()->actions[QUIT] = actQuit; - seq = QKeySequence::fromString( settings.value(QUIT).toString() ); - Properties::Instance()->actions[QUIT]->setShortcut(seq); - connect(actQuit, SIGNAL(triggered()), SLOT(close())); - menu_File->addAction(Properties::Instance()->actions[QUIT]); - addAction(Properties::Instance()->actions[QUIT]); - - settings.endGroup(); + setup_Action(QUIT, actQuit, "", this, SLOT(close()), menu_File); } void MainWindow::setup_ViewMenu_Actions() { - QKeySequence seq; - QSettings settings; - settings.beginGroup("Shortcuts"); - QAction *hideBordersAction = new QAction(tr("&Hide Window Borders"), this); hideBordersAction->setCheckable(true); hideBordersAction->setVisible(!m_dropMode); - seq = QKeySequence::fromString( settings.value(HIDE_WINDOW_BORDERS).toString() ); - hideBordersAction->setShortcut(seq); - connect(hideBordersAction, SIGNAL(triggered()), this, SLOT(toggleBorderless())); - menu_Window->addAction(hideBordersAction); - addAction(hideBordersAction); - Properties::Instance()->actions[HIDE_WINDOW_BORDERS] = hideBordersAction; + setup_Action(HIDE_WINDOW_BORDERS, hideBordersAction, + NULL, this, SLOT(toggleBorderless()), menu_Window); //Properties::Instance()->actions[HIDE_WINDOW_BORDERS]->setObjectName("toggle_Borderless"); // TODO/FIXME: it's broken somehow. When I call toggleBorderless() here the non-responsive window appear // Properties::Instance()->actions[HIDE_WINDOW_BORDERS]->setChecked(Properties::Instance()->borderless); @@ -389,29 +312,18 @@ void MainWindow::setup_ViewMenu_Actions() //toggleTabbar->setObjectName("toggle_TabBar"); showTabBarAction->setCheckable(true); showTabBarAction->setChecked(!Properties::Instance()->tabBarless); - seq = QKeySequence::fromString( settings.value(SHOW_TAB_BAR).toString() ); - showTabBarAction->setShortcut(seq); - menu_Window->addAction(showTabBarAction); - addAction(showTabBarAction); - Properties::Instance()->actions[SHOW_TAB_BAR] = showTabBarAction; + setup_Action(SHOW_TAB_BAR, showTabBarAction, + NULL, this, SLOT(toggleTabBar()), menu_Window); toggleTabBar(); - connect(showTabBarAction, SIGNAL(triggered()), this, SLOT(toggleTabBar())); QAction *toggleFullscreen = new QAction(tr("Fullscreen"), this); toggleFullscreen->setCheckable(true); toggleFullscreen->setChecked(false); - seq = QKeySequence::fromString(settings.value(FULLSCREEN, FULLSCREEN_SHORTCUT).toString()); - toggleFullscreen->setShortcut(seq); - menu_Window->addAction(toggleFullscreen); - addAction(toggleFullscreen); - connect(toggleFullscreen, SIGNAL(triggered(bool)), this, SLOT(showFullscreen(bool))); - Properties::Instance()->actions[FULLSCREEN] = toggleFullscreen; + setup_Action(FULLSCREEN, toggleFullscreen, + FULLSCREEN_SHORTCUT, this, SLOT(showFullscreen(bool)), menu_Window); - Properties::Instance()->actions[TOGGLE_BOOKMARKS] = m_bookmarksDock->toggleViewAction(); - seq = QKeySequence::fromString( settings.value(TOGGLE_BOOKMARKS, TOGGLE_BOOKMARKS_SHORTCUT).toString() ); - Properties::Instance()->actions[TOGGLE_BOOKMARKS]->setShortcut(seq); - menu_Window->addAction(Properties::Instance()->actions[TOGGLE_BOOKMARKS]); - settings.endGroup(); + setup_Action(TOGGLE_BOOKMARKS, m_bookmarksDock->toggleViewAction(), + TOGGLE_BOOKMARKS_SHORTCUT, NULL, NULL, menu_Window); menu_Window->addSeparator(); @@ -506,6 +418,25 @@ void MainWindow::setup_ViewMenu_Actions() menu_Window->addMenu(keyboardCursorShapeMenu); } +void MainWindow::setup_ContextMenu_Actions(QMenu* contextMenu) const +{ + contextMenu->addAction(Properties::Instance()->actions[COPY_SELECTION]); + contextMenu->addAction(Properties::Instance()->actions[PASTE_CLIPBOARD]); + contextMenu->addAction(Properties::Instance()->actions[PASTE_SELECTION]); + contextMenu->addAction(Properties::Instance()->actions[ZOOM_IN]); + contextMenu->addAction(Properties::Instance()->actions[ZOOM_OUT]); + contextMenu->addAction(Properties::Instance()->actions[ZOOM_RESET]); + contextMenu->addSeparator(); + contextMenu->addAction(Properties::Instance()->actions[CLEAR_TERMINAL]); + contextMenu->addAction(Properties::Instance()->actions[SPLIT_HORIZONTAL]); + contextMenu->addAction(Properties::Instance()->actions[SPLIT_VERTICAL]); + #warning TODO/FIXME: disable the action when there is only one terminal + contextMenu->addAction(Properties::Instance()->actions[SUB_COLLAPSE]); + contextMenu->addSeparator(); + contextMenu->addAction(Properties::Instance()->actions[TOGGLE_MENU]); + contextMenu->addAction(Properties::Instance()->actions[PREFERENCES]); +} + void MainWindow::setupCustomDirs() { const QSettings settings; @@ -753,3 +684,24 @@ void MainWindow::onCurrentTitleChanged(int index) setWindowTitle(title.isEmpty() || !Properties::Instance()->changeWindowTitle ? QStringLiteral("QTerminal") : title); setWindowIcon(icon.isNull() || !Properties::Instance()->changeWindowIcon ? QIcon::fromTheme("utilities-terminal") : icon); } + +bool MainWindow::hasMultipleTabs() +{ + return consoleTabulator->findChildren().count() > 1; +} + +bool MainWindow::hasMultipleSubterminals() +{ + return consoleTabulator->terminalHolder()->findChildren().count() > 1; +} + +void MainWindow::aboutToShowActionsMenu() +{ + const QList actions = menu_Actions->actions(); + for (QAction *action : actions) { + if (!action->data().isNull()) { + const checkfn check = action->data().value(); + action->setEnabled(check(*this)); + } + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index ae37a38..0b052f1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -36,7 +36,8 @@ public: QWidget * parent = 0, Qt::WindowFlags f = 0); ~MainWindow(); - bool dropMode() { return m_dropMode; } + bool dropMode() const { return m_dropMode; } + void setup_ContextMenu_Actions(QMenu* contextMenu) const; protected: bool event(QEvent* event); @@ -50,6 +51,8 @@ private: QDockWidget *m_bookmarksDock; + void setup_Action(const char *name, QAction *action, const char *defaultShortcut, const QObject *receiver, + const char *slot, QMenu *menu = NULL, const QVariant &data = QVariant()); void setup_FileMenu_Actions(); void setup_ActionsMenu_Actions(); void setup_ViewMenu_Actions(); @@ -64,6 +67,9 @@ private: void realign(); void setDropShortcut(QKeySequence dropShortCut); + bool hasMultipleTabs(); + bool hasMultipleSubterminals(); + private slots: void on_consoleTabulator_currentChanged(int); void propertiesChanged(); @@ -86,5 +92,7 @@ private slots: void addNewTab(); void onCurrentTitleChanged(int index); + + void aboutToShowActionsMenu(); }; #endif //MAINWINDOW_H diff --git a/src/properties.cpp b/src/properties.cpp index 43d4d00..b7b2bd1 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -104,6 +104,7 @@ void Properties::loadSettings() appTransparency = m_settings->value("MainWindow/ApplicationTransparency", 0).toInt(); termTransparency = m_settings->value("TerminalTransparency", 0).toInt(); + backgroundImage = m_settings->value("TerminalBackgroundImage", QString()).toString(); /* default to Right. see qtermwidget.h */ scrollBarPos = m_settings->value("ScrollbarPosition", 2).toInt(); @@ -154,8 +155,10 @@ void Properties::saveSettings() while( it.hasNext() ) { it.next(); - QKeySequence shortcut = it.value()->shortcut(); - m_settings->setValue( it.key(), shortcut.toString() ); + QStringList sequenceStrings; + foreach (QKeySequence shortcut, it.value()->shortcuts()) + sequenceStrings.append(shortcut.toString()); + m_settings->setValue(it.key(), sequenceStrings.join('|')); } m_settings->endGroup(); @@ -184,6 +187,7 @@ void Properties::saveSettings() m_settings->setValue("MainWindow/ApplicationTransparency", appTransparency); m_settings->setValue("TerminalTransparency", termTransparency); + m_settings->setValue("TerminalBackgroundImage", backgroundImage); m_settings->setValue("ScrollbarPosition", scrollBarPos); m_settings->setValue("TabsPosition", tabsPos); m_settings->setValue("KeyboardCursorShape", keyboardCursorShape); diff --git a/src/properties.h b/src/properties.h index 4f73ebf..dbe12c2 100644 --- a/src/properties.h +++ b/src/properties.h @@ -61,6 +61,7 @@ class Properties int appTransparency; int termTransparency; + QString backgroundImage; int scrollBarPos; int tabsPos; diff --git a/src/propertiesdialog.cpp b/src/propertiesdialog.cpp index 3cccdaf..82ad5b1 100644 --- a/src/propertiesdialog.cpp +++ b/src/propertiesdialog.cpp @@ -37,6 +37,8 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) this, SLOT(apply())); connect(changeFontButton, SIGNAL(clicked()), this, SLOT(changeFontButton_clicked())); + connect(chooseBackgroundImageButton, &QPushButton::clicked, + this, &PropertiesDialog::chooseBackgroundImageButton_clicked); QStringList emulations = QTermWidget::availableKeyBindings(); QStringList colorSchemes = QTermWidget::availableColorSchemes(); @@ -49,6 +51,8 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) if (csix != -1) colorSchemaCombo->setCurrentIndex(csix); + backgroundImageLineEdit->setText(Properties::Instance()->backgroundImage); + emulationComboBox->addItems(emulations); int eix = emulationComboBox->findText(Properties::Instance()->emulation); emulationComboBox->setCurrentIndex(eix != -1 ? eix : 0 ); @@ -114,8 +118,12 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) historyLimitedTo->setValue(Properties::Instance()->historyLimitedTo); dropShowOnStartCheckBox->setChecked(Properties::Instance()->dropShowOnStart); + dropHeightSpinBox->setValue(Properties::Instance()->dropHeight); + dropHeightSpinBox->setMaximum(100); dropWidthSpinBox->setValue(Properties::Instance()->dropWidht); + dropWidthSpinBox->setMaximum(100); + dropShortCutEdit->setText(Properties::Instance()->dropShortCut.toString()); useBookmarksCheckBox->setChecked(Properties::Instance()->useBookmarks); @@ -158,6 +166,7 @@ void PropertiesDialog::apply() Properties::Instance()->termTransparency = termTransparencyBox->value(); Properties::Instance()->highlightCurrentTerminal = highlightCurrentCheckBox->isChecked(); + Properties::Instance()->backgroundImage = backgroundImageLineEdit->text(); Properties::Instance()->askOnExit = askOnExitCheckBox->isChecked(); @@ -214,6 +223,15 @@ void PropertiesDialog::changeFontButton_clicked() setFontSample(f); } +void PropertiesDialog::chooseBackgroundImageButton_clicked() +{ + QString filename = QFileDialog::getOpenFileName( + this, tr("Open or create bookmarks file"), + QString(), tr("Images (*.bmp *.png *.xpm *.jpg)")); + if (!filename.isNull()) + backgroundImageLineEdit->setText(filename); +} + void PropertiesDialog::saveShortcuts() { QList< QString > shortcutKeys = Properties::Instance()->actions.keys(); @@ -230,7 +248,10 @@ void PropertiesDialog::saveShortcuts() QKeySequence sequence = QKeySequence(item->text()); QString sequenceString = sequence.toString(); - keyAction->setShortcut(sequenceString); + QList shortcuts; + foreach (sequenceString, item->text().split('|')) + shortcuts.append(QKeySequence(sequenceString)); + keyAction->setShortcuts(shortcuts); } } @@ -245,9 +266,13 @@ void PropertiesDialog::setupShortcuts() { QString keyValue = shortcutKeys.at(x); QAction *keyAction = Properties::Instance()->actions[keyValue]; + QStringList sequenceStrings; + + foreach (QKeySequence shortcut, keyAction->shortcuts()) + sequenceStrings.append(shortcut.toString()); QTableWidgetItem *itemName = new QTableWidgetItem( tr(keyValue.toStdString().c_str()) ); - QTableWidgetItem *itemShortcut = new QTableWidgetItem( keyAction->shortcut().toString() ); + QTableWidgetItem *itemShortcut = new QTableWidgetItem( sequenceStrings.join('|') ); itemName->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); diff --git a/src/propertiesdialog.h b/src/propertiesdialog.h index e8a7157..4304d19 100644 --- a/src/propertiesdialog.h +++ b/src/propertiesdialog.h @@ -44,6 +44,7 @@ class PropertiesDialog : public QDialog, Ui::PropertiesDialog void accept(); void changeFontButton_clicked(); + void chooseBackgroundImageButton_clicked(); void bookmarksButton_clicked(); protected: diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 8691968..ce860cb 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -253,24 +253,25 @@ void TabWidget::removeFinished() void TabWidget::removeTab(int index) { - setUpdatesEnabled(false); + if (count() > 1) { + setUpdatesEnabled(false); - QWidget * w = widget(index); - QTabWidget::removeTab(index); - w->deleteLater(); + QWidget * w = widget(index); + QTabWidget::removeTab(index); + w->deleteLater(); - updateTabIndices(); - int current = currentIndex(); - if (current >= 0 ) - { - qobject_cast(widget(current))->setInitialFocus(); - } -// do not decrease it as renaming is disabled in renameTabsAfterRemove -// tabNumerator--; - setUpdatesEnabled(true); - - if (count() == 0) + updateTabIndices(); + int current = currentIndex(); + if (current >= 0 ) + { + qobject_cast(widget(current))->setInitialFocus(); + } + // do not decrease it as renaming is disabled in renameTabsAfterRemove + // tabNumerator--; + setUpdatesEnabled(true); + } else { emit closeTabNotification(); + } renameTabsAfterRemove(); showHideTabBar(); diff --git a/src/termwidget.cpp b/src/termwidget.cpp index b5b5c49..b02b381 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -24,6 +24,7 @@ #include "termwidget.h" #include "config.h" #include "properties.h" +#include "mainwindow.h" static int TermWidgetCount = 0; @@ -67,7 +68,7 @@ TermWidgetImpl::TermWidgetImpl(const QString & wdir, const QString & shell, QWid connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenuCall(const QPoint &))); - connect(this, SIGNAL(urlActivated(QUrl)), this, SLOT(activateUrl(const QUrl&))); + connect(this, &QTermWidget::urlActivated, this, &TermWidgetImpl::activateUrl); startShellProgram(); } @@ -90,6 +91,7 @@ void TermWidgetImpl::propertiesChanged() setKeyBindings(Properties::Instance()->emulation); setTerminalOpacity(1.0 - Properties::Instance()->termTransparency/100.0); + setTerminalBackgroundImage(Properties::Instance()->backgroundImage); /* be consequent with qtermwidget.h here */ switch(Properties::Instance()->scrollBarPos) { @@ -123,23 +125,20 @@ void TermWidgetImpl::propertiesChanged() void TermWidgetImpl::customContextMenuCall(const QPoint & pos) { - QMenu menu; - menu.addAction(Properties::Instance()->actions[COPY_SELECTION]); - menu.addAction(Properties::Instance()->actions[PASTE_CLIPBOARD]); - menu.addAction(Properties::Instance()->actions[PASTE_SELECTION]); - menu.addAction(Properties::Instance()->actions[ZOOM_IN]); - menu.addAction(Properties::Instance()->actions[ZOOM_OUT]); - menu.addAction(Properties::Instance()->actions[ZOOM_RESET]); - menu.addSeparator(); - menu.addAction(Properties::Instance()->actions[CLEAR_TERMINAL]); - menu.addAction(Properties::Instance()->actions[SPLIT_HORIZONTAL]); - menu.addAction(Properties::Instance()->actions[SPLIT_VERTICAL]); -#warning TODO/FIXME: disable the action when there is only one terminal - menu.addAction(Properties::Instance()->actions[SUB_COLLAPSE]); - menu.addSeparator(); - menu.addAction(Properties::Instance()->actions[TOGGLE_MENU]); - menu.addAction(Properties::Instance()->actions[PREFERENCES]); - menu.exec(mapToGlobal(pos)); + QMenu* contextMenu = new QMenu(this); + + QList actions = filterActions(pos); + for (auto& action : actions) + { + contextMenu->addAction(action); + } + + contextMenu->addSeparator(); + + const MainWindow *main = qobject_cast(window()); + main->setup_ContextMenu_Actions(contextMenu); + + contextMenu->exec(mapToGlobal(pos)); } void TermWidgetImpl::zoomIn() @@ -166,8 +165,8 @@ void TermWidgetImpl::zoomReset() // Properties::Instance()->saveSettings(); } -void TermWidgetImpl::activateUrl(const QUrl & url) { - if (QApplication::keyboardModifiers() & Qt::ControlModifier) { +void TermWidgetImpl::activateUrl(const QUrl & url, bool fromContextMenu) { + if (QApplication::keyboardModifiers() & Qt::ControlModifier || fromContextMenu) { QDesktopServices::openUrl(url); } } diff --git a/src/termwidget.h b/src/termwidget.h index 9f79309..24813e4 100644 --- a/src/termwidget.h +++ b/src/termwidget.h @@ -46,7 +46,7 @@ class TermWidgetImpl : public QTermWidget private slots: void customContextMenuCall(const QPoint & pos); - void activateUrl(const QUrl& url); + void activateUrl(const QUrl& url, bool fromContextMenu); };