fix main window state saving in qt6
This commit is contained in:
parent
8cde9ab748
commit
b3216c570b
@ -688,32 +688,21 @@ void FormMain::loadSize() {
|
||||
void FormMain::saveSize() {
|
||||
Settings* settings = qApp->settings();
|
||||
bool is_fullscreen = isFullScreen();
|
||||
bool is_maximized = false;
|
||||
bool is_maximized = isMaximized();
|
||||
QPoint window_pos = normalGeometry().topLeft();
|
||||
QSize window_size = normalGeometry().size();
|
||||
|
||||
if (is_fullscreen) {
|
||||
m_ui->m_actionFullscreen->setChecked(false);
|
||||
|
||||
// We (process events to really) un-fullscreen, so that we can determine if window is really maximized.
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
if (isMaximized()) {
|
||||
is_maximized = true;
|
||||
|
||||
// Window is maximized, we store that fact to settings and unmaximize.
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::IsMainWindowMaximizedBeforeFullscreen, isMaximized());
|
||||
setWindowState((windowState() & ~Qt::WindowMaximized) | Qt::WindowActive);
|
||||
|
||||
// We process events to really have window un-maximized.
|
||||
qApp->processEvents();
|
||||
if (!window_size.isValid()) {
|
||||
window_size = sizeHint();
|
||||
}
|
||||
|
||||
settings->setValue(GROUP(GUI), GUI::MainMenuVisible, m_ui->m_actionSwitchMainMenu->isChecked());
|
||||
settings->setValue(GROUP(GUI), GUI::MainWindowInitialPosition, pos());
|
||||
settings->setValue(GROUP(GUI), GUI::MainWindowInitialSize, size());
|
||||
settings->setValue(GROUP(GUI), GUI::StatusBarVisible, m_ui->m_actionSwitchStatusBar->isChecked());
|
||||
|
||||
settings->setValue(GROUP(GUI), GUI::MainWindowInitialPosition, window_pos);
|
||||
settings->setValue(GROUP(GUI), GUI::MainWindowInitialSize, window_size);
|
||||
settings->setValue(GROUP(GUI), GUI::MainWindowStartsMaximized, is_maximized);
|
||||
settings->setValue(GROUP(GUI), GUI::MainWindowStartsFullscreen, is_fullscreen);
|
||||
settings->setValue(GROUP(GUI), GUI::StatusBarVisible, m_ui->m_actionSwitchStatusBar->isChecked());
|
||||
|
||||
m_ui->m_tabWidget->feedMessageViewer()->saveSize();
|
||||
}
|
||||
|
@ -756,40 +756,6 @@ void MessagesView::selectNextUnreadItem() {
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::selectNextImportantItem() {
|
||||
const QModelIndexList selected_rows = selectionModel()->selectedRows();
|
||||
int active_row;
|
||||
|
||||
if (!selected_rows.isEmpty()) {
|
||||
// Okay, something is selected, start from it.
|
||||
active_row = selected_rows.at(0).row();
|
||||
}
|
||||
else {
|
||||
active_row = 0;
|
||||
}
|
||||
|
||||
const QModelIndex next_important = m_proxyModel->getNextPreviousImportantItemIndex(active_row);
|
||||
|
||||
if (next_important.isValid()) {
|
||||
// We found unread message, mark it.
|
||||
setCurrentIndex(next_important);
|
||||
|
||||
// Make sure that item is properly visible even if
|
||||
// message previewer was hidden and shows up.
|
||||
qApp->processEvents();
|
||||
|
||||
scrollTo(next_important,
|
||||
!m_processingAnyMouseButton &&
|
||||
qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()
|
||||
? QAbstractItemView::ScrollHint::PositionAtCenter
|
||||
: QAbstractItemView::ScrollHint::PositionAtTop);
|
||||
|
||||
selectionModel()->select(next_important,
|
||||
QItemSelectionModel::SelectionFlag::Select | QItemSelectionModel::SelectionFlag::Rows);
|
||||
setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesView::searchMessages(const QString& pattern) {
|
||||
qDebugNN << LOGSEC_GUI << "Running search of messages with pattern" << QUOTE_W_SPACE_DOT(pattern);
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
class MessagesProxyModel;
|
||||
|
||||
class MessagesView : public BaseTreeView {
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MessagesView(QWidget* parent = nullptr);
|
||||
@ -59,7 +59,6 @@ class MessagesView : public BaseTreeView {
|
||||
void selectItemWithCursorAction(QAbstractItemView::CursorAction act);
|
||||
|
||||
void selectNextUnreadItem();
|
||||
void selectNextImportantItem();
|
||||
|
||||
// Searchs the visible message according to given pattern.
|
||||
void searchMessages(const QString& pattern);
|
||||
@ -89,8 +88,12 @@ class MessagesView : public BaseTreeView {
|
||||
void willReselectSameMessage();
|
||||
|
||||
private:
|
||||
void sort(int column, Qt::SortOrder order, bool repopulate_data,
|
||||
bool change_header, bool emit_changed_from_header, bool ignore_multicolumn_sorting);
|
||||
void sort(int column,
|
||||
Qt::SortOrder order,
|
||||
bool repopulate_data,
|
||||
bool change_header,
|
||||
bool emit_changed_from_header,
|
||||
bool ignore_multicolumn_sorting);
|
||||
|
||||
// Creates needed connections.
|
||||
void createConnections();
|
||||
|
@ -208,7 +208,8 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
||||
succeded++;
|
||||
add_offline_anyway = false;
|
||||
}
|
||||
} catch (const ApplicationException& ex) {
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
qCriticalNN << LOGSEC_CORE << "Cannot fetch medatada for feed:" << QUOTE_W_SPACE(feed_url)
|
||||
<< "with error:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||
}
|
||||
@ -321,9 +322,9 @@ bool FeedsImportExportModel::exportToTxtURLPerLine(QByteArray& result) {
|
||||
void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool fetch_metadata_online) {
|
||||
emit parsingStarted();
|
||||
emit layoutAboutToBeChanged();
|
||||
|
||||
setRootItem(nullptr);
|
||||
emit layoutChanged();
|
||||
|
||||
int completed = 0, succeded = 0, failed = 0;
|
||||
auto* root_item = new StandardServiceRoot();
|
||||
QNetworkProxy custom_proxy;
|
||||
@ -347,7 +348,8 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
||||
succeded++;
|
||||
add_offline_anyway = false;
|
||||
}
|
||||
} catch (const ApplicationException& ex) {
|
||||
}
|
||||
catch (const ApplicationException& ex) {
|
||||
qCriticalNN << LOGSEC_CORE << "Cannot fetch medatada for feed:" << QUOTE_W_SPACE(url)
|
||||
<< "with error:" << QUOTE_W_SPACE_DOT(ex.message());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user