" -l, --loglevel Set libsigrok/libsigrokdecode loglevel\n"
" -i, --input-file Load input from file\n"
" -I, --input-format Input format\n"
+ " -c, --clean Don't restore previous sessions on startup\n"
"\n", PV_BIN_NAME, PV_DESCRIPTION);
}
int ret = 0;
shared_ptr<sigrok::Context> context;
string open_file, open_file_format;
+ bool restore_sessions = true;
Application a(argc, argv);
{"loglevel", required_argument, nullptr, 'l'},
{"input-file", required_argument, nullptr, 'i'},
{"input-format", required_argument, nullptr, 'I'},
+ {"clean", no_argument, nullptr, 'c'},
{nullptr, 0, nullptr, 0}
};
const int c = getopt_long(argc, argv,
- "l:Vh?i:I:", long_options, nullptr);
+ "l:Vhc?i:I:", long_options, nullptr);
if (c == -1)
break;
case 'I':
open_file_format = optarg;
break;
+
+ case 'c':
+ restore_sessions = false;
+ break;
}
}
pv::DeviceManager device_manager(context);
// Initialise the main window
- pv::MainWindow w(device_manager,
- open_file, open_file_format);
+ pv::MainWindow w(device_manager, open_file, open_file_format,
+ restore_sessions);
w.show();
#ifdef ENABLE_SIGNALS
MainWindow::MainWindow(DeviceManager &device_manager,
string open_file_name, string open_file_format,
- QWidget *parent) :
+ bool restore_sessions, QWidget *parent) :
QMainWindow(parent),
device_manager_(device_manager),
session_selector_(this),
bind(&MainWindow::on_settingViewShowAnalogMinorGrid_changed, this, _1));
setup_ui();
- restore_ui_settings();
+ restore_ui_settings(restore_sessions);
if (!open_file_name.empty()) {
shared_ptr<Session> session = add_session();
settings.setValue("sessions", id);
}
-void MainWindow::restore_ui_settings()
+void MainWindow::restore_ui_settings(bool restore_sessions)
{
QSettings settings;
- int i, session_count;
settings.beginGroup("MainWindow");
settings.endGroup();
- session_count = settings.value("sessions", 0).toInt();
+ if (restore_sessions) {
+ int i, session_count;
- for (i = 0; i < session_count; i++) {
- settings.beginGroup("Session" + QString::number(i));
- shared_ptr<Session> session = add_session();
- session->restore_settings(settings);
- settings.endGroup();
+ session_count = settings.value("sessions", 0).toInt();
+
+ for (i = 0; i < session_count; i++) {
+ settings.beginGroup("Session" + QString::number(i));
+ shared_ptr<Session> session = add_session();
+ session->restore_settings(settings);
+ settings.endGroup();
+ }
}
}
explicit MainWindow(DeviceManager &device_manager,
string open_file_name = string(),
string open_file_format = string(),
+ bool restore_sessions = true,
QWidget *parent = nullptr);
~MainWindow();
void save_ui_settings();
- void restore_ui_settings();
+ void restore_ui_settings(bool restore_sessions);
shared_ptr<Session> get_tab_session(int index) const;