version 2.20

icon change
EDockWidget improvements
EMainWindow small refactoring
Graphic now remember last loaded graphics style and restore it on setGraphicsCount
This commit is contained in:
2023-08-23 16:33:43 +03:00
parent ca6bcd4944
commit b77648aae9
12 changed files with 319 additions and 182 deletions

View File

@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
project(QAD) project(QAD)
set(QAD_MAJOR 2) set(QAD_MAJOR 2)
set(QAD_MINOR 19) set(QAD_MINOR 20)
set(QAD_REVISION 0) set(QAD_REVISION 0)
set(QAD_SUFFIX ) set(QAD_SUFFIX )
set(QAD_COMPANY SHS) set(QAD_COMPANY SHS)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -6,6 +6,27 @@
#include <QStyle> #include <QStyle>
EDockWidget::EDockWidget(const QString & title, QWidget * parent, Qt::WindowFlags flags): QDockWidget(title, parent, flags) {
init();
}
EDockWidget::EDockWidget(QWidget * parent, Qt::WindowFlags flags): QDockWidget(parent, flags) {
init();
}
EDockWidget::~EDockWidget() {
delete btn_hide;
delete btn_dock;
delete btn_maximize;
delete lbl_title;
delete lbl_icon;
delete header;
delete empty_header;
}
void EDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) { void EDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) {
btn_dock->setVisible(features.testFlag(DockWidgetFloatable)); btn_dock->setVisible(features.testFlag(DockWidgetFloatable));
btn_hide->setVisible(features.testFlag(DockWidgetClosable)); btn_hide->setVisible(features.testFlag(DockWidgetClosable));
@@ -31,6 +52,16 @@ void EDockWidget::setWindowIcon(const QIcon & icon) {
} }
void EDockWidget::setEmptyHeader() {
if (titleBarWidget() != empty_header) setTitleBarWidget(empty_header);
}
void EDockWidget::setStandardHeader() {
if (titleBarWidget() != header) setTitleBarWidget(header);
}
bool EDockWidget::event(QEvent * e) { bool EDockWidget::event(QEvent * e) {
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish) { if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish) {
updateStyle(); updateStyle();
@@ -39,9 +70,19 @@ bool EDockWidget::event(QEvent * e) {
} }
void EDockWidget::changeEvent(QEvent * e) {
if (e->type() == QEvent::WindowStateChange || e->type() == QEvent::LanguageChange) {
updateStyle();
}
QDockWidget::changeEvent(e);
}
void EDockWidget::init() { void EDockWidget::init() {
header = new QFrame(); header = new QFrame();
header->setFrameShape(QFrame::StyledPanel); header->setFrameShape(QFrame::StyledPanel);
empty_header = new QWidget();
empty_header->setLayout(new QBoxLayout(QBoxLayout::BottomToTop));
QBoxLayout * lay = QBoxLayout * lay =
new QBoxLayout(features().testFlag(QDockWidget::DockWidgetVerticalTitleBar) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight); new QBoxLayout(features().testFlag(QDockWidget::DockWidgetVerticalTitleBar) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
lay->setContentsMargins(2, 2, 2, 2); lay->setContentsMargins(2, 2, 2, 2);
@@ -62,38 +103,62 @@ void EDockWidget::init() {
// #endif // #endif
lbl_title = new QLabel(windowTitle()); lbl_title = new QLabel(windowTitle());
lbl_title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); lbl_title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
btn_dock = new QToolButton(); auto createButton = [this](const char * slot) {
// btn_dock->setIconSize(QSize(16, 16)); auto * ret = new QToolButton();
btn_dock->setAutoRaise(true); ret->setAutoRaise(true);
btn_dock->setFocusPolicy(Qt::NoFocus); ret->setFocusPolicy(Qt::NoFocus);
btn_dock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); ret->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
btn_hide = new QToolButton(); // ret->setIconSize(QSize(16, 16));
// btn_hide->setIconSize(QSize(16, 16)); connect(ret, SIGNAL(clicked(bool)), this, slot);
btn_hide->setAutoRaise(true); return ret;
btn_hide->setFocusPolicy(Qt::NoFocus); };
btn_hide->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); btn_dock = createButton(SLOT(dockClicked()));
connect(btn_dock, SIGNAL(clicked(bool)), this, SLOT(dockClicked())); btn_maximize = createButton(SLOT(maximize()));
connect(btn_hide, SIGNAL(clicked(bool)), this, SLOT(hide())); btn_hide = createButton(SLOT(hide()));
lay->addWidget(lbl_icon); lay->addWidget(lbl_icon);
lay->addWidget(lbl_title); lay->addWidget(lbl_title);
lay->addWidget(btn_dock); lay->addWidget(btn_dock);
lay->addWidget(btn_maximize);
lay->addWidget(btn_hide); lay->addWidget(btn_hide);
header->setLayout(lay); header->setLayout(lay);
updateStyle(); updateStyle();
setTitleBarWidget(header); setTitleBarWidget(header);
connect(this, &QDockWidget::topLevelChanged, this, &EDockWidget::updateStyle);
} }
void EDockWidget::updateStyle() { void EDockWidget::updateStyle() {
int eh_m = style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin);
empty_header->layout()->setContentsMargins(eh_m, eh_m, 0, 0);
QSize icon_size = preferredIconSize(0.75, this); QSize icon_size = preferredIconSize(0.75, this);
int bm = 2 * style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this); int bm = 2 * style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this);
QSize btn_size = icon_size; QSize btn_size = icon_size;
btn_size += QSize(bm, bm); btn_size += QSize(bm, bm);
btn_dock->setIcon(style()->standardIcon(QStyle::SP_TitleBarNormalButton));
btn_dock->setIconSize(icon_size);
btn_dock->setFixedSize(btn_size);
btn_hide->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
btn_hide->setIconSize(icon_size);
btn_hide->setFixedSize(btn_size);
lbl_icon->setFixedSize(preferredIconSize(1.5, this)); lbl_icon->setFixedSize(preferredIconSize(1.5, this));
auto restyleButton = [this, icon_size, btn_size](QToolButton * btn, QStyle::StandardPixmap pm) {
btn->setIcon(style()->standardIcon(pm));
btn->setIconSize(icon_size);
btn->setFixedSize(btn_size);
};
restyleButton(btn_dock, isFloating() ? QStyle::SP_TitleBarUnshadeButton : QStyle::SP_TitleBarShadeButton);
restyleButton(btn_maximize, isMaximized() ? QStyle::SP_TitleBarNormalButton : QStyle::SP_TitleBarMaxButton);
restyleButton(btn_hide, QStyle::SP_TitleBarCloseButton);
btn_dock->setToolTip(isFloating() ? tr("Dock") : tr("Undock"));
btn_maximize->setToolTip(isMaximized() ? tr("Show normal") : tr("Maximize"));
btn_hide->setToolTip(tr("Hide"));
}
void EDockWidget::dockClicked() {
if (!isFloating() && isMaximized()) showNormal();
setFloating(!isFloating());
}
void EDockWidget::maximize() {
if (!isFloating()) setFloating(true);
if (isMaximized())
showNormal();
else
showMaximized();
} }

View File

@@ -35,34 +35,31 @@ class QAD_APPLICATION_EXPORT EDockWidget: public QDockWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit EDockWidget(const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()) explicit EDockWidget(const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags());
: QDockWidget(title, parent, flags) { explicit EDockWidget(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags());
init(); ~EDockWidget();
}
explicit EDockWidget(QWidget * parent = 0, Qt::WindowFlags flags = Qt::WindowFlags()): QDockWidget(parent, flags) { init(); }
~EDockWidget() {
delete btn_hide;
delete btn_dock;
delete lbl_title;
delete lbl_icon;
delete header;
}
void setFeatures(QDockWidget::DockWidgetFeatures features); void setFeatures(QDockWidget::DockWidgetFeatures features);
void setWindowTitle(const QString & title); void setWindowTitle(const QString & title);
void setWindowIcon(const QIcon & icon); void setWindowIcon(const QIcon & icon);
void setEmptyHeader();
void setStandardHeader();
private: private:
bool event(QEvent * e); bool event(QEvent * e) override;
void changeEvent(QEvent * e) override;
void init(); void init();
void updateStyle(); void updateStyle();
QFrame * header; QFrame * header;
QWidget * empty_header;
QLabel *lbl_title, *lbl_icon; QLabel *lbl_title, *lbl_icon;
QToolButton *btn_hide, *btn_dock; QToolButton *btn_hide, *btn_dock, *btn_maximize;
private slots: private slots:
void dockClicked() { setFloating(!isFloating()); } void dockClicked();
void maximize();
}; };
#endif // EDOCKWIDGET_H #endif // EDOCKWIDGET_H

View File

@@ -4,6 +4,7 @@
#include <QLabel> #include <QLabel>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <edockwidget.h>
EMainWindow::EMainWindow(QWidget * parent) EMainWindow::EMainWindow(QWidget * parent)
@@ -11,8 +12,7 @@ EMainWindow::EMainWindow(QWidget * parent)
, action_show_all_tools(this) , action_show_all_tools(this)
, action_hide_all_tools(this) , action_hide_all_tools(this)
, action_show_all_docks(this) , action_show_all_docks(this)
, action_hide_all_docks(this) , action_hide_all_docks(this) {
, first_show(true) {
menu_recent = 0; menu_recent = 0;
action_clear_recent = new QAction(QIcon(":/icons/edit-clear.png"), tr("Clear recent list"), this); action_clear_recent = new QAction(QIcon(":/icons/edit-clear.png"), tr("Clear recent list"), this);
connect(action_clear_recent, SIGNAL(triggered()), this, SLOT(clearRecent())); connect(action_clear_recent, SIGNAL(triggered()), this, SLOT(clearRecent()));
@@ -268,8 +268,8 @@ void EMainWindow::initDocks() {
void EMainWindow::initSession() { void EMainWindow::initSession() {
connect(&session, SIGNAL(loading(QPIConfig &)), this, SLOT(sessionLoading(QPIConfig &))); connect(&session, &SessionManager::loading, this, [this](QPIConfig & conf) { loadingSession(conf); });
connect(&session, SIGNAL(saving(QPIConfig &)), this, SLOT(sessionSaving(QPIConfig &))); connect(&session, &SessionManager::saving, this, [this](QPIConfig & conf) { savingSession(conf); });
} }
@@ -289,6 +289,12 @@ bool EMainWindow::checkSave() {
} }
void EMainWindow::setChanged(bool yes) {
is_changed = yes;
setWindowModified(yes);
}
void EMainWindow::changedDock() { void EMainWindow::changedDock() {
if (isHidden()) return; if (isHidden()) return;
QSet<QDockWidget *> invalid_tab_docks; QSet<QDockWidget *> invalid_tab_docks;
@@ -325,30 +331,19 @@ void EMainWindow::changedDock() {
for (QDockWidget * d: docks) { for (QDockWidget * d: docks) {
if (!d->titleBarWidget()) continue; if (!d->titleBarWidget()) continue;
QWidget * ctb = d->titleBarWidget();
if (!d->property("__titleWidget").isValid()) {
d->setProperty("__titleWidget", qulonglong(ctb));
QWidget * ntb = new QWidget();
int m = style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin);
ntb->setLayout(new QBoxLayout(QBoxLayout::BottomToTop));
ntb->layout()->setContentsMargins(m, m, 0, 0);
d->setProperty("__titleEmptyWidget", qulonglong(ntb));
}
if (!tdocks.contains(d)) { if (!tdocks.contains(d)) {
// qDebug() << "add dock" << d; // qDebug() << "add dock" << d;
tdocks << d; tdocks << d;
connect(d, &QObject::destroyed, this, [this, d]() { tdocks.removeOne(d); }); connect(d, &QObject::destroyed, this, [this, d]() { tdocks.removeOne(d); });
d->installEventFilter(this); d->installEventFilter(this);
} }
auto * ed = qobject_cast<EDockWidget *>(d);
if (ed) {
// qDebug() << d->windowTitle() << tabifiedDockWidgets(d); // qDebug() << d->windowTitle() << tabifiedDockWidgets(d);
if (tabifiedDockWidgets(d).isEmpty() || invalid_tab_docks.contains(d)) { if (tabifiedDockWidgets(d).isEmpty() || invalid_tab_docks.contains(d))
if (d->titleBarWidget() != (QWidget *)(d->property("__titleWidget").toULongLong())) ed->setStandardHeader();
d->setTitleBarWidget((QWidget *)(d->property("__titleWidget").toULongLong())); else
} else { ed->setEmptyHeader();
if (d->titleBarWidget() != (QWidget *)(d->property("__titleEmptyWidget").toULongLong())) {
d->setTitleBarWidget((QWidget *)(d->property("__titleEmptyWidget").toULongLong()));
d->layout()->setContentsMargins(0, 20, 0, 0);
}
} }
} }
} }

View File

@@ -88,59 +88,47 @@ public:
void setRecentMenu(QMenu * m); void setRecentMenu(QMenu * m);
int maxRecentItems() const { return max_recent; } int maxRecentItems() const { return max_recent; }
bool isChanged() const { return is_changed; }
protected: protected:
// Qt`s overloaded void showEvent(QShowEvent *) override;
void showEvent(QShowEvent *); void closeEvent(QCloseEvent *) override;
void closeEvent(QCloseEvent *); bool eventFilter(QObject * o, QEvent * e) override;
bool eventFilter(QObject * o, QEvent * e); void changeEvent(QEvent * e) override;
void changeEvent(QEvent * e); QMenu * createPopupMenu() override;
QMenu * createPopupMenu();
void addToRecent(const QString & path);
void prepareRecent();
void init(const QString & config) {
session.setFile(config);
initMenus();
initSession();
loadSession();
} // unusable
void saveSession(); void saveSession();
void loadSession(); void loadSession();
virtual void savingSession(QPIConfig & conf) {} void setChanged(bool yes = true);
void addToRecent(const QString & path);
virtual void loadingSession(QPIConfig & conf) {} virtual void loadingSession(QPIConfig & conf) {}
virtual void savingSession(QPIConfig & conf) {}
virtual QSize dockTabsIconSize() const { return iconSize(); } virtual QSize dockTabsIconSize() const { return iconSize(); }
virtual QString loadFilter() { return "All files(*)"; } virtual QString loadFilter() { return "All files(*)"; }
virtual QString saveFilter() { return "All files(*)"; } virtual QString saveFilter() { return "All files(*)"; }
SessionManager session;
QString file_name;
private:
void prepareRecent();
bool checkSave(); bool checkSave();
void setChanged(bool yes = true) {
isChanged = yes;
setWindowModified(yes);
}
void initMenus(); void initMenus();
void initDocks(); void initDocks();
void initSession(); void initSession();
QAction action_show_all_tools, action_hide_all_tools, action_show_all_docks, action_hide_all_docks; QAction action_show_all_tools, action_hide_all_tools, action_show_all_docks, action_hide_all_docks;
QString file_name;
QList<QTabBar *> tbars; QList<QTabBar *> tbars;
QList<QDockWidget *> tdocks; QList<QDockWidget *> tdocks;
QList<QAction *> actions_recent; QList<QAction *> actions_recent;
QAction * action_clear_recent; QAction * action_clear_recent;
QMenu * menu_recent; QMenu * menu_recent;
SessionManager session; bool is_changed;
bool isChanged, first_show;
int max_recent; int max_recent;
private slots:
void changedDock();
void sessionLoading(QPIConfig & conf) { loadingSession(conf); }
void sessionSaving(QPIConfig & conf) { savingSession(conf); }
void closeDock(int index);
void recentTriggered();
public slots: public slots:
void setMaxRecentItems(int mr); void setMaxRecentItems(int mr);
void changed() { setChanged(true); } void changed() { setChanged(true); }
@@ -152,6 +140,11 @@ public slots:
bool saveAsFile(); bool saveAsFile();
void clearRecent(); void clearRecent();
private slots:
void changedDock();
void closeDock(int index);
void recentTriggered();
signals: signals:
}; };

View File

@@ -9,93 +9,121 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="41"/> <location filename="../aboutwindow.ui" line="44"/>
<source>Versions</source> <source>Versions</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="56"/> <location filename="../aboutwindow.ui" line="59"/>
<source>Build</source> <source>Build</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="71"/> <location filename="../aboutwindow.ui" line="74"/>
<source>Authors</source> <source>Authors</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="100"/> <location filename="../aboutwindow.ui" line="103"/>
<source>About Qt...</source> <source>About Qt...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="111"/> <location filename="../aboutwindow.ui" line="114"/>
<source>OK</source> <source>OK</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.cpp" line="33"/> <location filename="../aboutwindow.cpp" line="33"/>
<location filename="../aboutwindow.cpp" line="157"/> <location filename="../aboutwindow.cpp" line="155"/>
<source>About</source> <source>About</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>EDockWidget</name>
<message>
<location filename="../edockwidget.cpp" line="131"/>
<source>Dock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="131"/>
<source>Undock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="132"/>
<source>Show normal</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="132"/>
<source>Maximize</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="133"/>
<source>Hide</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>EMainWindow</name> <name>EMainWindow</name>
<message> <message>
<location filename="../emainwindow.cpp" line="12"/> <location filename="../emainwindow.cpp" line="17"/>
<location filename="../emainwindow.cpp" line="130"/> <location filename="../emainwindow.cpp" line="123"/>
<source>Clear recent list</source> <source>Clear recent list</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="15"/> <location filename="../emainwindow.cpp" line="20"/>
<location filename="../emainwindow.cpp" line="16"/> <location filename="../emainwindow.cpp" line="21"/>
<location filename="../emainwindow.cpp" line="126"/> <location filename="../emainwindow.cpp" line="119"/>
<location filename="../emainwindow.cpp" line="127"/> <location filename="../emainwindow.cpp" line="120"/>
<source>Show all</source> <source>Show all</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="17"/> <location filename="../emainwindow.cpp" line="22"/>
<location filename="../emainwindow.cpp" line="18"/> <location filename="../emainwindow.cpp" line="23"/>
<location filename="../emainwindow.cpp" line="128"/> <location filename="../emainwindow.cpp" line="121"/>
<location filename="../emainwindow.cpp" line="129"/> <location filename="../emainwindow.cpp" line="122"/>
<source>Hide all</source> <source>Hide all</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="152"/> <location filename="../emainwindow.cpp" line="144"/>
<source>Toolbars</source> <source>Toolbars</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="177"/> <location filename="../emainwindow.cpp" line="169"/>
<source>Docks</source> <source>Docks</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="395"/> <location filename="../emainwindow.cpp" line="390"/>
<source>Select file to open</source> <source>Select file to open</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="404"/> <location filename="../emainwindow.cpp" line="398"/>
<source>Select files to open</source> <source>Select files to open</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="414"/> <location filename="../emainwindow.cpp" line="409"/>
<source>Save changes%1?</source> <source>Save changes%1?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="414"/> <location filename="../emainwindow.cpp" line="409"/>
<source> in</source> <source> in</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="427"/> <location filename="../emainwindow.cpp" line="423"/>
<source>Select file to save</source> <source>Select file to save</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -103,8 +131,8 @@
<context> <context>
<name>HistoryView</name> <name>HistoryView</name>
<message> <message>
<location filename="../historyview.cpp" line="17"/> <location filename="../historyview.cpp" line="19"/>
<location filename="../historyview.cpp" line="97"/> <location filename="../historyview.cpp" line="96"/>
<source>History cleared</source> <source>History cleared</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@@ -117,26 +145,27 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../logview.ui" line="119"/> <location filename="../logview.ui" line="125"/>
<location filename="../logview.cpp" line="37"/> <location filename="../logview.cpp" line="54"/>
<location filename="../logview.cpp" line="133"/> <location filename="../logview.cpp" line="222"/>
<source>Clear</source> <source>Clear</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../logview.cpp" line="35"/> <location filename="../logview.cpp" line="52"/>
<location filename="../logview.cpp" line="131"/> <location filename="../logview.cpp" line="220"/>
<source>Select All</source> <source>Select All</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../logview.cpp" line="36"/> <location filename="../logview.cpp" line="53"/>
<location filename="../logview.cpp" line="132"/> <location filename="../logview.cpp" line="221"/>
<source>Copy</source> <source>Copy</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../logview.cpp" line="46"/> <location filename="../logview.cpp" line="63"/>
<location filename="../logview.cpp" line="219"/>
<source>All</source> <source>All</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@@ -9,93 +9,121 @@
<translation> - О программе</translation> <translation> - О программе</translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="41"/> <location filename="../aboutwindow.ui" line="44"/>
<source>Versions</source> <source>Versions</source>
<translation>Версии</translation> <translation>Версии</translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="56"/> <location filename="../aboutwindow.ui" line="59"/>
<source>Build</source> <source>Build</source>
<translation>Сборка</translation> <translation>Сборка</translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="71"/> <location filename="../aboutwindow.ui" line="74"/>
<source>Authors</source> <source>Authors</source>
<translation>Авторы</translation> <translation>Авторы</translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="100"/> <location filename="../aboutwindow.ui" line="103"/>
<source>About Qt...</source> <source>About Qt...</source>
<translation>О Qt ...</translation> <translation>О Qt ...</translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.ui" line="111"/> <location filename="../aboutwindow.ui" line="114"/>
<source>OK</source> <source>OK</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../aboutwindow.cpp" line="33"/> <location filename="../aboutwindow.cpp" line="33"/>
<location filename="../aboutwindow.cpp" line="157"/> <location filename="../aboutwindow.cpp" line="155"/>
<source>About</source> <source>About</source>
<translation>О программе</translation> <translation>О программе</translation>
</message> </message>
</context> </context>
<context>
<name>EDockWidget</name>
<message>
<location filename="../edockwidget.cpp" line="131"/>
<source>Dock</source>
<translation>Закрепить</translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="131"/>
<source>Undock</source>
<translation>Открепить</translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="132"/>
<source>Show normal</source>
<translation>Восстановить</translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="132"/>
<source>Maximize</source>
<translation>Развернуть</translation>
</message>
<message>
<location filename="../edockwidget.cpp" line="133"/>
<source>Hide</source>
<translation>Скрыть</translation>
</message>
</context>
<context> <context>
<name>EMainWindow</name> <name>EMainWindow</name>
<message> <message>
<location filename="../emainwindow.cpp" line="12"/> <location filename="../emainwindow.cpp" line="17"/>
<location filename="../emainwindow.cpp" line="130"/> <location filename="../emainwindow.cpp" line="123"/>
<source>Clear recent list</source> <source>Clear recent list</source>
<translation>Очистить список недавних</translation> <translation>Очистить список недавних</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="15"/> <location filename="../emainwindow.cpp" line="20"/>
<location filename="../emainwindow.cpp" line="16"/> <location filename="../emainwindow.cpp" line="21"/>
<location filename="../emainwindow.cpp" line="126"/> <location filename="../emainwindow.cpp" line="119"/>
<location filename="../emainwindow.cpp" line="127"/> <location filename="../emainwindow.cpp" line="120"/>
<source>Show all</source> <source>Show all</source>
<translation>Показать все</translation> <translation>Показать все</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="17"/> <location filename="../emainwindow.cpp" line="22"/>
<location filename="../emainwindow.cpp" line="18"/> <location filename="../emainwindow.cpp" line="23"/>
<location filename="../emainwindow.cpp" line="128"/> <location filename="../emainwindow.cpp" line="121"/>
<location filename="../emainwindow.cpp" line="129"/> <location filename="../emainwindow.cpp" line="122"/>
<source>Hide all</source> <source>Hide all</source>
<translation>Скрыть все</translation> <translation>Скрыть все</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="152"/> <location filename="../emainwindow.cpp" line="144"/>
<source>Toolbars</source> <source>Toolbars</source>
<translation>Панели инструментов</translation> <translation>Панели инструментов</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="177"/> <location filename="../emainwindow.cpp" line="169"/>
<source>Docks</source> <source>Docks</source>
<translation>Окна</translation> <translation>Окна</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="395"/> <location filename="../emainwindow.cpp" line="390"/>
<source>Select file to open</source> <source>Select file to open</source>
<translation>Выбрать файл для открытия</translation> <translation>Выбрать файл для открытия</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="404"/> <location filename="../emainwindow.cpp" line="398"/>
<source>Select files to open</source> <source>Select files to open</source>
<translation>Выберите файлы для открытия</translation> <translation>Выберите файлы для открытия</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="414"/> <location filename="../emainwindow.cpp" line="409"/>
<source>Save changes%1?</source> <source>Save changes%1?</source>
<translation>Сохранить изменения%1?</translation> <translation>Сохранить изменения%1?</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="414"/> <location filename="../emainwindow.cpp" line="409"/>
<source> in</source> <source> in</source>
<translation> в</translation> <translation> в</translation>
</message> </message>
<message> <message>
<location filename="../emainwindow.cpp" line="427"/> <location filename="../emainwindow.cpp" line="423"/>
<source>Select file to save</source> <source>Select file to save</source>
<translation>Выберите файл для сохранения</translation> <translation>Выберите файл для сохранения</translation>
</message> </message>
@@ -103,8 +131,8 @@
<context> <context>
<name>HistoryView</name> <name>HistoryView</name>
<message> <message>
<location filename="../historyview.cpp" line="17"/> <location filename="../historyview.cpp" line="19"/>
<location filename="../historyview.cpp" line="97"/> <location filename="../historyview.cpp" line="96"/>
<source>History cleared</source> <source>History cleared</source>
<translation>История очищена</translation> <translation>История очищена</translation>
</message> </message>
@@ -117,26 +145,27 @@
<translation>Категория:</translation> <translation>Категория:</translation>
</message> </message>
<message> <message>
<location filename="../logview.ui" line="119"/> <location filename="../logview.ui" line="125"/>
<location filename="../logview.cpp" line="37"/> <location filename="../logview.cpp" line="54"/>
<location filename="../logview.cpp" line="133"/> <location filename="../logview.cpp" line="222"/>
<source>Clear</source> <source>Clear</source>
<translation>Очистить</translation> <translation>Очистить</translation>
</message> </message>
<message> <message>
<location filename="../logview.cpp" line="35"/> <location filename="../logview.cpp" line="52"/>
<location filename="../logview.cpp" line="131"/> <location filename="../logview.cpp" line="220"/>
<source>Select All</source> <source>Select All</source>
<translation>Выделить всё</translation> <translation>Выделить всё</translation>
</message> </message>
<message> <message>
<location filename="../logview.cpp" line="36"/> <location filename="../logview.cpp" line="53"/>
<location filename="../logview.cpp" line="132"/> <location filename="../logview.cpp" line="221"/>
<source>Copy</source> <source>Copy</source>
<translation>Копировать</translation> <translation>Копировать</translation>
</message> </message>
<message> <message>
<location filename="../logview.cpp" line="46"/> <location filename="../logview.cpp" line="63"/>
<location filename="../logview.cpp" line="219"/>
<source>All</source> <source>All</source>
<translation>Все</translation> <translation>Все</translation>
</message> </message>

View File

@@ -1252,24 +1252,31 @@ void Graphic::setCurrentGraphic(int arg) {
} }
void Graphic::setGraphicsCount(int arg, bool update) {
if (arg < 0) return;
while (graphics.size() < arg) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
graphics.append( # define _G_QRAND_ QRandomGenerator::global()->generate()
GraphicType(tr("y(x)"),
QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - QRandomGenerator::global()->generate() % 115)));
#else #else
graphics.append(GraphicType(tr("y(x)"), QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - qrand() % 115))); # define _G_QRAND_ qrand()
#endif #endif
void Graphic::setGraphicsCount(int count, bool update) {
if (count < 0) return;
while (graphics.size() < count) {
GraphicType gt(tr("y(x)"));
if (loaded_configs.size() > graphics.size())
gt = loaded_configs[graphics.size()];
else
gt.pen.setColor(QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - _G_QRAND_ % 115));
graphics.append(gt);
} }
while (graphics.size() > arg) { while (graphics.size() > count) {
delete graphics.back().pb; delete graphics.back().pb;
graphics.pop_back(); graphics.pop_back();
} }
if (update) updateLegend(); if (update) updateLegend();
} }
#undef _G_QRAND_
void Graphic::removeGraphic(int arg, bool update) { void Graphic::removeGraphic(int arg, bool update) {
if (arg < 0 || arg >= graphics.size()) return; if (arg < 0 || arg >= graphics.size()) return;
@@ -2309,6 +2316,10 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
setGridEnabled(conf->ui->groupGrid->isChecked()); setGridEnabled(conf->ui->groupGrid->isChecked());
updateLegend(); updateLegend();
repaintCanvas(); repaintCanvas();
for (int i = 0; i < qMin<int>(graphics.size(), loaded_configs.size()); ++i) {
loaded_configs[i] = graphics[i];
loaded_configs[i].removeData();
}
} }
@@ -2702,6 +2713,9 @@ void Graphic::load(QByteArray ba) {
setLegendVisible(a); setLegendVisible(a);
} break; } break;
} }
loaded_configs = graphics;
for (auto & i: loaded_configs)
i.removeData();
if (has_opengl != isOGL) setOpenGL(has_opengl); if (has_opengl != isOGL) setOpenGL(has_opengl);
updateLegend(); updateLegend();
repaintCanvas(true); repaintCanvas(true);

View File

@@ -442,7 +442,7 @@ protected:
QBrush selbrush; QBrush selbrush;
QPen grid_pen, selpen; QPen grid_pen, selpen;
QColor back_color, text_color; QColor back_color, text_color;
QVector<GraphicType> graphics; QVector<GraphicType> graphics, loaded_configs;
int curGraphic; int curGraphic;
GraphicAction curaction, prevaction; GraphicAction curaction, prevaction;
QRectF grect, selrect, limit_, def_rect; QRectF grect, selrect, limit_, def_rect;

View File

@@ -3,6 +3,38 @@
#include "qad_types.h" #include "qad_types.h"
#include "ui_graphic_conf.h" #include "ui_graphic_conf.h"
// GraphicType
GraphicType::GraphicType(QString name_, QColor color, Qt::PenStyle style, double width, bool visible_) {
pen.setColor(color);
pen.setStyle(style);
lines = true;
points = false;
fill = false;
fill_color = Qt::yellow;
if (qRound(width) == width)
pen.setWidth(qRound(width));
else
pen.setWidthF(width);
pen.setWidth(1);
pen.setCosmetic(true);
max_x = 0.;
name = name_;
visible = visible_;
pointWidth = 2.;
pb = new QCheckBox(name);
}
void GraphicType::removeData() {
polyline.clear();
polyline_pause.clear();
_lod.clear();
_lod_pause.clear();
}
// GraphicConf
GraphicConf::GraphicConf(QVector<GraphicType> & graphics_, QWidget * parent): QDialog(parent), graphics(graphics_) { GraphicConf::GraphicConf(QVector<GraphicType> & graphics_, QWidget * parent): QDialog(parent), graphics(graphics_) {
ui = new Ui::GraphicConf(); ui = new Ui::GraphicConf();

View File

@@ -38,25 +38,8 @@ struct QAD_GRAPHIC_EXPORT GraphicType {
QColor color = Qt::red, QColor color = Qt::red,
Qt::PenStyle style = Qt::SolidLine, Qt::PenStyle style = Qt::SolidLine,
double width = 0., double width = 0.,
bool visible_ = true) { bool visible_ = true);
pen.setColor(color); void removeData();
pen.setStyle(style);
lines = true;
points = false;
fill = false;
fill_color = Qt::yellow;
if (qRound(width) == width)
pen.setWidth(qRound(width));
else
pen.setWidthF(width);
pen.setWidth(1);
pen.setCosmetic(true);
max_x = 0.;
name = name_;
visible = visible_;
pointWidth = 2.;
pb = new QCheckBox(name);
}
//~GraphicType() {delete pb;} //~GraphicType() {delete pb;}
QString name; QString name;
QPolygonF polyline; QPolygonF polyline;