Tue, 14 May 2013 03:23:01 +0300
Split some stuff into separate files
--- a/src/aboutDialog.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/aboutDialog.cpp Tue May 14 03:23:01 2013 +0300 @@ -16,11 +16,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdlib.h> #include <qlabel.h> #include <qboxlayout.h> #include <qdialogbuttonbox.h> #include <qdesktopservices.h> +#include <qpushbutton.h> +#include <QTextEdit> #include <qurl.h> #include "common.h" #include "aboutDialog.h"
--- a/src/addObjectDialog.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/addObjectDialog.cpp Tue May 14 03:23:01 2013 +0300 @@ -17,8 +17,14 @@ */ #include <qgridlayout.h> -#include <qradiobutton.h> #include <qcheckbox.h> +#include <qdialogbuttonbox.h> +#include <qspinbox.h> +#include <qlabel.h> +#include <qlistwidget.h> +#include <qtreewidget.h> +#include <qlineedit.h> +#include <qpushbutton.h> #include "gui.h" #include "addObjectDialog.h" #include "file.h" @@ -26,6 +32,7 @@ #include "colorSelectDialog.h" #include "history.h" #include "setContentsDialog.h" +#include "radiobox.h" #define APPLY_COORDS(OBJ, N) \ for (short i = 0; i < N; ++i) \ @@ -208,8 +215,6 @@ dsb_coords[i]->setMaximum (10000.0); } - IMPLEMENT_DIALOG_BUTTONS - QGridLayout* const layout = new QGridLayout; layout->addWidget (lb_typeIcon, 0, 0); @@ -291,7 +296,7 @@ layout->addLayout (qCoordLayout, 0, 1, (coordCount / 3), 3); } - layout->addWidget (bbx_buttons, 5, 0, 1, 4); + layout->addWidget (makeButtonBox (*this), 5, 0, 1, 4); setLayout (layout); setWindowTitle (fmt (APPNAME ": New %s", g_saObjTypeNames[type]).chars());
--- a/src/addObjectDialog.h Tue May 14 02:28:28 2013 +0300 +++ b/src/addObjectDialog.h Tue May 14 03:23:01 2013 +0300 @@ -19,17 +19,16 @@ #ifndef ZZ_ADDOBJECTDIALOG_H #define ZZ_ADDOBJECTDIALOG_H -#include "gui.h" -#include "radiobox.h" -#include <qdialog.h> -#include <qlineedit.h> -#include <qdialogbuttonbox.h> -#include <qcheckbox.h> -#include <qspinbox.h> -#include <qlabel.h> -#include <qradiobutton.h> -#include <qlistwidget.h> -#include <qtreewidget.h> +#include <QDialog> +#include "ldtypes.h" + +class QLineEdit; +class RadioBox; +class QCheckBox; +class QSpinBox; +class QLabel; +class QTreeWidget; +class QDoubleSpinBox; class AddObjectDialog : public QDialog { Q_OBJECT @@ -66,8 +65,6 @@ QLineEdit* le_matrix; - QDialogButtonBox* bbx_buttons; - private: void setButtonBackground (QPushButton* button, short color); char* currentSubfileName ();
--- a/src/config.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/config.cpp Tue May 14 03:23:01 2013 +0300 @@ -23,11 +23,10 @@ #include <QDir> #include "common.h" #include "config.h" +#include "misc.h" std::vector<config*> g_configPointers; - - // ============================================================================= const char* g_WeekdayNames[7] = { "Sunday",
--- a/src/configDialog.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/configDialog.cpp Tue May 14 03:23:01 2013 +0300 @@ -16,6 +16,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <qgridlayout.h> +#include <qfiledialog.h> +#include <qcolordialog.h> +#include <qboxlayout.h> +#include <qevent.h> +#include <qgroupbox.h> #include "common.h" #include "configDialog.h" #include "file.h" @@ -23,12 +29,7 @@ #include "misc.h" #include "colors.h" #include "colorSelectDialog.h" -#include <qgridlayout.h> -#include <qfiledialog.h> -#include <qcolordialog.h> -#include <qboxlayout.h> -#include <qevent.h> -#include <qgroupbox.h> +#include "gldraw.h" extern_cfg (str, gl_bgcolor); extern_cfg (str, gl_maincolor);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/dialogs.cpp Tue May 14 03:23:01 2013 +0300 @@ -0,0 +1,147 @@ +/* + * LDForge: LDraw parts authoring CAD + * Copyright (C) 2013 Santeri Piippo + * + * 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 <QDialog> +#include <QLineEdit> +#include <QSpinBox> +#include <QDialogButtonBox> +#include <QFileDialog> +#include <QLabel> +#include <QPushButton> + +#include "dialogs.h" +#include "radiobox.h" +#include "gui.h" +#include "gldraw.h" +#include "docs.h" +#include "dialogs.h" + +// ============================================================================= +OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { + rb_camera = new RadioBox ("Camera", {}, 0, Qt::Horizontal, this); + + for (int i = 0; i < 6; ++i) { + if (i == 3) + rb_camera->rowBreak (); + + rb_camera->addButton (g_CameraNames[i]); + } + + GL::Camera cam = g_win->R ()->camera (); + if (cam != GL::Free) + rb_camera->setValue ((int) cam); + + QGroupBox* gb_image = new QGroupBox ("Image", this); + + QLabel* lb_fpath = new QLabel ("File:"); + le_fpath = new QLineEdit; + le_fpath->setFocus (); + + QLabel* lb_ofs = new QLabel ("Origin:"); + btn_fpath = new QPushButton; + btn_fpath->setIcon (getIcon ("folder")); + connect (btn_fpath, SIGNAL (clicked ()), this, SLOT (slot_fpath ())); + + sb_ofsx = new QSpinBox; + sb_ofsy = new QSpinBox; + sb_ofsx->setRange (0, 10000); + sb_ofsy->setRange (0, 10000); + sb_ofsx->setSuffix (" px"); + sb_ofsy->setSuffix (" px"); + + QLabel* lb_dimens = new QLabel ("Dimensions:"); + dsb_lwidth = new QDoubleSpinBox; + dsb_lheight = new QDoubleSpinBox; + dsb_lwidth->setRange (0.0f, 10000.0f); + dsb_lheight->setRange (0.0f, 10000.0f); + dsb_lwidth->setSuffix (" LDU"); + dsb_lheight->setSuffix (" LDU"); + dsb_lwidth->setSpecialValueText ("Automatic"); + dsb_lheight->setSpecialValueText ("Automatic"); + + dbb_buttons = makeButtonBox (*this); + dbb_buttons->addButton (QDialogButtonBox::Help); + connect (dbb_buttons, SIGNAL (helpRequested ()), this, SLOT (slot_help())); + + QHBoxLayout* fpathlayout = new QHBoxLayout; + fpathlayout->addWidget (lb_fpath); + fpathlayout->addWidget (le_fpath); + fpathlayout->addWidget (btn_fpath); + + QGridLayout* metalayout = new QGridLayout; + metalayout->addWidget (lb_ofs, 0, 0); + metalayout->addWidget (sb_ofsx, 0, 1); + metalayout->addWidget (sb_ofsy, 0, 2); + metalayout->addWidget (lb_dimens, 1, 0); + metalayout->addWidget (dsb_lwidth, 1, 1); + metalayout->addWidget (dsb_lheight, 1, 2); + + QVBoxLayout* imagelayout = new QVBoxLayout (gb_image); + imagelayout->addLayout (fpathlayout); + imagelayout->addLayout (metalayout); + + QVBoxLayout* layout = new QVBoxLayout (this); + layout->addWidget (rb_camera); + layout->addWidget (gb_image); + layout->addWidget (dbb_buttons); + + connect (dsb_lwidth, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); + connect (dsb_lheight, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); + connect (rb_camera, SIGNAL (valueChanged (int)), this, SLOT (fillDefaults (int))); + + slot_dimensionsChanged (); + fillDefaults (cam); +} + +void OverlayDialog::fillDefaults (int newcam) { + overlayMeta& info = g_overlays[newcam]; + + if (info.img != null) { + le_fpath->setText (info.fname); + sb_ofsx->setValue (info.ox); + sb_ofsy->setValue (info.oy); + dsb_lwidth->setValue (info.lw); + dsb_lheight->setValue (info.lh); + } else { + le_fpath->setText (""); + sb_ofsx->setValue (0); + sb_ofsy->setValue (0); + dsb_lwidth->setValue (0.0f); + dsb_lheight->setValue (0.0f); + } +} + +str OverlayDialog::fpath () const { return le_fpath->text (); } +ushort OverlayDialog::ofsx () const { return sb_ofsx->value (); } +ushort OverlayDialog::ofsy () const { return sb_ofsy->value (); } +double OverlayDialog::lwidth () const { return dsb_lwidth->value (); } +double OverlayDialog::lheight () const { return dsb_lheight->value (); } +int OverlayDialog::camera () const { return rb_camera->value (); } + +void OverlayDialog::slot_fpath () { + le_fpath->setText (QFileDialog::getOpenFileName (null, "Overlay image")); +} + +void OverlayDialog::slot_help () { + showDocumentation (g_docs_overlays); +} + +void OverlayDialog::slot_dimensionsChanged () { + bool enable = (dsb_lwidth->value () != 0) || (dsb_lheight->value () != 0); + dbb_buttons->button (QDialogButtonBox::Ok)->setEnabled (enable); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/dialogs.h Tue May 14 03:23:01 2013 +0300 @@ -0,0 +1,42 @@ +#ifndef DIALOGS_H +#define DIALOGS_H + +#include <QDialog> +#include "common.h" + +class QDialogButtonBox; +class QDoubleSpinBox; +class QPushButton; +class QLineEdit; +class QSpinBox; +class RadioBox; + +class OverlayDialog : public QDialog { + Q_OBJECT + +public: + explicit OverlayDialog (QWidget* parent = null, Qt::WindowFlags f = 0); + + str fpath () const; + ushort ofsx () const; + ushort ofsy () const; + double lwidth () const; + double lheight () const; + int camera () const; + +private: + RadioBox* rb_camera; + QPushButton* btn_fpath; + QLineEdit* le_fpath; + QSpinBox* sb_ofsx, *sb_ofsy; + QDoubleSpinBox* dsb_lwidth, *dsb_lheight; + QDialogButtonBox* dbb_buttons; + +private slots: + void slot_fpath (); + void slot_help (); + void slot_dimensionsChanged (); + void fillDefaults (int newcam); +}; + +#endif // DIALOGS_H \ No newline at end of file
--- a/src/extprogs.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/extprogs.cpp Tue May 14 03:23:01 2013 +0300 @@ -32,6 +32,7 @@ #include "file.h" #include "radiobox.h" #include "history.h" +#include "labeledwidget.h" // ============================================================================= cfg (str, prog_isecalc, "");
--- a/src/file.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/file.cpp Tue May 14 03:23:01 2013 +0300 @@ -28,6 +28,7 @@ #include "gui.h" #include "history.h" #include "ldrawPathDialog.h" +#include "gldraw.h" cfg (str, io_ldpath, ""); cfg (str, io_recentfiles, "");
--- a/src/gldraw.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/gldraw.cpp Tue May 14 03:23:01 2013 +0300 @@ -17,13 +17,9 @@ */ #include <QGLWidget> -#include <qdialog.h> -#include <qlineedit.h> -#include <qspinbox.h> -#include <qdialogbuttonbox.h> -#include <QFileDialog> #include <qevent.h> #include <GL/glu.h> + #include "common.h" #include "config.h" #include "file.h" @@ -33,8 +29,7 @@ #include "gui.h" #include "misc.h" #include "history.h" -#include "radiobox.h" -#include "docs.h" +#include "dialogs.h" static double g_objOffset[3]; @@ -51,13 +46,7 @@ { { 0, -1, 0 }, Z, Y, false, true }, }; -struct overlayMeta { - vertex v0, v1; - ushort ox, oy; - double lw, lh; - str fname; - QImage* img; -} g_overlays[6]; +overlayMeta g_overlays[6]; cfg (str, gl_bgcolor, "#CCCCD9"); cfg (str, gl_maincolor, "#707078"); @@ -75,19 +64,19 @@ struct CameraIcon { QPixmap* img; QRect srcRect, destRect, selRect; - GLRenderer::Camera cam; + GL::Camera cam; } g_CameraIcons[7]; const char* g_CameraNames[7] = { "Top", "Front", "Left", "Bottom", "Back", "Right", "Free" }; -const GLRenderer::Camera g_Cameras[7] = { - GLRenderer::Top, - GLRenderer::Front, - GLRenderer::Left, - GLRenderer::Bottom, - GLRenderer::Back, - GLRenderer::Right, - GLRenderer::Free +const GL::Camera g_Cameras[7] = { + GL::Top, + GL::Front, + GL::Left, + GL::Bottom, + GL::Back, + GL::Right, + GL::Free }; const struct GLAxis { @@ -105,7 +94,7 @@ GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) { resetAngles (); m_picking = m_rangepick = false; - m_camera = (GLRenderer::Camera) gl_camera.value; + m_camera = (GL::Camera) gl_camera.value; m_drawToolTip = false; m_planeDraw = false; @@ -118,7 +107,7 @@ m_thinBorderPen.setWidth (1); // Init camera icons - for (const GLRenderer::Camera cam : g_Cameras) { + for (const GL::Camera cam : g_Cameras) { str iconname; iconname.format ("camera-%s", str (g_CameraNames[cam]).lower ().c ()); @@ -948,7 +937,7 @@ } // ============================================================================= -void GLRenderer::setCamera (const GLRenderer::Camera cam) { +void GLRenderer::setCamera (const GL::Camera cam) { m_camera = cam; gl_camera = (int) cam; } @@ -1243,120 +1232,6 @@ } // ============================================================================= -OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { - rb_camera = new RadioBox ("Camera", {}, 0, Qt::Horizontal, this); - - for (int i = 0; i < 6; ++i) { - if (i == 3) - rb_camera->rowBreak (); - - rb_camera->addButton (g_CameraNames[i]); - } - - GL::Camera cam = g_win->R ()->camera (); - if (cam != GL::Free) - rb_camera->setValue ((int) cam); - - QGroupBox* gb_image = new QGroupBox ("Image", this); - - QLabel* lb_fpath = new QLabel ("File:"); - le_fpath = new QLineEdit; - le_fpath->setFocus (); - - QLabel* lb_ofs = new QLabel ("Origin:"); - btn_fpath = new QPushButton; - btn_fpath->setIcon (getIcon ("folder")); - connect (btn_fpath, SIGNAL (clicked ()), this, SLOT (slot_fpath ())); - - sb_ofsx = new QSpinBox; - sb_ofsy = new QSpinBox; - sb_ofsx->setRange (0, 10000); - sb_ofsy->setRange (0, 10000); - sb_ofsx->setSuffix (" px"); - sb_ofsy->setSuffix (" px"); - - QLabel* lb_dimens = new QLabel ("Dimensions:"); - dsb_lwidth = new QDoubleSpinBox; - dsb_lheight = new QDoubleSpinBox; - dsb_lwidth->setRange (0.0f, 10000.0f); - dsb_lheight->setRange (0.0f, 10000.0f); - dsb_lwidth->setSuffix (" LDU"); - dsb_lheight->setSuffix (" LDU"); - dsb_lwidth->setSpecialValueText ("Automatic"); - dsb_lheight->setSpecialValueText ("Automatic"); - - dbb_buttons = makeButtonBox (*this); - dbb_buttons->addButton (QDialogButtonBox::Help); - connect (dbb_buttons, SIGNAL (helpRequested ()), this, SLOT (slot_help())); - - QHBoxLayout* fpathlayout = new QHBoxLayout; - fpathlayout->addWidget (lb_fpath); - fpathlayout->addWidget (le_fpath); - fpathlayout->addWidget (btn_fpath); - - QGridLayout* metalayout = new QGridLayout; - metalayout->addWidget (lb_ofs, 0, 0); - metalayout->addWidget (sb_ofsx, 0, 1); - metalayout->addWidget (sb_ofsy, 0, 2); - metalayout->addWidget (lb_dimens, 1, 0); - metalayout->addWidget (dsb_lwidth, 1, 1); - metalayout->addWidget (dsb_lheight, 1, 2); - - QVBoxLayout* imagelayout = new QVBoxLayout (gb_image); - imagelayout->addLayout (fpathlayout); - imagelayout->addLayout (metalayout); - - QVBoxLayout* layout = new QVBoxLayout (this); - layout->addWidget (rb_camera); - layout->addWidget (gb_image); - layout->addWidget (dbb_buttons); - - connect (dsb_lwidth, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); - connect (dsb_lheight, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); - connect (rb_camera, SIGNAL (valueChanged (int)), this, SLOT (fillDefaults (int))); - - slot_dimensionsChanged (); - fillDefaults (cam); -} - -void OverlayDialog::fillDefaults (int newcam) { - overlayMeta& info = g_overlays[newcam]; - - if (info.img != null) { - le_fpath->setText (info.fname); - sb_ofsx->setValue (info.ox); - sb_ofsy->setValue (info.oy); - dsb_lwidth->setValue (info.lw); - dsb_lheight->setValue (info.lh); - } else { - le_fpath->setText (""); - sb_ofsx->setValue (0); - sb_ofsy->setValue (0); - dsb_lwidth->setValue (0.0f); - dsb_lheight->setValue (0.0f); - } -} - -str OverlayDialog::fpath () const { return le_fpath->text (); } -ushort OverlayDialog::ofsx () const { return sb_ofsx->value (); } -ushort OverlayDialog::ofsy () const { return sb_ofsy->value (); } -double OverlayDialog::lwidth () const { return dsb_lwidth->value (); } -double OverlayDialog::lheight () const { return dsb_lheight->value (); } -GL::Camera OverlayDialog::camera () const { return (GL::Camera) rb_camera->value (); } - -void OverlayDialog::slot_fpath () { - le_fpath->setText (QFileDialog::getOpenFileName (null, "Overlay image")); -} - -void OverlayDialog::slot_help () { - showDocumentation (g_docs_overlays); -} - -void OverlayDialog::slot_dimensionsChanged () { - bool enable = (dsb_lwidth->value () != 0) || (dsb_lheight->value () != 0); - dbb_buttons->button (QDialogButtonBox::Ok)->setEnabled (enable); -} - void GLRenderer::setupOverlay () { if (camera () == Free) return;
--- a/src/gldraw.h Tue May 14 02:28:28 2013 +0300 +++ b/src/gldraw.h Tue May 14 03:23:01 2013 +0300 @@ -131,32 +131,17 @@ GL::BFCBackList, }; -class OverlayDialog : public QDialog { - Q_OBJECT - -public: - explicit OverlayDialog (QWidget* parent = null, Qt::WindowFlags f = 0); - - str fpath () const; - ushort ofsx () const; - ushort ofsy () const; - double lwidth () const; - double lheight () const; - GL::Camera camera () const; - -private: - RadioBox* rb_camera; - QPushButton* btn_fpath; - QLineEdit* le_fpath; - QSpinBox* sb_ofsx, *sb_ofsy; - QDoubleSpinBox* dsb_lwidth, *dsb_lheight; - QDialogButtonBox* dbb_buttons; - -private slots: - void slot_fpath (); - void slot_help (); - void slot_dimensionsChanged (); - void fillDefaults (int newcam); +// Meta for overlays +struct overlayMeta { + vertex v0, v1; + ushort ox, oy; + double lw, lh; + str fname; + QImage* img; }; +extern const GL::Camera g_Cameras[7]; +extern const char* g_CameraNames[7]; +extern overlayMeta g_overlays[6]; + #endif // GLDRAW_H \ No newline at end of file
--- a/src/gui.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/gui.cpp Tue May 14 03:23:01 2013 +0300 @@ -26,6 +26,7 @@ #include <qtoolbutton.h> #include <qcombobox.h> #include <qdialogbuttonbox.h> +#include <QToolBar> #include <qcoreapplication.h> #include "common.h" #include "gldraw.h" @@ -183,9 +184,7 @@ addMenuAction ("newVertex"); // New Vertex addMenuAction ("newRadial"); // New Radial menu->addSeparator (); // ----- - addMenuAction ("beginDraw"); // Begin Drawing - addMenuAction ("doneDraw"); // Cancel Drawing - addMenuAction ("cancelDraw"); // Done Drawing + addMenuAction ("draw"); // Draw Mode // Edit menu initMenu ("&Edit");
--- a/src/gui.h Tue May 14 02:28:28 2013 +0300 +++ b/src/gui.h Tue May 14 03:23:01 2013 +0300 @@ -20,17 +20,10 @@ #define GUI_H #include <QMainWindow> -#include <QMenu> -#include <QToolBar> #include <QAction> -#include <QToolBar> -#include <QTextEdit> -#include <qpushbutton.h> -#include <qlistwidget.h> -#include <qlabel.h> -#include <qboxlayout.h> -#include "gldraw.h" +#include <QListWidget> #include "config.h" +#include "ldtypes.h" class QComboBox; class ForgeWindow; @@ -39,6 +32,7 @@ class DelHistory; class QToolButton; class QDialogButtonBox; +class GLRenderer; // Stuff for dialogs #define IMPLEMENT_DIALOG_BUTTONS \ @@ -187,53 +181,6 @@ void slot_lastSecondCleanup (); }; -// ============================================================================= -// LabeledWidget -// -// Convenience class for a widget with a label beside it. -// ============================================================================= -template<class R> class LabeledWidget : public QWidget { -public: - explicit LabeledWidget (const char* labelstr, QWidget* parent = null) : QWidget (parent) { - m_widget = new R (this); - commonInit (labelstr); - } - - explicit LabeledWidget (const char* labelstr, R* widget, QWidget* parent = null) : - QWidget (parent), m_widget (widget) - { - commonInit (labelstr); - } - - explicit LabeledWidget (QWidget* parent = 0, Qt::WindowFlags f = 0) { - m_widget = new R (this); - commonInit (""); - } - - R* widget () const { return m_widget; } - R* w () const { return m_widget; } - QLabel* label () const { return m_label; } - QLabel* l () const { return m_label; } - void setWidget (R* widget) { m_widget = widget; } - void setLabel (QLabel* label) { m_label = label; } - operator R* () { return m_widget; } - -private: - Q_DISABLE_COPY (LabeledWidget<R>) - - void commonInit (const char* labelstr) { - m_label = new QLabel (labelstr, this); - m_layout = new QHBoxLayout; - m_layout->addWidget (m_label); - m_layout->addWidget (m_widget); - setLayout (m_layout); - } - - R* m_widget; - QLabel* m_label; - QHBoxLayout* m_layout; -}; - // ----------------------------------------------------------------------------- // Other GUI-related stuff not directly part of ForgeWindow: QPixmap getIcon (const char* sIconName);
--- a/src/gui_actions.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/gui_actions.cpp Tue May 14 03:23:01 2013 +0300 @@ -18,6 +18,8 @@ #include <qfiledialog.h> #include <qmessagebox.h> +#include <QTextEdit> +#include <QBoxLayout> #include "gui.h" #include "file.h" #include "history.h" @@ -27,6 +29,7 @@ #include "aboutDialog.h" #include "misc.h" #include "ldrawPathDialog.h" +#include "gldraw.h" extern_cfg (bool, gl_wireframe); @@ -394,18 +397,10 @@ } // ========================================================================================================================================= -MAKE_ACTION (beginDraw, "Begin Drawing", "draw", "Begin drawing geometry", KEY (Insert)) { +MAKE_ACTION (draw, "Draw Mode", "draw", "Begin drawing geometry", KEY (Insert)) { g_win->R ()->beginPlaneDraw (); } -MAKE_ACTION (cancelDraw, "Cancel Drawing", "draw-cancel", "Cancel drawing geometry", KEY (Escape)) { - g_win->R ()->endPlaneDraw (false); -} - -MAKE_ACTION (doneDraw, "Done Drawing", "draw-done", "Done drawing geometry", KEY (Enter)) { - g_win->R ()->endPlaneDraw (true); -} - // ========================================================================================================================================= MAKE_ACTION (visibility, "Toggle Visibility", "visibility", "Toggles visibility/hiding on objects.", (0)) { for (LDObject* obj : g_win->sel ())
--- a/src/gui_editactions.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/gui_editactions.cpp Tue May 14 03:23:01 2013 +0300 @@ -30,6 +30,7 @@ #include "checkboxgroup.h" #include <qspinbox.h> #include <qcheckbox.h> +#include "gldraw.h" vector<LDObject*> g_Clipboard;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/labeledwidget.h Tue May 14 03:23:01 2013 +0300 @@ -0,0 +1,72 @@ +/* + * LDForge: LDraw parts authoring CAD + * Copyright (C) 2013 Santeri Piippo + * + * 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/>. + */ + +#ifndef LABELEDWIDGET_H +#define LABELEDWIDGET_H + +#include <QLabel> +#include <QBoxLayout> + +// ============================================================================= +// LabeledWidget +// +// Convenience class for a widget with a label beside it. +// ============================================================================= +template<class R> class LabeledWidget : public QWidget { +public: + explicit LabeledWidget (const char* labelstr, QWidget* parent = null) : QWidget (parent) { + m_widget = new R (this); + commonInit (labelstr); + } + + explicit LabeledWidget (const char* labelstr, R* widget, QWidget* parent = null) : + QWidget (parent), m_widget (widget) + { + commonInit (labelstr); + } + + explicit LabeledWidget (QWidget* parent = 0, Qt::WindowFlags f = 0) { + m_widget = new R (this); + commonInit (""); + } + + R* widget () const { return m_widget; } + R* w () const { return m_widget; } + QLabel* label () const { return m_label; } + QLabel* l () const { return m_label; } + void setWidget (R* widget) { m_widget = widget; } + void setLabel (QLabel* label) { m_label = label; } + operator R* () { return m_widget; } + +private: + Q_DISABLE_COPY (LabeledWidget<R>) + + void commonInit (const char* labelstr) { + m_label = new QLabel (labelstr, this); + m_layout = new QHBoxLayout; + m_layout->addWidget (m_label); + m_layout->addWidget (m_widget); + setLayout (m_layout); + } + + R* m_widget; + QLabel* m_label; + QHBoxLayout* m_layout; +}; + +#endif // LABELEDWIDGET_H \ No newline at end of file
--- a/src/ldrawPathDialog.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/ldrawPathDialog.cpp Tue May 14 03:23:01 2013 +0300 @@ -20,6 +20,8 @@ #include <qpushbutton.h> #include <qdialogbuttonbox.h> #include <QFileDialog> +#include <QBoxLayout> +#include <QLabel> #include "ldrawPathDialog.h" #include "gui.h" #include "file.h"
--- a/src/ldrawPathDialog.h Tue May 14 02:28:28 2013 +0300 +++ b/src/ldrawPathDialog.h Tue May 14 03:23:01 2013 +0300 @@ -19,7 +19,7 @@ #ifndef LDRAWPATHDIALOG_H #define LDRAWPATHDIALOG_H -#include <qdialog.h> +#include <QDialog> #include "common.h" class QLabel;
--- a/src/ldtypes.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/ldtypes.cpp Tue May 14 03:23:01 2013 +0300 @@ -22,6 +22,7 @@ #include "misc.h" #include "gui.h" #include "history.h" +#include "gldraw.h" char const* g_saObjTypeNames[] = { "subfile",
--- a/src/misc.h Tue May 14 02:28:28 2013 +0300 +++ b/src/misc.h Tue May 14 03:23:01 2013 +0300 @@ -19,8 +19,8 @@ #ifndef MISC_H #define MISC_H +#include "config.h" #include "common.h" -#include "config.h" #define NUM_PRIMES 500
--- a/src/newPartDialog.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/newPartDialog.cpp Tue May 14 03:23:01 2013 +0300 @@ -16,9 +16,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <qgridlayout.h> +#include <QGridLayout> +#include <QLabel> +#include <QLineEdit> +#include <QDialogButtonBox> + #include "newPartDialog.h" #include "file.h" +#include "gui.h" +#include "radiobox.h" // ------------------------------------- enum { @@ -64,8 +70,6 @@ boxes->addWidget (rb_license); boxes->addWidget (rb_BFC); - IMPLEMENT_DIALOG_BUTTONS - QGridLayout* layout = new QGridLayout; layout->addWidget (lb_brickIcon, 0, 0); layout->addWidget (lb_name, 0, 1); @@ -73,7 +77,7 @@ layout->addWidget (lb_author, 1, 1); layout->addWidget (le_author, 1, 2); layout->addLayout (boxes, 2, 1, 1, 2); - layout->addWidget (bbx_buttons, 3, 2); + layout->addWidget (makeButtonBox (*this), 3, 2); setLayout (layout); setWindowIcon (getIcon ("brick")); @@ -89,7 +93,7 @@ newFile (); short idx; - str zAuthor = dlg.le_author->text (); + str author = dlg.le_author->text (); vector<LDObject*>& objs = g_curfile->m_objs; idx = dlg.rb_BFC->value (); @@ -106,7 +110,7 @@ objs.push_back (new LDComment (dlg.le_name->text ())); objs.push_back (new LDComment ("Name: <untitled>.dat")); - objs.push_back (new LDComment (fmt ("Author: %s", zAuthor.chars()))); + objs.push_back (new LDComment (fmt ("Author: %s", author.chars()))); objs.push_back (new LDComment (fmt ("!LDRAW_ORG Unofficial_Part"))); if (sLicense != null)
--- a/src/newPartDialog.h Tue May 14 02:28:28 2013 +0300 +++ b/src/newPartDialog.h Tue May 14 03:23:01 2013 +0300 @@ -19,15 +19,12 @@ #ifndef NEWPARTDIALOG_H #define NEWPARTDIALOG_H -#include <qdialog.h> -#include <qlabel.h> -#include <qlineedit.h> -#include <qcombobox.h> -#include <qdialogbuttonbox.h> -#include <qradiobutton.h> -#include <qbuttongroup.h> -#include "gui.h" -#include "radiobox.h" +#include <QDialog> +#include "common.h" + +class QLabel; +class QLineEdit; +class RadioBox; class NewPartDialog : public QDialog { public: @@ -36,9 +33,7 @@ QLabel* lb_brickIcon, *lb_name, *lb_author, *lb_license, *lb_BFC; QLineEdit* le_name, *le_author; - RadioBox* rb_license, *rb_BFC; - QDialogButtonBox* bbx_buttons; }; #endif // NEWPARTDIALOG_H \ No newline at end of file
--- a/src/setContentsDialog.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/setContentsDialog.cpp Tue May 14 03:23:01 2013 +0300 @@ -16,8 +16,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <QAbstractButton> #include <qboxlayout.h> +#include <QLineEdit> +#include <QLabel> +#include <QDialogButtonBox> #include "setContentsDialog.h" #include "file.h" #include "gui.h" @@ -51,8 +53,6 @@ lb_errorIcon->setPixmap (qErrorPixmap); } - IMPLEMENT_DIALOG_BUTTONS - QVBoxLayout* layout = new QVBoxLayout; layout->addWidget (lb_contents); layout->addWidget (le_contents); @@ -64,7 +64,7 @@ layout2->addWidget (lb_error); } - layout2->addWidget (bbx_buttons); + layout2->addWidget (makeButtonBox (*this)); layout->addLayout (layout2); setLayout (layout); @@ -75,8 +75,8 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void SetContentsDialog::slot_handleButtons (QAbstractButton* qButton) { - qButton = qButton; +void SetContentsDialog::slot_handleButtons (QAbstractButton* btn) { + btn = btn; } // =============================================================================
--- a/src/setContentsDialog.h Tue May 14 02:28:28 2013 +0300 +++ b/src/setContentsDialog.h Tue May 14 03:23:01 2013 +0300 @@ -18,12 +18,13 @@ #ifndef SETCONTENTSDIALOG_H -#include <qdialog.h> -#include <qlineedit.h> -#include <qlabel.h> -#include <qdialogbuttonbox.h> +#include <QDialog> #include "common.h" +class QAbstractButton; +class QLabel; +class QLineEdit; + // ============================================================================= // SetContentsDialog // @@ -35,13 +36,12 @@ public: QLabel* lb_contents, *lb_errorIcon, *lb_error; QLineEdit* le_contents; - QDialogButtonBox* bbx_buttons; SetContentsDialog (LDObject* obj, QWidget* parent = null); static void staticDialog (LDObject* obj); private slots: - void slot_handleButtons (QAbstractButton* qButton); + void slot_handleButtons (QAbstractButton* btn); }; #endif // SETCONTENTSDIALOG_H \ No newline at end of file