New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove "default_host" profile #2950
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
96a23b4
Wrap addHost into mudlet::addHost()
vadi2 df67e26
Clean up comments
vadi2 77e8713
Merge remote-tracking branch 'origin/development' into remove-default…
vadi2 b5193b0
Pruning of default_profile usage - wip
vadi2 b41ee73
Update "first Mudlet launch ever" random profile selection
vadi2 fbfb807
Typo fix
vadi2 11b95b4
Review feedback
vadi2 bc5ea65
Merge remote-tracking branch 'origin/development' into remove-default…
vadi2 083927b
Review feedback
vadi2 b6445a1
Emit signal properly
vadi2 bb823ac
Fix crash when re-opening central debug console from another profile
vadi2 908ced4
Improve function definition
vadi2 bd05cef
Fix crash
vadi2 b5a9afa
Merge remote-tracking branch 'origin/development' into remove-default…
vadi2 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1189,8 +1189,7 @@ void dlgConnectionProfiles::fillout_form() { | |
mProfileList = QDir(mudlet::getMudletPath(mudlet::profilesPath)).entryList(QDir::Dirs | QDir::NoDotAndDotDot, | ||
QDir::Name); | ||
|
||
// if only the default_host is present it means no profiles have yet been created | ||
if (mProfileList.isEmpty() || (mProfileList.size() == 1 && mProfileList.at(0) == QStringLiteral("default_host"))) { | ||
if (mProfileList.isEmpty()) { | ||
welcome_message->show(); | ||
requiredArea->hide(); | ||
informationalArea->hide(); | ||
|
@@ -1604,13 +1603,7 @@ void dlgConnectionProfiles::fillout_form() { | |
#if defined(QT_DEBUG) | ||
mudServer = QStringLiteral("Mudlet self-test"); | ||
if (!deletedDefaultMuds.contains(mudServer) && !mProfileList.contains(mudServer)) { | ||
for (int i = mProfileList.size() - 1; i >= 0; --i) { | ||
if (mProfileList.at(i) == QLatin1String("default_host")) { | ||
mProfileList.insert(i, mudServer); | ||
break; | ||
} | ||
} | ||
|
||
mProfileList.append(mudServer); | ||
pM = new QListWidgetItem(mudServer); | ||
pM->setFont(font); | ||
pM->setForeground(QColor(Qt::white)); | ||
|
@@ -1628,36 +1621,36 @@ void dlgConnectionProfiles::fillout_form() { | |
QString toselectProfileName; | ||
int toselectRow = -1; | ||
int test_profile_row = -1; | ||
bool firstMudletLaunch = true; | ||
|
||
for (int i = 0; i < profiles_tree_widget->count(); i++) { | ||
auto profile = profiles_tree_widget->item(i); | ||
auto profileName = profile->text(); | ||
const auto profile = profiles_tree_widget->item(i); | ||
const auto profileName = profile->text(); | ||
if (profileName == QStringLiteral("Mudlet self-test")) { | ||
test_profile_row = i; | ||
} | ||
|
||
QDateTime profile_lastRead = QFileInfo( | ||
mudlet::getMudletPath(mudlet::profileXmlFilesPath, profileName)).lastModified(); | ||
// Since Qt 5.x null QTimes and QDateTimes are invalid - and might not | ||
// work as expected - so test for validity of the test_date value as well | ||
if ((!test_date.isValid()) || profile_lastRead > test_date) { | ||
test_date = profile_lastRead; | ||
toselectProfileName = profileName; | ||
toselectRow = i; | ||
const auto fileinfo = QFileInfo( | ||
mudlet::getMudletPath(mudlet::profileXmlFilesPath, profileName)); | ||
|
||
if (fileinfo.exists()) { | ||
firstMudletLaunch = false; | ||
QDateTime profile_lastRead = fileinfo.lastModified(); | ||
// Since Qt 5.x null QTimes and QDateTimes are invalid - and might not | ||
// work as expected - so test for validity of the test_date value as well | ||
if ((!test_date.isValid()) || profile_lastRead > test_date) { | ||
test_date = profile_lastRead; | ||
toselectProfileName = profileName; | ||
toselectRow = i; | ||
} | ||
} | ||
} | ||
|
||
if (toselectRow != -1 && toselectProfileName == QStringLiteral("default_host") && | ||
profiles_tree_widget->count() > 1) { | ||
// if the last profile read is default_host, it means the user hasn't created | ||
// any profiles yet since default_host profile cannot actually be used. In this case, | ||
// select a random pre-defined profile to give all MUDs a fair go | ||
|
||
// make sure not to select the default_host or test_profile though | ||
auto default_host_row = toselectRow; | ||
// dont infinite loop. | ||
if (test_profile_row == -1 || profiles_tree_widget->count() != 2) { | ||
while (toselectRow == default_host_row || toselectRow == test_profile_row) { | ||
if (firstMudletLaunch) { | ||
// Select a random pre-defined profile to give all MUDs a fair go first time | ||
// make sure not to select the test_profile though | ||
if (profiles_tree_widget->count() != 1) { | ||
while (toselectRow == -1 || toselectRow == test_profile_row) { | ||
toselectRow = qrand() % profiles_tree_widget->count(); | ||
} | ||
} | ||
|
@@ -2028,7 +2021,7 @@ void dlgConnectionProfiles::loadProfile(bool alsoConnect) | |
} | ||
// load an old profile if there is any | ||
// PLACEMARKER: Host creation (3) - normal case | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revise the number down now that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
if (hostManager.addHost(profile_name, port_entry->text().trimmed(), QString(), QString())) { | ||
if (mudlet::self()->addHost(profile_name, port_entry->text().trimmed(), QString(), QString())) { | ||
pHost = hostManager.getHost(profile_name); | ||
if (!pHost) { | ||
return; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never seen this syntax before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've used it in a few places in Mudlet now. It creates
dictionaryChanged
and sets it to a default value you'd expect. If you just dobool dictionaryChanged;
the value could be random because one wasn't given (it basically doesn't do anything at all to set one).Technical term is "braced intializer", unfortunately all resources I could find from a quick search weren't an easy read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses the default constructor IIRC - in the same manner as it would be for a member in a class's constructor's initialization list, e.g. if
dictionaryChanged
was a member then this would do the same as:would do in the initialization list.
Arguments can also be provided for the constructor of more complex items - and even
bool
s can be initialized to the non-default valuetrue
with: