| 111 |
111 |
| 112 // ============================================================================= |
112 // ============================================================================= |
| 113 // |
113 // |
| 114 KeySequenceConfigEntry* MainWindow::shortcutForAction (QAction* action) |
114 KeySequenceConfigEntry* MainWindow::shortcutForAction (QAction* action) |
| 115 { |
115 { |
| 116 String keycfgname = action->objectName() + "Shortcut"; |
116 QString keycfgname = action->objectName() + "Shortcut"; |
| 117 return KeySequenceConfigEntry::getByName (keycfgname); |
117 return KeySequenceConfigEntry::getByName (keycfgname); |
| 118 } |
118 } |
| 119 |
119 |
| 120 // ============================================================================= |
120 // ============================================================================= |
| 121 // |
121 // |
| 173 |
173 |
| 174 QAction* first = null; |
174 QAction* first = null; |
| 175 |
175 |
| 176 for (const QVariant& it : cfg::recentFiles) |
176 for (const QVariant& it : cfg::recentFiles) |
| 177 { |
177 { |
| 178 String file = it.toString(); |
178 QString file = it.toString(); |
| 179 QAction* recent = new QAction (getIcon ("open-recent"), file, this); |
179 QAction* recent = new QAction (getIcon ("open-recent"), file, this); |
| 180 |
180 |
| 181 connect (recent, SIGNAL (triggered()), this, SLOT (slot_recentFile())); |
181 connect (recent, SIGNAL (triggered()), this, SLOT (slot_recentFile())); |
| 182 ui->menuOpenRecent->insertAction (first, recent); |
182 ui->menuOpenRecent->insertAction (first, recent); |
| 183 m_recentFiles << recent; |
183 m_recentFiles << recent; |
| 189 // |
189 // |
| 190 QList<LDQuickColor> quickColorsFromConfig() |
190 QList<LDQuickColor> quickColorsFromConfig() |
| 191 { |
191 { |
| 192 QList<LDQuickColor> colors; |
192 QList<LDQuickColor> colors; |
| 193 |
193 |
| 194 for (String colorname : cfg::quickColorToolbar.split (":")) |
194 for (QString colorname : cfg::quickColorToolbar.split (":")) |
| 195 { |
195 { |
| 196 if (colorname == "|") |
196 if (colorname == "|") |
| 197 colors << LDQuickColor::getSeparator(); |
197 colors << LDQuickColor::getSeparator(); |
| 198 else |
198 else |
| 199 { |
199 { |
| 250 |
250 |
| 251 // ============================================================================= |
251 // ============================================================================= |
| 252 // |
252 // |
| 253 void MainWindow::updateTitle() |
253 void MainWindow::updateTitle() |
| 254 { |
254 { |
| 255 String title = format (APPNAME " %1", fullVersionString()); |
255 QString title = format (APPNAME " %1", fullVersionString()); |
| 256 |
256 |
| 257 // Append our current file if we have one |
257 // Append our current file if we have one |
| 258 if (getCurrentDocument()) |
258 if (getCurrentDocument()) |
| 259 { |
259 { |
| 260 title += ": "; |
260 title += ": "; |
| 725 |
725 |
| 726 // ============================================================================= |
726 // ============================================================================= |
| 727 // |
727 // |
| 728 bool MainWindow::save (LDDocumentPtr doc, bool saveAs) |
728 bool MainWindow::save (LDDocumentPtr doc, bool saveAs) |
| 729 { |
729 { |
| 730 String path = doc->fullPath(); |
730 QString path = doc->fullPath(); |
| 731 |
731 |
| 732 if (saveAs || path.isEmpty()) |
732 if (saveAs || path.isEmpty()) |
| 733 { |
733 { |
| 734 String name = doc->defaultName(); |
734 QString name = doc->defaultName(); |
| 735 |
735 |
| 736 if (not doc->fullPath().isEmpty()) |
736 if (not doc->fullPath().isEmpty()) |
| 737 name = doc->fullPath(); |
737 name = doc->fullPath(); |
| 738 elif (not doc->name().isEmpty()) |
738 elif (not doc->name().isEmpty()) |
| 739 name = doc->name(); |
739 name = doc->name(); |
| 759 // Add it to recent files |
759 // Add it to recent files |
| 760 addRecentFile (path); |
760 addRecentFile (path); |
| 761 return true; |
761 return true; |
| 762 } |
762 } |
| 763 |
763 |
| 764 String message = format (tr ("Failed to save to %1: %2"), path, strerror (errno)); |
764 QString message = format (tr ("Failed to save to %1: %2"), path, strerror (errno)); |
| 765 |
765 |
| 766 // Tell the user the save failed, and give the option for saving as with it. |
766 // Tell the user the save failed, and give the option for saving as with it. |
| 767 QMessageBox dlg (QMessageBox::Critical, tr ("Save Failure"), message, QMessageBox::Close, g_win); |
767 QMessageBox dlg (QMessageBox::Critical, tr ("Save Failure"), message, QMessageBox::Close, g_win); |
| 768 |
768 |
| 769 // Add a save-as button |
769 // Add a save-as button |
| 790 g_win->spawnContextMenu (ev->globalPos()); |
790 g_win->spawnContextMenu (ev->globalPos()); |
| 791 } |
791 } |
| 792 |
792 |
| 793 // ============================================================================= |
793 // ============================================================================= |
| 794 // |
794 // |
| 795 QPixmap getIcon (String iconName) |
795 QPixmap getIcon (QString iconName) |
| 796 { |
796 { |
| 797 return (QPixmap (format (":/icons/%1.png", iconName))); |
797 return (QPixmap (format (":/icons/%1.png", iconName))); |
| 798 } |
798 } |
| 799 |
799 |
| 800 // ============================================================================= |
800 // ============================================================================= |
| 801 // |
801 // |
| 802 bool confirm (const String& message) |
802 bool confirm (const QString& message) |
| 803 { |
803 { |
| 804 return confirm (MainWindow::tr ("Confirm"), message); |
804 return confirm (MainWindow::tr ("Confirm"), message); |
| 805 } |
805 } |
| 806 |
806 |
| 807 // ============================================================================= |
807 // ============================================================================= |
| 808 // |
808 // |
| 809 bool confirm (const String& title, const String& message) |
809 bool confirm (const QString& title, const QString& message) |
| 810 { |
810 { |
| 811 return QMessageBox::question (g_win, title, message, |
811 return QMessageBox::question (g_win, title, message, |
| 812 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; |
812 (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; |
| 813 } |
813 } |
| 814 |
814 |
| 815 // ============================================================================= |
815 // ============================================================================= |
| 816 // |
816 // |
| 817 void critical (const String& message) |
817 void critical (const QString& message) |
| 818 { |
818 { |
| 819 QMessageBox::critical (g_win, MainWindow::tr ("Error"), message, |
819 QMessageBox::critical (g_win, MainWindow::tr ("Error"), message, |
| 820 (QMessageBox::Close), QMessageBox::Close); |
820 (QMessageBox::Close), QMessageBox::Close); |
| 821 } |
821 } |
| 822 |
822 |