Просмотр исходного кода

had to use conventional methods, not static function, to open file dialog with default directory
also changed logic for how config values are sought, so we can override them at runtime

logicp 5 лет назад
Родитель
Сommit
d1bd25def6
2 измененных файлов с 14 добавлено и 8 удалено
  1. 9 3
      src/kfiledialog.cpp
  2. 5 5
      src/mainwindow.cpp

+ 9 - 3
src/kfiledialog.cpp

@@ -9,7 +9,13 @@ QString KFileDialog::openFileDialog(QString file_path) {
   if (!file_path.isEmpty()) {
     this->setDirectory(file_path);
   }
-  return this->getOpenFileName(this, tr("Open File"), "~",
-                               tr("All Files (*.*)"), nullptr,
-                               QFileDialog::DontUseNativeDialog);
+  this->exec();
+  QStringList filenames = this->selectedFiles();
+  if (!filenames.empty()) {
+    return filenames.at(0);
+  }
+  //  return this->getOpenFileName(this, tr("Open File"), "~",
+  //                               tr("All Files (*.*)"), nullptr,
+  //                               QFileDialog::DontUseNativeDialog);
+  return "";
 }

+ 5 - 5
src/mainwindow.cpp

@@ -41,11 +41,6 @@ MainWindow::MainWindow(int argc, char** argv, QWidget* parent)
   ui->setupUi(this);
   this->setWindowTitle("KYGUI");
   setConnectScreen();
-  m_config = getConfigObject(ui->kyConfig->toPlainText());
-  QString file_path = m_config.at("fileDirectory");
-  if (file_path != NULL) {
-    arg_ui->setFilePath(file_path);
-  }
   connect(ui->connect, &QPushButton::clicked, this, &MainWindow::connectClient);
   ui->processList->setModel(m_process_model);
   ui->eventList->setModel(m_event_model);
@@ -84,6 +79,11 @@ void MainWindow::setConnectScreen(bool visible) {
  * @brief MainWindow::buttonClicked
  */
 void MainWindow::connectClient() {
+  m_config = getConfigObject(ui->kyConfig->toPlainText());
+  QString file_path = m_config.at("fileDirectory");
+  if (file_path != NULL) {
+    arg_ui->setFilePath(file_path);
+  }
   setConnectScreen(false);
   qDebug() << "Connecting to KServer";
   QObject::connect(q_client, &Client::messageReceived, this,