- enhancement: Let encoding options in the statusbar more explicit.

change FileEndingType names
  applySettings shouldn't be called every time show event triggered.
This commit is contained in:
Roy Qu 2023-01-04 09:08:58 +08:00
parent f179f45cd9
commit 4f2fb8f540
5 changed files with 35 additions and 4 deletions

View File

@ -111,6 +111,7 @@ MainWindow* pMainWindow;
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), : QMainWindow(parent),
ui(new Ui::MainWindow), ui(new Ui::MainWindow),
mFullInitialized(false),
mSearchInFilesDialog(nullptr), mSearchInFilesDialog(nullptr),
mSearchDialog(nullptr), mSearchDialog(nullptr),
mReplaceDialog(nullptr), mReplaceDialog(nullptr),
@ -5296,6 +5297,9 @@ void MainWindow::closeEvent(QCloseEvent *event) {
void MainWindow::showEvent(QShowEvent *) void MainWindow::showEvent(QShowEvent *)
{ {
if (mFullInitialized)
return;
mFullInitialized = true;
applySettings(); applySettings();
const Settings::UI& settings = pSettings->ui(); const Settings::UI& settings = pSettings->ui();
ui->tabMessages->setCurrentIndex(settings.bottomPanelIndex()); ui->tabMessages->setCurrentIndex(settings.bottomPanelIndex());

View File

@ -772,6 +772,7 @@ private slots:
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
bool mFullInitialized;
EditorList *mEditorList; EditorList *mEditorList;
QLabel *mFileInfoStatus; QLabel *mFileInfoStatus;
LabelWithMenu *mFileEncodingStatus; LabelWithMenu *mFileEncodingStatus;

View File

@ -22,7 +22,7 @@
LabelWithMenu::LabelWithMenu(QWidget* parent):QLabel(parent) LabelWithMenu::LabelWithMenu(QWidget* parent):QLabel(parent)
{ {
mCursor = Qt::ArrowCursor;
} }
void LabelWithMenu::mousePressEvent(QMouseEvent *event) void LabelWithMenu::mousePressEvent(QMouseEvent *event)
@ -32,3 +32,21 @@ void LabelWithMenu::mousePressEvent(QMouseEvent *event)
QApplication::instance()->postEvent(this,e); QApplication::instance()->postEvent(this,e);
event->accept(); 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);
}

View File

@ -28,6 +28,14 @@ public:
// QWidget interface // QWidget interface
protected: protected:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
// QWidget interface
protected:
void enterEvent(QEvent *event) override;
void leaveEvent(QEvent *event) override;
private:
QCursor mCursor;
}; };
#endif // LABELWITHMENU_H #endif // LABELWITHMENU_H

View File

@ -38,9 +38,9 @@ class QTextCodec;
enum class FileEndingType { enum class FileEndingType {
Windows, Windows,
Linux, Unix,
Mac MacOld
};// Windows: CRLF, UNIX: LF, Mac: CR };// Windows: CRLF, UNIX: LF, Old Mac OS: CR (old mac os, not mac os x)
class BaseError{ class BaseError{
public: public: