From 447d71064a39eb9156a83872655ec2403695dad9 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 1 Jul 2025 00:10:26 +0800 Subject: [PATCH] Fix for Qt4 --- CMakeLists.txt | 58 +++----- src/bookmarkswidget.cpp | 27 ++-- src/bookmarkswidget.h | 4 +- src/dbusaddressable.cpp | 2 +- src/fontdialog.cpp | 8 +- src/fontdialog.h | 5 +- src/forms/bookmarkswidget.ui | 3 - src/main.cpp | 30 ++--- src/mainwindow.cpp | 156 +++++++++++----------- src/properties.cpp | 4 +- src/propertiesdialog.cpp | 110 ++++++++------- src/propertiesdialog.h | 14 +- src/qterminalutils.cpp | 53 +++++--- src/tab-switcher.cpp | 15 +-- src/tab-switcher.h | 4 +- src/tabbar.cpp | 2 +- src/tabwidget.cpp | 69 ++++------ src/tabwidget.h | 5 +- src/terminalconfig.cpp | 2 +- src/termwidget.cpp | 59 ++++---- src/termwidget.h | 8 +- src/termwidgetholder.cpp | 34 +++-- src/termwidgetholder.h | 6 +- src/third-party/qxtglobalshortcut_p.h | 4 - src/third-party/qxtglobalshortcut_x11.cpp | 4 +- 25 files changed, 318 insertions(+), 368 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0ca025..05dd3a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,23 +23,10 @@ endif() # Minimum Versions set(LXQTBT_MINIMUM_VERSION "0.13.0") set(QTERMWIDGET_MINIMUM_VERSION "1.4.0") -set(QT_MINIMUM_VERSION "5.15.0") - -find_package(Qt5Gui ${QT_MINIMUM_VERSION} REQUIRED) -find_package(Qt5LinguistTools ${QT_MINIMUM_VERSION} REQUIRED) -find_package(Qt5Widgets ${QT_MINIMUM_VERSION} REQUIRED) -if(UNIX) - find_package(Qt5DBus ${QT_MINIMUM_VERSION} REQUIRED) - if (NOT APPLE) - find_package(Qt5X11Extras ${QT_MINIMUM_VERSION} REQUIRED) - endif (NOT APPLE) -endif() -find_package(QTermWidget5 ${QTERMWIDGET_MINIMUM_VERSION} REQUIRED) -find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) -if (BUILD_TESTS) - find_package(Qt5 ${QT_MINIMUM_VERSION} CONFIG REQUIRED Test) -endif() +find_package(Qt4 COMPONENTS QtCore QtGui QtXml QtDBus REQUIRED) +find_package(QTermWidget4 ${QTERMWIDGET_MINIMUM_VERSION} REQUIRED) +find_package(lxqt-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) include(LXQtPreventInSourceBuilds) include(FindPkgConfig) @@ -53,13 +40,9 @@ message(STATUS "Qt version: ${Qt5Core_VERSION}") message(STATUS "Using bundled Qxt...") set(QXT_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/third-party") - if(APPLE) find_library(CARBON_LIBRARY Carbon REQUIRED) message(STATUS "CARBON_LIBRARY: ${CARBON_LIBRARY}") -elseif(UNIX) - find_package(X11 REQUIRED) - message(STATUS "X11_X11_LIB: ${X11_X11_LIB}") endif() add_definitions( @@ -98,26 +81,22 @@ set(QTERM_MOC_SRC src/tab-switcher.h ) -if (Qt5DBus_FOUND) +if (QtDBus_FOUND) add_definitions(-DHAVE_QDBUS) - QT5_ADD_DBUS_ADAPTOR(QTERM_SRC src/org.lxqt.QTerminal.Window.xml mainwindow.h MainWindow) - QT5_ADD_DBUS_ADAPTOR(QTERM_SRC src/org.lxqt.QTerminal.Tab.xml termwidgetholder.h TermWidgetHolder) - QT5_ADD_DBUS_ADAPTOR(QTERM_SRC src/org.lxqt.QTerminal.Terminal.xml termwidget.h TermWidget) - QT5_ADD_DBUS_ADAPTOR(QTERM_SRC src/org.lxqt.QTerminal.Process.xml qterminalapp.h QTerminalApp) + qt4_add_dbus_adaptor(QTERM_SRC src/org.lxqt.QTerminal.Window.xml mainwindow.h MainWindow) + qt4_add_dbus_adaptor(QTERM_SRC src/org.lxqt.QTerminal.Tab.xml termwidgetholder.h TermWidgetHolder) + qt4_add_dbus_adaptor(QTERM_SRC src/org.lxqt.QTerminal.Terminal.xml termwidget.h TermWidget) + qt4_add_dbus_adaptor(QTERM_SRC src/org.lxqt.QTerminal.Process.xml qterminalapp.h QTerminalApp) set(QTERM_MOC_SRC ${QTERM_MOC_SRC} src/dbusaddressable.h) - message(STATUS "Building with Qt5DBus support") + message(STATUS "Building with QtDBus support") endif() if(NOT QXT_FOUND) set(QTERM_SRC ${QTERM_SRC} src/third-party/qxtglobalshortcut.cpp) set(QTERM_MOC_SRC ${QTERM_MOC_SRC} src/third-party/qxtglobalshortcut.h) - if(WIN32) - set(QTERM_SRC ${QTERM_SRC} src/third-party/qxtglobalshortcut_win.cpp) - elseif(APPLE) + if(APPLE) set(QTERM_SRC ${QTERM_SRC} src/third-party/qxtglobalshortcut_mac.cpp) - else() - set(QTERM_SRC ${QTERM_SRC} src/third-party/qxtglobalshortcut_x11.cpp) endif() endif() @@ -132,9 +111,9 @@ set(QTERM_RCC_SRC src/icons.qrc ) -qt5_wrap_ui( QTERM_UI ${QTERM_UI_SRC} ) -qt5_wrap_cpp( QTERM_MOC ${QTERM_MOC_SRC} ) -qt5_add_resources( QTERM_RCC ${QTERM_RCC_SRC} ) +qt4_wrap_ui( QTERM_UI ${QTERM_UI_SRC} ) +qt4_wrap_cpp( QTERM_MOC ${QTERM_MOC_SRC} ) +qt4_add_resources( QTERM_RCC ${QTERM_RCC_SRC} ) lxqt_translate_ts(QTERM_QM UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS} @@ -163,7 +142,6 @@ if(X11_FOUND) include_directories("${X11_INCLUDE_DIR}") endif() - # TODO/FIXME: apple bundle set(GUI_TYPE "") set(APPLE_BUNDLE_SOURCES "") @@ -202,22 +180,20 @@ add_executable(${EXE_NAME} ${GUI_TYPE} ) target_link_libraries(${EXE_NAME} - Qt5::Gui - qtermwidget5 + Qt4::QtGui + qtermwidget4 util ) if(QXT_FOUND) target_link_libraries(${EXE_NAME} ${QXT_CORE_LIB} ${QXT_GUI_LIB}) endif() -if (Qt5DBus_FOUND) - target_link_libraries(${EXE_NAME} ${Qt5DBus_LIBRARIES}) +if (QtDBus_FOUND) + target_link_libraries(${EXE_NAME} ${QtDBus_LIBRARIES}) endif() if(APPLE) target_link_libraries(${EXE_NAME} ${CARBON_LIBRARY}) -elseif(UNIX) - target_link_libraries(${EXE_NAME} Qt5::X11Extras) endif() if(X11_FOUND) diff --git a/src/bookmarkswidget.cpp b/src/bookmarkswidget.cpp index 387d0a5..5208dd1 100644 --- a/src/bookmarkswidget.cpp +++ b/src/bookmarkswidget.cpp @@ -75,7 +75,7 @@ public: BookmarkRootItem() : AbstractBookmarkItem(AbstractBookmarkItem::Root) { - m_value = m_display = QStringLiteral("root"); + m_value = m_display = QLatin1String("root"); } }; @@ -90,7 +90,6 @@ public: } }; - class BookmarkGroupItem : public AbstractBookmarkItem { public: @@ -116,7 +115,7 @@ public: QFile f(fname); if (!f.open(QIODevice::ReadOnly)) { - //qDebug() << "Cannot open file" << fname; + // qDebug() << "Cannot open file" << fname; // TODO/FIXME: message box return; } @@ -179,11 +178,10 @@ public: QString xmlPos() { - return m_pos.join(QLatin1Char('.')); + return m_pos.join(QLatin1String(".")); } }; - BookmarksModel::BookmarksModel(QObject *parent) : QAbstractItemModel(parent), m_root(nullptr) @@ -267,7 +265,6 @@ QModelIndex BookmarksModel::index(int row, int column, const QModelIndex &parent return QModelIndex(); } - QModelIndex BookmarksModel::parent(const QModelIndex &index) const { if (!index.isValid()) @@ -320,7 +317,6 @@ bool BookmarksModel::setData(const QModelIndex &index, const QVariant &value, } #endif - BookmarksWidget::BookmarksWidget(QWidget *parent) : QWidget(parent) { @@ -331,15 +327,13 @@ BookmarksWidget::BookmarksWidget(QWidget *parent) treeView->header()->hide(); setFocusProxy(filterEdit); - connect(treeView, &QTreeView::activated, - this, &BookmarksWidget::handleCommand); - connect(filterEdit, &QLineEdit::textChanged, - this, &BookmarksWidget::filter); + connect(treeView, SIGNAL(activated(const QModelIndex &)), + this, SLOT(handleCommand(const QModelIndex &))); + connect(filterEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(filter(const QString &))); QShortcut *clearFilter = new QShortcut(QKeySequence (Qt::Key_Escape), this); - connect(clearFilter, &QShortcut::activated, this, [this] { - filterEdit->clear(); - }); + connect(clearFilter, SIGNAL(activated()), this, SLOT(clearFilterEdit())); } BookmarksWidget::~BookmarksWidget() @@ -386,3 +380,8 @@ void BookmarksWidget::filter(const QString& str) } } } + +void BookmarksWidget::clearFilterEdit() +{ + filterEdit->clear(); +} diff --git a/src/bookmarkswidget.h b/src/bookmarkswidget.h index 7195edb..b6edc8c 100644 --- a/src/bookmarkswidget.h +++ b/src/bookmarkswidget.h @@ -24,7 +24,6 @@ class AbstractBookmarkItem; class BookmarksModel; - class BookmarksWidget : public QWidget, Ui::BookmarksWidget { Q_OBJECT @@ -44,9 +43,9 @@ private: private slots: void handleCommand(const QModelIndex& index); void filter(const QString& str); + void clearFilterEdit(); }; - class BookmarksModel : public QAbstractItemModel { Q_OBJECT @@ -76,4 +75,3 @@ private: }; #endif - diff --git a/src/dbusaddressable.cpp b/src/dbusaddressable.cpp index b03a4f2..25e0720 100644 --- a/src/dbusaddressable.cpp +++ b/src/dbusaddressable.cpp @@ -20,6 +20,6 @@ DBusAddressable::DBusAddressable(const QString& prefix) { #ifdef HAVE_QDBUS QString uuidString = QUuid::createUuid().toString(); - m_path = prefix + QLatin1Char('/') + uuidString.replace(QRegExp(QStringLiteral("[\\{\\}\\-]")), QString()); + m_path = prefix + QLatin1Char('/') + uuidString.replace(QRegExp(QLatin1String("[\\{\\}\\-]")), QString()); #endif } diff --git a/src/fontdialog.cpp b/src/fontdialog.cpp index 4a053ee..2d86548 100644 --- a/src/fontdialog.cpp +++ b/src/fontdialog.cpp @@ -34,10 +34,10 @@ FontDialog::FontDialog(const QFont &f) setFontSample(f); - connect(fontComboBox, &QFontComboBox::currentFontChanged, - this, &FontDialog::setFontSample); - connect(sizeSpinBox, static_cast(&QSpinBox::valueChanged), - this, &FontDialog::setFontSize); + connect(fontComboBox, SIGNAL(currentFontChanged(const QFont &)), + this, SLOT(setFontSample(const QFont &))); + connect(sizeSpinBox, SIGNAL(valueChanged(int)), + this, SLOT(setFontSize())); } QFont FontDialog::getFont() diff --git a/src/fontdialog.h b/src/fontdialog.h index 19dc67c..8247a4c 100644 --- a/src/fontdialog.h +++ b/src/fontdialog.h @@ -22,19 +22,16 @@ #include "ui_fontdialog.h" #include "properties.h" - - class FontDialog : public QDialog, public Ui::FontDialog { Q_OBJECT public: - FontDialog(const QFont &f); + explicit FontDialog(const QFont &f); QFont getFont(); private slots: void setFontSample(const QFont &f); void setFontSize(); - }; #endif diff --git a/src/forms/bookmarkswidget.ui b/src/forms/bookmarkswidget.ui index 38e14ea..08007a7 100644 --- a/src/forms/bookmarkswidget.ui +++ b/src/forms/bookmarkswidget.ui @@ -35,9 +35,6 @@ - - true - diff --git a/src/main.cpp b/src/main.cpp index dee7254..bd4378f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -116,7 +116,7 @@ void parse_args(int argc, char* argv[], QString& workdir, QStringList & shell_co int main(int argc, char *argv[]) { - if (!qEnvironmentVariableIsEmpty("XPC_SERVICE_NAME")) { + if (!qgetenv("XPC_SERVICE_NAME").isEmpty()) { // On macOS, if qterminal.app is spawned by launchd (e.g., from Finder // or use `open qterminal.app`, $PWD is set to /. Workaround that by // go to $HOME first. @@ -130,10 +130,9 @@ int main(int argc, char *argv[]) qputenv("LANG", systemLocaleName.toLatin1()); } - QApplication::setApplicationName(QStringLiteral("qterminal")); - QApplication::setApplicationVersion(QStringLiteral(QTERMINAL_VERSION)); - QApplication::setOrganizationDomain(QStringLiteral("qterminal.org")); - QApplication::setDesktopFileName(QLatin1String("qterminal.desktop")); + QApplication::setApplicationName(QLatin1String("qterminal")); + QApplication::setApplicationVersion(QLatin1String(QTERMINAL_VERSION)); + QApplication::setOrganizationDomain(QLatin1String("qterminal.org")); // Warning: do not change settings format. It can screw bookmarks later. QSettings::setDefaultFormat(QSettings::IniFormat); @@ -157,41 +156,40 @@ int main(int argc, char *argv[]) const QSettings settings; const QFileInfo customStyle = QFileInfo( QFileInfo(settings.fileName()).canonicalPath() + - QStringLiteral("/style.qss") + QLatin1String("/style.qss") ); if (customStyle.isFile() && customStyle.isReadable()) { QFile style(customStyle.canonicalFilePath()); style.open(QFile::ReadOnly); - QString styleString = QLatin1String(style.readAll()); + QString styleString = QString::fromLatin1(style.readAll().constData()); app->setStyleSheet(styleString); } // icons /* setup our custom icon theme if there is no system theme (OS X, Windows) */ - QCoreApplication::instance()->setAttribute(Qt::AA_UseHighDpiPixmaps); //Fix for High-DPI systems if (QIcon::themeName().isEmpty()) - QIcon::setThemeName(QStringLiteral("QTerminal")); + QIcon::setThemeName(QLatin1String("QTerminal")); // translations // install the translations built-into Qt itself QTranslator qtTranslator; - qtTranslator.load(QStringLiteral("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + qtTranslator.load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); app->installTranslator(&qtTranslator); QTranslator translator; QString fname = QString::fromLatin1("qterminal_%1.qm").arg(QLocale::system().name().left(5)); #ifdef TRANSLATIONS_DIR //qDebug() << "TRANSLATIONS_DIR: Loading translation file" << fname << "from dir" << TRANSLATIONS_DIR; - /*qDebug() << "load success:" <<*/ translator.load(fname, QString::fromUtf8(TRANSLATIONS_DIR), QStringLiteral("_")); + /*qDebug() << "load success:" <<*/ translator.load(fname, QString::fromUtf8(TRANSLATIONS_DIR), QLatin1String("_")); #endif #ifdef APPLE_BUNDLE QDir translations_dir = QDir(QApplication::applicationDirPath()); translations_dir.cdUp(); - if (translations_dir.cd(QStringLiteral("Resources/translations"))) { + if (translations_dir.cd(QLatin1String("Resources/translations"))) { //qDebug() << "APPLE_BUNDLE: Loading translator file" << fname << "from dir" << translations_dir.path(); - /*qDebug() << "load success:" <<*/ translator.load(fname, translations_dir.path(), QStringLiteral("_")); + /*qDebug() << "load success:" <<*/ translator.load(fname, translations_dir.path(), QLatin1String("_")); } /*else { qWarning() << "Unable to find \"Resources/translations\" dir in" << translations_dir.path(); }*/ @@ -286,20 +284,20 @@ void QTerminalApp::registerOnDbus() "\teval `dbus-launch --auto-syntax`\n"); return; } - QString serviceName = QStringLiteral("org.lxqt.QTerminal-%1").arg(getpid()); + QString serviceName = QLatin1String("org.lxqt.QTerminal-%1").arg(getpid()); if (!QDBusConnection::sessionBus().registerService(serviceName)) { fprintf(stderr, "%s\n", qPrintable(QDBusConnection::sessionBus().lastError().message())); return; } new ProcessAdaptor(this); - QDBusConnection::sessionBus().registerObject(QStringLiteral("/"), this); + QDBusConnection::sessionBus().registerObject(QLatin1String("/"), this); } QList QTerminalApp::getWindows() { QList windows; - for (MainWindow *wnd : qAsConst(m_windowList)) + foreach (MainWindow *wnd, m_windowList) { windows.push_back(wnd->getDbusPath()); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 18042ef..0b4df2e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,16 +20,17 @@ #include #include #include -#include +#include #include -#include -#include +#include #ifdef HAVE_QDBUS #include #include "windowadaptor.h" #endif +#include + #include "terminalconfig.h" #include "mainwindow.h" #include "tabwidget.h" @@ -52,7 +53,7 @@ MainWindow::MainWindow(TerminalConfig &cfg, QWidget * parent, Qt::WindowFlags f) : QMainWindow(parent,f), - DBusAddressable(QStringLiteral("/windows")), + DBusAddressable(QLatin1String("/windows")), tabPosition(nullptr), scrollBarPosition(nullptr), keyboardCursorShape(nullptr), @@ -82,30 +83,28 @@ MainWindow::MainWindow(TerminalConfig &cfg, // https://github.com/lxqt/qterminal/issues/181 - Minimum size // https://github.com/lxqt/qterminal/issues/263 - Decrease minimal height QFontMetrics metrics(Properties::Instance()->font); - int spaceWidth = metrics.horizontalAdvance(QChar(QChar::Space)); + int spaceWidth = metrics.width(QLatin1Char(' ')); setMinimumSize(QSize(10 * spaceWidth, metrics.height())); m_bookmarksDock = new QDockWidget(tr("Bookmarks"), this); - m_bookmarksDock->setObjectName(QStringLiteral("BookmarksDockWidget")); + m_bookmarksDock->setObjectName(QLatin1String("BookmarksDockWidget")); m_bookmarksDock->setAutoFillBackground(true); BookmarksWidget *bookmarksWidget = new BookmarksWidget(m_bookmarksDock); bookmarksWidget->setAutoFillBackground(true); m_bookmarksDock->setWidget(bookmarksWidget); addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksDock); - connect(bookmarksWidget, &BookmarksWidget::callCommand, - this, &MainWindow::bookmarksWidget_callCommand); - - connect(m_bookmarksDock, &QDockWidget::visibilityChanged, - this, &MainWindow::bookmarksDock_visibilityChanged); - - connect(actAbout, &QAction::triggered, this, &MainWindow::actAbout_triggered); - connect(actAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt); - connect(&m_dropShortcut, &QxtGlobalShortcut::activated, this, &MainWindow::showHide); + connect(bookmarksWidget, SIGNAL(callCommand(const QString&)), + this, SLOT(bookmarksWidget_callCommand(const QString&))); + connect(m_bookmarksDock, SIGNAL(visibilityChanged(bool)), + this, SLOT(bookmarksDock_visibilityChanged(bool))); + connect(actAbout, SIGNAL(triggered()), this, SLOT(actAbout_triggered())); + connect(actAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(&m_dropShortcut, SIGNAL(activated()), this, SLOT(showHide())); setContentsMargins(0, 0, 0, 0); if (m_dropMode) { this->enableDropMode(); - setStyleSheet(QStringLiteral(QSS_DROP)); + setStyleSheet(QLatin1String(QSS_DROP)); } else { if (Properties::Instance()->saveSizeOnExit) { @@ -115,16 +114,14 @@ MainWindow::MainWindow(TerminalConfig &cfg, else if (Properties::Instance()->fixedWindowSize.isValid()) { resize(Properties::Instance()->fixedWindowSize); } - if (Properties::Instance()->savePosOnExit && !Properties::Instance()->mainWindowPosition.isNull() - && QGuiApplication::platformName() != QStringLiteral("wayland") - ) { + if (Properties::Instance()->savePosOnExit && !Properties::Instance()->mainWindowPosition.isNull()) { move(Properties::Instance()->mainWindowPosition); } restoreState(Properties::Instance()->mainWindowState); } consoleTabulator->setAutoFillBackground(true); - connect(consoleTabulator, &TabWidget::closeLastTabNotification, this, &MainWindow::close); + connect(consoleTabulator, SIGNAL(closeLastTabNotification()), this, SLOT(close())); consoleTabulator->setTabPosition((QTabWidget::TabPosition)Properties::Instance()->tabsPos); //consoleTabulator->setShellProgram(command); @@ -137,8 +134,8 @@ MainWindow::MainWindow(TerminalConfig &cfg, setupCustomDirs(); - connect(consoleTabulator, &TabWidget::currentTitleChanged, this, &MainWindow::onCurrentTitleChanged); - connect(menu_Actions, &QMenu::aboutToShow, this, &MainWindow::updateDisabledActions); + connect(consoleTabulator, SIGNAL(currentTitleChanged(int)), this, SLOT(onCurrentTitleChanged(int))); + connect(menu_Actions, SIGNAL(aboutToShow()), this, SLOT(updateDisabledActions())); /* The tab should be added after all changes are made to the main window; otherwise, the initial prompt might @@ -171,7 +168,7 @@ void MainWindow::enableDropMode() m_dropLockButton->setToolTip(tr("Keep window open when it loses focus")); consoleTabulator->setCornerWidget(m_dropLockButton, Qt::BottomRightCorner); m_dropLockButton->setCheckable(true); - m_dropLockButton->connect(m_dropLockButton, &QToolButton::clicked, this, &MainWindow::setKeepOpen); + connect(m_dropLockButton, SIGNAL(clicked(bool)), this, SLOT(setKeepOpen(bool))); setKeepOpen(Properties::Instance()->dropKeepOpen); m_dropLockButton->setAutoRaise(true); @@ -187,7 +184,7 @@ void MainWindow::setDropShortcut(const QKeySequence& dropShortCut) if (m_dropShortcut.shortcut() != dropShortCut) { m_dropShortcut.setShortcut(dropShortCut); - qWarning().noquote() << tr("Press \"%1\" to see the terminal.").arg(dropShortCut.toString()); + qWarning() << tr("Press \"%1\" to see the terminal.").arg(dropShortCut.toString()); } } @@ -195,7 +192,7 @@ void MainWindow::setup_Action(const char *name, QAction *action, const char *def const char *slot, QMenu *menu, const QVariant &data) { QSettings settings; - settings.beginGroup(QStringLiteral("Shortcuts")); + settings.beginGroup(QLatin1String("Shortcuts")); QList shortcuts; @@ -229,17 +226,17 @@ void MainWindow::setup_ActionsMenu_Actions() menu_Actions->clear(); - setup_Action(CLEAR_TERMINAL, new QAction(QIcon::fromTheme(QStringLiteral("edit-clear")), tr("&Clear Active Terminal"), settingOwner), + setup_Action(CLEAR_TERMINAL, new QAction(QIcon::fromTheme(QLatin1String("edit-clear")), tr("&Clear Active Terminal"), settingOwner), CLEAR_TERMINAL_SHORTCUT, consoleTabulator, SLOT(clearActiveTerminal()), menu_Actions); menu_Actions->addSeparator(); data.setValue(checkTabs); - setup_Action(TAB_NEXT, new QAction(QIcon::fromTheme(QStringLiteral("go-next")), tr("&Next Tab"), settingOwner), + setup_Action(TAB_NEXT, new QAction(QIcon::fromTheme(QLatin1String("go-next")), tr("&Next Tab"), settingOwner), TAB_NEXT_SHORTCUT, consoleTabulator, SLOT(switchToRight()), menu_Actions, data); - setup_Action(TAB_PREV, new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), tr("&Previous Tab"), settingOwner), + setup_Action(TAB_PREV, new QAction(QIcon::fromTheme(QLatin1String("go-previous")), tr("&Previous Tab"), settingOwner), TAB_PREV_SHORTCUT, consoleTabulator, SLOT(switchToLeft()), menu_Actions, data); setup_Action(TAB_PREV_HISTORY, new QAction(tr("&Previous Tab in History"), settingOwner), @@ -281,46 +278,46 @@ void MainWindow::setup_ActionsMenu_Actions() setup_Action(SUB_COLLAPSE, new QAction(tr("&Collapse Subterminal"), settingOwner), nullptr, consoleTabulator, SLOT(splitCollapse()), menu_Actions, data); - setup_Action(SUB_TOP, new QAction(QIcon::fromTheme(QStringLiteral("go-up")), tr("&Top Subterminal"), settingOwner), + setup_Action(SUB_TOP, new QAction(QIcon::fromTheme(QLatin1String("go-up")), tr("&Top Subterminal"), settingOwner), SUB_TOP_SHORTCUT, consoleTabulator, SLOT(switchTopSubterminal()), menu_Actions, data); - setup_Action(SUB_BOTTOM, new QAction(QIcon::fromTheme(QStringLiteral("go-down")), tr("&Bottom Subterminal"), settingOwner), + setup_Action(SUB_BOTTOM, new QAction(QIcon::fromTheme(QLatin1String("go-down")), tr("&Bottom Subterminal"), settingOwner), SUB_BOTTOM_SHORTCUT, consoleTabulator, SLOT(switchBottomSubterminal()), menu_Actions, data); - setup_Action(SUB_LEFT, new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), tr("L&eft Subterminal"), settingOwner), + setup_Action(SUB_LEFT, new QAction(QIcon::fromTheme(QLatin1String("go-previous")), tr("L&eft Subterminal"), settingOwner), SUB_LEFT_SHORTCUT, consoleTabulator, SLOT(switchLeftSubterminal()), menu_Actions, data); - setup_Action(SUB_RIGHT, new QAction(QIcon::fromTheme(QStringLiteral("go-next")), tr("R&ight Subterminal"), settingOwner), + setup_Action(SUB_RIGHT, new QAction(QIcon::fromTheme(QLatin1String("go-next")), tr("R&ight Subterminal"), settingOwner), SUB_RIGHT_SHORTCUT, consoleTabulator, SLOT(switchRightSubterminal()), 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. - setup_Action(COPY_SELECTION, new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy &Selection"), settingOwner), + setup_Action(COPY_SELECTION, new QAction(QIcon::fromTheme(QLatin1String("edit-copy")), tr("Copy &Selection"), settingOwner), COPY_SELECTION_SHORTCUT, consoleTabulator, SLOT(copySelection()), menu_Edit); - setup_Action(PASTE_CLIPBOARD, new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), tr("Paste Clip&board"), settingOwner), + setup_Action(PASTE_CLIPBOARD, new QAction(QIcon::fromTheme(QLatin1String("edit-paste")), tr("Paste Clip&board"), settingOwner), PASTE_CLIPBOARD_SHORTCUT, consoleTabulator, SLOT(pasteClipboard()), menu_Edit); - setup_Action(PASTE_SELECTION, new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), tr("Paste S&election"), settingOwner), + setup_Action(PASTE_SELECTION, new QAction(QIcon::fromTheme(QLatin1String("edit-paste")), tr("Paste S&election"), settingOwner), PASTE_SELECTION_SHORTCUT, consoleTabulator, SLOT(pasteSelection()), menu_Edit); - setup_Action(ZOOM_IN, new QAction(QIcon::fromTheme(QStringLiteral("zoom-in")), tr("Zoom &in"), settingOwner), + setup_Action(ZOOM_IN, new QAction(QIcon::fromTheme(QLatin1String("zoom-in")), tr("Zoom &in"), settingOwner), ZOOM_IN_SHORTCUT, consoleTabulator, SLOT(zoomIn()), menu_Edit); - setup_Action(ZOOM_OUT, new QAction(QIcon::fromTheme(QStringLiteral("zoom-out")), tr("Zoom &out"), settingOwner), + setup_Action(ZOOM_OUT, new QAction(QIcon::fromTheme(QLatin1String("zoom-out")), tr("Zoom &out"), settingOwner), ZOOM_OUT_SHORTCUT, consoleTabulator, SLOT(zoomOut()), menu_Edit); - setup_Action(ZOOM_RESET, new QAction(QIcon::fromTheme(QStringLiteral("zoom-original")), tr("Zoom rese&t"), settingOwner), + setup_Action(ZOOM_RESET, new QAction(QIcon::fromTheme(QLatin1String("zoom-original")), tr("Zoom rese&t"), settingOwner), ZOOM_RESET_SHORTCUT, consoleTabulator, SLOT(zoomReset()), menu_Edit); menu_Actions->addSeparator(); - setup_Action(FIND, new QAction(QIcon::fromTheme(QStringLiteral("edit-find")), tr("&Find..."), settingOwner), + setup_Action(FIND, new QAction(QIcon::fromTheme(QLatin1String("edit-find")), tr("&Find..."), settingOwner), FIND_SHORTCUT, this, SLOT(find()), menu_Actions); - setup_Action(HANDLE_HISTORY, new QAction(QIcon::fromTheme(QStringLiteral("handle-history")), tr("Handle history..."), settingOwner), + setup_Action(HANDLE_HISTORY, new QAction(QIcon::fromTheme(QLatin1String("handle-history")), tr("Handle history..."), settingOwner), NULL, this, SLOT(handleHistory()), menu_Actions); #if 0 @@ -355,7 +352,7 @@ void MainWindow::setup_ActionsMenu_Actions() void MainWindow::setup_FileMenu_Actions() { menu_File->clear(); - setup_Action(ADD_TAB, new QAction(QIcon::fromTheme(QStringLiteral("list-add")), tr("&New Tab"), settingOwner), + setup_Action(ADD_TAB, new QAction(QIcon::fromTheme(QLatin1String("list-add")), tr("&New Tab"), settingOwner), ADD_TAB_SHORTCUT, this, SLOT(addNewTab()), menu_File); if (presetsMenu == nullptr) { @@ -372,10 +369,10 @@ void MainWindow::setup_FileMenu_Actions() menu_File->addMenu(presetsMenu); - setup_Action(CLOSE_TAB, new QAction(QIcon::fromTheme(QStringLiteral("list-remove")), tr("&Close Tab"), settingOwner), + setup_Action(CLOSE_TAB, new QAction(QIcon::fromTheme(QLatin1String("list-remove")), tr("&Close Tab"), settingOwner), CLOSE_TAB_SHORTCUT, consoleTabulator, SLOT(removeCurrentTab()), menu_File); - setup_Action(NEW_WINDOW, new QAction(QIcon::fromTheme(QStringLiteral("window-new")), tr("&New Window"), settingOwner), + setup_Action(NEW_WINDOW, new QAction(QIcon::fromTheme(QLatin1String("window-new")), tr("&New Window"), settingOwner), NEW_WINDOW_SHORTCUT, this, SLOT(newTerminalWindow()), menu_File); menu_File->addSeparator(); @@ -384,7 +381,7 @@ void MainWindow::setup_FileMenu_Actions() menu_File->addSeparator(); - setup_Action(QUIT, new QAction(QIcon::fromTheme(QStringLiteral("application-exit")), tr("&Quit"), settingOwner), "", this, SLOT(close()), menu_File); + setup_Action(QUIT, new QAction(QIcon::fromTheme(QLatin1String("application-exit")), tr("&Quit"), settingOwner), "", this, SLOT(close()), menu_File); } void MainWindow::setup_ViewMenu_Actions() @@ -403,7 +400,7 @@ void MainWindow::setup_ViewMenu_Actions() setWindowFlags(windowFlags() ^ Qt::FramelessWindowHint); } else if (Properties::Instance()->borderless != windowFlags().testFlag(Qt::FramelessWindowHint)) - QTimer::singleShot(0, this, &MainWindow::toggleBorderless); // called by PropertiesDialog + QTimer::singleShot(0, this, SLOT(toggleBorderless())); // called by PropertiesDialog } setup_Action(HIDE_WINDOW_BORDERS, hideBordersAction, nullptr, this, SLOT(toggleBorderless()), menu_Window); @@ -447,19 +444,19 @@ void MainWindow::setup_ViewMenu_Actions() if( tabPosition->actions().count() > Properties::Instance()->tabsPos ) tabPosition->actions().at(Properties::Instance()->tabsPos)->setChecked(true); - connect(tabPosition, &QActionGroup::triggered, - consoleTabulator, &TabWidget::changeTabPosition); + connect(tabPosition, SIGNAL(triggered(QAction*)), + consoleTabulator, SLOT(changeTabPosition(QAction*))); if (tabPosMenu == nullptr) { tabPosMenu = new QMenu(tr("&Tabs Layout"), menu_Window); - tabPosMenu->setObjectName(QStringLiteral("tabPosMenu")); + tabPosMenu->setObjectName(QLatin1String("tabPosMenu")); for(int i=0; i < tabPosition->actions().size(); ++i) { tabPosMenu->addAction(tabPosition->actions().at(i)); } - connect(menu_Window, &QMenu::hovered, - this, &MainWindow::updateActionGroup); + connect(menu_Window, SIGNAL(hovered(QAction*)), + this, SLOT(updateActionGroup(QAction*))); } menu_Window->addMenu(tabPosMenu); /* */ @@ -480,13 +477,13 @@ void MainWindow::setup_ViewMenu_Actions() if( Properties::Instance()->scrollBarPos < scrollBarPosition->actions().size() ) scrollBarPosition->actions().at(Properties::Instance()->scrollBarPos)->setChecked(true); - connect(scrollBarPosition, &QActionGroup::triggered, - consoleTabulator, &TabWidget::changeScrollPosition); + connect(scrollBarPosition, SIGNAL(triggered(QAction*)), + consoleTabulator, SLOT(changeScrollPosition(QAction*))); } if (scrollPosMenu == nullptr) { scrollPosMenu = new QMenu(tr("S&crollbar Layout"), menu_Window); - scrollPosMenu->setObjectName(QStringLiteral("scrollPosMenu")); + scrollPosMenu->setObjectName(QLatin1String("scrollPosMenu")); for(int i=0; i < scrollBarPosition->actions().size(); ++i) { scrollPosMenu->addAction(scrollBarPosition->actions().at(i)); @@ -512,13 +509,13 @@ void MainWindow::setup_ViewMenu_Actions() if( Properties::Instance()->keyboardCursorShape < keyboardCursorShape->actions().size() ) keyboardCursorShape->actions().at(Properties::Instance()->keyboardCursorShape)->setChecked(true); - connect(keyboardCursorShape, &QActionGroup::triggered, - consoleTabulator, &TabWidget::changeKeyboardCursorShape); + connect(keyboardCursorShape, SIGNAL(triggered(QAction*)), + consoleTabulator, SLOT(changeKeyboardCursorShape(QAction*))); } if (keyboardCursorShapeMenu == nullptr) { keyboardCursorShapeMenu = new QMenu(tr("&Keyboard Cursor Shape"), menu_Window); - keyboardCursorShapeMenu->setObjectName(QStringLiteral("keyboardCursorShapeMenu")); + keyboardCursorShapeMenu->setObjectName(QLatin1String("keyboardCursorShapeMenu")); for(int i=0; i < keyboardCursorShape->actions().size(); ++i) { keyboardCursorShapeMenu->addAction(keyboardCursorShape->actions().at(i)); @@ -531,12 +528,15 @@ void MainWindow::setup_ViewMenu_Actions() void MainWindow::setupCustomDirs() { const QString appName = QCoreApplication::applicationName(); - QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, appName, - QStandardPaths::LocateDirectory); + QStringList dirs; + QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + if (!dataDir.isEmpty()) { + dirs << dataDir + QLatin1String("/") + appName; + } - dirs.removeDuplicates(); // QStandardPaths::locateAll() produces duplicates + dirs.removeDuplicates(); - for (const QString& dir : qAsConst(dirs)) { + foreach (const QString& dir, dirs) { TermWidgetImpl::addCustomColorSchemeDir(dir + QLatin1String("/color-schemes")); } // FIXME: To be deprecated and then removed @@ -620,15 +620,15 @@ void MainWindow::closeEvent(QCloseEvent *ev) // ask user for cancel only when there is at least one terminal active in this window QDialog * dia = new QDialog(this); - dia->setObjectName(QStringLiteral("exitDialog")); + dia->setObjectName(QLatin1String("exitDialog")); dia->setWindowTitle(tr("Exit QTerminal")); QCheckBox * dontAskCheck = new QCheckBox(tr("Do not ask again"), dia); QDialogButtonBox * buttonBox = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No, Qt::Horizontal, dia); buttonBox->button(QDialogButtonBox::Yes)->setDefault(true); - connect(buttonBox, &QDialogButtonBox::accepted, dia, &QDialog::accept); - connect(buttonBox, &QDialogButtonBox::rejected, dia, &QDialog::reject); + connect(buttonBox, SIGNAL(accepted()), dia, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), dia, SLOT(reject())); QVBoxLayout * lay = new QVBoxLayout(); lay->addWidget(new QLabel(tr("Are you sure you want to exit?"))); @@ -657,21 +657,21 @@ void MainWindow::closeEvent(QCloseEvent *ev) void MainWindow::actAbout_triggered() { QMessageBox::about(this, tr("About"), - QStringLiteral("
QTerminal %1

").arg(qApp->applicationVersion()) + QString::fromLatin1("
QTerminal %1

").arg(qApp->applicationVersion()) + tr("A lightweight and powerful multiplatform terminal emulator") - + QStringLiteral("

") + + QLatin1String("

") + tr("Copyright (C) ") + tr("2013-2022") - + QStringLiteral("
") + + QLatin1String("
") + tr("LXQt Project") - + QStringLiteral("

") + + QLatin1String("

") + tr("Development: ") - + QStringLiteral("https://github.com/lxqt/qterminal

")); + + QLatin1String("https://github.com/lxqt/qterminal

")); } void MainWindow::actProperties_triggered() { PropertiesDialog p(this); - connect(&p, &PropertiesDialog::propertiesChanged, this, &MainWindow::propertiesChanged); + connect(&p, SIGNAL(propertiesChanged()), this, SLOT(propertiesChanged())); p.exec(); } @@ -728,10 +728,8 @@ void MainWindow::realign() { if (m_dropMode) { - QScreen *appScreen = QGuiApplication::screenAt(QCursor::pos()); - if(appScreen == nullptr) - appScreen = QGuiApplication::primaryScreen(); - const QRect desktop = appScreen->availableGeometry(); + QDesktopWidget *desktopWidget = QApplication::desktop(); + QRect desktop = desktopWidget->availableGeometry(QCursor::pos()); QRect g = QRect(desktop.x(), desktop.y(), desktop.width() * Properties::Instance()->dropWidth / 100, @@ -790,9 +788,9 @@ void MainWindow::setKeepOpen(bool value) return; if (value) - m_dropLockButton->setIcon(QIcon::fromTheme(QStringLiteral("object-locked"))); + m_dropLockButton->setIcon(QIcon::fromTheme(QLatin1String("object-locked"))); else - m_dropLockButton->setIcon(QIcon::fromTheme(QStringLiteral("object-unlocked"))); + m_dropLockButton->setIcon(QIcon::fromTheme(QLatin1String("object-unlocked"))); m_dropLockButton->setChecked(value); } @@ -805,7 +803,7 @@ void MainWindow::find() void MainWindow::handleHistory() { - const QString dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + const QString dir = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); QDir().mkpath(dir); const QString fn = dir + QLatin1String("/qterminal.history.") + QString::number(QCoreApplication::applicationPid()); QFile file(fn); @@ -816,7 +814,7 @@ void MainWindow::handleHistory() TermWidgetImpl *impl = consoleTabulator->terminalHolder()->currentTerminal()->impl(); impl->saveHistory(&file); file.close(); - QStringList args = Properties::Instance()->handleHistoryCommand.split(QLatin1Char(' '), Qt::SkipEmptyParts); + QStringList args = Properties::Instance()->handleHistoryCommand.split(QLatin1Char(' '), QString::SkipEmptyParts); if (args.isEmpty()) return; @@ -898,8 +896,8 @@ void MainWindow::onCurrentTitleChanged(int index) title = consoleTabulator->tabText(index); icon = consoleTabulator->tabIcon(index); } - setWindowTitle(title.isEmpty() || !Properties::Instance()->changeWindowTitle ? QStringLiteral("QTerminal") : title); - setWindowIcon(icon.isNull() || !Properties::Instance()->changeWindowIcon ? QIcon::fromTheme(QStringLiteral("utilities-terminal")) : icon); + setWindowTitle(title.isEmpty() || !Properties::Instance()->changeWindowTitle ? QLatin1String("QTerminal") : title); + setWindowIcon(icon.isNull() || !Properties::Instance()->changeWindowIcon ? QIcon::fromTheme(QLatin1String("utilities-terminal")) : icon); } bool MainWindow::hasMultipleTabs(QAction *) diff --git a/src/properties.cpp b/src/properties.cpp index 841279c..57aa6b4 100644 --- a/src/properties.cpp +++ b/src/properties.cpp @@ -192,7 +192,7 @@ void Properties::saveSettings() const auto shortcuts = it.value()->shortcuts(); for (const QKeySequence &shortcut : shortcuts) sequenceStrings.append(shortcut.toString()); - m_settings->setValue(it.key(), sequenceStrings.join(QLatin1Char('|'))); + m_settings->setValue(it.key(), sequenceStrings.join(QLatin1String("|"))); } m_settings->endGroup(); @@ -383,7 +383,7 @@ void Properties::migrate_settings() void Properties::removeAccelerator(QString& str) { // Chinese, Japanese,... - str.remove(QRegularExpression(QStringLiteral("\\s*\\(&[a-zA-Z0-9]\\)\\s*"))); + str.remove(QRegExp(QLatin1String("\\s*\\(&[a-zA-Z0-9]\\)\\s*"))); // other languages str.remove(QLatin1Char('&')); } diff --git a/src/propertiesdialog.cpp b/src/propertiesdialog.cpp index 68565f0..5e1a64d 100644 --- a/src/propertiesdialog.cpp +++ b/src/propertiesdialog.cpp @@ -23,7 +23,9 @@ #include #include #include -#include +#include +#include +#include #include "propertiesdialog.h" #include "properties.h" @@ -36,7 +38,7 @@ void KeySequenceEdit::keyPressEvent(QKeyEvent* event) // by not allowing multiple shortcuts, // the Qt bug that makes Meta a non-modifier is worked around clear(); - QKeySequenceEdit::keyPressEvent(event); + QLineEdit::keyPressEvent(event); } Delegate::Delegate (QObject *parent) @@ -74,49 +76,51 @@ bool Delegate::eventFilter(QObject *object, QEvent *event) return QStyledItemDelegate::eventFilter (object, event); } +void PropertiesDialog::saveSizeOnExitStateChanged(int state) +{ + fixedSizeLabel->setEnabled(state == Qt::Unchecked); + xLabel->setEnabled(state == Qt::Unchecked); + fixedWithSpinBox->setEnabled(state == Qt::Unchecked); + fixedHeightSpinBox->setEnabled(state == Qt::Unchecked); + getCurrentSizeButton->setEnabled(state == Qt::Unchecked); +} + +void PropertiesDialog::getCurrentSizeClicked() +{ + QWidget *pw = parentWidget(); + if (pw != nullptr) + { + QSize pSize = pw->window()->geometry().size(); + fixedWithSpinBox->setValue(pSize.width()); + fixedHeightSpinBox->setValue(pSize.height()); + } +} + PropertiesDialog::PropertiesDialog(QWidget *parent) : QDialog(parent) { setupUi(this); - connect(buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, - this, &PropertiesDialog::apply); - connect(changeFontButton, &QPushButton::clicked, - this, &PropertiesDialog::changeFontButton_clicked); - connect(chooseBackgroundImageButton, &QPushButton::clicked, - this, &PropertiesDialog::chooseBackgroundImageButton_clicked); + connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), + this, SLOT(apply())); + connect(changeFontButton, SIGNAL(clicked()), + this, SLOT(changeFontButton_clicked())); + connect(chooseBackgroundImageButton, SIGNAL(clicked()), + this, SLOT(chooseBackgroundImageButton_clicked())); // fixed size - connect(saveSizeOnExitCheckBox, &QCheckBox::stateChanged, [this] (int state) { - fixedSizeLabel->setEnabled(state == Qt::Unchecked); - xLabel->setEnabled(state == Qt::Unchecked); - fixedWithSpinBox->setEnabled(state == Qt::Unchecked); - fixedHeightSpinBox->setEnabled(state == Qt::Unchecked); - getCurrentSizeButton->setEnabled(state == Qt::Unchecked); - }); - connect(getCurrentSizeButton, &QAbstractButton::clicked, [this, parent] { - if (parent != nullptr) - { - QSize pSize = parent->window()->geometry().size(); - fixedWithSpinBox->setValue(pSize.width()); - fixedHeightSpinBox->setValue(pSize.height()); - } - }); + connect(saveSizeOnExitCheckBox, SIGNAL(stateChanged(int)), + this, SLOT(saveSizeOnExitStateChanged(int))); + connect(getCurrentSizeButton, SIGNAL(clicked()), + this, SLOT(getCurrentSizeClicked())); + QSize ag; QSize minWinSize(0, 0); if (parent != nullptr) { minWinSize = parent->minimumSize(); - if (QWindow *win = parent->windowHandle()) - { - if (QScreen *sc = win->screen()) - { - ag = sc->availableVirtualGeometry().size() - // also consider the parent frame thickness because the parent window is fully formed - - (parent->window()->frameGeometry().size() - - parent->window()->geometry().size()); - } - } + QDesktopWidget *desktop = QApplication::desktop(); + ag = desktop->availableGeometry(parent).size(); } fixedWithSpinBox->setMinimum(minWinSize.width()); fixedHeightSpinBox->setMinimum(minWinSize.height()); @@ -128,7 +132,7 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) QStringList emulations = QTermWidget::availableKeyBindings(); QStringList colorSchemes = QTermWidget::availableColorSchemes(); - colorSchemes.sort(Qt::CaseInsensitive); + qSort(colorSchemes.begin(), colorSchemes.end()); listWidget->setCurrentRow(0); // resize the list widget to its content @@ -235,7 +239,9 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) audibleBellCheckBox->setEnabled(false); #endif - termComboBox->setCurrentText(Properties::Instance()->term); + int termIdx = termComboBox->findText(Properties::Instance()->term); + if (termIdx >= 0) + termComboBox->setCurrentIndex(termIdx); handleHistoryLineEdit->setText(Properties::Instance()->handleHistoryCommand); @@ -254,21 +260,21 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) dropShortCutEdit = new KeySequenceEdit(); dropShortCutFormLayout->setWidget(0, QFormLayout::FieldRole, dropShortCutEdit); dropShortCutEdit->installEventFilter(this); - dropShortCutEdit->setKeySequence(Properties::Instance()->dropShortCut); + dropShortCutEdit->setText(Properties::Instance()->dropShortCut.toString(QKeySequence::NativeText)); useBookmarksCheckBox->setChecked(Properties::Instance()->useBookmarks); bookmarksLineEdit->setText(Properties::Instance()->bookmarksFile); // also needed by openBookmarksFile() - connect(bookmarksLineEdit, &QLineEdit::editingFinished, - this, &PropertiesDialog::bookmarksPathEdited); // manual editing of bookmarks file path + connect(bookmarksLineEdit, SIGNAL(editingFinished()), + this, SLOT(bookmarksPathEdited())); // manual editing of bookmarks file path openBookmarksFile(); - connect(bookmarksButton, &QPushButton::clicked, - this, &PropertiesDialog::bookmarksButton_clicked); + connect(bookmarksButton, SIGNAL(clicked()), + this, SLOT(bookmarksButton_clicked())); exampleBookmarksButton = nullptr; #ifdef APP_DIR exampleBookmarksButton = new QPushButton(tr("Examples")); FindBookmarkLayout->addWidget(exampleBookmarksButton); - connect(exampleBookmarksButton, &QPushButton::clicked, - this, &PropertiesDialog::bookmarksButton_clicked); + connect(exampleBookmarksButton, SIGNAL(clicked()), + this, SLOT(bookmarksButton_clicked())); #endif terminalPresetComboBox->setCurrentIndex(Properties::Instance()->terminalsPreset); @@ -282,10 +288,7 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) confirmMultilinePasteCheckBox->setChecked(Properties::Instance()->confirmMultilinePaste); // save the size on canceling too (it's saved on accepting by apply()) - connect(this, &QDialog::rejected, [this] { - Properties::Instance()->prefDialogSize = size(); - Properties::Instance()->saveSettings(); - }); + connect(this, SIGNAL(rejected()), this, SLOT(onRejected())); // restore its size while fitting it into available desktop geometry QSize s; @@ -299,6 +302,11 @@ PropertiesDialog::PropertiesDialog(QWidget *parent) resize(s); } +void PropertiesDialog::onRejected() +{ + Properties::Instance()->prefDialogSize = size(); + Properties::Instance()->saveSettings(); +} PropertiesDialog::~PropertiesDialog() { @@ -376,7 +384,7 @@ void PropertiesDialog::apply() Properties::Instance()->dropKeepOpen = dropKeepOpenCheckBox->isChecked(); Properties::Instance()->dropHeight = dropHeightSpinBox->value(); Properties::Instance()->dropWidth = dropWidthSpinBox->value(); - Properties::Instance()->dropShortCut = dropShortCutEdit->keySequence(); + Properties::Instance()->dropShortCut = QKeySequence(dropShortCutEdit->text()); Properties::Instance()->useBookmarks = useBookmarksCheckBox->isChecked(); saveBookmarksFile(); @@ -477,7 +485,7 @@ void PropertiesDialog::setupShortcuts() QString txt = keyAction->text(); Properties::removeAccelerator(txt); QTableWidgetItem *itemName = new QTableWidgetItem(txt); - QTableWidgetItem *itemShortcut = new QTableWidgetItem( sequenceStrings.join(QLatin1Char('|')) ); + QTableWidgetItem *itemShortcut = new QTableWidgetItem( sequenceStrings.join(QLatin1String("|")) ); itemName->setFlags( itemName->flags() & ~Qt::ItemIsEditable & ~Qt::ItemIsSelectable ); @@ -566,7 +574,7 @@ void PropertiesDialog::openBookmarksFile() content = QString::fromLatin1("\n \n \n \n \n \n \n\n"); } else { - content = QString::fromUtf8(f.readAll()); + content = QString::fromUtf8(f.readAll().constData()); } bookmarkPlainEdit->setPlainText(content); @@ -611,7 +619,7 @@ void PropertiesDialog::saveBookmarksFile() QMessageBox::StandardButton btn = QMessageBox::Yes; if (fromAppDir) { btn = QMessageBox::question(this, tr("Question"), tr("Do you want to overwrite this bookmarks file?") - + QLatin1String("\n%1").arg(fname)); + + QString::fromLatin1("\n%1").arg(fname)); } else if (!fname.endsWith(QLatin1String(".xml"))) { btn = QMessageBox::question(this, tr("Question"), tr("The name of bookmarks file does not end with '.xml'.\nAre you sure that you want to overwrite it?")); @@ -623,7 +631,7 @@ void PropertiesDialog::saveBookmarksFile() if (!f.open(QFile::WriteOnly|QFile::Truncate)) { QMessageBox::warning(this, tr("Warning"), tr("Cannot write bookmarks to this file:") - + QLatin1String("\n%1").arg(fname)); + + QString::fromLatin1("\n%1").arg(fname)); } else { f.write(bookmarkPlainEdit->toPlainText().toUtf8()); diff --git a/src/propertiesdialog.h b/src/propertiesdialog.h index b1cc117..2368646 100644 --- a/src/propertiesdialog.h +++ b/src/propertiesdialog.h @@ -20,20 +20,21 @@ #define PROPERTIESDIALOG_H #include -#include +#include #include + #include "ui_propertiesdialog.h" -class KeySequenceEdit : public QKeySequenceEdit +class KeySequenceEdit : public QLineEdit { Q_OBJECT public: - KeySequenceEdit(QWidget *parent = nullptr) : QKeySequenceEdit(parent) {} + KeySequenceEdit(QWidget *parent = nullptr) : QLineEdit(parent) {} // to be used with Tab and Backtab void pressKey(QKeyEvent *event) { - QKeySequenceEdit::keyPressEvent(event); + QLineEdit::keyPressEvent(event); } protected: @@ -84,12 +85,13 @@ class PropertiesDialog : public QDialog, Ui::PropertiesDialog void chooseBackgroundImageButton_clicked(); void bookmarksPathEdited(); void bookmarksButton_clicked(); + void saveSizeOnExitStateChanged(int state); + void getCurrentSizeClicked(); + void onRejected(); protected: void setupShortcuts(); void saveShortcuts(); }; - #endif - diff --git a/src/qterminalutils.cpp b/src/qterminalutils.cpp index 62ce95e..3095654 100644 --- a/src/qterminalutils.cpp +++ b/src/qterminalutils.cpp @@ -15,50 +15,61 @@ * along with this program. If not, see . * ***************************************************************************/ -#include +#include #include "qterminalutils.h" QStringList parse_command(const QString& str) { - const QRegularExpression separator(QString::fromLatin1(R"('|(? index) { - list << str.mid(index, nextIndex - index).replace(escapedSpace, QStringLiteral(" ")); + QString part = str.mid(index, nextIndex - index); + part.replace(escapedSpace, QLatin1String(" ")); + list << part; } - if (match.capturedLength() == 0) - { // end of string ("\z") is matched + if (separator.cap(0).isEmpty()) + { // end of string break; } - index = nextIndex + match.capturedLength(); - auto c = str.at(index - 1); // last matched character + index = nextIndex + separator.matchedLength(); + QChar c = str.at(index - 1); if (!c.isSpace()) - { // a single quote or an unescaped double quote is matched - nextIndex = str.indexOf(c == QLatin1Char('\'') ? singleQuote : doubleQuote, index, &match); - if (nextIndex == -1) - { // the quote is not closed + { + int quoteIndex = -1; + if (c == QLatin1Char('\'')) + { + quoteIndex = singleQuote.indexIn(str, index); + } + else + { + quoteIndex = doubleQuote.indexIn(str, index); + } + if (quoteIndex == -1) + { break; } else { - if (nextIndex > index) + if (quoteIndex > index) { - list << str.mid(index, nextIndex - index).replace(escapedSpace, QStringLiteral(" ")); + QString part = str.mid(index, quoteIndex - index); + part.replace(escapedSpace, QLatin1String(" ")); + list << part; } - index = nextIndex + match.capturedLength(); + index = quoteIndex + (c == QLatin1Char('\'') ? singleQuote.matchedLength() : doubleQuote.matchedLength()); } } } return list; } - diff --git a/src/tab-switcher.cpp b/src/tab-switcher.cpp index 1a8f471..0cde8a6 100644 --- a/src/tab-switcher.cpp +++ b/src/tab-switcher.cpp @@ -57,14 +57,13 @@ public: protected: void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override { - QStyle *style = option.widget ? option.widget->style() : QApplication::style(); + QStyle *style = QApplication::style(); QString text = index.model()->data(index, static_cast(AppRole::Display)).toString(); QStyleOptionViewItem opt = option; initStyleOption(&opt, index); - opt.text = text; - style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, option.widget); + style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, NULL); } QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override @@ -72,10 +71,8 @@ protected: QStyleOptionViewItem opt = option; initStyleOption(&opt, index); opt.decorationSize = QSize(0, 0); - opt.text = index.model()->data(index, static_cast(AppRole::Display)).toString();; - const QWidget* widget = option.widget; - QStyle* style = widget ? widget->style() : QApplication::style(); - QSize contSize = style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), widget); + QStyle* style = QApplication::style(); + QSize contSize = style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), 0); return QSize( mParent ? qMin(mParent->width() - 2 * mFrameWidth, contSize.width()) : contSize.width(), @@ -101,7 +98,7 @@ TabSwitcher::TabSwitcher(TabWidget* tabs): m_timer->setInterval(100); m_timer->setSingleShot(true); - connect(m_timer, &QTimer::timeout, this, &TabSwitcher::timer); + connect(m_timer, SIGNAL(timeout()), this, SLOT(timer())); } TabSwitcher::~TabSwitcher() @@ -128,7 +125,6 @@ void TabSwitcher::showSwitcher() break; } - w += 2 * frameWidth(); h += 2 * frameWidth(); resize(w, h); @@ -182,4 +178,3 @@ void TabSwitcher::closeEvent(QCloseEvent *) } // ----------------------------------------------------------------------------------------------------------- - diff --git a/src/tab-switcher.h b/src/tab-switcher.h index 17d3b9b..d7162b6 100644 --- a/src/tab-switcher.h +++ b/src/tab-switcher.h @@ -10,6 +10,7 @@ class TabWidget; class AppModel : public QAbstractListModel { Q_OBJECT + public: AppModel(QObject* parent, TabWidget* tabs); @@ -46,6 +47,8 @@ protected: private: void showSwitcher(); + +private slots: void timer(); private: @@ -54,4 +57,3 @@ private: }; // ----------------------------------------------------------------------------------------------------------- - diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 16c1e0d..5a13e33 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -29,7 +29,7 @@ TabBar::TabBar(QWidget *parent) QFont f = font(); f.setBold(true); setFont(f); - setStyleSheet(QStringLiteral("QTabBar::tab:!selected { font-weight: normal; }")); + setStyleSheet(QLatin1String("QTabBar::tab:!selected { font-weight: normal; }")); } void TabBar::setFixedWidth(bool fixedWidth) diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 31bbc41..12fe013 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -55,25 +55,22 @@ TabWidget::TabWidget(QWidget* parent) : QTabWidget(parent), tabNumerator(0), mTa tabBar()->installEventFilter(this); - connect(this, &TabWidget::tabCloseRequested, this, &TabWidget::removeTab); - connect(tabBar(), &QTabBar::tabMoved, this, &TabWidget::updateTabIndices); - connect(this, &TabWidget::tabRenameRequested, this, &TabWidget::renameSession); - connect(this, &TabWidget::tabTitleColorChangeRequested, this, &TabWidget::setTitleColor); - connect(mSwitcher.data(), &TabSwitcher::activateTab, this, &TabWidget::switchTab); - connect(this, &TabWidget::currentChanged, this, &TabWidget::onCurrentChanged); + connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(removeTab(int))); + connect(tabBar(), SIGNAL(tabMoved(int,int)), this, SLOT(updateTabIndices())); + connect(this, SIGNAL(tabRenameRequested(int)), this, SLOT(renameSession(int))); + connect(this, SIGNAL(tabTitleColorChangeRequested(int)), this, SLOT(setTitleColor(int))); + connect(mSwitcher.data(), SIGNAL(activateTab(int)), this, SLOT(switchTab(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(onCurrentChanged(int))); } TabWidget::~TabWidget() -{ - QObject::disconnect(mFocusConnection); -} +{} TermWidgetHolder * TabWidget::terminalHolder() { return reinterpret_cast(widget(currentIndex())); } - int TabWidget::addNewTab(TerminalConfig config) { tabNumerator++; @@ -85,10 +82,11 @@ int TabWidget::addNewTab(TerminalConfig config) TermWidgetHolder *console = new TermWidgetHolder(config, this); console->setWindowTitle(label); - connect(console, &TermWidgetHolder::finished, this, &TabWidget::removeFinished); - connect(console, &TermWidgetHolder::lastTerminalClosed, this, &TabWidget::removeFinished); - connect(console, &TermWidgetHolder::termTitleChanged, this, &TabWidget::onTermTitleChanged); - connect(this, &QTabWidget::currentChanged, this, &TabWidget::currentTitleChanged); + connect(console, SIGNAL(finished()), this, SLOT(removeFinished())); + connect(console, SIGNAL(lastTerminalClosed()), this, SLOT(removeFinished())); + connect(console, SIGNAL(termTitleChanged(const QString&, const QString&)), + this, SLOT(onTermTitleChanged(const QString&, const QString&))); + connect(this, SIGNAL(currentChanged(int)), this, SIGNAL(currentTitleChanged(int))); const int newIndex = (Properties::Instance()->m_openNewTabRightToActiveTab ? currentIndex() + 1 : count()); const int index = insertTab(newIndex, console, label); @@ -249,9 +247,9 @@ void TabWidget::contextMenuEvent(QContextMenuEvent *event) QMenu menu(this); QMap< QString, QAction * > actions = findParent(this)->leaseActions(); - QAction *close = menu.addAction(QIcon::fromTheme(QStringLiteral("document-close")), tr("Close session")); + QAction *close = menu.addAction(QIcon::fromTheme(QLatin1String("document-close")), tr("Close session")); QAction *rename = menu.addAction(actions[QLatin1String(RENAME_SESSION)]->text()); - QAction *changeColor = menu.addAction(QIcon::fromTheme(QStringLiteral("color-management")), tr("Change title color")); + QAction *changeColor = menu.addAction(QIcon::fromTheme(QLatin1String("color-management")), tr("Change title color")); rename->setShortcut(actions[QLatin1String(RENAME_SESSION)]->shortcut()); rename->blockSignals(true); @@ -537,15 +535,9 @@ void TabWidget::preset2Horizontal() int ix = TabWidget::addNewTab(defaultConfig); TermWidgetHolder* term = reinterpret_cast(widget(ix)); - // NOTE: When splitting happens, the focus changes. Therefore, we should switch to - // the 1st terminal only when the window is activated and the focus has really changed. - QObject::disconnect(mFocusConnection); - mFocusConnection = connect(term, &TermWidgetHolder::termFocusChanged, this, [this, term] { - QObject::disconnect(mFocusConnection); - term->directionalNavigation(NavigationDirection::Top); - }); - term->splitHorizontal(term->currentTerminal()); + // switch to the 1st terminal + term->directionalNavigation(NavigationDirection::Left); } void TabWidget::preset2Vertical() @@ -554,14 +546,9 @@ void TabWidget::preset2Vertical() int ix = TabWidget::addNewTab(defaultConfig); TermWidgetHolder* term = reinterpret_cast(widget(ix)); - // see preset2Horizontal() for an explanation - QObject::disconnect(mFocusConnection); - mFocusConnection = connect(term, &TermWidgetHolder::termFocusChanged, this, [this, term] { - QObject::disconnect(mFocusConnection); - term->directionalNavigation(NavigationDirection::Left); - }); - term->splitVertical(term->currentTerminal()); + // switch to the 1st terminal + term->directionalNavigation(NavigationDirection::Left); } void TabWidget::preset4Terminals() @@ -569,21 +556,13 @@ void TabWidget::preset4Terminals() TerminalConfig defaultConfig; int ix = TabWidget::addNewTab(defaultConfig); TermWidgetHolder* term = reinterpret_cast(widget(ix)); - - // see preset2Horizontal() for an explanation - // Waiting for the first focus change is enough because, after it happens, - // the window is active and the other events happen serially. - QObject::disconnect(mFocusConnection); - mFocusConnection = connect(term, &TermWidgetHolder::termFocusChanged, this, [this, term] { - QObject::disconnect(mFocusConnection); - term->splitHorizontal(term->currentTerminal()); - term->directionalNavigation(NavigationDirection::Left); - term->splitHorizontal(term->currentTerminal()); - // switch to the 1st terminal (the focus is already changed) - term->directionalNavigation(NavigationDirection::Top); - }); - term->splitVertical(term->currentTerminal()); + term->splitHorizontal(term->currentTerminal()); + term->directionalNavigation(NavigationDirection::Left); + + term->splitHorizontal(term->currentTerminal()); + // switch to the 1st terminal + term->directionalNavigation(NavigationDirection::Top); } void TabWidget::showHideTabBar() diff --git a/src/tabwidget.h b/src/tabwidget.h index 2be6248..d61fcf3 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -40,6 +40,7 @@ class TabSwitcher; class TabWidget : public QTabWidget { Q_OBJECT + public: TabWidget(QWidget* parent = nullptr); ~TabWidget() override; @@ -97,6 +98,7 @@ public slots: void switchToNext(); void switchToPrev(); + signals: void closeLastTabNotification(); void tabRenameRequested(int); @@ -113,6 +115,7 @@ protected: renaming or new tab opening */ bool eventFilter(QObject *obj, QEvent *event) override; + protected slots: void updateTabIndices(); void onTermTitleChanged(const QString& title, const QString& icon); @@ -126,8 +129,6 @@ private: TabBar *mTabBar; QScopedPointer mSwitcher; QList mHistory; - - QMetaObject::Connection mFocusConnection; }; #endif diff --git a/src/terminalconfig.cpp b/src/terminalconfig.cpp index 1497a29..0b13a84 100644 --- a/src/terminalconfig.cpp +++ b/src/terminalconfig.cpp @@ -41,7 +41,7 @@ QStringList TerminalConfig::getShell() QByteArray envShell = qgetenv("SHELL"); if (envShell.constData() != nullptr) { - QString shellString = QString::fromLocal8Bit(envShell).trimmed(); + QString shellString = QString::fromLocal8Bit(envShell.constData()).trimmed(); if (!shellString.isEmpty()) return QStringList{shellString}; } diff --git a/src/termwidget.cpp b/src/termwidget.cpp index 309b384..ee66ada 100644 --- a/src/termwidget.cpp +++ b/src/termwidget.cpp @@ -51,7 +51,7 @@ TermWidgetImpl::TermWidgetImpl(TerminalConfig &cfg, QWidget * parent) #endif { TermWidgetCount++; - QString name(QStringLiteral("TermWidget_%1")); + QString name(QLatin1String("TermWidget_%1")); setObjectName(name.arg(TermWidgetCount)); setFlowControlEnabled(FLOW_CONTROL_ENABLED); @@ -70,26 +70,27 @@ TermWidgetImpl::TermWidgetImpl(TerminalConfig &cfg, QWidget * parent) setArgs(shell); } - setEnvironment(QStringList(QStringLiteral("TERM=%1").arg(Properties::Instance()->term))); + setEnvironment(QStringList(QString::fromLatin1("TERM=%1").arg(Properties::Instance()->term))); setMotionAfterPasting(Properties::Instance()->m_motionAfterPaste); disableBracketedPasteMode(Properties::Instance()->m_disableBracketedPasteMode); setContextMenuPolicy(Qt::CustomContextMenu); - if(Properties::Instance()->swapMouseButtons2and3) + if (Properties::Instance()->swapMouseButtons2and3) { - connect(this, &QWidget::customContextMenuRequested, - this, &TermWidgetImpl::pasteSelection); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(pasteSelection())); } else { - connect(this, &QWidget::customContextMenuRequested, - this, &TermWidgetImpl::customContextMenuCall); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(customContextMenuCall(const QPoint &))); } - connect(this, &QTermWidget::urlActivated, this, &TermWidgetImpl::activateUrl); - connect(this, &QTermWidget::bell, this, &TermWidgetImpl::bell); + connect(this, SIGNAL(urlActivated(const QUrl &, bool)), + this, SLOT(activateUrl(const QUrl &, bool))); + connect(this, SIGNAL(bell()), this, SLOT(bell())); startShellProgram(); } @@ -183,22 +184,22 @@ void TermWidgetImpl::customContextMenuCall(const QPoint & pos) menu.addSeparator(); } - menu.addAction(actions[QStringLiteral(COPY_SELECTION)]); - menu.addAction(actions[QStringLiteral(PASTE_CLIPBOARD)]); - menu.addAction(actions[QStringLiteral(PASTE_SELECTION)]); - menu.addAction(actions[QStringLiteral(ZOOM_IN)]); - menu.addAction(actions[QStringLiteral(ZOOM_OUT)]); - menu.addAction(actions[QStringLiteral(ZOOM_RESET)]); + menu.addAction(actions[QLatin1String(COPY_SELECTION)]); + menu.addAction(actions[QLatin1String(PASTE_CLIPBOARD)]); + menu.addAction(actions[QLatin1String(PASTE_SELECTION)]); + menu.addAction(actions[QLatin1String(ZOOM_IN)]); + menu.addAction(actions[QLatin1String(ZOOM_OUT)]); + menu.addAction(actions[QLatin1String(ZOOM_RESET)]); menu.addSeparator(); - menu.addAction(actions[QStringLiteral(CLEAR_TERMINAL)]); - menu.addAction(actions[QStringLiteral(SPLIT_HORIZONTAL)]); - menu.addAction(actions[QStringLiteral(SPLIT_VERTICAL)]); + menu.addAction(actions[QLatin1String(CLEAR_TERMINAL)]); + menu.addAction(actions[QLatin1String(SPLIT_HORIZONTAL)]); + menu.addAction(actions[QLatin1String(SPLIT_VERTICAL)]); // warning TODO/FIXME: disable the action when there is only one terminal - menu.addAction(actions[QStringLiteral(SUB_COLLAPSE)]); + menu.addAction(actions[QLatin1String(SUB_COLLAPSE)]); menu.addSeparator(); - menu.addAction(actions[QStringLiteral(TOGGLE_MENU)]); - menu.addAction(actions[QStringLiteral(HIDE_WINDOW_BORDERS)]); - menu.addAction(actions[QStringLiteral(PREFERENCES)]); + menu.addAction(actions[QLatin1String(TOGGLE_MENU)]); + menu.addAction(actions[QLatin1String(HIDE_WINDOW_BORDERS)]); + menu.addAction(actions[QLatin1String(PREFERENCES)]); menu.exec(mapToGlobal(pos)); } @@ -270,7 +271,7 @@ bool TermWidget::eventFilter(QObject * /*obj*/, QEvent * ev) TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) : QWidget(parent), - DBusAddressable(QStringLiteral("/terminals")) + DBusAddressable(QLatin1String("/terminals")) { #ifdef HAVE_QDBUS @@ -298,10 +299,14 @@ TermWidget::TermWidget(TerminalConfig &cfg, QWidget * parent) propertiesChanged(); - connect(m_term, &QTermWidget::finished, this, &TermWidget::finished); - connect(m_term, &QTermWidget::termGetFocus, this, &TermWidget::term_termGetFocus); - connect(m_term, &QTermWidget::termLostFocus, this, &TermWidget::term_termLostFocus); - connect(m_term, &QTermWidget::titleChanged, this, [this] { emit termTitleChanged(m_term->title(), m_term->icon()); }); + connect(m_term, SIGNAL(finished()), this, SIGNAL(finished())); + connect(m_term, SIGNAL(termGetFocus()), this, SLOT(term_termGetFocus())); + connect(m_term, SIGNAL(termLostFocus()), this, SLOT(term_termLostFocus())); + connect(m_term, SIGNAL(titleChanged()), this, SLOT(onTitleChanged())); +} + +void TermWidget::onTitleChanged() { + emit termTitleChanged(m_term->title(), m_term->icon()); } void TermWidget::propertiesChanged() diff --git a/src/termwidget.h b/src/termwidget.h index 75600b7..3300bf3 100644 --- a/src/termwidget.h +++ b/src/termwidget.h @@ -37,7 +37,6 @@ class TermWidgetImpl : public QTermWidget // QMap< QString, QAction * > actionMap; public: - TermWidgetImpl(TerminalConfig &cfg, QWidget * parent=nullptr); virtual ~TermWidgetImpl(); void propertiesChanged(); @@ -52,7 +51,7 @@ class TermWidgetImpl : public QTermWidget void zoomReset(); void customContextMenuCall(const QPoint & pos); - private slots: + private slots: void activateUrl(const QUrl& url, bool fromContextMenu); void bell(); @@ -62,7 +61,6 @@ class TermWidgetImpl : public QTermWidget #endif }; - class TermWidget : public QWidget, public DBusAddressable { Q_OBJECT @@ -99,8 +97,6 @@ class TermWidget : public QWidget, public DBusAddressable void termGetFocus(TermWidget * self); void termTitleChanged(QString titleText, QString icon); - public slots: - protected: bool focusNextPrevChild(bool) override { // prevent focus change with Tab and, especially, Backtab @@ -111,7 +107,7 @@ class TermWidget : public QWidget, public DBusAddressable private slots: void term_termGetFocus(); void term_termLostFocus(); + void onTitleChanged(); }; #endif - diff --git a/src/termwidgetholder.cpp b/src/termwidgetholder.cpp index 95c556c..04e65c0 100644 --- a/src/termwidgetholder.cpp +++ b/src/termwidgetholder.cpp @@ -39,7 +39,7 @@ TermWidgetHolder::TermWidgetHolder(TerminalConfig &config, QWidget * parent) : QWidget(parent) #ifdef HAVE_QDBUS - , DBusAddressable(QStringLiteral("/tabs")) + , DBusAddressable(QLatin1String("/tabs")) #endif { #ifdef HAVE_QDBUS @@ -201,7 +201,7 @@ void TermWidgetHolder::directionalNavigation(NavigationDirection dir) { // Find an active widget QList l = findChildren(); int ix = -1; - for (TermWidget * w : qAsConst(l)) + foreach (TermWidget * w, l) { ++ix; if (w->impl()->hasFocus()) @@ -233,7 +233,7 @@ void TermWidgetHolder::directionalNavigation(NavigationDirection dir) { int lowestX = INT_MAX; int lowestMidpointDistance = INT_MAX; TermWidget *fittest = nullptr; - for (TermWidget * w : qAsConst(l)) + foreach (TermWidget * w, l) { NavigationData contenderDims = getNormalizedDimensions(w, dir); int midpointDistance = std::min( @@ -287,13 +287,13 @@ void TermWidgetHolder::splitCollapse(TermWidget * term) term->setParent(nullptr); delete term; - QWidget *nextFocus = Q_NULLPTR; + QWidget *nextFocus = nullptr; // Collapse splitters containing a single element, excluding the top one. if (parent->count() == 1) { QSplitter *uselessSplitterParent = qobject_cast(parent->parent()); - if (uselessSplitterParent != Q_NULLPTR) { + if (uselessSplitterParent != nullptr) { int idx = uselessSplitterParent->indexOf(parent); assert(idx != -1); QWidget *singleHeir = parent->widget(0); @@ -361,18 +361,16 @@ TermWidget *TermWidgetHolder::newTerm(TerminalConfig &cfg) { TermWidget *w = new TermWidget(cfg, this); // proxy signals - connect(w, &TermWidget::renameSession, this, &TermWidgetHolder::renameSession); - connect(w, &TermWidget::removeCurrentSession, this, &TermWidgetHolder::lastTerminalClosed); - connect(w, &TermWidget::finished, this, &TermWidgetHolder::handle_finished); - // consume signals - - connect(w, static_cast(&TermWidget::splitHorizontal), - this, &TermWidgetHolder::splitHorizontal); - connect(w, static_cast(&TermWidget::splitVertical), - this, &TermWidgetHolder::splitVertical); - connect(w, &TermWidget::splitCollapse, this, &TermWidgetHolder::splitCollapse); - connect(w, &TermWidget::termGetFocus, this, &TermWidgetHolder::setCurrentTerminal); - connect(w, &TermWidget::termTitleChanged, this, &TermWidgetHolder::onTermTitleChanged); + connect(w, SIGNAL(renameSession(int)), this, SLOT(renameSession(int))); + connect(w, SIGNAL(removeCurrentSession()), this, SIGNAL(lastTerminalClosed())); + connect(w, SIGNAL(finished()), this, SLOT(handle_finished())); + + // Overloaded signals/slots with TermWidget* + connect(w, SIGNAL(splitHorizontal(TermWidget*)), this, SLOT(splitHorizontal(TermWidget*))); + connect(w, SIGNAL(splitVertical(TermWidget*)), this, SLOT(splitVertical(TermWidget*))); + connect(w, SIGNAL(splitCollapse(TermWidget*)), this, SLOT(splitCollapse(TermWidget*))); + connect(w, SIGNAL(termGetFocus(TermWidget*)), this, SLOT(setCurrentTerminal(TermWidget*))); + connect(w, SIGNAL(termTitleChanged(QString,QString)), this, SLOT(onTermTitleChanged(QString,QString))); return w; } @@ -390,7 +388,6 @@ void TermWidgetHolder::setCurrentTerminal(TermWidget* term) { Q_EMIT termTitleChanged(windowTitle(), QString{}); } - Q_EMIT termFocusChanged(); } } @@ -447,4 +444,3 @@ void TermWidgetHolder::closeTab() } #endif - diff --git a/src/termwidgetholder.h b/src/termwidgetholder.h index 9299300..7e97bcc 100644 --- a/src/termwidgetholder.h +++ b/src/termwidgetholder.h @@ -23,9 +23,8 @@ #include "termwidget.h" #include "terminalconfig.h" #include "dbusaddressable.h" -class QSplitter; - +class QSplitter; typedef enum NavigationDirection { Left, @@ -34,7 +33,6 @@ typedef enum NavigationDirection { Bottom } NavigationDirection; - /*! \brief TermWidget group/session manager. This widget (one per TabWidget tab) is a "proxy" widget between TabWidget and @@ -72,7 +70,6 @@ class TermWidgetHolder : public QWidget void closeTab(); #endif - public slots: void splitHorizontal(TermWidget * term); void splitVertical(TermWidget * term); @@ -103,4 +100,3 @@ class TermWidgetHolder : public QWidget }; #endif - diff --git a/src/third-party/qxtglobalshortcut_p.h b/src/third-party/qxtglobalshortcut_p.h index 45cc2b2..078edbe 100644 --- a/src/third-party/qxtglobalshortcut_p.h +++ b/src/third-party/qxtglobalshortcut_p.h @@ -33,15 +33,11 @@ #include "qxtglobalshortcut.h" #include -#include #include #include class QxtGlobalShortcutPrivate : public QxtPrivate -#if !defined(Q_OS_MAC) - ,public QAbstractNativeEventFilter -#endif { public: QXT_DECLARE_PUBLIC(QxtGlobalShortcut) diff --git a/src/third-party/qxtglobalshortcut_x11.cpp b/src/third-party/qxtglobalshortcut_x11.cpp index ecaf5c3..9301607 100644 --- a/src/third-party/qxtglobalshortcut_x11.cpp +++ b/src/third-party/qxtglobalshortcut_x11.cpp @@ -100,7 +100,7 @@ public: bool isValid() { - return QGuiApplication::platformName() == QStringLiteral("xcb") && m_display != nullptr; + return m_display != NULL; } Display *display() @@ -135,7 +135,7 @@ public: { QxtX11ErrorHandler errorHandler; - for (const quint32& maskMods : qAsConst(maskModifiers)) { + foreach (quint32 maskMods, maskModifiers) { XUngrabKey(display(), keycode, modifiers | maskMods, window); } -- 2.49.0