Browse Source

Merge pull request #17416 from Chocobo1/icon

Split code to smaller functions
adaptive-webui-19844
Chocobo1 2 years ago committed by GitHub
parent
commit
36bc77e2e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      src/gui/fspathedit.cpp
  2. 1711
      src/gui/optionsdialog.cpp
  3. 36
      src/gui/optionsdialog.h
  4. 1
      src/gui/torrentcontentmodel.cpp

38
src/gui/fspathedit.cpp

@ -70,6 +70,7 @@ class FileSystemPathEdit::FileSystemPathEditPrivate @@ -70,6 +70,7 @@ class FileSystemPathEdit::FileSystemPathEditPrivate
Q_DECLARE_PUBLIC(FileSystemPathEdit)
Q_DISABLE_COPY_MOVE(FileSystemPathEditPrivate)
private:
FileSystemPathEditPrivate(FileSystemPathEdit *q, Private::IFileEditorWithCompletion *editor);
void modeChanged();
@ -81,7 +82,7 @@ class FileSystemPathEdit::FileSystemPathEditPrivate @@ -81,7 +82,7 @@ class FileSystemPathEdit::FileSystemPathEditPrivate
QAction *m_browseAction = nullptr;
QToolButton *m_browseBtn = nullptr;
QString m_fileNameFilter;
Mode m_mode;
Mode m_mode = FileSystemPathEdit::Mode::FileOpen;
Path m_lastSignaledPath;
QString m_dialogCaption;
Private::FileSystemPathValidator *m_validator = nullptr;
@ -91,20 +92,22 @@ FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate( @@ -91,20 +92,22 @@ FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate(
FileSystemPathEdit *q, Private::IFileEditorWithCompletion *editor)
: q_ptr {q}
, m_editor {editor}
, m_browseAction {new QAction(q)}
, m_browseAction {new QAction(QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon), browseButtonFullText.tr(), q)}
, m_browseBtn {new QToolButton(q)}
, m_mode {FileSystemPathEdit::Mode::FileOpen}
, m_fileNameFilter {tr("Any file") + u" (*)"}
, m_validator {new Private::FileSystemPathValidator(q)}
{
m_browseAction->setIconText(browseButtonBriefText.tr());
m_browseAction->setText(browseButtonFullText.tr());
m_browseAction->setToolTip(browseButtonFullText.tr().remove(u'&'));
m_browseAction->setShortcut(Qt::CTRL + Qt::Key_B);
m_browseAction->setToolTip(browseButtonFullText.tr().remove(u'&'));
m_browseBtn->setDefaultAction(m_browseAction);
m_fileNameFilter = tr("Any file") + u" (*)";
m_editor->setBrowseAction(m_browseAction);
m_validator->setStrictMode(false);
m_editor->setBrowseAction(m_browseAction);
m_editor->setValidator(m_validator);
modeChanged();
}
@ -160,22 +163,7 @@ QString FileSystemPathEdit::FileSystemPathEditPrivate::dialogCaptionOrDefault() @@ -160,22 +163,7 @@ QString FileSystemPathEdit::FileSystemPathEditPrivate::dialogCaptionOrDefault()
void FileSystemPathEdit::FileSystemPathEditPrivate::modeChanged()
{
bool showDirsOnly = false;
switch (m_mode)
{
case FileSystemPathEdit::Mode::FileOpen:
case FileSystemPathEdit::Mode::FileSave:
showDirsOnly = false;
break;
case FileSystemPathEdit::Mode::DirectoryOpen:
case FileSystemPathEdit::Mode::DirectorySave:
showDirsOnly = true;
break;
default:
throw std::logic_error("Unknown FileSystemPathEdit mode");
}
m_browseAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon));
m_editor->completeDirectoriesOnly(showDirsOnly);
m_editor->completeDirectoriesOnly((m_mode == FileSystemPathEdit::Mode::DirectoryOpen) || (m_mode == FileSystemPathEdit::Mode::DirectorySave));
m_validator->setExistingOnly(m_mode != FileSystemPathEdit::Mode::FileSave);
m_validator->setDirectoriesOnly((m_mode == FileSystemPathEdit::Mode::DirectoryOpen) || (m_mode == FileSystemPathEdit::Mode::DirectorySave));
@ -297,10 +285,10 @@ FileSystemPathEdit::Mode FileSystemPathEdit::mode() const @@ -297,10 +285,10 @@ FileSystemPathEdit::Mode FileSystemPathEdit::mode() const
return d->m_mode;
}
void FileSystemPathEdit::setMode(FileSystemPathEdit::Mode theMode)
void FileSystemPathEdit::setMode(const Mode mode)
{
Q_D(FileSystemPathEdit);
d->m_mode = theMode;
d->m_mode = mode;
d->modeChanged();
}

1711
src/gui/optionsdialog.cpp

File diff suppressed because it is too large Load Diff

36
src/gui/optionsdialog.h

@ -103,19 +103,45 @@ private slots: @@ -103,19 +103,45 @@ private slots:
void on_addWatchedFolderButton_clicked();
void on_editWatchedFolderButton_clicked();
void on_removeWatchedFolderButton_clicked();
void on_registerDNSBtn_clicked();
void setLocale(const QString &localeStr);
#ifndef DISABLE_WEBUI
void webUIHttpsCertChanged(const Path &path);
void webUIHttpsKeyChanged(const Path &path);
void on_registerDNSBtn_clicked();
#endif
private:
void showEvent(QShowEvent *e) override;
// Methods
void saveOptions();
void loadOptions();
void initializeLanguageCombo();
void saveOptions() const;
void loadBehaviorTabOptions();
void saveBehaviorTabOptions() const;
void loadDownloadsTabOptions();
void saveDownloadsTabOptions() const;
void loadConnectionTabOptions();
void saveConnectionTabOptions() const;
void loadSpeedTabOptions();
void saveSpeedTabOptions() const;
void loadBittorrentTabOptions();
void saveBittorrentTabOptions() const;
void loadRSSTabOptions();
void saveRSSTabOptions() const;
#ifndef DISABLE_WEBUI
void loadWebUITabOptions();
void saveWebUITabOptions() const;
#endif // DISABLE_WEBUI
// General options
void initializeLanguageCombo();
QString getLocale() const;
bool startMinimized() const;
bool isSplashScreenDisabled() const;
@ -158,11 +184,13 @@ private: @@ -158,11 +184,13 @@ private:
int getMaxActiveUploads() const;
int getMaxActiveTorrents() const;
// WebUI
#ifndef DISABLE_WEBUI
bool isWebUiEnabled() const;
QString webUiUsername() const;
QString webUiPassword() const;
bool webUIAuthenticationOk();
bool isAlternativeWebUIPathValid();
#endif
bool schedTimesOk();

1
src/gui/torrentcontentmodel.cpp

@ -199,6 +199,7 @@ TorrentContentModel::TorrentContentModel(QObject *parent) @@ -199,6 +199,7 @@ TorrentContentModel::TorrentContentModel(QObject *parent)
, m_fileIconProvider {doesQFileIconProviderWork() ? new QFileIconProvider : new MimeFileIconProvider}
#endif
{
m_fileIconProvider->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
}
TorrentContentModel::~TorrentContentModel()

Loading…
Cancel
Save