git-svn-id: svn://db.shs.com.ru/libs@360 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "piqt_connection_edit.h"
|
||||
#include <QFileDialog>
|
||||
#include <qpiconfig.h>
|
||||
#include <evalspinbox.h>
|
||||
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@@ -9,6 +10,9 @@ int main(int argc, char * argv[]) {
|
||||
#if QT_VERSION >= 0x050000
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
#endif
|
||||
EvalSpinBox es;
|
||||
es.show();
|
||||
return a.exec();
|
||||
ConnectionEdit w;
|
||||
if (a.arguments().size() > 1) {
|
||||
QPIConfig cfg(a.arguments()[1]);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
#include <QScrollBar>
|
||||
#include <QClipboard>
|
||||
|
||||
/*
|
||||
class ProjectsModel: public QAbstractItemModel
|
||||
@@ -76,7 +77,11 @@ ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(pare
|
||||
actionOpen_here->setIcon(Utils::Icons::OPENFILE.icon());
|
||||
actionOpen_external->setIcon(Utils::Icons::OPENFILE.icon());
|
||||
actionShow_external->setIcon(Core::FileIconProvider::icon(QFileIconProvider::Folder));
|
||||
actionCopy_name->setIcon(Utils::Icons::COPY.icon());
|
||||
actionCopy_path->setIcon(Utils::Icons::COPY.icon());
|
||||
popup_menu.addActions(QList<QAction*>() << actionOpen_here << actionOpen_external << actionShow_external);
|
||||
popup_menu.addSeparator();
|
||||
popup_menu.addActions(QList<QAction*>() << actionCopy_name << actionCopy_path);
|
||||
proj_plug = 0;
|
||||
/*QList<QObject * > plugs = ExtensionSystem::PluginManager::allObjects();
|
||||
QStringList sl;
|
||||
@@ -384,3 +389,15 @@ void ProjectFilesystemWidget::on_actionShow_external_triggered() {
|
||||
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), menu_target.absoluteFilePath());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionCopy_name_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
QApplication::clipboard()->setText(menu_target.fileName());
|
||||
}
|
||||
|
||||
|
||||
void ProjectFilesystemWidget::on_actionCopy_path_triggered() {
|
||||
if (menu_target.path().isEmpty()) return;
|
||||
QApplication::clipboard()->setText(menu_target.absoluteFilePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ private slots:
|
||||
void on_actionOpen_here_triggered();
|
||||
void on_actionOpen_external_triggered();
|
||||
void on_actionShow_external_triggered();
|
||||
void on_actionCopy_name_triggered();
|
||||
void on_actionCopy_path_triggered();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -104,6 +104,16 @@
|
||||
<string>Show external ...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy_name">
|
||||
<property name="text">
|
||||
<string>Copy name</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy_path">
|
||||
<property name="text">
|
||||
<string>Copy path</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="projectfilesystem.qrc"/>
|
||||
|
||||
@@ -196,23 +196,7 @@ void EvalSpinBox::setValue(double val) {
|
||||
|
||||
|
||||
void EvalSpinBox::stepBy(int steps) {
|
||||
QString t = text();
|
||||
if (eval.check(t)) {
|
||||
t = eval.expression();
|
||||
QRegExp re("(\\-?\\d+)");
|
||||
int pos = 0;
|
||||
if ((pos = re.indexIn(t)) != -1) {
|
||||
double v = t.mid(pos, re.matchedLength()).toDouble();
|
||||
v += steps;
|
||||
t.remove(pos, re.matchedLength());
|
||||
t.insert(pos, QString::number(v));
|
||||
} else {
|
||||
double v = steps;
|
||||
t = QString::number(v) + t;
|
||||
}
|
||||
eval.check(t);
|
||||
lineEdit()->setText(eval.expression());
|
||||
}
|
||||
stepByDouble(steps);
|
||||
}
|
||||
|
||||
|
||||
@@ -285,6 +269,37 @@ void EvalSpinBox::focusOutEvent(QFocusEvent * event) {
|
||||
}
|
||||
|
||||
|
||||
void EvalSpinBox::wheelEvent(QWheelEvent * event) {
|
||||
if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
stepByDouble(event->delta() > 0 ? 0.1 : -0.1);
|
||||
else
|
||||
QAbstractSpinBox::wheelEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void EvalSpinBox::stepByDouble(double steps) {
|
||||
//qDebug() << "step" << steps;
|
||||
QString t = text();
|
||||
if (eval.check(t)) {
|
||||
t = eval.expression();
|
||||
//QRegExp re("(\\-?\\d+)");
|
||||
QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
|
||||
int pos = 0;
|
||||
if ((pos = re.indexIn(t)) != -1) {
|
||||
double v = t.mid(pos, re.matchedLength()).toDouble();
|
||||
v += steps;
|
||||
t.remove(pos, re.matchedLength());
|
||||
t.insert(pos, QString::number(v));
|
||||
} else {
|
||||
double v = steps;
|
||||
t = QString::number(v) + t;
|
||||
}
|
||||
eval.check(t);
|
||||
lineEdit()->setText(eval.expression());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EvalSpinBox::setDefaultText(const QString & t) {
|
||||
// bool def = (!cw->isHidden());
|
||||
dt = t;
|
||||
|
||||
@@ -41,6 +41,9 @@ protected:
|
||||
virtual StepEnabled stepEnabled() const;
|
||||
virtual void focusInEvent(QFocusEvent *event);
|
||||
virtual void focusOutEvent(QFocusEvent *event);
|
||||
virtual void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void stepByDouble(double steps);
|
||||
|
||||
QWidget * status;
|
||||
QWidget * cw;
|
||||
|
||||
Reference in New Issue
Block a user