diff --git a/editor/src/editor.cpp b/editor/src/editor.cpp index 39297056..2a5408d5 100644 --- a/editor/src/editor.cpp +++ b/editor/src/editor.cpp @@ -51,13 +51,22 @@ void Editor::loadFile(const QString &filepath) QFile file(filepath); if (file.open(QFile::ReadOnly)) { - auto fileContent = file.readAll(); + // set mouse status to wait. + QApplication::setOverrideCursor(Qt::WaitCursor); + + // reads all remaining data from the file. + QByteArray fileContent = file.readAll(); + + // read the encode. m_fileEncode = Utils::getFileEncode(fileContent, filepath); QTextStream stream(&fileContent); stream.setCodec(m_fileEncode); textEditor->setPlainText(stream.readAll()); + // restore mouse style. + QApplication::restoreOverrideCursor(); + updatePath(filepath); detectNewline(); diff --git a/editor/src/window.cpp b/editor/src/window.cpp index caf7288c..735fc485 100644 --- a/editor/src/window.cpp +++ b/editor/src/window.cpp @@ -63,13 +63,17 @@ Window::Window(DMainWindow *parent) m_titlebarStyleSheet(titlebar()->styleSheet()), m_themeName(m_settings->settings->option("base.theme.default")->value().toString()) { + m_blankFileDir = QDir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first()).filePath("blank-files"); + m_readonlyFileDir = QDir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first()).filePath("readonly-files"); + autoSaveDBus = new DBusDaemon::dbus("com.deepin.editor.daemon", "/", QDBusConnection::systemBus(), this); + // Init. installEventFilter(this); setAcceptDrops(true); - m_blankFileDir = QDir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first()).filePath("blank-files"); - m_readonlyFileDir = QDir(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first()).filePath("readonly-files"); - autoSaveDBus = new DBusDaemon::dbus("com.deepin.editor.daemon", "/", QDBusConnection::systemBus(), this); + // Apply qss theme. + Utils::applyQss(this, "main.qss"); + loadTheme(m_themeName); // Init settings. connect(m_settings, &Settings::adjustFont, this, &Window::updateFont); @@ -157,10 +161,6 @@ Window::Window(DMainWindow *parent) for (DSimpleListItem* item : m_themeBar->items) { (static_cast(item))->setFrameColor(frameSelectedColor, frameNormalColor); } - - // Apply qss theme. - Utils::applyQss(this, "main.qss"); - loadTheme(m_themeName); } Window::~Window()