62 extern_cfg (Bool, gl_colorbfc); |
62 extern_cfg (Bool, gl_colorbfc); |
63 extern_cfg (Bool, gl_drawangles); |
63 extern_cfg (Bool, gl_drawangles); |
64 |
64 |
65 // ============================================================================= |
65 // ============================================================================= |
66 // |
66 // |
67 |
67 MainWindow::MainWindow (QWidget* parent, Qt::WindowFlags flags) : |
68 MainWindow::MainWindow (QWidget* parent, Qt::WindowFlags flags) |
68 QMainWindow (parent, flags) |
69 { |
69 { |
70 g_win = this; |
70 g_win = this; |
71 ui = new Ui_LDForgeUI; |
71 ui = new Ui_LDForgeUI; |
72 ui->setupUi (this); |
72 ui->setupUi (this); |
73 m_updatingTabs = false; |
73 m_updatingTabs = false; |
809 { |
809 { |
810 return (QPixmap (format (":/icons/%1.png", iconName))); |
810 return (QPixmap (format (":/icons/%1.png", iconName))); |
811 } |
811 } |
812 |
812 |
813 // ============================================================================= |
813 // ============================================================================= |
814 bool confirm (QString msg) |
814 // |
|
815 bool confirm (const QString& message) |
815 { |
816 { |
816 return confirm (MainWindow::tr ("Confirm"), message); |
817 return confirm (MainWindow::tr ("Confirm"), message); |
817 } |
818 } |
818 |
819 |
819 bool confirm (QString title, QString msg) |
820 // ============================================================================= |
820 { |
821 // |
821 return QMessageBox::question (g_win, title, messag, |
822 bool confirm (const QString& title, const QString& message) |
|
823 { |
|
824 return QMessageBox::question (g_win, title, message, |
822 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; |
825 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; |
823 } |
826 } |
824 |
827 |
825 // ============================================================================= |
828 // ============================================================================= |
826 void critical (QString msg) |
829 // |
|
830 void critical (const QString& message) |
827 { |
831 { |
828 QMessageBox::critical (g_win, MainWindow::tr ("Error"), message, |
832 QMessageBox::critical (g_win, MainWindow::tr ("Error"), message, |
829 (QMessageBox::Close), QMessageBox::Close); |
833 (QMessageBox::Close), QMessageBox::Close); |
830 } |
834 } |
831 |
835 |
832 // ============================================================================= |
836 // ============================================================================= |
|
837 // |
833 QIcon makeColorIcon (LDColor* colinfo, const int size) |
838 QIcon makeColorIcon (LDColor* colinfo, const int size) |
834 { |
839 { |
835 // Create an image object and link a painter to it. |
840 // Create an image object and link a painter to it. |
836 QImage img (size, size, QImage::Format_ARGB32); |
841 QImage img (size, size, QImage::Format_ARGB32); |
837 QPainter paint (&img); |
842 QPainter paint (&img); |
854 paint.fillRect (QRect (1, 1, size - 2, size - 2), col); |
859 paint.fillRect (QRect (1, 1, size - 2, size - 2), col); |
855 return QIcon (QPixmap::fromImage (img)); |
860 return QIcon (QPixmap::fromImage (img)); |
856 } |
861 } |
857 |
862 |
858 // ============================================================================= |
863 // ============================================================================= |
|
864 // |
859 void makeColorComboBox (QComboBox* box) |
865 void makeColorComboBox (QComboBox* box) |
860 { |
866 { |
861 std::map<int, int> counts; |
867 std::map<int, int> counts; |
862 |
868 |
863 for (LDObject* obj : getCurrentDocument()->objects()) |
869 for (LDObject* obj : getCurrentDocument()->objects()) |
934 m_tabs->setTabIcon (doc->tabIndex(), doc->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); |
944 m_tabs->setTabIcon (doc->tabIndex(), doc->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); |
935 m_updatingTabs = oldUpdatingTabs; |
945 m_updatingTabs = oldUpdatingTabs; |
936 } |
946 } |
937 |
947 |
938 // ============================================================================= |
948 // ============================================================================= |
|
949 // |
939 // A file is selected from the list of files on the left of the screen. Find out |
950 // A file is selected from the list of files on the left of the screen. Find out |
940 // which file was picked and change to it. |
951 // which file was picked and change to it. |
|
952 // |
941 void MainWindow::changeCurrentFile() |
953 void MainWindow::changeCurrentFile() |
942 { |
954 { |
943 if (m_updatingTabs) |
955 if (m_updatingTabs) |
944 return; |
956 return; |
945 |
957 |
987 ui->actionAxes->setChecked (gl_axes); |
1003 ui->actionAxes->setChecked (gl_axes); |
988 ui->actionBFCView->setChecked (gl_colorbfc); |
1004 ui->actionBFCView->setChecked (gl_colorbfc); |
989 ui->actionDrawAngles->setChecked (gl_drawangles); |
1005 ui->actionDrawAngles->setChecked (gl_drawangles); |
990 } |
1006 } |
991 |
1007 |
|
1008 // ============================================================================= |
|
1009 // |
992 QImage imageFromScreencap (uchar* data, int w, int h) |
1010 QImage imageFromScreencap (uchar* data, int w, int h) |
993 { |
1011 { |
994 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
1012 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
995 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
1013 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
996 } |
1014 } |
999 // |
1017 // |
1000 LDQuickColor::LDQuickColor (LDColor* color, QToolButton* toolButton) : |
1018 LDQuickColor::LDQuickColor (LDColor* color, QToolButton* toolButton) : |
1001 m_color (color), |
1019 m_color (color), |
1002 m_toolButton (toolButton) {} |
1020 m_toolButton (toolButton) {} |
1003 |
1021 |
|
1022 // ============================================================================= |
|
1023 // |
1004 LDQuickColor LDQuickColor::getSeparator() |
1024 LDQuickColor LDQuickColor::getSeparator() |
1005 { |
1025 { |
1006 return LDQuickColor (null, null); |
1026 return LDQuickColor (null, null); |
1007 } |
1027 } |
1008 |
1028 |
|
1029 // ============================================================================= |
|
1030 // |
1009 bool LDQuickColor::isSeparator() const |
1031 bool LDQuickColor::isSeparator() const |
1010 { |
1032 { |
1011 return color() == null; |
1033 return color() == null; |
1012 } |
1034 } |