From 4f2fb8f540bedc8cd39580e4ab5b56472c1a69b9 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 4 Jan 2023 09:08:58 +0800 Subject: [PATCH] - enhancement: Let encoding options in the statusbar more explicit. change FileEndingType names applySettings shouldn't be called every time show event triggered. --- RedPandaIDE/mainwindow.cpp | 4 ++++ RedPandaIDE/mainwindow.h | 1 + RedPandaIDE/widgets/labelwithmenu.cpp | 20 +++++++++++++++++++- RedPandaIDE/widgets/labelwithmenu.h | 8 ++++++++ libs/redpanda_qt_utils/qt_utils/utils.h | 6 +++--- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index c098916a..9eed6dbb 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -111,6 +111,7 @@ MainWindow* pMainWindow; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), + mFullInitialized(false), mSearchInFilesDialog(nullptr), mSearchDialog(nullptr), mReplaceDialog(nullptr), @@ -5296,6 +5297,9 @@ void MainWindow::closeEvent(QCloseEvent *event) { void MainWindow::showEvent(QShowEvent *) { + if (mFullInitialized) + return; + mFullInitialized = true; applySettings(); const Settings::UI& settings = pSettings->ui(); ui->tabMessages->setCurrentIndex(settings.bottomPanelIndex()); diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index a4827224..8ab87452 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -772,6 +772,7 @@ private slots: private: Ui::MainWindow *ui; + bool mFullInitialized; EditorList *mEditorList; QLabel *mFileInfoStatus; LabelWithMenu *mFileEncodingStatus; diff --git a/RedPandaIDE/widgets/labelwithmenu.cpp b/RedPandaIDE/widgets/labelwithmenu.cpp index 2f41a5dd..60ceedee 100644 --- a/RedPandaIDE/widgets/labelwithmenu.cpp +++ b/RedPandaIDE/widgets/labelwithmenu.cpp @@ -22,7 +22,7 @@ LabelWithMenu::LabelWithMenu(QWidget* parent):QLabel(parent) { - + mCursor = Qt::ArrowCursor; } void LabelWithMenu::mousePressEvent(QMouseEvent *event) @@ -32,3 +32,21 @@ void LabelWithMenu::mousePressEvent(QMouseEvent *event) QApplication::instance()->postEvent(this,e); event->accept(); } + +void LabelWithMenu::enterEvent(QEvent *event) +{ + mCursor = cursor(); + setCursor(Qt::PointingHandCursor); + setTextInteractionFlags(Qt::TextInteractionFlag::TextSelectableByKeyboard); + setSelection(0,text().length()); + QLabel::enterEvent(event); +} + +void LabelWithMenu::leaveEvent(QEvent *event) +{ + setCursor(mCursor); + mCursor = Qt::ArrowCursor; + setSelection(0,0); + setTextInteractionFlags(Qt::TextInteractionFlag::NoTextInteraction); + QLabel::leaveEvent(event); +} diff --git a/RedPandaIDE/widgets/labelwithmenu.h b/RedPandaIDE/widgets/labelwithmenu.h index 605fa193..6e00cfc8 100644 --- a/RedPandaIDE/widgets/labelwithmenu.h +++ b/RedPandaIDE/widgets/labelwithmenu.h @@ -28,6 +28,14 @@ public: // QWidget interface protected: void mousePressEvent(QMouseEvent *event) override; + + // QWidget interface +protected: + void enterEvent(QEvent *event) override; + void leaveEvent(QEvent *event) override; + +private: + QCursor mCursor; }; #endif // LABELWITHMENU_H diff --git a/libs/redpanda_qt_utils/qt_utils/utils.h b/libs/redpanda_qt_utils/qt_utils/utils.h index 8b2e4adf..554a0c69 100644 --- a/libs/redpanda_qt_utils/qt_utils/utils.h +++ b/libs/redpanda_qt_utils/qt_utils/utils.h @@ -38,9 +38,9 @@ class QTextCodec; enum class FileEndingType { Windows, - Linux, - Mac -};// Windows: CRLF, UNIX: LF, Mac: CR + Unix, + MacOld +};// Windows: CRLF, UNIX: LF, Old Mac OS: CR (old mac os, not mac os x) class BaseError{ public: