Changeset c41ce0
- Timestamp:
- Aug 11, 2025, 5:43:56 PM (2 months ago)
- Branches:
- Candidate_v1.7.0, stable
- Children:
- 641550
- Parents:
- 6294b6
- git-author:
- Frederik Heber <frederik.heber@…> (05/03/24 15:25:52)
- git-committer:
- Frederik Heber <frederik.heber@…> (08/11/25 17:43:56)
- Location:
- src
- Files:
-
- 5 edited
-
UIElements/Qt4/QtMainWindow.cpp (modified) (2 diffs)
-
UIElements/Qt4/QtMainWindow.hpp (modified) (2 diffs)
-
UIElements/Qt4/QtUIFactory.cpp (modified) (4 diffs)
-
UIElements/Qt4/QtUIFactory.hpp (modified) (1 diff)
-
builder_init.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Qt4/QtMainWindow.cpp
r6294b6 rc41ce0 158 158 QSettings settings; 159 159 settings.beginGroup("MainWindow"); 160 resize(settings.value("size", QSize(400, 400)).toSize()); 161 move(settings.value("position", QPoint(200, 200)).toPoint()); 160 settingsSize = settings.value("size", QSize(400, 400)).toSize(); 161 settingsPosition = settings.value("position", QPoint(200, 200)).toPoint(); 162 163 const QStringList args = QCoreApplication::arguments(); 164 LOG(2, "DEBUG: QApp's seen arguments are " << args.join(",").toStdString()); 165 166 const int indexSize = args.indexOf(QString("--qt_size")); 167 const int indexPosition = args.indexOf(QString("--qt_position")); 168 169 if ((indexSize == -1) || (indexPosition == -1)) { 170 resize(settingsSize); 171 move(settingsPosition); 172 } else { 173 // Take size and position from command-line values instead 174 // NOTE: Qt 4.8's toInt() caps the second argument when it's below 1000 (yes, really!). Hence, we're using stoi() 175 const QSize cmdlineSize = QSize(stoi(args[indexSize + 1].split(",")[0].toStdString()), stoi(args[indexSize + 1].split(",")[1].toStdString())); 176 const QPoint cmdlinePosition = QPoint(stoi(args[indexPosition + 1].split(",")[0].toStdString()), stoi(args[indexPosition + 1].split(",")[1].toStdString())); 177 LOG(2, "DEBUG: Using size and position from the command line: (" << cmdlineSize.width() << "," << cmdlineSize.height() 178 << "), (" << cmdlinePosition.x() << "," << cmdlinePosition.y() << ")"); 179 resize(cmdlineSize); 180 move(cmdlinePosition); 181 } 162 182 if (settings.value("maximized", false).toBool()) 163 183 showMaximized(); 164 184 settings.endGroup(); 185 LOG(1, "INFO: Size and position is (" << size().width() << "," << size().height() << "), (" << pos().x() << "," << pos().y() << ")"); 165 186 166 187 connect(glWorldView,SIGNAL(hoverChanged(const atomId_t)), infoBox,SLOT(atomHover(const atomId_t))); … … 174 195 QtMainWindow::~QtMainWindow() 175 196 { 197 const QStringList args = QCoreApplication::arguments(); 198 const bool containsSize = args.contains(QString("--qt_size")); 199 const bool containsPosition = args.contains(QString("--qt_position")); 200 176 201 QSettings settings; 177 202 settings.beginGroup("MainWindow"); 178 settings.setValue("size", size()); 179 settings.setValue("position", pos()); 203 if (!containsSize || !containsPosition) { 204 settings.setValue("size", size()); 205 settings.setValue("position", pos()); 206 } else { 207 settings.setValue("size", settingsSize); 208 settings.setValue("position", settingsPosition); 209 } 180 210 settings.setValue("maximized", isMaximized()); 181 211 settings.endGroup(); -
src/UIElements/Qt4/QtMainWindow.hpp
r6294b6 rc41ce0 39 39 class QtToolBar; 40 40 class QCloseEvent; 41 class QSize; 42 class QPoint; 41 43 42 44 class QtObservedInstanceBoard; … … 73 75 QtLogBox *logBox; 74 76 QtLogBox *errorlogBox; 77 //!> Used to store old settings value for window size on exit when overridden from command line 78 QSize settingsSize; 79 //!> Used to store old settings value for window position on exit when overridden from command line 80 QPoint settingsPosition; 75 81 76 82 QtObservedInstanceBoard *InstanceBoard; -
src/UIElements/Qt4/QtUIFactory.cpp
r6294b6 rc41ce0 60 60 61 61 QtUIFactory::QtUIFactory(int _argc, char **_argv) : 62 argc( 1),63 argv( new char*[1]),62 argc(0), 63 argv(NULL), 64 64 testlauncher_Interrupted(false), 65 65 testlauncher_thread(NULL) … … 78 78 #ifdef HAVE_BOOST_THREAD_HPP 79 79 std::vector<std::string> scripts; 80 scripts.reserve(_argc-1); 81 for (int i=2;i<_argc;++i) 82 scripts.push_back(std::string(_argv[i])); 80 scripts.reserve(1); 81 scripts.push_back(std::string(_argv[2])); 83 82 84 83 // check for line-by-line execution … … 92 91 std::cerr << "Boost::thread support missing! Cannot launch test scripts.\n"; 93 92 #endif 94 // use fake commands to not pass test stuff 95 const int length = strlen(_argv[0]); 96 argv[0] = new char[length]; 97 strncpy(argv[0],_argv[0], length); 93 // remove test options from command line arguments 94 argc = _argc-2; 95 argv = new char*[argc]; 96 int j = 0; 97 for (int i=0;i<_argc;++i) { 98 if ((i >= 1) && (i<3)) 99 continue; 100 const int length = strlen(_argv[i]); 101 argv[j] = new char[length]; 102 strncpy(argv[j],_argv[i], length); 103 ++j; 104 } 98 105 app = new QApplication(argc,argv); 99 106 } else { 100 const int length = strlen(_argv[0]); 101 argv[0] = new char[length]; 102 strncpy(argv[0],_argv[0], length); 107 argc = _argc; 108 argv = new char*[argc]; 109 for (int i=0;i<_argc;++i) { 110 const int length = strlen(_argv[i]); 111 argv[i] = new char[length]; 112 strncpy(argv[i],_argv[i], length); 113 } 103 114 app = new QApplication(argc,argv); 104 115 } … … 146 157 { 147 158 return (strncmp(_argument,"--test", 6) == 0); 159 } 160 161 bool QtUIFactory::isGuiMode(const char *_argument) 162 { 163 return (strncmp(_argument,"--qt_size", 9) == 0) || (strncmp(_argument,"--qt_position", 13) == 0); 148 164 } 149 165 -
src/UIElements/Qt4/QtUIFactory.hpp
r6294b6 rc41ce0 46 46 47 47 static bool isTestMode(const char *_argument); 48 static bool isGuiMode(const char *_argument); 48 49 49 50 protected: -
src/builder_init.cpp
r6294b6 rc41ce0 140 140 #ifdef USE_GUI_QT 141 141 && !QtUIFactory::isTestMode(argv[1]) 142 && !QtUIFactory::isGuiMode(argv[1]) 142 143 #endif 143 144 ) {
Note:
See TracChangeset
for help on using the changeset viewer.
