- 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)
: 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());

View File

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

View File

@ -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);
}

View File

@ -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

View File

@ -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: