Changeset c41ce0 for src/UIElements/Qt4/QtMainWindow.cpp
- 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)
- File:
-
- 1 edited
-
src/UIElements/Qt4/QtMainWindow.cpp (modified) (2 diffs)
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();
Note:
See TracChangeset
for help on using the changeset viewer.
