Skip to content

Commit

Permalink
chore(editor):add new requirements,find box,replacement box can be mo…
Browse files Browse the repository at this point in the history
…ved.

1.Add new requirements, find and replace floating windows, which can be moved in full screen.
2.Revision of copywriting.
  • Loading branch information
n013121 committed Jan 10, 2020
1 parent 724c674 commit b2f70f4
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 252 deletions.
4 changes: 2 additions & 2 deletions src/findbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
#include <QDebug>

FindBar::FindBar(QWidget *parent)
: DFloatingWidget(parent)
: DAbstractDialog(parent)
{
// Init.
//setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
hide();
setFixedHeight(58);
setFixedHeight(48);

// Init layout and widgets.

Expand Down
3 changes: 2 additions & 1 deletion src/findbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
#include <DFloatingWidget>

#include <DPalette>
#include <DAbstractDialog>

DWIDGET_USE_NAMESPACE

class FindBar : public DFloatingWidget
class FindBar : public DAbstractDialog
{
Q_OBJECT

Expand Down
4 changes: 2 additions & 2 deletions src/replacebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
#include <QDebug>

ReplaceBar::ReplaceBar(QWidget *parent)
: DFloatingWidget(parent)
: DAbstractDialog(parent)
{
// Init.
hide();
setFixedHeight(58);
setFixedHeight(48);

// Init layout and widgets.
m_layout = new QHBoxLayout();
Expand Down
3 changes: 2 additions & 1 deletion src/replacebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
#include <DIconButton>
#include <DApplicationHelper>
#include <DFloatingWidget>
#include <DAbstractDialog>

DWIDGET_USE_NAMESPACE

class ReplaceBar : public DFloatingWidget
class ReplaceBar : public DAbstractDialog
{
Q_OBJECT

Expand Down
24 changes: 0 additions & 24 deletions src/resources/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@
"type": "shortcut",
"default": "Ctrl+0"
},
{
"key": "windowmaximizing",
"name": "Window maximizing",
"type": "shortcut",
"default": "Ctrl+Alt+F"
},
{
"key": "togglefullscreen",
"name": "Toggle fullscreen",
Expand Down Expand Up @@ -564,12 +558,6 @@
"reset" : false,
"default": "Ctrl+0"
},
{
"key": "windowmaximizing",
"hide": true,
"reset": false,
"default": "Ctrl+Alt+F"
},
{
"key": "togglefullscreen",
"hide" : true,
Expand Down Expand Up @@ -1022,12 +1010,6 @@
"reset" : false,
"default": "Ctrl+0"
},
{
"key": "windowmaximizing",
"hide": true,
"reset": false,
"default": "Ctrl+Alt+F"
},
{
"key": "togglefullscreen",
"hide" : true,
Expand Down Expand Up @@ -1480,12 +1462,6 @@
"reset" : false,
"default": "Ctrl+0"
},
{
"key": "windowmaximizing",
"hide": true,
"reset": false,
"default": "Ctrl+Alt+F"
},
{
"key": "togglefullscreen",
"hide" : true,
Expand Down
1 change: 0 additions & 1 deletion src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void GenerateSettingTranslate()
auto shortcuts_window_incrementfontsizeName = QObject::tr("Increase font size");
auto shortcuts_window_decrementfontsizeName = QObject::tr("Decrease font size");
auto shortcuts_window_resetfontsizeName = QObject::tr("Reset font size");
auto shortcuts_window_windowMaximizing = QObject::tr("Window maximizing");
auto shortcuts_window_help = QObject::tr("Help");
auto shortcuts_window_togglefullscreenName = QObject::tr("Toggle fullscreen");
auto shortcuts_window_findName = QObject::tr("Find");
Expand Down
36 changes: 13 additions & 23 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,17 @@ Window::Window(DMainWindow *parent)
m_jumpLineBar->raise();

// Init findbar panel.
DAnchors<FindBar> anchors_findbar(m_findBar);
anchors_findbar.setAnchor(Qt::AnchorBottom, m_centralWidget, Qt::AnchorBottom);
//static DAnchors<FindBar> anchors_findbar(m_findBar);
//anchors_findbar.setAnchor(Qt::AnchorBottom, m_centralWidget, Qt::AnchorBottom);
//anchors_findbar.setAnchor(Qt::AnchorHorizontalCenter, m_centralWidget, Qt::AnchorHorizontalCenter);
anchors_findbar.setBottomMargin(5);
//anchors_findbar.setBottomMargin(5);
//m_findBar->raise();

// Init replaceBar panel.
DAnchors<ReplaceBar> anchors_replaceBar(m_replaceBar);
anchors_replaceBar.setAnchor(Qt::AnchorBottom, m_centralWidget, Qt::AnchorBottom);
//DAnchors<ReplaceBar> anchors_replaceBar(m_replaceBar);
//anchors_replaceBar.setAnchor(Qt::AnchorBottom, m_centralWidget, Qt::AnchorBottom);
//anchors_replaceBar.setAnchor(Qt::AnchorHorizontalCenter, m_centralWidget, Qt::AnchorHorizontalCenter);
anchors_replaceBar.setBottomMargin(5);
//anchors_replaceBar.setBottomMargin(5);
//m_replaceBar->raise();

// Init theme panel.
Expand Down Expand Up @@ -960,6 +960,7 @@ void Window::popupFindBar()
m_replaceBar->hide();
}
m_findBar->raise();
m_findBar->move(mapToGlobal(QPoint(10, height() - 60)));
m_findBar->show();

QString text = wrapper->textEditor()->textCursor().selectedText();
Expand Down Expand Up @@ -990,6 +991,7 @@ void Window::popupReplaceBar()
m_findBar->hide();
}
m_replaceBar->raise();
m_replaceBar->move(mapToGlobal(QPoint(10, height() - 60)));
m_replaceBar->show();
//addBottomWidget(m_replaceBar);

Expand Down Expand Up @@ -1074,16 +1076,6 @@ void Window::popupThemePanel()
m_themePanel->popup();
}

void Window::windowMaximizing()
{
if (isMaximized()) {
showNormal();
} else {
//setWindowState(Qt::WindowMaximized);
showMaximized();
}
}

void Window::toggleFullscreen()
{
if (isFullScreen()) {
Expand All @@ -1102,7 +1094,7 @@ void Window::remberPositionSave()
m_remberPositionColumn = wrapper->textEditor()->getCurrentColumn();
m_remberPositionScrollOffset = wrapper->textEditor()->getScrollOffset();

currentWrapper()->showNotify(tr("Remember the current location"));
//currentWrapper()->showNotify(tr("Remember the current location"));
}

void Window::remberPositionRestore()
Expand Down Expand Up @@ -1303,7 +1295,7 @@ void Window::addBlankTab(const QString &blankFile)

int blankFileIndex = getBlankFileIndex();

m_tabbar->addTab(blankTabPath, tr("Blank document %1").arg(blankFileIndex));
m_tabbar->addTab(blankTabPath, tr("Untitled %1").arg(blankFileIndex));
EditWrapper *wrapper = createEditor();
wrapper->updatePath(blankTabPath);

Expand Down Expand Up @@ -1760,8 +1752,8 @@ void Window::resizeEvent(QResizeEvent *e)
m_settings->settings->option("advance.window.window_height")->setValue(rect().height() * 1.0 / screenGeometry.height());
}

m_findBar->resize(width(), m_findBar->height());
m_replaceBar->resize(width(), m_replaceBar->height());
m_findBar->resize(width() - 20, m_findBar->height());
m_replaceBar->resize(width() - 20, m_replaceBar->height());

DMainWindow::resizeEvent(e);
}
Expand Down Expand Up @@ -1856,9 +1848,7 @@ void Window::keyPressEvent(QKeyEvent *e)
decrementFontSize();
} else if (key == Utils::getKeyshortcutFromKeymap(m_settings, "window", "resetfontsize")) {
resetFontSize();
} else if (key == Utils::getKeyshortcutFromKeymap(m_settings, "window", "windowmaximizing")) {
windowMaximizing();
} else if (key == Utils::getKeyshortcutFromKeymap(m_settings, "window", "togglefullscreen")) {
} else if (key == Utils::getKeyshortcutFromKeymap(m_settings, "window", "togglefullscreen")) {
toggleFullscreen();
} else if (key == Utils::getKeyshortcutFromKeymap(m_settings, "window", "find")) {
popupFindBar();
Expand Down
1 change: 0 additions & 1 deletion src/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class Window : public DMainWindow
void popupPrintDialog();
void popupThemePanel();

void windowMaximizing();
void toggleFullscreen();

void remberPositionSave();
Expand Down
Loading

0 comments on commit b2f70f4

Please sign in to comment.