1
git-svn-id: svn://db.shs.com.ru/libs@1 a8b55f48-bf90-11e4-a774-851b48703e85
126
qad_application/.kdev4/qad_application.kdev4
Normal file
@@ -0,0 +1,126 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00q\x00a\x00d\x00_\x00a\x00p\x00p\x00l\x00i\x00c\x00a\x00t\x00i\x00o\x00n)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///mnt/data/orders/libs/qad_application/
|
||||
Build Type=
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr/local
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Filters]
|
||||
size=20
|
||||
|
||||
[Filters][0]
|
||||
inclusive=0
|
||||
pattern=.*
|
||||
targets=3
|
||||
|
||||
[Filters][1]
|
||||
inclusive=0
|
||||
pattern=.git
|
||||
targets=2
|
||||
|
||||
[Filters][10]
|
||||
inclusive=0
|
||||
pattern=*.a
|
||||
targets=1
|
||||
|
||||
[Filters][11]
|
||||
inclusive=0
|
||||
pattern=*.so
|
||||
targets=1
|
||||
|
||||
[Filters][12]
|
||||
inclusive=0
|
||||
pattern=*.so.*
|
||||
targets=1
|
||||
|
||||
[Filters][13]
|
||||
inclusive=0
|
||||
pattern=moc_*
|
||||
targets=1
|
||||
|
||||
[Filters][14]
|
||||
inclusive=0
|
||||
pattern=*.moc
|
||||
targets=1
|
||||
|
||||
[Filters][15]
|
||||
inclusive=0
|
||||
pattern=ui_*
|
||||
targets=1
|
||||
|
||||
[Filters][16]
|
||||
inclusive=0
|
||||
pattern=qrc_*
|
||||
targets=1
|
||||
|
||||
[Filters][17]
|
||||
inclusive=0
|
||||
pattern=*~
|
||||
targets=1
|
||||
|
||||
[Filters][18]
|
||||
inclusive=0
|
||||
pattern=.*.kate-swp
|
||||
targets=1
|
||||
|
||||
[Filters][19]
|
||||
inclusive=0
|
||||
pattern=.*.swp
|
||||
targets=1
|
||||
|
||||
[Filters][2]
|
||||
inclusive=0
|
||||
pattern=CVS
|
||||
targets=2
|
||||
|
||||
[Filters][3]
|
||||
inclusive=0
|
||||
pattern=.svn
|
||||
targets=2
|
||||
|
||||
[Filters][4]
|
||||
inclusive=0
|
||||
pattern=_svn
|
||||
targets=2
|
||||
|
||||
[Filters][5]
|
||||
inclusive=0
|
||||
pattern=SCCS
|
||||
targets=2
|
||||
|
||||
[Filters][6]
|
||||
inclusive=0
|
||||
pattern=_darcs
|
||||
targets=2
|
||||
|
||||
[Filters][7]
|
||||
inclusive=0
|
||||
pattern=.hg
|
||||
targets=2
|
||||
|
||||
[Filters][8]
|
||||
inclusive=0
|
||||
pattern=.bzr
|
||||
targets=2
|
||||
|
||||
[Filters][9]
|
||||
inclusive=0
|
||||
pattern=*.o
|
||||
targets=1
|
||||
|
||||
[MakeBuilder]
|
||||
Number Of Jobs=8
|
||||
36
qad_application/CMakeLists.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
project(qad_application)
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
find_package(Qt4 REQUIRED)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${QT_INCLUDES})
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
set(MOCS "emainwindow.h" "edockwidget.h" "etabwidget.h" "ribbon.h" "historyview.h" "qsingleapplication.h")
|
||||
set(CPPS "emainwindow.cpp" "edockwidget.cpp" "etabwidget.cpp" "ribbon.cpp" "historyview.cpp" "qsingleapplication.cpp")
|
||||
file(GLOB UIS "./*.ui")
|
||||
file(GLOB RES "./*.qrc")
|
||||
qt4_wrap_ui(CUIS ${UIS})
|
||||
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
||||
qt4_add_resources(CRES ${RES})
|
||||
add_library(qad_application SHARED ${CPPS} ${CUIS} ${CMOCS} ${CRES})
|
||||
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} qad_utils)
|
||||
target_link_libraries(qad_application ${LIBS})
|
||||
if (DEFINED LIB)
|
||||
set(LIB 1)
|
||||
if (${WIN32})
|
||||
find_package(MinGW REQUIRED)
|
||||
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||
install(FILES ${MOCS} DESTINATION ${MINGW_INCLUDE})
|
||||
install(TARGETS qad_application DESTINATION ${MINGW_LIB})
|
||||
get_filename_component(QTDIR ${QT_QMAKE_EXECUTABLE} PATH)
|
||||
install(TARGETS qad_application DESTINATION ${QTDIR})
|
||||
else ()
|
||||
set(CMAKE_INSTALL_PREFIX /usr)
|
||||
install(FILES ${MOCS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
|
||||
install(TARGETS qad_application DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif ()
|
||||
else ()
|
||||
install(TARGETS qad_application DESTINATION bin)
|
||||
endif ()
|
||||
0
qad_application/LEDOS_devices.dat
Normal file
4
qad_application/clean
Normal file
@@ -0,0 +1,4 @@
|
||||
#! /bin/bash
|
||||
VERBOSE=1 make clean
|
||||
rm -rvf CMakeFiles
|
||||
rm -vf CMakeCache.txt Makefile cmake_install.cmake install_manifest.txt *.dll *.a *.so *.user* *~ *cxx moc_* ui_* qrc_* *.o *.bak
|
||||
4
qad_application/clean.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
#make clean
|
||||
del /q /f /s CMakeFiles
|
||||
rmdir /q /s CMakeFiles
|
||||
del /q /f CMakeCache.txt Makefile cmake_install.cmake install_manifest.txt *.user* *~ *cxx moc_* ui_* qrc_* *.o *.exe *.a *.dll *.lib core *.bak
|
||||
51
qad_application/edockwidget.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "edockwidget.h"
|
||||
#include <QStyle>
|
||||
|
||||
|
||||
void EDockWidget::setFeatures(QDockWidget::DockWidgetFeatures features) {
|
||||
btn_dock->setVisible(features.testFlag(DockWidgetFloatable));
|
||||
btn_hide->setVisible(features.testFlag(DockWidgetClosable));
|
||||
QDockWidget::setFeatures(features);
|
||||
}
|
||||
|
||||
|
||||
void EDockWidget::init() {
|
||||
header = new QFrame();
|
||||
header->setFrameShape(QFrame::StyledPanel);
|
||||
QBoxLayout * lay = new QBoxLayout(features().testFlag(QDockWidget::DockWidgetVerticalTitleBar) ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight);
|
||||
lay->setContentsMargins(2, 2, 2, 2);
|
||||
lay->setSpacing(2);
|
||||
lbl_icon = new QLabel();
|
||||
lbl_icon->setPixmap(windowIcon().pixmap(QSize(24, 24)));
|
||||
lbl_icon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
lbl_title = new QLabel(windowTitle());
|
||||
lbl_title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
btn_dock = new QToolButton();
|
||||
//btn_dock->setIconSize(QSize(16, 16));
|
||||
int btn_wh = style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
QSize icon_size(btn_wh, btn_wh);
|
||||
btn_wh += 2 * style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this);
|
||||
QSize btn_size(btn_wh, btn_wh);
|
||||
btn_dock->setIcon(style()->standardIcon(QStyle::SP_TitleBarNormalButton));
|
||||
btn_dock->setIconSize(icon_size);
|
||||
btn_dock->setFixedSize(btn_size);
|
||||
btn_dock->setAutoRaise(true);
|
||||
btn_dock->setFocusPolicy(Qt::NoFocus);
|
||||
btn_dock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
btn_hide = new QToolButton();
|
||||
//btn_hide->setIconSize(QSize(16, 16));
|
||||
btn_hide->setIcon(style()->standardIcon(QStyle::SP_DockWidgetCloseButton));
|
||||
btn_hide->setIconSize(icon_size);
|
||||
btn_hide->setFixedSize(btn_size);
|
||||
btn_hide->setAutoRaise(true);
|
||||
btn_hide->setFocusPolicy(Qt::NoFocus);
|
||||
btn_hide->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
connect(btn_dock, SIGNAL(clicked(bool)), this, SLOT(dockClicked()));
|
||||
connect(btn_hide, SIGNAL(clicked(bool)), this, SLOT(hide()));
|
||||
lay->addWidget(lbl_icon);
|
||||
lay->addWidget(lbl_title);
|
||||
lay->addWidget(btn_dock);
|
||||
lay->addWidget(btn_hide);
|
||||
header->setLayout(lay);
|
||||
setTitleBarWidget(header);
|
||||
}
|
||||
37
qad_application/edockwidget.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef EDOCKWIDGET_H
|
||||
#define EDOCKWIDGET_H
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QIcon>
|
||||
#include <QToolButton>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
class EDockWidget: public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EDockWidget(const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0): QDockWidget(title, parent, flags) {init();}
|
||||
explicit EDockWidget(QWidget * parent = 0, Qt::WindowFlags flags = 0): 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 setWindowTitle(const QString & title) {lbl_title->setText(title); QDockWidget::setWindowTitle(title);}
|
||||
void setWindowIcon(const QIcon & icon) {lbl_icon->setPixmap(icon.pixmap(QSize(24, 24))); QDockWidget::setWindowIcon(icon);}
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
QFrame * header;
|
||||
QLabel * lbl_title, * lbl_icon;
|
||||
QToolButton * btn_hide, * btn_dock;
|
||||
|
||||
private slots:
|
||||
void dockClicked() {setFloating(!isFloating());}
|
||||
|
||||
};
|
||||
|
||||
#endif // EDOCKWIDGET_H
|
||||
69
qad_application/edockwidgetplugin.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "edockwidget.h"
|
||||
#include "edockwidgetplugin.h"
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
|
||||
EDockWidgetPlugin::EDockWidgetPlugin(QObject * parent): QObject(parent) {
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
void EDockWidgetPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
||||
if (m_initialized)
|
||||
return;
|
||||
|
||||
// Add extension registrations, etc. here
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
bool EDockWidgetPlugin::isInitialized() const {
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
|
||||
QWidget * EDockWidgetPlugin::createWidget(QWidget * parent) {
|
||||
return new EDockWidget(parent);
|
||||
}
|
||||
|
||||
|
||||
QString EDockWidgetPlugin::name() const {
|
||||
return QLatin1String("EDockWidget");
|
||||
}
|
||||
|
||||
|
||||
QString EDockWidgetPlugin::group() const {
|
||||
return QLatin1String("Containers");
|
||||
}
|
||||
|
||||
|
||||
QIcon EDockWidgetPlugin::icon() const {
|
||||
return QIcon(":/icons/edockwidget.png");
|
||||
}
|
||||
|
||||
|
||||
QString EDockWidgetPlugin::toolTip() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
QString EDockWidgetPlugin::whatsThis() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
bool EDockWidgetPlugin::isContainer() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString EDockWidgetPlugin::domXml() const {
|
||||
return QLatin1String("<widget class=\"EDockWidget\" name=\"dockWidget\">\n</widget>\n");
|
||||
}
|
||||
|
||||
|
||||
QString EDockWidgetPlugin::includeFile() const {
|
||||
return QLatin1String("edockwidget.h");
|
||||
}
|
||||
|
||||
31
qad_application/edockwidgetplugin.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef EDOCKWIDGETPLUGIN_H
|
||||
#define EDOCKWIDGETPLUGIN_H
|
||||
|
||||
#include <QDesignerCustomWidgetInterface>
|
||||
|
||||
class EDockWidgetPlugin: public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||
|
||||
public:
|
||||
EDockWidgetPlugin(QObject * parent = 0);
|
||||
|
||||
bool isContainer() const;
|
||||
bool isInitialized() const;
|
||||
QIcon icon() const;
|
||||
QString domXml() const;
|
||||
QString group() const;
|
||||
QString includeFile() const;
|
||||
QString name() const;
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QWidget * createWidget(QWidget * parent);
|
||||
void initialize(QDesignerFormEditorInterface * core);
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
325
qad_application/emainwindow.cpp
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
Peri4 Paint
|
||||
Copyright (C) 2011 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "emainwindow.h"
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QLabel>
|
||||
|
||||
|
||||
EMainWindow::EMainWindow(QWidget * parent): QMainWindow(parent), action_show_all_tools(this), action_hide_all_tools(this),
|
||||
action_show_all_docks(this), action_hide_all_docks(this), first_show(true) {
|
||||
qRegisterMetaType<Qt::DockWidgetArea>("Qt::DockWidgetArea");
|
||||
action_show_all_tools.setText(trUtf8("Show all"));
|
||||
action_show_all_docks.setText(trUtf8("Show all"));
|
||||
action_hide_all_tools.setText(trUtf8("Hide all"));
|
||||
action_hide_all_docks.setText(trUtf8("Hide all"));
|
||||
action_show_all_tools.setIcon(QIcon(":/icons/layer-visible-on.png"));
|
||||
action_show_all_docks.setIcon(QIcon(":/icons/layer-visible-on.png"));
|
||||
action_hide_all_tools.setIcon(QIcon(":/icons/layer-visible-off.png"));
|
||||
action_hide_all_docks.setIcon(QIcon(":/icons/layer-visible-off.png"));
|
||||
setChanged(false);
|
||||
initMenus();
|
||||
tid = startTimer(200);
|
||||
}
|
||||
|
||||
|
||||
EMainWindow::~EMainWindow() {
|
||||
saveSession();
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::showEvent(QShowEvent * e) {
|
||||
QWidget::showEvent(e);
|
||||
initMenus();
|
||||
if (!first_show) return;
|
||||
first_show = false;
|
||||
QList<QDockWidget * > docks(findChildren<QDockWidget * >());
|
||||
foreach (QDockWidget * d, docks) {
|
||||
connect(d, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(changedDock()));
|
||||
connect(d, SIGNAL(topLevelChanged(bool)), this, SLOT(changedDock()));
|
||||
}
|
||||
changedDock();
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::closeEvent(QCloseEvent * e) {
|
||||
if (!checkSave()) e->ignore();
|
||||
}
|
||||
|
||||
|
||||
bool EMainWindow::eventFilter(QObject * o, QEvent * e) {
|
||||
//qDebug() << o << e;
|
||||
if (tbars.contains((QTabBar*)o) && e->type() == QEvent::MouseButtonDblClick) {
|
||||
int tab = ((QTabBar*)o)->tabAt(((QMouseEvent * )e)->pos());
|
||||
if (tab >= 0) {
|
||||
QDockWidget * dock = (QDockWidget * )(((QTabBar*)o)->tabData(tab).toULongLong());
|
||||
if (dock != 0) {
|
||||
dock->setFloating(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e->type() == QEvent::Show || e->type() == QEvent::Hide || e->type() == QEvent::ChildAdded || e->type() == QEvent::ChildRemoved || e->type() == QEvent::MouseButtonPress) {
|
||||
if (tbars.contains((QTabBar*)o) || tdocks.contains((QDockWidget*)o)) {
|
||||
if (e->type() == QEvent::MouseButtonPress) {
|
||||
if (((QMouseEvent*)e)->button() == Qt::RightButton) {
|
||||
bool popup = tbars.contains((QTabBar*)o);
|
||||
if (tdocks.contains((QDockWidget*)o))
|
||||
popup = popup || ((QDockWidget*)o)->titleBarWidget()->geometry().contains(((QMouseEvent*)e)->pos());
|
||||
if (popup) {
|
||||
createPopupMenu()->popup(((QMouseEvent*)e)->globalPos());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e->type() == QEvent::Show || e->type() == QEvent::Hide /*|| e->type() == QEvent::ChildAdded || e->type() == QEvent::ChildRemoved*/) {
|
||||
//qDebug() << "filter";
|
||||
//QMetaObject::invokeMethod(this, "changedDock", Qt::QueuedConnection);
|
||||
changedDock();
|
||||
}
|
||||
}
|
||||
}
|
||||
return QMainWindow::eventFilter(o, e);
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::timerEvent(QTimerEvent * e) {
|
||||
if (e->timerId() == tid) {
|
||||
changedDock();
|
||||
return;
|
||||
}
|
||||
QMainWindow::timerEvent(e);
|
||||
}
|
||||
|
||||
|
||||
QMenu * EMainWindow::createPopupMenu() {
|
||||
QMenu * menuPopup = new QMenu;
|
||||
QWidgetAction * wa;
|
||||
QLabel * lbl;
|
||||
QAction * a;
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
// Toolbars
|
||||
QList<QToolBar * > tools = findChildren<QToolBar * >();
|
||||
if (!tools.isEmpty()) {
|
||||
wa = new QWidgetAction(menuPopup);
|
||||
lbl = new QLabel();
|
||||
lbl->setFrameShape(QFrame::StyledPanel);
|
||||
lbl->setFrameShadow(QFrame::Sunken);
|
||||
lbl->setText(trUtf8("Toolbars"));
|
||||
lbl->setFont(f);
|
||||
lbl->setAlignment(Qt::AlignCenter);
|
||||
wa->setDefaultWidget(lbl);
|
||||
menuPopup->addAction(wa);
|
||||
foreach (QToolBar * i, tools) {
|
||||
if (i->property("ribbon").toBool()) continue;
|
||||
a = new QAction(i->windowTitle(), menuPopup);
|
||||
a->setCheckable(true);
|
||||
a->setChecked(!i->isHidden());
|
||||
a->setIcon(i->windowIcon());
|
||||
connect(a, SIGNAL(toggled(bool)), i, SLOT(setVisible(bool)));
|
||||
menuPopup->addAction(a);
|
||||
};
|
||||
menuPopup->addSeparator();
|
||||
menuPopup->addAction(&action_show_all_tools);
|
||||
menuPopup->addAction(&action_hide_all_tools);
|
||||
}
|
||||
// Docks
|
||||
QList<QDockWidget * > docks = findChildren<QDockWidget * >();
|
||||
if (!docks.isEmpty()) {
|
||||
wa = new QWidgetAction(menuPopup);
|
||||
lbl = new QLabel();
|
||||
lbl->setFrameShape(QFrame::StyledPanel);
|
||||
lbl->setFrameShadow(QFrame::Sunken);
|
||||
lbl->setText(trUtf8("Docks"));
|
||||
lbl->setFont(f);
|
||||
lbl->setAlignment(Qt::AlignCenter);
|
||||
wa->setDefaultWidget(lbl);
|
||||
menuPopup->addAction(wa);
|
||||
foreach (QDockWidget * i, docks) {
|
||||
if (i->property("ribbon").toBool()) continue;
|
||||
a = new QAction(i->windowTitle(), menuPopup);
|
||||
a->setCheckable(true);
|
||||
a->setChecked(!i->isHidden());
|
||||
a->setIcon(i->windowIcon());
|
||||
connect(a, SIGNAL(toggled(bool)), i, SLOT(setVisible(bool)));
|
||||
menuPopup->addAction(a);
|
||||
};
|
||||
menuPopup->addSeparator();
|
||||
menuPopup->addAction(&action_show_all_docks);
|
||||
menuPopup->addAction(&action_hide_all_docks);
|
||||
}
|
||||
return menuPopup;
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::initMenus() {
|
||||
action_show_all_tools.disconnect();
|
||||
action_hide_all_tools.disconnect();
|
||||
action_show_all_docks.disconnect();
|
||||
action_hide_all_docks.disconnect();
|
||||
|
||||
QList<QToolBar * > tools = findChildren<QToolBar * >();
|
||||
foreach (QToolBar * i, tools) {
|
||||
if (i->property("ribbon").toBool()) continue;
|
||||
i->toggleViewAction()->setIcon(i->windowIcon());
|
||||
connect(&action_show_all_tools, SIGNAL(triggered(bool)), i, SLOT(show()));
|
||||
connect(&action_hide_all_tools, SIGNAL(triggered(bool)), i, SLOT(hide()));
|
||||
}
|
||||
|
||||
QList<QDockWidget * > docks = findChildren<QDockWidget * >();
|
||||
foreach (QDockWidget * i, docks) {
|
||||
if (i->property("ribbon").toBool()) continue;
|
||||
i->toggleViewAction()->setIcon(i->windowIcon());
|
||||
connect(&action_show_all_docks, SIGNAL(triggered(bool)), i, SLOT(show()));
|
||||
connect(&action_hide_all_docks, SIGNAL(triggered(bool)), i, SLOT(hide()));
|
||||
}
|
||||
|
||||
QList<QAction * > actions = findChildren<QAction * >();
|
||||
foreach (QAction * i, actions)
|
||||
i->setIconVisibleInMenu(true);
|
||||
addActions(actions);
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::initSession() {
|
||||
connect(&session, SIGNAL(loading(QPIConfig & )), this, SLOT(sessionLoading(QPIConfig & )));
|
||||
connect(&session, SIGNAL(saving(QPIConfig & )), this, SLOT(sessionSaving(QPIConfig & )));
|
||||
session.addEntry("EMainWindow", this);
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::saveSession() {
|
||||
session.save();
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::loadSession() {
|
||||
session.load();
|
||||
}
|
||||
|
||||
|
||||
bool EMainWindow::checkSave() {
|
||||
if (!isWindowModified()) return true;
|
||||
return saveFile(true);
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::changedDock() {
|
||||
QList<QTabBar * > tabs(findChildren<QTabBar * >());
|
||||
QList<QDockWidget * > docks = findChildren<QDockWidget * >();
|
||||
QSet<QDockWidget * > docks_tabs;
|
||||
QDockWidget * dock;
|
||||
//qDebug() << "change";
|
||||
foreach (QTabBar * t, tabs) {
|
||||
if (!t->objectName().isEmpty() || t->isHidden()) continue;
|
||||
if (!tbars.contains(t)) {
|
||||
tbars << t;
|
||||
connect(t, SIGNAL(tabCloseRequested(int)), this, SLOT(closeDock(int)));
|
||||
t->installEventFilter(this);
|
||||
t->setIconSize(dockTabsIconSIze());
|
||||
t->setTabsClosable(true);
|
||||
}
|
||||
//qDebug() << "tab";
|
||||
for (int i = 0; i < t->count(); ++i) {
|
||||
dock = (QDockWidget * )t->tabData(i).toULongLong();
|
||||
//qDebug() << i << dock;
|
||||
if (dock == 0) continue;
|
||||
t->setTabIcon(i, dock->windowIcon());
|
||||
docks_tabs << dock;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QDockWidget * d, docks) {
|
||||
if (d->titleBarWidget() == 0) 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)) {
|
||||
tdocks << d;
|
||||
//connect(t, SIGNAL((QObject*)), this, SLOT(changedDockClose(QObject*)));
|
||||
d->installEventFilter(this);
|
||||
}
|
||||
//d->titleBarWidget()->setHidden(docks_tabs.contains(d));
|
||||
if (tabifiedDockWidgets(d).isEmpty()) {
|
||||
if (d->titleBarWidget() != (QWidget * )(d->property("__titleWidget").toULongLong()))
|
||||
d->setTitleBarWidget((QWidget * )(d->property("__titleWidget").toULongLong()));
|
||||
} else {
|
||||
if (d->titleBarWidget() != (QWidget * )(d->property("__titleEmptyWidget").toULongLong())) {
|
||||
d->setTitleBarWidget((QWidget * )(d->property("__titleEmptyWidget").toULongLong()));
|
||||
d->layout()->setContentsMargins(0, 20, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::changedDockClose(QObject * bar) {
|
||||
//qDebug() << "close" << bar;
|
||||
tbars.removeAll((QTabBar * )bar);
|
||||
changedDock();
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::closeDock(int index) {
|
||||
QDockWidget * dock = (QDockWidget * )((QTabBar*)sender())->tabData(index).toULongLong();
|
||||
if (dock == 0) return;
|
||||
dock->close();
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::newFile() {
|
||||
if (!checkSave()) return;
|
||||
reset(true);
|
||||
setWindowModified(false);
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::openFile() {
|
||||
if (!checkSave()) return;
|
||||
QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select file to open"), file_name, loadFilter());
|
||||
if (ret.isEmpty()) return;
|
||||
load(ret);
|
||||
}
|
||||
|
||||
|
||||
bool EMainWindow::saveFile(bool ask) {
|
||||
if (ask) {
|
||||
int ret = QMessageBox::question(this, windowTitle(), trUtf8("Save changes%1?").arg(!file_name.isEmpty() ? (trUtf8("in") + " \"" + file_name + "\"") : ""), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save);
|
||||
if (ret == QMessageBox::Cancel) return false;
|
||||
if (ret == QMessageBox::Save) return saveFile();
|
||||
return true;
|
||||
}
|
||||
if (file_name.isEmpty()) return saveAsFile();
|
||||
save(file_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool EMainWindow::saveAsFile() {
|
||||
QString ret = QFileDialog::getSaveFileName(this, trUtf8("Select file to save"), file_name, saveFilter());
|
||||
if (ret.isEmpty()) return false;
|
||||
save(ret);
|
||||
return true;
|
||||
}
|
||||
109
qad_application/emainwindow.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef EMAINWINDOW_H
|
||||
#define EMAINWINDOW_H
|
||||
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
#include <QDesktopWidget>
|
||||
#include <QInputDialog>
|
||||
#include <QClipboard>
|
||||
#include <QRadioButton>
|
||||
#include <QThread>
|
||||
#include <QColorDialog>
|
||||
#include <QTime>
|
||||
#include <QSplitter>
|
||||
#include "session_manager.h"
|
||||
#include "ribbon.h"
|
||||
|
||||
class UAction: public QAction {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UAction(int ind,const QString & text, QObject * parent): QAction(text, parent) {
|
||||
index = ind;
|
||||
connect(this, SIGNAL(triggered()), this, SLOT(triggered()));
|
||||
connect(this, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
|
||||
connect(this, SIGNAL(hovered()), this, SLOT(hovered()));
|
||||
}
|
||||
UAction(int ind, const QIcon & icon, const QString & text, QObject * parent): QAction(icon, text, parent) {
|
||||
index = ind;
|
||||
connect(this, SIGNAL(triggered()), this, SLOT(triggered()));
|
||||
connect(this, SIGNAL(toggled(bool)), this, SLOT(toggled(bool)));
|
||||
connect(this, SIGNAL(hovered()), this, SLOT(hovered()));
|
||||
}
|
||||
public slots:
|
||||
void show() {setVisible(true);}
|
||||
void hide() {setVisible(false);}
|
||||
void setCheckedTrue() {setChecked(true);}
|
||||
void setCheckedFalse() {setChecked(false);}
|
||||
private:
|
||||
int index;
|
||||
private slots:
|
||||
void triggered() {emit itriggered(this, index);}
|
||||
void toggled(bool t) {emit itoggled(t, this, index);}
|
||||
void hovered() {emit ihovered(this);}
|
||||
signals:
|
||||
void itriggered(QAction *, int);
|
||||
void itoggled(bool, QAction *, int);
|
||||
void ihovered(QAction * action);
|
||||
};
|
||||
|
||||
|
||||
class EMainWindow: public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EMainWindow(QWidget * parent = 0);
|
||||
~EMainWindow();
|
||||
|
||||
virtual void reset(bool full = false) {}
|
||||
virtual bool load(const QString & path) {return true;}
|
||||
virtual bool save(const QString & path) {return true;}
|
||||
|
||||
void addSeparator() {}
|
||||
|
||||
protected:
|
||||
// Qt`s overloaded
|
||||
void showEvent(QShowEvent * );
|
||||
void closeEvent(QCloseEvent * );
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void timerEvent(QTimerEvent * e);
|
||||
QMenu * createPopupMenu();
|
||||
|
||||
void init(const QString & config) {session.setFile(config); initMenus(); initSession(); loadSession();}
|
||||
void initMenus();
|
||||
void initSession();
|
||||
virtual void saveSession();
|
||||
virtual void loadSession();
|
||||
virtual QSize dockTabsIconSIze() const {return iconSize();}
|
||||
virtual QString loadFilter() {return "All files(*)";}
|
||||
virtual QString saveFilter() {return "All files(*)";}
|
||||
|
||||
bool checkSave();
|
||||
void setChanged(bool yes = true) {isChanged = yes; setWindowModified(yes);}
|
||||
|
||||
QAction action_show_all_tools, action_hide_all_tools, action_show_all_docks, action_hide_all_docks;
|
||||
QString file_name, title_src;
|
||||
QList<QTabBar * > tbars;
|
||||
QList<QDockWidget * > tdocks;
|
||||
SessionManager session;
|
||||
bool isChanged, first_show;
|
||||
int tid;
|
||||
|
||||
private slots:
|
||||
void changedDock();
|
||||
void changedDockClose(QObject * bar);
|
||||
void closeDock(int index);
|
||||
virtual void sessionLoading(QPIConfig & conf) {}
|
||||
virtual void sessionSaving(QPIConfig & conf) {}
|
||||
|
||||
public slots:
|
||||
void changed() {setChanged(true);}
|
||||
void newFile();
|
||||
void openFile();
|
||||
bool saveFile(bool ask = false);
|
||||
bool saveAsFile();
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
69
qad_application/emainwindowplugin.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "emainwindow.h"
|
||||
#include "emainwindowplugin.h"
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
|
||||
EMainWindowPlugin::EMainWindowPlugin(QObject * parent): QObject(parent) {
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
void EMainWindowPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
||||
if (m_initialized)
|
||||
return;
|
||||
|
||||
// Add extension registrations, etc. here
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
bool EMainWindowPlugin::isInitialized() const {
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
|
||||
QWidget * EMainWindowPlugin::createWidget(QWidget * parent) {
|
||||
return new EMainWindow(parent);
|
||||
}
|
||||
|
||||
|
||||
QString EMainWindowPlugin::name() const {
|
||||
return QLatin1String("EMainWindow");
|
||||
}
|
||||
|
||||
|
||||
QString EMainWindowPlugin::group() const {
|
||||
return QLatin1String("Containers");
|
||||
}
|
||||
|
||||
|
||||
QIcon EMainWindowPlugin::icon() const {
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
|
||||
QString EMainWindowPlugin::toolTip() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
QString EMainWindowPlugin::whatsThis() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
bool EMainWindowPlugin::isContainer() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString EMainWindowPlugin::domXml() const {
|
||||
return QLatin1String("<widget class=\"EMainWindow\" name=\"mainWindow\">\n</widget>\n");
|
||||
}
|
||||
|
||||
|
||||
QString EMainWindowPlugin::includeFile() const {
|
||||
return QLatin1String("emainwindow.h");
|
||||
}
|
||||
|
||||
31
qad_application/emainwindowplugin.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef EMAINWINDOWPLUGIN_H
|
||||
#define EMAINWINDOWPLUGIN_H
|
||||
|
||||
#include <QDesignerCustomWidgetInterface>
|
||||
|
||||
class EMainWindowPlugin: public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||
|
||||
public:
|
||||
EMainWindowPlugin(QObject * parent = 0);
|
||||
|
||||
bool isContainer() const;
|
||||
bool isInitialized() const;
|
||||
QIcon icon() const;
|
||||
QString domXml() const;
|
||||
QString group() const;
|
||||
QString includeFile() const;
|
||||
QString name() const;
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QWidget * createWidget(QWidget * parent);
|
||||
void initialize(QDesignerFormEditorInterface * core);
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
104
qad_application/etabwidget.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
#include "etabwidget.h"
|
||||
|
||||
|
||||
ETabWidget::ETabWidget(QWidget* parent): QTabWidget(parent) {
|
||||
tabBar()->setMouseTracking(true);
|
||||
tabBar()->installEventFilter(this);
|
||||
}
|
||||
|
||||
|
||||
void ETabWidget::retranslate() {
|
||||
for (int i = 0; i < buttons.size(); ++i)
|
||||
buttons[i].toolTip = QApplication::translate("MainWindow", buttons[i].srcToolTip.toUtf8(), 0, QCoreApplication::UnicodeUTF8);
|
||||
QList<QToolButton * > bl = findChildren<QToolButton * >();
|
||||
foreach (QToolButton * i, bl)
|
||||
i->setToolTip(QApplication::translate("MainWindow", i->property("sourceToolTip").toString().toUtf8(), 0, QCoreApplication::UnicodeUTF8));
|
||||
}
|
||||
|
||||
|
||||
int ETabWidget::addTab(QWidget * page, const QIcon & icon, const QString & label) {
|
||||
int ret = QTabWidget::addTab(page, icon, label);
|
||||
QWidget * w = new QWidget();
|
||||
w->setLayout(new QBoxLayout(QBoxLayout::RightToLeft));
|
||||
w->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
w->layout()->setSpacing(2);
|
||||
QToolButton * b;
|
||||
foreach (const TabButton & i, buttons) {
|
||||
b = new QToolButton();
|
||||
b->setToolTip(i.toolTip);
|
||||
b->setIconSize(QSize(16, 16));
|
||||
b->setIcon(i.icon);
|
||||
//b->setFlat(true);
|
||||
b->setProperty("sourceToolTip", i.toolTip);
|
||||
b->setProperty("buttonRole", i.role);
|
||||
connect(b, SIGNAL(clicked(bool)), this, SLOT(buttonClicked()));
|
||||
w->layout()->addWidget(b);
|
||||
b->setVisible(i.visible);
|
||||
}
|
||||
tabBar()->setTabButton(ret, QTabBar::RightSide, w);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void ETabWidget::setButtonVisible(int role, bool yes) {
|
||||
QList<QToolButton * > bl = findChildren<QToolButton * >();
|
||||
foreach (QToolButton * i, bl)
|
||||
if (i->property("buttonRole").toInt() == role)
|
||||
i->setVisible(yes);
|
||||
QWidget * w;
|
||||
for (int i = 0; i < buttons.size(); ++i) {
|
||||
if (buttons[i].role == role)
|
||||
buttons[i].visible = yes;
|
||||
w = tabBar()->tabButton(i, QTabBar::RightSide);
|
||||
if (w != 0) w->adjustSize();
|
||||
}
|
||||
tabBar()->adjustSize();
|
||||
}
|
||||
|
||||
/*
|
||||
void ETabWidget::removeTab(int index) {
|
||||
tbs.removeAll(qobject_cast<QToolButton * >(tabBar()->tabButton(index, QTabBar::RightSide)->layout()->itemAt(1)->widget()));
|
||||
tbs.removeAll(qobject_cast<QToolButton * >(tabBar()->tabButton(index, QTabBar::RightSide)->layout()->itemAt(0)->widget()));
|
||||
QTabWidget::removeTab(index);
|
||||
}
|
||||
*/
|
||||
|
||||
bool ETabWidget::eventFilter(QObject * o, QEvent * e) {
|
||||
static int prev = -1;
|
||||
if (e->type() == QEvent::MouseMove) {
|
||||
QTabBar * t = qobject_cast<QTabBar * >(o);
|
||||
if (t == 0) return QTabWidget::eventFilter(o, e);
|
||||
for (int i = 0; i < count(); ++i)
|
||||
if (t->tabRect(i).contains(((QMouseEvent * )e)->pos())) {
|
||||
if (i != prev) {
|
||||
prev = i;
|
||||
emit tabHovered(i);
|
||||
}
|
||||
return QTabWidget::eventFilter(o, e);
|
||||
}
|
||||
if (-1 != prev) {
|
||||
prev = -1;
|
||||
emit tabHovered(-1);
|
||||
}
|
||||
}
|
||||
if (e->type() == QEvent::Leave) {
|
||||
if (-1 != prev) {
|
||||
prev = -1;
|
||||
emit tabHovered(-1);
|
||||
}
|
||||
}
|
||||
return QTabWidget::eventFilter(o, e);
|
||||
}
|
||||
|
||||
|
||||
void ETabWidget::buttonClicked() {
|
||||
QToolButton * s = qobject_cast<QToolButton * >(sender());
|
||||
if (s == 0) return;
|
||||
QWidget * pw = s->parentWidget();
|
||||
if (pw == 0) return;
|
||||
for (int i = 0; i < count(); ++i)
|
||||
if (tabBar()->tabButton(i, QTabBar::RightSide) == pw) {
|
||||
emit tabButtonClicked(i, s->property("buttonRole").toInt());
|
||||
return;
|
||||
}
|
||||
}
|
||||
54
qad_application/etabwidget.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef ETABWIDGET_H
|
||||
#define ETABWIDGET_H
|
||||
|
||||
#include <QTabWidget>
|
||||
#include <QDebug>
|
||||
#include <QTabBar>
|
||||
#include <QMouseEvent>
|
||||
#include <QEvent>
|
||||
#include <QToolButton>
|
||||
#include <QPushButton>
|
||||
#include <QLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
class ETabWidget: public QTabWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ETabWidget(QWidget * parent = 0);
|
||||
|
||||
void retranslate();
|
||||
void addTabButton(int role, const QIcon & icon, const QString & toolTip = QString()) {buttons << TabButton(role, icon, toolTip);}
|
||||
int addTab(QWidget * page, const QIcon & icon, const QString & label);
|
||||
int addTab(QWidget * page, const QString & label) {return addTab(page, QIcon(), label);}
|
||||
void setButtonVisible(int role, bool yes);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void tabInserted(int) {emit countChanged();}
|
||||
void tabRemoved(int) {emit countChanged();}
|
||||
|
||||
struct TabButton {
|
||||
TabButton(int r, const QIcon & i, const QString & t) {role = r; icon = i; visible = true; srcToolTip = t; toolTip = QApplication::translate("MainWindow", t.toUtf8(), 0, QCoreApplication::UnicodeUTF8);}
|
||||
int role;
|
||||
bool visible;
|
||||
QIcon icon;
|
||||
QString srcToolTip;
|
||||
QString toolTip;
|
||||
};
|
||||
|
||||
QList<TabButton> buttons;
|
||||
|
||||
private slots:
|
||||
void buttonClicked();
|
||||
|
||||
signals:
|
||||
void countChanged();
|
||||
void tabHovered(int tab);
|
||||
void tabButtonClicked(int tab, int role);
|
||||
|
||||
};
|
||||
|
||||
#endif // ETABWIDGET_H
|
||||
0
qad_application/gpio.conf
Normal file
138
qad_application/historyview.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
#include "historyview.h"
|
||||
|
||||
|
||||
HistoryView::HistoryView(QWidget* parent): QListWidget(parent) {
|
||||
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
setEditTriggers(NoEditTriggers);
|
||||
active_ = true;
|
||||
index = 0;
|
||||
setLimit(32);
|
||||
setHistoryColor(palette().color(QPalette::Highlight));
|
||||
connect(this, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemClicked(QListWidgetItem*)));
|
||||
connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelectionChanged()));
|
||||
registerAction(-1, tr("History cleared"), QImage(":/icons/clear-history.png"));
|
||||
}
|
||||
|
||||
|
||||
HistoryView::~HistoryView() {
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::addEntry(int action, int count_, const QString & suffix) {
|
||||
if (!active_) return;
|
||||
int cnt = count();
|
||||
for (int i = index; i < cnt; ++i)
|
||||
if (i >= 0) delete takeItem(index);
|
||||
addItem(new QListWidgetItem(actions_.value(action).icon, actionText(action, count_) + suffix));
|
||||
index = count();
|
||||
history_.resize(index);
|
||||
history_.back() = Entry(action);
|
||||
checkLimit();
|
||||
emit commandRequest(history_.back().command);
|
||||
scrollToItem(item(index - 1));
|
||||
blockSignals(true);
|
||||
for (int i = 0; i < index; ++i)
|
||||
item(i)->setSelected(true);
|
||||
blockSignals(false);
|
||||
emit redoAvailable(false);
|
||||
emit undoAvailable((index > 1));
|
||||
emit clearAvailable(history_.count() > 1);
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::registerAction(int action, const QString & text, const QImage & icon) {
|
||||
actions_[action] = HistoryView::Action(action, text, icon);
|
||||
}
|
||||
|
||||
|
||||
QString HistoryView::actionText(int action, int count_) {
|
||||
return QString(actions_.value(action).text).replace("%count", QString::number(count_));
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::checkLimit() {
|
||||
if (count() < limit_ + 1) return;
|
||||
int c = count() - limit_;
|
||||
for (int i = 0; i < c; ++i) {
|
||||
if (i >= index - 1) {
|
||||
if (count() < 2) break;
|
||||
delete takeItem(1);
|
||||
history_.remove(1);
|
||||
} else {
|
||||
if (count() < 1) break;
|
||||
delete takeItem(0);
|
||||
history_.pop_front();
|
||||
index--;
|
||||
}
|
||||
}
|
||||
if (index < 1) index = 1;
|
||||
if (index > count()) index = count();
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::itemClicked(QListWidgetItem * item) {
|
||||
if (!active_) return;
|
||||
if (index == row(item) + 1) return;
|
||||
index = row(item) + 1;
|
||||
//qDebug() << actions[index - 1].command;
|
||||
emit commandExecute(history_[index - 1].command);
|
||||
itemSelectionChanged();
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::itemSelectionChanged() {
|
||||
if (!active_) return;
|
||||
if (index < 1) index = 1;
|
||||
//qDebug() << "changed" << count();
|
||||
blockSignals(true);
|
||||
for (int i = 0; i < index; ++i)
|
||||
item(i)->setSelected(true);
|
||||
for (int i = index; i < count(); ++i)
|
||||
item(i)->setSelected(false);
|
||||
blockSignals(false);
|
||||
emit redoAvailable(index < count());
|
||||
emit undoAvailable((index > 1));
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::setLimit(int l) {
|
||||
limit_ = l;
|
||||
checkLimit();
|
||||
emit redoAvailable(index < count());
|
||||
emit undoAvailable((index > 1));
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::setHistoryColor(const QColor & c) {
|
||||
color_ = c;
|
||||
QPalette pal(palette());
|
||||
pal.setColor(QPalette::Highlight, color_);
|
||||
pal.setColor(QPalette::HighlightedText, pal.color(QPalette::Text));
|
||||
setPalette(pal);
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::clear(bool silent) {
|
||||
history_.clear();
|
||||
QListWidget::clear();
|
||||
if (!silent) addEntry(-1);
|
||||
emit clearAvailable(false);
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::undo() {
|
||||
if (index <= 1) return;
|
||||
index--;
|
||||
emit commandExecute(history_[index - 1].command);
|
||||
itemSelectionChanged();
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::redo() {
|
||||
if (index > count()) return;
|
||||
index++;
|
||||
emit commandExecute(history_[index - 1].command);
|
||||
itemSelectionChanged();
|
||||
}
|
||||
74
qad_application/historyview.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef HISTORYVIEW_H
|
||||
#define HISTORYVIEW_H
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
class HistoryView: public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int limit READ limit WRITE setLimit)
|
||||
Q_PROPERTY(QColor historyColor READ historyColor WRITE setHistoryColor)
|
||||
public:
|
||||
explicit HistoryView(QWidget * parent = 0);
|
||||
~HistoryView();
|
||||
|
||||
bool isActive() const {return active_;}
|
||||
int limit() const {return limit_;}
|
||||
QColor historyColor() const {return color_;}
|
||||
|
||||
void addEntry(int action, int count = 0, const QString & suffix = QString());
|
||||
void registerAction(int action, const QString & text, const QImage & icon = QImage());
|
||||
|
||||
private:
|
||||
struct Action {
|
||||
Action(int i = -1, const QString & t = QString(), const QImage & c = QImage()): id(i), text(t) {
|
||||
QPixmap px = QPixmap::fromImage(c);
|
||||
icon.addPixmap(px, QIcon::Active);
|
||||
icon.addPixmap(px, QIcon::Disabled);
|
||||
icon.addPixmap(px, QIcon::Normal);
|
||||
icon.addPixmap(px, QIcon::Selected);
|
||||
}
|
||||
int id;
|
||||
QString text;
|
||||
QIcon icon;
|
||||
};
|
||||
struct Entry {
|
||||
Entry(int a = -1, const QByteArray & c = QByteArray()): action(a), command(c) {}
|
||||
int action;
|
||||
QByteArray command;
|
||||
};
|
||||
|
||||
void checkLimit();
|
||||
QString actionText(int action, int count_);
|
||||
|
||||
QMap<int, Action> actions_;
|
||||
QVector<Entry> history_;
|
||||
QColor color_;
|
||||
bool active_;
|
||||
int index, limit_;
|
||||
|
||||
public slots:
|
||||
void setActive(bool yes) {active_ = yes;}
|
||||
void setLimit(int l);
|
||||
void setHistoryColor(const QColor & c);
|
||||
void clear(bool silent = false);
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
private slots:
|
||||
void itemClicked(QListWidgetItem * item);
|
||||
void itemSelectionChanged();
|
||||
|
||||
signals:
|
||||
void undoAvailable(bool);
|
||||
void redoAvailable(bool);
|
||||
void clearAvailable(bool);
|
||||
void commandRequest(QByteArray & s);
|
||||
void commandExecute(const QByteArray & s);
|
||||
|
||||
};
|
||||
|
||||
#endif // HISTORYVIEW_H
|
||||
69
qad_application/historyviewplugin.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#include "historyview.h"
|
||||
#include "historyviewplugin.h"
|
||||
#include <QtCore/QtPlugin>
|
||||
|
||||
|
||||
HistoryViewPlugin::HistoryViewPlugin(QObject * parent): QObject(parent) {
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
void HistoryViewPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
|
||||
if (m_initialized)
|
||||
return;
|
||||
|
||||
// Add extension registrations, etc. here
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
bool HistoryViewPlugin::isInitialized() const {
|
||||
return m_initialized;
|
||||
}
|
||||
|
||||
|
||||
QWidget * HistoryViewPlugin::createWidget(QWidget * parent) {
|
||||
return new HistoryView(parent);
|
||||
}
|
||||
|
||||
|
||||
QString HistoryViewPlugin::name() const {
|
||||
return QLatin1String("HistoryView");
|
||||
}
|
||||
|
||||
|
||||
QString HistoryViewPlugin::group() const {
|
||||
return QLatin1String("Display Widgets");
|
||||
}
|
||||
|
||||
|
||||
QIcon HistoryViewPlugin::icon() const {
|
||||
return QIcon(":/icons/historyview.png");
|
||||
}
|
||||
|
||||
|
||||
QString HistoryViewPlugin::toolTip() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
QString HistoryViewPlugin::whatsThis() const {
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
bool HistoryViewPlugin::isContainer() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString HistoryViewPlugin::domXml() const {
|
||||
return QLatin1String("<widget class=\"HistoryView\" name=\"historyView\">\n</widget>\n");
|
||||
}
|
||||
|
||||
|
||||
QString HistoryViewPlugin::includeFile() const {
|
||||
return QLatin1String("historyview.h");
|
||||
}
|
||||
|
||||
31
qad_application/historyviewplugin.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef HISTORYVIEWPLUGIN_H
|
||||
#define HISTORYVIEWPLUGIN_H
|
||||
|
||||
#include <QDesignerCustomWidgetInterface>
|
||||
|
||||
class HistoryViewPlugin: public QObject, public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||
|
||||
public:
|
||||
HistoryViewPlugin(QObject * parent = 0);
|
||||
|
||||
bool isContainer() const;
|
||||
bool isInitialized() const;
|
||||
QIcon icon() const;
|
||||
QString domXml() const;
|
||||
QString group() const;
|
||||
QString includeFile() const;
|
||||
QString name() const;
|
||||
QString toolTip() const;
|
||||
QString whatsThis() const;
|
||||
QWidget * createWidget(QWidget * parent);
|
||||
void initialize(QDesignerFormEditorInterface * core);
|
||||
|
||||
private:
|
||||
bool m_initialized;
|
||||
|
||||
};
|
||||
|
||||
#endif // HISTORYVIEWPLUGIN_H
|
||||
BIN
qad_application/icons/border-line.png
Normal file
|
After Width: | Height: | Size: 183 B |
BIN
qad_application/icons/clear-history.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
qad_application/icons/configure.png
Normal file
|
After Width: | Height: | Size: 717 B |
BIN
qad_application/icons/dialog-close.png
Normal file
|
After Width: | Height: | Size: 813 B |
BIN
qad_application/icons/document-save.png
Normal file
|
After Width: | Height: | Size: 563 B |
BIN
qad_application/icons/edit-clear-locationbar-rtl.png
Normal file
|
After Width: | Height: | Size: 644 B |
BIN
qad_application/icons/edit-clear.png
Normal file
|
After Width: | Height: | Size: 802 B |
BIN
qad_application/icons/edit-copy.png
Normal file
|
After Width: | Height: | Size: 485 B |
BIN
qad_application/icons/edit-delete.png
Normal file
|
After Width: | Height: | Size: 640 B |
BIN
qad_application/icons/edit-find.png
Normal file
|
After Width: | Height: | Size: 634 B |
BIN
qad_application/icons/edit-guides.png
Normal file
|
After Width: | Height: | Size: 544 B |
BIN
qad_application/icons/edit-paste.png
Normal file
|
After Width: | Height: | Size: 529 B |
BIN
qad_application/icons/edockwidget.png
Normal file
|
After Width: | Height: | Size: 638 B |
BIN
qad_application/icons/expand_s_x.png
Normal file
|
After Width: | Height: | Size: 571 B |
BIN
qad_application/icons/expand_s_y.png
Normal file
|
After Width: | Height: | Size: 577 B |
BIN
qad_application/icons/expand_x.png
Normal file
|
After Width: | Height: | Size: 579 B |
BIN
qad_application/icons/expand_y.png
Normal file
|
After Width: | Height: | Size: 577 B |
BIN
qad_application/icons/graphic.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
qad_application/icons/historyview.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
qad_application/icons/item.png
Normal file
|
After Width: | Height: | Size: 448 B |
BIN
qad_application/icons/layer-visible-off.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
qad_application/icons/layer-visible-on.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
qad_application/icons/legend.png
Normal file
|
After Width: | Height: | Size: 810 B |
BIN
qad_application/icons/list-add.png
Normal file
|
After Width: | Height: | Size: 564 B |
BIN
qad_application/icons/node-add.png
Normal file
|
After Width: | Height: | Size: 694 B |
BIN
qad_application/icons/node.png
Normal file
|
After Width: | Height: | Size: 658 B |
BIN
qad_application/icons/view-grid.png
Normal file
|
After Width: | Height: | Size: 691 B |
BIN
qad_application/icons/zoom-fit-best.png
Normal file
|
After Width: | Height: | Size: 539 B |
290
qad_application/lang/qad_application_ru.ts
Normal file
@@ -0,0 +1,290 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="ru_RU">
|
||||
<context>
|
||||
<name>Graphic</name>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="44"/>
|
||||
<source>Autofit</source>
|
||||
<translation>Автомасштаб</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="61"/>
|
||||
<source>Grid</source>
|
||||
<translation>Сетка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="84"/>
|
||||
<source>Cursor axis</source>
|
||||
<translation>Плавающие оси</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="104"/>
|
||||
<source>Only expand Y</source>
|
||||
<translation>Только расширять Y</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="124"/>
|
||||
<source>Only expand X</source>
|
||||
<translation>Только расширять X</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="144"/>
|
||||
<source>Border inputs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="167"/>
|
||||
<source>Legend</source>
|
||||
<translation>Легенда</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="190"/>
|
||||
<source>Configure ...</source>
|
||||
<translation>Настроить ...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="207"/>
|
||||
<source>Save image ...</source>
|
||||
<translation>Сохранить изображение ...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="240"/>
|
||||
<source>Clear</source>
|
||||
<translation>Очистить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="257"/>
|
||||
<source>Close</source>
|
||||
<translation>Закрыть</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.ui" line="408"/>
|
||||
<source>Cursor: ( ; )</source>
|
||||
<translation>Курсор: ( ; )</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="198"/>
|
||||
<location filename="../graphic.cpp" line="784"/>
|
||||
<source>Cursor: </source>
|
||||
<translation>Курсор: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="209"/>
|
||||
<source>Selection</source>
|
||||
<translation>Выделение</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="210"/>
|
||||
<source>Size</source>
|
||||
<translation>Размер</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="214"/>
|
||||
<location filename="../graphic.cpp" line="220"/>
|
||||
<source>Range</source>
|
||||
<translation>Диапазон</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="215"/>
|
||||
<location filename="../graphic.cpp" line="221"/>
|
||||
<source>Length</source>
|
||||
<translation>Длина</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="322"/>
|
||||
<location filename="../graphic.cpp" line="367"/>
|
||||
<source>Cursor</source>
|
||||
<translation>Курсор</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="508"/>
|
||||
<source>Save Image</source>
|
||||
<translation>Сохранить изображение</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="553"/>
|
||||
<source>y(x)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic.cpp" line="1096"/>
|
||||
<source>Check all</source>
|
||||
<translation>Выбрать все</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GraphicConf</name>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="17"/>
|
||||
<source>Graphic parameters</source>
|
||||
<translation>Параметры графика</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="32"/>
|
||||
<source>Appearance</source>
|
||||
<translation>Внешний вид</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="46"/>
|
||||
<source>Border inputs</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="53"/>
|
||||
<source>Antialiasing</source>
|
||||
<translation>Сглаживание</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="60"/>
|
||||
<source>Status bar</source>
|
||||
<translation>Панель статуса</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="67"/>
|
||||
<source>OpenGL</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="74"/>
|
||||
<source>Legend</source>
|
||||
<translation>Легенда</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="94"/>
|
||||
<source>Background color:</source>
|
||||
<translation>Цвет фона:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="114"/>
|
||||
<source>Text color:</source>
|
||||
<translation>Цвет текста:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="133"/>
|
||||
<source>Graphics</source>
|
||||
<translation>Графики</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="161"/>
|
||||
<location filename="../graphic_conf.ui" line="263"/>
|
||||
<source>Color:</source>
|
||||
<translation>Цвет:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="175"/>
|
||||
<location filename="../graphic_conf.ui" line="277"/>
|
||||
<source>Style:</source>
|
||||
<translation>Стиль:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="185"/>
|
||||
<source>Lines width:</source>
|
||||
<translation>Толщина линий:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="205"/>
|
||||
<source>Points width:</source>
|
||||
<translation>Толщина точек:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="225"/>
|
||||
<source>Fill:</source>
|
||||
<translation>Заливка:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="245"/>
|
||||
<source>Grid</source>
|
||||
<translation>Сетка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="287"/>
|
||||
<source>Width:</source>
|
||||
<translation>Толщина:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="317"/>
|
||||
<source>Step X:</source>
|
||||
<translation>Шаг X:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="324"/>
|
||||
<source>Step Y:</source>
|
||||
<translation>Шаг Y:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="347"/>
|
||||
<source>Auto step</source>
|
||||
<translation>Автоматический шаг</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="380"/>
|
||||
<source>Margins</source>
|
||||
<translation>Поля</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="392"/>
|
||||
<location filename="../graphic_conf.ui" line="402"/>
|
||||
<location filename="../graphic_conf.ui" line="422"/>
|
||||
<location filename="../graphic_conf.ui" line="462"/>
|
||||
<location filename="../graphic_conf.ui" line="482"/>
|
||||
<source> px</source>
|
||||
<translation> пикс</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="412"/>
|
||||
<source>All:</source>
|
||||
<translation>Все:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="432"/>
|
||||
<source>Right:</source>
|
||||
<translation>Правое:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="442"/>
|
||||
<source>Left:</source>
|
||||
<translation>Левое:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="452"/>
|
||||
<source>Bottom:</source>
|
||||
<translation>Нижнее:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.ui" line="472"/>
|
||||
<source>Top:</source>
|
||||
<translation>Верхнее:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="7"/>
|
||||
<source>NoPen</source>
|
||||
<translation>НетЛинии</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="7"/>
|
||||
<source>Solid</source>
|
||||
<translation>Сплошная</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="7"/>
|
||||
<source>Dash</source>
|
||||
<translation>Штриховая</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="8"/>
|
||||
<source>Dot</source>
|
||||
<translation>Пунктирная</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="8"/>
|
||||
<source>Dash-Dot</source>
|
||||
<translation>ШтрихПунктирная</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../graphic_conf.cpp" line="8"/>
|
||||
<source>Dash-Dot-Dot</source>
|
||||
<translation>ШтрихПунктирПунктирная</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
1
qad_application/make_lib.bat
Normal file
@@ -0,0 +1 @@
|
||||
cmake_mgw -DLIB= && make install %* && qmake && make install %*
|
||||
19
qad_application/qad_application.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "edockwidgetplugin.h"
|
||||
#include "emainwindowplugin.h"
|
||||
#include "historyviewplugin.h"
|
||||
#include "qad_application.h"
|
||||
|
||||
|
||||
QADApplication::QADApplication(QObject * parent): QObject(parent) {
|
||||
//m_widgets.append(new EDockWidgetPlugin(this));
|
||||
m_widgets.append(new EMainWindowPlugin(this));
|
||||
m_widgets.append(new HistoryViewPlugin(this));
|
||||
}
|
||||
|
||||
|
||||
QList<QDesignerCustomWidgetInterface * > QADApplication::customWidgets() const {
|
||||
return m_widgets;
|
||||
}
|
||||
|
||||
|
||||
Q_EXPORT_PLUGIN2(qad_graphic_plugin, QADApplication)
|
||||
21
qad_application/qad_application.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef QAD_APPLICATION_H
|
||||
#define QAD_APPLICATION_H
|
||||
|
||||
#include <QtDesigner/QtDesigner>
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
class QADApplication: public QObject, public QDesignerCustomWidgetCollectionInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
|
||||
|
||||
public:
|
||||
explicit QADApplication(QObject * parent = 0);
|
||||
virtual QList<QDesignerCustomWidgetInterface * > customWidgets() const;
|
||||
|
||||
private:
|
||||
QList<QDesignerCustomWidgetInterface * > m_widgets;
|
||||
|
||||
};
|
||||
|
||||
#endif // QAD_APPLICATION_H
|
||||
3
qad_application/qad_application.kdev4
Normal file
@@ -0,0 +1,3 @@
|
||||
[Project]
|
||||
Manager=KDevCMakeManager
|
||||
Name=qad_application
|
||||
18
qad_application/qad_application.pro
Normal file
@@ -0,0 +1,18 @@
|
||||
### eqmake4 was here ###
|
||||
CONFIG += designer plugin release
|
||||
TARGET = $$qtLibraryTarget(qad_application_plugin)
|
||||
TEMPLATE = lib
|
||||
|
||||
HEADERS = qad_application.h edockwidgetplugin.h emainwindowplugin.h historyviewplugin.h
|
||||
SOURCES = qad_application.cpp edockwidgetplugin.cpp emainwindowplugin.cpp historyviewplugin.cpp
|
||||
RESOURCES = qad_application.qrc
|
||||
TRANSLATIONS = lang/qad_application_ru.ts
|
||||
LIBS += -L. -lqad_utils -lqad_application
|
||||
QMAKE_CXXFLAGS += -g3
|
||||
QMAKE_CFLAGS += -g3
|
||||
|
||||
target.path = $$[QT_INSTALL_PLUGINS]/designer
|
||||
INSTALLS += target
|
||||
|
||||
CONFIG -= debug_and_release debug
|
||||
CONFIG += release
|
||||
33
qad_application/qad_application.qrc
Normal file
@@ -0,0 +1,33 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/dialog-close.png</file>
|
||||
<file>icons/edit-clear.png</file>
|
||||
<file>icons/edit-guides.png</file>
|
||||
<file>icons/view-grid.png</file>
|
||||
<file>icons/zoom-fit-best.png</file>
|
||||
<file>icons/configure.png</file>
|
||||
<file>icons/document-save.png</file>
|
||||
<file>icons/edit-clear-locationbar-rtl.png</file>
|
||||
<file>icons/edit-find.png</file>
|
||||
<file>icons/list-add.png</file>
|
||||
<file>icons/edit-delete.png</file>
|
||||
<file>icons/item.png</file>
|
||||
<file>icons/node-add.png</file>
|
||||
<file>icons/node.png</file>
|
||||
<file>icons/edit-copy.png</file>
|
||||
<file>icons/edit-paste.png</file>
|
||||
<file>icons/expand_s_x.png</file>
|
||||
<file>icons/expand_s_y.png</file>
|
||||
<file>icons/expand_x.png</file>
|
||||
<file>icons/expand_y.png</file>
|
||||
<file>icons/border-line.png</file>
|
||||
<file>icons/legend.png</file>
|
||||
<file>icons/graphic.png</file>
|
||||
<file>lang/qad_application_ru.ts</file>
|
||||
<file>icons/edockwidget.png</file>
|
||||
<file>icons/layer-visible-off.png</file>
|
||||
<file>icons/layer-visible-on.png</file>
|
||||
<file>icons/historyview.png</file>
|
||||
<file>icons/clear-history.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
33
qad_application/qad_application.qrc.depends
Normal file
@@ -0,0 +1,33 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/dialog-close.png</file>
|
||||
<file>icons/edit-clear.png</file>
|
||||
<file>icons/edit-guides.png</file>
|
||||
<file>icons/view-grid.png</file>
|
||||
<file>icons/zoom-fit-best.png</file>
|
||||
<file>icons/configure.png</file>
|
||||
<file>icons/document-save.png</file>
|
||||
<file>icons/edit-clear-locationbar-rtl.png</file>
|
||||
<file>icons/edit-find.png</file>
|
||||
<file>icons/list-add.png</file>
|
||||
<file>icons/edit-delete.png</file>
|
||||
<file>icons/item.png</file>
|
||||
<file>icons/node-add.png</file>
|
||||
<file>icons/node.png</file>
|
||||
<file>icons/edit-copy.png</file>
|
||||
<file>icons/edit-paste.png</file>
|
||||
<file>icons/expand_s_x.png</file>
|
||||
<file>icons/expand_s_y.png</file>
|
||||
<file>icons/expand_x.png</file>
|
||||
<file>icons/expand_y.png</file>
|
||||
<file>icons/border-line.png</file>
|
||||
<file>icons/legend.png</file>
|
||||
<file>icons/graphic.png</file>
|
||||
<file>lang/qad_application_ru.ts</file>
|
||||
<file>icons/edockwidget.png</file>
|
||||
<file>icons/layer-visible-off.png</file>
|
||||
<file>icons/layer-visible-on.png</file>
|
||||
<file>icons/historyview.png</file>
|
||||
<file>icons/clear-history.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
87
qad_application/qsingleapplication.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include <QDebug>
|
||||
#include "qsingleapplication.h"
|
||||
|
||||
|
||||
#define QSA_SHMSIZE 4096
|
||||
#define QSA_MSGSIZE (QSA_SHMSIZE - sizeof(quint32) - sizeof(quint32))
|
||||
|
||||
|
||||
QSingleApplication::QSingleApplication(const QString & app_name): QThread() {
|
||||
shm.setKey(app_name);
|
||||
exiting = false;
|
||||
first = !shm.attach();
|
||||
if (!first) {
|
||||
shm.detach();
|
||||
first = !shm.attach();
|
||||
if (!first)
|
||||
return;
|
||||
}
|
||||
shm.create(QSA_SHMSIZE);
|
||||
shm.attach();
|
||||
shm.lock();
|
||||
void * d = shm.data();
|
||||
if (d) qMemSet(d, 0, sizeof(quint32));
|
||||
shm.unlock();
|
||||
start();
|
||||
//qDebug() << "start listen";
|
||||
}
|
||||
|
||||
|
||||
QSingleApplication::~QSingleApplication() {
|
||||
if (first) {
|
||||
exiting = true;
|
||||
quit();
|
||||
if (!wait(100))
|
||||
terminate();
|
||||
}
|
||||
if (shm.isAttached()) shm.detach();
|
||||
}
|
||||
|
||||
|
||||
void QSingleApplication::sendMessage(const QByteArray & m) {
|
||||
//qDebug() << "send message" << first << shm.isAttached();
|
||||
if (first || !shm.isAttached()) return;
|
||||
if (m.size() > int(QSA_MSGSIZE)) {
|
||||
qDebug() << "[QSingleApplication] Too large message:" << m.size() << ">" << QSA_MSGSIZE;
|
||||
return;
|
||||
}
|
||||
shm.lock();
|
||||
quint32 num(0), size = m.size();
|
||||
void * d = shm.data();
|
||||
if (d) {
|
||||
qMemCopy(&num, d, sizeof(quint32));
|
||||
num++;
|
||||
qMemCopy(d, &num, sizeof(quint32));
|
||||
qMemCopy((((char*)d) + sizeof(quint32)), &size, sizeof(quint32));
|
||||
qMemCopy((((char*)d) + sizeof(quint32) + sizeof(quint32)), m.constData(), size);
|
||||
}
|
||||
shm.unlock();
|
||||
}
|
||||
|
||||
|
||||
void QSingleApplication::run() {
|
||||
quint32 num(0), pnum(0), size(0);
|
||||
while (!exiting) {
|
||||
shm.lock();
|
||||
const void * d = shm.constData();
|
||||
if (d) {
|
||||
qMemCopy(&num, d, sizeof(quint32));
|
||||
if (pnum != num) {
|
||||
pnum = num;
|
||||
//qDebug() << "new message" << num;
|
||||
qMemCopy(&size, (((const char*)d) + sizeof(quint32)), sizeof(quint32));
|
||||
if (size <= int(QSA_MSGSIZE)) {
|
||||
QByteArray msg;
|
||||
msg.resize(size);
|
||||
qMemCopy(msg.data(), (((const char*)d) + sizeof(quint32) + sizeof(quint32)), size);
|
||||
emit messageReceived(msg);
|
||||
} else {
|
||||
qDebug() << "[QSingleApplication] Invalid message size:" << size;
|
||||
}
|
||||
}
|
||||
}
|
||||
shm.unlock();
|
||||
if (exiting) break;
|
||||
msleep(10);
|
||||
}
|
||||
}
|
||||
30
qad_application/qsingleapplication.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef QSINGLEAPPLICATION_H
|
||||
#define QSINGLEAPPLICATION_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QSharedMemory>
|
||||
|
||||
class QSingleApplication: public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QSingleApplication(const QString & app_name = QString("qapp"));
|
||||
~QSingleApplication();
|
||||
|
||||
bool isFirst() const {return first;}
|
||||
|
||||
private:
|
||||
void run();
|
||||
|
||||
QSharedMemory shm;
|
||||
bool first, exiting;
|
||||
|
||||
public slots:
|
||||
void sendMessage(const QByteArray & m);
|
||||
|
||||
signals:
|
||||
void messageReceived(QByteArray);
|
||||
|
||||
};
|
||||
|
||||
#endif // QSINGLEAPPLICATION_H
|
||||
195
qad_application/ribbon.cpp
Normal file
@@ -0,0 +1,195 @@
|
||||
#include "ribbon.h"
|
||||
#include <QScrollBar>
|
||||
|
||||
|
||||
Ribbon::Ribbon(QMainWindow * parent_): QToolBar() {
|
||||
delay_e = true;
|
||||
delay = 1000;
|
||||
hovered = -1;
|
||||
setObjectName("ribbon");
|
||||
setProperty("ribbon", true);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
parent = parent_;
|
||||
if (parent_)
|
||||
parent_->installEventFilter(this);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
Ribbon::~Ribbon() {
|
||||
}
|
||||
|
||||
|
||||
bool Ribbon::eventFilter(QObject * o, QEvent * e) {
|
||||
if (o == parent) {
|
||||
if (e->type() == QEvent::Resize || e->type() == QEvent::WindowActivate)
|
||||
_resize();
|
||||
return QToolBar::eventFilter(o, e);
|
||||
}
|
||||
if (e->type() == QEvent::ActionChanged) {
|
||||
QToolButton * b = qobject_cast<QToolButton * >((QObject * )o->property("ribbonButton").toLongLong());
|
||||
if (b != 0)
|
||||
b->setEnabled(qobject_cast<QAction * >(o)->isEnabled());
|
||||
}
|
||||
return QToolBar::eventFilter(o, e);
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::timerEvent(QTimerEvent * e) {
|
||||
if (hovers.value(e->timerId(), -1) == hovered)
|
||||
tab->setCurrentIndex(hovered);
|
||||
hovers.remove(e->timerId());
|
||||
killTimer(e->timerId());
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::_resize() {
|
||||
return; // WARNING
|
||||
for (int i = 0; i < tab->count(); ++i) {
|
||||
int h = ((QScrollArea*)(tab->widget(i)))->sizeHint().height();
|
||||
if (((QScrollArea*)(tab->widget(i)))->horizontalScrollBar()->isVisible())
|
||||
h += ((QScrollArea*)(tab->widget(i)))->horizontalScrollBar()->height();
|
||||
((QScrollArea*)(tab->widget(i)))->setMinimumHeight(h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::setVisible(bool yes) {
|
||||
QToolBar::setVisible(yes);
|
||||
if (parent == 0) return;
|
||||
if (parent->menuBar() == 0) return;
|
||||
parent->menuBar()->setVisible(!yes);
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::init() {
|
||||
if (parent == 0) return;
|
||||
if (parent->menuBar() == 0) return;
|
||||
QList<QAction * > lm = parent->menuBar()->actions(), la;
|
||||
tab = new ETabWidget();
|
||||
tab->setObjectName("ribbon_tab_widget");
|
||||
connect(tab, SIGNAL(tabHovered(int)), this, SLOT(tabHovered(int)));
|
||||
connect(tab, SIGNAL(currentChanged(int)), this, SIGNAL(currentTabChanged(int)));
|
||||
tab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
QGroupBox * g;
|
||||
QBoxLayout * l, * tl;
|
||||
QToolButton * b;
|
||||
//tab->setIconSize(QSize(32, 32));
|
||||
foreach (QAction * i, lm) {
|
||||
if (i->menu() == 0) continue;
|
||||
la = i->menu()->actions();
|
||||
tab->addTab(new QWidget(), i->icon(), i->text());
|
||||
/*QScrollArea * sa = new QScrollArea();
|
||||
sa->setWidget(new QWidget());
|
||||
sa->setWidgetResizable(true);
|
||||
sa->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
sa->setFrameShape(QFrame::NoFrame);
|
||||
tab->addTab(sa, i->icon(), i->text());*/
|
||||
tab->widget(tab->count() - 1)->setProperty("ribbonAction", qlonglong((void * )i));
|
||||
i->setIcon(QIcon());
|
||||
tl = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
tl->setSpacing(2);
|
||||
tl->setContentsMargins(2, 2, 2, 2);
|
||||
g = new QGroupBox();
|
||||
l = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
g->setLayout(l);
|
||||
l->setSpacing(2);
|
||||
l->setContentsMargins(2, 2, 2, 2);
|
||||
foreach (QAction * j, la) {
|
||||
if (j->isSeparator()) {
|
||||
if (l->isEmpty()) continue;
|
||||
tl->addWidget(g);
|
||||
g = new QGroupBox();
|
||||
l = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||
l->setSpacing(2);
|
||||
l->setContentsMargins(2, 2, 2, 2);
|
||||
g->setLayout(l);
|
||||
continue;
|
||||
}
|
||||
if (qobject_cast<QWidgetAction*>(j)) {
|
||||
QWidget * _w = qobject_cast<QWidgetAction*>(j)->defaultWidget();
|
||||
l->addWidget(_w);
|
||||
_w->show();
|
||||
continue;
|
||||
}
|
||||
b = new QToolButton();
|
||||
b->setEnabled(j->isEnabled());
|
||||
b->setProperty("ribbonAction", qlonglong((void * )j));
|
||||
j->setProperty("ribbonButton", qlonglong((void * )b));
|
||||
j->installEventFilter(this);
|
||||
if (j->menu() != 0) {
|
||||
b->setPopupMode(QToolButton::InstantPopup);
|
||||
b->setMenu(j->menu());
|
||||
} else {
|
||||
b->setCheckable(j->isCheckable());
|
||||
if (b->isCheckable()) {
|
||||
b->setChecked(j->isChecked());
|
||||
connect(b, SIGNAL(toggled(bool)), j, SLOT(setChecked(bool)));
|
||||
connect(j, SIGNAL(toggled(bool)), b, SLOT(setChecked(bool)));
|
||||
} else
|
||||
connect(b, SIGNAL(clicked()), j, SLOT(trigger()));
|
||||
}
|
||||
//b->setIconSize(QSize(16, 16));
|
||||
b->setIcon(j->icon());
|
||||
b->setText(j->text());
|
||||
//b->setToolTip(j->toolTip());
|
||||
//b->addAction(j);
|
||||
//b->setShortcut(j->shortcut());
|
||||
b->setAutoRaise(true);
|
||||
b->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
b->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
buttons << b;
|
||||
l->addWidget(b);
|
||||
}
|
||||
tl->addWidget(g);
|
||||
tl->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
//sa->widget()->setLayout(tl);
|
||||
tab->widget(tab->count() - 1)->setLayout(tl);
|
||||
}
|
||||
setFloatable(false);
|
||||
setMovable(false);
|
||||
scroll_area = new QScrollArea();
|
||||
scroll_area->setFrameShape(QFrame::NoFrame);
|
||||
scroll_area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
scroll_area->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
scroll_area->setWidget(tab);
|
||||
_resize();
|
||||
//addWidget(scroll_area);
|
||||
addWidget(tab);
|
||||
parent->addToolBar(Qt::TopToolBarArea, this);
|
||||
parent->menuBar()->hide();
|
||||
tab->setAutoFillBackground(false);
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::retranslate() {
|
||||
QAction * a;
|
||||
foreach (QToolButton * i, buttons) {
|
||||
a = (QAction * )(i->property("ribbonAction").toLongLong());
|
||||
if (a == 0) continue;
|
||||
i->setText(a->text());
|
||||
i->setToolTip(a->toolTip());
|
||||
//i->setShortcut(a->shortcut());
|
||||
}
|
||||
for (int i = 0; i < tab->count(); ++i) {
|
||||
a = (QAction * )(tab->widget(i)->property("ribbonAction").toLongLong());
|
||||
if (a == 0) continue;
|
||||
tab->setTabText(i, a->text());
|
||||
}
|
||||
_resize();
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::setIconSize(const QSize & size) {
|
||||
foreach (QToolButton * i, buttons)
|
||||
i->setIconSize(size);
|
||||
_resize();
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::setTabIconSize(const QSize & size) {
|
||||
tab->setIconSize(size);
|
||||
_resize();
|
||||
}
|
||||
61
qad_application/ribbon.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef RIBBON_H
|
||||
#define RIBBON_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QActionGroup>
|
||||
#include <QWidgetAction>
|
||||
#include <QMenuBar>
|
||||
#include <QTabWidget>
|
||||
#include <QGroupBox>
|
||||
#include <QDockWidget>
|
||||
#include <QToolBar>
|
||||
#include <QScrollArea>
|
||||
#include "etabwidget.h"
|
||||
|
||||
|
||||
class Ribbon: public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Ribbon(QMainWindow * parent = 0);
|
||||
~Ribbon();
|
||||
|
||||
void init();
|
||||
void retranslate();
|
||||
void setIconSize(const QSize & size);
|
||||
void setTabIconSize(const QSize & size);
|
||||
void setButtonStyle(const Qt::ToolButtonStyle & style) {foreach (QToolButton * i, buttons) i->setToolButtonStyle(style);}
|
||||
void setAutoSwitchEnabled(bool yes) {delay_e = yes;}
|
||||
void setAutoSwitchDelay(float delay_s) {delay = delay_s * 1000;}
|
||||
void setCurrentTab(int tab_) {if (tab_ < 0 || tab_ >= tab->count()) return; tab->setCurrentIndex(tab_);}
|
||||
int currentTab() const {return tab->currentIndex();}
|
||||
QTabWidget * tabWidget() const {return tab;}
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void timerEvent(QTimerEvent * e);
|
||||
void _resize();
|
||||
|
||||
int hovered, delay;
|
||||
bool delay_e;
|
||||
QList<QToolButton * > buttons;
|
||||
QMap<int, int> hovers;
|
||||
ETabWidget * tab;
|
||||
QScrollArea * scroll_area;
|
||||
QMainWindow * parent;
|
||||
|
||||
private slots:
|
||||
void tabHovered(int tab) {if (!delay_e) return; hovers.clear(); hovered = tab; hovers.insert(startTimer(delay), tab);}
|
||||
|
||||
public slots:
|
||||
void setVisible(bool yes);
|
||||
void setHidden(bool yes) {setVisible(!yes);}
|
||||
void show() {setVisible(true);}
|
||||
void hide() {setVisible(false);}
|
||||
|
||||
signals:
|
||||
void currentTabChanged(int);
|
||||
|
||||
};
|
||||
|
||||
#endif // RIBBON_H
|
||||